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
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "../../../
|
|
6
|
-
import
|
|
1
|
+
import { $a as Path, Ds as SchemaContentDefault, Ht as EditorJsonValue, Ls as SchemaContentRule, iu as TxDeclaredMethod, pa as NodeEntry, qo as Point, ss as PropertyStringDescriptor, v as BaseElement } from "../../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { _t as NodeInsertOptions } from "../../../core-BqR-fEDp.js";
|
|
4
|
+
import { At as Plugin, xt as InternalPluginAuthorExtension } from "../../../index-DPowErHa.js";
|
|
5
|
+
import { t as ComboboxEditor } from "../../../combobox-Dr0OYZIE.js";
|
|
6
|
+
import "../../../index-BTx5oK7k.js";
|
|
7
|
+
import { i as FootnoteAnchor, r as CreateFootnoteDefinitionOptions } from "../../../index-BsV2McRr.js";
|
|
7
8
|
declare const FootnoteDefinitionPlugin: Plugin<Readonly<{
|
|
8
9
|
readonly __pluginWritableProperties: Readonly<{
|
|
9
10
|
descriptor: PropertyStringDescriptor<{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { iu as TxDeclaredMethod, ps as Range, s as Anchor } from "../../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { An as CapturedFormat, Co as PluginReference, _ as BasePlugin, xo as PluginDependency } from "../../../core-BqR-fEDp.js";
|
|
4
|
+
import { At as Plugin, xt as InternalPluginAuthorExtension } from "../../../index-DPowErHa.js";
|
|
4
5
|
/**
|
|
5
6
|
* One view's format painter. An armed brush always holds the look it copied
|
|
6
7
|
* and an anchor on the range it copied from; `once` puts the brush down after
|
|
@@ -0,0 +1,313 @@
|
|
|
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 { INK_TOUCH_ACTION } from "./inkInput.internal.js";
|
|
5
|
+
import { createInkSurface } from "./inkPaint.internal.js";
|
|
6
|
+
import { observeInkLayout, stackInkSigns } from "./inkWatch.internal.js";
|
|
7
|
+
import { attachInkCapture } from "./inkCapture.internal.js";
|
|
8
|
+
import { InkPlugin } from "./InkPlugin.js";
|
|
9
|
+
import { NOTHING_PLACED, createInkPlacer } from "./inkPlacement.internal.js";
|
|
10
|
+
import * as React$1 from "react";
|
|
11
|
+
import { c } from "react/compiler-runtime";
|
|
12
|
+
//#region src/react/features/ink/InkContent.tsx
|
|
13
|
+
const ARRIVE_MS = 50;
|
|
14
|
+
const SETTLE_MS = 250;
|
|
15
|
+
const SLICE_MS = 3;
|
|
16
|
+
const whenIdle = (run, timeoutMs) => {
|
|
17
|
+
if (typeof requestIdleCallback === "function") {
|
|
18
|
+
const id = requestIdleCallback(run, timeoutMs === void 0 ? void 0 : { timeout: Math.max(1, timeoutMs) });
|
|
19
|
+
return () => cancelIdleCallback(id);
|
|
20
|
+
}
|
|
21
|
+
const id = setTimeout(run, 0);
|
|
22
|
+
return () => clearTimeout(id);
|
|
23
|
+
};
|
|
24
|
+
const sameSigns = (a, b) => a.bottom === b.bottom && a.signs.length === b.signs.length && 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 === b.signs[at].sign.marks || sign.marks.length === b.signs[at].sign.marks.length && sign.marks.every((mark, n) => mark === b.signs[at].sign.marks[n])));
|
|
25
|
+
const firstElementAfter = (element) => {
|
|
26
|
+
for (let at = element; at; at = at.parentElement) if (at.nextElementSibling) return at.nextElementSibling;
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The ink plugin's `wrapContent` slot: the slot's content, then a layer with
|
|
31
|
+
* the ink of its Editable, drawn over it and its margins. Each mark
|
|
32
|
+
* draws on its words while they stand as they were when it was drawn, and
|
|
33
|
+
* otherwise shows as a `sign` in the Editable's padding where the mark's lines
|
|
34
|
+
* end, the left padding for a mark drawn in right-to-left text: at its
|
|
35
|
+
* block's top when the block's words changed or cannot be measured, or a
|
|
36
|
+
* margin note's margin is too narrow, and beside the nearest block left when a
|
|
37
|
+
* marked block is gone, or on the document's start when none is left. A place
|
|
38
|
+
* shows one sign per state, and a sign that would cover the one above it on its
|
|
39
|
+
* side of the Editable moves down below it. A press on a sign is the sign's
|
|
40
|
+
* own. The layer draws the marks of the blocks within a screen of the view,
|
|
41
|
+
* and every mark once the page is about to print. With the Draw tool on, a pen
|
|
42
|
+
* or the primary mouse button draws a mark, which saves when the contact ends
|
|
43
|
+
* and keeps the Editable's focus and caret. A finger still scrolls, and other
|
|
44
|
+
* mouse buttons keep their own behavior. The view's `hidden` hides ink and
|
|
45
|
+
* signs, and picked marks paint with a halo. Turning the view read-only turns
|
|
46
|
+
* the tool off. The layer fills the nearest positioned ancestor of the
|
|
47
|
+
* Editable, which should hold the Editable and its margins, and reaches at
|
|
48
|
+
* least to the Editable's bottom, so it covers the whole content of a
|
|
49
|
+
* scrolling ancestor. Pass the slot's props on with a `sign`, as in
|
|
50
|
+
* `wrapContent: (props) => <InkContent {...props} sign={Sign} />`, so the
|
|
51
|
+
* layer comes right after the Editable and before every `afterEditable` slot.
|
|
52
|
+
* In development, the mount throws unless the layer is the first element after
|
|
53
|
+
* the Editable, so a mount from `wrapRoot`, `beforeEditable` or
|
|
54
|
+
* `afterEditable` that puts the layer elsewhere, such as after a toolbar,
|
|
55
|
+
* fails. The layer sits at z-index 50, so a press on a control inside the
|
|
56
|
+
* content at that level or below, such as a block's drag handle, reaches the
|
|
57
|
+
* layer, while a toolbar or menu at that level from an `afterEditable` slot or
|
|
58
|
+
* a portal stays above it. When page chrome at or below that level, such as a
|
|
59
|
+
* sticky header, can sit over the editor, give the positioned ancestor its own
|
|
60
|
+
* stacking context, such as with `isolation: isolate`, so the layer stays
|
|
61
|
+
* below that chrome.
|
|
62
|
+
*/
|
|
63
|
+
function InkContent(t0) {
|
|
64
|
+
const $ = c(5);
|
|
65
|
+
const { children, sign } = t0;
|
|
66
|
+
let t1;
|
|
67
|
+
if ($[0] !== sign) {
|
|
68
|
+
t1 = /* @__PURE__ */ React$1.createElement(InkLayer, { sign });
|
|
69
|
+
$[0] = sign;
|
|
70
|
+
$[1] = t1;
|
|
71
|
+
} else t1 = $[1];
|
|
72
|
+
let t2;
|
|
73
|
+
if ($[2] !== children || $[3] !== t1) {
|
|
74
|
+
t2 = /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, children, t1);
|
|
75
|
+
$[2] = children;
|
|
76
|
+
$[3] = t1;
|
|
77
|
+
$[4] = t2;
|
|
78
|
+
} else t2 = $[4];
|
|
79
|
+
return t2;
|
|
80
|
+
}
|
|
81
|
+
function InkLayer({ sign: Sign }) {
|
|
82
|
+
const editableRef = useEditableRef();
|
|
83
|
+
const view = useEditor();
|
|
84
|
+
const editor = useModelEditor();
|
|
85
|
+
const tool = useViewStore(InkPlugin, (state) => state.tool);
|
|
86
|
+
const hidden = useViewStore(InkPlugin, (state_0) => state_0.hidden);
|
|
87
|
+
const picked = useViewStore(InkPlugin, (state_1) => state_1.picked);
|
|
88
|
+
const readOnly = useEditorViewState(view, (state_2) => state_2.isReadOnly());
|
|
89
|
+
const [layer, setLayer] = React$1.useState(null);
|
|
90
|
+
const [surface, setSurface] = React$1.useState(null);
|
|
91
|
+
const mountInk = React$1.useCallback((into) => {
|
|
92
|
+
setSurface(into && createInkSurface(into));
|
|
93
|
+
}, []);
|
|
94
|
+
const [shown] = React$1.useState(() => {
|
|
95
|
+
let current = NOTHING_PLACED;
|
|
96
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
97
|
+
return {
|
|
98
|
+
get: () => current,
|
|
99
|
+
set: (next) => {
|
|
100
|
+
current = next;
|
|
101
|
+
for (const listener of listeners) listener();
|
|
102
|
+
},
|
|
103
|
+
subscribe: (listener_0) => {
|
|
104
|
+
listeners.add(listener_0);
|
|
105
|
+
return () => {
|
|
106
|
+
listeners.delete(listener_0);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
const placed = React$1.useSyncExternalStore(shown.subscribe, shown.get, shown.get);
|
|
112
|
+
const preview = React$1.useRef(null);
|
|
113
|
+
const currentTool = React$1.useRef(tool);
|
|
114
|
+
const capture = React$1.useRef(null);
|
|
115
|
+
React$1.useLayoutEffect(() => {
|
|
116
|
+
currentTool.current = tool;
|
|
117
|
+
}, [tool]);
|
|
118
|
+
React$1.useEffect(() => {
|
|
119
|
+
if (!readOnly) return;
|
|
120
|
+
capture.current?.cancel();
|
|
121
|
+
view.plugin(InkPlugin).api.setTool(null);
|
|
122
|
+
}, [readOnly, view]);
|
|
123
|
+
React$1.useEffect(() => {
|
|
124
|
+
const editable = editableRef.current;
|
|
125
|
+
const path = preview.current;
|
|
126
|
+
if (!layer || !editable || !path || !surface) return void 0;
|
|
127
|
+
if (process.env.NODE_ENV !== "production" && firstElementAfter(editable) !== layer) throw new Error("InkContent must be the `wrapContent` slot of its plugin, so its ink layer is the first element after the Editable. Mounted elsewhere, the layer can cover what comes after the Editable, such as a toolbar.");
|
|
128
|
+
const attached = attachInkCapture({
|
|
129
|
+
editor,
|
|
130
|
+
layer,
|
|
131
|
+
preview: path,
|
|
132
|
+
tool: () => currentTool.current,
|
|
133
|
+
view
|
|
134
|
+
});
|
|
135
|
+
const placer = createInkPlacer({
|
|
136
|
+
editable,
|
|
137
|
+
layer,
|
|
138
|
+
view
|
|
139
|
+
});
|
|
140
|
+
const page = layer.ownerDocument;
|
|
141
|
+
const win = page.defaultView;
|
|
142
|
+
let frame = 0;
|
|
143
|
+
let moveFrame = 0;
|
|
144
|
+
let settle;
|
|
145
|
+
let stopSlice;
|
|
146
|
+
let audit;
|
|
147
|
+
let painted = NOTHING_PLACED;
|
|
148
|
+
let scrollStartedAt;
|
|
149
|
+
let stopArrival;
|
|
150
|
+
const show = (next_0) => {
|
|
151
|
+
const { bottom, ink, signs } = next_0;
|
|
152
|
+
painted = next_0;
|
|
153
|
+
surface.paint(ink);
|
|
154
|
+
if (!sameSigns(next_0, shown.get())) shown.set({
|
|
155
|
+
bottom,
|
|
156
|
+
signs
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const stopArriving = () => {
|
|
160
|
+
stopArrival?.();
|
|
161
|
+
stopArrival = void 0;
|
|
162
|
+
scrollStartedAt = void 0;
|
|
163
|
+
};
|
|
164
|
+
const paint = () => {
|
|
165
|
+
frame = 0;
|
|
166
|
+
show(placer.place());
|
|
167
|
+
};
|
|
168
|
+
const arrive = () => {
|
|
169
|
+
const start = performance.now();
|
|
170
|
+
const { placed: next_1, undecided } = placer.arrive(painted, (onScreen) => {
|
|
171
|
+
const now = performance.now();
|
|
172
|
+
const sliceSpent = now - start >= SLICE_MS;
|
|
173
|
+
const screenOverdue = onScreen && scrollStartedAt !== void 0 && now >= scrollStartedAt + ARRIVE_MS;
|
|
174
|
+
return sliceSpent && !screenOverdue;
|
|
175
|
+
});
|
|
176
|
+
show(next_1);
|
|
177
|
+
if (undecided !== "screen") scrollStartedAt = void 0;
|
|
178
|
+
stopArrival = undecided ? whenIdle(arrive, scrollStartedAt === void 0 ? void 0 : scrollStartedAt + ARRIVE_MS - performance.now()) : void 0;
|
|
179
|
+
};
|
|
180
|
+
const move = () => {
|
|
181
|
+
const ink_0 = placer.follow(painted);
|
|
182
|
+
moveFrame = 0;
|
|
183
|
+
if (ink_0 !== painted.ink) surface.paint(ink_0);
|
|
184
|
+
};
|
|
185
|
+
const stopAudit = () => {
|
|
186
|
+
clearTimeout(settle);
|
|
187
|
+
stopSlice?.();
|
|
188
|
+
stopSlice = void 0;
|
|
189
|
+
audit = void 0;
|
|
190
|
+
};
|
|
191
|
+
const slice = () => {
|
|
192
|
+
const start_0 = performance.now();
|
|
193
|
+
audit ??= placer.audit();
|
|
194
|
+
if (audit(() => performance.now() - start_0 >= SLICE_MS)) {
|
|
195
|
+
stopSlice = whenIdle(slice);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
stopAudit();
|
|
199
|
+
show(placer.place());
|
|
200
|
+
};
|
|
201
|
+
const settleLater = () => {
|
|
202
|
+
stopAudit();
|
|
203
|
+
settle = setTimeout(() => {
|
|
204
|
+
stopSlice = whenIdle(slice);
|
|
205
|
+
}, SETTLE_MS);
|
|
206
|
+
};
|
|
207
|
+
const schedule = () => {
|
|
208
|
+
frame ||= requestAnimationFrame(paint);
|
|
209
|
+
settleLater();
|
|
210
|
+
};
|
|
211
|
+
const onScroll = ({ target }) => {
|
|
212
|
+
if (target instanceof Element && target !== editable && editable.contains(target)) return;
|
|
213
|
+
if (scrollStartedAt === void 0) {
|
|
214
|
+
scrollStartedAt = performance.now();
|
|
215
|
+
stopArrival?.();
|
|
216
|
+
stopArrival = whenIdle(arrive, ARRIVE_MS);
|
|
217
|
+
}
|
|
218
|
+
moveFrame ||= requestAnimationFrame(move);
|
|
219
|
+
settleLater();
|
|
220
|
+
};
|
|
221
|
+
const onPrint = () => {
|
|
222
|
+
cancelAnimationFrame(frame);
|
|
223
|
+
cancelAnimationFrame(moveFrame);
|
|
224
|
+
frame = 0;
|
|
225
|
+
moveFrame = 0;
|
|
226
|
+
stopAudit();
|
|
227
|
+
stopArriving();
|
|
228
|
+
show(placer.placeEvery());
|
|
229
|
+
};
|
|
230
|
+
const unsubscribe = editor.subscribeCommit(({ changed }) => {
|
|
231
|
+
if (!changed.hasAny("document")) return;
|
|
232
|
+
schedule();
|
|
233
|
+
});
|
|
234
|
+
const stopLayout = observeInkLayout(editable, layer, (change, within) => {
|
|
235
|
+
placer.layoutChanged(change, within);
|
|
236
|
+
attached.layoutChanged(change);
|
|
237
|
+
if (change !== "scroll") schedule();
|
|
238
|
+
});
|
|
239
|
+
page.addEventListener("scroll", onScroll, {
|
|
240
|
+
capture: true,
|
|
241
|
+
passive: true
|
|
242
|
+
});
|
|
243
|
+
win?.addEventListener("resize", schedule);
|
|
244
|
+
win?.addEventListener("beforeprint", onPrint);
|
|
245
|
+
capture.current = attached;
|
|
246
|
+
schedule();
|
|
247
|
+
return () => {
|
|
248
|
+
cancelAnimationFrame(frame);
|
|
249
|
+
cancelAnimationFrame(moveFrame);
|
|
250
|
+
stopAudit();
|
|
251
|
+
stopArriving();
|
|
252
|
+
unsubscribe();
|
|
253
|
+
stopLayout();
|
|
254
|
+
page.removeEventListener("scroll", onScroll, { capture: true });
|
|
255
|
+
win?.removeEventListener("resize", schedule);
|
|
256
|
+
win?.removeEventListener("beforeprint", onPrint);
|
|
257
|
+
attached.detach();
|
|
258
|
+
capture.current = null;
|
|
259
|
+
};
|
|
260
|
+
}, [
|
|
261
|
+
editableRef,
|
|
262
|
+
editor,
|
|
263
|
+
layer,
|
|
264
|
+
shown,
|
|
265
|
+
surface,
|
|
266
|
+
view
|
|
267
|
+
]);
|
|
268
|
+
React$1.useLayoutEffect(() => {
|
|
269
|
+
surface?.setLook(hidden, picked);
|
|
270
|
+
}, [
|
|
271
|
+
hidden,
|
|
272
|
+
picked,
|
|
273
|
+
surface
|
|
274
|
+
]);
|
|
275
|
+
React$1.useLayoutEffect(() => layer && !hidden ? stackInkSigns(layer, placed.signs) : void 0);
|
|
276
|
+
return /* @__PURE__ */ React$1.createElement("div", {
|
|
277
|
+
"data-ink-layer": "",
|
|
278
|
+
ref: setLayer,
|
|
279
|
+
style: {
|
|
280
|
+
cursor: tool ? "crosshair" : void 0,
|
|
281
|
+
inset: 0,
|
|
282
|
+
minHeight: placed.bottom,
|
|
283
|
+
pointerEvents: tool && !readOnly ? "auto" : "none",
|
|
284
|
+
position: "absolute",
|
|
285
|
+
touchAction: INK_TOUCH_ACTION,
|
|
286
|
+
zIndex: 50
|
|
287
|
+
}
|
|
288
|
+
}, /* @__PURE__ */ React$1.createElement("svg", {
|
|
289
|
+
"aria-hidden": true,
|
|
290
|
+
style: {
|
|
291
|
+
height: "100%",
|
|
292
|
+
left: 0,
|
|
293
|
+
overflow: "visible",
|
|
294
|
+
pointerEvents: "none",
|
|
295
|
+
position: "absolute",
|
|
296
|
+
top: 0,
|
|
297
|
+
width: "100%"
|
|
298
|
+
}
|
|
299
|
+
}, /* @__PURE__ */ React$1.createElement("g", { ref: mountInk }), /* @__PURE__ */ React$1.createElement("path", {
|
|
300
|
+
"data-ink-stroke": "",
|
|
301
|
+
ref: preview
|
|
302
|
+
})), !hidden && placed.signs.map(({ id, left, sign }) => /* @__PURE__ */ React$1.createElement("div", {
|
|
303
|
+
"data-ink-sign": sign.state,
|
|
304
|
+
key: id,
|
|
305
|
+
style: {
|
|
306
|
+
left,
|
|
307
|
+
pointerEvents: "auto",
|
|
308
|
+
position: "absolute"
|
|
309
|
+
}
|
|
310
|
+
}, /* @__PURE__ */ React$1.createElement(Sign, { sign }))));
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
313
|
+
export { InkContent };
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import React from "react";
|
|
7
|
-
|
|
8
|
-
* The words the marks `marks` names were drawn on, as plain text laid out by
|
|
9
|
-
* their saved lines, with each mark's ink over them. Marks drawn on the
|
|
10
|
-
* same blocks share one copy, and the copy's box takes in their ink, so a
|
|
11
|
-
* note drawn in the margin shows beside its words. A mark no longer saved
|
|
12
|
-
* shows nothing.
|
|
13
|
-
*/
|
|
14
|
-
declare function InkCopyView({ marks }: {
|
|
15
|
-
marks: readonly string[];
|
|
16
|
-
}): React.JSX.Element;
|
|
1
|
+
import { Ca as NodeKey, iu as TxDeclaredMethod, oo as Plugin, qs as SchemaElementPropertyDefinition, ss as PropertyStringDescriptor } from "../../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { Co as PluginReference, _ as BasePlugin, aa as BasePluginDependencyReferenceFor, xo as PluginDependency } from "../../../core-BqR-fEDp.js";
|
|
4
|
+
import { Xt as WrapContentProps, cn as InternalReactPluginAdapterResult, jt as PluginApiContext } from "../../../index-DPowErHa.js";
|
|
5
|
+
import { a as InkCopyPlace, c as InkMargin, d as InkMarkInput, h as InkTool, o as InkDirection, p as InkSample, r as InkBrush, s as InkLine, u as InkMarkBlock } from "../../../index-DwWQVwQt.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import React$1 from "react";
|
|
17
8
|
/**
|
|
18
9
|
* Marks whose ink is not on the page, shown as one sign: `changed` when their
|
|
19
10
|
* words changed or moved, `deleted` when a marked block is gone, and `narrow`
|
|
@@ -24,7 +15,8 @@ type InkSign = Readonly<{
|
|
|
24
15
|
state: 'changed' | 'deleted' | 'narrow';
|
|
25
16
|
}>;
|
|
26
17
|
/**
|
|
27
|
-
* The ink
|
|
18
|
+
* The ink plugin's `wrapContent` slot: the slot's content, then a layer with
|
|
19
|
+
* the ink of its Editable, drawn over it and its margins. Each mark
|
|
28
20
|
* draws on its words while they stand as they were when it was drawn, and
|
|
29
21
|
* otherwise shows as a `sign` in the Editable's padding where the mark's lines
|
|
30
22
|
* end, the left padding for a mark drawn in right-to-left text: at its
|
|
@@ -42,20 +34,34 @@ type InkSign = Readonly<{
|
|
|
42
34
|
* the tool off. The layer fills the nearest positioned ancestor of the
|
|
43
35
|
* Editable, which should hold the Editable and its margins, and reaches at
|
|
44
36
|
* least to the Editable's bottom, so it covers the whole content of a
|
|
45
|
-
* scrolling ancestor.
|
|
46
|
-
* `wrapContent
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* the
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* layer
|
|
37
|
+
* scrolling ancestor. Pass the slot's props on with a `sign`, as in
|
|
38
|
+
* `wrapContent: (props) => <InkContent {...props} sign={Sign} />`, so the
|
|
39
|
+
* layer comes right after the Editable and before every `afterEditable` slot.
|
|
40
|
+
* In development, the mount throws unless the layer is the first element after
|
|
41
|
+
* the Editable, so a mount from `wrapRoot`, `beforeEditable` or
|
|
42
|
+
* `afterEditable` that puts the layer elsewhere, such as after a toolbar,
|
|
43
|
+
* fails. The layer sits at z-index 50, so a press on a control inside the
|
|
44
|
+
* content at that level or below, such as a block's drag handle, reaches the
|
|
45
|
+
* layer, while a toolbar or menu at that level from an `afterEditable` slot or
|
|
46
|
+
* a portal stays above it. When page chrome at or below that level, such as a
|
|
47
|
+
* sticky header, can sit over the editor, give the positioned ancestor its own
|
|
48
|
+
* stacking context, such as with `isolation: isolate`, so the layer stays
|
|
49
|
+
* below that chrome.
|
|
54
50
|
*/
|
|
55
|
-
declare function
|
|
56
|
-
sign: React
|
|
51
|
+
declare function InkContent({ children, sign }: WrapContentProps & {
|
|
52
|
+
sign: React.ComponentType<{
|
|
57
53
|
sign: InkSign;
|
|
58
54
|
}>;
|
|
55
|
+
}): React.JSX.Element;
|
|
56
|
+
/**
|
|
57
|
+
* The words the marks `marks` names were drawn on, as plain text laid out by
|
|
58
|
+
* their saved lines, with each mark's ink over them. Marks drawn on the
|
|
59
|
+
* same blocks share one copy, and the copy's box takes in their ink, so a
|
|
60
|
+
* note drawn in the margin shows beside its words. A mark no longer saved
|
|
61
|
+
* shows nothing.
|
|
62
|
+
*/
|
|
63
|
+
declare function InkCopyView({ marks }: {
|
|
64
|
+
marks: readonly string[];
|
|
59
65
|
}): React$1.JSX.Element;
|
|
60
66
|
/**
|
|
61
67
|
* Pen markup on a document's text, with each view's Draw tool. A view keeps
|
|
@@ -72,6 +78,11 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
72
78
|
readonly records: {
|
|
73
79
|
readonly "ink-copies": {
|
|
74
80
|
readonly history: "retain";
|
|
81
|
+
readonly namedBy: {
|
|
82
|
+
keep: (id: string) => boolean;
|
|
83
|
+
names: ({ copies }: Readonly<Record<string, unknown>>) => string[] | null;
|
|
84
|
+
set: "ink-marks";
|
|
85
|
+
};
|
|
75
86
|
};
|
|
76
87
|
readonly "ink-gone": {
|
|
77
88
|
readonly history: "retain";
|
|
@@ -99,7 +110,6 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
99
110
|
value: string;
|
|
100
111
|
}>;
|
|
101
112
|
}> & Readonly<Record<"read", {
|
|
102
|
-
readonly entry: (id: string) => ElementIdEntry | undefined;
|
|
103
113
|
readonly id: (key: NodeKey) => string | undefined;
|
|
104
114
|
}>> & Readonly<Record<"schema", {
|
|
105
115
|
readonly properties: {
|
|
@@ -108,6 +118,9 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
108
118
|
}>, Readonly<{
|
|
109
119
|
group: "element";
|
|
110
120
|
kind: "group";
|
|
121
|
+
}>, Readonly<{
|
|
122
|
+
key: string;
|
|
123
|
+
map: (value: string, renamed: (name: string) => string | undefined) => string;
|
|
111
124
|
}>>;
|
|
112
125
|
};
|
|
113
126
|
}>> & Readonly<Record<never, never>>> & Pick<BasePlugin<Readonly<{
|
|
@@ -129,6 +142,9 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
129
142
|
}>, Readonly<{
|
|
130
143
|
group: "element";
|
|
131
144
|
kind: "group";
|
|
145
|
+
}>, Readonly<{
|
|
146
|
+
key: string;
|
|
147
|
+
map: (value: string, renamed: (name: string) => string | undefined) => string;
|
|
132
148
|
}>>;
|
|
133
149
|
};
|
|
134
150
|
};
|
|
@@ -138,7 +154,6 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
138
154
|
readonly generateId: () => string;
|
|
139
155
|
};
|
|
140
156
|
readonly read: {
|
|
141
|
-
readonly entry: (id: string) => ElementIdEntry | undefined;
|
|
142
157
|
readonly id: (key: NodeKey) => string | undefined;
|
|
143
158
|
};
|
|
144
159
|
}>> & Readonly<Record<never, never>>, "~schema.plugins">];
|
|
@@ -197,6 +212,11 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
197
212
|
readonly records: {
|
|
198
213
|
readonly "ink-copies": {
|
|
199
214
|
readonly history: "retain";
|
|
215
|
+
readonly namedBy: {
|
|
216
|
+
keep: (id: string) => boolean;
|
|
217
|
+
names: ({ copies }: Readonly<Record<string, unknown>>) => string[] | null;
|
|
218
|
+
set: "ink-marks";
|
|
219
|
+
};
|
|
200
220
|
};
|
|
201
221
|
readonly "ink-gone": {
|
|
202
222
|
readonly history: "retain";
|
|
@@ -224,7 +244,6 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
224
244
|
value: string;
|
|
225
245
|
}>;
|
|
226
246
|
}> & Readonly<Record<"read", {
|
|
227
|
-
readonly entry: (id: string) => ElementIdEntry | undefined;
|
|
228
247
|
readonly id: (key: NodeKey) => string | undefined;
|
|
229
248
|
}>> & Readonly<Record<"schema", {
|
|
230
249
|
readonly properties: {
|
|
@@ -233,6 +252,9 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
233
252
|
}>, Readonly<{
|
|
234
253
|
group: "element";
|
|
235
254
|
kind: "group";
|
|
255
|
+
}>, Readonly<{
|
|
256
|
+
key: string;
|
|
257
|
+
map: (value: string, renamed: (name: string) => string | undefined) => string;
|
|
236
258
|
}>>;
|
|
237
259
|
};
|
|
238
260
|
}>> & Readonly<Record<never, never>>> & Pick<BasePlugin<Readonly<{
|
|
@@ -254,6 +276,9 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
254
276
|
}>, Readonly<{
|
|
255
277
|
group: "element";
|
|
256
278
|
kind: "group";
|
|
279
|
+
}>, Readonly<{
|
|
280
|
+
key: string;
|
|
281
|
+
map: (value: string, renamed: (name: string) => string | undefined) => string;
|
|
257
282
|
}>>;
|
|
258
283
|
};
|
|
259
284
|
};
|
|
@@ -263,7 +288,6 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
263
288
|
readonly generateId: () => string;
|
|
264
289
|
};
|
|
265
290
|
readonly read: {
|
|
266
|
-
readonly entry: (id: string) => ElementIdEntry | undefined;
|
|
267
291
|
readonly id: (key: NodeKey) => string | undefined;
|
|
268
292
|
};
|
|
269
293
|
}>> & Readonly<Record<never, never>>, "~schema.plugins">];
|
|
@@ -323,4 +347,4 @@ declare const InkPlugin: InternalReactPluginAdapterResult<BasePlugin<Readonly<{
|
|
|
323
347
|
setTool: (tool: InkTool | null) => boolean;
|
|
324
348
|
};
|
|
325
349
|
}>;
|
|
326
|
-
export {
|
|
350
|
+
export { InkContent, InkCopyView, InkPlugin, InkSign };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { InkPlugin } from "./InkPlugin.js";
|
|
2
|
+
import { InkContent } from "./InkContent.js";
|
|
2
3
|
import { InkCopyView } from "./InkCopyView.js";
|
|
3
|
-
|
|
4
|
-
export { InkCopyView, InkLayer, InkPlugin };
|
|
4
|
+
export { InkContent, InkCopyView, InkPlugin };
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { PathApi, scheduleAfterCommitNotification } from "../../../facade.js";
|
|
2
2
|
import { HistoryPlugin } from "../../../lib/plugins/HistoryPlugin.js";
|
|
3
|
+
import { roundPixel, roundSample } from "../../../features/ink/lib/inkCodec.internal.js";
|
|
4
|
+
import { holdInkBlock } from "../../../features/ink/lib/inkGone.internal.js";
|
|
3
5
|
import { footprintEnters, gapAround, inkTouchedWords, inkWords } from "../../../features/ink/lib/inkMatch.internal.js";
|
|
4
6
|
import { BaseInkPlugin } from "../../../features/ink/lib/BaseInkPlugin.js";
|
|
5
|
-
import { inkOutline } from "./inkPaint.internal.js";
|
|
6
7
|
import { inkDraws, inkPressure, inkSamplesOf } from "./inkInput.internal.js";
|
|
7
8
|
import { inkBoxOf, inkTextBlocks, inkWordBoxes, measureInkBlock, sameInkBox, sameInkLayout } from "./inkMeasure.internal.js";
|
|
9
|
+
import { inkOutline } from "./inkPaint.internal.js";
|
|
10
|
+
import { keepsLayouts } from "./inkWatch.internal.js";
|
|
8
11
|
//#region src/react/features/ink/inkCapture.internal.ts
|
|
12
|
+
const release = (epoch) => {
|
|
13
|
+
for (const free of epoch.holds.splice(0)) free();
|
|
14
|
+
};
|
|
9
15
|
const heldBy = (epoch) => epoch.blocks.length > 0 || !epoch.note ? epoch.blocks : [epoch.note];
|
|
10
16
|
const lineStart = (live, index) => index === 0 ? 0 : live.lines[index - 1].end;
|
|
11
17
|
const runsOf = (live, points, radius) => {
|
|
@@ -164,17 +170,24 @@ const attachInkCapture = ({ editor, layer, preview, tool, view }) => {
|
|
|
164
170
|
const seal = () => {
|
|
165
171
|
const done = epoch;
|
|
166
172
|
epoch = null;
|
|
167
|
-
if (!done
|
|
168
|
-
const input = inputOf(done, contact.brush);
|
|
169
|
-
if (!input)
|
|
173
|
+
if (!done) return;
|
|
174
|
+
const input = contact && inputOf(done, contact.brush);
|
|
175
|
+
if (!input) {
|
|
176
|
+
release(done);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
170
179
|
scheduleAfterCommitNotification(editor, () => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
180
|
+
try {
|
|
181
|
+
const tracked = editor.plugin(HistoryPlugin).installed;
|
|
182
|
+
const joins = tracked && savedAt === editor.read.history().revision;
|
|
183
|
+
editor.update((tx) => {
|
|
184
|
+
if (joins) tx.history.merge();
|
|
185
|
+
tx.plugin(BaseInkPlugin).add(input);
|
|
186
|
+
});
|
|
187
|
+
savedAt = tracked ? editor.read.history().revision : void 0;
|
|
188
|
+
} finally {
|
|
189
|
+
release(done);
|
|
190
|
+
}
|
|
178
191
|
});
|
|
179
192
|
};
|
|
180
193
|
const cutAt = (time) => {
|
|
@@ -187,7 +200,7 @@ const attachInkCapture = ({ editor, layer, preview, tool, view }) => {
|
|
|
187
200
|
cutAt(performance.now());
|
|
188
201
|
draw();
|
|
189
202
|
};
|
|
190
|
-
const heldMoved = (open, origin, change) => heldBy(open).some(({ block, live }) => change
|
|
203
|
+
const heldMoved = (open, origin, change) => heldBy(open).some(({ block, live }) => keepsLayouts(change) ? !sameInkBox(live.box, inkBoxOf(block.element, origin)) : !sameInkLayout(live, measureInkBlock(block.element, block.text, origin)));
|
|
191
204
|
const changedAt = (block) => block.path.flatMap((_, at) => {
|
|
192
205
|
const key = view.key(block.path.slice(0, at + 1));
|
|
193
206
|
const time = key === null ? void 0 : changedSinceCut.get(key);
|
|
@@ -195,7 +208,7 @@ const attachInkCapture = ({ editor, layer, preview, tool, view }) => {
|
|
|
195
208
|
});
|
|
196
209
|
const take = (event, origin) => {
|
|
197
210
|
if (!contact || event.timeStamp < dropBefore) return;
|
|
198
|
-
const point = [event.clientX - origin.left, event.clientY - origin.top];
|
|
211
|
+
const point = [roundPixel(event.clientX - origin.left), roundPixel(event.clientY - origin.top)];
|
|
199
212
|
const [previous] = epoch?.samples.slice(-1) ?? [];
|
|
200
213
|
const { brush } = contact;
|
|
201
214
|
const radius = brush.size / 2;
|
|
@@ -210,19 +223,27 @@ const attachInkCapture = ({ editor, layer, preview, tool, view }) => {
|
|
|
210
223
|
const open = epoch ?? {
|
|
211
224
|
at: Date.now(),
|
|
212
225
|
blocks: [],
|
|
226
|
+
holds: [],
|
|
213
227
|
note: void 0,
|
|
214
228
|
samples: [],
|
|
215
229
|
start: event.timeStamp
|
|
216
230
|
};
|
|
217
231
|
const [last] = open.samples.slice(-1);
|
|
218
232
|
const segment = last ? [[last[0], last[1]], point] : [point];
|
|
233
|
+
const hold = (entered) => {
|
|
234
|
+
open.holds.push(holdInkBlock(editor, entered.block.id));
|
|
235
|
+
return entered;
|
|
236
|
+
};
|
|
219
237
|
epoch = open;
|
|
220
238
|
for (const { block } of entering(segment)) {
|
|
221
239
|
const entered = enter(block, origin);
|
|
222
|
-
if (entered) open.blocks.push(entered);
|
|
240
|
+
if (entered) open.blocks.push(hold(entered));
|
|
241
|
+
}
|
|
242
|
+
if (open.samples.length === 0 && open.blocks.length === 0) {
|
|
243
|
+
const note = nearestTo(point, origin);
|
|
244
|
+
open.note = note && hold(note);
|
|
223
245
|
}
|
|
224
|
-
|
|
225
|
-
open.samples.push([
|
|
246
|
+
open.samples.push(roundSample([
|
|
226
247
|
point[0],
|
|
227
248
|
point[1],
|
|
228
249
|
inkPressure(event, last && {
|
|
@@ -230,9 +251,10 @@ const attachInkCapture = ({ editor, layer, preview, tool, view }) => {
|
|
|
230
251
|
pressure: last[2]
|
|
231
252
|
}, brush.size),
|
|
232
253
|
Math.max(last?.[3] ?? 0, event.timeStamp - open.start)
|
|
233
|
-
]);
|
|
254
|
+
]));
|
|
234
255
|
};
|
|
235
256
|
const cancel = () => {
|
|
257
|
+
if (epoch) release(epoch);
|
|
236
258
|
epoch = null;
|
|
237
259
|
contact = null;
|
|
238
260
|
changedSinceCut = /* @__PURE__ */ new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { simulatedPressure } from "
|
|
1
|
+
import { simulatedPressure } from "../../../internal/penStroke.internal.js";
|
|
2
2
|
//#region src/react/features/ink/inkInput.internal.ts
|
|
3
3
|
/**
|
|
4
4
|
* The layer's `touch-action`: a finger still pans the page natively while the
|