-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
3,436 additions
and
2,358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<script lang="ts" setup> | ||
//https://github.com/bcakmakoglu/vue-flow/blob/master/docs/components/DocsRepl.vue | ||
import type { SFCOptions } from '@vue/repl'; | ||
import { ReplStore, Repl as VueRepl } from '@vue/repl'; | ||
import '@vue/repl/style.css'; | ||
import { exampleImports } from '../examples'; | ||
import CodeMirror from '@vue/repl/codemirror-editor'; | ||
import Diagram from '../../src/index'; | ||
const props = defineProps<{ | ||
example: keyof typeof exampleImports; | ||
mainFile?: string; | ||
dependencies?: Record<string, string> } | ||
>() | ||
let css = ''; | ||
const store = new ReplStore({ | ||
showOutput: true, | ||
outputMode: 'preview', | ||
}) | ||
const files: Record<string, (typeof imports)[keyof typeof imports]> = {} | ||
const imports = exampleImports[props.example] | ||
const additionalImports: Object = ('additionalImports' in imports ? imports.additionalImports : {}) as Object; | ||
for (const example of Object.keys(imports).filter((i) => i !== 'additionalImports')) { | ||
if (example.includes('css')) { | ||
css += `${imports[example as keyof typeof imports]}` | ||
} else { | ||
files[example] = imports[example as keyof typeof imports] | ||
} | ||
} | ||
await store.setVueVersion('3.2.37') | ||
await store.setFiles( | ||
{ | ||
...files, | ||
'main.css': css, | ||
}, | ||
props.mainFile ?? 'App.vue', | ||
) | ||
// pre-set import map | ||
const diagram = | ||
store.setImportMap({ | ||
imports: { | ||
'vue-diagrams': 'https://unpkg.com/vue-diagrams@latest', | ||
...additionalImports, | ||
}, | ||
} as any); | ||
</script> | ||
|
||
<template> | ||
<VueRepl | ||
:clear-console="true" | ||
:editor="CodeMirror" | ||
:auto-resize="true" | ||
:store="store" | ||
:show-compile-output="false" | ||
:show-import-map="false" | ||
@keydown.ctrl.s.prevent | ||
@keydown.meta.s.prevent | ||
/> | ||
</template> | ||
|
||
<style> | ||
.file-selector { | ||
} | ||
.vue-repl { | ||
--vh: 100vh; | ||
margin-top: 52px; | ||
height: calc(var(--vh) - 72px); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PlaygroundApp } from './playground' | ||
|
||
export const exampleImports = { | ||
playground: { | ||
'App.vue': PlaygroundApp, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<diagram :model="model" height="700" /> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Diagram } from "vue-diagrams"; | ||
export default { | ||
components: { | ||
Diagram, | ||
}, | ||
data() { | ||
const diagramModel = new Diagram.Model(); | ||
const node1 = diagramModel.addNode("test2", 300, 200); | ||
const inPort = node1.addInPort("test"); | ||
const node2 = diagramModel.addNode("test", 10, 300, 144, 80); | ||
const node2OutPort = node2.addOutPort("testOut"); | ||
node2.addOutPort("testOut2"); | ||
node2.color = "#00cc66"; | ||
const node3 = diagramModel.addNode("test3", 10, 100, 72, 100); | ||
const node3OutPort = node3.addOutPort("testOut3"); | ||
node3.color = "#cc6600"; | ||
node3.deletable = false; | ||
diagramModel.addLink(node2OutPort, inPort); | ||
diagramModel.addLink(node3OutPort, inPort); | ||
return { | ||
model: diagramModel | ||
}; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as PlaygroundApp } from './App.vue?raw' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<template> | ||
<div> | ||
Playground page | ||
<client-only placeholder="Loading..."> | ||
<Repl example="playground" /> | ||
</client-only> | ||
</div> | ||
</template> | ||
<script lang="ts"> | ||
import Repl from '../components/Repl.vue'; | ||
export default { | ||
components: { | ||
Repl, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"exclude": [ | ||
"node_modules", | ||
"dist" | ||
], | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"target": "es2017", | ||
"lib": [ | ||
"DOM", | ||
"ESNext" | ||
], | ||
"preserveSymlinks": true, | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"incremental": false, | ||
"skipLibCheck": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"noUnusedLocals": false, | ||
"strictNullChecks": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"jsx": "preserve", | ||
"baseUrl": ".", | ||
"types": [ | ||
"vite/client", | ||
"@types/node" | ||
] | ||
} | ||
} |
Oops, something went wrong.