@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,157 +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 { proseMirrorPositionToTextOffset, textOffsetToLineColumn } from '../editor/index.js';
|
|
11
|
-
import { ANCHOR_CONTEXT_LENGTH } from './comments/types.js';
|
|
12
|
-
/**
|
|
13
|
-
* Generate a stable block ID from node type and content.
|
|
14
|
-
*
|
|
15
|
-
* Creates a deterministic identifier for a block-level node by combining
|
|
16
|
-
* the node type with a hash of the first 50 characters of its content.
|
|
17
|
-
* This ID survives document edits as long as the block type and initial
|
|
18
|
-
* content remain the same.
|
|
19
|
-
*
|
|
20
|
-
* @param nodeType - The ProseMirror node type name (e.g., 'heading', 'paragraph')
|
|
21
|
-
* @param textContent - The text content of the node
|
|
22
|
-
* @returns A stable block ID in the format `{nodeType}-{hash}`
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* const blockId = generateBlockId('heading', 'Introduction to Anchoring');
|
|
27
|
-
* // Returns something like 'heading-abc123'
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export function generateBlockId(nodeType, textContent) {
|
|
31
|
-
// Simple hash function for short strings
|
|
32
|
-
const contentPrefix = textContent.slice(0, 50);
|
|
33
|
-
let hash = 0;
|
|
34
|
-
for (let i = 0; i < contentPrefix.length; i++) {
|
|
35
|
-
const character = contentPrefix.charCodeAt(i);
|
|
36
|
-
hash = (hash << 5) - hash + character;
|
|
37
|
-
hash = hash & hash; // Convert to 32-bit integer
|
|
38
|
-
}
|
|
39
|
-
return `${nodeType}-${Math.abs(hash).toString(36)}`;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Detect if a selection spans an entire block node.
|
|
43
|
-
*
|
|
44
|
-
* Checks whether the selection boundaries (from, to) exactly match
|
|
45
|
-
* the content boundaries of a block-level node at depth 1 (direct
|
|
46
|
-
* children of the document root). This is useful for determining
|
|
47
|
-
* if a comment should be anchored to an entire block rather than
|
|
48
|
-
* just the selected text.
|
|
49
|
-
*
|
|
50
|
-
* @param document - The ProseMirror document node
|
|
51
|
-
* @param from - Start position of the selection
|
|
52
|
-
* @param to - End position of the selection
|
|
53
|
-
* @returns The block ID if selection spans entire block, undefined otherwise
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* const view = editor.getView();
|
|
58
|
-
* const { from, to } = view.state.selection;
|
|
59
|
-
* const blockId = detectBlockLevelAnchor(view.state.doc, from, to);
|
|
60
|
-
*
|
|
61
|
-
* if (blockId) {
|
|
62
|
-
* // Selection covers an entire block (heading, paragraph, etc.)
|
|
63
|
-
* console.log('Block-level selection:', blockId);
|
|
64
|
-
* } else {
|
|
65
|
-
* // Partial text selection within a block
|
|
66
|
-
* console.log('Text selection');
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export function detectBlockLevelAnchor(document, from, to) {
|
|
71
|
-
// Resolve positions to find the containing nodes
|
|
72
|
-
const resolvedFrom = document.resolve(from);
|
|
73
|
-
const resolvedTo = document.resolve(to);
|
|
74
|
-
// Check if we're selecting an entire block at depth 1 (direct children of doc)
|
|
75
|
-
// This catches headings, paragraphs, code blocks, etc.
|
|
76
|
-
if (resolvedFrom.depth >= 1 && resolvedTo.depth >= 1) {
|
|
77
|
-
// Find the block-level parent
|
|
78
|
-
const parentDepth = 1;
|
|
79
|
-
const fromParent = resolvedFrom.node(parentDepth);
|
|
80
|
-
const toParent = resolvedTo.node(parentDepth);
|
|
81
|
-
// If selection is within the same block node
|
|
82
|
-
if (fromParent === toParent) {
|
|
83
|
-
// Check if selection covers the entire block's content
|
|
84
|
-
const parentStart = resolvedFrom.start(parentDepth);
|
|
85
|
-
const parentEnd = resolvedFrom.end(parentDepth);
|
|
86
|
-
if (from === parentStart && to === parentEnd) {
|
|
87
|
-
// Selection covers the entire block
|
|
88
|
-
const nodeType = fromParent.type.name;
|
|
89
|
-
const textContent = fromParent.textContent;
|
|
90
|
-
return generateBlockId(nodeType, textContent);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Build a CommentAnchor from a ProseMirror selection range.
|
|
98
|
-
*
|
|
99
|
-
* Creates a complete anchor object with all the data needed for both
|
|
100
|
-
* runtime positioning (ProseMirror positions) and persistence
|
|
101
|
-
* (TextQuoteSelector-style quote/prefix/suffix).
|
|
102
|
-
*
|
|
103
|
-
* The anchor includes:
|
|
104
|
-
* - ProseMirror positions (from, to)
|
|
105
|
-
* - Selected text (quote)
|
|
106
|
-
* - Context for re-anchoring (prefix, suffix)
|
|
107
|
-
* - Original position data for disambiguation
|
|
108
|
-
* - Block ID if selection spans entire block
|
|
109
|
-
*
|
|
110
|
-
* @param view - The ProseMirror EditorView
|
|
111
|
-
* @param from - Start position of the selection
|
|
112
|
-
* @param to - End position of the selection
|
|
113
|
-
* @returns A complete CommentAnchor ready for use or persistence
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* const view = editor.getView();
|
|
118
|
-
* const { from, to } = view.state.selection;
|
|
119
|
-
*
|
|
120
|
-
* if (from !== to) {
|
|
121
|
-
* const anchor = buildAnchorFromSelection(view, from, to);
|
|
122
|
-
* // Use anchor for thread creation
|
|
123
|
-
* onthreadcreate?.({ anchor, body: comment, authorId: userId });
|
|
124
|
-
* }
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
export function buildAnchorFromSelection(view, from, to) {
|
|
128
|
-
const { doc } = view.state;
|
|
129
|
-
// Extract text directly from ProseMirror document
|
|
130
|
-
const selectedText = doc.textBetween(from, to, '\n');
|
|
131
|
-
// Get surrounding context (prefix/suffix) from the document
|
|
132
|
-
const prefixStart = Math.max(0, from - ANCHOR_CONTEXT_LENGTH);
|
|
133
|
-
const suffixEnd = Math.min(doc.content.size, to + ANCHOR_CONTEXT_LENGTH);
|
|
134
|
-
const prefix = doc.textBetween(prefixStart, from, '\n');
|
|
135
|
-
const suffix = doc.textBetween(to, suffixEnd, '\n');
|
|
136
|
-
// Calculate text offset for originalPosition (used for disambiguation)
|
|
137
|
-
const textOffset = proseMirrorPositionToTextOffset(doc, from);
|
|
138
|
-
// Compute line/column from the document text
|
|
139
|
-
const originalPosition = textOffsetToLineColumn(doc, textOffset);
|
|
140
|
-
// Check if this is a block-level selection
|
|
141
|
-
const blockId = detectBlockLevelAnchor(doc, from, to);
|
|
142
|
-
const anchor = {
|
|
143
|
-
from,
|
|
144
|
-
to,
|
|
145
|
-
quote: selectedText,
|
|
146
|
-
prefix,
|
|
147
|
-
suffix,
|
|
148
|
-
status: 'anchored',
|
|
149
|
-
originalQuote: selectedText,
|
|
150
|
-
lastKnownOffset: textOffset,
|
|
151
|
-
originalPosition,
|
|
152
|
-
};
|
|
153
|
-
if (blockId !== undefined) {
|
|
154
|
-
anchor.blockId = blockId;
|
|
155
|
-
}
|
|
156
|
-
return anchor;
|
|
157
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comment and thread system for the Markdown Review Editor.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
export { ANCHOR_CONTEXT_LENGTH, createDocumentAnchor, createTextQuoteAnchor, generateId, isDocumentAnchor, isTextAnchor, timestamp, } from './types.js';
|
|
7
|
-
export type { AnchorStatus, AnchorType, AnchorUpdate, Comment, CommentAnchor, CommentCreateEvent, CommentDeleteEvent, CommentUpdateEvent, CreateCommentInput, CreateThreadInput, PersistedAnchor, PersistedThread, ReanchorResult, ReviewState, RuntimeAnchor, TextQuoteAnchor, Thread, ThreadCreateEvent, ThreadDeleteEvent, UpdateCommentInput, } from './types.js';
|
|
8
|
-
export { findAllOccurrences, fuzzyReanchor, reanchorQuote, scoreContextMatch } from './reanchor.js';
|
|
9
|
-
export type { ReanchorInput } from './reanchor.js';
|
|
10
|
-
export { addComment, addThread, deleteComment, deleteThread, getVisibleComments, isCommentVisible, restoreComment, updateComment, } from './updates.js';
|
|
11
|
-
export type { UpdateResult } from './updates.js';
|
|
12
|
-
export { extractMentions } from './mentions.js';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comment and thread system for the Markdown Review Editor.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
export { ANCHOR_CONTEXT_LENGTH, createDocumentAnchor, createTextQuoteAnchor,
|
|
7
|
-
// Utilities
|
|
8
|
-
generateId, isDocumentAnchor, isTextAnchor, timestamp, } from './types.js';
|
|
9
|
-
// Re-anchoring algorithm (DEP-39)
|
|
10
|
-
export { findAllOccurrences, fuzzyReanchor, reanchorQuote, scoreContextMatch } from './reanchor.js';
|
|
11
|
-
// Pure update helpers (DEP-40)
|
|
12
|
-
export { addComment, addThread, deleteComment, deleteThread, getVisibleComments, isCommentVisible, restoreComment, updateComment, } from './updates.js';
|
|
13
|
-
// Mention extraction (DEP-40)
|
|
14
|
-
export { extractMentions } from './mentions.js';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mention extraction utility for comment bodies.
|
|
3
|
-
*
|
|
4
|
-
* Extracts @username mentions while avoiding false positives from:
|
|
5
|
-
* - Email addresses (user@example.com)
|
|
6
|
-
* - Code blocks (```code```)
|
|
7
|
-
* - Inline code (`code`)
|
|
8
|
-
*
|
|
9
|
-
* ## Known Limitations
|
|
10
|
-
*
|
|
11
|
-
* This is a regex-based heuristic, not a full Markdown parser. Edge cases:
|
|
12
|
-
* - **Unterminated fenced blocks**: An unclosed ``` consumes the rest of the string
|
|
13
|
-
* - **Escaped backticks**: Inline code with escaped backticks (e.g., `foo\`bar`) may misbehave
|
|
14
|
-
* - **HTML code tags**: `<code>@mention</code>` is not detected as code
|
|
15
|
-
*
|
|
16
|
-
* For most comment use cases, these limitations are acceptable. If more robust
|
|
17
|
-
* parsing is needed, consider using the editor's AST via Milkdown/Prosemirror.
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Extract @mentions from a comment body.
|
|
23
|
-
*
|
|
24
|
-
* Matches @username patterns where username contains alphanumeric characters,
|
|
25
|
-
* underscores, and hyphens. Ignores mentions inside code blocks and inline code,
|
|
26
|
-
* and avoids matching email addresses.
|
|
27
|
-
*
|
|
28
|
-
* @param body - The comment body (Markdown)
|
|
29
|
-
* @returns Array of unique usernames (without the @ prefix)
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* extractMentions('Hello @alice and @bob!')
|
|
33
|
-
* // Returns: ['alice', 'bob']
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* extractMentions('Email: user@example.com @alice')
|
|
37
|
-
* // Returns: ['alice'] (ignores email)
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* extractMentions('See `@config` or @alice')
|
|
41
|
-
* // Returns: ['alice'] (ignores inline code)
|
|
42
|
-
*/
|
|
43
|
-
export declare function extractMentions(body: string): string[];
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mention extraction utility for comment bodies.
|
|
3
|
-
*
|
|
4
|
-
* Extracts @username mentions while avoiding false positives from:
|
|
5
|
-
* - Email addresses (user@example.com)
|
|
6
|
-
* - Code blocks (```code```)
|
|
7
|
-
* - Inline code (`code`)
|
|
8
|
-
*
|
|
9
|
-
* ## Known Limitations
|
|
10
|
-
*
|
|
11
|
-
* This is a regex-based heuristic, not a full Markdown parser. Edge cases:
|
|
12
|
-
* - **Unterminated fenced blocks**: An unclosed ``` consumes the rest of the string
|
|
13
|
-
* - **Escaped backticks**: Inline code with escaped backticks (e.g., `foo\`bar`) may misbehave
|
|
14
|
-
* - **HTML code tags**: `<code>@mention</code>` is not detected as code
|
|
15
|
-
*
|
|
16
|
-
* For most comment use cases, these limitations are acceptable. If more robust
|
|
17
|
-
* parsing is needed, consider using the editor's AST via Milkdown/Prosemirror.
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
// Match @username but not email addresses (preceded by word char, period, or plus)
|
|
22
|
-
// Uses a capturing group alternative instead of negative lookbehind for Safari <16.4 compatibility
|
|
23
|
-
// Pattern: (start-of-string OR non-email-char) followed by @username
|
|
24
|
-
// The username is in capture group 2
|
|
25
|
-
// Hoisted outside function to avoid regex recompilation on each call
|
|
26
|
-
const mentionRegex = /(^|[^.\w+])@([\w-]+)/g;
|
|
27
|
-
/**
|
|
28
|
-
* Extract @mentions from a comment body.
|
|
29
|
-
*
|
|
30
|
-
* Matches @username patterns where username contains alphanumeric characters,
|
|
31
|
-
* underscores, and hyphens. Ignores mentions inside code blocks and inline code,
|
|
32
|
-
* and avoids matching email addresses.
|
|
33
|
-
*
|
|
34
|
-
* @param body - The comment body (Markdown)
|
|
35
|
-
* @returns Array of unique usernames (without the @ prefix)
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* extractMentions('Hello @alice and @bob!')
|
|
39
|
-
* // Returns: ['alice', 'bob']
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* extractMentions('Email: user@example.com @alice')
|
|
43
|
-
* // Returns: ['alice'] (ignores email)
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* extractMentions('See `@config` or @alice')
|
|
47
|
-
* // Returns: ['alice'] (ignores inline code)
|
|
48
|
-
*/
|
|
49
|
-
export function extractMentions(body) {
|
|
50
|
-
// Remove fenced code blocks (```...```)
|
|
51
|
-
const withoutFencedCode = body.replace(/```[\s\S]*?```/g, '');
|
|
52
|
-
// Remove inline code (`...`)
|
|
53
|
-
const withoutCode = withoutFencedCode.replace(/`[^`]*`/g, '');
|
|
54
|
-
// Reset regex lastIndex since we're reusing a global regex
|
|
55
|
-
mentionRegex.lastIndex = 0;
|
|
56
|
-
const mentions = new Set();
|
|
57
|
-
for (const match of withoutCode.matchAll(mentionRegex)) {
|
|
58
|
-
// Group 2 contains the username (group 1 is the preceding character/start-of-string)
|
|
59
|
-
const username = match[2];
|
|
60
|
-
if (username) {
|
|
61
|
-
mentions.add(username);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return Array.from(mentions);
|
|
65
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-anchoring algorithm for comment anchors.
|
|
3
|
-
*
|
|
4
|
-
* This module implements the TextQuoteSelector re-anchoring algorithm
|
|
5
|
-
* that finds anchor positions after document edits. It uses:
|
|
6
|
-
* - Exact quote matching
|
|
7
|
-
* - Prefix/suffix context scoring
|
|
8
|
-
* - Position proximity for disambiguation
|
|
9
|
-
* - Fuzzy matching as fallback
|
|
10
|
-
*
|
|
11
|
-
* @module
|
|
12
|
-
*/
|
|
13
|
-
import type { ReanchorResult } from './types.js';
|
|
14
|
-
/**
|
|
15
|
-
* Match result from searching for a quote in text.
|
|
16
|
-
*/
|
|
17
|
-
interface QuoteMatch {
|
|
18
|
-
/** Start offset in text */
|
|
19
|
-
start: number;
|
|
20
|
-
/** End offset in text */
|
|
21
|
-
end: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Anchor data for re-anchoring.
|
|
25
|
-
*/
|
|
26
|
-
export interface ReanchorInput {
|
|
27
|
-
/** The quoted text to find */
|
|
28
|
-
quote: string;
|
|
29
|
-
/** Context before the quote */
|
|
30
|
-
prefix: string;
|
|
31
|
-
/** Context after the quote */
|
|
32
|
-
suffix: string;
|
|
33
|
-
/** Original position when created */
|
|
34
|
-
originalPosition?: {
|
|
35
|
-
offset: number;
|
|
36
|
-
} | undefined;
|
|
37
|
-
/** Last known text offset (preferred for disambiguation) */
|
|
38
|
-
lastKnownOffset?: number | undefined;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Find all exact occurrences of a quote in document text.
|
|
42
|
-
*
|
|
43
|
-
* @param quote - Text to find
|
|
44
|
-
* @param documentText - Document to search
|
|
45
|
-
* @returns Array of match positions
|
|
46
|
-
*/
|
|
47
|
-
export declare function findAllOccurrences(quote: string, documentText: string): QuoteMatch[];
|
|
48
|
-
/**
|
|
49
|
-
* Score how well a match's surrounding context matches the expected context.
|
|
50
|
-
*
|
|
51
|
-
* Uses longest common subsequence (LCS) to handle minor edits in context.
|
|
52
|
-
*
|
|
53
|
-
* @param documentText - Full document text
|
|
54
|
-
* @param match - The match to score
|
|
55
|
-
* @param expectedPrefix - Expected prefix context
|
|
56
|
-
* @param expectedSuffix - Expected suffix context
|
|
57
|
-
* @returns Score from 0 (no match) to 1 (perfect match)
|
|
58
|
-
*/
|
|
59
|
-
export declare function scoreContextMatch(documentText: string, match: QuoteMatch, expectedPrefix: string, expectedSuffix: string): number;
|
|
60
|
-
/**
|
|
61
|
-
* Attempt fuzzy re-anchoring when exact quote is not found.
|
|
62
|
-
*
|
|
63
|
-
* Uses the prefix + suffix to try to locate where the anchor was.
|
|
64
|
-
* This is a fallback for when the quoted text was deleted or significantly changed.
|
|
65
|
-
*
|
|
66
|
-
* @param documentText - Full document text
|
|
67
|
-
* @param anchor - Original anchor data
|
|
68
|
-
* @returns Re-anchor result with found=false (the quoted text no longer exists)
|
|
69
|
-
*/
|
|
70
|
-
export declare function fuzzyReanchor(documentText: string, anchor: ReanchorInput): ReanchorResult;
|
|
71
|
-
/**
|
|
72
|
-
* Re-anchor a quote in a document.
|
|
73
|
-
*
|
|
74
|
-
* Algorithm:
|
|
75
|
-
* 1. Find all exact occurrences of the quote
|
|
76
|
-
* 2. If none found, attempt fuzzy re-anchoring
|
|
77
|
-
* 3. If one found, score its context and return
|
|
78
|
-
* 4. If multiple found, score by context + position proximity
|
|
79
|
-
* 5. Check margin between top matches for ambiguity
|
|
80
|
-
*
|
|
81
|
-
* @param documentText - Full document text (from doc.textBetween())
|
|
82
|
-
* @param anchor - Anchor data with quote, context, and position hints
|
|
83
|
-
* @returns Re-anchor result with new position and status
|
|
84
|
-
*/
|
|
85
|
-
export declare function reanchorQuote(documentText: string, anchor: ReanchorInput): ReanchorResult;
|
|
86
|
-
export {};
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-anchoring algorithm for comment anchors.
|
|
3
|
-
*
|
|
4
|
-
* This module implements the TextQuoteSelector re-anchoring algorithm
|
|
5
|
-
* that finds anchor positions after document edits. It uses:
|
|
6
|
-
* - Exact quote matching
|
|
7
|
-
* - Prefix/suffix context scoring
|
|
8
|
-
* - Position proximity for disambiguation
|
|
9
|
-
* - Fuzzy matching as fallback
|
|
10
|
-
*
|
|
11
|
-
* @module
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Find all exact occurrences of a quote in document text.
|
|
15
|
-
*
|
|
16
|
-
* @param quote - Text to find
|
|
17
|
-
* @param documentText - Document to search
|
|
18
|
-
* @returns Array of match positions
|
|
19
|
-
*/
|
|
20
|
-
export function findAllOccurrences(quote, documentText) {
|
|
21
|
-
const matches = [];
|
|
22
|
-
if (!quote)
|
|
23
|
-
return matches;
|
|
24
|
-
let startIndex = 0;
|
|
25
|
-
while (true) {
|
|
26
|
-
const index = documentText.indexOf(quote, startIndex);
|
|
27
|
-
if (index === -1)
|
|
28
|
-
break;
|
|
29
|
-
matches.push({
|
|
30
|
-
start: index,
|
|
31
|
-
end: index + quote.length,
|
|
32
|
-
});
|
|
33
|
-
startIndex = index + 1;
|
|
34
|
-
}
|
|
35
|
-
return matches;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Score how well a match's surrounding context matches the expected context.
|
|
39
|
-
*
|
|
40
|
-
* Uses longest common subsequence (LCS) to handle minor edits in context.
|
|
41
|
-
*
|
|
42
|
-
* @param documentText - Full document text
|
|
43
|
-
* @param match - The match to score
|
|
44
|
-
* @param expectedPrefix - Expected prefix context
|
|
45
|
-
* @param expectedSuffix - Expected suffix context
|
|
46
|
-
* @returns Score from 0 (no match) to 1 (perfect match)
|
|
47
|
-
*/
|
|
48
|
-
export function scoreContextMatch(documentText, match, expectedPrefix, expectedSuffix) {
|
|
49
|
-
// Extract actual context from document
|
|
50
|
-
const actualPrefix = documentText.slice(Math.max(0, match.start - expectedPrefix.length), match.start);
|
|
51
|
-
const actualSuffix = documentText.slice(match.end, match.end + expectedSuffix.length);
|
|
52
|
-
// Score prefix match
|
|
53
|
-
const prefixScore = expectedPrefix.length > 0 ? lcsRatio(actualPrefix, expectedPrefix) : 1.0;
|
|
54
|
-
// Score suffix match
|
|
55
|
-
const suffixScore = expectedSuffix.length > 0 ? lcsRatio(actualSuffix, expectedSuffix) : 1.0;
|
|
56
|
-
// Average the scores, weighting prefix slightly higher
|
|
57
|
-
// (prefix is often more stable than suffix)
|
|
58
|
-
return prefixScore * 0.55 + suffixScore * 0.45;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Calculate LCS (Longest Common Subsequence) ratio between two strings.
|
|
62
|
-
*
|
|
63
|
-
* @param a - First string
|
|
64
|
-
* @param b - Second string
|
|
65
|
-
* @returns Ratio of LCS length to max string length (0-1)
|
|
66
|
-
*/
|
|
67
|
-
function lcsRatio(a, b) {
|
|
68
|
-
if (a.length === 0 || b.length === 0)
|
|
69
|
-
return 0;
|
|
70
|
-
const lcsLength = longestCommonSubsequence(a, b);
|
|
71
|
-
return lcsLength / Math.max(a.length, b.length);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Calculate length of longest common subsequence.
|
|
75
|
-
*
|
|
76
|
-
* Uses dynamic programming with space optimization.
|
|
77
|
-
*/
|
|
78
|
-
function longestCommonSubsequence(a, b) {
|
|
79
|
-
const aLength = a.length;
|
|
80
|
-
const bLength = b.length;
|
|
81
|
-
// Use two rows for space optimization
|
|
82
|
-
let previousRow = Array.from({ length: bLength + 1 }, () => 0);
|
|
83
|
-
let currentRow = Array.from({ length: bLength + 1 }, () => 0);
|
|
84
|
-
for (let aIndex = 1; aIndex <= aLength; aIndex += 1) {
|
|
85
|
-
for (let bIndex = 1; bIndex <= bLength; bIndex += 1) {
|
|
86
|
-
if (a[aIndex - 1] === b[bIndex - 1]) {
|
|
87
|
-
currentRow[bIndex] = (previousRow[bIndex - 1] ?? 0) + 1;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
currentRow[bIndex] = Math.max(previousRow[bIndex] ?? 0, currentRow[bIndex - 1] ?? 0);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// Swap rows
|
|
94
|
-
[previousRow, currentRow] = [currentRow, previousRow];
|
|
95
|
-
}
|
|
96
|
-
return previousRow[bLength] ?? 0;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Attempt fuzzy re-anchoring when exact quote is not found.
|
|
100
|
-
*
|
|
101
|
-
* Uses the prefix + suffix to try to locate where the anchor was.
|
|
102
|
-
* This is a fallback for when the quoted text was deleted or significantly changed.
|
|
103
|
-
*
|
|
104
|
-
* @param documentText - Full document text
|
|
105
|
-
* @param anchor - Original anchor data
|
|
106
|
-
* @returns Re-anchor result with found=false (the quoted text no longer exists)
|
|
107
|
-
*/
|
|
108
|
-
export function fuzzyReanchor(documentText, anchor) {
|
|
109
|
-
const { prefix, suffix, lastKnownOffset, originalPosition } = anchor;
|
|
110
|
-
const referenceOffset = lastKnownOffset ?? originalPosition?.offset;
|
|
111
|
-
// Try to find the junction point using prefix + suffix
|
|
112
|
-
if (prefix.length > 0 && suffix.length > 0) {
|
|
113
|
-
// Search for prefix ending + suffix beginning near reference position
|
|
114
|
-
const searchRadius = 500; // Characters to search around reference
|
|
115
|
-
const searchStart = Math.max(0, (referenceOffset ?? 0) - searchRadius);
|
|
116
|
-
const searchEnd = Math.min(documentText.length, (referenceOffset ?? documentText.length) + searchRadius);
|
|
117
|
-
const searchText = documentText.slice(searchStart, searchEnd);
|
|
118
|
-
// Look for prefix ending
|
|
119
|
-
const prefixEnd = prefix.slice(-20); // Last 20 chars of prefix
|
|
120
|
-
const suffixStart = suffix.slice(0, 20); // First 20 chars of suffix
|
|
121
|
-
let bestPos = -1;
|
|
122
|
-
let bestScore = 0;
|
|
123
|
-
// Slide through search region looking for best match
|
|
124
|
-
for (let i = 0; i < searchText.length - 1; i++) {
|
|
125
|
-
const beforeSlice = searchText.slice(Math.max(0, i - prefixEnd.length), i);
|
|
126
|
-
const afterSlice = searchText.slice(i, i + suffixStart.length);
|
|
127
|
-
const beforeScore = lcsRatio(beforeSlice, prefixEnd);
|
|
128
|
-
const afterScore = lcsRatio(afterSlice, suffixStart);
|
|
129
|
-
const score = (beforeScore + afterScore) / 2;
|
|
130
|
-
if (score > bestScore) {
|
|
131
|
-
bestScore = score;
|
|
132
|
-
bestPos = searchStart + i;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (bestScore >= 0.5) {
|
|
136
|
-
// Found a reasonable junction point where the text was deleted
|
|
137
|
-
// Return not found - the thread will be auto-deleted
|
|
138
|
-
return {
|
|
139
|
-
found: false,
|
|
140
|
-
from: bestPos,
|
|
141
|
-
to: bestPos,
|
|
142
|
-
confidence: bestScore,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// Couldn't find anything - completely gone
|
|
147
|
-
return {
|
|
148
|
-
found: false,
|
|
149
|
-
from: referenceOffset ?? 0,
|
|
150
|
-
to: referenceOffset ?? 0,
|
|
151
|
-
confidence: 0,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Re-anchor a quote in a document.
|
|
156
|
-
*
|
|
157
|
-
* Algorithm:
|
|
158
|
-
* 1. Find all exact occurrences of the quote
|
|
159
|
-
* 2. If none found, attempt fuzzy re-anchoring
|
|
160
|
-
* 3. If one found, score its context and return
|
|
161
|
-
* 4. If multiple found, score by context + position proximity
|
|
162
|
-
* 5. Check margin between top matches for ambiguity
|
|
163
|
-
*
|
|
164
|
-
* @param documentText - Full document text (from doc.textBetween())
|
|
165
|
-
* @param anchor - Anchor data with quote, context, and position hints
|
|
166
|
-
* @returns Re-anchor result with new position and status
|
|
167
|
-
*/
|
|
168
|
-
export function reanchorQuote(documentText, anchor) {
|
|
169
|
-
const { quote, prefix, suffix, originalPosition, lastKnownOffset } = anchor;
|
|
170
|
-
// Prefer lastKnownOffset over originalPosition for disambiguation
|
|
171
|
-
// lastKnownOffset tracks current location, originalPosition is historical
|
|
172
|
-
const referenceOffset = lastKnownOffset ?? originalPosition?.offset;
|
|
173
|
-
// Find all exact occurrences
|
|
174
|
-
const matches = findAllOccurrences(quote, documentText);
|
|
175
|
-
// No matches - try fuzzy re-anchoring
|
|
176
|
-
if (matches.length === 0) {
|
|
177
|
-
return fuzzyReanchor(documentText, anchor);
|
|
178
|
-
}
|
|
179
|
-
// Single match - score its context
|
|
180
|
-
if (matches.length === 1) {
|
|
181
|
-
const match = matches[0];
|
|
182
|
-
if (!match) {
|
|
183
|
-
return fuzzyReanchor(documentText, anchor);
|
|
184
|
-
}
|
|
185
|
-
const confidence = scoreContextMatch(documentText, match, prefix, suffix);
|
|
186
|
-
return {
|
|
187
|
-
found: true,
|
|
188
|
-
from: match.start,
|
|
189
|
-
to: match.end,
|
|
190
|
-
confidence,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
// Multiple matches - score by context + position proximity
|
|
194
|
-
const scoredMatches = matches.map((match) => {
|
|
195
|
-
const contextScore = scoreContextMatch(documentText, match, prefix, suffix);
|
|
196
|
-
// Position proximity (exponential decay with distance)
|
|
197
|
-
let proximityScore = 0;
|
|
198
|
-
if (referenceOffset !== undefined) {
|
|
199
|
-
const distance = Math.abs(match.start - referenceOffset);
|
|
200
|
-
proximityScore = Math.exp(-distance / 500);
|
|
201
|
-
}
|
|
202
|
-
// Weight context more heavily than proximity
|
|
203
|
-
const totalScore = contextScore * 0.7 + proximityScore * 0.3;
|
|
204
|
-
return { ...match, contextScore, proximityScore, totalScore };
|
|
205
|
-
});
|
|
206
|
-
// Sort by total score descending
|
|
207
|
-
scoredMatches.sort((a, b) => b.totalScore - a.totalScore);
|
|
208
|
-
const best = scoredMatches[0];
|
|
209
|
-
if (!best) {
|
|
210
|
-
return fuzzyReanchor(documentText, anchor);
|
|
211
|
-
}
|
|
212
|
-
// We found matches, return the best one
|
|
213
|
-
// The confidence score captures how certain we are about this match
|
|
214
|
-
return {
|
|
215
|
-
found: true,
|
|
216
|
-
from: best.start,
|
|
217
|
-
to: best.end,
|
|
218
|
-
confidence: best.totalScore,
|
|
219
|
-
};
|
|
220
|
-
}
|