From e6c66902969439d932f949fb39dcd0128ed44f98 Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin Date: Fri, 3 Nov 2023 22:20:43 +0800 Subject: [PATCH] feat: use typst repr in cetz editor --- projects/cetz-editor/definitions.typ | 21 + projects/cetz-editor/definitions.yaml | 43 -- projects/cetz-editor/index.html | 564 +++++++++++++------------ projects/cetz-editor/src/global.d.mts | 1 + projects/cetz-editor/src/index.mts | 583 +++++++++++++++++++++++++- projects/cetz-editor/typst-style.css | 8 +- 6 files changed, 888 insertions(+), 332 deletions(-) create mode 100644 projects/cetz-editor/definitions.typ delete mode 100644 projects/cetz-editor/definitions.yaml diff --git a/projects/cetz-editor/definitions.typ b/projects/cetz-editor/definitions.typ new file mode 100644 index 00000000..21b545ec --- /dev/null +++ b/projects/cetz-editor/definitions.typ @@ -0,0 +1,21 @@ + +#let x-circle(rad: 200, inner-text: "") = { + circle((0, 0), radius: rad, name: node-label) + debug-label((-rad*0.7, -rad*0.7)) + content(node-label, inner-text) +} +#let x-rect(x: 200, y: none, inner-text: "") = { + let y = if y == none { + x + } else { + y + } + rect((0, 0), (x, y), name: node-label) + debug-label((0, 0)) + content(node-label, inner-text) +} +#let x-arrow(start: (0, 10), end: (50, 10), inner-text: "", mark: (end: ">")) = { + set-style(mark: (fill: none, size: 14)) + line(start, end, name: "t", mark: mark) + content("t", inner-text) +} \ No newline at end of file diff --git a/projects/cetz-editor/definitions.yaml b/projects/cetz-editor/definitions.yaml deleted file mode 100644 index 445a1ce1..00000000 --- a/projects/cetz-editor/definitions.yaml +++ /dev/null @@ -1,43 +0,0 @@ -definitions: - - id: x-circle - props: # default props - rad: 200 - inner-text: '""' - draw: | - { - circle((0, 0), radius: rad, name: node-label) - debug-label((-rad*0.7, -rad*0.7)) - content(node-label, inner-text) - } - - id: x-rect - props: # default props - x: 200 - y: none - inner-text: '""' - draw: | - { - let y = if y == none { - x - } else { - y - } - rect((0, 0), (x, y), name: node-label) - debug-label((0, 0)) - content(node-label, inner-text) - - } - - id: x-arrow - props: # default props - start: (0, 10) - end: (50, 10) - inner-text: '""' - mark: | - (end: ">") - draw: | - { - set-style(mark: (fill: none, size: 7)) - line(start, end, name: "t", mark: mark) - content("t", inner-text) - } -width: 600pt -height: 600pt diff --git a/projects/cetz-editor/index.html b/projects/cetz-editor/index.html index 0cf35abb..e0352b1a 100644 --- a/projects/cetz-editor/index.html +++ b/projects/cetz-editor/index.html @@ -2,299 +2,319 @@ - - - - Cetz Editor - - - - - + + + + Cetz Editor + + + + -
-
-
- -
- SVG - PDF - CeTZ - Element +
+
+
+ +
+ SVG + PDF + CeTZ + Element +
+
-
-
-
-
-
-
-
-
- definition: - -
-
- element: -
+
+
+
+
+
+ definition: + + from +
- - - + + +
+
+
+ element: +
+ + + +
+
+
+ viewport: + + · + +
+
+
+
+
+
+
+
+
+
+
-
-
- viewport: - - · - -
-
-
-
-
-
-
-
-
-
-
-
- -