@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
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProseMirror plugin for comment anchor tracking.
|
|
3
|
-
*
|
|
4
|
-
* This plugin:
|
|
5
|
-
* - Tracks anchor positions through document edits via tr.mapping.map()
|
|
6
|
-
* - Detects when anchors need re-anchoring (quote drift)
|
|
7
|
-
* - Provides decorations for visual anchor highlights
|
|
8
|
-
* - Auto-deletes threads when their anchor text is removed
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*
|
|
12
|
-
* SSR safety: the `@milkdown/kit/prose/*` value imports below resolve to
|
|
13
|
-
* prosemirror-state and prosemirror-view. They are imported STATICALLY — and
|
|
14
|
-
* deliberately so — because prosemirror is SSR-safe at module-evaluation time:
|
|
15
|
-
* `prosemirror-view` reads `document`/`navigator` only behind
|
|
16
|
-
* `typeof X !== 'undefined'` guards, so on the server (where those globals are
|
|
17
|
-
* absent) it falls back to null/"" rather than throwing. There is therefore
|
|
18
|
-
* nothing to defer behind a runtime browser guard at this layer; the SSR
|
|
19
|
-
* boundary lives in the consuming Svelte component (MarkdownEditor mounts the
|
|
20
|
-
* live editor inside `{#if browser}`). This invariant is enforced by
|
|
21
|
-
* `src/ssr-import.test.ts`.
|
|
22
|
-
*/
|
|
23
|
-
import { PluginKey } from '@milkdown/kit/prose/state';
|
|
24
|
-
import type { AnchorUpdate } from './comments/types.js';
|
|
25
|
-
/**
|
|
26
|
-
* State for a single anchor tracked by the plugin.
|
|
27
|
-
*/
|
|
28
|
-
export interface AnchorState {
|
|
29
|
-
/** Thread ID this anchor belongs to */
|
|
30
|
-
threadId: string;
|
|
31
|
-
/** ProseMirror start position */
|
|
32
|
-
from: number;
|
|
33
|
-
/** ProseMirror end position */
|
|
34
|
-
to: number;
|
|
35
|
-
/** Current quote text at this position */
|
|
36
|
-
quote: string;
|
|
37
|
-
/** Original quote text (never updated) */
|
|
38
|
-
originalQuote: string;
|
|
39
|
-
/** Context before the quote */
|
|
40
|
-
prefix: string;
|
|
41
|
-
/** Context after the quote */
|
|
42
|
-
suffix: string;
|
|
43
|
-
/** Original position from creation */
|
|
44
|
-
originalPosition?: {
|
|
45
|
-
offset: number;
|
|
46
|
-
line: number;
|
|
47
|
-
column: number;
|
|
48
|
-
} | undefined;
|
|
49
|
-
/** Last known text offset (updated on each edit) */
|
|
50
|
-
lastKnownOffset?: number | undefined;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Plugin state containing all tracked anchors.
|
|
54
|
-
*/
|
|
55
|
-
export interface AnchorPluginState {
|
|
56
|
-
/** Map of thread ID to anchor state */
|
|
57
|
-
anchors: Map<string, AnchorState>;
|
|
58
|
-
/** Flag indicating deferred re-anchoring is needed */
|
|
59
|
-
needsReanchor: boolean;
|
|
60
|
-
/** Thread ID currently focused in the UI */
|
|
61
|
-
activeThreadId: string | null;
|
|
62
|
-
/** Thread ID currently hovered in the UI */
|
|
63
|
-
hoveredThreadId: string | null;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Options for creating the anchor plugin.
|
|
67
|
-
*/
|
|
68
|
-
export interface AnchorPluginOptions {
|
|
69
|
-
/** Called when anchor positions change */
|
|
70
|
-
onAnchorsUpdate?: (updates: AnchorUpdate[]) => void;
|
|
71
|
-
/** Called when an anchor's text is deleted and the thread should be removed */
|
|
72
|
-
onAnchorDeleted?: (threadId: string) => void;
|
|
73
|
-
/** Called when user clicks on an anchor decoration */
|
|
74
|
-
onAnchorClick?: (threadId: string, event: MouseEvent) => void;
|
|
75
|
-
}
|
|
76
|
-
export declare const anchorPluginKey: PluginKey<AnchorPluginState>;
|
|
77
|
-
/**
|
|
78
|
-
* Create the anchor tracking plugin.
|
|
79
|
-
*
|
|
80
|
-
* IMPORTANT: This should be called once per ReviewEditor instance,
|
|
81
|
-
* in the instance script (not module script) before the editor mounts.
|
|
82
|
-
*
|
|
83
|
-
* @param options - Plugin options with callbacks
|
|
84
|
-
* @returns Milkdown plugin wrapper
|
|
85
|
-
*/
|
|
86
|
-
export declare function createAnchorPlugin(options?: AnchorPluginOptions): import("@milkdown/utils").$Prose;
|
|
@@ -1,490 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProseMirror plugin for comment anchor tracking.
|
|
3
|
-
*
|
|
4
|
-
* This plugin:
|
|
5
|
-
* - Tracks anchor positions through document edits via tr.mapping.map()
|
|
6
|
-
* - Detects when anchors need re-anchoring (quote drift)
|
|
7
|
-
* - Provides decorations for visual anchor highlights
|
|
8
|
-
* - Auto-deletes threads when their anchor text is removed
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*
|
|
12
|
-
* SSR safety: the `@milkdown/kit/prose/*` value imports below resolve to
|
|
13
|
-
* prosemirror-state and prosemirror-view. They are imported STATICALLY — and
|
|
14
|
-
* deliberately so — because prosemirror is SSR-safe at module-evaluation time:
|
|
15
|
-
* `prosemirror-view` reads `document`/`navigator` only behind
|
|
16
|
-
* `typeof X !== 'undefined'` guards, so on the server (where those globals are
|
|
17
|
-
* absent) it falls back to null/"" rather than throwing. There is therefore
|
|
18
|
-
* nothing to defer behind a runtime browser guard at this layer; the SSR
|
|
19
|
-
* boundary lives in the consuming Svelte component (MarkdownEditor mounts the
|
|
20
|
-
* live editor inside `{#if browser}`). This invariant is enforced by
|
|
21
|
-
* `src/ssr-import.test.ts`.
|
|
22
|
-
*/
|
|
23
|
-
import { Plugin, PluginKey } from '@milkdown/kit/prose/state';
|
|
24
|
-
import { Decoration, DecorationSet } from '@milkdown/kit/prose/view';
|
|
25
|
-
import { $prose } from '@milkdown/kit/utils';
|
|
26
|
-
import { proseMirrorPositionToTextOffset, textOffsetToProseMirrorPosition } from '../editor/index.js';
|
|
27
|
-
import { reanchorQuote } from './comments/reanchor.js';
|
|
28
|
-
function isObjectRecord(value) {
|
|
29
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
30
|
-
}
|
|
31
|
-
function isAnchorPluginMeta(value) {
|
|
32
|
-
if (!isObjectRecord(value))
|
|
33
|
-
return false;
|
|
34
|
-
switch (value['type']) {
|
|
35
|
-
case 'sync':
|
|
36
|
-
return Array.isArray(value['threads']) && value['source'] === 'external';
|
|
37
|
-
case 'add':
|
|
38
|
-
return isObjectRecord(value['thread']);
|
|
39
|
-
case 'remove':
|
|
40
|
-
return typeof value['threadId'] === 'string';
|
|
41
|
-
case 'set-active':
|
|
42
|
-
case 'set-hover':
|
|
43
|
-
return typeof value['threadId'] === 'string' || value['threadId'] === null;
|
|
44
|
-
default:
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// ============================================================================
|
|
49
|
-
// Plugin Key
|
|
50
|
-
// ============================================================================
|
|
51
|
-
export const anchorPluginKey = new PluginKey('anchor');
|
|
52
|
-
// ============================================================================
|
|
53
|
-
// Transaction Handling
|
|
54
|
-
// ============================================================================
|
|
55
|
-
/**
|
|
56
|
-
* Check if a transaction affected an anchor's range (inclusive of boundaries).
|
|
57
|
-
*/
|
|
58
|
-
function didTransactionAffectAnchorRange(tr, from, to) {
|
|
59
|
-
for (const step of tr.steps) {
|
|
60
|
-
const stepMap = step.getMap();
|
|
61
|
-
let affected = false;
|
|
62
|
-
stepMap.forEach((oldStart, oldEnd) => {
|
|
63
|
-
// Include boundaries: use <= and >= for inclusive check
|
|
64
|
-
const overlaps = oldStart <= to && oldEnd >= from;
|
|
65
|
-
if (overlaps)
|
|
66
|
-
affected = true;
|
|
67
|
-
});
|
|
68
|
-
if (affected)
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Handle meta-transactions (add/remove/sync anchors).
|
|
75
|
-
*/
|
|
76
|
-
function handleMetaTransaction(meta, prevState) {
|
|
77
|
-
switch (meta.type) {
|
|
78
|
-
case 'sync': {
|
|
79
|
-
// Sync external thread state into plugin
|
|
80
|
-
const newAnchors = new Map();
|
|
81
|
-
for (const thread of meta.threads) {
|
|
82
|
-
const anchor = thread.anchor;
|
|
83
|
-
newAnchors.set(thread.id, {
|
|
84
|
-
threadId: thread.id,
|
|
85
|
-
from: anchor.from,
|
|
86
|
-
to: anchor.to,
|
|
87
|
-
quote: anchor.quote,
|
|
88
|
-
originalQuote: anchor.originalQuote ?? anchor.quote,
|
|
89
|
-
prefix: anchor.prefix,
|
|
90
|
-
suffix: anchor.suffix,
|
|
91
|
-
originalPosition: anchor.originalPosition,
|
|
92
|
-
lastKnownOffset: anchor.lastKnownOffset,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
anchors: newAnchors,
|
|
97
|
-
needsReanchor: false,
|
|
98
|
-
activeThreadId: prevState.activeThreadId,
|
|
99
|
-
hoveredThreadId: prevState.hoveredThreadId,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
case 'add': {
|
|
103
|
-
const newAnchors = new Map(prevState.anchors);
|
|
104
|
-
const anchor = meta.thread.anchor;
|
|
105
|
-
newAnchors.set(meta.thread.id, {
|
|
106
|
-
threadId: meta.thread.id,
|
|
107
|
-
from: anchor.from,
|
|
108
|
-
to: anchor.to,
|
|
109
|
-
quote: anchor.quote,
|
|
110
|
-
originalQuote: anchor.originalQuote ?? anchor.quote,
|
|
111
|
-
prefix: anchor.prefix,
|
|
112
|
-
suffix: anchor.suffix,
|
|
113
|
-
originalPosition: anchor.originalPosition,
|
|
114
|
-
lastKnownOffset: anchor.lastKnownOffset,
|
|
115
|
-
});
|
|
116
|
-
return { ...prevState, anchors: newAnchors };
|
|
117
|
-
}
|
|
118
|
-
case 'remove': {
|
|
119
|
-
const newAnchors = new Map(prevState.anchors);
|
|
120
|
-
newAnchors.delete(meta.threadId);
|
|
121
|
-
return { ...prevState, anchors: newAnchors };
|
|
122
|
-
}
|
|
123
|
-
case 'set-active': {
|
|
124
|
-
return { ...prevState, activeThreadId: meta.threadId };
|
|
125
|
-
}
|
|
126
|
-
case 'set-hover': {
|
|
127
|
-
return { ...prevState, hoveredThreadId: meta.threadId };
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Map anchor positions through a transaction.
|
|
133
|
-
*/
|
|
134
|
-
function mapAnchorsThroughTransaction(tr, prevState, newState) {
|
|
135
|
-
const newAnchors = new Map();
|
|
136
|
-
let needsReanchor = false;
|
|
137
|
-
for (const [threadId, anchor] of prevState.anchors) {
|
|
138
|
-
// Map positions through the transaction
|
|
139
|
-
const mappedFrom = tr.mapping.map(anchor.from, -1);
|
|
140
|
-
const mappedTo = tr.mapping.map(anchor.to, 1);
|
|
141
|
-
// Check if range collapsed (anchor deleted or cut)
|
|
142
|
-
// Instead of immediately orphaning, defer to re-anchoring.
|
|
143
|
-
// This supports cut/paste and move operations where the text
|
|
144
|
-
// may reappear elsewhere in the document.
|
|
145
|
-
if (mappedFrom >= mappedTo) {
|
|
146
|
-
needsReanchor = true;
|
|
147
|
-
// Update lastKnownOffset so re-anchoring doesn't bias toward stale position
|
|
148
|
-
const collapsedOffset = proseMirrorPositionToTextOffset(newState.doc, mappedFrom);
|
|
149
|
-
newAnchors.set(threadId, {
|
|
150
|
-
...anchor,
|
|
151
|
-
from: mappedFrom,
|
|
152
|
-
to: mappedFrom,
|
|
153
|
-
lastKnownOffset: collapsedOffset,
|
|
154
|
-
// Keep current status until re-anchor determines fate
|
|
155
|
-
});
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
// Get current quote at mapped position
|
|
159
|
-
const currentQuote = newState.doc.textBetween(mappedFrom, mappedTo, '\n');
|
|
160
|
-
// Check if quote drifted (text at position doesn't match stored quote)
|
|
161
|
-
// This can happen from cut/paste, undo/redo, or collaborative edits
|
|
162
|
-
const quoteDrifted = currentQuote !== anchor.quote;
|
|
163
|
-
// Check if edit affected this anchor's range
|
|
164
|
-
if (didTransactionAffectAnchorRange(tr, anchor.from, anchor.to)) {
|
|
165
|
-
// Update quote/prefix/suffix to follow the edit
|
|
166
|
-
const newPrefix = newState.doc.textBetween(Math.max(0, mappedFrom - 50), mappedFrom, '\n');
|
|
167
|
-
const newSuffix = newState.doc.textBetween(mappedTo, Math.min(newState.doc.content.size, mappedTo + 50), '\n');
|
|
168
|
-
// Update lastKnownOffset for disambiguation
|
|
169
|
-
const newLastKnownOffset = proseMirrorPositionToTextOffset(newState.doc, mappedFrom);
|
|
170
|
-
newAnchors.set(threadId, {
|
|
171
|
-
...anchor,
|
|
172
|
-
from: mappedFrom,
|
|
173
|
-
to: mappedTo,
|
|
174
|
-
quote: currentQuote,
|
|
175
|
-
prefix: newPrefix,
|
|
176
|
-
suffix: newSuffix,
|
|
177
|
-
lastKnownOffset: newLastKnownOffset,
|
|
178
|
-
// originalQuote stays unchanged
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
else if (quoteDrifted) {
|
|
182
|
-
// Edit was outside but quote drifted (cut/paste scenario)
|
|
183
|
-
// Mark for deferred re-anchoring
|
|
184
|
-
needsReanchor = true;
|
|
185
|
-
const newLastKnownOffset = proseMirrorPositionToTextOffset(newState.doc, mappedFrom);
|
|
186
|
-
newAnchors.set(threadId, {
|
|
187
|
-
...anchor,
|
|
188
|
-
from: mappedFrom,
|
|
189
|
-
to: mappedTo,
|
|
190
|
-
lastKnownOffset: newLastKnownOffset,
|
|
191
|
-
// Keep old quote/prefix/suffix - re-anchoring will find the new location
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
// Edit was outside, quote still matches - just map positions
|
|
196
|
-
const newLastKnownOffset = proseMirrorPositionToTextOffset(newState.doc, mappedFrom);
|
|
197
|
-
newAnchors.set(threadId, {
|
|
198
|
-
...anchor,
|
|
199
|
-
from: mappedFrom,
|
|
200
|
-
to: mappedTo,
|
|
201
|
-
lastKnownOffset: newLastKnownOffset,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
anchors: newAnchors,
|
|
207
|
-
needsReanchor,
|
|
208
|
-
activeThreadId: prevState.activeThreadId,
|
|
209
|
-
hoveredThreadId: prevState.hoveredThreadId,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
// ============================================================================
|
|
213
|
-
// Deferred Re-anchoring
|
|
214
|
-
// ============================================================================
|
|
215
|
-
/**
|
|
216
|
-
* Perform deferred re-anchoring for anchors that drifted.
|
|
217
|
-
*
|
|
218
|
-
* When an anchor's text is deleted (found: false), the anchor is removed
|
|
219
|
-
* and onAnchorDeleted is called so the parent can delete the thread.
|
|
220
|
-
*/
|
|
221
|
-
function performDeferredReanchoring(view, pluginState, options) {
|
|
222
|
-
const { doc } = view.state;
|
|
223
|
-
const documentText = doc.textBetween(0, doc.content.size, '\n');
|
|
224
|
-
const updates = [];
|
|
225
|
-
const deletedThreadIds = [];
|
|
226
|
-
const newAnchors = new Map();
|
|
227
|
-
for (const [threadId, anchor] of pluginState.anchors) {
|
|
228
|
-
// Re-anchor if the quote at current position doesn't match
|
|
229
|
-
const currentQuote = doc.textBetween(anchor.from, anchor.to, '\n');
|
|
230
|
-
if (currentQuote === anchor.quote) {
|
|
231
|
-
// Quote still matches, no re-anchoring needed
|
|
232
|
-
newAnchors.set(threadId, anchor);
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
// Perform re-anchoring
|
|
236
|
-
const result = reanchorQuote(documentText, {
|
|
237
|
-
quote: anchor.quote,
|
|
238
|
-
prefix: anchor.prefix,
|
|
239
|
-
suffix: anchor.suffix,
|
|
240
|
-
originalPosition: anchor.originalPosition,
|
|
241
|
-
lastKnownOffset: anchor.lastKnownOffset,
|
|
242
|
-
});
|
|
243
|
-
// If the text was deleted, mark for removal
|
|
244
|
-
if (!result.found) {
|
|
245
|
-
deletedThreadIds.push(threadId);
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
// Convert text offsets back to PM positions
|
|
249
|
-
// reanchorQuote returns text offsets, which we must convert
|
|
250
|
-
const newFrom = textOffsetToProseMirrorPosition(doc, result.from) ?? anchor.from;
|
|
251
|
-
const newTo = textOffsetToProseMirrorPosition(doc, result.to) ?? anchor.to;
|
|
252
|
-
// Bounds check: clamp to valid doc range
|
|
253
|
-
const docSize = doc.content.size;
|
|
254
|
-
const clampedFrom = Math.max(0, Math.min(newFrom, docSize));
|
|
255
|
-
const clampedTo = Math.max(clampedFrom, Math.min(newTo, docSize));
|
|
256
|
-
const newQuote = clampedFrom < clampedTo ? doc.textBetween(clampedFrom, clampedTo, '\n') : anchor.quote;
|
|
257
|
-
// Compute new prefix/suffix context from the document at the new position
|
|
258
|
-
// This ensures subsequent re-anchors have fresh context data
|
|
259
|
-
let newPrefix = anchor.prefix;
|
|
260
|
-
let newSuffix = anchor.suffix;
|
|
261
|
-
if (clampedFrom < clampedTo) {
|
|
262
|
-
const prefixStart = Math.max(0, clampedFrom - 50);
|
|
263
|
-
const suffixEnd = Math.min(docSize, clampedTo + 50);
|
|
264
|
-
newPrefix = doc.textBetween(prefixStart, clampedFrom, '\n');
|
|
265
|
-
newSuffix = doc.textBetween(clampedTo, suffixEnd, '\n');
|
|
266
|
-
}
|
|
267
|
-
const newAnchor = {
|
|
268
|
-
...anchor,
|
|
269
|
-
from: clampedFrom,
|
|
270
|
-
to: clampedTo,
|
|
271
|
-
quote: newQuote,
|
|
272
|
-
prefix: newPrefix,
|
|
273
|
-
suffix: newSuffix,
|
|
274
|
-
lastKnownOffset: result.from,
|
|
275
|
-
};
|
|
276
|
-
newAnchors.set(threadId, newAnchor);
|
|
277
|
-
// Collect update
|
|
278
|
-
updates.push({
|
|
279
|
-
threadId,
|
|
280
|
-
from: clampedFrom,
|
|
281
|
-
to: clampedTo,
|
|
282
|
-
quote: newQuote,
|
|
283
|
-
prefix: newPrefix,
|
|
284
|
-
suffix: newSuffix,
|
|
285
|
-
status: 'anchored',
|
|
286
|
-
lastKnownOffset: result.from,
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
// Dispatch state update
|
|
290
|
-
view.dispatch(view.state.tr.setMeta(anchorPluginKey, {
|
|
291
|
-
type: 'sync',
|
|
292
|
-
threads: Array.from(newAnchors.values()).map((a) => ({
|
|
293
|
-
id: a.threadId,
|
|
294
|
-
anchor: { ...a, status: 'anchored' },
|
|
295
|
-
comments: [],
|
|
296
|
-
createdAt: new Date().toISOString(),
|
|
297
|
-
})),
|
|
298
|
-
source: 'external',
|
|
299
|
-
}));
|
|
300
|
-
// Fire updates callback
|
|
301
|
-
if (updates.length > 0) {
|
|
302
|
-
options.onAnchorsUpdate?.(updates);
|
|
303
|
-
}
|
|
304
|
-
// Fire deleted callbacks - parent should delete these threads
|
|
305
|
-
for (const threadId of deletedThreadIds) {
|
|
306
|
-
options.onAnchorDeleted?.(threadId);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
// ============================================================================
|
|
310
|
-
// Decorations
|
|
311
|
-
// ============================================================================
|
|
312
|
-
/**
|
|
313
|
-
* Compute decorations for all anchors.
|
|
314
|
-
*
|
|
315
|
-
* All anchors get a simple inline highlight. Active and hovered states
|
|
316
|
-
* are indicated via additional CSS classes.
|
|
317
|
-
*/
|
|
318
|
-
function computeDecorations(state) {
|
|
319
|
-
const pluginState = anchorPluginKey.getState(state);
|
|
320
|
-
if (!pluginState)
|
|
321
|
-
return DecorationSet.empty;
|
|
322
|
-
const decorations = [];
|
|
323
|
-
const docSize = state.doc.content.size;
|
|
324
|
-
const activeThreadId = pluginState.activeThreadId;
|
|
325
|
-
const hoveredThreadId = pluginState.hoveredThreadId;
|
|
326
|
-
for (const [threadId, anchor] of pluginState.anchors) {
|
|
327
|
-
// Bounds checking: clamp positions to valid doc range
|
|
328
|
-
const from = Math.max(0, Math.min(anchor.from, docSize));
|
|
329
|
-
const to = Math.max(from, Math.min(anchor.to, docSize));
|
|
330
|
-
// Skip invalid ranges
|
|
331
|
-
if (from >= to)
|
|
332
|
-
continue;
|
|
333
|
-
const isActive = activeThreadId === threadId;
|
|
334
|
-
const activeClass = isActive ? ' comment-anchor--active' : '';
|
|
335
|
-
const isHovered = hoveredThreadId === threadId;
|
|
336
|
-
const hoveredClass = isHovered ? ' comment-anchor--hovered' : '';
|
|
337
|
-
// Standard highlight for all anchors
|
|
338
|
-
decorations.push(Decoration.inline(from, to, {
|
|
339
|
-
class: `comment-anchor${activeClass}${hoveredClass}`,
|
|
340
|
-
'data-thread-id': threadId,
|
|
341
|
-
}, { key: `anchor-${threadId}` }));
|
|
342
|
-
}
|
|
343
|
-
return DecorationSet.create(state.doc, decorations);
|
|
344
|
-
}
|
|
345
|
-
// ============================================================================
|
|
346
|
-
// Plugin Factory
|
|
347
|
-
// ============================================================================
|
|
348
|
-
/**
|
|
349
|
-
* Create the anchor tracking plugin.
|
|
350
|
-
*
|
|
351
|
-
* IMPORTANT: This should be called once per ReviewEditor instance,
|
|
352
|
-
* in the instance script (not module script) before the editor mounts.
|
|
353
|
-
*
|
|
354
|
-
* @param options - Plugin options with callbacks
|
|
355
|
-
* @returns Milkdown plugin wrapper
|
|
356
|
-
*/
|
|
357
|
-
export function createAnchorPlugin(options = {}) {
|
|
358
|
-
let reanchorTimeout = null;
|
|
359
|
-
function updateHoverState(view, threadId) {
|
|
360
|
-
const pluginState = anchorPluginKey.getState(view.state);
|
|
361
|
-
if (pluginState?.hoveredThreadId === threadId)
|
|
362
|
-
return;
|
|
363
|
-
view.dispatch(view.state.tr.setMeta(anchorPluginKey, {
|
|
364
|
-
type: 'set-hover',
|
|
365
|
-
threadId,
|
|
366
|
-
}));
|
|
367
|
-
}
|
|
368
|
-
return $prose(() => {
|
|
369
|
-
return new Plugin({
|
|
370
|
-
key: anchorPluginKey,
|
|
371
|
-
state: {
|
|
372
|
-
init: () => ({
|
|
373
|
-
anchors: new Map(),
|
|
374
|
-
needsReanchor: false,
|
|
375
|
-
activeThreadId: null,
|
|
376
|
-
hoveredThreadId: null,
|
|
377
|
-
}),
|
|
378
|
-
apply: (tr, prevState, _, newState) => {
|
|
379
|
-
// Handle meta-transactions first
|
|
380
|
-
const meta = tr.getMeta(anchorPluginKey);
|
|
381
|
-
if (isAnchorPluginMeta(meta)) {
|
|
382
|
-
return handleMetaTransaction(meta, prevState);
|
|
383
|
-
}
|
|
384
|
-
// No doc change = no position updates needed
|
|
385
|
-
if (!tr.docChanged)
|
|
386
|
-
return prevState;
|
|
387
|
-
// Map positions and detect inside-range edits
|
|
388
|
-
return mapAnchorsThroughTransaction(tr, prevState, newState);
|
|
389
|
-
},
|
|
390
|
-
},
|
|
391
|
-
view: () => {
|
|
392
|
-
// Track doc identity to detect stale re-anchor results
|
|
393
|
-
// Using doc identity (doc.eq()) instead of size, because
|
|
394
|
-
// same-length edits could apply an out-of-date re-anchor
|
|
395
|
-
let scheduledDoc = null;
|
|
396
|
-
return {
|
|
397
|
-
update: (view) => {
|
|
398
|
-
const pluginState = anchorPluginKey.getState(view.state);
|
|
399
|
-
if (!pluginState?.needsReanchor)
|
|
400
|
-
return;
|
|
401
|
-
// Capture the doc at schedule time for identity check
|
|
402
|
-
scheduledDoc = view.state.doc;
|
|
403
|
-
// Debounce re-anchoring (300ms)
|
|
404
|
-
if (reanchorTimeout)
|
|
405
|
-
clearTimeout(reanchorTimeout);
|
|
406
|
-
reanchorTimeout = setTimeout(() => {
|
|
407
|
-
// Verify doc hasn't changed during debounce using identity check
|
|
408
|
-
if (!scheduledDoc || !view.state.doc.eq(scheduledDoc)) {
|
|
409
|
-
// Doc changed, skip this run - next update will reschedule
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
const currentPluginState = anchorPluginKey.getState(view.state);
|
|
413
|
-
if (currentPluginState) {
|
|
414
|
-
performDeferredReanchoring(view, currentPluginState, options);
|
|
415
|
-
}
|
|
416
|
-
}, 300);
|
|
417
|
-
},
|
|
418
|
-
destroy: () => {
|
|
419
|
-
if (reanchorTimeout)
|
|
420
|
-
clearTimeout(reanchorTimeout);
|
|
421
|
-
},
|
|
422
|
-
};
|
|
423
|
-
},
|
|
424
|
-
props: {
|
|
425
|
-
decorations: computeDecorations,
|
|
426
|
-
handleDOMEvents: {
|
|
427
|
-
mouseover: (view, event) => {
|
|
428
|
-
const target = event.target;
|
|
429
|
-
if (!(target instanceof Element))
|
|
430
|
-
return false;
|
|
431
|
-
const anchorElement = target.closest('[data-thread-id]');
|
|
432
|
-
if (!anchorElement) {
|
|
433
|
-
updateHoverState(view, null);
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
const threadId = anchorElement.getAttribute('data-thread-id');
|
|
437
|
-
if (threadId) {
|
|
438
|
-
updateHoverState(view, threadId);
|
|
439
|
-
}
|
|
440
|
-
return false;
|
|
441
|
-
},
|
|
442
|
-
mouseout: (view, event) => {
|
|
443
|
-
const target = event.target;
|
|
444
|
-
if (!(target instanceof Element))
|
|
445
|
-
return false;
|
|
446
|
-
const anchorElement = target.closest('[data-thread-id]');
|
|
447
|
-
if (!anchorElement)
|
|
448
|
-
return false;
|
|
449
|
-
const threadId = anchorElement.getAttribute('data-thread-id');
|
|
450
|
-
if (!threadId)
|
|
451
|
-
return false;
|
|
452
|
-
const relatedTarget = event.relatedTarget;
|
|
453
|
-
if (relatedTarget instanceof Element) {
|
|
454
|
-
const nextAnchor = relatedTarget.closest(`[data-thread-id="${threadId}"]`);
|
|
455
|
-
if (nextAnchor) {
|
|
456
|
-
return false;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
updateHoverState(view, null);
|
|
460
|
-
return false;
|
|
461
|
-
},
|
|
462
|
-
mouseleave: (view) => {
|
|
463
|
-
updateHoverState(view, null);
|
|
464
|
-
return false;
|
|
465
|
-
},
|
|
466
|
-
// Handle clicks on anchor decorations to surface them to the parent component.
|
|
467
|
-
// Always returns false to let ProseMirror handle selection and other default behavior.
|
|
468
|
-
click: (_view, event) => {
|
|
469
|
-
if (!options.onAnchorClick)
|
|
470
|
-
return false;
|
|
471
|
-
// Check if click target is within an anchor decoration.
|
|
472
|
-
// Guard against non-Element targets (e.g., text nodes) which don't have .closest()
|
|
473
|
-
const target = event.target;
|
|
474
|
-
if (!(target instanceof Element))
|
|
475
|
-
return false;
|
|
476
|
-
const anchorElement = target.closest('[data-thread-id]');
|
|
477
|
-
if (anchorElement) {
|
|
478
|
-
const threadId = anchorElement.getAttribute('data-thread-id');
|
|
479
|
-
if (threadId) {
|
|
480
|
-
options.onAnchorClick(threadId, event);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
// Always return false - we never want to prevent ProseMirror from handling the event
|
|
484
|
-
return false;
|
|
485
|
-
},
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
});
|
|
489
|
-
});
|
|
490
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Editor anchoring utilities for creating and detecting anchor positions.
|
|
3
|
-
*
|
|
4
|
-
* These utilities are extracted from ReviewEditor to enable reuse across
|
|
5
|
-
* different editor components and features. They work with ProseMirror
|
|
6
|
-
* documents to create TextQuoteSelector-style anchors.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import type { Node } from '@milkdown/prose/model';
|
|
11
|
-
import type { EditorView } from '@milkdown/prose/view';
|
|
12
|
-
import type { CommentAnchor } from './comments/types.js';
|
|
13
|
-
/**
|
|
14
|
-
* Generate a stable block ID from node type and content.
|
|
15
|
-
*
|
|
16
|
-
* Creates a deterministic identifier for a block-level node by combining
|
|
17
|
-
* the node type with a hash of the first 50 characters of its content.
|
|
18
|
-
* This ID survives document edits as long as the block type and initial
|
|
19
|
-
* content remain the same.
|
|
20
|
-
*
|
|
21
|
-
* @param nodeType - The ProseMirror node type name (e.g., 'heading', 'paragraph')
|
|
22
|
-
* @param textContent - The text content of the node
|
|
23
|
-
* @returns A stable block ID in the format `{nodeType}-{hash}`
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const blockId = generateBlockId('heading', 'Introduction to Anchoring');
|
|
28
|
-
* // Returns something like 'heading-abc123'
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare function generateBlockId(nodeType: string, textContent: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* Detect if a selection spans an entire block node.
|
|
34
|
-
*
|
|
35
|
-
* Checks whether the selection boundaries (from, to) exactly match
|
|
36
|
-
* the content boundaries of a block-level node at depth 1 (direct
|
|
37
|
-
* children of the document root). This is useful for determining
|
|
38
|
-
* if a comment should be anchored to an entire block rather than
|
|
39
|
-
* just the selected text.
|
|
40
|
-
*
|
|
41
|
-
* @param document - The ProseMirror document node
|
|
42
|
-
* @param from - Start position of the selection
|
|
43
|
-
* @param to - End position of the selection
|
|
44
|
-
* @returns The block ID if selection spans entire block, undefined otherwise
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* const view = editor.getView();
|
|
49
|
-
* const { from, to } = view.state.selection;
|
|
50
|
-
* const blockId = detectBlockLevelAnchor(view.state.doc, from, to);
|
|
51
|
-
*
|
|
52
|
-
* if (blockId) {
|
|
53
|
-
* // Selection covers an entire block (heading, paragraph, etc.)
|
|
54
|
-
* console.log('Block-level selection:', blockId);
|
|
55
|
-
* } else {
|
|
56
|
-
* // Partial text selection within a block
|
|
57
|
-
* console.log('Text selection');
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export declare function detectBlockLevelAnchor(document: Node, from: number, to: number): string | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Build a CommentAnchor from a ProseMirror selection range.
|
|
64
|
-
*
|
|
65
|
-
* Creates a complete anchor object with all the data needed for both
|
|
66
|
-
* runtime positioning (ProseMirror positions) and persistence
|
|
67
|
-
* (TextQuoteSelector-style quote/prefix/suffix).
|
|
68
|
-
*
|
|
69
|
-
* The anchor includes:
|
|
70
|
-
* - ProseMirror positions (from, to)
|
|
71
|
-
* - Selected text (quote)
|
|
72
|
-
* - Context for re-anchoring (prefix, suffix)
|
|
73
|
-
* - Original position data for disambiguation
|
|
74
|
-
* - Block ID if selection spans entire block
|
|
75
|
-
*
|
|
76
|
-
* @param view - The ProseMirror EditorView
|
|
77
|
-
* @param from - Start position of the selection
|
|
78
|
-
* @param to - End position of the selection
|
|
79
|
-
* @returns A complete CommentAnchor ready for use or persistence
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const view = editor.getView();
|
|
84
|
-
* const { from, to } = view.state.selection;
|
|
85
|
-
*
|
|
86
|
-
* if (from !== to) {
|
|
87
|
-
* const anchor = buildAnchorFromSelection(view, from, to);
|
|
88
|
-
* // Use anchor for thread creation
|
|
89
|
-
* onthreadcreate?.({ anchor, body: comment, authorId: userId });
|
|
90
|
-
* }
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
export declare function buildAnchorFromSelection(view: EditorView, from: number, to: number): CommentAnchor;
|