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,4 +1,6 @@
|
|
|
1
|
-
import { readAuthoredView, subscribeEditorViewState } from "../../../facade.js";
|
|
1
|
+
import { isDocumentView, readAuthoredView, subscribeEditorViewState } from "../../../facade.js";
|
|
2
|
+
import { getCompiledPlateModelBinding } from "../../../internal/plugin/compilePlateModel.js";
|
|
3
|
+
import { PLUGINS } from "../../../utils/plate-keys.js";
|
|
2
4
|
import { ElementApi, PathApi, SelectionApi, createEditorView } from "../../../core.js";
|
|
3
5
|
import { frameTakes } from "../../../features/board/lib/boardFrame.internal.js";
|
|
4
6
|
import { BOARD_STYLE_KEYS, parseBoardStyle } from "../../../features/board/lib/boardStyle.internal.js";
|
|
@@ -8,11 +10,13 @@ import { BaseBoardFramePlugin } from "../../../features/board/lib/BaseBoardFrame
|
|
|
8
10
|
import { BaseBoardGeoPlugin } from "../../../features/board/lib/BaseBoardGeoPlugin.js";
|
|
9
11
|
import { BaseBoardImagePlugin } from "../../../features/board/lib/BaseBoardImagePlugin.js";
|
|
10
12
|
import { BaseBoardNotePlugin } from "../../../features/board/lib/BaseBoardNotePlugin.js";
|
|
11
|
-
import { BaseBoardStrokePlugin } from "../../../features/board/lib/BaseBoardStrokePlugin.js";
|
|
12
13
|
import { shapeIdOf } from "../../../features/board/lib/boardCopy.internal.js";
|
|
13
14
|
import { keepsBoardRatio } from "../../../features/board/lib/boardRatio.internal.js";
|
|
15
|
+
import { boardTypesOf } from "../../../features/board/lib/boardTypes.internal.js";
|
|
14
16
|
import { BaseBoardPlugin } from "../../../features/board/lib/BaseBoardPlugin.js";
|
|
17
|
+
import { uploadDraftsOf } from "../../../internal/plugin/uploadDrafts.js";
|
|
15
18
|
import { createBoardIndex } from "./boardIndex.internal.js";
|
|
19
|
+
import { BOARD_PLACE_SIZE } from "./boardPick.internal.js";
|
|
16
20
|
import { createBoardVoice } from "./boardVoice.internal.js";
|
|
17
21
|
import { attachBoardKeys, takeTextTab } from "./boardKeys.internal.js";
|
|
18
22
|
import { attachBoardClipboard } from "./boardClipboard.internal.js";
|
|
@@ -34,6 +38,11 @@ const ZOOM_STEPS = [
|
|
|
34
38
|
const WHEEL_STEP_ZOOM = 100;
|
|
35
39
|
const FIT_PADDING = 32;
|
|
36
40
|
const PICTURE_GAP = 16;
|
|
41
|
+
const FILE_DRAG_EVENTS = [
|
|
42
|
+
"dragenter",
|
|
43
|
+
"dragover",
|
|
44
|
+
"drop"
|
|
45
|
+
];
|
|
37
46
|
const percentOf = (zoom) => Math.round(zoom * 100);
|
|
38
47
|
const clampZoom = (zoom) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom));
|
|
39
48
|
const scrollsBy = (delta, overflow, at, shown, total) => (overflow === "auto" || overflow === "scroll") && (delta > 0 ? Math.ceil(at + shown) < total : delta < 0 && at > 0);
|
|
@@ -72,13 +81,6 @@ const validStyle = (style) => {
|
|
|
72
81
|
const showAs = (styles, key, shown) => {
|
|
73
82
|
styles[key] = shown;
|
|
74
83
|
};
|
|
75
|
-
const TOOL_SHAPES = {
|
|
76
|
-
arrow: BaseBoardArrowPlugin.name,
|
|
77
|
-
frame: BaseBoardFramePlugin.name,
|
|
78
|
-
geo: BaseBoardGeoPlugin.name,
|
|
79
|
-
note: BaseBoardNotePlugin.name,
|
|
80
|
-
pen: BaseBoardStrokePlugin.name
|
|
81
|
-
};
|
|
82
84
|
const subscribeTo = (listeners) => (listener) => {
|
|
83
85
|
listeners.add(listener);
|
|
84
86
|
return () => {
|
|
@@ -89,8 +91,11 @@ const SHAPES_EDITABLE = `[data-editor-content-root-slot="${BOARD_SHAPES_SLOT}"]
|
|
|
89
91
|
const setShapeSelection = (tx, keys) => tx.selection.setNodes(keys, { mode: shapeSelectionMode(tx.schema, keys.flatMap((key) => tx.nodes.get(key)?.[0] ?? [])) });
|
|
90
92
|
const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
91
93
|
const keyOf = (node) => editor.read((state) => state.key(node));
|
|
92
|
-
const board = keyOf(element);
|
|
93
94
|
const root = editor.read.schema.getElementContentRoots(element)["shapes"] ?? "";
|
|
95
|
+
const shownBoard = mounted.read((state) => state.key(element));
|
|
96
|
+
const ownerBoard = editor.read.roots().find((entry) => entry.root === root)?.owners[0];
|
|
97
|
+
const board = ownerBoard && (ownerBoard.root ? createEditorView(editor, { root: ownerBoard.root }) : editor).key(ownerBoard.path);
|
|
98
|
+
if (!board) throw new Error("A board view needs its board in the editor.");
|
|
94
99
|
const rootView = createEditorView(editor, { root });
|
|
95
100
|
const boards = editor.plugin(BaseBoardPlugin);
|
|
96
101
|
const shownBoards = mounted.plugin(BaseBoardPlugin);
|
|
@@ -98,6 +103,14 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
98
103
|
const authored = readAuthoredView(shapes);
|
|
99
104
|
return !shapes.read.view.isReadOnly() && !(authored && "preview" in authored);
|
|
100
105
|
};
|
|
106
|
+
const takesPictureFiles = () => {
|
|
107
|
+
const image = editor.plugin(BaseBoardImagePlugin);
|
|
108
|
+
const holds = image.installed && editor.read.schema.element(image.schema.type)?.content?.allowedElementTypes || [];
|
|
109
|
+
return writable() && [PLUGINS.upload, PLUGINS.image].every((name) => {
|
|
110
|
+
const type = getCompiledPlateModelBinding(editor, name)?.elementType;
|
|
111
|
+
return !!type && holds.includes(type);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
101
114
|
let state = {
|
|
102
115
|
camera: {
|
|
103
116
|
x: 0,
|
|
@@ -107,6 +120,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
107
120
|
nextStyle: {},
|
|
108
121
|
selectedShapes: [],
|
|
109
122
|
styles: {},
|
|
123
|
+
takesPictureFiles: takesPictureFiles(),
|
|
110
124
|
tool: "select",
|
|
111
125
|
toolLocked: false,
|
|
112
126
|
writable: writable()
|
|
@@ -119,7 +133,15 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
119
133
|
const notifyErasing = (ids) => {
|
|
120
134
|
for (const id of ids) for (const listener of erasingListeners.get(id) ?? []) listener();
|
|
121
135
|
};
|
|
122
|
-
const
|
|
136
|
+
const types = boardTypesOf(editor);
|
|
137
|
+
const toolShapes = {
|
|
138
|
+
arrow: () => BaseBoardArrowPlugin.name,
|
|
139
|
+
frame: () => BaseBoardFramePlugin.name,
|
|
140
|
+
geo: types.geo,
|
|
141
|
+
note: types.note,
|
|
142
|
+
pen: types.stroke
|
|
143
|
+
};
|
|
144
|
+
const takes = (type, key) => key === "geo" ? type === types.geo() : editor.read.schema.property({
|
|
123
145
|
key,
|
|
124
146
|
placement: "element",
|
|
125
147
|
type
|
|
@@ -142,6 +164,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
142
164
|
};
|
|
143
165
|
const styleFor = (type, style) => {
|
|
144
166
|
const taken = {};
|
|
167
|
+
if (type === void 0) return taken;
|
|
145
168
|
const take = (key) => {
|
|
146
169
|
if (style[key] !== void 0 && takes(type, key)) taken[key] = style[key];
|
|
147
170
|
};
|
|
@@ -158,7 +181,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
158
181
|
}];
|
|
159
182
|
};
|
|
160
183
|
const stylesOf = ({ nextStyle, selectedShapes, tool }) => {
|
|
161
|
-
const next =
|
|
184
|
+
const next = toolShapes[tool]?.();
|
|
162
185
|
const targets = tool === "select" ? styleTargets(selectedShapes).map(({ node }) => storedStylesOf(node)) : [];
|
|
163
186
|
const styles = {};
|
|
164
187
|
const valuesOf = (key) => {
|
|
@@ -206,9 +229,10 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
206
229
|
}) ?? false,
|
|
207
230
|
isEmpty: (block) => editor.read.nodes.isEmpty(block),
|
|
208
231
|
keepsRatio: keepsBoardRatio(editor),
|
|
232
|
+
types,
|
|
209
233
|
members: () => {
|
|
210
234
|
const shown = new Map(shownView.read.children().map((node, at) => [ElementApi.isElement(node) ? shapeIdOf(node) : "", shownView.key([at])]));
|
|
211
|
-
const entries = shownBoards.read.shapes(
|
|
235
|
+
const entries = shownBoards.read.shapes(shownBoard).filter(({ id }) => shown.has(id));
|
|
212
236
|
renderedKeyOf = new Map(entries.flatMap(({ id, key }) => {
|
|
213
237
|
const rendered = shown.get(id);
|
|
214
238
|
return rendered ? [[key, rendered]] : [];
|
|
@@ -240,6 +264,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
240
264
|
let layer = null;
|
|
241
265
|
let zoomLayer = null;
|
|
242
266
|
const focusTarget = React$1.createRef();
|
|
267
|
+
let pictureHost = null;
|
|
243
268
|
let surface = null;
|
|
244
269
|
let gestures = null;
|
|
245
270
|
let interaction = null;
|
|
@@ -288,14 +313,16 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
288
313
|
const listed = keys.size === 0 ? [] : index.entries().filter((entry) => keys.has(entry.key)).map(withShownNode);
|
|
289
314
|
const selected = sameShapes(listed, state.selectedShapes) ? state.selectedShapes : listed;
|
|
290
315
|
const canWrite = writable();
|
|
316
|
+
const takesFiles = takesPictureFiles();
|
|
291
317
|
const styles = stylesOf({
|
|
292
318
|
...state,
|
|
293
319
|
selectedShapes: selected
|
|
294
320
|
});
|
|
295
|
-
if (selected !== state.selectedShapes || canWrite !== state.writable || styles !== state.styles) publish({
|
|
321
|
+
if (selected !== state.selectedShapes || canWrite !== state.writable || takesFiles !== state.takesPictureFiles || styles !== state.styles) publish({
|
|
296
322
|
...state,
|
|
297
323
|
selectedShapes: selected,
|
|
298
324
|
styles,
|
|
325
|
+
takesPictureFiles: takesFiles,
|
|
299
326
|
writable: canWrite
|
|
300
327
|
});
|
|
301
328
|
};
|
|
@@ -424,7 +451,9 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
424
451
|
y: y + height / 2
|
|
425
452
|
};
|
|
426
453
|
};
|
|
427
|
-
const
|
|
454
|
+
const shownLayoutOf = (node) => ElementApi.isElement(node) ? index.byId(shapeIdOf(node)) : void 0;
|
|
455
|
+
const selectedNodes = () => editor.read.selection.nodeMode() ? editor.read.selection.nodes() : [];
|
|
456
|
+
const selectedKeys = () => new Set(selectedNodes().flatMap(([node]) => shownLayoutOf(node)?.key ?? []));
|
|
428
457
|
const selectedShapes = () => {
|
|
429
458
|
const keys = selectedKeys();
|
|
430
459
|
return index.entries().flatMap((entry) => {
|
|
@@ -496,7 +525,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
496
525
|
};
|
|
497
526
|
const editedShape = () => {
|
|
498
527
|
const key = editedKey();
|
|
499
|
-
return key
|
|
528
|
+
return (key && shownLayoutOf(editor.read.nodes.get(key)?.[0])) ?? null;
|
|
500
529
|
};
|
|
501
530
|
const focusRoot = () => {
|
|
502
531
|
surface?.querySelector(SHAPES_EDITABLE)?.focus({ preventScroll: true });
|
|
@@ -511,12 +540,13 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
511
540
|
editor.api.dom.deselect();
|
|
512
541
|
return true;
|
|
513
542
|
};
|
|
514
|
-
const
|
|
515
|
-
const order = new Map(index.entries().map((entry, at) => [entry.
|
|
516
|
-
const sorted =
|
|
543
|
+
const selectIds = (ids) => {
|
|
544
|
+
const order = new Map(index.entries().map((entry, at) => [entry.id, at]));
|
|
545
|
+
const sorted = ids.toSorted((a, b) => (order.get(a) ?? 0) - (order.get(b) ?? 0));
|
|
517
546
|
deselectOnBoard();
|
|
518
|
-
editor.update((tx) => setShapeSelection(tx, sorted));
|
|
547
|
+
editor.update((tx) => setShapeSelection(tx, sorted.flatMap((id) => tx.unique.holder("shapeId", id)?.key ?? [])));
|
|
519
548
|
};
|
|
549
|
+
const select = (keys) => selectIds(keys.flatMap((key) => index.layout(key)?.id ?? []));
|
|
520
550
|
const focusBoard = () => {
|
|
521
551
|
const edited = editedShape();
|
|
522
552
|
if (edited) select([edited.key]);
|
|
@@ -563,10 +593,9 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
563
593
|
if (holder) setShapeSelection(tx, [holder.key]);
|
|
564
594
|
return written;
|
|
565
595
|
});
|
|
566
|
-
|
|
567
|
-
if (!inserted) return false;
|
|
596
|
+
if (!id || !boards.read.shape(id)) return false;
|
|
568
597
|
if (!state.toolLocked) setState({ tool: "select" });
|
|
569
|
-
|
|
598
|
+
selectIds([id]);
|
|
570
599
|
return true;
|
|
571
600
|
};
|
|
572
601
|
const placeShape = (tool, box, { style, takesShapes = false }) => {
|
|
@@ -591,18 +620,14 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
591
620
|
if (tool === "frame") return tx.plugin(BaseBoardFramePlugin).insert(box, { board });
|
|
592
621
|
if (tool === "note") return tx.plugin(BaseBoardNotePlugin).insert({
|
|
593
622
|
...box,
|
|
594
|
-
...styleFor(
|
|
623
|
+
...styleFor(types.note(), style)
|
|
595
624
|
}, { board });
|
|
596
625
|
return tx.plugin(BaseBoardGeoPlugin).insert({
|
|
597
626
|
...box,
|
|
598
|
-
...styleFor(
|
|
627
|
+
...styleFor(types.geo(), style)
|
|
599
628
|
}, { board });
|
|
600
629
|
});
|
|
601
630
|
};
|
|
602
|
-
const selectIds = (ids) => select(ids.flatMap((id) => {
|
|
603
|
-
const shape = boards.read.shape(id);
|
|
604
|
-
return shape ? [shape.key] : [];
|
|
605
|
-
}));
|
|
606
631
|
const land = (slice, place) => {
|
|
607
632
|
const ids = write((tx) => tx.plugin(BaseBoardPlugin).insertCopy(slice, {
|
|
608
633
|
board,
|
|
@@ -614,25 +639,59 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
614
639
|
};
|
|
615
640
|
const pendingPictures = createPendingPictures({
|
|
616
641
|
editor,
|
|
617
|
-
|
|
642
|
+
shapes,
|
|
618
643
|
writable
|
|
619
644
|
});
|
|
620
|
-
const
|
|
645
|
+
const landRow = (tx, children, sizes, point) => {
|
|
646
|
+
const width = sizes.reduce((total, box) => total + box.width, 0) + PICTURE_GAP * (sizes.length - 1);
|
|
647
|
+
let x = point.x - width / 2;
|
|
648
|
+
return children.flatMap((child, at) => {
|
|
649
|
+
const box = sizes[at];
|
|
650
|
+
const id = tx.plugin(BaseBoardImagePlugin).insert({
|
|
651
|
+
children: [child],
|
|
652
|
+
...box,
|
|
653
|
+
x,
|
|
654
|
+
y: point.y - box.height / 2
|
|
655
|
+
}, { board });
|
|
656
|
+
x += box.width + PICTURE_GAP;
|
|
657
|
+
return id ?? [];
|
|
658
|
+
});
|
|
659
|
+
};
|
|
660
|
+
const landPictureFiles = (files, point, refused) => {
|
|
661
|
+
if (!surface || files.length === 0) return;
|
|
662
|
+
pendingPictures.load(surface, files, (sizes) => {
|
|
663
|
+
const ids = write((tx) => {
|
|
664
|
+
const upload = uploadDraftsOf(tx);
|
|
665
|
+
let taken = files;
|
|
666
|
+
let batch = upload?.admit(taken, { kind: "image" });
|
|
667
|
+
if (batch && "failure" in batch && batch.failure.code === "unsupported-file-type") {
|
|
668
|
+
const others = new Set(batch.failure.files);
|
|
669
|
+
taken = files.filter((file) => !others.has(file));
|
|
670
|
+
batch = upload?.admit(taken, { kind: "image" });
|
|
671
|
+
}
|
|
672
|
+
if (!batch || "failure" in batch) return [];
|
|
673
|
+
const landed = landRow(tx, batch.drafts, taken.map((file) => sizes[files.indexOf(file)]), point);
|
|
674
|
+
batch.fill(landed.flatMap((id) => {
|
|
675
|
+
const holder = tx.unique.holder("shapeId", id);
|
|
676
|
+
const shape = holder && tx.nodes.get(holder.key)?.[0];
|
|
677
|
+
const draft = shape && ElementApi.isElement(shape) && shape.children[0];
|
|
678
|
+
return draft && tx.key(draft) || [];
|
|
679
|
+
}));
|
|
680
|
+
return landed;
|
|
681
|
+
});
|
|
682
|
+
if (ids && ids.length > 0) selectIds(ids);
|
|
683
|
+
else refused?.();
|
|
684
|
+
});
|
|
685
|
+
};
|
|
686
|
+
const landPictures = (images, point, fallbackFiles = []) => {
|
|
621
687
|
if (!surface) return;
|
|
622
|
-
pendingPictures.load(surface, images, (
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
x,
|
|
630
|
-
y: point.y - box.height / 2
|
|
631
|
-
}, { board });
|
|
632
|
-
x += box.width + PICTURE_GAP;
|
|
633
|
-
return id ?? [];
|
|
634
|
-
}));
|
|
635
|
-
if (ids) selectIds(ids);
|
|
688
|
+
pendingPictures.load(surface, images.map(({ url }) => String(url)), (sizes, failed) => {
|
|
689
|
+
const landLinks = () => {
|
|
690
|
+
const ids = write((tx) => landRow(tx, images, sizes, point));
|
|
691
|
+
if (ids) selectIds(ids);
|
|
692
|
+
};
|
|
693
|
+
if (failed && fallbackFiles.length > 0) landPictureFiles(fallbackFiles, point, landLinks);
|
|
694
|
+
else landLinks();
|
|
636
695
|
});
|
|
637
696
|
};
|
|
638
697
|
const paste = (data) => {
|
|
@@ -641,6 +700,37 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
641
700
|
shownView.update((tx) => setShapeSelection(tx, keys));
|
|
642
701
|
return !!shownView.api.dom.clipboard.insertData(data);
|
|
643
702
|
};
|
|
703
|
+
const pasteNote = (data, point) => {
|
|
704
|
+
const { height, width } = BOARD_PLACE_SIZE.note;
|
|
705
|
+
return insertAndSelect((tx) => {
|
|
706
|
+
const id = tx.plugin(BaseBoardNotePlugin).insert({
|
|
707
|
+
height,
|
|
708
|
+
width,
|
|
709
|
+
x: point.x - width / 2,
|
|
710
|
+
y: point.y - height / 2,
|
|
711
|
+
...styleFor(types.note(), state.nextStyle)
|
|
712
|
+
}, { board });
|
|
713
|
+
const holder = id && tx.unique.holder("shapeId", id);
|
|
714
|
+
const shape = holder && tx.nodes.get(holder.key);
|
|
715
|
+
if (shape) {
|
|
716
|
+
const at = {
|
|
717
|
+
offset: 0,
|
|
718
|
+
path: [
|
|
719
|
+
...shape[1],
|
|
720
|
+
0,
|
|
721
|
+
0
|
|
722
|
+
],
|
|
723
|
+
root
|
|
724
|
+
};
|
|
725
|
+
tx.selection.set({
|
|
726
|
+
anchor: at,
|
|
727
|
+
focus: at
|
|
728
|
+
});
|
|
729
|
+
shownView.api.dom.clipboard.insertData(data);
|
|
730
|
+
}
|
|
731
|
+
return id;
|
|
732
|
+
});
|
|
733
|
+
};
|
|
644
734
|
const core = {
|
|
645
735
|
replaceInteraction: (next) => {
|
|
646
736
|
cancelInteraction();
|
|
@@ -670,9 +760,12 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
670
760
|
viewBox,
|
|
671
761
|
commit,
|
|
672
762
|
edit: (key) => {
|
|
763
|
+
const id = index.layout(key)?.id;
|
|
764
|
+
if (!id || !boards.read.shape(id)) return;
|
|
673
765
|
focusRoot();
|
|
674
766
|
editor.update((tx) => {
|
|
675
|
-
const
|
|
767
|
+
const owned = tx.unique.holder("shapeId", id)?.key;
|
|
768
|
+
const end = owned && tx.points.end(owned);
|
|
676
769
|
if (end) tx.selection.set(end);
|
|
677
770
|
});
|
|
678
771
|
},
|
|
@@ -690,6 +783,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
690
783
|
},
|
|
691
784
|
deselectOnBoard,
|
|
692
785
|
land,
|
|
786
|
+
landPictureFiles,
|
|
693
787
|
landPictures,
|
|
694
788
|
leaveBoard: (backward) => {
|
|
695
789
|
if (!writable()) {
|
|
@@ -719,6 +813,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
719
813
|
});
|
|
720
814
|
},
|
|
721
815
|
paste,
|
|
816
|
+
pasteNote,
|
|
722
817
|
place: placeShape,
|
|
723
818
|
redo: () => {
|
|
724
819
|
if (writable()) history?.redo();
|
|
@@ -747,6 +842,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
747
842
|
slice: (ids) => boards.read.slice(ids),
|
|
748
843
|
state: () => state,
|
|
749
844
|
styleFor,
|
|
845
|
+
takesPictureFiles,
|
|
750
846
|
toggleSelected: (key) => {
|
|
751
847
|
const keys = selectedShapes().map((shape) => shape.key);
|
|
752
848
|
select(keys.includes(key) ? keys.filter((held) => held !== key) : [...keys, key]);
|
|
@@ -794,10 +890,25 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
794
890
|
y: camera.y + event.deltaY / camera.zoom
|
|
795
891
|
});
|
|
796
892
|
};
|
|
893
|
+
const onFileDrag = (event) => {
|
|
894
|
+
const data = event.dataTransfer;
|
|
895
|
+
if (!data || !Array.from(data.types).includes("Files") || editedShape() || !takesPictureFiles()) return;
|
|
896
|
+
event.preventDefault();
|
|
897
|
+
event.stopPropagation();
|
|
898
|
+
data.dropEffect = "copy";
|
|
899
|
+
mounted.api.dom.drag.indicate(null);
|
|
900
|
+
if (event.type !== "drop") return;
|
|
901
|
+
measure();
|
|
902
|
+
landPictureFiles(Array.from(data.files), boardPointAt({
|
|
903
|
+
x: event.clientX,
|
|
904
|
+
y: event.clientY
|
|
905
|
+
}));
|
|
906
|
+
};
|
|
797
907
|
const keys = attachBoardKeys(host, core);
|
|
798
908
|
gestures = attachBoardGestures(host, core, keys.spaceHeld);
|
|
799
909
|
const detachClipboard = attachBoardClipboard(host, core);
|
|
800
910
|
host.addEventListener("wheel", onWheel, { passive: false });
|
|
911
|
+
for (const type of FILE_DRAG_EVENTS) host.addEventListener(type, onFileDrag);
|
|
801
912
|
return () => {
|
|
802
913
|
gestures?.detach();
|
|
803
914
|
gestures = null;
|
|
@@ -810,6 +921,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
810
921
|
surface = null;
|
|
811
922
|
resizeObserver.disconnect();
|
|
812
923
|
host.removeEventListener("wheel", onWheel);
|
|
924
|
+
for (const type of FILE_DRAG_EVENTS) host.removeEventListener(type, onFileDrag);
|
|
813
925
|
keys.detach();
|
|
814
926
|
detachClipboard();
|
|
815
927
|
pendingPictures.cancel();
|
|
@@ -818,8 +930,13 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
818
930
|
index.update();
|
|
819
931
|
shownVersion = index.version();
|
|
820
932
|
refresh();
|
|
821
|
-
|
|
933
|
+
const view = {
|
|
822
934
|
actions: {
|
|
935
|
+
exportPicture: async ({ format, kit }) => {
|
|
936
|
+
const selected = selectedShapes().map(({ id }) => id);
|
|
937
|
+
const [{ drawBoardPicture }, plugins] = await Promise.all([import("./boardExport.internal.js"), kit]);
|
|
938
|
+
return drawBoardPicture(view, selected, format, plugins);
|
|
939
|
+
},
|
|
823
940
|
fit,
|
|
824
941
|
focus: () => {
|
|
825
942
|
core.focusBoard();
|
|
@@ -834,8 +951,8 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
834
951
|
const valid = validStyle(style);
|
|
835
952
|
if (Object.keys(valid).length === 0) return;
|
|
836
953
|
const edited = editedKey();
|
|
837
|
-
const
|
|
838
|
-
const picks = state.tool === "select" ? boards.read.shapes(board).filter(({ key }) =>
|
|
954
|
+
const ownerKeys = new Set(edited ? [edited] : selectedNodes().map(([node]) => keyOf(node)));
|
|
955
|
+
const picks = state.tool === "select" ? boards.read.shapes(board).filter(({ key }) => ownerKeys.has(key)).flatMap(({ id, node }) => {
|
|
839
956
|
const taken = styleFor(node.type, valid);
|
|
840
957
|
return Object.keys(taken).length > 0 ? [{
|
|
841
958
|
id,
|
|
@@ -855,6 +972,9 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
855
972
|
},
|
|
856
973
|
setTool: core.setTool,
|
|
857
974
|
setToolLocked: core.setToolLocked,
|
|
975
|
+
upload: (files) => {
|
|
976
|
+
if (takesPictureFiles()) landPictureFiles(files, viewCenter());
|
|
977
|
+
},
|
|
858
978
|
zoomIn: core.zoomIn,
|
|
859
979
|
zoomOut: core.zoomOut
|
|
860
980
|
},
|
|
@@ -874,7 +994,8 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
874
994
|
if (reshaped || reschemed || changed.hasAny("selection") || editor.read.selection.nodeMode()) showSelection();
|
|
875
995
|
if (changed.hasAny("selection")) voice.selectionChanged();
|
|
876
996
|
});
|
|
877
|
-
const unsubscribeViewState = subscribeEditorViewState(shapes, () => {
|
|
997
|
+
const unsubscribeViewState = subscribeEditorViewState(shapes, (change) => {
|
|
998
|
+
if (change !== "readOnly" && change !== "authored") return;
|
|
878
999
|
gestures?.refuseWrites();
|
|
879
1000
|
shownView = createEditorView(mounted, { root });
|
|
880
1001
|
follow();
|
|
@@ -895,6 +1016,24 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
895
1016
|
if (!index.byId(id)) index.update();
|
|
896
1017
|
return index.shownLayout(id);
|
|
897
1018
|
},
|
|
1019
|
+
holdPictureHost: (host) => {
|
|
1020
|
+
pictureHost = host;
|
|
1021
|
+
},
|
|
1022
|
+
pictureSource: (selected) => {
|
|
1023
|
+
const host = pictureHost;
|
|
1024
|
+
if (!host?.isConnected) return null;
|
|
1025
|
+
index.update();
|
|
1026
|
+
const picked = new Set(selected);
|
|
1027
|
+
for (const id of selected) for (const member of index.membersOf(id) ?? []) picked.add(member);
|
|
1028
|
+
const authored = isDocumentView(editor) ? void 0 : readAuthoredView(shapes);
|
|
1029
|
+
return {
|
|
1030
|
+
editor,
|
|
1031
|
+
host,
|
|
1032
|
+
layouts: [...index.layouts()].filter(({ id }) => selected.length === 0 || picked.has(id)).sort((a, b) => a.rank - b.rank),
|
|
1033
|
+
projection: authored && ("preview" in authored ? authored.preview : "proposed"),
|
|
1034
|
+
root
|
|
1035
|
+
};
|
|
1036
|
+
},
|
|
898
1037
|
renderWith: (next) => {
|
|
899
1038
|
({history, messages} = next);
|
|
900
1039
|
},
|
|
@@ -928,6 +1067,7 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
928
1067
|
takeTextTab: (event) => takeTextTab(core, event),
|
|
929
1068
|
viewport: () => viewport
|
|
930
1069
|
};
|
|
1070
|
+
return view;
|
|
931
1071
|
};
|
|
932
1072
|
const BoardViewContext = React$1.createContext(null);
|
|
933
1073
|
const useBoardViewContext = () => {
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { NodeApi, screenReaderAnnouncementEffect } from "../../../core.js";
|
|
2
2
|
import "../../../features/board/lib/boardFrame.internal.js";
|
|
3
|
-
import {
|
|
4
|
-
import { BaseBoardGeoPlugin } from "../../../features/board/lib/BaseBoardGeoPlugin.js";
|
|
5
|
-
import { BaseBoardNotePlugin } from "../../../features/board/lib/BaseBoardNotePlugin.js";
|
|
6
|
-
import { BaseBoardStrokePlugin } from "../../../features/board/lib/BaseBoardStrokePlugin.js";
|
|
3
|
+
import { boardTypesOf } from "../../../features/board/lib/boardTypes.internal.js";
|
|
7
4
|
//#region src/react/features/board/boardVoice.internal.ts
|
|
8
|
-
const KINDS = /* @__PURE__ */ new Map([
|
|
9
|
-
[BaseBoardFramePlugin.name, "frame"],
|
|
10
|
-
[BaseBoardGeoPlugin.name, "geo"],
|
|
11
|
-
[BaseBoardNotePlugin.name, "note"],
|
|
12
|
-
[BaseBoardStrokePlugin.name, "stroke"]
|
|
13
|
-
]);
|
|
14
5
|
const textOf = (node) => {
|
|
15
6
|
if (node.type === "boardFrame") return typeof node.name === "string" ? node.name : "";
|
|
16
7
|
return node.children.map((child) => NodeApi.string(child)).filter(Boolean).join(" ");
|
|
@@ -26,10 +17,18 @@ const createBoardVoice = ({ editing, editor, index, members, messages, selectedS
|
|
|
26
17
|
let owed = null;
|
|
27
18
|
let pending = null;
|
|
28
19
|
let selection = [];
|
|
20
|
+
const types = boardTypesOf(editor);
|
|
21
|
+
const kindOf = (type) => {
|
|
22
|
+
if (type === "boardFrame") return "frame";
|
|
23
|
+
if (type === types.geo()) return "geo";
|
|
24
|
+
if (type === types.note()) return "note";
|
|
25
|
+
if (type === types.stroke()) return "stroke";
|
|
26
|
+
return "shape";
|
|
27
|
+
};
|
|
29
28
|
const describe = (entry, entries) => {
|
|
30
29
|
const text = textOf(entry.node);
|
|
31
30
|
if (entry.kind !== "arrow") return {
|
|
32
|
-
kind:
|
|
31
|
+
kind: kindOf(entry.node.type),
|
|
33
32
|
text
|
|
34
33
|
};
|
|
35
34
|
const endOf = (side) => {
|