@draftably/editor 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +4 -5
  2. package/dist/assets/{engine.worker-DmHew5f6.js → engine.worker-DwN9io_m.js} +2765 -2722
  3. package/dist/element.js +1 -1
  4. package/dist/index.js +19553 -2
  5. package/dist/types/src/components/controls.d.ts +8 -5
  6. package/dist/types/src/state/canvas-commands.d.ts +169 -0
  7. package/dist/types/src/state/canvas-keyboard.d.ts +15 -0
  8. package/dist/types/src/state/links.d.ts +4 -1
  9. package/dist/types/src/state/workspace.d.ts +3 -0
  10. package/package.json +1 -1
  11. package/dist/assets/import-d2.worker-CnXfFXoa.js +0 -5395
  12. package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +0 -87
  13. package/dist/chunks/arc-rJj0TtXf.js +0 -83
  14. package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +0 -4781
  15. package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +0 -1440
  16. package/dist/chunks/browser-iNhbPsGc.js +0 -40
  17. package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +0 -1524
  18. package/dist/chunks/channel-qMvPU6eH.js +0 -5
  19. package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +0 -670
  20. package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +0 -18
  21. package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +0 -262
  22. package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +0 -68
  23. package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +0 -19
  24. package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +0 -8
  25. package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +0 -19
  26. package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +0 -8
  27. package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +0 -451
  28. package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +0 -1570
  29. package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +0 -2608
  30. package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +0 -22361
  31. package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +0 -299
  32. package/dist/chunks/cytoscape.esm-CRsF_JA3.js +0 -18791
  33. package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +0 -2157
  34. package/dist/chunks/defaultLocale-BgPVtth8.js +0 -171
  35. package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +0 -531
  36. package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +0 -153
  37. package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +0 -346
  38. package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +0 -480
  39. package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +0 -219
  40. package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +0 -2586
  41. package/dist/chunks/dot-importer-B23jwEkx.js +0 -1547
  42. package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +0 -109
  43. package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +0 -49229
  44. package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +0 -1064
  45. package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +0 -1771
  46. package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +0 -2729
  47. package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +0 -815
  48. package/dist/chunks/graph-CKJmgLki.js +0 -1541
  49. package/dist/chunks/import-core-C-I1wGfw.js +0 -145
  50. package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +0 -24
  51. package/dist/chunks/init-DjUOC4st.js +0 -16
  52. package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +0 -624
  53. package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +0 -834
  54. package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +0 -724
  55. package/dist/chunks/katex-BsrBVQKd.js +0 -11314
  56. package/dist/chunks/linear-4t7D_ros.js +0 -259
  57. package/dist/chunks/mermaid-facade-BoLWBerE.js +0 -289
  58. package/dist/chunks/mermaid-importer-Cgx1IhmR.js +0 -478
  59. package/dist/chunks/mermaid.core-DXv6D2Sm.js +0 -19244
  60. package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +0 -837
  61. package/dist/chunks/mount-C1Xk_GQz.js +0 -22131
  62. package/dist/chunks/ordinal-DfAQgscy.js +0 -61
  63. package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +0 -95
  64. package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +0 -208
  65. package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +0 -1029
  66. package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +0 -77
  67. package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +0 -889
  68. package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +0 -859
  69. package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +0 -2972
  70. package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +0 -46
  71. package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +0 -1520
  72. package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +0 -4991
  73. package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +0 -13
  74. package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +0 -1058
  75. package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +0 -7945
  76. package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +0 -1578
  77. package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +0 -678
  78. package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +0 -1536
  79. package/dist/types/src/import/browser.d.ts +0 -3
  80. package/dist/types/src/import/detect.d.ts +0 -31
  81. package/dist/types/src/import/dot-importer.d.ts +0 -3
  82. package/dist/types/src/import/import-core.d.ts +0 -105
  83. package/dist/types/src/import/mermaid-facade.d.ts +0 -120
  84. package/dist/types/src/import/mermaid-importer.d.ts +0 -4
  85. package/dist/types/src/import/mermaid-sequence.d.ts +0 -8
  86. package/dist/types/src/import/scratch.d.ts +0 -3
  87. package/dist/types/src/lib/source-hash.d.ts +0 -7
  88. package/dist/types/src/model/candidates.d.ts +0 -53
  89. package/dist/types/src/model/examples.d.ts +0 -15
  90. package/dist/types/src/model/label-hits.d.ts +0 -27
  91. package/dist/types/src/model/static-scene.d.ts +0 -15
  92. package/dist/types/src/state/commands.d.ts +0 -529
  93. package/dist/types/src/state/comparison.d.ts +0 -151
  94. package/dist/types/src/state/files.d.ts +0 -61
  95. package/dist/types/src/state/keyboard.d.ts +0 -6
  96. package/dist/types/src/state/launch.d.ts +0 -61
  97. package/dist/types/src/state/ui.d.ts +0 -39
@@ -1,6 +1,6 @@
1
1
  /** Small form and button primitives shared by panels, menus and dialogs. */
2
2
  import { type JSX } from 'solid-js';
3
- import { type CommandId } from '../state/commands';
3
+ import type { Command } from '../state/canvas-commands';
4
4
  /** Attributes that give an element the shared tooltip. See `Tips`. */
5
5
  export declare const tip: (label: string, keys?: string, hint?: string) => {
6
6
  'data-tip': string;
@@ -20,12 +20,15 @@ export declare function IconButton(props: {
20
20
  pressed?: boolean;
21
21
  variant?: 'ghost' | 'primary';
22
22
  } & Omit<JSX.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>): JSX.Element;
23
- /** An icon button that runs a command and explains itself from the command's own words. */
24
- export declare function CommandButton(props: {
25
- command: CommandId;
23
+ /**
24
+ * An icon button for one table of commands: it runs a command and explains itself from the
25
+ * command's own words.
26
+ */
27
+ export declare const commandButton: <Id extends string>(table: Record<Id, Command>, run: (id: Id) => void, enabled: (id: Id) => boolean) => (props: {
28
+ command: Id;
26
29
  label?: string;
27
30
  pressed?: boolean;
28
- }): JSX.Element;
31
+ }) => JSX.Element;
29
32
  /** Text with each word of a query marked where it matches. */
30
33
  export declare function Highlight(props: {
31
34
  text: string;
@@ -0,0 +1,169 @@
1
+ export interface Command {
2
+ label: string;
3
+ /** Shortcut shown in menus. */
4
+ keys?: string;
5
+ icon?: string;
6
+ /** What it does, in a sentence: shown in tooltips and the palette. */
7
+ hint?: string;
8
+ run: () => unknown;
9
+ /** Allowed while a timeline preview is open. */
10
+ duringTimeline?: boolean;
11
+ /** Exits the brush before running. */
12
+ endsBrush?: boolean;
13
+ enabled?: () => boolean;
14
+ /** Why this cannot work here, shown instead of running it. */
15
+ blocked?: () => string | null;
16
+ }
17
+ declare function undoCommand(): void;
18
+ declare function redoCommand(): void;
19
+ export declare const hasSelection: () => boolean;
20
+ export declare const canvasCommands: {
21
+ undo: {
22
+ hint: string;
23
+ label: string;
24
+ keys: string;
25
+ icon: string;
26
+ run: typeof undoCommand;
27
+ duringTimeline: true;
28
+ enabled: () => boolean;
29
+ };
30
+ redo: {
31
+ hint: string;
32
+ label: string;
33
+ keys: string;
34
+ icon: string;
35
+ run: typeof redoCommand;
36
+ enabled: () => boolean;
37
+ };
38
+ 'add-node': {
39
+ hint: string;
40
+ label: string;
41
+ keys: string;
42
+ icon: string;
43
+ run: () => void;
44
+ };
45
+ 'add-connected': {
46
+ hint: string;
47
+ label: string;
48
+ keys: string;
49
+ icon: string;
50
+ run: () => string | undefined;
51
+ };
52
+ duplicate: {
53
+ hint: string;
54
+ enabled: () => boolean;
55
+ label: string;
56
+ keys: string;
57
+ icon: string;
58
+ run: () => void;
59
+ };
60
+ group: {
61
+ hint: string;
62
+ enabled: () => boolean;
63
+ label: string;
64
+ keys: string;
65
+ icon: string;
66
+ run: () => string;
67
+ };
68
+ ungroup: {
69
+ hint: string;
70
+ enabled: () => boolean;
71
+ label: string;
72
+ keys: string;
73
+ run: () => void;
74
+ };
75
+ pin: {
76
+ hint: string;
77
+ enabled: () => boolean;
78
+ label: string;
79
+ keys: string;
80
+ icon: string;
81
+ run: () => void;
82
+ };
83
+ delete: {
84
+ hint: string;
85
+ label: string;
86
+ enabled: () => boolean;
87
+ keys: string;
88
+ icon: string;
89
+ run: () => void;
90
+ };
91
+ 'delete-deep': {
92
+ label: string;
93
+ keys: string;
94
+ run: () => void;
95
+ };
96
+ layout: {
97
+ hint: string;
98
+ label: string;
99
+ keys: string;
100
+ icon: string;
101
+ run: () => Promise<import("./session/layout").LayoutOutcome>;
102
+ blocked: () => string | null;
103
+ endsBrush: true;
104
+ };
105
+ 'layout-rebuild': {
106
+ hint: string;
107
+ label: string;
108
+ keys: string;
109
+ run: () => Promise<import("./session/layout").LayoutOutcome>;
110
+ blocked: () => string | null;
111
+ endsBrush: true;
112
+ };
113
+ 'layout-accept': {
114
+ label: string;
115
+ run: () => void;
116
+ };
117
+ 'layout-discard': {
118
+ label: string;
119
+ run: () => void;
120
+ };
121
+ reroute: {
122
+ hint: string;
123
+ label: string;
124
+ keys: string;
125
+ icon: string;
126
+ run: () => void;
127
+ };
128
+ 'auto-ports': {
129
+ hint: string;
130
+ label: string;
131
+ keys: string;
132
+ run: () => void;
133
+ };
134
+ fit: {
135
+ hint: string;
136
+ label: string;
137
+ keys: string;
138
+ icon: string;
139
+ run: () => void;
140
+ duringTimeline: true;
141
+ };
142
+ 'zoom-in': {
143
+ label: string;
144
+ keys: string;
145
+ icon: string;
146
+ run: () => void;
147
+ duringTimeline: true;
148
+ };
149
+ 'zoom-out': {
150
+ label: string;
151
+ keys: string;
152
+ icon: string;
153
+ run: () => void;
154
+ duringTimeline: true;
155
+ };
156
+ 'reset-camera': {
157
+ label: string;
158
+ keys: string;
159
+ run: () => void;
160
+ duringTimeline: true;
161
+ };
162
+ };
163
+ export type CanvasCommandId = keyof typeof canvasCommands;
164
+ /** Run `command` unless a timeline preview or its own check blocks it, reporting failures. */
165
+ export declare function runChecked(id: string, command: Command): undefined;
166
+ export declare const checkedEnabled: (command: Command) => boolean;
167
+ export declare const runCanvasCommand: (id: CanvasCommandId) => undefined;
168
+ export declare const canvasCommandEnabled: (id: CanvasCommandId) => boolean;
169
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Canvas shortcuts and shape copy and paste for the active session. The app runs its own keys
3
+ * around these in `keyboard.ts`; an embedded editor uses them as they are.
4
+ */
5
+ export declare const isEditable: (el: EventTarget | null) => boolean;
6
+ /**
7
+ * Run the canvas shortcut for `e`. True when the key was used, or belongs to a field, so the host
8
+ * should not act on it. `closeMenu` lets Escape close the host's open menu, before it clears the
9
+ * selection; it returns true when it closed one.
10
+ */
11
+ export declare function handleCanvasKey(e: KeyboardEvent, closeMenu?: () => boolean): boolean;
12
+ export declare function handleKeyUp(e: KeyboardEvent): void;
13
+ export declare function copyShapes(e: ClipboardEvent): void;
14
+ /** Paste copied shapes: from the clipboard text, or the session's own copy when it is empty. */
15
+ export declare function pasteShapes(e: ClipboardEvent): void;
@@ -4,8 +4,11 @@ import type { DiagramSession } from './session';
4
4
  * Null when no file on disk is open.
5
5
  */
6
6
  export declare function linkBase(s: DiagramSession): string | null;
7
+ /** `href` joined to a URL `link-base`, or null. */
8
+ export declare const joined: (s: DiagramSession, href: string) => string | null;
7
9
  /** What opening `href` does, for a tooltip or the Inspector. */
8
10
  export declare function describeLink(s: DiagramSession, href: string): string;
11
+ /** A path inside the served folder, relative to it, or null. */
12
+ export declare function servedPath(file: string): string | null;
9
13
  /** A link as an exported SVG carries it: file paths from the diagram's folder, URLs as written. */
10
14
  export declare function exportHref(s: DiagramSession, href: string): string;
11
- export declare function openLink(s: DiagramSession, href: string): void;
@@ -0,0 +1,3 @@
1
+ import type { WorkspaceInfo } from '../server/workspace';
2
+ /** The served folder, or null on the static site and in an embedded editor. */
3
+ export declare const workspace: import("solid-js").Accessor<WorkspaceInfo | null>, setWorkspace: import("solid-js").Setter<WorkspaceInfo | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftably/editor",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The Draftably diagram editor: drag boxes and lines, and get the .draft source back.",
5
5
  "license": "MIT",
6
6
  "type": "module",