@beyondwork/docx-react-component 1.0.27 → 1.0.29
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/dist/canonical-document-BLEbzL2J.d.cts +844 -0
- package/dist/canonical-document-BLEbzL2J.d.ts +844 -0
- package/dist/chunk-2FJS5GZM.js +763 -0
- package/dist/chunk-2FJS5GZM.js.map +1 -0
- package/{src/core/commands/section-layout-commands.ts → dist/chunk-2OQBZS3F.js} +106 -340
- package/dist/chunk-2OQBZS3F.js.map +1 -0
- package/dist/chunk-2S7W4KFO.js +127 -0
- package/dist/chunk-2S7W4KFO.js.map +1 -0
- package/dist/chunk-2TG72QSW.js +3874 -0
- package/dist/chunk-2TG72QSW.js.map +1 -0
- package/{src/core/commands/table-structure-commands.ts → dist/chunk-36QNIZBO.js} +126 -315
- package/dist/chunk-36QNIZBO.js.map +1 -0
- package/dist/chunk-4AQOYAW4.js +3069 -0
- package/dist/chunk-4AQOYAW4.js.map +1 -0
- package/dist/chunk-4D5EWJ3P.js +77 -0
- package/dist/chunk-4D5EWJ3P.js.map +1 -0
- package/dist/chunk-5FN54NDH.js +2257 -0
- package/dist/chunk-5FN54NDH.js.map +1 -0
- package/dist/chunk-BOYGQYRQ.js +7306 -0
- package/dist/chunk-BOYGQYRQ.js.map +1 -0
- package/dist/chunk-CN3XMECL.js +212 -0
- package/dist/chunk-CN3XMECL.js.map +1 -0
- package/dist/chunk-EBI3BX6U.js +164 -0
- package/dist/chunk-EBI3BX6U.js.map +1 -0
- package/dist/chunk-EILUG3VB.js +1275 -0
- package/dist/chunk-EILUG3VB.js.map +1 -0
- package/dist/chunk-FUDY333O.js +70 -0
- package/dist/chunk-FUDY333O.js.map +1 -0
- package/dist/chunk-GBVOWFIK.js +1237 -0
- package/dist/chunk-GBVOWFIK.js.map +1 -0
- package/dist/chunk-H4TQ3H3Y.js +262 -0
- package/dist/chunk-H4TQ3H3Y.js.map +1 -0
- package/{src/core/commands/style-commands.ts → dist/chunk-JGB3IXZO.js} +40 -113
- package/dist/chunk-JGB3IXZO.js.map +1 -0
- package/dist/chunk-KD2QRQPY.js +4342 -0
- package/dist/chunk-KD2QRQPY.js.map +1 -0
- package/dist/chunk-KLMXQVYK.js +369 -0
- package/dist/chunk-KLMXQVYK.js.map +1 -0
- package/dist/chunk-KZUG5KFQ.js +214 -0
- package/dist/chunk-KZUG5KFQ.js.map +1 -0
- package/{src/core/state/text-transaction.ts → dist/chunk-QDAQ4CJU.js} +79 -236
- package/dist/chunk-QDAQ4CJU.js.map +1 -0
- package/{src/legal/bookmarks.ts → dist/chunk-RMH72RZI.js} +44 -130
- package/dist/chunk-RMH72RZI.js.map +1 -0
- package/dist/chunk-SWKWQZXM.js +117 -0
- package/dist/chunk-SWKWQZXM.js.map +1 -0
- package/{src/core/commands/formatting-commands.ts → dist/chunk-TJBP2K4T.js} +196 -536
- package/dist/chunk-TJBP2K4T.js.map +1 -0
- package/dist/chunk-TLCEAQDQ.js +542 -0
- package/dist/chunk-TLCEAQDQ.js.map +1 -0
- package/{src/core/commands/text-commands.ts → dist/chunk-UZXBISGO.js} +86 -142
- package/dist/chunk-UZXBISGO.js.map +1 -0
- package/dist/chunk-WGBAKP3Q.js +3220 -0
- package/dist/chunk-WGBAKP3Q.js.map +1 -0
- package/dist/compare/index.cjs +5475 -0
- package/dist/compare/index.cjs.map +1 -0
- package/dist/compare/index.d.cts +114 -0
- package/dist/compare/index.d.ts +114 -0
- package/dist/compare/index.js +731 -0
- package/dist/compare/index.js.map +1 -0
- package/dist/core/commands/formatting-commands.cjs +828 -0
- package/dist/core/commands/formatting-commands.cjs.map +1 -0
- package/dist/core/commands/formatting-commands.d.cts +63 -0
- package/dist/core/commands/formatting-commands.d.ts +63 -0
- package/dist/core/commands/formatting-commands.js +37 -0
- package/dist/core/commands/formatting-commands.js.map +1 -0
- package/dist/core/commands/image-commands.cjs +2023 -0
- package/dist/core/commands/image-commands.cjs.map +1 -0
- package/dist/core/commands/image-commands.d.cts +58 -0
- package/dist/core/commands/image-commands.d.ts +58 -0
- package/dist/core/commands/image-commands.js +18 -0
- package/dist/core/commands/image-commands.js.map +1 -0
- package/dist/core/commands/section-layout-commands.cjs +477 -0
- package/dist/core/commands/section-layout-commands.cjs.map +1 -0
- package/dist/core/commands/section-layout-commands.d.cts +62 -0
- package/dist/core/commands/section-layout-commands.d.ts +62 -0
- package/dist/core/commands/section-layout-commands.js +21 -0
- package/dist/core/commands/section-layout-commands.js.map +1 -0
- package/dist/core/commands/style-commands.cjs +214 -0
- package/dist/core/commands/style-commands.cjs.map +1 -0
- package/dist/core/commands/style-commands.d.cts +13 -0
- package/dist/core/commands/style-commands.d.ts +13 -0
- package/dist/core/commands/style-commands.js +9 -0
- package/dist/core/commands/style-commands.js.map +1 -0
- package/dist/core/commands/table-structure-commands.cjs +1883 -0
- package/dist/core/commands/table-structure-commands.cjs.map +1 -0
- package/dist/core/commands/table-structure-commands.d.cts +59 -0
- package/dist/core/commands/table-structure-commands.d.ts +59 -0
- package/dist/core/commands/table-structure-commands.js +12 -0
- package/dist/core/commands/table-structure-commands.js.map +1 -0
- package/dist/core/commands/text-commands.cjs +2391 -0
- package/dist/core/commands/text-commands.cjs.map +1 -0
- package/dist/core/commands/text-commands.d.cts +24 -0
- package/dist/core/commands/text-commands.d.ts +24 -0
- package/dist/core/commands/text-commands.js +28 -0
- package/dist/core/commands/text-commands.js.map +1 -0
- package/dist/core/selection/mapping.cjs +200 -0
- package/dist/core/selection/mapping.cjs.map +1 -0
- package/dist/core/selection/mapping.d.cts +2 -0
- package/dist/core/selection/mapping.d.ts +2 -0
- package/dist/core/selection/mapping.js +31 -0
- package/dist/core/selection/mapping.js.map +1 -0
- package/dist/core/state/editor-state.cjs +2278 -0
- package/dist/core/state/editor-state.cjs.map +1 -0
- package/dist/core/state/editor-state.d.cts +2 -0
- package/dist/core/state/editor-state.d.ts +2 -0
- package/dist/core/state/editor-state.js +26 -0
- package/dist/core/state/editor-state.js.map +1 -0
- package/dist/index.cjs +38553 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +7856 -0
- package/dist/index.js.map +1 -0
- package/dist/io/docx-session.cjs +16236 -0
- package/dist/io/docx-session.cjs.map +1 -0
- package/dist/io/docx-session.d.cts +21 -0
- package/dist/io/docx-session.d.ts +21 -0
- package/dist/io/docx-session.js +18 -0
- package/dist/io/docx-session.js.map +1 -0
- package/dist/legal/index.cjs +3900 -0
- package/dist/legal/index.cjs.map +1 -0
- package/dist/legal/index.d.cts +86 -0
- package/dist/legal/index.d.ts +86 -0
- package/dist/legal/index.js +616 -0
- package/dist/legal/index.js.map +1 -0
- package/dist/public-types-7ZL_94cz.d.ts +1573 -0
- package/dist/public-types-CeMaDueh.d.cts +1573 -0
- package/dist/public-types.cjs +19 -0
- package/dist/public-types.cjs.map +1 -0
- package/dist/public-types.d.cts +2 -0
- package/dist/public-types.d.ts +2 -0
- package/dist/public-types.js +1 -0
- package/dist/public-types.js.map +1 -0
- package/dist/runtime/document-runtime.cjs +11140 -0
- package/dist/runtime/document-runtime.cjs.map +1 -0
- package/dist/runtime/document-runtime.d.cts +231 -0
- package/dist/runtime/document-runtime.d.ts +231 -0
- package/dist/runtime/document-runtime.js +21 -0
- package/dist/runtime/document-runtime.js.map +1 -0
- package/dist/structural-helpers-CilgOVhh.d.cts +10 -0
- package/dist/structural-helpers-q0Gd-eBN.d.ts +10 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.cjs +313 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.cjs.map +1 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +67 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +67 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.js +23 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.js.map +1 -0
- package/dist/ui-tailwind/index.cjs +4833 -0
- package/dist/ui-tailwind/index.cjs.map +1 -0
- package/dist/ui-tailwind/index.d.cts +617 -0
- package/dist/ui-tailwind/index.d.ts +617 -0
- package/dist/ui-tailwind/index.js +575 -0
- package/dist/ui-tailwind/index.js.map +1 -0
- package/package.json +64 -54
- package/src/README.md +0 -85
- package/src/api/README.md +0 -26
- package/src/api/public-types.ts +0 -1418
- package/src/api/session-state.ts +0 -60
- package/src/compare/diff-engine.ts +0 -623
- package/src/compare/export-redlines.ts +0 -280
- package/src/compare/index.ts +0 -25
- package/src/compare/snapshot.ts +0 -97
- package/src/component-inventory.md +0 -99
- package/src/core/README.md +0 -10
- package/src/core/commands/README.md +0 -3
- package/src/core/commands/image-commands.ts +0 -373
- package/src/core/commands/index.ts +0 -1757
- package/src/core/commands/list-commands.ts +0 -565
- package/src/core/commands/paragraph-layout-commands.ts +0 -339
- package/src/core/commands/review-commands.ts +0 -108
- package/src/core/commands/structural-helpers.ts +0 -309
- package/src/core/schema/README.md +0 -3
- package/src/core/schema/text-schema.ts +0 -516
- package/src/core/search/search-text.ts +0 -357
- package/src/core/selection/README.md +0 -3
- package/src/core/selection/mapping.ts +0 -289
- package/src/core/selection/review-anchors.ts +0 -183
- package/src/core/state/README.md +0 -3
- package/src/core/state/editor-state.ts +0 -892
- package/src/formats/xlsx/io/parse-shared-strings.ts +0 -41
- package/src/formats/xlsx/io/parse-sheet.ts +0 -459
- package/src/formats/xlsx/io/parse-styles.ts +0 -59
- package/src/formats/xlsx/io/parse-workbook.ts +0 -75
- package/src/formats/xlsx/io/serialize-shared-strings.ts +0 -72
- package/src/formats/xlsx/io/serialize-sheet.ts +0 -333
- package/src/formats/xlsx/io/serialize-styles.ts +0 -98
- package/src/formats/xlsx/io/serialize-workbook.ts +0 -429
- package/src/formats/xlsx/io/xlsx-session.ts +0 -314
- package/src/formats/xlsx/model/cell.ts +0 -189
- package/src/formats/xlsx/model/sheet.ts +0 -326
- package/src/formats/xlsx/model/styles.ts +0 -118
- package/src/formats/xlsx/model/workbook.ts +0 -453
- package/src/formats/xlsx/runtime/cell-commands.ts +0 -567
- package/src/formats/xlsx/runtime/sheet-commands.ts +0 -206
- package/src/formats/xlsx/runtime/workbook-runtime.ts +0 -177
- package/src/formats/xlsx/runtime/workbook-transaction.ts +0 -822
- package/src/index.ts +0 -101
- package/src/io/README.md +0 -10
- package/src/io/docx-session.ts +0 -2882
- package/src/io/export/README.md +0 -3
- package/src/io/export/export-session.ts +0 -220
- package/src/io/export/minimal-docx.ts +0 -115
- package/src/io/export/reattach-preserved-parts.ts +0 -54
- package/src/io/export/serialize-comments.ts +0 -947
- package/src/io/export/serialize-footnotes.ts +0 -399
- package/src/io/export/serialize-headers-footers.ts +0 -372
- package/src/io/export/serialize-main-document.ts +0 -1376
- package/src/io/export/serialize-numbering.ts +0 -118
- package/src/io/export/serialize-revisions.ts +0 -389
- package/src/io/export/serialize-runtime-revisions.ts +0 -269
- package/src/io/export/serialize-tables.ts +0 -174
- package/src/io/export/split-review-boundaries.ts +0 -356
- package/src/io/normalize/README.md +0 -3
- package/src/io/normalize/normalize-text.ts +0 -639
- package/src/io/ooxml/README.md +0 -3
- package/src/io/ooxml/highlight-colors.ts +0 -39
- package/src/io/ooxml/numbering-sentinels.ts +0 -44
- package/src/io/ooxml/parse-comments.ts +0 -846
- package/src/io/ooxml/parse-complex-content.ts +0 -287
- package/src/io/ooxml/parse-fields.ts +0 -834
- package/src/io/ooxml/parse-footnotes.ts +0 -896
- package/src/io/ooxml/parse-headers-footers.ts +0 -1169
- package/src/io/ooxml/parse-inline-media.ts +0 -461
- package/src/io/ooxml/parse-main-document.ts +0 -2877
- package/src/io/ooxml/parse-numbering.ts +0 -432
- package/src/io/ooxml/parse-revisions.ts +0 -931
- package/src/io/ooxml/parse-settings.ts +0 -184
- package/src/io/ooxml/parse-shapes.ts +0 -296
- package/src/io/ooxml/parse-styles.ts +0 -463
- package/src/io/ooxml/parse-tables.ts +0 -618
- package/src/io/ooxml/parse-theme.ts +0 -346
- package/src/io/ooxml/part-manifest.ts +0 -136
- package/src/io/ooxml/revision-boundaries.ts +0 -351
- package/src/io/opc/README.md +0 -3
- package/src/io/opc/corrupt-package.ts +0 -166
- package/src/io/opc/docx-package.ts +0 -74
- package/src/io/opc/package-reader.ts +0 -325
- package/src/io/opc/package-writer.ts +0 -273
- package/src/io/source-package-provenance.ts +0 -241
- package/src/legal/cross-references.ts +0 -414
- package/src/legal/defined-terms.ts +0 -203
- package/src/legal/index.ts +0 -32
- package/src/legal/signature-blocks.ts +0 -259
- package/src/model/README.md +0 -3
- package/src/model/canonical-document.ts +0 -2632
- package/src/model/cds-1.0.0.ts +0 -212
- package/src/model/snapshot.ts +0 -649
- package/src/preservation/README.md +0 -3
- package/src/preservation/markup-compatibility.ts +0 -48
- package/src/preservation/opaque-fragment-store.ts +0 -89
- package/src/preservation/opaque-region.ts +0 -233
- package/src/preservation/package-preservation.ts +0 -113
- package/src/preservation/preserved-part-manifest.ts +0 -56
- package/src/preservation/relationship-retention.ts +0 -57
- package/src/preservation/store.ts +0 -185
- package/src/review/README.md +0 -16
- package/src/review/store/README.md +0 -3
- package/src/review/store/comment-anchors.ts +0 -70
- package/src/review/store/comment-remapping.ts +0 -154
- package/src/review/store/comment-store.ts +0 -331
- package/src/review/store/comment-thread.ts +0 -109
- package/src/review/store/revision-actions.ts +0 -394
- package/src/review/store/revision-store.ts +0 -312
- package/src/review/store/revision-types.ts +0 -171
- package/src/review/store/runtime-comment-store.ts +0 -43
- package/src/runtime/README.md +0 -3
- package/src/runtime/ai-action-policy.ts +0 -764
- package/src/runtime/collab-review-sync.ts +0 -254
- package/src/runtime/document-layout.ts +0 -332
- package/src/runtime/document-navigation.ts +0 -603
- package/src/runtime/document-runtime.ts +0 -3159
- package/src/runtime/document-search.ts +0 -145
- package/src/runtime/numbering-prefix.ts +0 -216
- package/src/runtime/page-layout-estimation.ts +0 -212
- package/src/runtime/read-only-diagnostics-runtime.ts +0 -241
- package/src/runtime/review-runtime.ts +0 -44
- package/src/runtime/revision-runtime.ts +0 -107
- package/src/runtime/session-capabilities.ts +0 -192
- package/src/runtime/story-context.ts +0 -164
- package/src/runtime/story-targeting.ts +0 -162
- package/src/runtime/surface-projection.ts +0 -1357
- package/src/runtime/table-commands.ts +0 -173
- package/src/runtime/table-schema.ts +0 -309
- package/src/runtime/view-state.ts +0 -477
- package/src/runtime/virtualized-rendering.ts +0 -258
- package/src/runtime/workflow-markup.ts +0 -353
- package/src/ui/README.md +0 -30
- package/src/ui/WordReviewEditor.tsx +0 -4097
- package/src/ui/browser-export.ts +0 -52
- package/src/ui/comments/README.md +0 -3
- package/src/ui/compatibility/README.md +0 -3
- package/src/ui/editor-command-bag.ts +0 -120
- package/src/ui/editor-runtime-boundary.ts +0 -1457
- package/src/ui/editor-shell-view.tsx +0 -142
- package/src/ui/editor-surface/README.md +0 -3
- package/src/ui/editor-surface-controller.tsx +0 -63
- package/src/ui/headless/comment-decoration-model.ts +0 -124
- package/src/ui/headless/preserve-editor-selection.ts +0 -5
- package/src/ui/headless/revision-decoration-model.ts +0 -128
- package/src/ui/headless/selection-helpers.ts +0 -54
- package/src/ui/headless/selection-toolbar-model.ts +0 -34
- package/src/ui/headless/use-editor-keyboard.ts +0 -103
- package/src/ui/review/README.md +0 -3
- package/src/ui/runtime-snapshot-selectors.ts +0 -197
- package/src/ui/shared/revision-filters.ts +0 -31
- package/src/ui/status/README.md +0 -3
- package/src/ui/theme/README.md +0 -3
- package/src/ui/toolbar/README.md +0 -3
- package/src/ui/workflow-surface-blocked-rails.ts +0 -94
- package/src/ui-tailwind/chrome/tw-alert-banner.tsx +0 -64
- package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +0 -129
- package/src/ui-tailwind/chrome/tw-layout-panel.tsx +0 -114
- package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +0 -34
- package/src/ui-tailwind/chrome/tw-page-ruler.tsx +0 -386
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +0 -186
- package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +0 -139
- package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +0 -128
- package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +0 -58
- package/src/ui-tailwind/chrome/use-before-unload.ts +0 -20
- package/src/ui-tailwind/editor-surface/perf-probe.ts +0 -179
- package/src/ui-tailwind/editor-surface/pm-collab-plugins.ts +0 -40
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +0 -178
- package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +0 -31
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +0 -427
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +0 -123
- package/src/ui-tailwind/editor-surface/pm-schema.ts +0 -876
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +0 -504
- package/src/ui-tailwind/editor-surface/search-plugin.ts +0 -168
- package/src/ui-tailwind/editor-surface/surface-build-keys.ts +0 -61
- package/src/ui-tailwind/editor-surface/tw-caret.tsx +0 -12
- package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +0 -150
- package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +0 -129
- package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +0 -58
- package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +0 -151
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +0 -973
- package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +0 -111
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +0 -436
- package/src/ui-tailwind/index.ts +0 -62
- package/src/ui-tailwind/page-chrome-model.ts +0 -27
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +0 -406
- package/src/ui-tailwind/review/tw-health-panel.tsx +0 -149
- package/src/ui-tailwind/review/tw-review-rail.tsx +0 -120
- package/src/ui-tailwind/review/tw-revision-sidebar.tsx +0 -164
- package/src/ui-tailwind/status/tw-status-bar.tsx +0 -61
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +0 -52
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +0 -1064
- package/src/ui-tailwind/tw-review-workspace.tsx +0 -1417
- package/src/validation/README.md +0 -3
- package/src/validation/compatibility-engine.ts +0 -634
- package/src/validation/compatibility-report.ts +0 -161
- package/src/validation/diagnostics.ts +0 -204
- package/src/validation/docx-comment-proof.ts +0 -707
- package/src/validation/import-diagnostics.ts +0 -128
- package/src/validation/low-priority-word-surfaces.ts +0 -373
- /package/{src → dist}/ui-tailwind/theme/editor-theme.css +0 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/ui-tailwind/editor-surface/search-plugin.ts
|
|
21
|
+
var search_plugin_exports = {};
|
|
22
|
+
__export(search_plugin_exports, {
|
|
23
|
+
DEFAULT_SEARCH_HIGHLIGHT_COLOR: () => DEFAULT_SEARCH_HIGHLIGHT_COLOR,
|
|
24
|
+
clearSearch: () => clearSearch,
|
|
25
|
+
createSearchExcerpt: () => createSearchExcerpt,
|
|
26
|
+
createSearchPlugin: () => createSearchPlugin,
|
|
27
|
+
findSearchMatches: () => findSearchMatches,
|
|
28
|
+
performSearch: () => performSearch,
|
|
29
|
+
searchPluginKey: () => searchPluginKey,
|
|
30
|
+
searchSecondaryStories: () => searchSecondaryStories
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(search_plugin_exports);
|
|
33
|
+
var import_prosemirror_state = require("prosemirror-state");
|
|
34
|
+
var import_prosemirror_view = require("prosemirror-view");
|
|
35
|
+
|
|
36
|
+
// src/core/search/search-text.ts
|
|
37
|
+
function buildSearchPattern(query, options = {}) {
|
|
38
|
+
if (!query) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const caseSensitive = options.matchCase ?? options.caseSensitive ?? false;
|
|
42
|
+
const regex = options.regex ?? false;
|
|
43
|
+
const wholeWord = options.wholeWord ?? false;
|
|
44
|
+
try {
|
|
45
|
+
const source = regex ? query : query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
46
|
+
const wrapped = wholeWord ? `\\b${source}\\b` : source;
|
|
47
|
+
return new RegExp(wrapped, caseSensitive ? "g" : "gi");
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function findSearchMatches(text, query, options = {}) {
|
|
53
|
+
const pattern = buildSearchPattern(query, options);
|
|
54
|
+
if (!pattern) return [];
|
|
55
|
+
const results = [];
|
|
56
|
+
let match;
|
|
57
|
+
pattern.lastIndex = 0;
|
|
58
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
59
|
+
results.push({
|
|
60
|
+
from: match.index,
|
|
61
|
+
to: match.index + match[0].length,
|
|
62
|
+
text: match[0],
|
|
63
|
+
index: results.length
|
|
64
|
+
});
|
|
65
|
+
if (match[0].length === 0) {
|
|
66
|
+
pattern.lastIndex += 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return results;
|
|
70
|
+
}
|
|
71
|
+
function createSearchExcerpt(text, from, to, radius = 24) {
|
|
72
|
+
const safeFrom = Math.max(0, Math.min(from, text.length));
|
|
73
|
+
const safeTo = Math.max(safeFrom, Math.min(to, text.length));
|
|
74
|
+
const start = Math.max(0, safeFrom - radius);
|
|
75
|
+
const end = Math.min(text.length, safeTo + radius);
|
|
76
|
+
const prefix = start > 0 ? "\u2026" : "";
|
|
77
|
+
const suffix = end < text.length ? "\u2026" : "";
|
|
78
|
+
const excerpt = text.slice(start, end).replace(/[\uFFF9\uFFFA]/gu, "").replace(/\s{2,}/gu, " ").trim();
|
|
79
|
+
return `${prefix}${excerpt}${suffix}`;
|
|
80
|
+
}
|
|
81
|
+
function searchSurfaceBlocks(blocks, query, options = {}) {
|
|
82
|
+
const projection = projectSurfaceText(blocks);
|
|
83
|
+
return findSearchMatches(projection.text, query, options).map((match) => {
|
|
84
|
+
const range = resolveProjectedRuntimeRange(
|
|
85
|
+
projection.offsetMap,
|
|
86
|
+
match.from,
|
|
87
|
+
match.to
|
|
88
|
+
);
|
|
89
|
+
if (!range) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...match,
|
|
94
|
+
from: range.from,
|
|
95
|
+
to: range.to,
|
|
96
|
+
excerpt: createSearchExcerpt(projection.text, match.from, match.to)
|
|
97
|
+
};
|
|
98
|
+
}).filter((match) => Boolean(match));
|
|
99
|
+
}
|
|
100
|
+
function searchSecondaryStories(stories, query, options = {}) {
|
|
101
|
+
const results = [];
|
|
102
|
+
for (const story of stories) {
|
|
103
|
+
for (const match of searchSurfaceBlocks(story.blocks, query, options)) {
|
|
104
|
+
results.push({
|
|
105
|
+
storyTarget: story.target,
|
|
106
|
+
from: match.from,
|
|
107
|
+
to: match.to,
|
|
108
|
+
text: match.text,
|
|
109
|
+
index: results.length,
|
|
110
|
+
excerpt: match.excerpt
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return results;
|
|
115
|
+
}
|
|
116
|
+
function projectSurfaceText(blocks) {
|
|
117
|
+
const builder = {
|
|
118
|
+
text: [],
|
|
119
|
+
offsetMap: [],
|
|
120
|
+
nextRuntimeOffset: 0
|
|
121
|
+
};
|
|
122
|
+
appendSurfaceBlocks(builder, blocks);
|
|
123
|
+
return {
|
|
124
|
+
text: builder.text.join(""),
|
|
125
|
+
offsetMap: builder.offsetMap
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function appendSurfaceBlocks(builder, blocks) {
|
|
129
|
+
for (const block of blocks) {
|
|
130
|
+
if (block.kind === "opaque_block") {
|
|
131
|
+
if (block.fragmentId.startsWith("preview:")) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
appendAtomicSpan(builder, block.from, block.to, "\uFFFA");
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (block.kind === "table") {
|
|
138
|
+
appendRuntimeGap(builder, block.from);
|
|
139
|
+
for (const [rowIndex, row] of block.rows.entries()) {
|
|
140
|
+
if (rowIndex > 0) {
|
|
141
|
+
appendSyntheticSeparator(builder, "\n");
|
|
142
|
+
}
|
|
143
|
+
for (const [cellIndex, cell] of row.cells.entries()) {
|
|
144
|
+
if (cellIndex > 0) {
|
|
145
|
+
appendSyntheticSeparator(builder, " ");
|
|
146
|
+
}
|
|
147
|
+
appendSurfaceBlocks(builder, cell.content);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
appendRuntimeGap(builder, block.to);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (block.kind === "sdt_block") {
|
|
154
|
+
appendRuntimeGap(builder, block.from);
|
|
155
|
+
appendSurfaceBlocks(builder, block.children);
|
|
156
|
+
appendRuntimeGap(builder, block.to);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
for (const segment of block.segments) {
|
|
160
|
+
switch (segment.kind) {
|
|
161
|
+
case "text":
|
|
162
|
+
appendTextSpan(builder, segment.text, segment.from);
|
|
163
|
+
break;
|
|
164
|
+
case "tab":
|
|
165
|
+
appendAtomicSpan(builder, segment.from, segment.to, " ");
|
|
166
|
+
break;
|
|
167
|
+
case "hard_break":
|
|
168
|
+
appendAtomicSpan(builder, segment.from, segment.to, "\n");
|
|
169
|
+
break;
|
|
170
|
+
case "image":
|
|
171
|
+
appendAtomicSpan(builder, segment.from, segment.to, "\uFFFC");
|
|
172
|
+
break;
|
|
173
|
+
case "opaque_inline":
|
|
174
|
+
appendAtomicSpan(builder, segment.from, segment.to, "\uFFF9");
|
|
175
|
+
break;
|
|
176
|
+
case "note_ref":
|
|
177
|
+
appendAtomicSpan(builder, segment.from, segment.to, "\uFFFA");
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
appendRuntimeGap(builder, block.to);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function appendTextSpan(builder, text, startOffset) {
|
|
185
|
+
appendRuntimeGap(builder, startOffset);
|
|
186
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
187
|
+
builder.text.push(text[index]);
|
|
188
|
+
builder.offsetMap.push(startOffset + index);
|
|
189
|
+
}
|
|
190
|
+
builder.nextRuntimeOffset = Math.max(
|
|
191
|
+
builder.nextRuntimeOffset,
|
|
192
|
+
startOffset + text.length
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function appendAtomicSpan(builder, from, to, char) {
|
|
196
|
+
appendRuntimeGap(builder, from);
|
|
197
|
+
const width = Math.max(1, to - from);
|
|
198
|
+
for (let index = 0; index < width; index += 1) {
|
|
199
|
+
builder.text.push(char);
|
|
200
|
+
builder.offsetMap.push(from + index);
|
|
201
|
+
}
|
|
202
|
+
builder.nextRuntimeOffset = Math.max(builder.nextRuntimeOffset, to);
|
|
203
|
+
}
|
|
204
|
+
function appendRuntimeGap(builder, nextFrom) {
|
|
205
|
+
for (let offset = builder.nextRuntimeOffset; offset < nextFrom; offset += 1) {
|
|
206
|
+
builder.text.push("\n");
|
|
207
|
+
builder.offsetMap.push(offset);
|
|
208
|
+
}
|
|
209
|
+
builder.nextRuntimeOffset = Math.max(builder.nextRuntimeOffset, nextFrom);
|
|
210
|
+
}
|
|
211
|
+
function appendSyntheticSeparator(builder, value) {
|
|
212
|
+
for (const char of value) {
|
|
213
|
+
builder.text.push(char);
|
|
214
|
+
builder.offsetMap.push(null);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function resolveProjectedRuntimeRange(offsetMap, from, to) {
|
|
218
|
+
let runtimeFrom;
|
|
219
|
+
for (let index = from; index < to; index += 1) {
|
|
220
|
+
const offset = offsetMap[index];
|
|
221
|
+
if (offset !== null && offset !== void 0) {
|
|
222
|
+
runtimeFrom = offset;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
let runtimeTo;
|
|
227
|
+
for (let index = to - 1; index >= from; index -= 1) {
|
|
228
|
+
const offset = offsetMap[index];
|
|
229
|
+
if (offset !== null && offset !== void 0) {
|
|
230
|
+
runtimeTo = offset + 1;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (runtimeFrom === void 0 || runtimeTo === void 0) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
return { from: runtimeFrom, to: runtimeTo };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/ui-tailwind/editor-surface/search-plugin.ts
|
|
241
|
+
var DEFAULT_SEARCH_HIGHLIGHT_COLOR = "#fde68a";
|
|
242
|
+
var searchPluginKey = new import_prosemirror_state.PluginKey("search");
|
|
243
|
+
function createSearchPlugin() {
|
|
244
|
+
return new import_prosemirror_state.Plugin({
|
|
245
|
+
key: searchPluginKey,
|
|
246
|
+
state: {
|
|
247
|
+
init() {
|
|
248
|
+
return { results: [], highlightColor: null };
|
|
249
|
+
},
|
|
250
|
+
apply(tr, pluginState) {
|
|
251
|
+
const meta = tr.getMeta(searchPluginKey);
|
|
252
|
+
if (meta) return meta;
|
|
253
|
+
return pluginState;
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
props: {
|
|
257
|
+
decorations(state) {
|
|
258
|
+
const pluginState = searchPluginKey.getState(state);
|
|
259
|
+
if (!pluginState || pluginState.results.length === 0 || !pluginState.highlightColor) {
|
|
260
|
+
return import_prosemirror_view.DecorationSet.empty;
|
|
261
|
+
}
|
|
262
|
+
const decos = pluginState.results.map(
|
|
263
|
+
(r) => import_prosemirror_view.Decoration.inline(r.from, r.to, {
|
|
264
|
+
style: `background-color: ${pluginState.highlightColor}; border-radius: 2px;`,
|
|
265
|
+
class: "search-highlight"
|
|
266
|
+
})
|
|
267
|
+
);
|
|
268
|
+
return import_prosemirror_view.DecorationSet.create(state.doc, decos);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function performSearch(state, query, options = {}) {
|
|
274
|
+
const pattern = buildSearchPattern(query, options);
|
|
275
|
+
if (!pattern) return [];
|
|
276
|
+
const results = [];
|
|
277
|
+
state.doc.descendants((node, pos) => {
|
|
278
|
+
if (!node.isText || !node.text) return;
|
|
279
|
+
let match;
|
|
280
|
+
pattern.lastIndex = 0;
|
|
281
|
+
while ((match = pattern.exec(node.text)) !== null) {
|
|
282
|
+
results.push({
|
|
283
|
+
from: pos + match.index,
|
|
284
|
+
to: pos + match.index + match[0].length,
|
|
285
|
+
text: match[0],
|
|
286
|
+
index: results.length
|
|
287
|
+
});
|
|
288
|
+
if (match[0].length === 0) {
|
|
289
|
+
pattern.lastIndex += 1;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
return results;
|
|
294
|
+
}
|
|
295
|
+
function clearSearch(state, dispatch) {
|
|
296
|
+
if (!dispatch) return true;
|
|
297
|
+
dispatch(
|
|
298
|
+
state.tr.setMeta(searchPluginKey, { results: [], highlightColor: null })
|
|
299
|
+
);
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
303
|
+
0 && (module.exports = {
|
|
304
|
+
DEFAULT_SEARCH_HIGHLIGHT_COLOR,
|
|
305
|
+
clearSearch,
|
|
306
|
+
createSearchExcerpt,
|
|
307
|
+
createSearchPlugin,
|
|
308
|
+
findSearchMatches,
|
|
309
|
+
performSearch,
|
|
310
|
+
searchPluginKey,
|
|
311
|
+
searchSecondaryStories
|
|
312
|
+
});
|
|
313
|
+
//# sourceMappingURL=search-plugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui-tailwind/editor-surface/search-plugin.ts","../../../src/core/search/search-text.ts"],"sourcesContent":["/**\n * ProseMirror search/highlight plugin for the editor surface.\n *\n * Provides in-document search with optional case sensitivity and regex support.\n * Matched ranges are shown as inline decorations with a configurable highlight color.\n *\n * Usage:\n * 1. Include createSearchPlugin() in the editor plugin list.\n * 2. Call performSearch(state, query, options) to compute matches.\n * 3. Dispatch the results into the plugin state via searchPluginKey meta.\n * 4. Call clearSearch(state, dispatch) to remove all highlights.\n */\n\nimport { Plugin, PluginKey } from \"prosemirror-state\";\nimport type { EditorState, Transaction } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\n\nimport type {\n SearchOptions as PublicSearchOptions,\n} from \"../../api/public-types\";\nimport {\n buildSearchPattern,\n createSearchExcerpt,\n findSearchMatches,\n searchSecondaryStories,\n type SecondaryStorySearchResult,\n type SearchTextOptions,\n} from \"../../core/search/search-text.ts\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface SearchResult {\n from: number;\n to: number;\n text: string;\n index: number;\n}\n\nexport interface SearchOptions extends PublicSearchOptions, SearchTextOptions {\n regex?: boolean;\n highlightColor?: string;\n}\n\nexport const DEFAULT_SEARCH_HIGHLIGHT_COLOR = \"#fde68a\";\n\n// ---------------------------------------------------------------------------\n// Plugin state\n// ---------------------------------------------------------------------------\n\ninterface SearchPluginState {\n results: SearchResult[];\n highlightColor: string | null;\n}\n\nexport const searchPluginKey = new PluginKey<SearchPluginState>(\"search\");\n\n// ---------------------------------------------------------------------------\n// Plugin factory\n// ---------------------------------------------------------------------------\n\nexport function createSearchPlugin(): Plugin<SearchPluginState> {\n return new Plugin<SearchPluginState>({\n key: searchPluginKey,\n\n state: {\n init(): SearchPluginState {\n return { results: [], highlightColor: null };\n },\n\n apply(tr: Transaction, pluginState: SearchPluginState): SearchPluginState {\n const meta = tr.getMeta(searchPluginKey) as SearchPluginState | undefined;\n if (meta) return meta;\n return pluginState;\n },\n },\n\n props: {\n decorations(state: EditorState): DecorationSet {\n const pluginState = searchPluginKey.getState(state);\n if (\n !pluginState ||\n pluginState.results.length === 0 ||\n !pluginState.highlightColor\n ) {\n return DecorationSet.empty;\n }\n\n const decos = pluginState.results.map((r) =>\n Decoration.inline(r.from, r.to, {\n style: `background-color: ${pluginState.highlightColor}; border-radius: 2px;`,\n class: \"search-highlight\",\n }),\n );\n\n return DecorationSet.create(state.doc, decos);\n },\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Search computation\n// ---------------------------------------------------------------------------\n\n/**\n * Scan all text nodes in the document for matches of `query`.\n * Returns an array of match ranges; does not dispatch anything.\n * To apply highlights, set the results on the plugin via:\n * view.dispatch(view.state.tr.setMeta(searchPluginKey, { results, highlightColor }))\n */\nexport function performSearch(\n state: EditorState,\n query: string,\n options: SearchOptions = {},\n): SearchResult[] {\n const pattern = buildSearchPattern(query, options);\n if (!pattern) return [];\n\n const results: SearchResult[] = [];\n\n state.doc.descendants((node, pos) => {\n if (!node.isText || !node.text) return;\n\n let match: RegExpExecArray | null;\n pattern.lastIndex = 0;\n while ((match = pattern.exec(node.text)) !== null) {\n results.push({\n from: pos + match.index,\n to: pos + match.index + match[0].length,\n text: match[0],\n index: results.length,\n });\n\n if (match[0].length === 0) {\n pattern.lastIndex += 1;\n }\n }\n });\n\n return results;\n}\n\n// ---------------------------------------------------------------------------\n// Clear helper (ProseMirror Command signature)\n// ---------------------------------------------------------------------------\n\n/**\n * ProseMirror command that clears all search highlights from the plugin state.\n */\nexport function clearSearch(\n state: EditorState,\n dispatch?: (tr: Transaction) => void,\n): boolean {\n if (!dispatch) return true;\n dispatch(\n state.tr.setMeta(searchPluginKey, { results: [], highlightColor: null }),\n );\n return true;\n}\n\nexport {\n createSearchExcerpt,\n findSearchMatches,\n searchSecondaryStories,\n};\nexport type { SecondaryStorySearchResult };\n","import type {\n EditorStoryTarget,\n SearchOptions as PublicSearchOptions,\n SecondaryStorySurface,\n SurfaceBlockSnapshot,\n WorkflowCandidateRange,\n} from \"../../api/public-types\";\n\nexport interface SearchTextOptions extends PublicSearchOptions {\n caseSensitive?: boolean;\n regex?: boolean;\n}\n\nexport interface SearchResult {\n from: number;\n to: number;\n text: string;\n index: number;\n}\n\nexport interface SurfaceSearchResult extends SearchResult {\n excerpt: string;\n}\n\nexport interface SecondaryStorySearchResult extends SurfaceSearchResult {\n storyTarget: EditorStoryTarget;\n}\n\ninterface ProjectedSurfaceText {\n text: string;\n offsetMap: Array<number | null>;\n}\n\ninterface SurfaceProjectionBuilder {\n text: string[];\n offsetMap: Array<number | null>;\n nextRuntimeOffset: number;\n}\n\nexport function buildSearchPattern(\n query: string,\n options: SearchTextOptions = {},\n): RegExp | null {\n if (!query) {\n return null;\n }\n\n const caseSensitive = options.matchCase ?? options.caseSensitive ?? false;\n const regex = options.regex ?? false;\n const wholeWord = options.wholeWord ?? false;\n\n try {\n const source = regex\n ? query\n : query.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const wrapped = wholeWord ? `\\\\b${source}\\\\b` : source;\n return new RegExp(wrapped, caseSensitive ? \"g\" : \"gi\");\n } catch {\n return null;\n }\n}\n\nexport function findSearchMatches(\n text: string,\n query: string,\n options: SearchTextOptions = {},\n): SearchResult[] {\n const pattern = buildSearchPattern(query, options);\n if (!pattern) return [];\n\n const results: SearchResult[] = [];\n let match: RegExpExecArray | null;\n pattern.lastIndex = 0;\n while ((match = pattern.exec(text)) !== null) {\n results.push({\n from: match.index,\n to: match.index + match[0].length,\n text: match[0],\n index: results.length,\n });\n\n if (match[0].length === 0) {\n pattern.lastIndex += 1;\n }\n }\n\n return results;\n}\n\nexport function createSearchExcerpt(\n text: string,\n from: number,\n to: number,\n radius = 24,\n): string {\n const safeFrom = Math.max(0, Math.min(from, text.length));\n const safeTo = Math.max(safeFrom, Math.min(to, text.length));\n const start = Math.max(0, safeFrom - radius);\n const end = Math.min(text.length, safeTo + radius);\n const prefix = start > 0 ? \"…\" : \"\";\n const suffix = end < text.length ? \"…\" : \"\";\n const excerpt = text\n .slice(start, end)\n .replace(/[\\uFFF9\\uFFFA]/gu, \"\")\n .replace(/\\s{2,}/gu, \" \")\n .trim();\n return `${prefix}${excerpt}${suffix}`;\n}\n\nexport function searchSurfaceBlocks(\n blocks: readonly SurfaceBlockSnapshot[],\n query: string,\n options: SearchTextOptions = {},\n): SurfaceSearchResult[] {\n const projection = projectSurfaceText(blocks);\n return findSearchMatches(projection.text, query, options)\n .map((match) => {\n const range = resolveProjectedRuntimeRange(\n projection.offsetMap,\n match.from,\n match.to,\n );\n if (!range) {\n return null;\n }\n\n return {\n ...match,\n from: range.from,\n to: range.to,\n excerpt: createSearchExcerpt(projection.text, match.from, match.to),\n };\n })\n .filter((match): match is SurfaceSearchResult => Boolean(match));\n}\n\nexport function searchSecondaryStories(\n stories: readonly SecondaryStorySurface[],\n query: string,\n options: SearchTextOptions = {},\n): SecondaryStorySearchResult[] {\n const results: SecondaryStorySearchResult[] = [];\n\n for (const story of stories) {\n for (const match of searchSurfaceBlocks(story.blocks, query, options)) {\n results.push({\n storyTarget: story.target,\n from: match.from,\n to: match.to,\n text: match.text,\n index: results.length,\n excerpt: match.excerpt,\n });\n }\n }\n\n return results;\n}\n\n/**\n * Derive workflow candidate ranges from search results.\n *\n * Maps search hits into `WorkflowCandidateRange` values suitable for\n * inclusion in a host-fed `WorkflowOverlay`. The runtime search results\n * supply runtime-mapped `from`/`to` positions that align with the\n * canonical document model.\n */\nexport function deriveCandidateRangesFromSearch(\n results: readonly SurfaceSearchResult[],\n storyTarget?: EditorStoryTarget,\n source: WorkflowCandidateRange[\"source\"] = \"search\",\n): WorkflowCandidateRange[] {\n return results.map((result, index) => ({\n candidateId: `search-candidate-${index}`,\n storyTarget,\n anchor: {\n kind: \"range\" as const,\n from: result.from,\n to: result.to,\n assoc: { start: 1 as const, end: -1 as const },\n },\n label: result.excerpt,\n source,\n }));\n}\n\nexport function projectSurfaceText(\n blocks: readonly SurfaceBlockSnapshot[],\n): ProjectedSurfaceText {\n const builder: SurfaceProjectionBuilder = {\n text: [],\n offsetMap: [],\n nextRuntimeOffset: 0,\n };\n\n appendSurfaceBlocks(builder, blocks);\n\n return {\n text: builder.text.join(\"\"),\n offsetMap: builder.offsetMap,\n };\n}\n\nfunction appendSurfaceBlocks(\n builder: SurfaceProjectionBuilder,\n blocks: readonly SurfaceBlockSnapshot[],\n): void {\n for (const block of blocks) {\n if (block.kind === \"opaque_block\") {\n if (block.fragmentId.startsWith(\"preview:\")) {\n continue;\n }\n appendAtomicSpan(builder, block.from, block.to, \"\\uFFFA\");\n continue;\n }\n\n if (block.kind === \"table\") {\n appendRuntimeGap(builder, block.from);\n for (const [rowIndex, row] of block.rows.entries()) {\n if (rowIndex > 0) {\n appendSyntheticSeparator(builder, \"\\n\");\n }\n for (const [cellIndex, cell] of row.cells.entries()) {\n if (cellIndex > 0) {\n appendSyntheticSeparator(builder, \"\\t\");\n }\n appendSurfaceBlocks(builder, cell.content);\n }\n }\n appendRuntimeGap(builder, block.to);\n continue;\n }\n\n if (block.kind === \"sdt_block\") {\n appendRuntimeGap(builder, block.from);\n appendSurfaceBlocks(builder, block.children);\n appendRuntimeGap(builder, block.to);\n continue;\n }\n\n for (const segment of block.segments) {\n switch (segment.kind) {\n case \"text\":\n appendTextSpan(builder, segment.text, segment.from);\n break;\n case \"tab\":\n appendAtomicSpan(builder, segment.from, segment.to, \"\\t\");\n break;\n case \"hard_break\":\n appendAtomicSpan(builder, segment.from, segment.to, \"\\n\");\n break;\n case \"image\":\n appendAtomicSpan(builder, segment.from, segment.to, \"\\uFFFC\");\n break;\n case \"opaque_inline\":\n appendAtomicSpan(builder, segment.from, segment.to, \"\\uFFF9\");\n break;\n case \"note_ref\":\n appendAtomicSpan(builder, segment.from, segment.to, \"\\uFFFA\");\n break;\n }\n }\n\n appendRuntimeGap(builder, block.to);\n }\n}\n\nfunction appendTextSpan(\n builder: SurfaceProjectionBuilder,\n text: string,\n startOffset: number,\n): void {\n appendRuntimeGap(builder, startOffset);\n\n for (let index = 0; index < text.length; index += 1) {\n builder.text.push(text[index]!);\n builder.offsetMap.push(startOffset + index);\n }\n\n builder.nextRuntimeOffset = Math.max(\n builder.nextRuntimeOffset,\n startOffset + text.length,\n );\n}\n\nfunction appendAtomicSpan(\n builder: SurfaceProjectionBuilder,\n from: number,\n to: number,\n char: string,\n): void {\n appendRuntimeGap(builder, from);\n const width = Math.max(1, to - from);\n\n for (let index = 0; index < width; index += 1) {\n builder.text.push(char);\n builder.offsetMap.push(from + index);\n }\n\n builder.nextRuntimeOffset = Math.max(builder.nextRuntimeOffset, to);\n}\n\nfunction appendRuntimeGap(\n builder: SurfaceProjectionBuilder,\n nextFrom: number,\n): void {\n for (\n let offset = builder.nextRuntimeOffset;\n offset < nextFrom;\n offset += 1\n ) {\n builder.text.push(\"\\n\");\n builder.offsetMap.push(offset);\n }\n\n builder.nextRuntimeOffset = Math.max(builder.nextRuntimeOffset, nextFrom);\n}\n\nfunction appendSyntheticSeparator(\n builder: SurfaceProjectionBuilder,\n value: string,\n): void {\n for (const char of value) {\n builder.text.push(char);\n builder.offsetMap.push(null);\n }\n}\n\nfunction resolveProjectedRuntimeRange(\n offsetMap: ReadonlyArray<number | null>,\n from: number,\n to: number,\n): { from: number; to: number } | null {\n let runtimeFrom: number | undefined;\n for (let index = from; index < to; index += 1) {\n const offset = offsetMap[index];\n if (offset !== null && offset !== undefined) {\n runtimeFrom = offset;\n break;\n }\n }\n\n let runtimeTo: number | undefined;\n for (let index = to - 1; index >= from; index -= 1) {\n const offset = offsetMap[index];\n if (offset !== null && offset !== undefined) {\n runtimeTo = offset + 1;\n break;\n }\n }\n\n if (runtimeFrom === undefined || runtimeTo === undefined) {\n return null;\n }\n\n return { from: runtimeFrom, to: runtimeTo };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,+BAAkC;AAElC,8BAA0C;;;ACwBnC,SAAS,mBACd,OACA,UAA6B,CAAC,GACf;AACf,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,QAAQ,aAAa,QAAQ,iBAAiB;AACpE,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,YAAY,QAAQ,aAAa;AAEvC,MAAI;AACF,UAAM,SAAS,QACX,QACA,MAAM,QAAQ,uBAAuB,MAAM;AAC/C,UAAM,UAAU,YAAY,MAAM,MAAM,QAAQ;AAChD,WAAO,IAAI,OAAO,SAAS,gBAAgB,MAAM,IAAI;AAAA,EACvD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,kBACd,MACA,OACA,UAA6B,CAAC,GACd;AAChB,QAAM,UAAU,mBAAmB,OAAO,OAAO;AACjD,MAAI,CAAC,QAAS,QAAO,CAAC;AAEtB,QAAM,UAA0B,CAAC;AACjC,MAAI;AACJ,UAAQ,YAAY;AACpB,UAAQ,QAAQ,QAAQ,KAAK,IAAI,OAAO,MAAM;AAC5C,YAAQ,KAAK;AAAA,MACX,MAAM,MAAM;AAAA,MACZ,IAAI,MAAM,QAAQ,MAAM,CAAC,EAAE;AAAA,MAC3B,MAAM,MAAM,CAAC;AAAA,MACb,OAAO,QAAQ;AAAA,IACjB,CAAC;AAED,QAAI,MAAM,CAAC,EAAE,WAAW,GAAG;AACzB,cAAQ,aAAa;AAAA,IACvB;AAAA,EACF;AAEA,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|
2
|
+
import { aS as SearchOptions$1, v as EditorStoryTarget, aT as SecondaryStorySurface } from '../../public-types-CeMaDueh.cjs';
|
|
3
|
+
import '../../canonical-document-BLEbzL2J.cjs';
|
|
4
|
+
|
|
5
|
+
interface SearchTextOptions extends SearchOptions$1 {
|
|
6
|
+
caseSensitive?: boolean;
|
|
7
|
+
regex?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface SearchResult$1 {
|
|
10
|
+
from: number;
|
|
11
|
+
to: number;
|
|
12
|
+
text: string;
|
|
13
|
+
index: number;
|
|
14
|
+
}
|
|
15
|
+
interface SurfaceSearchResult extends SearchResult$1 {
|
|
16
|
+
excerpt: string;
|
|
17
|
+
}
|
|
18
|
+
interface SecondaryStorySearchResult extends SurfaceSearchResult {
|
|
19
|
+
storyTarget: EditorStoryTarget;
|
|
20
|
+
}
|
|
21
|
+
declare function findSearchMatches(text: string, query: string, options?: SearchTextOptions): SearchResult$1[];
|
|
22
|
+
declare function createSearchExcerpt(text: string, from: number, to: number, radius?: number): string;
|
|
23
|
+
declare function searchSecondaryStories(stories: readonly SecondaryStorySurface[], query: string, options?: SearchTextOptions): SecondaryStorySearchResult[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* ProseMirror search/highlight plugin for the editor surface.
|
|
27
|
+
*
|
|
28
|
+
* Provides in-document search with optional case sensitivity and regex support.
|
|
29
|
+
* Matched ranges are shown as inline decorations with a configurable highlight color.
|
|
30
|
+
*
|
|
31
|
+
* Usage:
|
|
32
|
+
* 1. Include createSearchPlugin() in the editor plugin list.
|
|
33
|
+
* 2. Call performSearch(state, query, options) to compute matches.
|
|
34
|
+
* 3. Dispatch the results into the plugin state via searchPluginKey meta.
|
|
35
|
+
* 4. Call clearSearch(state, dispatch) to remove all highlights.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
interface SearchResult {
|
|
39
|
+
from: number;
|
|
40
|
+
to: number;
|
|
41
|
+
text: string;
|
|
42
|
+
index: number;
|
|
43
|
+
}
|
|
44
|
+
interface SearchOptions extends SearchOptions$1, SearchTextOptions {
|
|
45
|
+
regex?: boolean;
|
|
46
|
+
highlightColor?: string;
|
|
47
|
+
}
|
|
48
|
+
declare const DEFAULT_SEARCH_HIGHLIGHT_COLOR = "#fde68a";
|
|
49
|
+
interface SearchPluginState {
|
|
50
|
+
results: SearchResult[];
|
|
51
|
+
highlightColor: string | null;
|
|
52
|
+
}
|
|
53
|
+
declare const searchPluginKey: PluginKey<SearchPluginState>;
|
|
54
|
+
declare function createSearchPlugin(): Plugin<SearchPluginState>;
|
|
55
|
+
/**
|
|
56
|
+
* Scan all text nodes in the document for matches of `query`.
|
|
57
|
+
* Returns an array of match ranges; does not dispatch anything.
|
|
58
|
+
* To apply highlights, set the results on the plugin via:
|
|
59
|
+
* view.dispatch(view.state.tr.setMeta(searchPluginKey, { results, highlightColor }))
|
|
60
|
+
*/
|
|
61
|
+
declare function performSearch(state: EditorState, query: string, options?: SearchOptions): SearchResult[];
|
|
62
|
+
/**
|
|
63
|
+
* ProseMirror command that clears all search highlights from the plugin state.
|
|
64
|
+
*/
|
|
65
|
+
declare function clearSearch(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
66
|
+
|
|
67
|
+
export { DEFAULT_SEARCH_HIGHLIGHT_COLOR, type SearchOptions, type SearchResult, type SecondaryStorySearchResult, clearSearch, createSearchExcerpt, createSearchPlugin, findSearchMatches, performSearch, searchPluginKey, searchSecondaryStories };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { EditorState, Transaction, Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { aS as SearchOptions$1, v as EditorStoryTarget, aT as SecondaryStorySurface } from '../../public-types-7ZL_94cz.js';
|
|
3
|
+
import '../../canonical-document-BLEbzL2J.js';
|
|
4
|
+
|
|
5
|
+
interface SearchTextOptions extends SearchOptions$1 {
|
|
6
|
+
caseSensitive?: boolean;
|
|
7
|
+
regex?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface SearchResult$1 {
|
|
10
|
+
from: number;
|
|
11
|
+
to: number;
|
|
12
|
+
text: string;
|
|
13
|
+
index: number;
|
|
14
|
+
}
|
|
15
|
+
interface SurfaceSearchResult extends SearchResult$1 {
|
|
16
|
+
excerpt: string;
|
|
17
|
+
}
|
|
18
|
+
interface SecondaryStorySearchResult extends SurfaceSearchResult {
|
|
19
|
+
storyTarget: EditorStoryTarget;
|
|
20
|
+
}
|
|
21
|
+
declare function findSearchMatches(text: string, query: string, options?: SearchTextOptions): SearchResult$1[];
|
|
22
|
+
declare function createSearchExcerpt(text: string, from: number, to: number, radius?: number): string;
|
|
23
|
+
declare function searchSecondaryStories(stories: readonly SecondaryStorySurface[], query: string, options?: SearchTextOptions): SecondaryStorySearchResult[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* ProseMirror search/highlight plugin for the editor surface.
|
|
27
|
+
*
|
|
28
|
+
* Provides in-document search with optional case sensitivity and regex support.
|
|
29
|
+
* Matched ranges are shown as inline decorations with a configurable highlight color.
|
|
30
|
+
*
|
|
31
|
+
* Usage:
|
|
32
|
+
* 1. Include createSearchPlugin() in the editor plugin list.
|
|
33
|
+
* 2. Call performSearch(state, query, options) to compute matches.
|
|
34
|
+
* 3. Dispatch the results into the plugin state via searchPluginKey meta.
|
|
35
|
+
* 4. Call clearSearch(state, dispatch) to remove all highlights.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
interface SearchResult {
|
|
39
|
+
from: number;
|
|
40
|
+
to: number;
|
|
41
|
+
text: string;
|
|
42
|
+
index: number;
|
|
43
|
+
}
|
|
44
|
+
interface SearchOptions extends SearchOptions$1, SearchTextOptions {
|
|
45
|
+
regex?: boolean;
|
|
46
|
+
highlightColor?: string;
|
|
47
|
+
}
|
|
48
|
+
declare const DEFAULT_SEARCH_HIGHLIGHT_COLOR = "#fde68a";
|
|
49
|
+
interface SearchPluginState {
|
|
50
|
+
results: SearchResult[];
|
|
51
|
+
highlightColor: string | null;
|
|
52
|
+
}
|
|
53
|
+
declare const searchPluginKey: PluginKey<SearchPluginState>;
|
|
54
|
+
declare function createSearchPlugin(): Plugin<SearchPluginState>;
|
|
55
|
+
/**
|
|
56
|
+
* Scan all text nodes in the document for matches of `query`.
|
|
57
|
+
* Returns an array of match ranges; does not dispatch anything.
|
|
58
|
+
* To apply highlights, set the results on the plugin via:
|
|
59
|
+
* view.dispatch(view.state.tr.setMeta(searchPluginKey, { results, highlightColor }))
|
|
60
|
+
*/
|
|
61
|
+
declare function performSearch(state: EditorState, query: string, options?: SearchOptions): SearchResult[];
|
|
62
|
+
/**
|
|
63
|
+
* ProseMirror command that clears all search highlights from the plugin state.
|
|
64
|
+
*/
|
|
65
|
+
declare function clearSearch(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
66
|
+
|
|
67
|
+
export { DEFAULT_SEARCH_HIGHLIGHT_COLOR, type SearchOptions, type SearchResult, type SecondaryStorySearchResult, clearSearch, createSearchExcerpt, createSearchPlugin, findSearchMatches, performSearch, searchPluginKey, searchSecondaryStories };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_SEARCH_HIGHLIGHT_COLOR,
|
|
3
|
+
clearSearch,
|
|
4
|
+
createSearchPlugin,
|
|
5
|
+
performSearch,
|
|
6
|
+
searchPluginKey
|
|
7
|
+
} from "../../chunk-4D5EWJ3P.js";
|
|
8
|
+
import {
|
|
9
|
+
createSearchExcerpt,
|
|
10
|
+
findSearchMatches,
|
|
11
|
+
searchSecondaryStories
|
|
12
|
+
} from "../../chunk-CN3XMECL.js";
|
|
13
|
+
export {
|
|
14
|
+
DEFAULT_SEARCH_HIGHLIGHT_COLOR,
|
|
15
|
+
clearSearch,
|
|
16
|
+
createSearchExcerpt,
|
|
17
|
+
createSearchPlugin,
|
|
18
|
+
findSearchMatches,
|
|
19
|
+
performSearch,
|
|
20
|
+
searchPluginKey,
|
|
21
|
+
searchSecondaryStories
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=search-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|