@draftably/editor 0.0.0-stage → 0.1.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.
- package/README.md +26 -2
- package/dist/LICENSE +21 -0
- package/dist/assets/engine.worker-DmHew5f6.js +6813 -0
- package/dist/assets/import-d2.worker-CnXfFXoa.js +5395 -0
- package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +87 -0
- package/dist/chunks/arc-rJj0TtXf.js +83 -0
- package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +4781 -0
- package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +1440 -0
- package/dist/chunks/browser-iNhbPsGc.js +40 -0
- package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +1524 -0
- package/dist/chunks/channel-qMvPU6eH.js +5 -0
- package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +670 -0
- package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +18 -0
- package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +262 -0
- package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +68 -0
- package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +19 -0
- package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +8 -0
- package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +19 -0
- package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +8 -0
- package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +451 -0
- package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +1570 -0
- package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +2608 -0
- package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +22361 -0
- package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +299 -0
- package/dist/chunks/cytoscape.esm-CRsF_JA3.js +18791 -0
- package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +2157 -0
- package/dist/chunks/defaultLocale-BgPVtth8.js +171 -0
- package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +531 -0
- package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +153 -0
- package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +346 -0
- package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +480 -0
- package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +219 -0
- package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +2586 -0
- package/dist/chunks/dot-importer-B23jwEkx.js +1547 -0
- package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +109 -0
- package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +49229 -0
- package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +1064 -0
- package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +1771 -0
- package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +2729 -0
- package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +815 -0
- package/dist/chunks/graph-CKJmgLki.js +1541 -0
- package/dist/chunks/import-core-C-I1wGfw.js +145 -0
- package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +24 -0
- package/dist/chunks/init-DjUOC4st.js +16 -0
- package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +624 -0
- package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +834 -0
- package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +724 -0
- package/dist/chunks/katex-BsrBVQKd.js +11314 -0
- package/dist/chunks/linear-4t7D_ros.js +259 -0
- package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
- package/dist/chunks/mermaid-importer-Cgx1IhmR.js +478 -0
- package/dist/chunks/mermaid.core-DXv6D2Sm.js +19244 -0
- package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +837 -0
- package/dist/chunks/mount-C1Xk_GQz.js +22131 -0
- package/dist/chunks/ordinal-DfAQgscy.js +61 -0
- package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +95 -0
- package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +208 -0
- package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +1029 -0
- package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +77 -0
- package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +889 -0
- package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +859 -0
- package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +2972 -0
- package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +46 -0
- package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +1520 -0
- package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +4991 -0
- package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +13 -0
- package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +1058 -0
- package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +7945 -0
- package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +1578 -0
- package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +678 -0
- package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +1536 -0
- package/dist/element.js +36 -0
- package/dist/index.js +4 -0
- package/dist/types/src/cli/links.d.ts +4 -0
- package/dist/types/src/cli/pdf.d.ts +29 -0
- package/dist/types/src/cli/png.d.ts +23 -0
- package/dist/types/src/cli/svg.d.ts +4 -0
- package/dist/types/src/components/Icon.d.ts +14 -0
- package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
- package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
- package/dist/types/src/components/canvas/Frame.d.ts +22 -0
- package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
- package/dist/types/src/components/canvas/Notes.d.ts +5 -0
- package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
- package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
- package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
- package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
- package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
- package/dist/types/src/components/controls.d.ts +88 -0
- package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
- package/dist/types/src/components/scene/GroupView.d.ts +22 -0
- package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
- package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
- package/dist/types/src/components/scene/NodeView.d.ts +18 -0
- package/dist/types/src/components/scene/parts.d.ts +50 -0
- package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
- package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
- package/dist/types/src/components/session-context.d.ts +486 -0
- package/dist/types/src/dsl/cells.d.ts +91 -0
- package/dist/types/src/dsl/channels.d.ts +53 -0
- package/dist/types/src/dsl/compile.d.ts +162 -0
- package/dist/types/src/dsl/frame.d.ts +38 -0
- package/dist/types/src/dsl/lanes.d.ts +23 -0
- package/dist/types/src/dsl/layout-edits.d.ts +58 -0
- package/dist/types/src/dsl/legend-notes.d.ts +3 -0
- package/dist/types/src/dsl/project.d.ts +39 -0
- package/dist/types/src/dsl/source-edits.d.ts +37 -0
- package/dist/types/src/dsl/syntax.d.ts +317 -0
- package/dist/types/src/dsl/translate.d.ts +69 -0
- package/dist/types/src/editor/Editor.d.ts +6 -0
- package/dist/types/src/editor/element.d.ts +15 -0
- package/dist/types/src/editor/mount.d.ts +23 -0
- package/dist/types/src/import/browser.d.ts +3 -0
- package/dist/types/src/import/detect.d.ts +31 -0
- package/dist/types/src/import/dot-importer.d.ts +3 -0
- package/dist/types/src/import/import-core.d.ts +105 -0
- package/dist/types/src/import/mermaid-facade.d.ts +120 -0
- package/dist/types/src/import/mermaid-importer.d.ts +4 -0
- package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
- package/dist/types/src/import/scratch.d.ts +3 -0
- package/dist/types/src/lib/engine-tasks.d.ts +88 -0
- package/dist/types/src/lib/font-data.d.ts +9 -0
- package/dist/types/src/lib/saved-diagram.d.ts +4 -0
- package/dist/types/src/lib/scene-cache.d.ts +4 -0
- package/dist/types/src/lib/source-hash.d.ts +7 -0
- package/dist/types/src/lib/svg-export.d.ts +15 -0
- package/dist/types/src/model/appearance.d.ts +209 -0
- package/dist/types/src/model/bounds.d.ts +19 -0
- package/dist/types/src/model/camera.d.ts +21 -0
- package/dist/types/src/model/candidates.d.ts +53 -0
- package/dist/types/src/model/colors.d.ts +22 -0
- package/dist/types/src/model/document.d.ts +24 -0
- package/dist/types/src/model/edits.d.ts +133 -0
- package/dist/types/src/model/embed.d.ts +17 -0
- package/dist/types/src/model/examples.d.ts +15 -0
- package/dist/types/src/model/font-faces.d.ts +24 -0
- package/dist/types/src/model/fonts.d.ts +47 -0
- package/dist/types/src/model/footnote.d.ts +34 -0
- package/dist/types/src/model/frame.d.ts +71 -0
- package/dist/types/src/model/geometry.d.ts +29 -0
- package/dist/types/src/model/graph.d.ts +53 -0
- package/dist/types/src/model/heading.d.ts +38 -0
- package/dist/types/src/model/icons.d.ts +2 -0
- package/dist/types/src/model/label-hits.d.ts +27 -0
- package/dist/types/src/model/labels.d.ts +88 -0
- package/dist/types/src/model/legend.d.ts +25 -0
- package/dist/types/src/model/link.d.ts +63 -0
- package/dist/types/src/model/markers.d.ts +47 -0
- package/dist/types/src/model/note.d.ts +75 -0
- package/dist/types/src/model/panels.d.ts +11 -0
- package/dist/types/src/model/rich-text.d.ts +24 -0
- package/dist/types/src/model/routes.d.ts +170 -0
- package/dist/types/src/model/samples.d.ts +11 -0
- package/dist/types/src/model/stack.d.ts +8 -0
- package/dist/types/src/model/static-scene.d.ts +15 -0
- package/dist/types/src/model/status.d.ts +84 -0
- package/dist/types/src/model/styles.d.ts +13 -0
- package/dist/types/src/model/surface.d.ts +31 -0
- package/dist/types/src/model/types.d.ts +277 -0
- package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
- package/dist/types/src/server/file-session.d.ts +19 -0
- package/dist/types/src/server/workspace.d.ts +21 -0
- package/dist/types/src/state/active-session.d.ts +479 -0
- package/dist/types/src/state/commands.d.ts +529 -0
- package/dist/types/src/state/comparison.d.ts +151 -0
- package/dist/types/src/state/files.d.ts +61 -0
- package/dist/types/src/state/keyboard.d.ts +6 -0
- package/dist/types/src/state/keys.d.ts +5 -0
- package/dist/types/src/state/launch.d.ts +61 -0
- package/dist/types/src/state/links.d.ts +11 -0
- package/dist/types/src/state/session/actions.d.ts +77 -0
- package/dist/types/src/state/session/canvas-text.d.ts +24 -0
- package/dist/types/src/state/session/document.d.ts +84 -0
- package/dist/types/src/state/session/editor.d.ts +81 -0
- package/dist/types/src/state/session/emphasis.d.ts +11 -0
- package/dist/types/src/state/session/file-session.d.ts +98 -0
- package/dist/types/src/state/session/index.d.ts +496 -0
- package/dist/types/src/state/session/layout.d.ts +79 -0
- package/dist/types/src/state/session/pointer.d.ts +19 -0
- package/dist/types/src/state/session/routing.d.ts +20 -0
- package/dist/types/src/state/session/scene.d.ts +144 -0
- package/dist/types/src/state/session/sculpt.d.ts +70 -0
- package/dist/types/src/state/toast.d.ts +14 -0
- package/dist/types/src/state/ui.d.ts +39 -0
- package/package.json +41 -3
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { PdfOptions } from '../cli/pdf';
|
|
2
|
+
/** How PNG, SVG and copied images look. The last choice is remembered in this browser. */
|
|
3
|
+
export interface ExportLook {
|
|
4
|
+
/** PNG pixels per drawing pixel. */
|
|
5
|
+
scale: number;
|
|
6
|
+
/** Leave out the canvas color behind the drawing. */
|
|
7
|
+
transparent: boolean;
|
|
8
|
+
/** Draw the title, subtitle and key round the drawing. */
|
|
9
|
+
heading: boolean;
|
|
10
|
+
/** Carry the open file's `.draft` source. */
|
|
11
|
+
source: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const exportLook: import("solid-js").Accessor<ExportLook>;
|
|
14
|
+
export { exportLook };
|
|
15
|
+
export declare function setExportLook(patch: Partial<ExportLook>): void;
|
|
16
|
+
/**
|
|
17
|
+
* Open a PNG or SVG export that carries `.draft` source as a new scratch diagram, which the
|
|
18
|
+
* example bar offers to save as a file. Resolves false when the image carries no source.
|
|
19
|
+
*/
|
|
20
|
+
export declare function openImageSource(file: File): Promise<boolean>;
|
|
21
|
+
export declare const sceneReady: () => boolean;
|
|
22
|
+
export declare const filename: (extension: string) => string;
|
|
23
|
+
/** Open diagram JSON, an editable SVG export, or a saved layout timeline. */
|
|
24
|
+
export declare function importText(text: string, name?: string): Promise<void>;
|
|
25
|
+
/** Embed an image as a new shape, or replace the image in an existing one. */
|
|
26
|
+
export declare function insertImage(file: File, replaceId?: string | null): Promise<void>;
|
|
27
|
+
export declare function openFile(file: File | undefined, replaceImageId?: string | null): Promise<void>;
|
|
28
|
+
/** Convert before switching files; failed or cancelled imports leave the current work in place. */
|
|
29
|
+
export declare function importForeignText(text: string, name?: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Editable SVG: the drawing plus the full diagram in a metadata element. With `onlySelection` and
|
|
32
|
+
* something selected, the image is cropped to the selected objects with a margin and no heading.
|
|
33
|
+
*/
|
|
34
|
+
export declare function exportSvg(look?: ExportLook, onlySelection?: boolean): string;
|
|
35
|
+
/** The files the PDF dialog starts with checked, in order. */
|
|
36
|
+
declare const pdfFiles: import("solid-js").Accessor<string[]>;
|
|
37
|
+
export { pdfFiles };
|
|
38
|
+
/** Open the export dialog on PDF with `paths` chosen. */
|
|
39
|
+
export declare function openPdfExport(paths: string[]): void;
|
|
40
|
+
/**
|
|
41
|
+
* Ask the server for one PDF of `paths` in order, as `draftably pdf` makes it, and download it.
|
|
42
|
+
* Throws with the server's message, such as the file whose errors stopped the export.
|
|
43
|
+
*/
|
|
44
|
+
export declare function exportPdf(paths: string[], opts: PdfOptions): Promise<void>;
|
|
45
|
+
export type ExportFormat = 'json' | 'svg' | 'png';
|
|
46
|
+
export declare function exportDocument(format: ExportFormat, look?: ExportLook, onlySelection?: boolean): Promise<void>;
|
|
47
|
+
/** What Copy puts on the clipboard: every format at once, or one thing as text. */
|
|
48
|
+
export type CopyAs = 'image' | 'svg' | 'source' | 'link';
|
|
49
|
+
/**
|
|
50
|
+
* Copy the diagram, or the selection when something is selected. `image` writes one clipboard item
|
|
51
|
+
* with PNG, SVG, HTML and the SVG markup as text, so the app it is pasted into takes the format it
|
|
52
|
+
* reads; a browser that refuses some of them gets the richest set it accepts, down to PNG alone.
|
|
53
|
+
* The other kinds copy one thing as text.
|
|
54
|
+
*/
|
|
55
|
+
export declare function copyImage(kind?: CopyAs, look?: ExportLook, onlySelection?: boolean): Promise<void>;
|
|
56
|
+
/** Formats the export dialog makes. */
|
|
57
|
+
export type ExportKind = 'png' | 'svg' | 'pdf' | 'copy';
|
|
58
|
+
declare const exportKind: import("solid-js").Accessor<ExportKind>, setExportKind: import("solid-js").Setter<ExportKind>;
|
|
59
|
+
export { exportKind, setExportKind };
|
|
60
|
+
/** Open the export dialog on `kind`. */
|
|
61
|
+
export declare function openExport(kind: ExportKind): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Global keyboard shortcuts and clipboard handling for the editor. */
|
|
2
|
+
export declare function handleKeyDown(e: KeyboardEvent): void | null;
|
|
3
|
+
export declare function handleKeyUp(e: KeyboardEvent): void;
|
|
4
|
+
export declare function handleCopy(e: ClipboardEvent): void;
|
|
5
|
+
/** Paste images, copied objects, diagram JSON, or a list of titles to build from. */
|
|
6
|
+
export declare function handlePaste(e: ClipboardEvent): Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { WorkspaceFile, WorkspaceInfo } from '../server/workspace';
|
|
2
|
+
export type LaunchMode = 'static' | 'start' | 'file' | 'example';
|
|
3
|
+
/** The served folder, or null on the static site. */
|
|
4
|
+
export declare const workspace: import("solid-js").Accessor<WorkspaceInfo | null>;
|
|
5
|
+
/** The start screen shown over the editor (the static site's first run, or File › Start). */
|
|
6
|
+
export declare const startOpen: import("solid-js").Accessor<boolean>;
|
|
7
|
+
export declare const setStartOpen: import("solid-js").Setter<boolean>;
|
|
8
|
+
/** Why the requested file or example could not be opened. */
|
|
9
|
+
export declare const launchNotice: import("solid-js").Accessor<string>;
|
|
10
|
+
/** What the page shows: the start page, or the editor on a file, an example or browser storage. */
|
|
11
|
+
export declare const launchView: import("solid-js").Accessor<LaunchMode>;
|
|
12
|
+
export declare const fileUrl: (path: string) => string;
|
|
13
|
+
export declare const exampleUrl: (id: string) => string;
|
|
14
|
+
export declare const startUrl: () => string;
|
|
15
|
+
/**
|
|
16
|
+
* A page of the public site (docs, the Playground). `draftably open` and the dev server have no
|
|
17
|
+
* site, so their links go to draftably.dev.
|
|
18
|
+
*/
|
|
19
|
+
export declare const siteUrl: (path?: string) => string;
|
|
20
|
+
/** Home: the served folder's start page, or the public site's landing page. */
|
|
21
|
+
export declare const homeUrl: () => string;
|
|
22
|
+
/** The editor was opened from the Playground, as its "Open in the editor" does. */
|
|
23
|
+
export declare const cameFromPlayground: () => boolean;
|
|
24
|
+
/** What happens to the source when it goes to the Playground, said before it goes. */
|
|
25
|
+
export declare function playgroundNote(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Show the current source in the Playground. A file stays open here and the Playground opens in
|
|
28
|
+
* a new tab; an example goes in this tab, since its source is all it has.
|
|
29
|
+
*/
|
|
30
|
+
export declare function openInPlayground(): Promise<undefined>;
|
|
31
|
+
/** List the folder's diagrams again. */
|
|
32
|
+
export declare function refreshWorkspace(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Keep the folder's list current while the page is visible, so diagrams an agent or the command
|
|
35
|
+
* line writes appear without a reload. Returns a function that stops watching.
|
|
36
|
+
*/
|
|
37
|
+
export declare function watchWorkspace(intervalMs?: number): () => void;
|
|
38
|
+
/** The served file drawn as SVG. The modified time makes a changed file a new image. */
|
|
39
|
+
export declare const thumbnailUrl: (file: WorkspaceFile) => string;
|
|
40
|
+
export declare function launch(): Promise<LaunchMode>;
|
|
41
|
+
/** Write a new diagram file in the served folder. Resolves its path, or throws the reason. */
|
|
42
|
+
export declare function createDiagramFile(path: string, source: string): Promise<string>;
|
|
43
|
+
/** A file name for a title: "Billing flow" → "billing-flow.draft". */
|
|
44
|
+
export declare const fileNameFor: (title: string) => string;
|
|
45
|
+
/** Source for a new, nearly empty diagram. */
|
|
46
|
+
export declare const newDiagramSource: (title: string) => string;
|
|
47
|
+
/** Register work to close before the page shows another file, such as an open Compare. */
|
|
48
|
+
export declare const onLeaveFile: (handler: () => void) => undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Open a served file, or the start page, without reloading the page, so the current drawing
|
|
51
|
+
* stays on screen until the next one is ready. Anything else (an example, another site, an edited
|
|
52
|
+
* example that the browser should ask about) loads as a normal page.
|
|
53
|
+
*/
|
|
54
|
+
export declare function go(url: string, { push }?: {
|
|
55
|
+
push?: boolean | undefined;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Route plain clicks on links to served files and the start page through `go`, and follow the
|
|
59
|
+
* browser's back and forward buttons. Returns a function that stops.
|
|
60
|
+
*/
|
|
61
|
+
export declare function navigateInPlace(): () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DiagramSession } from './session';
|
|
2
|
+
/**
|
|
3
|
+
* Where a relative link starts: `config link-base=` from the diagram's folder, else its git root.
|
|
4
|
+
* Null when no file on disk is open.
|
|
5
|
+
*/
|
|
6
|
+
export declare function linkBase(s: DiagramSession): string | null;
|
|
7
|
+
/** What opening `href` does, for a tooltip or the Inspector. */
|
|
8
|
+
export declare function describeLink(s: DiagramSession, href: string): string;
|
|
9
|
+
/** A link as an exported SVG carries it: file paths from the diagram's folder, URLs as written. */
|
|
10
|
+
export declare function exportHref(s: DiagramSession, href: string): string;
|
|
11
|
+
export declare function openLink(s: DiagramSession, href: string): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type AppearanceOverrides, type Shade, type ThemeId } from '../../model/appearance';
|
|
2
|
+
import * as edits from '../../model/edits';
|
|
3
|
+
import type { Diagram, IntentPlacement, IntentRole, Point, Side } from '../../model/types';
|
|
4
|
+
import { type Tool } from './editor';
|
|
5
|
+
import type { EditorPart } from './editor';
|
|
6
|
+
import type { DocumentPart } from './document';
|
|
7
|
+
import type { ScenePart } from './scene';
|
|
8
|
+
import type { LayoutPart } from './layout';
|
|
9
|
+
/** Inline-edit ids of the frame's title and subtitle; never valid object ids. */
|
|
10
|
+
export declare const HEADING_EDIT: {
|
|
11
|
+
readonly title: string;
|
|
12
|
+
readonly subtitle: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function createActions(s: EditorPart & DocumentPart & ScenePart & LayoutPart): {
|
|
15
|
+
inlineDraft: import("solid-js").Accessor<string>;
|
|
16
|
+
setInlineDraft: import("solid-js").Setter<string>;
|
|
17
|
+
setToolInterceptor: (fn: (tool: Tool) => boolean) => (tool: Tool) => boolean;
|
|
18
|
+
setTool: (next: Tool) => void;
|
|
19
|
+
startInlineEdit: (id: string) => void;
|
|
20
|
+
finishInlineEdit: (save?: boolean) => void;
|
|
21
|
+
addNode: (partial?: edits.NewNode, at?: Point, edit?: boolean) => string;
|
|
22
|
+
addEdge: (partial: edits.NewEdge) => string;
|
|
23
|
+
completeConnection: (targetId: string, side?: Side | "auto") => void;
|
|
24
|
+
quickExtend: ({ side, sibling, at, from, }?: {
|
|
25
|
+
side?: Side | null;
|
|
26
|
+
sibling?: boolean;
|
|
27
|
+
at?: Point | null;
|
|
28
|
+
from?: string | null;
|
|
29
|
+
}) => string | undefined;
|
|
30
|
+
insertStep: (edgeId: string, at?: Point | null) => string | undefined;
|
|
31
|
+
buildFromList: (lines: string[], options?: {
|
|
32
|
+
mode?: edits.BuildMode;
|
|
33
|
+
title?: string;
|
|
34
|
+
source?: string | null;
|
|
35
|
+
parentId?: string | null;
|
|
36
|
+
}) => string[];
|
|
37
|
+
wrapSelection: () => string;
|
|
38
|
+
drawContainer: (rect: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
w: number;
|
|
42
|
+
h: number;
|
|
43
|
+
}) => void;
|
|
44
|
+
deleteSelection: (deep?: boolean) => void;
|
|
45
|
+
ungroupSelection: () => void;
|
|
46
|
+
togglePin: () => void;
|
|
47
|
+
clearManualMarkers: () => void;
|
|
48
|
+
alignSelection: (kind: edits.AlignKind) => void;
|
|
49
|
+
nudgeSelection: (dx: number, dy: number) => boolean;
|
|
50
|
+
setColor: (color: Diagram["styles"][string]["color"]) => void;
|
|
51
|
+
chooseTheme: (theme: ThemeId) => void;
|
|
52
|
+
setAppearanceOverrides: (patch: Partial<AppearanceOverrides>, label?: string) => void;
|
|
53
|
+
setShade: (shade: Shade | undefined) => void;
|
|
54
|
+
fitSelectedContainer: () => void;
|
|
55
|
+
toggleCollapse: (id?: string | undefined) => void;
|
|
56
|
+
reverseSelectedEdge: () => void;
|
|
57
|
+
resetSelectedBends: () => void;
|
|
58
|
+
setLayoutIntent: (role: IntentRole, id: string | null, placement?: IntentPlacement) => void;
|
|
59
|
+
markSelectedAs: (role: IntentRole) => void;
|
|
60
|
+
addWaypointAt: (edgeId: string, point?: Point) => void;
|
|
61
|
+
removeWaypoint: (edgeId: string, index: number) => void;
|
|
62
|
+
reroute: ({ auto }?: {
|
|
63
|
+
auto?: boolean | undefined;
|
|
64
|
+
}) => void;
|
|
65
|
+
toggleTheme: () => void;
|
|
66
|
+
copySelection: () => edits.ClipboardFragment | null;
|
|
67
|
+
hasClipboard: () => boolean;
|
|
68
|
+
pasteFragment: (part?: edits.ClipboardFragment | null) => void;
|
|
69
|
+
duplicateSelection: () => void;
|
|
70
|
+
openDocument: (input: unknown, { fit, label }?: {
|
|
71
|
+
fit?: boolean | undefined;
|
|
72
|
+
label?: string | undefined;
|
|
73
|
+
}) => Diagram;
|
|
74
|
+
newDocument: () => void;
|
|
75
|
+
openSample: (id: string) => Diagram | undefined;
|
|
76
|
+
};
|
|
77
|
+
export type ActionsPart = ReturnType<typeof createActions>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Diagram } from '../../model/types';
|
|
2
|
+
export type TextKind = 'title' | 'subtitle' | 'note' | 'footnote' | 'legend' | 'phase';
|
|
3
|
+
export declare const textId: (kind: TextKind, key?: string | number) => string;
|
|
4
|
+
/** The kind and key of a text id; undefined for an object id. */
|
|
5
|
+
export declare function parseTextId(id: string | null | undefined): {
|
|
6
|
+
kind: TextKind;
|
|
7
|
+
key: string;
|
|
8
|
+
} | undefined;
|
|
9
|
+
/** What the Inspector, undo steps and the editor call each kind. */
|
|
10
|
+
export declare const TEXT_NAMES: Record<TextKind, string>;
|
|
11
|
+
/** The text's current words, or undefined when the id names nothing in `d`. */
|
|
12
|
+
export declare function textValue(d: Diagram, id: string): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Write `value` to the text `id` names. An empty note or legend row is removed; a phase keeps its
|
|
15
|
+
* old label, since a phase needs one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setTextValue(d: Diagram, id: string, value: string): void;
|
|
18
|
+
/** Remove the text: a note, footnote or legend row goes, a title or subtitle empties; a phase stays. */
|
|
19
|
+
export declare function removeText(d: Diagram, id: string): void;
|
|
20
|
+
export declare function createCanvasText(): {
|
|
21
|
+
selectedText: import("solid-js").Accessor<string | null>;
|
|
22
|
+
setSelectedText: import("solid-js").Setter<string | null>;
|
|
23
|
+
};
|
|
24
|
+
export type CanvasTextPart = ReturnType<typeof createCanvasText>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Camera, Diagram } from '../../model/types';
|
|
2
|
+
import type { CanvasTextPart } from './canvas-text';
|
|
3
|
+
import type { SessionOptions } from '.';
|
|
4
|
+
export interface HistoryEntry {
|
|
5
|
+
data: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/** Local brush holds before and after this step; holds are session state, not document data. */
|
|
8
|
+
holds?: {
|
|
9
|
+
before: string[];
|
|
10
|
+
after: string[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type SaveStatus = 'saved' | 'saving' | 'preview' | 'failed';
|
|
14
|
+
/**
|
|
15
|
+
* Handles every committed edit instead of the browser history while a diagram file is open, so
|
|
16
|
+
* the edit can be written to the file. Returns whether the edit was kept.
|
|
17
|
+
*/
|
|
18
|
+
type CommitHandler = (before: string, label: string, kind: EditKind) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* `arrangement`: the edit is a drawing produced by a layout pass, a timeline step or the brush,
|
|
21
|
+
* saved as positions rather than translated move by move.
|
|
22
|
+
*/
|
|
23
|
+
export type EditKind = 'edit' | 'arrangement';
|
|
24
|
+
/** Replaces the browser history while a diagram file is open: undo steps through its source. */
|
|
25
|
+
export interface HistoryHandler {
|
|
26
|
+
undo(): void;
|
|
27
|
+
redo(): void;
|
|
28
|
+
canUndo(): boolean;
|
|
29
|
+
canRedo(): boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function createDocument(s: CanvasTextPart, options: SessionOptions): {
|
|
32
|
+
options: SessionOptions;
|
|
33
|
+
doc: Diagram;
|
|
34
|
+
setDoc: import("solid-js/store").SetStoreFunction<Diagram>;
|
|
35
|
+
saveStatus: import("solid-js").Accessor<SaveStatus>;
|
|
36
|
+
undoStack: import("solid-js").Accessor<HistoryEntry[]>;
|
|
37
|
+
redoStack: import("solid-js").Accessor<HistoryEntry[]>;
|
|
38
|
+
revision: import("solid-js").Accessor<number>;
|
|
39
|
+
snapshotDoc: () => Diagram;
|
|
40
|
+
snapshot: () => string;
|
|
41
|
+
selection: import("solid-js").Accessor<ReadonlySet<string>>;
|
|
42
|
+
selectedIds: () => string[];
|
|
43
|
+
isSelected: (id: string) => boolean;
|
|
44
|
+
singleSelection: () => string | undefined;
|
|
45
|
+
setSelection: (ids: Iterable<string>) => void;
|
|
46
|
+
selectItems: (ids: string[], { add, toggle }?: {
|
|
47
|
+
add?: boolean | undefined;
|
|
48
|
+
toggle?: boolean | undefined;
|
|
49
|
+
}) => void;
|
|
50
|
+
clearSelection: () => void;
|
|
51
|
+
selectText: (id: string) => void;
|
|
52
|
+
onBeforeEdit: (handler: () => void) => void;
|
|
53
|
+
prepareForEdit: () => void;
|
|
54
|
+
onSourceIdMap: (handler: (mapId: (id: string) => string) => void) => void;
|
|
55
|
+
mapSourceIds: (mapId: (id: string) => string) => void;
|
|
56
|
+
setCommitHandler: (handler: CommitHandler | null) => CommitHandler | null;
|
|
57
|
+
editsGoToFile: () => boolean;
|
|
58
|
+
commit: (before: string, label?: string, kind?: EditKind) => boolean;
|
|
59
|
+
pushUndo: (entry: HistoryEntry) => void;
|
|
60
|
+
annotateLastUndo: (holds: HistoryEntry["holds"]) => void;
|
|
61
|
+
transact: (label: string, fn: (draft: Diagram) => void, kind?: EditKind) => boolean;
|
|
62
|
+
mutate: (fn: (draft: Diagram) => void) => void;
|
|
63
|
+
restoreDocument: (next: Diagram, { keepCamera }?: {
|
|
64
|
+
keepCamera?: boolean | undefined;
|
|
65
|
+
}) => void;
|
|
66
|
+
onHistoryStep: (handler: (entry: HistoryEntry, direction: "undo" | "redo") => void) => void;
|
|
67
|
+
setHistoryHandler: (handler: HistoryHandler | null) => HistoryHandler | null;
|
|
68
|
+
undo: () => void;
|
|
69
|
+
redo: () => void;
|
|
70
|
+
canUndo: () => boolean;
|
|
71
|
+
canRedo: () => boolean;
|
|
72
|
+
setCamera: (camera: Camera) => void;
|
|
73
|
+
disableBrowserStorage: () => boolean;
|
|
74
|
+
setPersistenceBlocked: (blocked: boolean) => void;
|
|
75
|
+
persist: () => void;
|
|
76
|
+
persistNow: () => void;
|
|
77
|
+
restoreSavedDocument: () => {
|
|
78
|
+
restored: boolean;
|
|
79
|
+
notice?: string;
|
|
80
|
+
};
|
|
81
|
+
watchOtherTabs: () => () => void;
|
|
82
|
+
};
|
|
83
|
+
export type DocumentPart = ReturnType<typeof createDocument>;
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { NodeGeometry, Point, PortSide, Rect } from '../../model/types';
|
|
2
|
+
import type { DocumentPart } from './document';
|
|
3
|
+
import type { ScenePart } from './scene';
|
|
4
|
+
export type Tool = 'select' | 'pan' | 'box' | 'diamond' | 'circle' | 'text' | 'container' | 'connect' | 'brush';
|
|
5
|
+
export declare const DRAW_TOOLS: readonly ["box", "diamond", "circle", "text", "container"];
|
|
6
|
+
export type DrawTool = (typeof DRAW_TOOLS)[number];
|
|
7
|
+
export declare const isDrawTool: (tool: Tool) => tool is DrawTool;
|
|
8
|
+
export interface Guide {
|
|
9
|
+
axis: 'x' | 'y';
|
|
10
|
+
value: number;
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
}
|
|
14
|
+
/** Visual feedback for the gesture in progress. */
|
|
15
|
+
export interface DragFeedback {
|
|
16
|
+
kind: string;
|
|
17
|
+
marquee?: Rect;
|
|
18
|
+
draw?: Rect;
|
|
19
|
+
guides?: Guide[];
|
|
20
|
+
dropTargetId?: string | null;
|
|
21
|
+
resizingContainer?: boolean;
|
|
22
|
+
/** A note being dragged: its box, and the object it would sit beside if dropped. */
|
|
23
|
+
text?: {
|
|
24
|
+
rect: Rect;
|
|
25
|
+
near?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare const MIN_ZOOM = 0.08;
|
|
29
|
+
export declare const MAX_ZOOM = 4;
|
|
30
|
+
export { NodeGeometry };
|
|
31
|
+
export declare function createEditor(s: DocumentPart & ScenePart): {
|
|
32
|
+
tool: import("solid-js").Accessor<Tool>;
|
|
33
|
+
setToolSignal: import("solid-js").Setter<Tool>;
|
|
34
|
+
connectFrom: import("solid-js").Accessor<{
|
|
35
|
+
id: string;
|
|
36
|
+
side: PortSide;
|
|
37
|
+
} | null>;
|
|
38
|
+
setConnectFrom: import("solid-js").Setter<{
|
|
39
|
+
id: string;
|
|
40
|
+
side: PortSide;
|
|
41
|
+
} | null>;
|
|
42
|
+
pointer: import("solid-js").Accessor<Point | null>;
|
|
43
|
+
setPointer: import("solid-js").Setter<Point | null>;
|
|
44
|
+
drag: import("solid-js").Accessor<DragFeedback | null>;
|
|
45
|
+
setDrag: import("solid-js").Setter<DragFeedback | null>;
|
|
46
|
+
inlineEditId: import("solid-js").Accessor<string | null>;
|
|
47
|
+
setInlineEditId: import("solid-js").Setter<string | null>;
|
|
48
|
+
spaceHeld: import("solid-js").Accessor<boolean>;
|
|
49
|
+
setSpaceHeld: import("solid-js").Setter<boolean>;
|
|
50
|
+
measuredStageSize: import("solid-js").Accessor<{
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
}>;
|
|
54
|
+
setMeasuredStageSize: import("solid-js").Setter<{
|
|
55
|
+
width: number;
|
|
56
|
+
height: number;
|
|
57
|
+
}>;
|
|
58
|
+
reducedMotion: import("solid-js").Accessor<boolean>;
|
|
59
|
+
setReducedMotion: import("solid-js").Setter<boolean>;
|
|
60
|
+
registerCanvas: (el: SVGSVGElement) => SVGSVGElement;
|
|
61
|
+
canvasElement: () => SVGSVGElement | undefined;
|
|
62
|
+
focusCanvas: () => void | undefined;
|
|
63
|
+
stageSize: () => {
|
|
64
|
+
width: number;
|
|
65
|
+
height: number;
|
|
66
|
+
};
|
|
67
|
+
screenToWorld: (clientX: number, clientY: number) => Point;
|
|
68
|
+
canvasCenter: () => Point;
|
|
69
|
+
zoomAt: (factor: number, clientX?: number, clientY?: number) => void;
|
|
70
|
+
panBy: (dx: number, dy: number) => void;
|
|
71
|
+
setStageSize: (size: {
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
}) => void;
|
|
75
|
+
fitView: () => void;
|
|
76
|
+
diagramClipped: () => boolean;
|
|
77
|
+
fitRects: (rects: Rect[], reservedBottom?: number) => void;
|
|
78
|
+
revealObject: (id: string) => void;
|
|
79
|
+
centerSelection: () => void;
|
|
80
|
+
};
|
|
81
|
+
export type EditorPart = ReturnType<typeof createEditor>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DocumentPart } from './document';
|
|
2
|
+
export declare function createEmphasis(s: DocumentPart): {
|
|
3
|
+
states: () => import("../../model/appearance").EmphasisState[];
|
|
4
|
+
activeState: () => string | null;
|
|
5
|
+
gridOpen: import("solid-js").Accessor<boolean>;
|
|
6
|
+
setGridOpen: import("solid-js").Setter<boolean>;
|
|
7
|
+
showState: (id: string | null) => void;
|
|
8
|
+
stepState: (by: 1 | -1) => boolean;
|
|
9
|
+
drawnDoc: () => import("../../model/types").Diagram;
|
|
10
|
+
};
|
|
11
|
+
export type EmphasisPart = ReturnType<typeof createEmphasis>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type Diagnostic, type Scene } from '../../dsl/compile';
|
|
2
|
+
import { type ShapeChange, UnstorableLayout } from '../../dsl/layout-edits';
|
|
3
|
+
import type { RoutingResult } from '../../engines/routing-engine.js';
|
|
4
|
+
import type { Diagram, LayoutSettings, RoutingSettings } from '../../model/types';
|
|
5
|
+
import type { DocumentPart } from './document';
|
|
6
|
+
import type { CanvasTextPart } from './canvas-text';
|
|
7
|
+
export interface FileSessionInfo {
|
|
8
|
+
name: string;
|
|
9
|
+
path: string;
|
|
10
|
+
source: string;
|
|
11
|
+
revision: string;
|
|
12
|
+
/** Where the file's relative links start (files only). */
|
|
13
|
+
root?: string;
|
|
14
|
+
/** Set for an example: its id. The source is never written to disk. */
|
|
15
|
+
example?: string;
|
|
16
|
+
/** The file's path relative to the served folder (files only). */
|
|
17
|
+
file?: string;
|
|
18
|
+
}
|
|
19
|
+
export type FileStatus = 'saved' | 'saving' | 'invalid' | 'conflict' | 'failed' | 'offline';
|
|
20
|
+
/** The id of the blank draft that New opens: a scratch copy with no example behind it. */
|
|
21
|
+
export declare const DRAFT_ID = "untitled";
|
|
22
|
+
/** The source scope a layout scope maps to: `root`, a group, or null for a loose selection. */
|
|
23
|
+
export declare function sourceScope(scope: {
|
|
24
|
+
scope: string;
|
|
25
|
+
containerId?: string;
|
|
26
|
+
}): string | null;
|
|
27
|
+
export { UnstorableLayout };
|
|
28
|
+
export declare function createFileSession(s: DocumentPart & CanvasTextPart): {
|
|
29
|
+
openSource: (source: string, onChange?: (source: string) => void) => Promise<void>;
|
|
30
|
+
receiveSource: (source: string) => Promise<void>;
|
|
31
|
+
liveSource: import("solid-js").Accessor<string>;
|
|
32
|
+
sourceDraft: import("solid-js").Accessor<string | null>;
|
|
33
|
+
fileSession: import("solid-js").Accessor<FileSessionInfo | null>;
|
|
34
|
+
fileMode: () => boolean;
|
|
35
|
+
exampleMode: () => boolean;
|
|
36
|
+
scratchName: () => "Draft" | "Example";
|
|
37
|
+
exampleEdited: () => boolean;
|
|
38
|
+
leaveAgreed: () => boolean;
|
|
39
|
+
agreeToLeave: () => undefined;
|
|
40
|
+
fileStatus: import("solid-js").Accessor<FileStatus>;
|
|
41
|
+
sourceError: import("solid-js").Accessor<{
|
|
42
|
+
message: string;
|
|
43
|
+
line: number;
|
|
44
|
+
} | null>;
|
|
45
|
+
fileScene: import("solid-js").Accessor<Scene | null>;
|
|
46
|
+
fileDiagnostics: () => Diagnostic[];
|
|
47
|
+
conflictProposal: import("solid-js").Accessor<string | null>;
|
|
48
|
+
movedByChange: import("solid-js").Accessor<string[]>;
|
|
49
|
+
fileCompiling: import("solid-js").Accessor<boolean>;
|
|
50
|
+
exampleRestored: () => boolean;
|
|
51
|
+
currentSource: () => string;
|
|
52
|
+
setRouteSink: (sink: {
|
|
53
|
+
adopt: (routes: {
|
|
54
|
+
fingerprint: string;
|
|
55
|
+
result: RoutingResult;
|
|
56
|
+
}) => void;
|
|
57
|
+
quick: (on: boolean) => void;
|
|
58
|
+
/** A shown revision's full routes are still on their way from the worker. */
|
|
59
|
+
awaiting: (on: boolean) => void;
|
|
60
|
+
}) => {
|
|
61
|
+
adopt: (routes: {
|
|
62
|
+
fingerprint: string;
|
|
63
|
+
result: RoutingResult;
|
|
64
|
+
}) => void;
|
|
65
|
+
quick: (on: boolean) => void;
|
|
66
|
+
/** A shown revision's full routes are still on their way from the worker. */
|
|
67
|
+
awaiting: (on: boolean) => void;
|
|
68
|
+
};
|
|
69
|
+
showSource: (source: string, selection?: string[] | (() => string[]), mapId?: (id: string) => string) => Promise<Scene | null>;
|
|
70
|
+
keepDiskVersion: () => void;
|
|
71
|
+
saveProposalOverDisk: () => void;
|
|
72
|
+
retrySave: () => undefined;
|
|
73
|
+
typeSource: (next: string, burst: number) => Promise<null | undefined>;
|
|
74
|
+
commitSource: (next: string, label: string, message: string) => Promise<boolean>;
|
|
75
|
+
fileBlocked: () => string | null;
|
|
76
|
+
sourceWithRecipe: (scope: string, settings: LayoutSettings, direction?: "right" | "down") => {
|
|
77
|
+
source: string;
|
|
78
|
+
removed: number;
|
|
79
|
+
};
|
|
80
|
+
sourceWithShape: (scope: string, change: ShapeChange) => {
|
|
81
|
+
source: string;
|
|
82
|
+
removed: number;
|
|
83
|
+
};
|
|
84
|
+
changedLines: (source: string) => string[];
|
|
85
|
+
changedLine: (source: string) => string;
|
|
86
|
+
sourceWithRouting: (routing: RoutingSettings, base?: string) => string;
|
|
87
|
+
projectSource: (source: string) => Promise<Diagram>;
|
|
88
|
+
reflowSelectedGroup: (id: string) => void;
|
|
89
|
+
openFileSession: (file: string) => Promise<boolean>;
|
|
90
|
+
prefetchFile: (file: string) => Promise<void>;
|
|
91
|
+
settleSave: () => Promise<void>;
|
|
92
|
+
closeFileSession: () => void;
|
|
93
|
+
openExampleSession: (id: string, title: string, source: string, key?: string) => Promise<void>;
|
|
94
|
+
resetExample: () => void;
|
|
95
|
+
markExampleSaved: () => void;
|
|
96
|
+
fileStatusText: () => string;
|
|
97
|
+
};
|
|
98
|
+
export type FileSessionPart = ReturnType<typeof createFileSession>;
|