platejs 54.0.0-beta.2 → 54.0.0-beta.4
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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
- package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/AIChatPlugin.js +113 -78
- package/dist/ai/react/CopilotPlugin.js +1 -1
- package/dist/ai/react/index.d.ts +23 -16
- package/dist/authored/index.d.ts +4 -4
- package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
- package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/ai.md +4 -3
- package/dist/docs/api/core/plate-components.md +0 -19
- package/dist/docs/api/core/plate-controller.md +5 -3
- package/dist/docs/api/core/plate-plugin.md +3 -0
- package/dist/docs/api/core/plate-store.md +3 -3
- package/dist/docs/api/core.md +45 -5
- package/dist/docs/api/dom.md +11 -4
- package/dist/docs/api/editor-transforms.md +2 -1
- package/dist/docs/api/react-hooks.md +45 -13
- package/dist/docs/authored-changes.md +9 -4
- package/dist/docs/basic-blocks.md +42 -29
- package/dist/docs/block-placeholder.md +4 -2
- package/dist/docs/blockquote.md +5 -3
- package/dist/docs/board.md +118 -10
- package/dist/docs/code-block.md +47 -0
- package/dist/docs/comment.md +2 -2
- package/dist/docs/discussion.md +1 -1
- package/dist/docs/document-model.md +15 -3
- package/dist/docs/docx.md +1 -1
- package/dist/docs/dom-coverage.md +5 -0
- package/dist/docs/editor.md +50 -4
- package/dist/docs/examples/editable-voids.md +2 -3
- package/dist/docs/external-text.md +2 -0
- package/dist/docs/field.md +370 -0
- package/dist/docs/find.md +9 -6
- package/dist/docs/form.md +2 -0
- package/dist/docs/heading.md +6 -0
- package/dist/docs/installation/manual.md +0 -4
- package/dist/docs/link.md +3 -3
- package/dist/docs/llms.txt +4 -2
- package/dist/docs/markdown.md +270 -14
- package/dist/docs/plugin-components.md +13 -10
- package/dist/docs/plugin-input-rules.md +66 -15
- package/dist/docs/prompt-editor.md +205 -0
- package/dist/docs/roots.md +8 -6
- package/dist/docs/rtl.md +6 -4
- package/dist/docs/selection.md +7 -4
- package/dist/docs/suggestion.md +1 -1
- package/dist/docs/toolbar.md +26 -30
- package/dist/docs/upload.md +106 -17
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/docxStaticComponents.js +12 -2
- package/dist/docx/export/lib/exportDocx.js +46 -17
- package/dist/docx/export/lib/internal/xml-builder.js +11 -16
- package/dist/docx/export/lib/reviewPart.js +1 -1
- package/dist/docx/export/lib/reviewProjection.js +52 -10
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -6
- package/dist/dom/plite-dom.internal.js +2 -2
- package/dist/excalidraw/index.d.ts +3 -2
- package/dist/excalidraw/react/index.d.ts +3 -2
- package/dist/facade.js +2 -2
- package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
- package/dist/features/board/index.d.ts +2 -2
- package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
- package/dist/features/board/lib/boardStroke.internal.js +13 -1
- package/dist/features/board/lib/boardTypes.internal.js +16 -0
- package/dist/features/callout/index.d.ts +3 -2
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
- package/dist/features/combobox/index.d.ts +2 -2
- package/dist/features/comments/BaseCommentsPlugin.js +33 -17
- package/dist/features/comments/index.d.ts +1 -1
- package/dist/features/date/index.d.ts +3 -2
- package/dist/features/details/index.d.ts +3 -2
- package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
- package/dist/features/field/index.d.ts +2 -0
- package/dist/features/field/index.js +4 -0
- package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
- package/dist/features/field/lib/applyFieldValues.js +188 -0
- package/dist/features/field/lib/fieldRules.internal.js +204 -0
- package/dist/features/find/index.d.ts +3 -2
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
- package/dist/features/ink/lib/inkCodec.internal.js +130 -0
- package/dist/features/ink/lib/inkGone.internal.js +229 -48
- package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
- package/dist/features/lint/index.d.ts +3 -2
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
- package/dist/features/mention/index.d.ts +5 -4
- package/dist/features/suggestion/index.d.ts +1 -1
- package/dist/features/table/index.d.ts +1 -1
- package/dist/features/table/lib/BaseTablePlugin.js +64 -15
- package/dist/features/table/lib/internal/selection.js +4 -2
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +2 -2
- package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
- package/dist/history/index.d.ts +2 -2
- package/dist/html/index.d.ts +3 -3
- package/dist/html/server/index.d.ts +1 -1
- package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
- package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
- package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
- package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
- package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
- package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
- package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
- package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
- package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
- package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
- package/dist/index-C9Fu-P4E.d.ts +773 -0
- package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
- package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
- package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
- package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
- package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
- package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
- package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
- package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
- package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
- package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
- package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
- package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
- package/dist/index.d.ts +4 -4
- package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
- package/dist/internal/plugin/OverridePlugin.js +101 -119
- package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
- package/dist/internal/plugin/pastedUploadFiles.js +4 -0
- package/dist/internal/plugin/resolvePlugin.js +1 -1
- package/dist/internal/plugin/resolvePlugins.js +3 -0
- package/dist/internal/plugin/uploadDrafts.js +6 -0
- package/dist/internal/utils/mergePlugins.js +1 -0
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
- package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
- package/dist/lib/plugins/html/htmlSafety.js +1 -1
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +3 -1
- package/dist/markdown/lib/MarkdownPlugin.js +14 -11
- package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
- package/dist/markdown/lib/internal/markdownConversion.js +776 -74
- package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
- package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
- package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
- package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
- package/dist/markdown/lib/internal/markdownLine.js +5 -3
- package/dist/markdown/lib/internal/markdownMappings.js +19 -7
- package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
- package/dist/markdown/lib/internal/markdownSegments.js +57 -48
- package/dist/markdown/lib/internal/markdownTags.js +29 -9
- package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
- package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
- package/dist/math/index.d.ts +3 -2
- package/dist/math/react/index.d.ts +4 -3
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/migratePlateV54.js +4 -6
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
- package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
- package/dist/migrations/v53-manifest.internal.js +4 -0
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +42 -23
- package/dist/react/components/EditorProvider.js +5 -5
- package/dist/react/components/Plate.js +102 -128
- package/dist/react/components/PlateContainer.js +40 -32
- package/dist/react/components/PlateController.js +28 -16
- package/dist/react/components/PlateRoot.internal.js +3 -2
- package/dist/react/core.js +4 -4
- package/dist/react/features/board/BoardSurface.js +116 -87
- package/dist/react/features/board/boardClipboard.internal.js +15 -5
- package/dist/react/features/board/boardExport.internal.js +470 -0
- package/dist/react/features/board/boardGesture.internal.js +6 -3
- package/dist/react/features/board/boardIndex.internal.js +7 -18
- package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
- package/dist/react/features/board/boardPictures.internal.js +19 -13
- package/dist/react/features/board/boardView.internal.js +190 -50
- package/dist/react/features/board/boardVoice.internal.js +10 -11
- package/dist/react/features/board/index.d.ts +108 -18
- package/dist/react/features/callout/index.d.ts +3 -2
- package/dist/react/features/combobox/index.d.ts +8 -8
- package/dist/react/features/comments/index.d.ts +6 -5
- package/dist/react/features/date/index.d.ts +4 -3
- package/dist/react/features/details/index.d.ts +4 -3
- package/dist/react/features/field/FieldPlugin.js +35 -0
- package/dist/react/features/field/index.d.ts +315 -0
- package/dist/react/features/field/index.js +2 -0
- package/dist/react/features/footnote/index.d.ts +7 -6
- package/dist/react/features/format-painter/index.d.ts +4 -3
- package/dist/react/features/ink/InkContent.js +313 -0
- package/dist/react/features/ink/index.d.ts +57 -33
- package/dist/react/features/ink/index.js +2 -2
- package/dist/react/features/ink/inkCapture.internal.js +39 -17
- package/dist/react/features/ink/inkInput.internal.js +1 -1
- package/dist/react/features/ink/inkLayout.internal.js +6 -3
- package/dist/react/features/ink/inkPaint.internal.js +78 -2
- package/dist/react/features/ink/inkPlacement.internal.js +332 -104
- package/dist/react/features/ink/inkWatch.internal.js +7 -5
- package/dist/react/features/layout/index.d.ts +5 -4
- package/dist/react/features/media/index.d.ts +5 -4
- package/dist/react/features/mention/index.d.ts +6 -5
- package/dist/react/features/resizable/Resizable.js +4 -6
- package/dist/react/features/resizable/index.d.ts +5 -5
- package/dist/react/features/suggestion/index.d.ts +6 -5
- package/dist/react/features/table/TablePlugin.js +4 -11
- package/dist/react/features/table/index.d.ts +10 -8
- package/dist/react/features/table/useTableResize.js +10 -1
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +11 -6
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +4 -4
- package/dist/react/internal/plate-context.js +434 -188
- package/dist/react/plite-react.js +2 -2
- package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
- package/dist/react/stores/plate/useEditor.js +32 -14
- package/dist/react/stores/plate/useEditorHistory.js +55 -0
- package/dist/react/stores/plate/useEditorSelector.js +79 -21
- package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
- package/dist/react/utils/pipeRenderElement.internal.js +1 -1
- package/dist/react/utils/pluginRenderElement.internal.js +1 -1
- package/dist/react/virtualized.d.ts +4 -4
- package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
- package/dist/static/index.d.ts +18 -18
- package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
- package/dist/static/internal/staticPresentation.js +4 -4
- package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +6 -6
- package/package.json +20 -2
- package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
- package/dist/react/components/EditorSelectionView.js +0 -40
- package/dist/react/features/ink/InkLayer.js +0 -218
- package/dist/react/internal/createPlateTargetScope.js +0 -62
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "platejs",
|
|
3
|
-
"version": "54.0.0-beta.
|
|
3
|
+
"version": "54.0.0-beta.4",
|
|
4
4
|
"description": "Plate – a framework for building rich text editors on the web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contentEditable",
|
|
@@ -162,6 +162,16 @@
|
|
|
162
162
|
"import": "./dist/react/features/upload/index.js",
|
|
163
163
|
"default": "./dist/react/features/upload/index.js"
|
|
164
164
|
},
|
|
165
|
+
"./field": {
|
|
166
|
+
"types": "./dist/features/field/index.d.ts",
|
|
167
|
+
"import": "./dist/features/field/index.js",
|
|
168
|
+
"default": "./dist/features/field/index.js"
|
|
169
|
+
},
|
|
170
|
+
"./field/react": {
|
|
171
|
+
"types": "./dist/react/features/field/index.d.ts",
|
|
172
|
+
"import": "./dist/react/features/field/index.js",
|
|
173
|
+
"default": "./dist/react/features/field/index.js"
|
|
174
|
+
},
|
|
165
175
|
"./find": {
|
|
166
176
|
"types": "./dist/features/find/index.d.ts",
|
|
167
177
|
"import": "./dist/features/find/index.js",
|
|
@@ -379,6 +389,7 @@
|
|
|
379
389
|
"lodash": "^4.17.23",
|
|
380
390
|
"mdast-util-math": "3.0.0",
|
|
381
391
|
"mdast-util-mdx": "3.0.0",
|
|
392
|
+
"micromark-extension-cjk-friendly-util": "3.0.1",
|
|
382
393
|
"mutative": "^1.1.0",
|
|
383
394
|
"nanoid": "^5.1.5",
|
|
384
395
|
"optics-ts": "2.4.1",
|
|
@@ -389,7 +400,7 @@
|
|
|
389
400
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
390
401
|
"unist-util-visit": "5.0.0",
|
|
391
402
|
"zustand": "^5.0.5",
|
|
392
|
-
"plitejs": "54.0.0-beta.
|
|
403
|
+
"plitejs": "54.0.0-beta.4"
|
|
393
404
|
},
|
|
394
405
|
"devDependencies": {
|
|
395
406
|
"@ai-sdk/react": "^3.0.0",
|
|
@@ -422,7 +433,10 @@
|
|
|
422
433
|
"mime-types": "^2.1.35",
|
|
423
434
|
"react": "19.2.8",
|
|
424
435
|
"react-dom": "19.2.8",
|
|
436
|
+
"remark-cjk-friendly": "2.3.4",
|
|
437
|
+
"remark-cjk-friendly-gfm-strikethrough": "2.3.3",
|
|
425
438
|
"remark-emoji": "5.0.1",
|
|
439
|
+
"remark-frontmatter": "5.0.0",
|
|
426
440
|
"remark-gfm": "4.0.1",
|
|
427
441
|
"remark-math": "6.0.0",
|
|
428
442
|
"remark-parse": "^11.0.0",
|
|
@@ -578,6 +592,8 @@
|
|
|
578
592
|
"lint:partition:docx-paste": "node ../../tooling/scripts/run-entrypoint-task.mjs lint platejs docx-paste",
|
|
579
593
|
"lint:partition:excalidraw": "node ../../tooling/scripts/run-entrypoint-task.mjs lint platejs excalidraw",
|
|
580
594
|
"lint:partition:excalidraw-react": "node ../../tooling/scripts/run-entrypoint-task.mjs lint platejs excalidraw-react",
|
|
595
|
+
"lint:partition:field": "node ../../tooling/scripts/run-entrypoint-task.mjs lint platejs field",
|
|
596
|
+
"lint:partition:field-react": "node ../../tooling/scripts/run-entrypoint-task.mjs lint platejs field-react",
|
|
581
597
|
"lint:partition:find": "node ../../tooling/scripts/run-entrypoint-task.mjs lint platejs find",
|
|
582
598
|
"lint:partition:footnote": "node ../../tooling/scripts/run-entrypoint-task.mjs lint platejs footnote",
|
|
583
599
|
"lint:partition:footnote-react": "node ../../tooling/scripts/run-entrypoint-task.mjs lint platejs footnote-react",
|
|
@@ -653,6 +669,8 @@
|
|
|
653
669
|
"test:partition:docx-paste": "node ../../tooling/scripts/run-entrypoint-task.mjs test platejs docx-paste",
|
|
654
670
|
"test:partition:excalidraw": "node ../../tooling/scripts/run-entrypoint-task.mjs test platejs excalidraw",
|
|
655
671
|
"test:partition:excalidraw-react": "node ../../tooling/scripts/run-entrypoint-task.mjs test platejs excalidraw-react",
|
|
672
|
+
"test:partition:field": "node ../../tooling/scripts/run-entrypoint-task.mjs test platejs field",
|
|
673
|
+
"test:partition:field-react": "node ../../tooling/scripts/run-entrypoint-task.mjs test platejs field-react",
|
|
656
674
|
"test:partition:find": "node ../../tooling/scripts/run-entrypoint-task.mjs test platejs find",
|
|
657
675
|
"test:partition:footnote": "node ../../tooling/scripts/run-entrypoint-task.mjs test platejs footnote",
|
|
658
676
|
"test:partition:footnote-react": "node ../../tooling/scripts/run-entrypoint-task.mjs test platejs footnote-react",
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { getMarkdownMarkWriter } from "../internal/markdownMappings.js";
|
|
2
|
-
//#region src/markdown/lib/serializer/convertTextsSerialize.ts
|
|
3
|
-
const convertTextsSerialize = (slateTexts, options) => {
|
|
4
|
-
const { mappings } = options;
|
|
5
|
-
const plainMarkSet = new Set(options.plainMarks);
|
|
6
|
-
const isWritten = (leaf, key) => !!leaf?.[key] && !plainMarkSet.has(key) && getMarkdownMarkWriter(mappings, key, leaf[key]) !== void 0;
|
|
7
|
-
const writerKind = (leaf, key) => leaf && getMarkdownMarkWriter(mappings, key, leaf[key])?.kind;
|
|
8
|
-
const mdastTexts = [];
|
|
9
|
-
const starts = [];
|
|
10
|
-
let ends = [];
|
|
11
|
-
let textTemp = "";
|
|
12
|
-
for (let j = 0; j < slateTexts.length; j++) {
|
|
13
|
-
const cur = slateTexts[j];
|
|
14
|
-
Object.entries(cur).forEach(([key, value]) => {
|
|
15
|
-
if (key === "text" || !value || plainMarkSet.has(key) || isWritten(cur, key) || options.state.schema.property({
|
|
16
|
-
key,
|
|
17
|
-
placement: "text"
|
|
18
|
-
})?.role === "metadata") return;
|
|
19
|
-
options.report({
|
|
20
|
-
code: "markdown-property-omitted",
|
|
21
|
-
key,
|
|
22
|
-
message: `Markdown cannot represent text property "${key}"; it was omitted.`,
|
|
23
|
-
model: {
|
|
24
|
-
...options.modelLocation(cur),
|
|
25
|
-
property: key
|
|
26
|
-
},
|
|
27
|
-
owner: key,
|
|
28
|
-
phase: "serialize",
|
|
29
|
-
reason: "unsupported",
|
|
30
|
-
severity: "warning"
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
textTemp += cur.text;
|
|
34
|
-
const prevStarts = starts.slice();
|
|
35
|
-
const prevEnds = ends.slice();
|
|
36
|
-
const prev = slateTexts[j - 1];
|
|
37
|
-
const next = slateTexts[j + 1];
|
|
38
|
-
ends = [];
|
|
39
|
-
mappings.markOrder.forEach((key) => {
|
|
40
|
-
if (isWritten(cur, key)) {
|
|
41
|
-
if (!isWritten(prev, key)) starts.push(key);
|
|
42
|
-
if (!isWritten(next, key)) ends.push(key);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const endSet = new Set(ends);
|
|
46
|
-
const endsToRemove = starts.reduce((acc, key, markIndex) => {
|
|
47
|
-
if (endSet.has(key)) acc.push({
|
|
48
|
-
index: markIndex,
|
|
49
|
-
key
|
|
50
|
-
});
|
|
51
|
-
return acc;
|
|
52
|
-
}, []);
|
|
53
|
-
if (starts.length > 0) {
|
|
54
|
-
let bef = "";
|
|
55
|
-
let aft = "";
|
|
56
|
-
if (endsToRemove.length === 1 && (prevStarts.toString() !== starts.toString() || prevEnds.some((key) => writerKind(prev, key) === "emphasis") && ends.some((key) => writerKind(cur, key) === "strong")) && starts.length - endsToRemove.length === 0) {
|
|
57
|
-
while (textTemp.startsWith(" ")) {
|
|
58
|
-
bef += " ";
|
|
59
|
-
textTemp = textTemp.slice(1);
|
|
60
|
-
}
|
|
61
|
-
while (textTemp.endsWith(" ")) {
|
|
62
|
-
aft += " ";
|
|
63
|
-
textTemp = textTemp.slice(0, -1);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
let res = {
|
|
67
|
-
type: "text",
|
|
68
|
-
value: textTemp
|
|
69
|
-
};
|
|
70
|
-
textTemp = "";
|
|
71
|
-
starts.slice().reverse().forEach((key) => {
|
|
72
|
-
const writer = getMarkdownMarkWriter(mappings, key, cur[key]);
|
|
73
|
-
switch (writer?.kind) {
|
|
74
|
-
case "delete":
|
|
75
|
-
case "emphasis":
|
|
76
|
-
case "strong":
|
|
77
|
-
res = {
|
|
78
|
-
children: [res],
|
|
79
|
-
type: writer.kind
|
|
80
|
-
};
|
|
81
|
-
break;
|
|
82
|
-
case "inlineCode": {
|
|
83
|
-
let currentRes = res;
|
|
84
|
-
while (currentRes.type !== "text" && currentRes.type !== "inlineCode") currentRes = currentRes.children[0];
|
|
85
|
-
currentRes.type = "inlineCode";
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case "wrap": {
|
|
89
|
-
const node = writer.wrap?.(cur, options);
|
|
90
|
-
if (node && isMdMarkContainer(node)) res = {
|
|
91
|
-
...node,
|
|
92
|
-
children: [res]
|
|
93
|
-
};
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case void 0: break;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
const arr = [];
|
|
100
|
-
if (bef.length > 0) arr.push({
|
|
101
|
-
type: "text",
|
|
102
|
-
value: bef
|
|
103
|
-
});
|
|
104
|
-
arr.push(res);
|
|
105
|
-
if (aft.length > 0) arr.push({
|
|
106
|
-
type: "text",
|
|
107
|
-
value: aft
|
|
108
|
-
});
|
|
109
|
-
mdastTexts.push(...arr);
|
|
110
|
-
}
|
|
111
|
-
if (endsToRemove.length > 0) endsToRemove.reverse().forEach((e) => {
|
|
112
|
-
starts.splice(e.index, 1);
|
|
113
|
-
});
|
|
114
|
-
else {
|
|
115
|
-
mdastTexts.push({
|
|
116
|
-
type: "text",
|
|
117
|
-
value: textTemp
|
|
118
|
-
});
|
|
119
|
-
textTemp = "";
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (textTemp) {
|
|
123
|
-
mdastTexts.push({
|
|
124
|
-
type: "text",
|
|
125
|
-
value: textTemp
|
|
126
|
-
});
|
|
127
|
-
textTemp = "";
|
|
128
|
-
}
|
|
129
|
-
return mergeTexts(mdastTexts).map((node) => {
|
|
130
|
-
if (!hasContent(node)) return {
|
|
131
|
-
type: "text",
|
|
132
|
-
value: ""
|
|
133
|
-
};
|
|
134
|
-
return node;
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
const isMdMarkContainer = (node) => node.type === "delete" || node.type === "emphasis" || node.type === "mdxJsxTextElement" || node.type === "strong";
|
|
138
|
-
const hasContent = (node) => {
|
|
139
|
-
if (node.type === "inlineCode") return node.value !== "";
|
|
140
|
-
if (node.type === "text") return node.value !== "";
|
|
141
|
-
if (node.children?.length > 0) for (const child of node.children) {
|
|
142
|
-
if (child.type !== "emphasis" && child.type !== "strong" && child.type !== "inlineCode" && child.type !== "delete" && child.type !== "text") return true;
|
|
143
|
-
if (hasContent(child)) return true;
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
};
|
|
147
|
-
const sameContainer = (left, right) => left.type === right.type && (left.type !== "mdxJsxTextElement" || left.name === right.name && JSON.stringify(left.attributes) === JSON.stringify(right.attributes));
|
|
148
|
-
const mergeTexts = (nodes) => {
|
|
149
|
-
const res = [];
|
|
150
|
-
for (const cur of nodes) {
|
|
151
|
-
const last = res.at(-1);
|
|
152
|
-
if (last && sameContainer(last, cur)) if (last.type === "text") last.value += cur.value;
|
|
153
|
-
else if (last.type === "inlineCode") last.value += cur.value;
|
|
154
|
-
else last.children = mergeTexts(last.children.concat(cur.children));
|
|
155
|
-
else {
|
|
156
|
-
if (cur.type === "text" && cur.value === "") continue;
|
|
157
|
-
res.push(cur);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return res;
|
|
161
|
-
};
|
|
162
|
-
//#endregion
|
|
163
|
-
export { convertTextsSerialize };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useEditorEditableElement, useSelectionView } from "../plite-react.js";
|
|
2
|
-
import { PlateTargetProvider, PlateViewFactsContext, getPlateTarget } from "../internal/plate-context.js";
|
|
3
|
-
import { useEditor, useEditorContainerRef } from "../stores/plate/useEditor.js";
|
|
4
|
-
import React from "react";
|
|
5
|
-
//#region src/react/components/EditorSelectionView.tsx
|
|
6
|
-
/**
|
|
7
|
-
* Give children the mounted view whose root holds the selection, such as a
|
|
8
|
-
* board note's view inside the page, as the editor they act on. Inside it
|
|
9
|
-
* `useEditor()`, `useEditableRef()`, `useEditorFocused()` and
|
|
10
|
-
* `useFocusedLast()` answer for that view. Children keep the current editor
|
|
11
|
-
* when the selection is in its root, when no view of the selection's root is
|
|
12
|
-
* mounted inside its Editable, or when several are and none is focused or was
|
|
13
|
-
* focused last.
|
|
14
|
-
*/
|
|
15
|
-
function EditorSelectionView({ children }) {
|
|
16
|
-
const editor = useEditor();
|
|
17
|
-
const containerRef = useEditorContainerRef();
|
|
18
|
-
const { readOnly } = React.useContext(PlateViewFactsContext);
|
|
19
|
-
const view = useSelectionView(editor);
|
|
20
|
-
const editable = useEditorEditableElement(view);
|
|
21
|
-
const mountedTarget = getPlateTarget(view);
|
|
22
|
-
const target = React.useMemo(() => mountedTarget ?? {
|
|
23
|
-
editor: view,
|
|
24
|
-
containerRef,
|
|
25
|
-
editableRef: { get current() {
|
|
26
|
-
return editable?.isConnected ? editable : null;
|
|
27
|
-
} }
|
|
28
|
-
}, [
|
|
29
|
-
containerRef,
|
|
30
|
-
editable,
|
|
31
|
-
mountedTarget,
|
|
32
|
-
view
|
|
33
|
-
]);
|
|
34
|
-
return /* @__PURE__ */ React.createElement(PlateTargetProvider, {
|
|
35
|
-
readOnly: view === editor ? readOnly : void 0,
|
|
36
|
-
target
|
|
37
|
-
}, children);
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
export { EditorSelectionView };
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { useEditorViewState } from "../../plite-react.js";
|
|
2
|
-
import { useEditableRef, useEditor, useModelEditor } from "../../stores/plate/useEditor.js";
|
|
3
|
-
import { useViewStore } from "../../stores/plate/useViewStore.js";
|
|
4
|
-
import { inkOutline } from "./inkPaint.internal.js";
|
|
5
|
-
import { InkPlugin } from "./InkPlugin.js";
|
|
6
|
-
import { INK_TOUCH_ACTION } from "./inkInput.internal.js";
|
|
7
|
-
import { attachInkCapture } from "./inkCapture.internal.js";
|
|
8
|
-
import { NOTHING_PLACED, createInkPlacer } from "./inkPlacement.internal.js";
|
|
9
|
-
import { observeInkLayout, stackInkSigns } from "./inkWatch.internal.js";
|
|
10
|
-
import * as React$1 from "react";
|
|
11
|
-
//#region src/react/features/ink/InkLayer.tsx
|
|
12
|
-
const samePlaced = (a, b) => a.bottom === b.bottom && a.ink.length === b.ink.length && a.signs.length === b.signs.length && a.ink.every(({ dx, dy, mark }, at) => mark === b.ink[at].mark && dx === b.ink[at].dx && dy === b.ink[at].dy) && a.signs.every(({ id, left, sign, top }, at) => id === b.signs[at].id && left === b.signs[at].left && top === b.signs[at].top && sign.marks.join(",") === b.signs[at].sign.marks.join(","));
|
|
13
|
-
/**
|
|
14
|
-
* The ink of a mounted Editable, drawn over it and its margins. Each mark
|
|
15
|
-
* draws on its words while they stand as they were when it was drawn, and
|
|
16
|
-
* otherwise shows as a `sign` in the Editable's padding where the mark's lines
|
|
17
|
-
* end, the left padding for a mark drawn in right-to-left text: at its
|
|
18
|
-
* block's top when the block's words changed or cannot be measured, or a
|
|
19
|
-
* margin note's margin is too narrow, and beside the nearest block left when a
|
|
20
|
-
* marked block is gone, or on the document's start when none is left. A place
|
|
21
|
-
* shows one sign per state, and a sign that would cover the one above it on its
|
|
22
|
-
* side of the Editable moves down below it. A press on a sign is the sign's
|
|
23
|
-
* own. The layer draws the marks of the blocks within a screen of the view,
|
|
24
|
-
* and every mark once the page is about to print. With the Draw tool on, a pen
|
|
25
|
-
* or the primary mouse button draws a mark, which saves when the contact ends
|
|
26
|
-
* and keeps the Editable's focus and caret. A finger still scrolls, and other
|
|
27
|
-
* mouse buttons keep their own behavior. The view's `hidden` hides ink and
|
|
28
|
-
* signs, and picked marks paint with a halo. Turning the view read-only turns
|
|
29
|
-
* the tool off. The layer fills the nearest positioned ancestor of the
|
|
30
|
-
* Editable, which should hold the Editable and its margins, and reaches at
|
|
31
|
-
* least to the Editable's bottom, so it covers the whole content of a
|
|
32
|
-
* scrolling ancestor. Render it after the content from the plugin's
|
|
33
|
-
* `wrapContent` slot, so it comes after the Editable and before every
|
|
34
|
-
* `afterEditable` slot. It sits at z-index 50, so a press on a control inside
|
|
35
|
-
* the content at that level or below, such as a block's drag handle, reaches
|
|
36
|
-
* the layer, while a toolbar or menu at that level from an `afterEditable`
|
|
37
|
-
* slot or a portal stays above it. When page chrome at or below that level,
|
|
38
|
-
* such as a sticky header, can sit over the editor, give the positioned
|
|
39
|
-
* ancestor its own stacking context, such as with `isolation: isolate`, so the
|
|
40
|
-
* layer stays below that chrome.
|
|
41
|
-
*/
|
|
42
|
-
function InkLayer({ sign: Sign }) {
|
|
43
|
-
const editableRef = useEditableRef();
|
|
44
|
-
const view = useEditor();
|
|
45
|
-
const editor = useModelEditor();
|
|
46
|
-
const tool = useViewStore(InkPlugin, (state) => state.tool);
|
|
47
|
-
const hidden = useViewStore(InkPlugin, (state_0) => state_0.hidden);
|
|
48
|
-
const picked = useViewStore(InkPlugin, (state_1) => state_1.picked);
|
|
49
|
-
const readOnly = useEditorViewState(view, (state_2) => state_2.isReadOnly());
|
|
50
|
-
const [layer, setLayer] = React$1.useState(null);
|
|
51
|
-
const [shown] = React$1.useState(() => {
|
|
52
|
-
let current = NOTHING_PLACED;
|
|
53
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
54
|
-
return {
|
|
55
|
-
get: () => current,
|
|
56
|
-
set: (next) => {
|
|
57
|
-
current = next;
|
|
58
|
-
for (const listener of listeners) listener();
|
|
59
|
-
},
|
|
60
|
-
subscribe: (listener_0) => {
|
|
61
|
-
listeners.add(listener_0);
|
|
62
|
-
return () => {
|
|
63
|
-
listeners.delete(listener_0);
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
const placed = React$1.useSyncExternalStore(shown.subscribe, shown.get, shown.get);
|
|
69
|
-
const [outlines] = React$1.useState(() => /* @__PURE__ */ new Map());
|
|
70
|
-
const preview = React$1.useRef(null);
|
|
71
|
-
const currentTool = React$1.useRef(tool);
|
|
72
|
-
const capture = React$1.useRef(null);
|
|
73
|
-
React$1.useLayoutEffect(() => {
|
|
74
|
-
currentTool.current = tool;
|
|
75
|
-
}, [tool]);
|
|
76
|
-
React$1.useEffect(() => {
|
|
77
|
-
if (!readOnly) return;
|
|
78
|
-
capture.current?.cancel();
|
|
79
|
-
view.plugin(InkPlugin).api.setTool(null);
|
|
80
|
-
}, [readOnly, view]);
|
|
81
|
-
React$1.useEffect(() => {
|
|
82
|
-
const editable = editableRef.current;
|
|
83
|
-
const path = preview.current;
|
|
84
|
-
if (!layer || !editable || !path) return void 0;
|
|
85
|
-
const attached = attachInkCapture({
|
|
86
|
-
editor,
|
|
87
|
-
layer,
|
|
88
|
-
preview: path,
|
|
89
|
-
tool: () => currentTool.current,
|
|
90
|
-
view
|
|
91
|
-
});
|
|
92
|
-
const placer = createInkPlacer({
|
|
93
|
-
editable,
|
|
94
|
-
layer,
|
|
95
|
-
view
|
|
96
|
-
});
|
|
97
|
-
const page = layer.ownerDocument;
|
|
98
|
-
const win = page.defaultView;
|
|
99
|
-
let frame = 0;
|
|
100
|
-
let kept = [];
|
|
101
|
-
const show = (next_0) => {
|
|
102
|
-
if (!samePlaced(next_0, shown.get())) shown.set(next_0);
|
|
103
|
-
};
|
|
104
|
-
const paint = () => {
|
|
105
|
-
frame = 0;
|
|
106
|
-
const marks = view.plugin(InkPlugin).read.marks();
|
|
107
|
-
if (marks !== kept) {
|
|
108
|
-
const saved = new Set(marks.map((mark) => mark.id));
|
|
109
|
-
kept = marks;
|
|
110
|
-
for (const id of outlines.keys()) if (!saved.has(id)) outlines.delete(id);
|
|
111
|
-
}
|
|
112
|
-
show(placer.place());
|
|
113
|
-
};
|
|
114
|
-
const schedule = () => {
|
|
115
|
-
frame ||= requestAnimationFrame(paint);
|
|
116
|
-
};
|
|
117
|
-
const onPrint = () => {
|
|
118
|
-
cancelAnimationFrame(frame);
|
|
119
|
-
frame = 0;
|
|
120
|
-
show(placer.placeEvery());
|
|
121
|
-
};
|
|
122
|
-
const unsubscribe = editor.subscribeCommit(({ changed }) => {
|
|
123
|
-
if (!changed.hasAny("document")) return;
|
|
124
|
-
if (changed.nodeKeysAll("presence").length > 0 || changed.hasAny("properties")) placer.nodesChanged();
|
|
125
|
-
schedule();
|
|
126
|
-
});
|
|
127
|
-
const stopLayout = observeInkLayout(editable, layer, (change, within) => {
|
|
128
|
-
placer.layoutChanged(change, within);
|
|
129
|
-
attached.layoutChanged(change);
|
|
130
|
-
schedule();
|
|
131
|
-
});
|
|
132
|
-
page.addEventListener("scroll", schedule, {
|
|
133
|
-
capture: true,
|
|
134
|
-
passive: true
|
|
135
|
-
});
|
|
136
|
-
win?.addEventListener("resize", schedule);
|
|
137
|
-
win?.addEventListener("beforeprint", onPrint);
|
|
138
|
-
capture.current = attached;
|
|
139
|
-
schedule();
|
|
140
|
-
return () => {
|
|
141
|
-
cancelAnimationFrame(frame);
|
|
142
|
-
unsubscribe();
|
|
143
|
-
stopLayout();
|
|
144
|
-
page.removeEventListener("scroll", schedule, { capture: true });
|
|
145
|
-
win?.removeEventListener("resize", schedule);
|
|
146
|
-
win?.removeEventListener("beforeprint", onPrint);
|
|
147
|
-
attached.detach();
|
|
148
|
-
capture.current = null;
|
|
149
|
-
};
|
|
150
|
-
}, [
|
|
151
|
-
editableRef,
|
|
152
|
-
editor,
|
|
153
|
-
layer,
|
|
154
|
-
outlines,
|
|
155
|
-
shown,
|
|
156
|
-
view
|
|
157
|
-
]);
|
|
158
|
-
React$1.useLayoutEffect(() => layer && !hidden ? stackInkSigns(layer, placed.signs) : void 0);
|
|
159
|
-
const outlineOf = (mark_0) => {
|
|
160
|
-
let outline = outlines.get(mark_0.id);
|
|
161
|
-
if (outline === void 0) {
|
|
162
|
-
outline = inkOutline(mark_0.samples, mark_0.brush);
|
|
163
|
-
outlines.set(mark_0.id, outline);
|
|
164
|
-
}
|
|
165
|
-
return outline;
|
|
166
|
-
};
|
|
167
|
-
return /* @__PURE__ */ React$1.createElement("div", {
|
|
168
|
-
"data-ink-layer": "",
|
|
169
|
-
ref: setLayer,
|
|
170
|
-
style: {
|
|
171
|
-
cursor: tool ? "crosshair" : void 0,
|
|
172
|
-
inset: 0,
|
|
173
|
-
minHeight: placed.bottom,
|
|
174
|
-
pointerEvents: tool && !readOnly ? "auto" : "none",
|
|
175
|
-
position: "absolute",
|
|
176
|
-
touchAction: INK_TOUCH_ACTION,
|
|
177
|
-
zIndex: 50
|
|
178
|
-
}
|
|
179
|
-
}, /* @__PURE__ */ React$1.createElement("svg", {
|
|
180
|
-
"aria-hidden": true,
|
|
181
|
-
style: {
|
|
182
|
-
height: "100%",
|
|
183
|
-
left: 0,
|
|
184
|
-
overflow: "visible",
|
|
185
|
-
pointerEvents: "none",
|
|
186
|
-
position: "absolute",
|
|
187
|
-
top: 0,
|
|
188
|
-
width: "100%"
|
|
189
|
-
}
|
|
190
|
-
}, !hidden && placed.ink.map(({ dx, dy, mark: mark_1 }) => {
|
|
191
|
-
const halo = picked.includes(mark_1.id);
|
|
192
|
-
return /* @__PURE__ */ React$1.createElement("path", {
|
|
193
|
-
d: outlineOf(mark_1),
|
|
194
|
-
"data-ink-mark": mark_1.id,
|
|
195
|
-
"data-picked": halo || void 0,
|
|
196
|
-
fill: mark_1.brush.color,
|
|
197
|
-
key: mark_1.id,
|
|
198
|
-
opacity: mark_1.brush.opacity,
|
|
199
|
-
stroke: halo ? mark_1.brush.color : void 0,
|
|
200
|
-
strokeOpacity: halo ? .35 : void 0,
|
|
201
|
-
strokeWidth: halo ? mark_1.brush.size * 2 : void 0,
|
|
202
|
-
transform: `translate(${dx} ${dy})`
|
|
203
|
-
});
|
|
204
|
-
}), /* @__PURE__ */ React$1.createElement("path", {
|
|
205
|
-
"data-ink-stroke": "",
|
|
206
|
-
ref: preview
|
|
207
|
-
})), !hidden && placed.signs.map(({ id: id_0, left, sign }) => /* @__PURE__ */ React$1.createElement("div", {
|
|
208
|
-
"data-ink-sign": sign.state,
|
|
209
|
-
key: id_0,
|
|
210
|
-
style: {
|
|
211
|
-
left,
|
|
212
|
-
pointerEvents: "auto",
|
|
213
|
-
position: "absolute"
|
|
214
|
-
}
|
|
215
|
-
}, /* @__PURE__ */ React$1.createElement(Sign, { sign }))));
|
|
216
|
-
}
|
|
217
|
-
//#endregion
|
|
218
|
-
export { InkLayer };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
//#region src/react/internal/createPlateTargetScope.ts
|
|
2
|
-
function createPlateTargetScope(usedAt) {
|
|
3
|
-
const targets = /* @__PURE__ */ new Set();
|
|
4
|
-
const primary = /* @__PURE__ */ new Set();
|
|
5
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
6
|
-
let selected = null;
|
|
7
|
-
const select = (next) => {
|
|
8
|
-
if (next === selected) return;
|
|
9
|
-
selected = next;
|
|
10
|
-
listeners.forEach((listener) => listener());
|
|
11
|
-
};
|
|
12
|
-
const firstPrimary = () => primary.values().next().value ?? null;
|
|
13
|
-
const findLatestUsed = () => {
|
|
14
|
-
let latest = null;
|
|
15
|
-
let latestStamp = 0;
|
|
16
|
-
for (const target of targets) {
|
|
17
|
-
const stamp = usedAt(target);
|
|
18
|
-
if (stamp > latestStamp) {
|
|
19
|
-
latest = target;
|
|
20
|
-
latestStamp = stamp;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return latest;
|
|
24
|
-
};
|
|
25
|
-
const latestAt = () => selected ? usedAt(selected) : 0;
|
|
26
|
-
return {
|
|
27
|
-
getSnapshot: () => selected,
|
|
28
|
-
register(target, isPrimary) {
|
|
29
|
-
targets.add(target);
|
|
30
|
-
if (isPrimary) primary.add(target);
|
|
31
|
-
if (usedAt(target) > latestAt()) select(target);
|
|
32
|
-
else if (latestAt() === 0) select(firstPrimary());
|
|
33
|
-
let registered = true;
|
|
34
|
-
return () => {
|
|
35
|
-
if (!registered) return;
|
|
36
|
-
registered = false;
|
|
37
|
-
targets.delete(target);
|
|
38
|
-
primary.delete(target);
|
|
39
|
-
if (selected !== target) return;
|
|
40
|
-
const nothingUsed = latestAt() === 0;
|
|
41
|
-
select(nothingUsed ? firstPrimary() : findLatestUsed() ?? firstPrimary());
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
setPrimary(target, isPrimary) {
|
|
45
|
-
if (!targets.has(target)) return;
|
|
46
|
-
if (isPrimary) primary.add(target);
|
|
47
|
-
else primary.delete(target);
|
|
48
|
-
if (latestAt() === 0) select(firstPrimary());
|
|
49
|
-
},
|
|
50
|
-
used(target) {
|
|
51
|
-
if (targets.has(target) && usedAt(target) >= latestAt()) select(target);
|
|
52
|
-
},
|
|
53
|
-
subscribe: (listener) => {
|
|
54
|
-
listeners.add(listener);
|
|
55
|
-
return () => {
|
|
56
|
-
listeners.delete(listener);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { createPlateTargetScope };
|