@lostgradient/cinder 0.16.1 → 0.17.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/CHANGELOG.md +185 -0
- package/README.md +33 -11
- package/components.json +53 -102
- package/dist/_internal/chart/chart-utilities.d.ts +1 -0
- package/dist/cli/index.js +63 -10
- package/dist/cli/mcp-dependencies.d.ts +4 -0
- package/dist/components/approval-card/approval-card.css +1 -6
- package/dist/components/approval-card/index.js +94 -55
- package/dist/components/area-chart/index.js +40 -6
- package/dist/components/bar-chart/index.js +132 -83
- package/dist/components/code-block/index.js +58 -9
- package/dist/components/command-menu/command-menu.css +9 -0
- package/dist/components/command-menu/index.js +7 -2
- package/dist/components/diff-statistics/diff-statistics.svelte.d.ts +3 -3
- package/dist/components/file-upload/file-upload.schema.js +5 -1
- package/dist/components/file-upload/file-upload.types.d.ts +2 -0
- package/dist/components/file-upload/index.js +37 -27
- package/dist/components/invocation-rule-builder/index.d.ts +1 -1
- package/dist/components/invocation-rule-builder/index.js +244 -199
- package/dist/components/invocation-rule-builder/invocation-rule-builder.css +8 -0
- package/dist/components/invocation-rule-builder/invocation-rule-builder.schema.d.ts +2 -2
- package/dist/components/invocation-rule-builder/invocation-rule-builder.schema.js +309 -193
- package/dist/components/invocation-rule-builder/invocation-rule-builder.svelte.d.ts +3 -2
- package/dist/components/invocation-rule-builder/invocation-rule-builder.types.d.ts +98 -31
- package/dist/components/json-editor/index.d.ts +5 -0
- package/dist/components/json-editor/index.js +261 -0
- package/dist/components/json-editor/json-editor.css +49 -0
- package/dist/components/{diff-viewer/diff-viewer.schema.js → json-editor/json-editor.schema.js} +37 -49
- package/dist/components/json-editor/json-editor.svelte.d.ts +21 -0
- package/dist/components/json-editor/json-editor.types.d.ts +25 -0
- package/dist/components/{diff-viewer/diff-viewer.variables.js → json-editor/json-editor.variables.js} +4 -4
- package/dist/components/json-schema-editor/index.js +2041 -4165
- package/dist/components/json-schema-editor/json-schema-editor-state.svelte.d.ts +17 -1
- package/dist/components/json-schema-editor/json-schema-editor-types.d.ts +8 -1
- package/dist/components/json-schema-editor/json-schema-editor.css +35 -0
- package/dist/components/json-schema-editor/json-schema-editor.svelte.d.ts +0 -1
- package/dist/components/json-schema-editor/json-schema-validator.d.ts +9 -4
- package/dist/components/line-chart/index.js +40 -6
- package/dist/components/matrix-chart/index.js +40 -6
- package/dist/components/payload-inspector/index.js +10 -2
- package/dist/components/payload-inspector/payload-inspector.schema.js +11 -1
- package/dist/components/payload-inspector/payload-inspector.types.d.ts +20 -0
- package/dist/components/run-step-timeline/index.js +158 -110
- package/dist/components/run-step-timeline/run-step-timeline.css +46 -0
- package/dist/components/run-step-timeline/run-step-timeline.schema.js +26 -1
- package/dist/components/run-step-timeline/run-step-timeline.types.d.ts +22 -2
- package/dist/components/schedule-builder/index.js +165 -93
- package/dist/components/schedule-builder/schedule-builder.schema.js +8 -1
- package/dist/components/schedule-builder/schedule-builder.svelte.d.ts +1 -1
- package/dist/components/schedule-builder/schedule-builder.types.d.ts +12 -0
- package/dist/components/schema-form/index.d.ts +1 -1
- package/dist/components/schema-form/index.js +107 -25
- package/dist/components/schema-form/schema-form.schema.js +9 -1
- package/dist/components/schema-form/schema-form.svelte.d.ts +1 -1
- package/dist/components/schema-form/schema-form.types.d.ts +8 -0
- package/dist/components/sidebar/index.js +93 -42
- package/dist/components/sidebar/sidebar.css +7 -16
- package/dist/components/sidebar/sidebar.schema.js +8 -9
- package/dist/components/sidebar/sidebar.types.d.ts +14 -12
- package/dist/components/source-diff-viewer/source-diff-viewer.svelte.d.ts +2 -2
- package/dist/components/spectrogram/index.js +40 -6
- package/dist/components/spectrum-chart/index.js +40 -6
- package/dist/components/tabs/tabs.css +2 -0
- package/dist/components/textarea/textarea.svelte.d.ts +1 -1
- package/dist/components/toast-region/index.js +2 -2
- package/dist/components/toast-region/toast-region.css +1 -1
- package/dist/components/waveform/index.js +40 -6
- package/dist/highlighters/shiki/index.d.ts +47 -5
- package/dist/highlighters/shiki/index.js +58 -9
- package/dist/index.d.ts +4 -4
- package/dist/index.js +15347 -16138
- package/dist/server/components/access-gate/index.js +2 -5
- package/dist/server/components/approval-card/index.js +2 -2
- package/dist/server/components/area-chart/index.js +3 -3
- package/dist/server/components/bar-chart/index.js +3 -3
- package/dist/server/components/command-menu/index.js +1 -1
- package/dist/server/components/context-menu/index.js +5 -5
- package/dist/server/components/data-table/index.js +2 -2
- package/dist/server/components/diff-statistics/index.js +3 -5
- package/dist/server/components/dropdown/index.js +6 -7
- package/dist/server/components/file-upload/index.js +2 -3
- package/dist/server/components/icons/index.js +17 -26
- package/dist/server/components/inline-loading/index.js +1 -1
- package/dist/server/components/invocation-rule-builder/index.js +1 -1
- package/dist/server/components/json-editor/index.js +13 -0
- package/dist/server/components/json-schema-editor/index.js +4 -16
- package/dist/server/components/line-chart/index.js +3 -3
- package/dist/server/components/matrix-chart/index.js +2 -2
- package/dist/server/components/menu-bar/index.js +4 -4
- package/dist/server/components/payload-inspector/index.js +2 -2
- package/dist/server/components/run-step-timeline/index.js +1 -1
- package/dist/server/components/schedule-builder/index.js +3 -3
- package/dist/server/components/schema-form/index.js +1 -1
- package/dist/server/components/selection-popover/index.js +3 -5
- package/dist/server/components/sidebar/index.js +1 -1
- package/dist/server/components/spectrogram/index.js +2 -2
- package/dist/server/components/spectrum-chart/index.js +2 -2
- package/dist/server/components/surface/index.js +3 -5
- package/dist/server/components/table/index.js +2 -2
- package/dist/server/components/tabs/index.js +5 -5
- package/dist/server/components/toast-region/index.js +1 -1
- package/dist/server/components/toolbar/index.js +2 -3
- package/dist/server/components/waveform/index.js +2 -2
- package/dist/server/highlighters/shiki/index.js +61 -25
- package/dist/server/index.js +105 -115
- package/dist/server/{index.server-7yfz2t73.js → index.server-003t81xk.js} +1 -1
- package/dist/server/{index.server-gwgm8gqg.js → index.server-032p855q.js} +4 -4
- package/dist/server/{index.server-tf2n3ccm.js → index.server-1vfhzhkj.js} +1 -1
- package/dist/server/{index.server-jz5yxwde.js → index.server-4cbqjf14.js} +16 -7
- package/dist/server/{index.server-aqethy0w.js → index.server-66nm5gd5.js} +102 -26
- package/dist/server/{index.server-m0ezemav.js → index.server-6mnbznbt.js} +4 -2
- package/dist/server/{index.server-1nq8h5yb.js → index.server-6vbpz6dd.js} +40 -6
- package/dist/server/{index.server-796hb0r8.js → index.server-7qak74fg.js} +1 -1
- package/dist/server/{index.server-5exh7rmw.js → index.server-7ygdwxre.js} +57 -5
- package/dist/server/{index.server-q1d48s9t.js → index.server-8c6cck0y.js} +6 -4
- package/dist/server/index.server-93vt8ktj.js +95 -0
- package/dist/server/{index.server-ep81fn23.js → index.server-9eccb2fc.js} +2 -2
- package/dist/server/{index.server-zncgb7mw.js → index.server-9nac5z11.js} +92 -49
- package/dist/server/{index.server-bf7d81b4.js → index.server-9vqfmhez.js} +16 -18
- package/dist/server/{index.server-nt304e00.js → index.server-dx58qant.js} +1 -1
- package/dist/server/{index.server-zh3r8vfd.js → index.server-fhrqsg97.js} +1 -1
- package/dist/server/{index.server-dq0k0qf6.js → index.server-geq56xaz.js} +10 -10
- package/dist/server/{index.server-51sxnete.js → index.server-hxveaqg1.js} +10 -10
- package/dist/server/{index.server-c5qv3p61.js → index.server-j87v28yy.js} +59 -30
- package/dist/server/{index.server-s5g7reqp.js → index.server-mewms9dg.js} +2 -2
- package/dist/server/index.server-mm728d0w.js +20 -0
- package/dist/server/{index.server-5mc2vsy0.js → index.server-n0rbn5yf.js} +4 -2
- package/dist/server/{index.server-qv0kkre4.js → index.server-ng8y854r.js} +188 -107
- package/dist/server/{index.server-wasj5rbh.js → index.server-q5gvb174.js} +4 -4
- package/dist/server/{index.server-g5jgq3jp.js → index.server-qxneqxf8.js} +40 -6
- package/dist/server/{index.server-x1dha7bk.js → index.server-rnddtcb3.js} +4 -2
- package/dist/server/{index.server-7zpzspk6.js → index.server-s4wm4g2a.js} +30 -2
- package/dist/server/index.server-szgghcdh.js +887 -0
- package/dist/server/{index.server-thcda9ny.js → index.server-vd302sxz.js} +11 -4
- package/dist/server/{index.server-3sq9d73w.js → index.server-vz9hqkdq.js} +2 -2
- package/dist/server/{index.server-mvjzcna5.js → index.server-wg6ddzpa.js} +42 -20
- package/dist/server/{index.server-67q8dmbp.js → index.server-y2ncgt7p.js} +1 -1
- package/dist/server/{index.server-4x91gzy1.js → index.server-yqhww50r.js} +4 -4
- package/dist/server/{index.server-7798gc22.js → index.server-zfx4magq.js} +4 -2
- package/package.json +45 -288
- package/src/_internal/chart/chart-utilities.ts +74 -5
- package/src/components/approval-card/approval-card-actions.svelte +12 -28
- package/src/components/approval-card/approval-card.css +1 -6
- package/src/components/bar-chart/bar-chart.examples.json +1 -1
- package/src/components/bar-chart/bar-chart.svelte +3 -1
- package/src/components/command-menu/command-menu.css +9 -0
- package/src/components/command-menu/command-menu.svelte +9 -2
- package/src/components/file-upload/file-upload.schema.json +4 -0
- package/src/components/file-upload/file-upload.schema.ts +4 -0
- package/src/components/file-upload/file-upload.svelte +3 -3
- package/src/components/file-upload/file-upload.types.ts +2 -0
- package/src/components/invocation-rule-builder/index.ts +1 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.css +8 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.examples.json +6 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.schema.json +70 -7
- package/src/components/invocation-rule-builder/invocation-rule-builder.schema.ts +5 -250
- package/src/components/invocation-rule-builder/invocation-rule-builder.svelte +106 -83
- package/src/components/invocation-rule-builder/invocation-rule-builder.types.ts +145 -62
- package/src/components/json-editor/index.ts +6 -0
- package/src/components/json-editor/json-editor.css +49 -0
- package/src/components/json-editor/json-editor.examples.json +13 -0
- package/src/components/json-editor/json-editor.schema.json +57 -0
- package/src/components/json-editor/json-editor.schema.ts +62 -0
- package/src/components/json-editor/json-editor.svelte +104 -0
- package/src/components/json-editor/json-editor.types.ts +29 -0
- package/src/components/json-schema-editor/diff-view.svelte +26 -8
- package/src/components/json-schema-editor/form-view.svelte +1 -1
- package/src/components/json-schema-editor/json-schema-editor-state.svelte.ts +163 -56
- package/src/components/json-schema-editor/json-schema-editor-types.ts +8 -1
- package/src/components/json-schema-editor/json-schema-editor.css +35 -0
- package/src/components/json-schema-editor/json-schema-validator.ts +59 -25
- package/src/components/json-schema-editor/json-view.svelte +52 -18
- package/src/components/payload-inspector/payload-inspector.schema.json +8 -0
- package/src/components/payload-inspector/payload-inspector.schema.ts +10 -0
- package/src/components/payload-inspector/payload-inspector.svelte +2 -2
- package/src/components/payload-inspector/payload-inspector.types.ts +20 -0
- package/src/components/run-step-timeline/run-step-timeline.css +46 -0
- package/src/components/run-step-timeline/run-step-timeline.examples.json +3 -3
- package/src/components/run-step-timeline/run-step-timeline.schema.json +24 -0
- package/src/components/run-step-timeline/run-step-timeline.schema.ts +26 -0
- package/src/components/run-step-timeline/run-step-timeline.svelte +41 -4
- package/src/components/run-step-timeline/run-step-timeline.types.ts +22 -1
- package/src/components/run-step-timeline/run-step-timeline.utilities.ts +9 -1
- package/src/components/schedule-builder/schedule-builder.schema.json +7 -0
- package/src/components/schedule-builder/schedule-builder.schema.ts +8 -0
- package/src/components/schedule-builder/schedule-builder.svelte +94 -22
- package/src/components/schedule-builder/schedule-builder.types.ts +12 -0
- package/src/components/schema-form/index.ts +1 -0
- package/src/components/schema-form/schema-form-body.svelte +94 -17
- package/src/components/schema-form/schema-form.examples.json +1 -1
- package/src/components/schema-form/schema-form.schema.json +5 -0
- package/src/components/schema-form/schema-form.schema.ts +6 -0
- package/src/components/schema-form/schema-form.svelte +4 -0
- package/src/components/schema-form/schema-form.types.ts +9 -0
- package/src/components/side-navigation/side-navigation.examples.json +1 -1
- package/src/components/sidebar/sidebar.css +7 -16
- package/src/components/sidebar/sidebar.examples.json +3 -3
- package/src/components/sidebar/sidebar.schema.json +7 -8
- package/src/components/sidebar/sidebar.schema.ts +8 -8
- package/src/components/sidebar/sidebar.svelte +65 -27
- package/src/components/sidebar/sidebar.types.ts +14 -12
- package/src/components/tabs/tabs.css +2 -0
- package/src/components/toast-region/toast-region.css +1 -1
- package/src/components/toast-region/toast-region.examples.json +1 -1
- package/src/components/toast-region/toast-region.svelte +2 -2
- package/src/highlighters/shiki/index.ts +157 -17
- package/src/index.ts +5 -7
- package/src/styles/components.css +1 -1
- package/src/utilities/change-tracker.svelte.ts +1 -1
- package/dist/commentary/anchor-decorations.d.ts +0 -86
- package/dist/commentary/anchor-decorations.js +0 -490
- package/dist/commentary/anchoring.d.ts +0 -93
- package/dist/commentary/anchoring.js +0 -157
- package/dist/commentary/comments/index.d.ts +0 -12
- package/dist/commentary/comments/index.js +0 -14
- package/dist/commentary/comments/mentions.d.ts +0 -43
- package/dist/commentary/comments/mentions.js +0 -65
- package/dist/commentary/comments/reanchor.d.ts +0 -86
- package/dist/commentary/comments/reanchor.js +0 -220
- package/dist/commentary/comments/types.d.ts +0 -260
- package/dist/commentary/comments/types.js +0 -83
- package/dist/commentary/comments/updates.d.ts +0 -102
- package/dist/commentary/comments/updates.js +0 -226
- package/dist/commentary/export/comments-export.d.ts +0 -42
- package/dist/commentary/export/comments-export.js +0 -258
- package/dist/commentary/export/index.d.ts +0 -12
- package/dist/commentary/export/index.js +0 -12
- package/dist/commentary/export/markdown-summary.d.ts +0 -31
- package/dist/commentary/export/markdown-summary.js +0 -218
- package/dist/commentary/export/types.d.ts +0 -162
- package/dist/commentary/export/types.js +0 -7
- package/dist/commentary/export/unified-diff.d.ts +0 -28
- package/dist/commentary/export/unified-diff.js +0 -250
- package/dist/commentary/index.d.ts +0 -6
- package/dist/commentary/index.js +0 -6
- package/dist/commentary/session/index.d.ts +0 -12
- package/dist/commentary/session/index.js +0 -14
- package/dist/commentary/session/persistence.d.ts +0 -92
- package/dist/commentary/session/persistence.js +0 -253
- package/dist/commentary/session/types.d.ts +0 -208
- package/dist/commentary/session/types.js +0 -26
- package/dist/commentary/session/updates.d.ts +0 -155
- package/dist/commentary/session/updates.js +0 -362
- package/dist/commentary/shared/anchor-types.d.ts +0 -116
- package/dist/commentary/shared/anchor-types.js +0 -9
- package/dist/components/diff-viewer/diff-controller.svelte.d.ts +0 -75
- package/dist/components/diff-viewer/diff-front-matter.svelte.d.ts +0 -28
- package/dist/components/diff-viewer/diff-line.svelte.d.ts +0 -22
- package/dist/components/diff-viewer/diff-summary-bar.svelte.d.ts +0 -13
- package/dist/components/diff-viewer/diff-toolbar.svelte.d.ts +0 -36
- package/dist/components/diff-viewer/diff-viewer.svelte.d.ts +0 -22
- package/dist/components/diff-viewer/diff-viewer.types.d.ts +0 -53
- package/dist/components/diff-viewer/front-matter-header.svelte.d.ts +0 -26
- package/dist/components/diff-viewer/index.d.ts +0 -4
- package/dist/components/diff-viewer/index.js +0 -2848
- package/dist/components/markdown-editor/editor-skeleton.svelte.d.ts +0 -10
- package/dist/components/markdown-editor/editor-toolbar/editor-toolbar.svelte.d.ts +0 -37
- package/dist/components/markdown-editor/editor-toolbar/index.d.ts +0 -11
- package/dist/components/markdown-editor/editor-toolbar/link-popover.svelte.d.ts +0 -30
- package/dist/components/markdown-editor/editor-toolbar/toolbar-button.svelte.d.ts +0 -19
- package/dist/components/markdown-editor/editor-toolbar/toolbar-dropdown.svelte.d.ts +0 -24
- package/dist/components/markdown-editor/editor-toolbar/toolbar-separator.svelte.d.ts +0 -7
- package/dist/components/markdown-editor/editor-toolbar/types.d.ts +0 -13
- package/dist/components/markdown-editor/index.css +0 -61
- package/dist/components/markdown-editor/index.d.ts +0 -4
- package/dist/components/markdown-editor/index.js +0 -7494
- package/dist/components/markdown-editor/markdown-editor.schema.d.ts +0 -3
- package/dist/components/markdown-editor/markdown-editor.schema.js +0 -177
- package/dist/components/markdown-editor/markdown-editor.svelte.d.ts +0 -29
- package/dist/components/markdown-editor/markdown-editor.types.d.ts +0 -100
- package/dist/components/markdown-editor/markdown-editor.variables.d.ts +0 -2
- package/dist/components/markdown-editor/markdown-editor.variables.js +0 -61
- package/dist/components/review-editor/comment-composer.svelte.d.ts +0 -37
- package/dist/components/review-editor/comment-list.svelte.d.ts +0 -19
- package/dist/components/review-editor/comment-sidebar.svelte.d.ts +0 -22
- package/dist/components/review-editor/export-actions.svelte.d.ts +0 -18
- package/dist/components/review-editor/focus-navigation.d.ts +0 -105
- package/dist/components/review-editor/front-matter-fields.svelte.d.ts +0 -10
- package/dist/components/review-editor/index.d.ts +0 -20
- package/dist/components/review-editor/index.js +0 -14731
- package/dist/components/review-editor/live-region.svelte.d.ts +0 -23
- package/dist/components/review-editor/review-editor-anchors.svelte.d.ts +0 -96
- package/dist/components/review-editor/review-editor-controls.svelte.d.ts +0 -41
- package/dist/components/review-editor/review-editor-exports.d.ts +0 -80
- package/dist/components/review-editor/review-editor-front-matter.d.ts +0 -28
- package/dist/components/review-editor/review-editor-impl.svelte.d.ts +0 -31
- package/dist/components/review-editor/review-editor-selection-geometry.d.ts +0 -10
- package/dist/components/review-editor/review-editor-selection-types.d.ts +0 -62
- package/dist/components/review-editor/review-editor-selection.svelte.d.ts +0 -50
- package/dist/components/review-editor/review-editor-state.svelte.d.ts +0 -77
- package/dist/components/review-editor/review-editor-threads.svelte.d.ts +0 -137
- package/dist/components/review-editor/review-editor.css +0 -273
- package/dist/components/review-editor/review-editor.schema.d.ts +0 -3
- package/dist/components/review-editor/review-editor.schema.js +0 -143
- package/dist/components/review-editor/review-editor.svelte.d.ts +0 -19
- package/dist/components/review-editor/review-editor.types.d.ts +0 -77
- package/dist/components/review-editor/review-editor.variables.d.ts +0 -2
- package/dist/components/review-editor/review-editor.variables.js +0 -61
- package/dist/components/review-editor/thread-popover.svelte.d.ts +0 -32
- package/dist/diff/index.d.ts +0 -2
- package/dist/diff/index.js +0 -1
- package/dist/diff/line-diff.d.ts +0 -84
- package/dist/diff/line-diff.js +0 -372
- package/dist/diff/types.d.ts +0 -1
- package/dist/diff/types.js +0 -1
- package/dist/editor/attach.d.ts +0 -30
- package/dist/editor/attach.js +0 -86
- package/dist/editor/bridge.d.ts +0 -110
- package/dist/editor/bridge.js +0 -260
- package/dist/editor/clipboard.d.ts +0 -19
- package/dist/editor/clipboard.js +0 -189
- package/dist/editor/commands.d.ts +0 -167
- package/dist/editor/commands.js +0 -728
- package/dist/editor/component-runtime.d.ts +0 -21
- package/dist/editor/component-runtime.js +0 -20
- package/dist/editor/editor.d.ts +0 -23
- package/dist/editor/editor.js +0 -256
- package/dist/editor/index.d.ts +0 -30
- package/dist/editor/index.js +0 -42
- package/dist/editor/keymap-plugin.d.ts +0 -56
- package/dist/editor/keymap-plugin.js +0 -157
- package/dist/editor/link-input-rule.d.ts +0 -4
- package/dist/editor/link-input-rule.js +0 -26
- package/dist/editor/milkdown-plugin-runtime.d.ts +0 -20
- package/dist/editor/milkdown-plugin-runtime.js +0 -43
- package/dist/editor/placeholder-security.d.ts +0 -22
- package/dist/editor/placeholder-security.js +0 -36
- package/dist/editor/placeholder.d.ts +0 -14
- package/dist/editor/placeholder.js +0 -56
- package/dist/editor/sanitize-html.d.ts +0 -32
- package/dist/editor/sanitize-html.js +0 -111
- package/dist/editor/template-completion-plugin.d.ts +0 -159
- package/dist/editor/template-completion-plugin.js +0 -615
- package/dist/editor/template-invalid-decoration-plugin.d.ts +0 -73
- package/dist/editor/template-invalid-decoration-plugin.js +0 -155
- package/dist/editor/template-placeholders.d.ts +0 -96
- package/dist/editor/template-placeholders.js +0 -355
- package/dist/editor/template-position-utilities.d.ts +0 -34
- package/dist/editor/template-position-utilities.js +0 -63
- package/dist/editor/template-render.d.ts +0 -37
- package/dist/editor/template-render.js +0 -45
- package/dist/editor/test-utilities.d.ts +0 -49
- package/dist/editor/test-utilities.js +0 -93
- package/dist/editor/types.d.ts +0 -234
- package/dist/editor/types.js +0 -8
- package/dist/markdown/diff/compute.d.ts +0 -28
- package/dist/markdown/diff/compute.js +0 -250
- package/dist/markdown/diff/frontmatter.d.ts +0 -66
- package/dist/markdown/diff/frontmatter.js +0 -135
- package/dist/markdown/diff/index.d.ts +0 -27
- package/dist/markdown/diff/index.js +0 -28
- package/dist/markdown/diff/line-diff.d.ts +0 -2
- package/dist/markdown/diff/line-diff.js +0 -1
- package/dist/markdown/diff/positions.d.ts +0 -66
- package/dist/markdown/diff/positions.js +0 -147
- package/dist/markdown/diff/types.d.ts +0 -78
- package/dist/markdown/diff/types.js +0 -7
- package/dist/markdown/index.d.ts +0 -2
- package/dist/markdown/index.js +0 -8
- package/dist/markdown/pipeline/ast.d.ts +0 -302
- package/dist/markdown/pipeline/ast.js +0 -417
- package/dist/markdown/pipeline/errors.d.ts +0 -37
- package/dist/markdown/pipeline/errors.js +0 -49
- package/dist/markdown/pipeline/frontmatter.d.ts +0 -127
- package/dist/markdown/pipeline/frontmatter.js +0 -438
- package/dist/markdown/pipeline/index.d.ts +0 -37
- package/dist/markdown/pipeline/index.js +0 -40
- package/dist/markdown/pipeline/parser.d.ts +0 -65
- package/dist/markdown/pipeline/parser.js +0 -106
- package/dist/markdown/pipeline/serializer.d.ts +0 -67
- package/dist/markdown/pipeline/serializer.js +0 -78
- package/dist/markdown/pipeline/strip-positions.d.ts +0 -20
- package/dist/markdown/pipeline/strip-positions.js +0 -28
- package/dist/markdown/pipeline/types.d.ts +0 -116
- package/dist/markdown/pipeline/types.js +0 -8
- package/dist/markdown/rendering/extract-code-blocks.d.ts +0 -16
- package/dist/markdown/rendering/extract-code-blocks.js +0 -27
- package/dist/markdown/rendering/highlighter.d.ts +0 -109
- package/dist/markdown/rendering/highlighter.js +0 -251
- package/dist/markdown/rendering/index.d.ts +0 -41
- package/dist/markdown/rendering/index.js +0 -46
- package/dist/markdown/rendering/mermaid-cache.d.ts +0 -55
- package/dist/markdown/rendering/mermaid-cache.js +0 -123
- package/dist/markdown/rendering/rehype-shiki-sync.d.ts +0 -57
- package/dist/markdown/rendering/rehype-shiki-sync.js +0 -354
- package/dist/markdown/rendering/render-async.d.ts +0 -43
- package/dist/markdown/rendering/render-async.js +0 -114
- package/dist/markdown/rendering/render-streaming.d.ts +0 -33
- package/dist/markdown/rendering/render-streaming.js +0 -123
- package/dist/markdown/rendering/render-worker.d.ts +0 -19
- package/dist/markdown/rendering/render-worker.js +0 -35
- package/dist/markdown/rendering/render.d.ts +0 -123
- package/dist/markdown/rendering/render.js +0 -477
- package/dist/markdown/rendering/sanitize-schema.d.ts +0 -24
- package/dist/markdown/rendering/sanitize-schema.js +0 -105
- package/dist/markdown/rendering/transform-urls.d.ts +0 -37
- package/dist/markdown/rendering/transform-urls.js +0 -51
- package/dist/markdown/rendering/types.d.ts +0 -51
- package/dist/markdown/rendering/types.js +0 -8
- package/dist/markdown/rendering/worker-dom-shim.d.ts +0 -87
- package/dist/markdown/rendering/worker-dom-shim.js +0 -50
- package/dist/markdown/utilities/safe-url.d.ts +0 -100
- package/dist/markdown/utilities/safe-url.js +0 -236
- package/dist/markdown/utilities/sort-keys.d.ts +0 -19
- package/dist/markdown/utilities/sort-keys.js +0 -33
- package/dist/server/commentary/anchor-decorations.js +0 -490
- package/dist/server/commentary/anchoring.js +0 -157
- package/dist/server/commentary/comments/index.js +0 -14
- package/dist/server/commentary/comments/mentions.js +0 -65
- package/dist/server/commentary/comments/reanchor.js +0 -220
- package/dist/server/commentary/comments/types.js +0 -83
- package/dist/server/commentary/comments/updates.js +0 -226
- package/dist/server/commentary/export/comments-export.js +0 -258
- package/dist/server/commentary/export/index.js +0 -12
- package/dist/server/commentary/export/markdown-summary.js +0 -218
- package/dist/server/commentary/export/types.js +0 -7
- package/dist/server/commentary/export/unified-diff.js +0 -250
- package/dist/server/commentary/index.js +0 -6
- package/dist/server/commentary/session/index.js +0 -14
- package/dist/server/commentary/session/persistence.js +0 -253
- package/dist/server/commentary/session/types.js +0 -26
- package/dist/server/commentary/session/updates.js +0 -362
- package/dist/server/commentary/shared/anchor-types.js +0 -9
- package/dist/server/components/diff-viewer/index.js +0 -33
- package/dist/server/components/markdown-editor/index.js +0 -52
- package/dist/server/components/review-editor/index.js +0 -3493
- package/dist/server/diff/index.js +0 -1
- package/dist/server/diff/line-diff.js +0 -372
- package/dist/server/diff/types.js +0 -1
- package/dist/server/editor/attach.js +0 -86
- package/dist/server/editor/bridge.js +0 -260
- package/dist/server/editor/clipboard.js +0 -189
- package/dist/server/editor/commands.js +0 -728
- package/dist/server/editor/component-runtime.js +0 -20
- package/dist/server/editor/editor.js +0 -256
- package/dist/server/editor/index.js +0 -42
- package/dist/server/editor/keymap-plugin.js +0 -157
- package/dist/server/editor/link-input-rule.js +0 -26
- package/dist/server/editor/milkdown-plugin-runtime.js +0 -43
- package/dist/server/editor/placeholder-security.js +0 -36
- package/dist/server/editor/placeholder.js +0 -56
- package/dist/server/editor/sanitize-html.js +0 -111
- package/dist/server/editor/template-completion-plugin.js +0 -615
- package/dist/server/editor/template-invalid-decoration-plugin.js +0 -155
- package/dist/server/editor/template-placeholders.js +0 -355
- package/dist/server/editor/template-position-utilities.js +0 -63
- package/dist/server/editor/template-render.js +0 -45
- package/dist/server/editor/test-utilities.js +0 -93
- package/dist/server/editor/types.js +0 -8
- package/dist/server/index.server-25wmev4e.js +0 -2
- package/dist/server/index.server-2c56kqws.js +0 -187
- package/dist/server/index.server-45n4s30n.js +0 -35
- package/dist/server/index.server-4jkqgp17.js +0 -1026
- package/dist/server/index.server-8nm871y8.js +0 -176
- package/dist/server/index.server-d04aj37r.js +0 -62
- package/dist/server/index.server-dg19y3m7.js +0 -9
- package/dist/server/index.server-g3726bja.js +0 -9
- package/dist/server/index.server-gyzmkrnz.js +0 -2
- package/dist/server/index.server-jp19145t.js +0 -9
- package/dist/server/index.server-n4jxy52q.js +0 -2
- package/dist/server/index.server-sghkqw5x.js +0 -421
- package/dist/server/index.server-w6am2dxc.js +0 -12
- package/dist/server/index.server-x66zvjfc.js +0 -1163
- package/dist/server/index.server-zdhv33ph.js +0 -124
- package/dist/server/index.server-zke5zt13.js +0 -9
- package/dist/server/markdown/diff/compute.js +0 -250
- package/dist/server/markdown/diff/frontmatter.js +0 -135
- package/dist/server/markdown/diff/index.js +0 -28
- package/dist/server/markdown/diff/line-diff.js +0 -1
- package/dist/server/markdown/diff/positions.js +0 -147
- package/dist/server/markdown/diff/types.js +0 -7
- package/dist/server/markdown/index.js +0 -8
- package/dist/server/markdown/pipeline/ast.js +0 -417
- package/dist/server/markdown/pipeline/errors.js +0 -49
- package/dist/server/markdown/pipeline/frontmatter.js +0 -438
- package/dist/server/markdown/pipeline/index.js +0 -40
- package/dist/server/markdown/pipeline/parser.js +0 -106
- package/dist/server/markdown/pipeline/serializer.js +0 -78
- package/dist/server/markdown/pipeline/strip-positions.js +0 -28
- package/dist/server/markdown/pipeline/types.js +0 -8
- package/dist/server/markdown/rendering/extract-code-blocks.js +0 -27
- package/dist/server/markdown/rendering/highlighter.js +0 -251
- package/dist/server/markdown/rendering/index.js +0 -46
- package/dist/server/markdown/rendering/mermaid-cache.js +0 -123
- package/dist/server/markdown/rendering/rehype-shiki-sync.js +0 -354
- package/dist/server/markdown/rendering/render-async.js +0 -114
- package/dist/server/markdown/rendering/render-streaming.js +0 -123
- package/dist/server/markdown/rendering/render-worker.js +0 -35
- package/dist/server/markdown/rendering/render.js +0 -477
- package/dist/server/markdown/rendering/sanitize-schema.js +0 -105
- package/dist/server/markdown/rendering/transform-urls.js +0 -51
- package/dist/server/markdown/rendering/types.js +0 -8
- package/dist/server/markdown/rendering/worker-dom-shim.js +0 -50
- package/dist/server/markdown/utilities/safe-url.js +0 -236
- package/dist/server/markdown/utilities/sort-keys.js +0 -33
- package/src/components/diff-viewer/diff-controller.svelte.ts +0 -250
- package/src/components/diff-viewer/diff-front-matter.svelte +0 -52
- package/src/components/diff-viewer/diff-line.svelte +0 -340
- package/src/components/diff-viewer/diff-summary-bar.svelte +0 -106
- package/src/components/diff-viewer/diff-toolbar.svelte +0 -182
- package/src/components/diff-viewer/diff-viewer.examples.json +0 -25
- package/src/components/diff-viewer/diff-viewer.schema.json +0 -61
- package/src/components/diff-viewer/diff-viewer.schema.ts +0 -70
- package/src/components/diff-viewer/diff-viewer.svelte +0 -400
- package/src/components/diff-viewer/diff-viewer.types.ts +0 -56
- package/src/components/diff-viewer/front-matter-header.svelte +0 -137
- package/src/components/diff-viewer/index.ts +0 -5
- package/src/components/markdown-editor/editor-skeleton.svelte +0 -85
- package/src/components/markdown-editor/editor-toolbar/editor-toolbar.svelte +0 -318
- package/src/components/markdown-editor/editor-toolbar/index.ts +0 -18
- package/src/components/markdown-editor/editor-toolbar/link-popover.svelte +0 -314
- package/src/components/markdown-editor/editor-toolbar/toolbar-button.svelte +0 -97
- package/src/components/markdown-editor/editor-toolbar/toolbar-dropdown.svelte +0 -106
- package/src/components/markdown-editor/editor-toolbar/toolbar-separator.svelte +0 -30
- package/src/components/markdown-editor/editor-toolbar/types.ts +0 -15
- package/src/components/markdown-editor/index.ts +0 -10
- package/src/components/markdown-editor/markdown-editor.examples.json +0 -19
- package/src/components/markdown-editor/markdown-editor.schema.json +0 -111
- package/src/components/markdown-editor/markdown-editor.schema.ts +0 -122
- package/src/components/markdown-editor/markdown-editor.svelte +0 -872
- package/src/components/markdown-editor/markdown-editor.types.ts +0 -124
- package/src/components/markdown-editor/markdown-editor.variables.json +0 -1
- package/src/components/markdown-editor/markdown-editor.variables.ts +0 -3
- package/src/components/markdown-editor/prosemirror.css +0 -76
- package/src/components/review-editor/comment-composer.svelte +0 -271
- package/src/components/review-editor/comment-list.svelte +0 -311
- package/src/components/review-editor/comment-sidebar.svelte +0 -449
- package/src/components/review-editor/export-actions.svelte +0 -188
- package/src/components/review-editor/focus-navigation.ts +0 -220
- package/src/components/review-editor/front-matter-fields.svelte +0 -159
- package/src/components/review-editor/index.ts +0 -59
- package/src/components/review-editor/live-region.svelte +0 -109
- package/src/components/review-editor/review-editor-anchors.svelte.ts +0 -219
- package/src/components/review-editor/review-editor-controls.svelte +0 -201
- package/src/components/review-editor/review-editor-exports.ts +0 -145
- package/src/components/review-editor/review-editor-front-matter.ts +0 -237
- package/src/components/review-editor/review-editor-impl.svelte +0 -1509
- package/src/components/review-editor/review-editor-selection-geometry.ts +0 -31
- package/src/components/review-editor/review-editor-selection-types.ts +0 -68
- package/src/components/review-editor/review-editor-selection.svelte.ts +0 -292
- package/src/components/review-editor/review-editor-state.svelte.ts +0 -117
- package/src/components/review-editor/review-editor-threads.svelte.ts +0 -435
- package/src/components/review-editor/review-editor.css +0 -273
- package/src/components/review-editor/review-editor.examples.json +0 -19
- package/src/components/review-editor/review-editor.schema.json +0 -83
- package/src/components/review-editor/review-editor.schema.ts +0 -88
- package/src/components/review-editor/review-editor.svelte +0 -18
- package/src/components/review-editor/review-editor.types.ts +0 -92
- package/src/components/review-editor/review-editor.variables.json +0 -1
- package/src/components/review-editor/review-editor.variables.ts +0 -3
- package/src/components/review-editor/thread-popover.svelte +0 -261
- /package/dist/components/{review-editor/review-editor.css.d.ts → json-editor/json-editor.css.d.ts} +0 -0
- /package/dist/components/{diff-viewer/diff-viewer.schema.d.ts → json-editor/json-editor.schema.d.ts} +0 -0
- /package/dist/components/{diff-viewer/diff-viewer.variables.d.ts → json-editor/json-editor.variables.d.ts} +0 -0
- /package/src/components/{diff-viewer/diff-viewer.variables.json → json-editor/json-editor.variables.json} +0 -0
- /package/src/components/{diff-viewer/diff-viewer.variables.ts → json-editor/json-editor.variables.ts} +0 -0
package/dist/editor/commands.js
DELETED
|
@@ -1,728 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Command registry for the Milkdown editor.
|
|
3
|
-
*
|
|
4
|
-
* This module provides functions to execute editor commands and query editor state.
|
|
5
|
-
* Used by the toolbar and keyboard shortcuts.
|
|
6
|
-
*
|
|
7
|
-
* IMPORTANT: Uses Milkdown's command system (callCommand) to ensure
|
|
8
|
-
* commands respect Milkdown contexts and work correctly.
|
|
9
|
-
*/
|
|
10
|
-
let commandRuntime = null;
|
|
11
|
-
let commandRuntimePromise = null;
|
|
12
|
-
function formatCommandKey(commandKey) {
|
|
13
|
-
return typeof commandKey === 'string' ? commandKey : 'Milkdown command';
|
|
14
|
-
}
|
|
15
|
-
async function resolveCommandRuntime() {
|
|
16
|
-
if (commandRuntime)
|
|
17
|
-
return commandRuntime;
|
|
18
|
-
commandRuntimePromise ??= (async () => {
|
|
19
|
-
const [core, utilities, commonmark, gfm, history, schemaList] = await Promise.all([
|
|
20
|
-
import('@milkdown/kit/core'),
|
|
21
|
-
import('@milkdown/kit/utils'),
|
|
22
|
-
import('@milkdown/kit/preset/commonmark'),
|
|
23
|
-
import('@milkdown/kit/preset/gfm'),
|
|
24
|
-
import('@milkdown/kit/plugin/history'),
|
|
25
|
-
import('@milkdown/kit/prose/schema-list'),
|
|
26
|
-
]);
|
|
27
|
-
return {
|
|
28
|
-
editorViewCtx: core.editorViewCtx,
|
|
29
|
-
schemaCtx: core.schemaCtx,
|
|
30
|
-
callCommand: utilities.callCommand,
|
|
31
|
-
toggleStrongCommand: commonmark.toggleStrongCommand,
|
|
32
|
-
toggleEmphasisCommand: commonmark.toggleEmphasisCommand,
|
|
33
|
-
toggleInlineCodeCommand: commonmark.toggleInlineCodeCommand,
|
|
34
|
-
wrapInHeadingCommand: commonmark.wrapInHeadingCommand,
|
|
35
|
-
wrapInBulletListCommand: commonmark.wrapInBulletListCommand,
|
|
36
|
-
wrapInOrderedListCommand: commonmark.wrapInOrderedListCommand,
|
|
37
|
-
wrapInBlockquoteCommand: commonmark.wrapInBlockquoteCommand,
|
|
38
|
-
insertHrCommand: commonmark.insertHrCommand,
|
|
39
|
-
turnIntoTextCommand: commonmark.turnIntoTextCommand,
|
|
40
|
-
liftListItemCommand: commonmark.liftListItemCommand,
|
|
41
|
-
sinkListItemCommand: commonmark.sinkListItemCommand,
|
|
42
|
-
toggleStrikethroughCommand: gfm.toggleStrikethroughCommand,
|
|
43
|
-
undoCommand: history.undoCommand,
|
|
44
|
-
redoCommand: history.redoCommand,
|
|
45
|
-
liftListItem: schemaList.liftListItem,
|
|
46
|
-
wrapInList: schemaList.wrapInList,
|
|
47
|
-
};
|
|
48
|
-
})();
|
|
49
|
-
commandRuntime = await commandRuntimePromise;
|
|
50
|
-
return commandRuntime;
|
|
51
|
-
}
|
|
52
|
-
/** Load Milkdown command modules before synchronous command handlers run. */
|
|
53
|
-
export async function preloadCommandRuntime() {
|
|
54
|
-
await resolveCommandRuntime();
|
|
55
|
-
}
|
|
56
|
-
function getCommandRuntime() {
|
|
57
|
-
if (commandRuntime)
|
|
58
|
-
return commandRuntime;
|
|
59
|
-
commandRuntimePromise ??= resolveCommandRuntime();
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
function shouldLogDevelopmentWarnings() {
|
|
63
|
-
return typeof process === 'undefined' || process.env.NODE_ENV !== 'production';
|
|
64
|
-
}
|
|
65
|
-
function getEditorView(ctx) {
|
|
66
|
-
const runtime = getCommandRuntime();
|
|
67
|
-
if (!runtime)
|
|
68
|
-
return null;
|
|
69
|
-
return ctx.get(runtime.editorViewCtx);
|
|
70
|
-
}
|
|
71
|
-
function getEditorSchema(ctx) {
|
|
72
|
-
const runtime = getCommandRuntime();
|
|
73
|
-
if (!runtime)
|
|
74
|
-
return null;
|
|
75
|
-
return ctx.get(runtime.schemaCtx);
|
|
76
|
-
}
|
|
77
|
-
function getEditorViewAndSchema(ctx) {
|
|
78
|
-
const runtime = getCommandRuntime();
|
|
79
|
-
if (!runtime)
|
|
80
|
-
return { view: null, schema: null };
|
|
81
|
-
return {
|
|
82
|
-
view: ctx.get(runtime.editorViewCtx),
|
|
83
|
-
schema: ctx.get(runtime.schemaCtx),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
const WORD_CHAR_REGEX = /[A-Za-z0-9_]/;
|
|
87
|
-
function isHeadingLevel(value) {
|
|
88
|
-
return value === 1 || value === 2 || value === 3 || value === 4 || value === 5 || value === 6;
|
|
89
|
-
}
|
|
90
|
-
function findWordRange(view) {
|
|
91
|
-
const { selection } = view.state;
|
|
92
|
-
if (!selection.empty)
|
|
93
|
-
return null;
|
|
94
|
-
const { $from } = selection;
|
|
95
|
-
if (!$from.parent.isTextblock)
|
|
96
|
-
return null;
|
|
97
|
-
const text = $from.parent.textBetween(0, $from.parent.content.size, '\0', '\ufffc');
|
|
98
|
-
if (!text)
|
|
99
|
-
return null;
|
|
100
|
-
const offset = $from.parentOffset;
|
|
101
|
-
const leftChar = offset > 0 ? (text[offset - 1] ?? '') : '';
|
|
102
|
-
const rightChar = offset < text.length ? (text[offset] ?? '') : '';
|
|
103
|
-
if (!WORD_CHAR_REGEX.test(leftChar) && !WORD_CHAR_REGEX.test(rightChar)) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
let startOffset = offset;
|
|
107
|
-
let endOffset = offset;
|
|
108
|
-
if (WORD_CHAR_REGEX.test(leftChar)) {
|
|
109
|
-
startOffset = offset - 1;
|
|
110
|
-
while (startOffset > 0 && WORD_CHAR_REGEX.test(text[startOffset - 1] ?? '')) {
|
|
111
|
-
startOffset--;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (WORD_CHAR_REGEX.test(rightChar)) {
|
|
115
|
-
endOffset = offset + 1;
|
|
116
|
-
while (endOffset < text.length && WORD_CHAR_REGEX.test(text[endOffset] ?? '')) {
|
|
117
|
-
endOffset++;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const base = $from.start();
|
|
121
|
-
const from = base + startOffset;
|
|
122
|
-
const to = base + endOffset;
|
|
123
|
-
if (from === to)
|
|
124
|
-
return null;
|
|
125
|
-
return { from, to };
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Run a Milkdown command and refocus the editor.
|
|
129
|
-
*/
|
|
130
|
-
export function runCommand(ctx, commandKey, payload) {
|
|
131
|
-
const runtime = getCommandRuntime();
|
|
132
|
-
if (!runtime)
|
|
133
|
-
return false;
|
|
134
|
-
try {
|
|
135
|
-
// callCommand returns a function that takes ctx and returns boolean
|
|
136
|
-
const result = runtime.callCommand(commandKey, payload)(ctx);
|
|
137
|
-
// Refocus editor after command
|
|
138
|
-
const view = getEditorView(ctx);
|
|
139
|
-
view?.focus();
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
if (shouldLogDevelopmentWarnings()) {
|
|
144
|
-
console.warn(`[Editor] Command failed: ${formatCommandKey(commandKey)}`, error);
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
150
|
-
// Mark Commands
|
|
151
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
152
|
-
/**
|
|
153
|
-
* Toggle bold (strong) mark on the current selection.
|
|
154
|
-
*/
|
|
155
|
-
export function toggleBold(ctx) {
|
|
156
|
-
const runtime = getCommandRuntime();
|
|
157
|
-
if (!runtime)
|
|
158
|
-
return false;
|
|
159
|
-
const { view, schema } = getEditorViewAndSchema(ctx);
|
|
160
|
-
if (!schema)
|
|
161
|
-
return false;
|
|
162
|
-
const strongMark = schema.marks['strong'];
|
|
163
|
-
if (!view || !strongMark) {
|
|
164
|
-
return runCommand(ctx, runtime.toggleStrongCommand.key);
|
|
165
|
-
}
|
|
166
|
-
const wordRange = findWordRange(view);
|
|
167
|
-
if (!wordRange) {
|
|
168
|
-
return runCommand(ctx, runtime.toggleStrongCommand.key);
|
|
169
|
-
}
|
|
170
|
-
const { from, to } = wordRange;
|
|
171
|
-
const tr = view.state.tr;
|
|
172
|
-
if (view.state.doc.rangeHasMark(from, to, strongMark)) {
|
|
173
|
-
tr.removeMark(from, to, strongMark);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
tr.addMark(from, to, strongMark.create());
|
|
177
|
-
}
|
|
178
|
-
view.dispatch(tr.scrollIntoView());
|
|
179
|
-
view.focus();
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Toggle italic (emphasis) mark on the current selection.
|
|
184
|
-
*/
|
|
185
|
-
export function toggleItalic(ctx) {
|
|
186
|
-
const runtime = getCommandRuntime();
|
|
187
|
-
return runtime ? runCommand(ctx, runtime.toggleEmphasisCommand.key) : false;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Toggle inline code mark on the current selection.
|
|
191
|
-
*/
|
|
192
|
-
export function toggleCode(ctx) {
|
|
193
|
-
const runtime = getCommandRuntime();
|
|
194
|
-
return runtime ? runCommand(ctx, runtime.toggleInlineCodeCommand.key) : false;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Toggle strikethrough mark on the current selection.
|
|
198
|
-
*/
|
|
199
|
-
export function toggleStrikethrough(ctx) {
|
|
200
|
-
const runtime = getCommandRuntime();
|
|
201
|
-
return runtime ? runCommand(ctx, runtime.toggleStrikethroughCommand.key) : false;
|
|
202
|
-
}
|
|
203
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
204
|
-
// Block Commands
|
|
205
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
206
|
-
/**
|
|
207
|
-
* Set the current block to a heading at the specified level.
|
|
208
|
-
*/
|
|
209
|
-
export function setHeading(ctx, level) {
|
|
210
|
-
const runtime = getCommandRuntime();
|
|
211
|
-
return runtime ? runCommand(ctx, runtime.wrapInHeadingCommand.key, level) : false;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Convert the current block to a paragraph (remove heading/list/etc).
|
|
215
|
-
*/
|
|
216
|
-
export function setParagraph(ctx) {
|
|
217
|
-
const runtime = getCommandRuntime();
|
|
218
|
-
return runtime ? runCommand(ctx, runtime.turnIntoTextCommand.key) : false;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Toggle bullet list on the current block.
|
|
222
|
-
*/
|
|
223
|
-
export function toggleBulletList(ctx) {
|
|
224
|
-
const runtime = getCommandRuntime();
|
|
225
|
-
if (!runtime)
|
|
226
|
-
return false;
|
|
227
|
-
if (runCommand(ctx, runtime.wrapInBulletListCommand.key))
|
|
228
|
-
return true;
|
|
229
|
-
return toggleListFallback(ctx, 'bullet');
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Toggle ordered list on the current block.
|
|
233
|
-
*/
|
|
234
|
-
export function toggleOrderedList(ctx) {
|
|
235
|
-
const runtime = getCommandRuntime();
|
|
236
|
-
if (!runtime)
|
|
237
|
-
return false;
|
|
238
|
-
if (runCommand(ctx, runtime.wrapInOrderedListCommand.key))
|
|
239
|
-
return true;
|
|
240
|
-
return toggleListFallback(ctx, 'ordered');
|
|
241
|
-
}
|
|
242
|
-
function toggleListFallback(ctx, listType) {
|
|
243
|
-
const runtime = getCommandRuntime();
|
|
244
|
-
if (!runtime)
|
|
245
|
-
return false;
|
|
246
|
-
try {
|
|
247
|
-
const { view, schema } = getEditorViewAndSchema(ctx);
|
|
248
|
-
if (!view || !schema)
|
|
249
|
-
return false;
|
|
250
|
-
const listItemType = schema.nodes['list_item'];
|
|
251
|
-
const listNodeType = listType === 'bullet' ? schema.nodes['bullet_list'] : schema.nodes['ordered_list'];
|
|
252
|
-
if (!listItemType || !listNodeType)
|
|
253
|
-
return false;
|
|
254
|
-
const activeBlock = getActiveBlockType(ctx);
|
|
255
|
-
const isSameList = activeBlock.type === 'listItem' && activeBlock.listType === listType;
|
|
256
|
-
const isOtherList = activeBlock.type === 'listItem' && activeBlock.listType && activeBlock.listType !== listType;
|
|
257
|
-
if (isSameList || isOtherList) {
|
|
258
|
-
const lifted = runtime.liftListItem(listItemType)(view.state, view.dispatch);
|
|
259
|
-
if (lifted && isSameList) {
|
|
260
|
-
view.focus();
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const wrapped = runtime.wrapInList(listNodeType)(view.state, view.dispatch);
|
|
265
|
-
if (wrapped) {
|
|
266
|
-
view.focus();
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
catch {
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Toggle blockquote on the current block.
|
|
277
|
-
*/
|
|
278
|
-
export function toggleBlockquote(ctx) {
|
|
279
|
-
const runtime = getCommandRuntime();
|
|
280
|
-
return runtime ? runCommand(ctx, runtime.wrapInBlockquoteCommand.key) : false;
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Indent a list item (sink).
|
|
284
|
-
*/
|
|
285
|
-
export function indentListItem(ctx) {
|
|
286
|
-
const runtime = getCommandRuntime();
|
|
287
|
-
return runtime ? runCommand(ctx, runtime.sinkListItemCommand.key) : false;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Outdent a list item (lift).
|
|
291
|
-
*/
|
|
292
|
-
export function outdentListItem(ctx) {
|
|
293
|
-
const runtime = getCommandRuntime();
|
|
294
|
-
return runtime ? runCommand(ctx, runtime.liftListItemCommand.key) : false;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Insert a horizontal rule.
|
|
298
|
-
*/
|
|
299
|
-
export function insertHorizontalRule(ctx) {
|
|
300
|
-
const runtime = getCommandRuntime();
|
|
301
|
-
return runtime ? runCommand(ctx, runtime.insertHrCommand.key) : false;
|
|
302
|
-
}
|
|
303
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
304
|
-
// History Commands
|
|
305
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
306
|
-
/**
|
|
307
|
-
* Undo the last action.
|
|
308
|
-
*/
|
|
309
|
-
export function undo(ctx) {
|
|
310
|
-
const runtime = getCommandRuntime();
|
|
311
|
-
return runtime ? runCommand(ctx, runtime.undoCommand.key) : false;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Redo the last undone action.
|
|
315
|
-
*/
|
|
316
|
-
export function redo(ctx) {
|
|
317
|
-
const runtime = getCommandRuntime();
|
|
318
|
-
return runtime ? runCommand(ctx, runtime.redoCommand.key) : false;
|
|
319
|
-
}
|
|
320
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
321
|
-
// Link Commands
|
|
322
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
323
|
-
/**
|
|
324
|
-
* Insert a link at the current cursor position (when no selection).
|
|
325
|
-
* This inserts text and applies the link mark in a single transaction.
|
|
326
|
-
*/
|
|
327
|
-
export function insertLinkAtCursor(ctx, text, url) {
|
|
328
|
-
try {
|
|
329
|
-
const view = getEditorView(ctx);
|
|
330
|
-
const schema = getEditorSchema(ctx);
|
|
331
|
-
if (!schema)
|
|
332
|
-
return false;
|
|
333
|
-
const linkMarkType = schema.marks['link'];
|
|
334
|
-
if (!view || !linkMarkType)
|
|
335
|
-
return false;
|
|
336
|
-
const { from } = view.state.selection;
|
|
337
|
-
const linkMark = linkMarkType.create({ href: url });
|
|
338
|
-
const tr = view.state.tr.insertText(text, from).addMark(from, from + text.length, linkMark);
|
|
339
|
-
view.dispatch(tr);
|
|
340
|
-
view.focus();
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
catch (error) {
|
|
344
|
-
if (shouldLogDevelopmentWarnings()) {
|
|
345
|
-
console.warn('[Editor] insertLinkAtCursor failed:', error);
|
|
346
|
-
}
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Apply a link mark to the current selection.
|
|
352
|
-
*/
|
|
353
|
-
export function applyLinkToSelection(ctx, url) {
|
|
354
|
-
try {
|
|
355
|
-
const view = getEditorView(ctx);
|
|
356
|
-
const schema = getEditorSchema(ctx);
|
|
357
|
-
if (!schema)
|
|
358
|
-
return false;
|
|
359
|
-
const linkMarkType = schema.marks['link'];
|
|
360
|
-
if (!view || !linkMarkType)
|
|
361
|
-
return false;
|
|
362
|
-
const { from, to } = view.state.selection;
|
|
363
|
-
if (from === to)
|
|
364
|
-
return false; // No selection
|
|
365
|
-
const linkMark = linkMarkType.create({ href: url });
|
|
366
|
-
const tr = view.state.tr.addMark(from, to, linkMark);
|
|
367
|
-
view.dispatch(tr);
|
|
368
|
-
view.focus();
|
|
369
|
-
return true;
|
|
370
|
-
}
|
|
371
|
-
catch (error) {
|
|
372
|
-
if (shouldLogDevelopmentWarnings()) {
|
|
373
|
-
console.warn('[Editor] applyLinkToSelection failed:', error);
|
|
374
|
-
}
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Update an existing link at the cursor position.
|
|
380
|
-
* Replaces the text and URL of the link the cursor is inside.
|
|
381
|
-
* Used when editing a link (cursor inside link, no selection).
|
|
382
|
-
*/
|
|
383
|
-
export function updateLinkAtCursor(ctx, text, url) {
|
|
384
|
-
try {
|
|
385
|
-
const view = getEditorView(ctx);
|
|
386
|
-
const schema = getEditorSchema(ctx);
|
|
387
|
-
if (!schema)
|
|
388
|
-
return false;
|
|
389
|
-
const linkMarkType = schema.marks['link'];
|
|
390
|
-
if (!view || !linkMarkType)
|
|
391
|
-
return false;
|
|
392
|
-
const { from } = view.state.selection;
|
|
393
|
-
const range = findMarkRange(view, linkMarkType, from);
|
|
394
|
-
if (!range)
|
|
395
|
-
return false;
|
|
396
|
-
const [start, end] = range;
|
|
397
|
-
const linkMark = linkMarkType.create({ href: url });
|
|
398
|
-
// Replace the existing link text with new text and apply link mark
|
|
399
|
-
const tr = view.state.tr
|
|
400
|
-
.delete(start, end)
|
|
401
|
-
.insertText(text, start)
|
|
402
|
-
.addMark(start, start + text.length, linkMark);
|
|
403
|
-
view.dispatch(tr);
|
|
404
|
-
view.focus();
|
|
405
|
-
return true;
|
|
406
|
-
}
|
|
407
|
-
catch (error) {
|
|
408
|
-
if (shouldLogDevelopmentWarnings()) {
|
|
409
|
-
console.warn('[Editor] updateLinkAtCursor failed:', error);
|
|
410
|
-
}
|
|
411
|
-
return false;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* Find the range of a specific mark instance at a given position.
|
|
416
|
-
* Returns [start, end] if mark exists at position, null otherwise.
|
|
417
|
-
*
|
|
418
|
-
* IMPORTANT: This compares mark instances (same type AND same attributes),
|
|
419
|
-
* not just mark types. This ensures adjacent links with different URLs
|
|
420
|
-
* are treated as separate ranges.
|
|
421
|
-
*/
|
|
422
|
-
function findMarkRange(view, markType, pos) {
|
|
423
|
-
const $pos = view.state.doc.resolve(pos);
|
|
424
|
-
const parent = $pos.parent;
|
|
425
|
-
// Get the specific mark instance at the cursor position.
|
|
426
|
-
// $pos.marks() returns marks AFTER the position, so if cursor is at end of
|
|
427
|
-
// marked text, we need to also check nodeBefore and nodeAfter.
|
|
428
|
-
let targetMark = markType.isInSet($pos.marks());
|
|
429
|
-
// If not found, check the node before (handles cursor at end of marked text)
|
|
430
|
-
if (!targetMark && $pos.nodeBefore) {
|
|
431
|
-
targetMark = markType.isInSet($pos.nodeBefore.marks);
|
|
432
|
-
}
|
|
433
|
-
// If still not found, check the node after (handles cursor at start of marked text)
|
|
434
|
-
if (!targetMark && $pos.nodeAfter) {
|
|
435
|
-
targetMark = markType.isInSet($pos.nodeAfter.marks);
|
|
436
|
-
}
|
|
437
|
-
if (!targetMark) {
|
|
438
|
-
return null;
|
|
439
|
-
}
|
|
440
|
-
// Helper to check if a node has the same mark instance (type + attributes)
|
|
441
|
-
const hasSameMark = (marks) => {
|
|
442
|
-
const mark = markType.isInSet(marks);
|
|
443
|
-
return mark !== undefined && mark.eq(targetMark);
|
|
444
|
-
};
|
|
445
|
-
// When cursor is at end of parent content, index equals childCount (out of bounds).
|
|
446
|
-
// Clamp to valid range for iteration.
|
|
447
|
-
const startIndex = Math.min($pos.index(), parent.childCount - 1);
|
|
448
|
-
// Find start by walking backward from current index
|
|
449
|
-
let start = $pos.start();
|
|
450
|
-
for (let i = startIndex; i >= 0; i--) {
|
|
451
|
-
const child = parent.child(i);
|
|
452
|
-
if (!hasSameMark(child.marks)) {
|
|
453
|
-
// Mark starts after this node - sum up sizes of nodes before current
|
|
454
|
-
for (let j = 0; j <= i; j++) {
|
|
455
|
-
start += parent.child(j).nodeSize;
|
|
456
|
-
}
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
459
|
-
if (i === 0) {
|
|
460
|
-
// Mark starts at beginning of parent
|
|
461
|
-
start = $pos.start();
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
// Find end by walking forward from current index
|
|
465
|
-
let end = $pos.start();
|
|
466
|
-
for (let i = 0; i < parent.childCount; i++) {
|
|
467
|
-
const child = parent.child(i);
|
|
468
|
-
end += child.nodeSize;
|
|
469
|
-
if (i >= startIndex && !hasSameMark(child.marks)) {
|
|
470
|
-
// Mark ends before this node
|
|
471
|
-
end -= child.nodeSize;
|
|
472
|
-
break;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
return [start, end];
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Remove link mark from the current selection or a specified range.
|
|
479
|
-
*
|
|
480
|
-
* @param ctx - Milkdown editor context
|
|
481
|
-
* @param range - Optional pre-computed range [from, to] to remove link from.
|
|
482
|
-
* If not provided, uses current selection (or finds link at cursor).
|
|
483
|
-
* Pass this when the editor may have lost focus (e.g., popover interactions).
|
|
484
|
-
*/
|
|
485
|
-
export function removeLink(ctx, range) {
|
|
486
|
-
try {
|
|
487
|
-
const view = getEditorView(ctx);
|
|
488
|
-
const schema = getEditorSchema(ctx);
|
|
489
|
-
if (!schema)
|
|
490
|
-
return false;
|
|
491
|
-
const linkMarkType = schema.marks['link'];
|
|
492
|
-
if (!view || !linkMarkType)
|
|
493
|
-
return false;
|
|
494
|
-
let from;
|
|
495
|
-
let to;
|
|
496
|
-
if (range) {
|
|
497
|
-
// Use pre-computed range (preferred when called from popovers/dialogs)
|
|
498
|
-
[from, to] = range;
|
|
499
|
-
}
|
|
500
|
-
else {
|
|
501
|
-
// Fall back to current selection
|
|
502
|
-
({ from, to } = view.state.selection);
|
|
503
|
-
// If selection is collapsed, find the link mark range
|
|
504
|
-
if (from === to) {
|
|
505
|
-
const foundRange = findMarkRange(view, linkMarkType, from);
|
|
506
|
-
if (!foundRange)
|
|
507
|
-
return false;
|
|
508
|
-
[from, to] = foundRange;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
const tr = view.state.tr.removeMark(from, to, linkMarkType);
|
|
512
|
-
view.dispatch(tr);
|
|
513
|
-
view.focus();
|
|
514
|
-
return true;
|
|
515
|
-
}
|
|
516
|
-
catch (error) {
|
|
517
|
-
if (shouldLogDevelopmentWarnings()) {
|
|
518
|
-
console.warn('[Editor] removeLink failed:', error);
|
|
519
|
-
}
|
|
520
|
-
return false;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Get the link URL at the current cursor position, if any.
|
|
525
|
-
*/
|
|
526
|
-
export function getLinkAtCursor(ctx) {
|
|
527
|
-
try {
|
|
528
|
-
const view = getEditorView(ctx);
|
|
529
|
-
const schema = getEditorSchema(ctx);
|
|
530
|
-
if (!schema)
|
|
531
|
-
return null;
|
|
532
|
-
const linkMarkType = schema.marks['link'];
|
|
533
|
-
if (!view || !linkMarkType)
|
|
534
|
-
return null;
|
|
535
|
-
const { $from } = view.state.selection;
|
|
536
|
-
const linkMark = linkMarkType.isInSet($from.marks());
|
|
537
|
-
if (linkMark) {
|
|
538
|
-
const href = linkMark.attrs['href'];
|
|
539
|
-
return typeof href === 'string' ? href : null;
|
|
540
|
-
}
|
|
541
|
-
return null;
|
|
542
|
-
}
|
|
543
|
-
catch {
|
|
544
|
-
return null;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Get the link text at the current cursor position, if cursor is inside a link.
|
|
549
|
-
* Returns the full link text even when selection is collapsed.
|
|
550
|
-
*/
|
|
551
|
-
export function getLinkTextAtCursor(ctx) {
|
|
552
|
-
try {
|
|
553
|
-
const view = getEditorView(ctx);
|
|
554
|
-
const schema = getEditorSchema(ctx);
|
|
555
|
-
if (!schema)
|
|
556
|
-
return null;
|
|
557
|
-
const linkMarkType = schema.marks['link'];
|
|
558
|
-
if (!view || !linkMarkType)
|
|
559
|
-
return null;
|
|
560
|
-
const { from } = view.state.selection;
|
|
561
|
-
const range = findMarkRange(view, linkMarkType, from);
|
|
562
|
-
if (!range)
|
|
563
|
-
return null;
|
|
564
|
-
const [start, end] = range;
|
|
565
|
-
return view.state.doc.textBetween(start, end);
|
|
566
|
-
}
|
|
567
|
-
catch {
|
|
568
|
-
return null;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Get the link range at the current cursor position.
|
|
573
|
-
* Returns [from, to] if cursor is inside a link, null otherwise.
|
|
574
|
-
*
|
|
575
|
-
* Use this to capture the link range before focus leaves the editor
|
|
576
|
-
* (e.g., when opening a popover), then pass the range to removeLink.
|
|
577
|
-
*/
|
|
578
|
-
export function getLinkRangeAtCursor(ctx) {
|
|
579
|
-
try {
|
|
580
|
-
const view = getEditorView(ctx);
|
|
581
|
-
const schema = getEditorSchema(ctx);
|
|
582
|
-
if (!schema)
|
|
583
|
-
return null;
|
|
584
|
-
const linkMarkType = schema.marks['link'];
|
|
585
|
-
if (!view || !linkMarkType)
|
|
586
|
-
return null;
|
|
587
|
-
const { from } = view.state.selection;
|
|
588
|
-
return findMarkRange(view, linkMarkType, from);
|
|
589
|
-
}
|
|
590
|
-
catch {
|
|
591
|
-
return null;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
595
|
-
// State Queries
|
|
596
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
597
|
-
/**
|
|
598
|
-
* Check if a mark type is active at the current selection.
|
|
599
|
-
*/
|
|
600
|
-
export function isMarkActive(view, markType) {
|
|
601
|
-
const { from, $from, to, empty } = view.state.selection;
|
|
602
|
-
if (empty) {
|
|
603
|
-
return !!markType.isInSet(view.state.storedMarks || $from.marks());
|
|
604
|
-
}
|
|
605
|
-
return view.state.doc.rangeHasMark(from, to, markType);
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Get all active marks at the current selection.
|
|
609
|
-
*/
|
|
610
|
-
export function getActiveMarks(ctx) {
|
|
611
|
-
const result = {
|
|
612
|
-
bold: false,
|
|
613
|
-
italic: false,
|
|
614
|
-
code: false,
|
|
615
|
-
strikethrough: false,
|
|
616
|
-
link: false,
|
|
617
|
-
};
|
|
618
|
-
try {
|
|
619
|
-
const view = getEditorView(ctx);
|
|
620
|
-
const schema = getEditorSchema(ctx);
|
|
621
|
-
if (!view || !schema)
|
|
622
|
-
return result;
|
|
623
|
-
const strongMark = schema.marks['strong'];
|
|
624
|
-
const emphasisMark = schema.marks['emphasis'];
|
|
625
|
-
const codeMark = schema.marks['code'];
|
|
626
|
-
const strikethroughMark = schema.marks['strikethrough'];
|
|
627
|
-
const linkMark = schema.marks['link'];
|
|
628
|
-
if (strongMark) {
|
|
629
|
-
result.bold = isMarkActive(view, strongMark);
|
|
630
|
-
}
|
|
631
|
-
if (emphasisMark) {
|
|
632
|
-
result.italic = isMarkActive(view, emphasisMark);
|
|
633
|
-
}
|
|
634
|
-
if (codeMark) {
|
|
635
|
-
result.code = isMarkActive(view, codeMark);
|
|
636
|
-
}
|
|
637
|
-
if (strikethroughMark) {
|
|
638
|
-
result.strikethrough = isMarkActive(view, strikethroughMark);
|
|
639
|
-
}
|
|
640
|
-
if (linkMark) {
|
|
641
|
-
result.link = isMarkActive(view, linkMark);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
catch {
|
|
645
|
-
// Return default values on error
|
|
646
|
-
}
|
|
647
|
-
return result;
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Get the active block type at the current selection.
|
|
651
|
-
*/
|
|
652
|
-
export function getActiveBlockType(ctx) {
|
|
653
|
-
const result = { type: 'paragraph' };
|
|
654
|
-
try {
|
|
655
|
-
const view = getEditorView(ctx);
|
|
656
|
-
const schema = getEditorSchema(ctx);
|
|
657
|
-
if (!view || !schema)
|
|
658
|
-
return result;
|
|
659
|
-
const { $from } = view.state.selection;
|
|
660
|
-
// Walk up the document tree to find the block type
|
|
661
|
-
for (let depth = $from.depth; depth >= 0; depth--) {
|
|
662
|
-
const node = $from.node(depth);
|
|
663
|
-
if (node.type === schema.nodes['heading']) {
|
|
664
|
-
const headingLevel = node.attrs['level'];
|
|
665
|
-
if (!isHeadingLevel(headingLevel))
|
|
666
|
-
return { type: 'unknown' };
|
|
667
|
-
return {
|
|
668
|
-
type: 'heading',
|
|
669
|
-
headingLevel,
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
if (node.type === schema.nodes['blockquote']) {
|
|
673
|
-
return { type: 'blockquote' };
|
|
674
|
-
}
|
|
675
|
-
if (node.type === schema.nodes['code_block']) {
|
|
676
|
-
return { type: 'codeBlock' };
|
|
677
|
-
}
|
|
678
|
-
if (node.type === schema.nodes['list_item']) {
|
|
679
|
-
const parent = depth > 0 ? $from.node(depth - 1) : null;
|
|
680
|
-
if (parent?.type === schema.nodes['bullet_list']) {
|
|
681
|
-
return { type: 'listItem', listType: 'bullet' };
|
|
682
|
-
}
|
|
683
|
-
if (parent?.type === schema.nodes['ordered_list']) {
|
|
684
|
-
return { type: 'listItem', listType: 'ordered' };
|
|
685
|
-
}
|
|
686
|
-
return { type: 'listItem' };
|
|
687
|
-
}
|
|
688
|
-
if (node.type === schema.nodes['paragraph']) {
|
|
689
|
-
return { type: 'paragraph' };
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
catch {
|
|
694
|
-
// Return default values on error
|
|
695
|
-
}
|
|
696
|
-
return result;
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* Check if the current selection is collapsed (cursor only, no selection).
|
|
700
|
-
*/
|
|
701
|
-
export function isSelectionCollapsed(ctx) {
|
|
702
|
-
try {
|
|
703
|
-
const view = getEditorView(ctx);
|
|
704
|
-
if (!view)
|
|
705
|
-
return true;
|
|
706
|
-
return view.state.selection.empty;
|
|
707
|
-
}
|
|
708
|
-
catch {
|
|
709
|
-
return true;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Get the selected text, if any.
|
|
714
|
-
*/
|
|
715
|
-
export function getSelectedText(ctx) {
|
|
716
|
-
try {
|
|
717
|
-
const view = getEditorView(ctx);
|
|
718
|
-
if (!view)
|
|
719
|
-
return '';
|
|
720
|
-
const { from, to } = view.state.selection;
|
|
721
|
-
if (from === to)
|
|
722
|
-
return '';
|
|
723
|
-
return view.state.doc.textBetween(from, to);
|
|
724
|
-
}
|
|
725
|
-
catch {
|
|
726
|
-
return '';
|
|
727
|
-
}
|
|
728
|
-
}
|