@lostgradient/cinder 0.16.0 → 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 +191 -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/data-table/index.js +88 -31
- 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/table/index.js +85 -28
- package/dist/components/table/table.css +11 -0
- package/dist/components/table/table.schema.js +10 -1
- package/dist/components/table/table.types.d.ts +24 -1
- 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 +15394 -16128
- 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 +3 -3
- 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 +3 -3
- 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 +106 -116
- package/dist/server/{index.server-7yfz2t73.js → index.server-003t81xk.js} +1 -1
- package/dist/server/{index.server-mehav5vs.js → index.server-032p855q.js} +5 -5
- 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-ne4gzxvz.js → index.server-q5gvb174.js} +5 -5
- 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-xanq9ppe.js +119 -0
- 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/table/table.css +11 -0
- package/src/components/table/table.examples.json +3 -3
- package/src/components/table/table.schema.json +9 -0
- package/src/components/table/table.schema.ts +11 -0
- package/src/components/table/table.svelte +58 -14
- package/src/components/table/table.types.ts +27 -1
- 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-mzj20rfz.js +0 -77
- 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
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser-safe editor surface for Svelte components.
|
|
3
|
-
*
|
|
4
|
-
* This subpath intentionally excludes template rendering helpers that load the
|
|
5
|
-
* markdown rendering pipeline at module-evaluation time.
|
|
6
|
-
*
|
|
7
|
-
* This module is the **single canonical re-export source** for the symbols
|
|
8
|
-
* listed below. `./index.ts` (the package root) re-exports these names from
|
|
9
|
-
* here rather than from `./commands.js` directly, so every consumer of the
|
|
10
|
-
* package sees one re-export path per name. Bun's bundler on Linux emits a
|
|
11
|
-
* `Duplicate export of '<name>'` SyntaxError at module evaluation when both
|
|
12
|
-
* package entry points re-export the same name from `./commands.js`
|
|
13
|
-
* independently — routing index through component-runtime collapses those
|
|
14
|
-
* two paths into one and eliminates the duplicate.
|
|
15
|
-
*/
|
|
16
|
-
export { createEditorAttachment } from './attach.js';
|
|
17
|
-
export { applyLinkToSelection, getActiveBlockType, getActiveMarks, getLinkAtCursor, getLinkRangeAtCursor, getLinkTextAtCursor, insertLinkAtCursor, isSelectionCollapsed, redo, removeLink, setHeading, setParagraph, toggleBlockquote, toggleBold, toggleBulletList, toggleCode, toggleItalic, toggleOrderedList, toggleStrikethrough, undo, updateLinkAtCursor, } from './commands.js';
|
|
18
|
-
export { setEditorReadonly } from './editor.js';
|
|
19
|
-
export { getShortcutDisplay } from './keymap-plugin.js';
|
|
20
|
-
export { DEFAULT_DEBOUNCE_MS } from './types.js';
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Milkdown editor initialization.
|
|
3
|
-
*
|
|
4
|
-
* This module configures Milkdown with CommonMark + GFM support,
|
|
5
|
-
* integrating with the DEP-35 pipeline for consistent serialization.
|
|
6
|
-
*/
|
|
7
|
-
import { DEFAULT_DEBOUNCE_MS } from './types.js';
|
|
8
|
-
function shouldLogDevelopmentWarnings() {
|
|
9
|
-
return typeof process === 'undefined' || process.env.NODE_ENV !== 'production';
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Create and configure a Milkdown editor instance.
|
|
13
|
-
*
|
|
14
|
-
* @param container - DOM element to mount the editor in
|
|
15
|
-
* @param config - Editor configuration
|
|
16
|
-
* @returns Promise resolving to EditorState for imperative control
|
|
17
|
-
*/
|
|
18
|
-
export async function createEditor(container, config = {}) {
|
|
19
|
-
if (typeof document === 'undefined') {
|
|
20
|
-
throw new Error('createEditor() requires a browser document.');
|
|
21
|
-
}
|
|
22
|
-
const [{ Editor, rootCtx, defaultValueCtx, editorViewCtx, editorViewOptionsCtx }, { commonmark }, { gfm }, { history }, { listener, listenerCtx }, { getMarkdown, replaceAll }, { preloadCommandRuntime }, { placeholderPlugin }, { createEditorKeymap }, { clipboardPlugin }, { linkInputRulePlugin }, { createTemplateCompletionPlugin }, { createTemplateInvalidDecorationPlugin },] = await Promise.all([
|
|
23
|
-
import('@milkdown/kit/core'),
|
|
24
|
-
import('@milkdown/kit/preset/commonmark'),
|
|
25
|
-
import('@milkdown/kit/preset/gfm'),
|
|
26
|
-
import('@milkdown/kit/plugin/history'),
|
|
27
|
-
import('@milkdown/kit/plugin/listener'),
|
|
28
|
-
import('@milkdown/kit/utils'),
|
|
29
|
-
import('./commands.js'),
|
|
30
|
-
import('./placeholder.js'),
|
|
31
|
-
import('./keymap-plugin.js'),
|
|
32
|
-
import('./clipboard.js'),
|
|
33
|
-
import('./link-input-rule.js'),
|
|
34
|
-
import('./template-completion-plugin.js'),
|
|
35
|
-
import('./template-invalid-decoration-plugin.js'),
|
|
36
|
-
]);
|
|
37
|
-
await preloadCommandRuntime();
|
|
38
|
-
const { initialContent = '', readonly = false, ariaLabel, changeDebounceMs = DEFAULT_DEBOUNCE_MS, onchange, onselectionchange, onlinkshortcut, oncommentshortcut, plugins = [], placeholderCompletion, placeholderDecoration, } = config;
|
|
39
|
-
const resolvedAriaLabel = typeof ariaLabel === 'string' && ariaLabel.trim().length > 0 ? ariaLabel.trim() : undefined;
|
|
40
|
-
// Track if we're updating from external source to prevent loops
|
|
41
|
-
let isExternalUpdate = false;
|
|
42
|
-
// Track if editor is destroyed to prevent accessing context after cleanup
|
|
43
|
-
let isDestroyed = false;
|
|
44
|
-
let debounceTimeout = null;
|
|
45
|
-
// Build the editor
|
|
46
|
-
let builder = Editor.make()
|
|
47
|
-
.config((ctx) => {
|
|
48
|
-
ctx.set(rootCtx, container);
|
|
49
|
-
ctx.set(defaultValueCtx, initialContent);
|
|
50
|
-
if (resolvedAriaLabel) {
|
|
51
|
-
ctx.update(editorViewOptionsCtx, (previous) => {
|
|
52
|
-
const previousAttributes = previous.attributes;
|
|
53
|
-
return {
|
|
54
|
-
...previous,
|
|
55
|
-
attributes: typeof previousAttributes === 'function'
|
|
56
|
-
? (state) => ({ ...previousAttributes(state), 'aria-label': resolvedAriaLabel })
|
|
57
|
-
: { ...previousAttributes, 'aria-label': resolvedAriaLabel },
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
.config((ctx) => {
|
|
63
|
-
// Set up change listener
|
|
64
|
-
const listenerManager = ctx.get(listenerCtx);
|
|
65
|
-
listenerManager.markdownUpdated((_ctx, markdown, prevMarkdown) => {
|
|
66
|
-
// Skip if editor is destroyed (debounced callback fired after cleanup)
|
|
67
|
-
if (isDestroyed)
|
|
68
|
-
return;
|
|
69
|
-
// Skip if this is an external update (from setMarkdown)
|
|
70
|
-
if (isExternalUpdate)
|
|
71
|
-
return;
|
|
72
|
-
// Skip if content unchanged
|
|
73
|
-
if (markdown === prevMarkdown)
|
|
74
|
-
return;
|
|
75
|
-
// Debounce onChange calls
|
|
76
|
-
if (debounceTimeout)
|
|
77
|
-
clearTimeout(debounceTimeout);
|
|
78
|
-
debounceTimeout = setTimeout(() => {
|
|
79
|
-
if (isDestroyed)
|
|
80
|
-
return; // Guard after debounce
|
|
81
|
-
onchange?.(markdown);
|
|
82
|
-
}, changeDebounceMs);
|
|
83
|
-
});
|
|
84
|
-
// Selection change tracking (for DEP-39 comment anchoring and toolbar state)
|
|
85
|
-
// We need TWO listeners:
|
|
86
|
-
// 1. selectionUpdated - fires on selection-only changes (user clicks without editing)
|
|
87
|
-
// 2. updated - fires on document changes (which also change the selection position)
|
|
88
|
-
// Together, these ensure the toolbar always reflects the current cursor position.
|
|
89
|
-
if (onselectionchange) {
|
|
90
|
-
const notifySelectionChange = (listenerContext) => {
|
|
91
|
-
// Skip if editor is destroyed
|
|
92
|
-
if (isDestroyed)
|
|
93
|
-
return;
|
|
94
|
-
// Wrap context access in try-catch - Milkdown may have already cleared
|
|
95
|
-
// its context registry during unmount, causing ctx.get() to throw
|
|
96
|
-
let view;
|
|
97
|
-
try {
|
|
98
|
-
view = listenerContext.get(editorViewCtx);
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
// Context already destroyed during cleanup, silently ignore
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
// Guard against view not being ready or state not yet attached
|
|
105
|
-
if (!view?.state)
|
|
106
|
-
return;
|
|
107
|
-
const { from, to } = view.state.selection;
|
|
108
|
-
const selection = {
|
|
109
|
-
from,
|
|
110
|
-
to,
|
|
111
|
-
isCollapsed: from === to,
|
|
112
|
-
};
|
|
113
|
-
onselectionchange(selection);
|
|
114
|
-
};
|
|
115
|
-
// Listen for selection-only changes (clicking without editing)
|
|
116
|
-
listenerManager.selectionUpdated(notifySelectionChange);
|
|
117
|
-
// Listen for document changes (which also affect selection position)
|
|
118
|
-
listenerManager.updated(notifySelectionChange);
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
.use(commonmark)
|
|
122
|
-
.use(gfm)
|
|
123
|
-
.use(linkInputRulePlugin)
|
|
124
|
-
.use(clipboardPlugin)
|
|
125
|
-
.use(history)
|
|
126
|
-
.use(createEditorKeymap({
|
|
127
|
-
...(onlinkshortcut ? { onlinkshortcut } : {}),
|
|
128
|
-
...(oncommentshortcut ? { oncommentshortcut } : {}),
|
|
129
|
-
})) // DEP-37/47: Keyboard shortcuts
|
|
130
|
-
.use(listener)
|
|
131
|
-
.use(placeholderPlugin);
|
|
132
|
-
// DEP-583: Conditionally register placeholder completion plugin
|
|
133
|
-
if (placeholderCompletion) {
|
|
134
|
-
const completionConfig = placeholderCompletion;
|
|
135
|
-
builder = builder.use(createTemplateCompletionPlugin(() => completionConfig));
|
|
136
|
-
}
|
|
137
|
-
// DEP-583: Conditionally register placeholder invalid decoration plugin
|
|
138
|
-
if (placeholderDecoration) {
|
|
139
|
-
const decorationConfig = placeholderDecoration;
|
|
140
|
-
builder = builder.use(createTemplateInvalidDecorationPlugin(() => decorationConfig.candidates, decorationConfig.invalidClassName ? () => decorationConfig.invalidClassName : undefined));
|
|
141
|
-
}
|
|
142
|
-
// Apply additional plugins (for DEP-39 anchoring, decorations, etc.)
|
|
143
|
-
const editor = await builder.use(plugins).create();
|
|
144
|
-
// Get the view for direct access
|
|
145
|
-
const view = editor.ctx.get(editorViewCtx);
|
|
146
|
-
// Apply readonly state
|
|
147
|
-
if (readonly && view) {
|
|
148
|
-
view.setProps({ editable: () => false });
|
|
149
|
-
}
|
|
150
|
-
// Apply aria-label to the ProseMirror DOM element (the element with role="textbox")
|
|
151
|
-
if (resolvedAriaLabel && view?.dom) {
|
|
152
|
-
view.dom.setAttribute('aria-label', resolvedAriaLabel);
|
|
153
|
-
}
|
|
154
|
-
// Build the state object
|
|
155
|
-
const state = {
|
|
156
|
-
editor,
|
|
157
|
-
view,
|
|
158
|
-
focus() {
|
|
159
|
-
view?.focus();
|
|
160
|
-
},
|
|
161
|
-
getMarkdown() {
|
|
162
|
-
return editor.action(getMarkdown());
|
|
163
|
-
},
|
|
164
|
-
setMarkdown(content) {
|
|
165
|
-
// Clear any pending debounce to prevent stale callbacks
|
|
166
|
-
if (debounceTimeout) {
|
|
167
|
-
clearTimeout(debounceTimeout);
|
|
168
|
-
debounceTimeout = null;
|
|
169
|
-
}
|
|
170
|
-
isExternalUpdate = true;
|
|
171
|
-
editor.action(replaceAll(content));
|
|
172
|
-
// Reset flag after microtask
|
|
173
|
-
queueMicrotask(() => {
|
|
174
|
-
isExternalUpdate = false;
|
|
175
|
-
});
|
|
176
|
-
},
|
|
177
|
-
clearPendingTimers() {
|
|
178
|
-
if (debounceTimeout) {
|
|
179
|
-
clearTimeout(debounceTimeout);
|
|
180
|
-
debounceTimeout = null;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
markDestroyed() {
|
|
184
|
-
isDestroyed = true;
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
return state;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Update the readonly state of an editor.
|
|
191
|
-
*/
|
|
192
|
-
export function setEditorReadonly(state, readonly) {
|
|
193
|
-
state.view?.setProps({ editable: () => !readonly });
|
|
194
|
-
}
|
|
195
|
-
// Track stderr suppression nesting to prevent race conditions (DEP-139).
|
|
196
|
-
// When multiple destroyEditor calls execute concurrently, we need reference counting
|
|
197
|
-
// to ensure we only restore stderr when the outermost call completes.
|
|
198
|
-
let stderrSuppressionDepth = 0;
|
|
199
|
-
let originalStderrWrite = null;
|
|
200
|
-
function writeWithSuppressedMilkdownErrors(chunk, encodingOrCallback, callback) {
|
|
201
|
-
const message = typeof chunk === 'string' ? chunk : chunk.toString();
|
|
202
|
-
if (message.includes('MilkdownError')) {
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
if (!originalStderrWrite)
|
|
206
|
-
return true;
|
|
207
|
-
if (typeof encodingOrCallback === 'function') {
|
|
208
|
-
return originalStderrWrite(chunk, encodingOrCallback);
|
|
209
|
-
}
|
|
210
|
-
return originalStderrWrite(chunk, encodingOrCallback, callback);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Destroy an editor instance and clean up resources.
|
|
214
|
-
*/
|
|
215
|
-
export function destroyEditor(state) {
|
|
216
|
-
// Mark destroyed first to prevent debounced callbacks from accessing context
|
|
217
|
-
state.markDestroyed();
|
|
218
|
-
state.clearPendingTimers();
|
|
219
|
-
// Suppress MilkdownError stderr output during destruction (DEP-139).
|
|
220
|
-
// Milkdown logs "Context editorView not found" errors to stderr during teardown
|
|
221
|
-
// when it accesses its own context that's being destroyed. These are harmless.
|
|
222
|
-
// Only applicable in Node/test environments; browser builds don't have process.stderr.
|
|
223
|
-
const stderr = typeof process !== 'undefined' ? process.stderr : undefined;
|
|
224
|
-
if (stderr) {
|
|
225
|
-
// Increment depth and capture original on first entry
|
|
226
|
-
if (stderrSuppressionDepth === 0) {
|
|
227
|
-
originalStderrWrite = stderr.write.bind(stderr);
|
|
228
|
-
stderr.write = writeWithSuppressedMilkdownErrors;
|
|
229
|
-
}
|
|
230
|
-
stderrSuppressionDepth++;
|
|
231
|
-
}
|
|
232
|
-
try {
|
|
233
|
-
void state.editor.destroy();
|
|
234
|
-
}
|
|
235
|
-
catch (error) {
|
|
236
|
-
// Milkdown can throw during teardown if its context registry has already been cleared
|
|
237
|
-
// (e.g. rapid mount/unmount in tests). Destroy should never crash the app.
|
|
238
|
-
// Suppress "Context editorView not found" errors during cleanup - they're harmless.
|
|
239
|
-
const isMilkdownContextError = error instanceof Error &&
|
|
240
|
-
error.message.includes('Context') &&
|
|
241
|
-
error.message.includes('not found');
|
|
242
|
-
if (!isMilkdownContextError && shouldLogDevelopmentWarnings()) {
|
|
243
|
-
console.warn('[Editor] Failed to destroy Milkdown editor:', error);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
finally {
|
|
247
|
-
// Decrement depth and restore stderr only when reaching zero
|
|
248
|
-
if (stderr) {
|
|
249
|
-
stderrSuppressionDepth--;
|
|
250
|
-
if (stderrSuppressionDepth === 0 && originalStderrWrite) {
|
|
251
|
-
stderr.write = originalStderrWrite;
|
|
252
|
-
originalStderrWrite = null;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Milkdown editor integration for SvelteKit.
|
|
3
|
-
*
|
|
4
|
-
* This module provides the core editor functionality for the
|
|
5
|
-
* Markdown Review Editor, integrating Milkdown (ProseMirror-based)
|
|
6
|
-
* with Svelte 5 patterns.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```svelte
|
|
10
|
-
* <script>
|
|
11
|
-
* import { createEditorAttachment, type EditorHandle } from '$lib/editor';
|
|
12
|
-
*
|
|
13
|
-
* let markdown = $state('# Hello');
|
|
14
|
-
* let handle: EditorHandle | null = null;
|
|
15
|
-
* </script>
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @packageDocumentation
|
|
19
|
-
*/
|
|
20
|
-
// Browser-safe surface — single canonical re-export path.
|
|
21
|
-
// Symbols overlapping with `./component-runtime.js` flow through that module
|
|
22
|
-
// so Bun's bundler sees one re-export path per name (see comment in
|
|
23
|
-
// `./component-runtime.ts` for the duplicate-export-on-Linux background).
|
|
24
|
-
export { DEFAULT_DEBOUNCE_MS, applyLinkToSelection, createEditorAttachment, getActiveBlockType, getActiveMarks, getLinkAtCursor, getLinkRangeAtCursor, getLinkTextAtCursor, getShortcutDisplay, insertLinkAtCursor, isSelectionCollapsed, redo, removeLink, setEditorReadonly, setHeading, setParagraph, toggleBlockquote, toggleBold, toggleBulletList, toggleCode, toggleItalic, toggleOrderedList, toggleStrikethrough, undo, updateLinkAtCursor, } from './component-runtime.js';
|
|
25
|
-
// Server-or-advanced surface — names not in component-runtime.
|
|
26
|
-
export { createEditor, destroyEditor } from './editor.js';
|
|
27
|
-
// Position mapping (DEP-39)
|
|
28
|
-
export { buildTextToProseMirrorPositionMap, enrichSelectionWithSource, mapPosToSource, mapSourceToPos, proseMirrorPositionToTextOffset, textOffsetToLineColumn, textOffsetToProseMirrorPosition, } from './bridge.js';
|
|
29
|
-
// Commands not in component-runtime
|
|
30
|
-
export { getSelectedText, indentListItem, insertHorizontalRule, isMarkActive, outdentListItem, } from './commands.js';
|
|
31
|
-
// Keymap plugin extras (DEP-37) — getShortcutDisplay comes from component-runtime
|
|
32
|
-
export { createEditorKeymap, editorKeymap, getShortcutDefinitions, } from './keymap-plugin.js';
|
|
33
|
-
// Template placeholders (DEP-582, DEP-625)
|
|
34
|
-
export { buildPlaceholderCandidatesFromJsonSchema, isBlockedSegment, parsePlaceholderTokens, resolveTemplatePlaceholders, validatePlaceholderTokens, } from './template-placeholders.js';
|
|
35
|
-
// Template rendering (DEP-625)
|
|
36
|
-
// Not re-exported here to avoid loading heavy @cinder/markdown pipeline for lightweight placeholder operations
|
|
37
|
-
// Import from '../editor/template-render.js' instead
|
|
38
|
-
// Placeholder security (DEP-625)
|
|
39
|
-
export { RESERVED_SEGMENTS } from './placeholder-security.js';
|
|
40
|
-
// Template placeholder plugins (DEP-583)
|
|
41
|
-
export { createTemplateCompletionPlugin, templateCompletionPluginKey, } from './template-completion-plugin.js';
|
|
42
|
-
export { createTemplateInvalidDecorationPlugin, templateInvalidDecorationPluginKey, } from './template-invalid-decoration-plugin.js';
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keyboard shortcuts plugin for the Milkdown editor.
|
|
3
|
-
*
|
|
4
|
-
* IMPORTANT: Uses $shortcut + callCommand (NOT raw ProseMirror keymap).
|
|
5
|
-
* This ensures bindings are registered after editor init and respect Milkdown contexts.
|
|
6
|
-
*/
|
|
7
|
-
let shortcutRuntime = null;
|
|
8
|
-
let shortcutRuntimePromise = null;
|
|
9
|
-
async function resolveShortcutRuntime() {
|
|
10
|
-
if (shortcutRuntime)
|
|
11
|
-
return shortcutRuntime;
|
|
12
|
-
shortcutRuntimePromise ??= (async () => {
|
|
13
|
-
const [utilities, commonmark, gfm, history] = await Promise.all([
|
|
14
|
-
import('@milkdown/kit/utils'),
|
|
15
|
-
import('@milkdown/kit/preset/commonmark'),
|
|
16
|
-
import('@milkdown/kit/preset/gfm'),
|
|
17
|
-
import('@milkdown/kit/plugin/history'),
|
|
18
|
-
]);
|
|
19
|
-
return {
|
|
20
|
-
$shortcut: utilities.$shortcut,
|
|
21
|
-
callCommand: utilities.callCommand,
|
|
22
|
-
toggleStrongCommand: commonmark.toggleStrongCommand,
|
|
23
|
-
toggleEmphasisCommand: commonmark.toggleEmphasisCommand,
|
|
24
|
-
toggleInlineCodeCommand: commonmark.toggleInlineCodeCommand,
|
|
25
|
-
wrapInHeadingCommand: commonmark.wrapInHeadingCommand,
|
|
26
|
-
wrapInBulletListCommand: commonmark.wrapInBulletListCommand,
|
|
27
|
-
wrapInOrderedListCommand: commonmark.wrapInOrderedListCommand,
|
|
28
|
-
wrapInBlockquoteCommand: commonmark.wrapInBlockquoteCommand,
|
|
29
|
-
insertHrCommand: commonmark.insertHrCommand,
|
|
30
|
-
sinkListItemCommand: commonmark.sinkListItemCommand,
|
|
31
|
-
liftListItemCommand: commonmark.liftListItemCommand,
|
|
32
|
-
toggleStrikethroughCommand: gfm.toggleStrikethroughCommand,
|
|
33
|
-
undoCommand: history.undoCommand,
|
|
34
|
-
redoCommand: history.redoCommand,
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
|
-
shortcutRuntime = await shortcutRuntimePromise;
|
|
38
|
-
return shortcutRuntime;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Create keyboard shortcuts plugin for the Milkdown editor.
|
|
42
|
-
*
|
|
43
|
-
* @param options - Optional callbacks for shortcuts that need external handling
|
|
44
|
-
* @returns Milkdown plugin with keyboard bindings
|
|
45
|
-
*
|
|
46
|
-
* Note: Mod = Cmd on Mac, Ctrl on Windows/Linux
|
|
47
|
-
*/
|
|
48
|
-
export function createEditorKeymap(options = {}) {
|
|
49
|
-
const keymapPlugin = (ctx) => async () => {
|
|
50
|
-
const runtime = await resolveShortcutRuntime();
|
|
51
|
-
const shortcutPlugin = runtime.$shortcut((shortcutContext) => {
|
|
52
|
-
const call = (key, payload) => runtime.callCommand(key, payload)(shortcutContext);
|
|
53
|
-
const bindings = {
|
|
54
|
-
'Mod-b': () => call(runtime.toggleStrongCommand.key),
|
|
55
|
-
'Mod-i': () => call(runtime.toggleEmphasisCommand.key),
|
|
56
|
-
'Mod-e': () => call(runtime.toggleInlineCodeCommand.key),
|
|
57
|
-
'Mod-Shift-s': () => call(runtime.toggleStrikethroughCommand.key),
|
|
58
|
-
'Mod-Alt-1': () => call(runtime.wrapInHeadingCommand.key, 1),
|
|
59
|
-
'Mod-Alt-2': () => call(runtime.wrapInHeadingCommand.key, 2),
|
|
60
|
-
'Mod-Alt-3': () => call(runtime.wrapInHeadingCommand.key, 3),
|
|
61
|
-
'Mod-Shift-8': () => call(runtime.wrapInBulletListCommand.key),
|
|
62
|
-
'Mod-Shift-7': () => call(runtime.wrapInOrderedListCommand.key),
|
|
63
|
-
Tab: () => call(runtime.sinkListItemCommand.key),
|
|
64
|
-
'Shift-Tab': () => call(runtime.liftListItemCommand.key),
|
|
65
|
-
'Mod-Shift-9': () => call(runtime.wrapInBlockquoteCommand.key),
|
|
66
|
-
'Mod-Shift--': () => call(runtime.insertHrCommand.key),
|
|
67
|
-
'Mod-z': () => call(runtime.undoCommand.key),
|
|
68
|
-
'Mod-Shift-z': () => call(runtime.redoCommand.key),
|
|
69
|
-
'Mod-y': () => call(runtime.redoCommand.key),
|
|
70
|
-
};
|
|
71
|
-
if (options.onlinkshortcut) {
|
|
72
|
-
bindings['Mod-k'] = () => {
|
|
73
|
-
options.onlinkshortcut?.();
|
|
74
|
-
return true;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (options.oncommentshortcut) {
|
|
78
|
-
bindings['Ctrl-Alt-c'] = () => {
|
|
79
|
-
options.oncommentshortcut?.();
|
|
80
|
-
return true;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return bindings;
|
|
84
|
-
});
|
|
85
|
-
await shortcutPlugin(ctx)();
|
|
86
|
-
};
|
|
87
|
-
return keymapPlugin;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Default keyboard shortcuts (no external callbacks).
|
|
91
|
-
* @deprecated Use createEditorKeymap() for new code.
|
|
92
|
-
*/
|
|
93
|
-
export const editorKeymap = createEditorKeymap();
|
|
94
|
-
/**
|
|
95
|
-
* Convert a Mod-style shortcut to platform-specific display string.
|
|
96
|
-
*
|
|
97
|
-
* @param shortcut - Shortcut in Mod notation (e.g., "Mod-b", "Mod-Shift-k")
|
|
98
|
-
* @param isMac - Whether to use macOS symbols (defaults to detecting from navigator)
|
|
99
|
-
* @returns Display string (e.g., "⌘B" on Mac, "Ctrl+B" on Windows)
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* getShortcutDisplay('Mod-b') // "⌘B" on Mac, "Ctrl+B" on Windows
|
|
103
|
-
* getShortcutDisplay('Mod-Shift-s') // "⌘⇧S" on Mac, "Ctrl+Shift+S" on Windows
|
|
104
|
-
*/
|
|
105
|
-
export function getShortcutDisplay(shortcut, isMac) {
|
|
106
|
-
// Detect platform if not specified (SSR-safe default to false)
|
|
107
|
-
const isMacPlatform = isMac ?? (typeof navigator !== 'undefined' && /Mac|iPod|iPhone|iPad/.test(navigator.platform));
|
|
108
|
-
const parts = shortcut.split('-');
|
|
109
|
-
// Convert each part to display format
|
|
110
|
-
const displayParts = parts.map((part) => {
|
|
111
|
-
switch (part) {
|
|
112
|
-
case 'Mod':
|
|
113
|
-
return isMacPlatform ? '⌘' : 'Ctrl';
|
|
114
|
-
case 'Shift':
|
|
115
|
-
return isMacPlatform ? '⇧' : 'Shift';
|
|
116
|
-
case 'Alt':
|
|
117
|
-
return isMacPlatform ? '⌥' : 'Alt';
|
|
118
|
-
case 'Ctrl':
|
|
119
|
-
return isMacPlatform ? '⌃' : 'Ctrl';
|
|
120
|
-
default:
|
|
121
|
-
// Uppercase single letters, keep others as-is
|
|
122
|
-
return part.length === 1 ? part.toUpperCase() : part;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
// Join with + for Windows, no separator for Mac (just symbols)
|
|
126
|
-
return isMacPlatform ? displayParts.join('') : displayParts.join('+');
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Get keyboard shortcuts for the current platform.
|
|
130
|
-
*/
|
|
131
|
-
export function getShortcutDefinitions(isMac = false) {
|
|
132
|
-
const mod = isMac ? '⌘' : 'Ctrl';
|
|
133
|
-
const alt = isMac ? '⌥' : 'Alt';
|
|
134
|
-
const shift = isMac ? '⇧' : 'Shift';
|
|
135
|
-
return [
|
|
136
|
-
{ action: 'Bold', keys: [mod, 'B'] },
|
|
137
|
-
{ action: 'Italic', keys: [mod, 'I'] },
|
|
138
|
-
{ action: 'Inline Code', keys: [mod, 'E'] },
|
|
139
|
-
{ action: 'Strikethrough', keys: [mod, shift, 'S'] },
|
|
140
|
-
{ action: 'Link', keys: [mod, 'K'] },
|
|
141
|
-
{ action: 'Heading 1', keys: [mod, alt, '1'] },
|
|
142
|
-
{ action: 'Heading 2', keys: [mod, alt, '2'] },
|
|
143
|
-
{ action: 'Heading 3', keys: [mod, alt, '3'] },
|
|
144
|
-
{ action: 'Bullet List', keys: [mod, shift, '8'] },
|
|
145
|
-
{ action: 'Ordered List', keys: [mod, shift, '7'] },
|
|
146
|
-
{ action: 'Blockquote', keys: [mod, shift, '9'] },
|
|
147
|
-
{ action: 'Indent', keys: ['Tab'] },
|
|
148
|
-
{ action: 'Outdent', keys: [shift, 'Tab'] },
|
|
149
|
-
{ action: 'Undo', keys: [mod, 'Z'] },
|
|
150
|
-
{ action: 'Redo', keys: isMac ? [mod, shift, 'Z'] : [mod, 'Y'] },
|
|
151
|
-
// Suggestion shortcuts (DEP-43) - suggest-mode-specific
|
|
152
|
-
{ action: 'Accept Suggestion (Suggest mode only)', keys: [mod, shift, 'Y'] },
|
|
153
|
-
{ action: 'Reject Suggestion (Suggest mode only)', keys: [mod, shift, 'N'] },
|
|
154
|
-
// Comment shortcut (DEP-47) - review-mode-specific
|
|
155
|
-
{ action: 'Add Comment (Comment mode only)', keys: ['Ctrl', alt, 'C'] },
|
|
156
|
-
];
|
|
157
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Input rule for converting Markdown link syntax into a link mark.
|
|
3
|
-
*/
|
|
4
|
-
import { InputRule } from 'prosemirror-inputrules';
|
|
5
|
-
import { createLazyInputRule } from './milkdown-plugin-runtime.js';
|
|
6
|
-
const linkInputRuleRegex = /(^|[^!])\[([^\]]+)\]\(([^)\s]+)\)$/;
|
|
7
|
-
export const linkInputRulePlugin = createLazyInputRule(async (ctx) => {
|
|
8
|
-
const { schemaCtx } = await import('@milkdown/kit/core');
|
|
9
|
-
const schema = ctx.get(schemaCtx);
|
|
10
|
-
const linkMark = schema.marks['link'];
|
|
11
|
-
if (!linkMark) {
|
|
12
|
-
return new InputRule(/$^/, () => null);
|
|
13
|
-
}
|
|
14
|
-
return new InputRule(linkInputRuleRegex, (state, match, start, end) => {
|
|
15
|
-
const prefix = match[1] ?? '';
|
|
16
|
-
const text = match[2];
|
|
17
|
-
const url = match[3];
|
|
18
|
-
if (!text || !url)
|
|
19
|
-
return null;
|
|
20
|
-
const startPos = start + prefix.length;
|
|
21
|
-
const mark = linkMark.create({ href: url });
|
|
22
|
-
const baseMarks = state.storedMarks ?? state.selection.$from.marks();
|
|
23
|
-
const marks = mark.addToSet(baseMarks);
|
|
24
|
-
return state.tr.replaceWith(startPos, end, state.schema.text(text, marks));
|
|
25
|
-
}, { inCodeMark: false });
|
|
26
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Register a ProseMirror plugin without importing Milkdown runtime modules at package import time.
|
|
3
|
-
*/
|
|
4
|
-
export function createLazyProsePlugin(createProseMirrorPlugin) {
|
|
5
|
-
let prosePlugin;
|
|
6
|
-
const milkdownPlugin = (context) => async () => {
|
|
7
|
-
const { SchemaReady, prosePluginsCtx } = await import('@milkdown/kit/core');
|
|
8
|
-
await context.wait(SchemaReady);
|
|
9
|
-
const registeredPlugin = await createProseMirrorPlugin(context);
|
|
10
|
-
prosePlugin = registeredPlugin;
|
|
11
|
-
context.update(prosePluginsCtx, (plugins) => [...plugins, registeredPlugin]);
|
|
12
|
-
return () => {
|
|
13
|
-
context.update(prosePluginsCtx, (plugins) => plugins.filter((plugin) => plugin !== registeredPlugin));
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
const lazyPlugin = Object.assign(milkdownPlugin, {
|
|
17
|
-
plugin: () => {
|
|
18
|
-
if (!prosePlugin) {
|
|
19
|
-
throw new Error('ProseMirror plugin has not been registered yet.');
|
|
20
|
-
}
|
|
21
|
-
return prosePlugin;
|
|
22
|
-
},
|
|
23
|
-
key: () => prosePlugin?.spec.key,
|
|
24
|
-
});
|
|
25
|
-
return lazyPlugin;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Register a ProseMirror input rule without importing Milkdown runtime modules at package import time.
|
|
29
|
-
*/
|
|
30
|
-
export function createLazyInputRule(createInputRule) {
|
|
31
|
-
const milkdownPlugin = (context) => async () => {
|
|
32
|
-
const { SchemaReady, inputRulesCtx } = await import('@milkdown/kit/core');
|
|
33
|
-
await context.wait(SchemaReady);
|
|
34
|
-
const inputRule = await createInputRule(context);
|
|
35
|
-
context.update(inputRulesCtx, (inputRules) => [...inputRules, inputRule]);
|
|
36
|
-
lazyPlugin.inputRule = inputRule;
|
|
37
|
-
return () => {
|
|
38
|
-
context.update(inputRulesCtx, (inputRules) => inputRules.filter((registeredInputRule) => registeredInputRule !== inputRule));
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
const lazyPlugin = milkdownPlugin;
|
|
42
|
-
return lazyPlugin;
|
|
43
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared security constants for placeholder path validation and resolution.
|
|
3
|
-
*
|
|
4
|
-
* DEP-625: Prototype pollution prevention.
|
|
5
|
-
* DEP-617 learning: Security constants that enforce the same invariant across layers
|
|
6
|
-
* must live in one place and be imported where needed.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Reserved segments that must never be resolved in placeholder paths.
|
|
12
|
-
*
|
|
13
|
-
* Accessing these property names can pollute prototypes, invoke built-in methods,
|
|
14
|
-
* or traverse the prototype chain in unexpected ways. All reserved segments are
|
|
15
|
-
* checked case-insensitively to prevent bypasses like `__PROTO__` or `Constructor`.
|
|
16
|
-
*
|
|
17
|
-
* This constant is shared across:
|
|
18
|
-
* - `template-placeholders.ts`: Runtime placeholder resolution
|
|
19
|
-
* - `applications/web/src/lib/validators/placeholder-path.ts`: Validation layer
|
|
20
|
-
* - `applications/web/src/lib/utilities/preview-composer.ts`: Preview rendering
|
|
21
|
-
*/
|
|
22
|
-
export const RESERVED_SEGMENTS = new Set([
|
|
23
|
-
'__proto__',
|
|
24
|
-
'constructor',
|
|
25
|
-
'prototype',
|
|
26
|
-
'__definegetter__',
|
|
27
|
-
'__definesetter__',
|
|
28
|
-
'__lookupgetter__',
|
|
29
|
-
'__lookupsetter__',
|
|
30
|
-
'hasownproperty',
|
|
31
|
-
'isprototypeof',
|
|
32
|
-
'propertyisenumerable',
|
|
33
|
-
'tostring',
|
|
34
|
-
'tolocalestring',
|
|
35
|
-
'valueof',
|
|
36
|
-
]);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Placeholder plugin for Milkdown.
|
|
3
|
-
*
|
|
4
|
-
* Adds the `is-editor-empty` class to the first paragraph when the editor
|
|
5
|
-
* is empty, enabling CSS placeholder styling via ::before pseudo-element.
|
|
6
|
-
*/
|
|
7
|
-
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
8
|
-
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
9
|
-
import { createLazyProsePlugin } from './milkdown-plugin-runtime.js';
|
|
10
|
-
const placeholderPluginKey = new PluginKey('placeholder');
|
|
11
|
-
/**
|
|
12
|
-
* Check if the document is considered "empty" for placeholder purposes.
|
|
13
|
-
* Empty means: single paragraph with no text content, or completely empty.
|
|
14
|
-
*/
|
|
15
|
-
function isDocumentEmpty(doc) {
|
|
16
|
-
// Document must have exactly one child
|
|
17
|
-
if (doc.childCount !== 1)
|
|
18
|
-
return false;
|
|
19
|
-
const firstChild = doc.firstChild;
|
|
20
|
-
if (!firstChild)
|
|
21
|
-
return true;
|
|
22
|
-
// First child must be a paragraph
|
|
23
|
-
if (firstChild.type.name !== 'paragraph')
|
|
24
|
-
return false;
|
|
25
|
-
// Paragraph must be empty or contain only whitespace
|
|
26
|
-
return firstChild.textContent.trim().length === 0;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Create a Milkdown plugin that adds placeholder support.
|
|
30
|
-
*
|
|
31
|
-
* When the editor is empty (single empty paragraph), this adds the
|
|
32
|
-
* `is-editor-empty` class to the first paragraph, allowing CSS to
|
|
33
|
-
* display a placeholder via `::before` pseudo-element.
|
|
34
|
-
*/
|
|
35
|
-
export const placeholderPlugin = createLazyProsePlugin(() => {
|
|
36
|
-
return new Plugin({
|
|
37
|
-
key: placeholderPluginKey,
|
|
38
|
-
props: {
|
|
39
|
-
decorations(state) {
|
|
40
|
-
const { doc } = state;
|
|
41
|
-
if (!isDocumentEmpty(doc)) {
|
|
42
|
-
return DecorationSet.empty;
|
|
43
|
-
}
|
|
44
|
-
const firstChild = doc.firstChild;
|
|
45
|
-
if (!firstChild) {
|
|
46
|
-
return DecorationSet.empty;
|
|
47
|
-
}
|
|
48
|
-
// Add the is-editor-empty class to the first paragraph
|
|
49
|
-
const decoration = Decoration.node(0, firstChild.nodeSize, {
|
|
50
|
-
class: 'is-editor-empty',
|
|
51
|
-
});
|
|
52
|
-
return DecorationSet.create(doc, [decoration]);
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
});
|