platejs 54.0.0-beta.2 → 54.0.0-beta.3
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-DY104TqL.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-Deo6n6Fs.d.ts} +7 -3
- package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-CJX5bKuv.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-DAOYWuvC.d.ts} +2 -2
- package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-Dt-unJZY-DCddmbSD.d.ts} +10 -2
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-BJG8l_mk.d.ts → core-ClHasORr.d.ts} +433 -95
- 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 +4 -2
- package/dist/docs/api/core/plate-plugin.md +3 -0
- package/dist/docs/api/core/plate-store.md +3 -3
- package/dist/docs/api/dom.md +14 -4
- package/dist/docs/api/editor-transforms.md +2 -1
- package/dist/docs/api/react-hooks.md +25 -11
- package/dist/docs/authored-changes.md +5 -2
- package/dist/docs/basic-blocks.md +42 -29
- package/dist/docs/blockquote.md +5 -3
- package/dist/docs/board.md +63 -8
- package/dist/docs/code-block.md +47 -0
- package/dist/docs/discussion.md +1 -1
- package/dist/docs/docx.md +1 -1
- package/dist/docs/dom-coverage.md +5 -0
- 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 +176 -8
- package/dist/docs/plugin-components.md +13 -10
- package/dist/docs/plugin-input-rules.md +4 -12
- 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 +29 -5
- package/dist/docx/export/lib/reviewPart.js +1 -1
- package/dist/docx/export/lib/reviewProjection.js +10 -8
- 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/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 +10 -10
- package/dist/features/field/index.d.ts +2 -0
- package/dist/features/field/index.js +2 -0
- package/dist/features/field/lib/BaseFieldPlugin.js +414 -0
- package/dist/features/field/lib/fieldRules.internal.js +42 -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 +533 -62
- 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 +1 -1
- package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +6 -2
- 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 +14 -8
- 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-cg_cWsaN.d.ts} +2 -31
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-D1CFXA-i.d.ts → index-8WO2vI0U.d.ts} +475 -143
- package/dist/{index-DaM37gF6.d.ts → index-B5mYEawV.d.ts} +37 -21
- package/dist/{index-Bq3sdm3S.d.ts → index-BZWFoUXt.d.ts} +5 -4
- package/dist/{index-DdIRduDG.d.ts → index-C0POz7rg.d.ts} +3 -2
- package/dist/{index-Bxfvicyy.d.ts → index-C1_JIhL4.d.ts} +4 -3
- package/dist/{index-DC_MNGyu.d.ts → index-C35V_hj0.d.ts} +3 -3
- package/dist/{index-kLKMc-pI.d.ts → index-C6ql9pKw.d.ts} +2 -2
- package/dist/{index-hsC_sOn2.d.ts → index-C9DiGDVj.d.ts} +35 -5
- package/dist/{index-DTgaSxKr.d.ts → index-CLsEe3LY.d.ts} +40 -4
- package/dist/{index-CT7miqQN.d.ts → index-CdOLsPaW.d.ts} +29 -9
- package/dist/{index-DLA2DUR2.d.ts → index-CktYvOgk.d.ts} +4 -3
- package/dist/{index-BBKGrsG3.d.ts → index-Cmuluh6f.d.ts} +1 -1
- package/dist/{index-BiQerPJS.d.ts → index-CzLwBZpY.d.ts} +2 -2
- package/dist/{index-DzD6BIFJ.d.ts → index-D3-2iM1b.d.ts} +7 -5
- package/dist/{index-Cl77E9yr.d.ts → index-DKOFvteF.d.ts} +2 -2
- package/dist/{index-iaZOhA76.d.ts → index-DPWyk3lG-DOYwohXO.d.ts} +1 -1
- package/dist/index-DQnjqtQa.d.ts +678 -0
- package/dist/{index-CcZbqPqk.d.ts → index-Do9pj1GK.d.ts} +73 -39
- package/dist/{index-BU6k1Aev.d.ts → index-DpltOCot-A2b3p3Eb.d.ts} +4735 -4586
- package/dist/{index-Bc2Yg_2j.d.ts → index-HPYawTae-BCUQLEWF.d.ts} +2 -2
- package/dist/{index-BkR7-GLI.d.ts → index-baQOK89E.d.ts} +2 -2
- package/dist/{index-D5W-p9bS.d.ts → index-oIJAZxc2.d.ts} +49 -4
- package/dist/{index-xdmCBvlT.d.ts → index-r7yb77Wy.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 +8 -2
- 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 +5 -15
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +2 -1
- package/dist/markdown/lib/MarkdownPlugin.js +16 -9
- package/dist/markdown/lib/RawHtmlPlugin.js +24 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
- package/dist/markdown/lib/internal/markdownConversion.js +773 -74
- package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
- 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 +314 -0
- package/dist/markdown/lib/internal/markdownSegments.js +57 -48
- package/dist/markdown/lib/internal/markdownTags.js +22 -8
- 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/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +17 -8
- package/dist/react/components/EditorProvider.js +5 -5
- package/dist/react/components/Plate.js +103 -122
- 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/boardGesture.internal.js +6 -3
- package/dist/react/features/board/boardIndex.internal.js +7 -18
- package/dist/react/features/board/boardPictures.internal.js +19 -13
- package/dist/react/features/board/boardView.internal.js +184 -49
- package/dist/react/features/board/boardVoice.internal.js +10 -11
- package/dist/react/features/board/index.d.ts +64 -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 +34 -0
- package/dist/react/features/field/index.d.ts +312 -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 -29
- 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 +331 -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 +8 -7
- 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 +425 -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 +66 -21
- 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-aUwpNnAw.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();
|
|
@@ -834,8 +946,8 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
834
946
|
const valid = validStyle(style);
|
|
835
947
|
if (Object.keys(valid).length === 0) return;
|
|
836
948
|
const edited = editedKey();
|
|
837
|
-
const
|
|
838
|
-
const picks = state.tool === "select" ? boards.read.shapes(board).filter(({ key }) =>
|
|
949
|
+
const ownerKeys = new Set(edited ? [edited] : selectedNodes().map(([node]) => keyOf(node)));
|
|
950
|
+
const picks = state.tool === "select" ? boards.read.shapes(board).filter(({ key }) => ownerKeys.has(key)).flatMap(({ id, node }) => {
|
|
839
951
|
const taken = styleFor(node.type, valid);
|
|
840
952
|
return Object.keys(taken).length > 0 ? [{
|
|
841
953
|
id,
|
|
@@ -855,6 +967,9 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
855
967
|
},
|
|
856
968
|
setTool: core.setTool,
|
|
857
969
|
setToolLocked: core.setToolLocked,
|
|
970
|
+
upload: (files) => {
|
|
971
|
+
if (takesPictureFiles()) landPictureFiles(files, viewCenter());
|
|
972
|
+
},
|
|
858
973
|
zoomIn: core.zoomIn,
|
|
859
974
|
zoomOut: core.zoomOut
|
|
860
975
|
},
|
|
@@ -874,7 +989,8 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
874
989
|
if (reshaped || reschemed || changed.hasAny("selection") || editor.read.selection.nodeMode()) showSelection();
|
|
875
990
|
if (changed.hasAny("selection")) voice.selectionChanged();
|
|
876
991
|
});
|
|
877
|
-
const unsubscribeViewState = subscribeEditorViewState(shapes, () => {
|
|
992
|
+
const unsubscribeViewState = subscribeEditorViewState(shapes, (change) => {
|
|
993
|
+
if (change !== "readOnly" && change !== "authored") return;
|
|
878
994
|
gestures?.refuseWrites();
|
|
879
995
|
shownView = createEditorView(mounted, { root });
|
|
880
996
|
follow();
|
|
@@ -895,6 +1011,25 @@ const createBoardView = (editor, mounted, element, initialMessages, shapes) => {
|
|
|
895
1011
|
if (!index.byId(id)) index.update();
|
|
896
1012
|
return index.shownLayout(id);
|
|
897
1013
|
},
|
|
1014
|
+
holdPictureHost: (host) => {
|
|
1015
|
+
pictureHost = host;
|
|
1016
|
+
},
|
|
1017
|
+
pictureSource: () => {
|
|
1018
|
+
const host = pictureHost;
|
|
1019
|
+
if (!host) return null;
|
|
1020
|
+
index.update();
|
|
1021
|
+
const selected = selectedShapes();
|
|
1022
|
+
const picked = new Set(selected.map(({ id }) => id));
|
|
1023
|
+
for (const { id } of selected) for (const member of index.membersOf(id) ?? []) picked.add(member);
|
|
1024
|
+
const authored = isDocumentView(editor) ? void 0 : readAuthoredView(shapes);
|
|
1025
|
+
return {
|
|
1026
|
+
editor,
|
|
1027
|
+
host,
|
|
1028
|
+
layouts: [...index.layouts()].filter(({ id }) => selected.length === 0 || picked.has(id)).sort((a, b) => a.rank - b.rank),
|
|
1029
|
+
projection: authored && ("preview" in authored ? authored.preview : "proposed"),
|
|
1030
|
+
root
|
|
1031
|
+
};
|
|
1032
|
+
},
|
|
898
1033
|
renderWith: (next) => {
|
|
899
1034
|
({history, messages} = next);
|
|
900
1035
|
},
|
|
@@ -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) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../../htmlTypes-
|
|
3
|
-
import { _ as BasePlugin, ct as BlockInsertOptions } from "../../../core-
|
|
4
|
-
import { At as Plugin, tn as EditorElementProps } from "../../../index-
|
|
5
|
-
import { B as
|
|
6
|
-
import * as React
|
|
1
|
+
import { H as Descendant, Qo as PropertyJsonDescriptor, Si as Element, Vt as EditorJsonValue, Ws as SchemaElementPropertyDefinition, Zo as PropertyEnumDescriptor, _c as SchemaPropertyTypeChangePolicy, es as PropertyNumberDescriptor, eu as TxDeclaredMethod, gc as SchemaPropertySplitPolicy, hc as SchemaPropertyRole, is as PropertyStringDescriptor, j as ContentSlice, ls as PropertyValueOptions, oc as SchemaPropertyCopyPolicy, os as PropertyValueDescriptor, pc as SchemaPropertyLandingPolicy, ss as PropertyValueKind, xa as NodeKey } from "../../../index-DpltOCot-A2b3p3Eb.js";
|
|
2
|
+
import "../../../htmlTypes-cg_cWsaN.js";
|
|
3
|
+
import { _ as BasePlugin, ct as BlockInsertOptions } from "../../../core-ClHasORr.js";
|
|
4
|
+
import { At as Plugin, tn as EditorElementProps } from "../../../index-8WO2vI0U.js";
|
|
5
|
+
import { B as isBoardSize, C as BoardArrowEnd, E as isBoardArrowEnd, F as BoardPlace, G as BoardStyles, H as BOARD_ARROW_STYLES, I as BoardRestackDirection, L as BoardShapeInsertProps, M as BoardShapePlace, N as isBoardFramePlace, P as isBoardShapePlace, R as BoardSize, S as BoardArrowAnchor, T as BoardArrowSide, U as BOARD_STROKE_STYLES, V as isStackingKey, W as BoardStyleProperties, c as BoardStrokePoints, h as BoardGeo, k as BoardMemberEntry, l as isBoardStrokePoints, o as BoardInkPoint, s as BoardStrokePath, w as BoardArrowEnds, x as BoardArrowEndInput } from "../../../index-oIJAZxc2.js";
|
|
6
|
+
import * as React from "react";
|
|
7
7
|
import "rbush";
|
|
8
8
|
declare const BoardPlugin: Plugin<Readonly<{
|
|
9
9
|
readonly __pluginWritableProperties: Readonly<{
|
|
@@ -164,12 +164,34 @@ declare const BoardPlugin: Plugin<Readonly<{
|
|
|
164
164
|
}>>, Readonly<{
|
|
165
165
|
kind: 'types';
|
|
166
166
|
types: string[];
|
|
167
|
+
}>, Readonly<{
|
|
168
|
+
key: string;
|
|
169
|
+
map: (value: Readonly<{
|
|
170
|
+
x: number;
|
|
171
|
+
y: number;
|
|
172
|
+
}> | Readonly<{
|
|
173
|
+
frame: string;
|
|
174
|
+
frameOrigin: BoardPlace;
|
|
175
|
+
x: number;
|
|
176
|
+
y: number;
|
|
177
|
+
}>, renamed: (name: string) => string | undefined) => Readonly<{
|
|
178
|
+
x: number;
|
|
179
|
+
y: number;
|
|
180
|
+
}> | Readonly<{
|
|
181
|
+
frame: string;
|
|
182
|
+
frameOrigin: BoardPlace;
|
|
183
|
+
x: number;
|
|
184
|
+
y: number;
|
|
185
|
+
}>;
|
|
167
186
|
}>>;
|
|
168
187
|
readonly shapeId: SchemaElementPropertyDefinition<PropertyStringDescriptor<{
|
|
169
188
|
readonly generate: typeof import("nanoid").nanoid;
|
|
170
189
|
}>, Readonly<{
|
|
171
190
|
kind: 'types';
|
|
172
191
|
types: readonly string[];
|
|
192
|
+
}>, Readonly<{
|
|
193
|
+
key: string;
|
|
194
|
+
map: (value: string, renamed: (name: string) => string | undefined) => string;
|
|
173
195
|
}>>;
|
|
174
196
|
readonly size: SchemaElementPropertyDefinition<PropertyJsonDescriptor<Readonly<{
|
|
175
197
|
height: number;
|
|
@@ -198,6 +220,15 @@ declare const BoardPlugin: Plugin<Readonly<{
|
|
|
198
220
|
}>>, Readonly<{
|
|
199
221
|
kind: 'types';
|
|
200
222
|
types: string[];
|
|
223
|
+
}>, Readonly<{
|
|
224
|
+
key: string;
|
|
225
|
+
map: (value: Readonly<{
|
|
226
|
+
height: number;
|
|
227
|
+
width: number;
|
|
228
|
+
}>, renamed: (name: string) => string | undefined) => Readonly<{
|
|
229
|
+
height: number;
|
|
230
|
+
width: number;
|
|
231
|
+
}>;
|
|
201
232
|
}>>;
|
|
202
233
|
readonly zIndex: SchemaElementPropertyDefinition<PropertyStringDescriptor<{
|
|
203
234
|
readonly required: true;
|
|
@@ -206,6 +237,9 @@ declare const BoardPlugin: Plugin<Readonly<{
|
|
|
206
237
|
}>, Readonly<{
|
|
207
238
|
kind: 'types';
|
|
208
239
|
types: readonly string[];
|
|
240
|
+
}>, Readonly<{
|
|
241
|
+
key: string;
|
|
242
|
+
map: (value: string, renamed: (name: string) => string | undefined) => string;
|
|
209
243
|
}>>;
|
|
210
244
|
readonly framePlace?: Readonly<{
|
|
211
245
|
copy: SchemaPropertyCopyPolicy;
|
|
@@ -975,6 +1009,7 @@ declare const BoardPlugin: Plugin<Readonly<{
|
|
|
975
1009
|
readonly shape: (id: string) => BoardMemberEntry | null;
|
|
976
1010
|
readonly slice: (ids: readonly string[]) => ContentSlice | null;
|
|
977
1011
|
readonly shapes: (board: NodeKey) => BoardMemberEntry[];
|
|
1012
|
+
readonly strokePath: (id: string) => BoardStrokePath | null;
|
|
978
1013
|
};
|
|
979
1014
|
readonly readMiddleware: true;
|
|
980
1015
|
readonly update: {
|
|
@@ -1704,12 +1739,6 @@ declare const BoardImagePlugin: Plugin<Readonly<{
|
|
|
1704
1739
|
}>) => string | undefined>;
|
|
1705
1740
|
};
|
|
1706
1741
|
}>>;
|
|
1707
|
-
/** Where a stroke draws: an SVG path over a box of `width` by `height`. */
|
|
1708
|
-
type BoardStrokePath = Readonly<{
|
|
1709
|
-
height: number;
|
|
1710
|
-
path: string;
|
|
1711
|
-
width: number;
|
|
1712
|
-
}>;
|
|
1713
1742
|
/** Where an arrow draws: its two ends in board coordinates and the path between them. */
|
|
1714
1743
|
type BoardArrowPath = BoardArrowEnds & Readonly<{
|
|
1715
1744
|
path: string;
|
|
@@ -1967,6 +1996,12 @@ type BoardViewState = Readonly<{
|
|
|
1967
1996
|
* changes.
|
|
1968
1997
|
*/
|
|
1969
1998
|
selectedShapes: readonly BoardMemberEntry[];
|
|
1999
|
+
/**
|
|
2000
|
+
* Whether the board lands picture files from `upload`, a paste or a drop,
|
|
2001
|
+
* which needs a view that can write, the upload plugin, and an image shape
|
|
2002
|
+
* that holds both the upload draft and the image element.
|
|
2003
|
+
*/
|
|
2004
|
+
takesPictureFiles: boolean;
|
|
1970
2005
|
tool: BoardTool;
|
|
1971
2006
|
/**
|
|
1972
2007
|
* Whether the note, shape, frame and arrow tools stay picked after they add
|
|
@@ -2001,6 +2036,17 @@ type BoardViewActions = Readonly<{
|
|
|
2001
2036
|
* the selection, and the focused view says `toolLock` when it changes.
|
|
2002
2037
|
*/
|
|
2003
2038
|
setToolLocked: (locked: boolean) => void;
|
|
2039
|
+
/**
|
|
2040
|
+
* Upload each of `files` as an image shape, in a row centered on the view,
|
|
2041
|
+
* as one undo step, and select the shapes. The shapes land once the
|
|
2042
|
+
* pictures load. A landing that still waits lands nothing after another
|
|
2043
|
+
* landing starts, a key or press on the board, any paste, a document or
|
|
2044
|
+
* selection change, focus leaving the board, or the view turning read-only.
|
|
2045
|
+
* The upload plugin reports a file that is not a picture, and the pictures
|
|
2046
|
+
* beside it still land. An empty list changes nothing, and neither does a
|
|
2047
|
+
* view whose `takesPictureFiles` is false.
|
|
2048
|
+
*/
|
|
2049
|
+
upload: (files: readonly File[]) => void;
|
|
2004
2050
|
/** Zoom in to the next of 10, 25, 50, 100, 200, 400 and 800 percent around the view's center, as `+` does, and do nothing at 800. A focused board says the new zoom. */
|
|
2005
2051
|
zoomIn: () => void;
|
|
2006
2052
|
/** Zoom out to the next lower of 10, 25, 50, 100, 200, 400 and 800 percent around the view's center, as `-` does, and do nothing at 10. A focused board says the new zoom. */
|
|
@@ -2021,8 +2067,8 @@ type BoardViewActions = Readonly<{
|
|
|
2021
2067
|
*/
|
|
2022
2068
|
declare function BoardShape({ className, style, ...props }: EditorElementProps<typeof BoardArrowPlugin | typeof BoardFramePlugin | typeof BoardGeoPlugin | typeof BoardImagePlugin | typeof BoardNotePlugin | typeof BoardStrokePlugin> & {
|
|
2023
2069
|
className?: string;
|
|
2024
|
-
style?: React
|
|
2025
|
-
}): React
|
|
2070
|
+
style?: React.CSSProperties;
|
|
2071
|
+
}): React.JSX.Element;
|
|
2026
2072
|
/**
|
|
2027
2073
|
* Where the board arrow `element` draws: its two ends in board coordinates,
|
|
2028
2074
|
* each bound end stopped at its shape's outline, and the path between them.
|
|
@@ -2083,12 +2129,12 @@ declare const useStrokePath: (element: Element) => BoardStrokePath | undefined;
|
|
|
2083
2129
|
* `height`; it never changes the document.
|
|
2084
2130
|
*/
|
|
2085
2131
|
declare function BoardSurface({ height, messages, toolbar, ...props }: EditorElementProps<typeof BoardPlugin> & {
|
|
2086
|
-
height?: React
|
|
2132
|
+
height?: React.CSSProperties['height'];
|
|
2087
2133
|
messages: BoardMessages;
|
|
2088
|
-
toolbar?: React
|
|
2089
|
-
}): React
|
|
2134
|
+
toolbar?: React.ReactNode;
|
|
2135
|
+
}): React.JSX.Element;
|
|
2090
2136
|
/** Read the surrounding board view's state, such as its tool. */
|
|
2091
2137
|
declare const useBoardView: <T>(selector: (view: BoardViewState) => T) => T;
|
|
2092
2138
|
/** Change the surrounding board view's tool, next style and camera. */
|
|
2093
2139
|
declare const useBoardActions: () => BoardViewActions;
|
|
2094
|
-
export { type BoardArrowPath, BoardArrowPlugin, type BoardCamera, type BoardCorner, BoardFramePlugin, BoardGeoPlugin, BoardImagePlugin, type BoardMessages, BoardNotePlugin, type BoardPickState, BoardPlugin, BoardShape, type BoardShapeDescription,
|
|
2140
|
+
export { type BoardArrowPath, BoardArrowPlugin, type BoardCamera, type BoardCorner, BoardFramePlugin, BoardGeoPlugin, BoardImagePlugin, type BoardMessages, BoardNotePlugin, type BoardPickState, BoardPlugin, BoardShape, type BoardShapeDescription, BoardStrokePlugin, type BoardStyle, BoardSurface, type BoardTool, type BoardViewActions, type BoardViewState, useArrowPath, useBoardActions, useBoardView, useStrokePath };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Vt as EditorJsonValue, is as PropertyStringDescriptor, ls as PropertyValueOptions } from "../../../index-DpltOCot-A2b3p3Eb.js";
|
|
2
|
+
import "../../../htmlTypes-cg_cWsaN.js";
|
|
3
|
+
import { At as Plugin } from "../../../index-8WO2vI0U.js";
|
|
3
4
|
declare const CalloutPlugin: Plugin<Readonly<{
|
|
4
5
|
formats: true;
|
|
5
6
|
rules: true;
|