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.
Files changed (237) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +56 -0
  3. package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DY104TqL.d.ts} +2 -2
  4. package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-Deo6n6Fs.d.ts} +7 -3
  5. package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-CJX5bKuv.d.ts} +7 -7
  6. package/dist/ai/index.d.ts +1 -1
  7. package/dist/ai/react/AIChatPlugin.js +113 -78
  8. package/dist/ai/react/CopilotPlugin.js +1 -1
  9. package/dist/ai/react/index.d.ts +23 -16
  10. package/dist/authored/index.d.ts +4 -4
  11. package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
  12. package/dist/code-block/codemirror/index.d.ts +1 -1
  13. package/dist/{combobox-DkBGgyd3.d.ts → combobox-DAOYWuvC.d.ts} +2 -2
  14. package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-Dt-unJZY-DCddmbSD.d.ts} +10 -2
  15. package/dist/compiler/index.d.ts +2 -2
  16. package/dist/{core-BJG8l_mk.d.ts → core-ClHasORr.d.ts} +433 -95
  17. package/dist/diff/index.d.ts +2 -2
  18. package/dist/docs/ai.md +4 -3
  19. package/dist/docs/api/core/plate-components.md +0 -19
  20. package/dist/docs/api/core/plate-controller.md +4 -2
  21. package/dist/docs/api/core/plate-plugin.md +3 -0
  22. package/dist/docs/api/core/plate-store.md +3 -3
  23. package/dist/docs/api/dom.md +14 -4
  24. package/dist/docs/api/editor-transforms.md +2 -1
  25. package/dist/docs/api/react-hooks.md +25 -11
  26. package/dist/docs/authored-changes.md +5 -2
  27. package/dist/docs/basic-blocks.md +42 -29
  28. package/dist/docs/blockquote.md +5 -3
  29. package/dist/docs/board.md +63 -8
  30. package/dist/docs/code-block.md +47 -0
  31. package/dist/docs/discussion.md +1 -1
  32. package/dist/docs/docx.md +1 -1
  33. package/dist/docs/dom-coverage.md +5 -0
  34. package/dist/docs/examples/editable-voids.md +2 -3
  35. package/dist/docs/external-text.md +2 -0
  36. package/dist/docs/field.md +370 -0
  37. package/dist/docs/find.md +9 -6
  38. package/dist/docs/form.md +2 -0
  39. package/dist/docs/heading.md +6 -0
  40. package/dist/docs/installation/manual.md +0 -4
  41. package/dist/docs/link.md +3 -3
  42. package/dist/docs/llms.txt +4 -2
  43. package/dist/docs/markdown.md +176 -8
  44. package/dist/docs/plugin-components.md +13 -10
  45. package/dist/docs/plugin-input-rules.md +4 -12
  46. package/dist/docs/prompt-editor.md +205 -0
  47. package/dist/docs/roots.md +8 -6
  48. package/dist/docs/rtl.md +6 -4
  49. package/dist/docs/selection.md +7 -4
  50. package/dist/docs/suggestion.md +1 -1
  51. package/dist/docs/toolbar.md +26 -30
  52. package/dist/docs/upload.md +106 -17
  53. package/dist/docx/export/index.d.ts +3 -3
  54. package/dist/docx/export/lib/docxStaticComponents.js +12 -2
  55. package/dist/docx/export/lib/exportDocx.js +29 -5
  56. package/dist/docx/export/lib/reviewPart.js +1 -1
  57. package/dist/docx/export/lib/reviewProjection.js +10 -8
  58. package/dist/docx/import/index.d.ts +4 -4
  59. package/dist/docx/paste/index.d.ts +4 -4
  60. package/dist/dom/index.d.ts +1 -6
  61. package/dist/dom/plite-dom.internal.js +2 -2
  62. package/dist/excalidraw/index.d.ts +3 -2
  63. package/dist/excalidraw/react/index.d.ts +3 -2
  64. package/dist/facade.js +2 -2
  65. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
  66. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
  67. package/dist/features/board/index.d.ts +2 -2
  68. package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
  69. package/dist/features/board/lib/boardStroke.internal.js +13 -1
  70. package/dist/features/board/lib/boardTypes.internal.js +16 -0
  71. package/dist/features/callout/index.d.ts +3 -2
  72. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
  73. package/dist/features/combobox/index.d.ts +2 -2
  74. package/dist/features/comments/index.d.ts +1 -1
  75. package/dist/features/date/index.d.ts +3 -2
  76. package/dist/features/details/index.d.ts +3 -2
  77. package/dist/features/details/lib/BaseDetailsPlugin.js +10 -10
  78. package/dist/features/field/index.d.ts +2 -0
  79. package/dist/features/field/index.js +2 -0
  80. package/dist/features/field/lib/BaseFieldPlugin.js +414 -0
  81. package/dist/features/field/lib/fieldRules.internal.js +42 -0
  82. package/dist/features/find/index.d.ts +3 -2
  83. package/dist/features/footnote/index.d.ts +1 -1
  84. package/dist/features/ink/index.d.ts +1 -1
  85. package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
  86. package/dist/features/ink/lib/inkCodec.internal.js +130 -0
  87. package/dist/features/ink/lib/inkGone.internal.js +229 -48
  88. package/dist/features/ink/lib/inkPlaces.internal.js +533 -62
  89. package/dist/features/layout/index.d.ts +1 -1
  90. package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
  91. package/dist/features/lint/index.d.ts +3 -2
  92. package/dist/features/media/index.d.ts +1 -1
  93. package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
  94. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +6 -2
  95. package/dist/features/mention/index.d.ts +5 -4
  96. package/dist/features/suggestion/index.d.ts +1 -1
  97. package/dist/features/table/index.d.ts +1 -1
  98. package/dist/features/table/lib/BaseTablePlugin.js +14 -8
  99. package/dist/features/table/lib/internal/selection.js +4 -2
  100. package/dist/features/toc/index.d.ts +1 -1
  101. package/dist/features/upload/index.d.ts +2 -2
  102. package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
  103. package/dist/history/index.d.ts +2 -2
  104. package/dist/html/index.d.ts +3 -3
  105. package/dist/html/server/index.d.ts +1 -1
  106. package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-cg_cWsaN.d.ts} +2 -31
  107. package/dist/hyperscript/index.d.ts +1 -1
  108. package/dist/{index-D1CFXA-i.d.ts → index-8WO2vI0U.d.ts} +475 -143
  109. package/dist/{index-DaM37gF6.d.ts → index-B5mYEawV.d.ts} +37 -21
  110. package/dist/{index-Bq3sdm3S.d.ts → index-BZWFoUXt.d.ts} +5 -4
  111. package/dist/{index-DdIRduDG.d.ts → index-C0POz7rg.d.ts} +3 -2
  112. package/dist/{index-Bxfvicyy.d.ts → index-C1_JIhL4.d.ts} +4 -3
  113. package/dist/{index-DC_MNGyu.d.ts → index-C35V_hj0.d.ts} +3 -3
  114. package/dist/{index-kLKMc-pI.d.ts → index-C6ql9pKw.d.ts} +2 -2
  115. package/dist/{index-hsC_sOn2.d.ts → index-C9DiGDVj.d.ts} +35 -5
  116. package/dist/{index-DTgaSxKr.d.ts → index-CLsEe3LY.d.ts} +40 -4
  117. package/dist/{index-CT7miqQN.d.ts → index-CdOLsPaW.d.ts} +29 -9
  118. package/dist/{index-DLA2DUR2.d.ts → index-CktYvOgk.d.ts} +4 -3
  119. package/dist/{index-BBKGrsG3.d.ts → index-Cmuluh6f.d.ts} +1 -1
  120. package/dist/{index-BiQerPJS.d.ts → index-CzLwBZpY.d.ts} +2 -2
  121. package/dist/{index-DzD6BIFJ.d.ts → index-D3-2iM1b.d.ts} +7 -5
  122. package/dist/{index-Cl77E9yr.d.ts → index-DKOFvteF.d.ts} +2 -2
  123. package/dist/{index-iaZOhA76.d.ts → index-DPWyk3lG-DOYwohXO.d.ts} +1 -1
  124. package/dist/index-DQnjqtQa.d.ts +678 -0
  125. package/dist/{index-CcZbqPqk.d.ts → index-Do9pj1GK.d.ts} +73 -39
  126. package/dist/{index-BU6k1Aev.d.ts → index-DpltOCot-A2b3p3Eb.d.ts} +4735 -4586
  127. package/dist/{index-Bc2Yg_2j.d.ts → index-HPYawTae-BCUQLEWF.d.ts} +2 -2
  128. package/dist/{index-BkR7-GLI.d.ts → index-baQOK89E.d.ts} +2 -2
  129. package/dist/{index-D5W-p9bS.d.ts → index-oIJAZxc2.d.ts} +49 -4
  130. package/dist/{index-xdmCBvlT.d.ts → index-r7yb77Wy.d.ts} +3 -2
  131. package/dist/index.d.ts +4 -4
  132. package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
  133. package/dist/internal/plugin/OverridePlugin.js +101 -119
  134. package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
  135. package/dist/internal/plugin/pastedUploadFiles.js +4 -0
  136. package/dist/internal/plugin/resolvePlugin.js +1 -1
  137. package/dist/internal/plugin/resolvePlugins.js +3 -0
  138. package/dist/internal/plugin/uploadDrafts.js +6 -0
  139. package/dist/internal/utils/mergePlugins.js +1 -0
  140. package/dist/lib/plugins/element-id/ElementIdPlugin.js +8 -2
  141. package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
  142. package/dist/lib/plugins/html/htmlSafety.js +1 -1
  143. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +5 -15
  144. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
  145. package/dist/markdown/index.d.ts +2 -2
  146. package/dist/markdown/index.js +2 -1
  147. package/dist/markdown/lib/MarkdownPlugin.js +16 -9
  148. package/dist/markdown/lib/RawHtmlPlugin.js +24 -0
  149. package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
  150. package/dist/markdown/lib/internal/markdownConversion.js +773 -74
  151. package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
  152. package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
  153. package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
  154. package/dist/markdown/lib/internal/markdownLine.js +5 -3
  155. package/dist/markdown/lib/internal/markdownMappings.js +19 -7
  156. package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
  157. package/dist/markdown/lib/internal/markdownRawHtml.js +314 -0
  158. package/dist/markdown/lib/internal/markdownSegments.js +57 -48
  159. package/dist/markdown/lib/internal/markdownTags.js +22 -8
  160. package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
  161. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
  162. package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
  163. package/dist/math/index.d.ts +3 -2
  164. package/dist/math/react/index.d.ts +4 -3
  165. package/dist/migrations/index.d.ts +3 -3
  166. package/dist/pagination/index.d.ts +1 -1
  167. package/dist/pagination/react/index.d.ts +4 -4
  168. package/dist/react/components/EditorContentView.internal.js +17 -8
  169. package/dist/react/components/EditorProvider.js +5 -5
  170. package/dist/react/components/Plate.js +103 -122
  171. package/dist/react/components/PlateContainer.js +40 -32
  172. package/dist/react/components/PlateController.js +28 -16
  173. package/dist/react/components/PlateRoot.internal.js +3 -2
  174. package/dist/react/core.js +4 -4
  175. package/dist/react/features/board/BoardSurface.js +116 -87
  176. package/dist/react/features/board/boardClipboard.internal.js +15 -5
  177. package/dist/react/features/board/boardGesture.internal.js +6 -3
  178. package/dist/react/features/board/boardIndex.internal.js +7 -18
  179. package/dist/react/features/board/boardPictures.internal.js +19 -13
  180. package/dist/react/features/board/boardView.internal.js +184 -49
  181. package/dist/react/features/board/boardVoice.internal.js +10 -11
  182. package/dist/react/features/board/index.d.ts +64 -18
  183. package/dist/react/features/callout/index.d.ts +3 -2
  184. package/dist/react/features/combobox/index.d.ts +8 -8
  185. package/dist/react/features/comments/index.d.ts +6 -5
  186. package/dist/react/features/date/index.d.ts +4 -3
  187. package/dist/react/features/details/index.d.ts +4 -3
  188. package/dist/react/features/field/FieldPlugin.js +34 -0
  189. package/dist/react/features/field/index.d.ts +312 -0
  190. package/dist/react/features/field/index.js +2 -0
  191. package/dist/react/features/footnote/index.d.ts +7 -6
  192. package/dist/react/features/format-painter/index.d.ts +4 -3
  193. package/dist/react/features/ink/InkContent.js +313 -0
  194. package/dist/react/features/ink/index.d.ts +57 -29
  195. package/dist/react/features/ink/index.js +2 -2
  196. package/dist/react/features/ink/inkCapture.internal.js +39 -17
  197. package/dist/react/features/ink/inkInput.internal.js +1 -1
  198. package/dist/react/features/ink/inkLayout.internal.js +6 -3
  199. package/dist/react/features/ink/inkPaint.internal.js +78 -2
  200. package/dist/react/features/ink/inkPlacement.internal.js +331 -104
  201. package/dist/react/features/ink/inkWatch.internal.js +7 -5
  202. package/dist/react/features/layout/index.d.ts +5 -4
  203. package/dist/react/features/media/index.d.ts +5 -4
  204. package/dist/react/features/mention/index.d.ts +6 -5
  205. package/dist/react/features/resizable/Resizable.js +4 -6
  206. package/dist/react/features/resizable/index.d.ts +5 -5
  207. package/dist/react/features/suggestion/index.d.ts +6 -5
  208. package/dist/react/features/table/TablePlugin.js +4 -11
  209. package/dist/react/features/table/index.d.ts +8 -7
  210. package/dist/react/features/toc/index.d.ts +2 -2
  211. package/dist/react/features/upload/index.d.ts +11 -6
  212. package/dist/react/index.d.ts +6 -6
  213. package/dist/react/index.js +4 -4
  214. package/dist/react/internal/plate-context.js +425 -188
  215. package/dist/react/plite-react.js +2 -2
  216. package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
  217. package/dist/react/stores/plate/useEditor.js +32 -14
  218. package/dist/react/stores/plate/useEditorHistory.js +55 -0
  219. package/dist/react/stores/plate/useEditorSelector.js +66 -21
  220. package/dist/react/utils/pipeRenderElement.internal.js +1 -1
  221. package/dist/react/utils/pluginRenderElement.internal.js +1 -1
  222. package/dist/react/virtualized.d.ts +4 -4
  223. package/dist/{source-CNKy99Th.d.ts → source-aUwpNnAw.d.ts} +4 -4
  224. package/dist/static/index.d.ts +18 -18
  225. package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
  226. package/dist/static/internal/staticPresentation.js +4 -4
  227. package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
  228. package/dist/tabbable/index.d.ts +1 -1
  229. package/dist/tabbable/react/index.d.ts +3 -3
  230. package/dist/testing/index.d.ts +3 -3
  231. package/dist/yjs/index.d.ts +1 -1
  232. package/dist/yjs/react/index.d.ts +6 -6
  233. package/package.json +20 -2
  234. package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
  235. package/dist/react/components/EditorSelectionView.js +0 -40
  236. package/dist/react/features/ink/InkLayer.js +0 -218
  237. package/dist/react/internal/createPlateTargetScope.js +0 -62
@@ -1,5 +1,6 @@
1
- import { useEditorHistory, useElementSelected, useRootEditor } from "../../plite-react.js";
1
+ import { useElementSelected, useRootEditor } from "../../plite-react.js";
2
2
  import { useEditor, useModelEditor } from "../../stores/plate/useEditor.js";
3
+ import { useEditorHistory } from "../../stores/plate/useEditorHistory.js";
3
4
  import { EditorElement } from "../../components/plate-nodes.js";
4
5
  import { BOARD_SHAPES_SLOT } from "../../../features/board/lib/boardShape.internal.js";
5
6
  import { keepToolbarArrowFromBrowser } from "./boardKeys.internal.js";
@@ -51,7 +52,7 @@ import { c } from "react/compiler-runtime";
51
52
  * `height`; it never changes the document.
52
53
  */
53
54
  function BoardSurface(t0) {
54
- const $ = c(33);
55
+ const $ = c(37);
55
56
  const { height, messages, toolbar, ...props } = t0;
56
57
  const { element } = props;
57
58
  const editor = useModelEditor();
@@ -68,145 +69,166 @@ function BoardSurface(t0) {
68
69
  } else t1 = $[1];
69
70
  const attach = t1;
70
71
  let t2;
71
- if ($[2] !== mounted) {
72
- t2 = { editor: mounted };
73
- $[2] = mounted;
72
+ if ($[2] !== view) {
73
+ t2 = (host) => view.holdPictureHost(host);
74
+ $[2] = view;
74
75
  $[3] = t2;
75
76
  } else t2 = $[3];
76
- const history = useEditorHistory(t2);
77
+ const holdPictureHost = t2;
77
78
  let t3;
78
- if ($[4] !== view) {
79
- t3 = () => view.state().tool === "hand";
80
- $[4] = view;
79
+ if ($[4] !== mounted) {
80
+ t3 = { editor: mounted };
81
+ $[4] = mounted;
81
82
  $[5] = t3;
82
83
  } else t3 = $[5];
83
- const readHand = t3;
84
- const hand = React$1.useSyncExternalStore(view.subscribe, readHand, readHand);
84
+ const history = useEditorHistory(t3);
85
85
  let t4;
86
+ if ($[6] !== view) {
87
+ t4 = () => view.state().tool === "hand";
88
+ $[6] = view;
89
+ $[7] = t4;
90
+ } else t4 = $[7];
91
+ const readHand = t4;
92
+ const hand = React$1.useSyncExternalStore(view.subscribe, readHand, readHand);
86
93
  let t5;
87
- if ($[6] !== history || $[7] !== messages || $[8] !== view) {
88
- t4 = () => view.renderWith({
94
+ let t6;
95
+ if ($[8] !== history || $[9] !== messages || $[10] !== view) {
96
+ t5 = () => view.renderWith({
89
97
  history,
90
98
  messages
91
99
  });
92
- t5 = [
100
+ t6 = [
93
101
  history,
94
102
  messages,
95
103
  view
96
104
  ];
97
- $[6] = history;
98
- $[7] = messages;
99
- $[8] = view;
100
- $[9] = t4;
101
- $[10] = t5;
105
+ $[8] = history;
106
+ $[9] = messages;
107
+ $[10] = view;
108
+ $[11] = t5;
109
+ $[12] = t6;
102
110
  } else {
103
- t4 = $[9];
104
- t5 = $[10];
111
+ t5 = $[11];
112
+ t6 = $[12];
105
113
  }
106
- React$1.useLayoutEffect(t4, t5);
107
- let t6;
114
+ React$1.useLayoutEffect(t5, t6);
108
115
  let t7;
109
- if ($[11] !== view) {
110
- t6 = () => view.connect();
111
- t7 = [view];
112
- $[11] = view;
113
- $[12] = t6;
114
- $[13] = t7;
116
+ let t8;
117
+ if ($[13] !== view) {
118
+ t7 = () => view.connect();
119
+ t8 = [view];
120
+ $[13] = view;
121
+ $[14] = t7;
122
+ $[15] = t8;
115
123
  } else {
116
- t6 = $[12];
117
- t7 = $[13];
124
+ t7 = $[14];
125
+ t8 = $[15];
118
126
  }
119
- React$1.useEffect(t6, t7);
120
- const t8 = hand ? "grab" : void 0;
121
- const t9 = height ?? element.height;
122
- let t10;
123
- if ($[14] !== t8 || $[15] !== t9) {
124
- t10 = {
125
- cursor: t8,
126
- height: t9,
127
+ React$1.useEffect(t7, t8);
128
+ const t9 = hand ? "grab" : void 0;
129
+ const t10 = height ?? element.height;
130
+ let t11;
131
+ if ($[16] !== t10 || $[17] !== t9) {
132
+ t11 = {
133
+ cursor: t9,
134
+ height: t10,
127
135
  overflow: "clip",
128
136
  position: "relative",
129
137
  touchAction: "none"
130
138
  };
131
- $[14] = t8;
132
- $[15] = t9;
133
139
  $[16] = t10;
134
- } else t10 = $[16];
135
- const t11 = "";
136
- const t12 = view.takeTextTab;
137
- let t13;
140
+ $[17] = t9;
141
+ $[18] = t11;
142
+ } else t11 = $[18];
143
+ const t12 = "";
144
+ const t13 = view.takeTextTab;
138
145
  let t14;
139
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
140
- t13 = {
146
+ let t15;
147
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
148
+ t14 = {
141
149
  left: 0,
142
150
  position: "absolute",
143
151
  top: 0,
144
152
  transformOrigin: "0 0",
145
153
  willChange: "transform"
146
154
  };
147
- t14 = {
155
+ t15 = {
148
156
  left: 0,
149
157
  position: "absolute",
150
158
  top: 0,
151
159
  transformOrigin: "0 0"
152
160
  };
153
- $[17] = t13;
154
- $[18] = t14;
161
+ $[19] = t14;
162
+ $[20] = t15;
155
163
  } else {
156
- t13 = $[17];
157
- t14 = $[18];
164
+ t14 = $[19];
165
+ t15 = $[20];
158
166
  }
159
- const t15 = props.slots.contentRoot(BOARD_SHAPES_SLOT, {
167
+ const t16 = props.slots.contentRoot(BOARD_SHAPES_SLOT, {
160
168
  ariaLabel: messages.label,
161
169
  nodeSelectionFocus: view.focusTarget,
162
170
  tabIndex: -1,
163
171
  viewport
164
172
  });
165
- let t16;
166
- if ($[19] !== t14 || $[20] !== t15) {
167
- t16 = /* @__PURE__ */ React$1.createElement("div", { style: t14 }, t15);
168
- $[19] = t14;
169
- $[20] = t15;
170
- $[21] = t16;
171
- } else t16 = $[21];
172
173
  let t17;
173
- if ($[22] !== attach || $[23] !== t13 || $[24] !== t16 || $[25] !== view.takeTextTab) {
174
- t17 = /* @__PURE__ */ React$1.createElement("div", {
175
- "data-board-layer": t11,
174
+ if ($[21] !== t15 || $[22] !== t16) {
175
+ t17 = /* @__PURE__ */ React$1.createElement("div", { style: t15 }, t16);
176
+ $[21] = t15;
177
+ $[22] = t16;
178
+ $[23] = t17;
179
+ } else t17 = $[23];
180
+ let t18;
181
+ if ($[24] !== attach || $[25] !== t14 || $[26] !== t17 || $[27] !== view.takeTextTab) {
182
+ t18 = /* @__PURE__ */ React$1.createElement("div", {
183
+ "data-board-layer": t12,
176
184
  ref: attach,
177
- onKeyDown: t12,
178
- style: t13
179
- }, t16);
180
- $[22] = attach;
181
- $[23] = t13;
182
- $[24] = t16;
183
- $[25] = view.takeTextTab;
185
+ onKeyDown: t13,
186
+ style: t14
187
+ }, t17);
188
+ $[24] = attach;
189
+ $[25] = t14;
184
190
  $[26] = t17;
185
- } else t17 = $[26];
186
- let t18;
187
- if ($[27] !== messages.instructions || $[28] !== messages.label || $[29] !== view.focusTarget) {
188
- t18 = /* @__PURE__ */ React$1.createElement(BoardFocusTarget, {
191
+ $[27] = view.takeTextTab;
192
+ $[28] = t18;
193
+ } else t18 = $[28];
194
+ let t19;
195
+ if ($[29] !== messages.instructions || $[30] !== messages.label || $[31] !== view.focusTarget) {
196
+ t19 = /* @__PURE__ */ React$1.createElement(BoardFocusTarget, {
189
197
  focusRef: view.focusTarget,
190
198
  instructions: messages.instructions,
191
199
  label: messages.label
192
200
  });
193
- $[27] = messages.instructions;
194
- $[28] = messages.label;
195
- $[29] = view.focusTarget;
196
- $[30] = t18;
197
- } else t18 = $[30];
198
- let t19;
199
- if ($[31] !== toolbar) {
200
- t19 = toolbar && /* @__PURE__ */ React$1.createElement("div", {
201
+ $[29] = messages.instructions;
202
+ $[30] = messages.label;
203
+ $[31] = view.focusTarget;
204
+ $[32] = t19;
205
+ } else t19 = $[32];
206
+ let t20;
207
+ if ($[33] !== holdPictureHost) {
208
+ t20 = /* @__PURE__ */ React$1.createElement("div", {
209
+ "aria-hidden": true,
210
+ contentEditable: false,
211
+ "data-board-picture-host": "",
212
+ "data-editor-root-chrome-ignore": "true",
213
+ inert: true,
214
+ ref: holdPictureHost,
215
+ style: PICTURE_HOST
216
+ });
217
+ $[33] = holdPictureHost;
218
+ $[34] = t20;
219
+ } else t20 = $[34];
220
+ let t21;
221
+ if ($[35] !== toolbar) {
222
+ t21 = toolbar && /* @__PURE__ */ React$1.createElement("div", {
201
223
  contentEditable: false,
202
224
  "data-board-toolbar": "",
203
225
  role: "presentation",
204
226
  style: { cursor: "default" },
205
227
  onKeyDown: keepToolbarArrowFromBrowser
206
228
  }, toolbar);
207
- $[31] = toolbar;
208
- $[32] = t19;
209
- } else t19 = $[32];
229
+ $[35] = toolbar;
230
+ $[36] = t21;
231
+ } else t21 = $[36];
210
232
  return /* @__PURE__ */ React$1.createElement(BoardViewContext.Provider, { value: view }, /* @__PURE__ */ React$1.createElement(EditorElement, {
211
233
  ...props,
212
234
  attributes: {
@@ -214,9 +236,16 @@ function BoardSurface(t0) {
214
236
  "data-board": view.root,
215
237
  "data-selected": selected || void 0
216
238
  },
217
- style: t10
218
- }, t17, t18, t19, props.children));
239
+ style: t11
240
+ }, t18, t19, t20, t21, props.children));
219
241
  }
242
+ const PICTURE_HOST = {
243
+ left: 0,
244
+ opacity: 0,
245
+ pointerEvents: "none",
246
+ position: "absolute",
247
+ top: 0
248
+ };
220
249
  const WITHOUT_OWN_FOCUS_RING = {
221
250
  clipPath: "inset(50%)",
222
251
  height: 0,
@@ -1,5 +1,6 @@
1
1
  import { ElementApi } from "../../../core.js";
2
2
  import { BaseBoardImagePlugin } from "../../../features/board/lib/BaseBoardImagePlugin.js";
3
+ import { pastedUploadFiles } from "../../../internal/plugin/pastedUploadFiles.js";
3
4
  import { readImageLink } from "../../../internal/plugin/imageLink.js";
4
5
  import { activeElementOf } from "./boardVoice.internal.js";
5
6
  //#region src/react/features/board/boardClipboard.internal.ts
@@ -49,16 +50,25 @@ const attachBoardClipboard = (host, core) => {
49
50
  const onTarget = !!target && target === core.focusTarget.current;
50
51
  const onBoard = onTarget || !!hover && editor.api.dom.hasEditableTarget(target) && (host.contains(target) || target.contains(host));
51
52
  if (!event.clipboardData || !onBoard) return;
52
- const read = editor.api.dom.clipboard.readSlice(event.clipboardData);
53
+ const data = event.clipboardData;
54
+ const read = editor.api.dom.clipboard.readSlice(data);
55
+ const holdsFiles = data.files.length > 0 && read.kind !== "slice";
56
+ if (holdsFiles && !onTarget) return;
53
57
  core.measure();
54
- const pictures = read.kind !== "slice" && !core.editedShape() && core.writable() && editor.plugin(BaseBoardImagePlugin).installed ? picturesIn(event.clipboardData) : void 0;
55
- if (pictures) {
58
+ const point = hover ? core.boardPointAt(hover) : core.viewCenter();
59
+ const open = read.kind !== "slice" && !core.editedShape();
60
+ const pictures = open && core.writable() && editor.plugin(BaseBoardImagePlugin).installed ? picturesIn(data) : void 0;
61
+ const takesFiles = open && core.takesPictureFiles();
62
+ const fallbackFiles = takesFiles && pictures ? Array.from(data.files) : [];
63
+ const pictureFiles = takesFiles && !pictures ? pastedUploadFiles(data) : [];
64
+ if (pictures || pictureFiles.length > 0) {
56
65
  event.preventDefault();
57
66
  event.stopPropagation();
58
- core.landPictures(pictures, hover ? core.boardPointAt(hover) : core.viewCenter());
67
+ if (pictures) core.landPictures(pictures, point, fallbackFiles);
68
+ else core.landPictureFiles(pictureFiles, point);
59
69
  return;
60
70
  }
61
- if (!((read.kind === "slice" ? core.land(read.slice, hover ? core.boardPointAt(hover) : void 0) : onTarget && core.selectedShapes().length > 0 && core.paste(event.clipboardData)) || onTarget)) return;
71
+ if (!((read.kind === "slice" ? core.land(read.slice, hover ? core.boardPointAt(hover) : void 0) : onTarget && !holdsFiles && (core.selectedShapes().length > 0 && core.paste(data) || open && data.getData("text/plain").trim() !== "" && core.pasteNote(data, point))) || onTarget)) return;
62
72
  event.preventDefault();
63
73
  event.stopPropagation();
64
74
  };
@@ -1,7 +1,8 @@
1
1
  import { BaseBoardArrowPlugin } from "../../../features/board/lib/BaseBoardArrowPlugin.js";
2
+ import { simulatedPressure, strokeOutline } from "../../../internal/penStroke.internal.js";
2
3
  import { BOARD_PEN } from "../../../features/board/lib/boardStroke.internal.js";
3
4
  import { BaseBoardStrokePlugin } from "../../../features/board/lib/BaseBoardStrokePlugin.js";
4
- import { simulatedPressure, strokeOutline } from "../../internal/penStroke.internal.js";
5
+ import { boardTypesOf } from "../../../features/board/lib/boardTypes.internal.js";
5
6
  import { CORNERS_CLOCKWISE, draggedBox, resized, sameBox, spanOf } from "./boardIndex.internal.js";
6
7
  import { BOARD_PLACE_SIZE, arrowEndOn } from "./boardPick.internal.js";
7
8
  import { drawGuides, elementOf, placeElement, previewArrowLine, previewCopy, previewGuides, previewPlaceOutline, previewSelectBox, previewStroke } from "./boardPreview.internal.js";
@@ -241,7 +242,7 @@ const attachBoardGestures = (host, core, spaceHeld) => {
241
242
  return;
242
243
  }
243
244
  if (done.kind === "pen") core.write((tx) => tx.plugin(BaseBoardStrokePlugin).insert({
244
- ...core.styleFor(BaseBoardStrokePlugin.name, done.style),
245
+ ...core.styleFor(boardTypesOf(core.editor).stroke(), done.style),
245
246
  points: done.points
246
247
  }, { board: core.board }));
247
248
  else if (done.kind === "arrow") {
@@ -331,6 +332,7 @@ const attachBoardGestures = (host, core, spaceHeld) => {
331
332
  gesture = pan(pointer, pointerId);
332
333
  } else if (selecting && shapeElement && shape && handle) {
333
334
  if (!core.writable()) return;
335
+ core.focusBoard();
334
336
  gesture = {
335
337
  corner: handle,
336
338
  element: shapeElement,
@@ -357,7 +359,8 @@ const attachBoardGestures = (host, core, spaceHeld) => {
357
359
  if (event.shiftKey) {
358
360
  moving = held ? [] : [...selected, shape];
359
361
  core.toggleSelected(shape.key);
360
- } else if (!held) core.select([shape.key]);
362
+ } else if (held) core.focusBoard();
363
+ else core.select([shape.key]);
361
364
  const ids = new Set(moving.map(({ id }) => id));
362
365
  const carried = new Set(ids);
363
366
  for (const id of ids) for (const member of index.membersOf(id) ?? []) carried.add(member);
@@ -1,10 +1,8 @@
1
1
  import { ElementApi } from "../../../core.js";
2
- import "../../../features/board/lib/boardShape.internal.js";
3
2
  import { ARROW_SIDES, boardArrowTargetOf, boardOutlineOf, isBoundArrowEnd, resolveBoardArrow } from "../../../features/board/lib/boardArrow.internal.js";
4
- import { BOARD_PEN, BOARD_STROKE_REACH, BOARD_STROKE_TYPE, boardInkIn } from "../../../features/board/lib/boardStroke.internal.js";
3
+ import { BOARD_STROKE_REACH, boardInkIn, boardStrokePath, boardStrokePointsOf } from "../../../features/board/lib/boardStroke.internal.js";
5
4
  import { paintKeyOf, paintOrder } from "../../../features/board/lib/boardCopy.internal.js";
6
5
  import { flooredSizeKeepingRatio } from "../../../features/board/lib/boardRatio.internal.js";
7
- import { strokeOutline } from "../../internal/penStroke.internal.js";
8
6
  import { lineSide, onInk, segmentGap } from "./boardInk.internal.js";
9
7
  import RBush from "rbush";
10
8
  //#region src/react/features/board/boardIndex.internal.ts
@@ -88,8 +86,6 @@ const resized = (start, corner, dx, dy, { center, keepRatio }) => {
88
86
  y: top ? start.y + (start.height - height) : start.y
89
87
  };
90
88
  };
91
- const isStroke = (entry) => entry.node.type === BOARD_STROKE_TYPE;
92
- const inkOf = (entry) => isStroke(entry) && Array.isArray(entry.node.points) ? entry.node.points : void 0;
93
89
  const sameInk = (a, b) => a === b || a.length === b.length && a.every((value, at) => value === b[at]);
94
90
  const drawnInk = /* @__PURE__ */ new WeakMap();
95
91
  const inkOnBoard = (layout, ink) => {
@@ -107,7 +103,7 @@ const inOutline = (outline, at) => {
107
103
  return !sides.has(1) || !sides.has(-1);
108
104
  };
109
105
  const outlineAlong = (outline, from, to, slop, solid) => outline.some((start, at) => segmentGap(from, to, start, outline[(at + 1) % outline.length]) <= slop) || (inOutline(outline, from) || inOutline(outline, to)) && solid();
110
- const hollow = (node, isEmpty) => node?.type === "boardGeo" && (node.fill ?? "none") === "none" && node.children.every((block) => ElementApi.isElement(block) && isEmpty(block));
106
+ const hollow = (node, geoType, isEmpty) => node !== void 0 && node.type === geoType && (node.fill ?? "none") === "none" && node.children.every((block) => ElementApi.isElement(block) && isEmpty(block));
111
107
  const reaches = (layout, at, zoom) => {
112
108
  switch (layout.kind) {
113
109
  case "arrow": return false;
@@ -121,7 +117,7 @@ const reaches = (layout, at, zoom) => {
121
117
  * and hit tests read, frame membership, and where each arrow draws, with the
122
118
  * preview a gesture shows in place of the stored drawing.
123
119
  */
124
- const createBoardIndex = ({ children: childrenOf, takesText: takesTextIn, isEmpty, keepsRatio: keepsRatioIn, members: membersRead, nodeOf, previewCleared }) => {
120
+ const createBoardIndex = ({ children: childrenOf, takesText: takesTextIn, isEmpty, keepsRatio: keepsRatioIn, members: membersRead, nodeOf, previewCleared, types }) => {
125
121
  const tree = new RBush();
126
122
  let children = null;
127
123
  let entries = [];
@@ -137,6 +133,8 @@ const createBoardIndex = ({ children: childrenOf, takesText: takesTextIn, isEmpt
137
133
  const arrowListeners = /* @__PURE__ */ new Map();
138
134
  const strokePaths = /* @__PURE__ */ new WeakMap();
139
135
  let version = 0;
136
+ const isStroke = (entry) => entry.node.type === types.stroke();
137
+ const inkOf = (entry) => boardStrokePointsOf(entry, types.stroke());
140
138
  const sameMember = (entry, previous) => {
141
139
  if (entry.key !== previous.key || entry.id !== previous.id || entry.zIndex !== previous.zIndex) return false;
142
140
  if (entry.kind === "arrow") return previous.kind === "arrow" && sameEnd(entry.start, previous.start) && sameEnd(entry.end, previous.end);
@@ -251,7 +249,7 @@ const createBoardIndex = ({ children: childrenOf, takesText: takesTextIn, isEmpt
251
249
  default: {
252
250
  if (layout.ink) return onInk(inkOnBoard(layout, layout.ink), from, to, zoom);
253
251
  const target = targets.get(layout.id);
254
- return !!target && outlineAlong(boardOutlineOf(target, zoom), from, to, slop, () => !hollow(nodeOf(layout.key), isEmpty));
252
+ return !!target && outlineAlong(boardOutlineOf(target, zoom), from, to, slop, () => !hollow(nodeOf(layout.key), types.geo(), isEmpty));
255
253
  }
256
254
  }
257
255
  };
@@ -407,16 +405,7 @@ const createBoardIndex = ({ children: childrenOf, takesText: takesTextIn, isEmpt
407
405
  const { height, width } = layout.box;
408
406
  const drawn = strokePaths.get(ink);
409
407
  if (drawn && drawn.height === height && drawn.width === width) return drawn;
410
- const next = {
411
- height,
412
- path: strokeOutline(boardInkIn(ink, {
413
- height,
414
- width,
415
- x: 0,
416
- y: 0
417
- }), BOARD_PEN, true),
418
- width
419
- };
408
+ const next = boardStrokePath(ink, layout.box);
420
409
  strokePaths.set(ink, next);
421
410
  return next;
422
411
  },
@@ -1,4 +1,5 @@
1
1
  import { subscribeEditorViewState } from "../../../facade.js";
2
+ import "../../../internal/plugin/uploadDrafts.js";
2
3
  import { activeElementOf } from "./boardVoice.internal.js";
3
4
  //#region src/react/features/board/boardPictures.internal.ts
4
5
  const LONGEST_SIDE = 480;
@@ -14,19 +15,21 @@ const fit = ({ naturalHeight, naturalWidth }) => {
14
15
  width: naturalWidth * scale
15
16
  };
16
17
  };
17
- const createPendingPictures = ({ editor, mounted, writable }) => {
18
+ const createPendingPictures = ({ editor, shapes, writable }) => {
18
19
  let stop = null;
19
20
  const cancel = () => {
20
21
  const held = stop;
21
22
  stop = null;
22
23
  held?.();
23
24
  };
24
- const load = (host, elements, loaded) => {
25
+ const load = (host, sources, loaded) => {
25
26
  cancel();
26
27
  const view = host.ownerDocument.defaultView;
27
28
  if (!view) return;
28
- const sizes = elements.map(() => void 0);
29
- const images = elements.map(() => new view.Image());
29
+ const urls = sources.map((source) => typeof source === "string" ? source : view.URL.createObjectURL(source));
30
+ const sizes = sources.map(() => void 0);
31
+ const images = sources.map(() => new view.Image());
32
+ let failed = false;
30
33
  const drop = () => {
31
34
  if (stop === halt) cancel();
32
35
  };
@@ -35,13 +38,13 @@ const createPendingPictures = ({ editor, mounted, writable }) => {
35
38
  sizes[at] = size;
36
39
  if (sizes.includes(void 0)) return;
37
40
  cancel();
38
- loaded(elements.map((element, index) => ({
39
- element,
40
- size: sizes[index] ?? UNLOADED
41
- })));
41
+ loaded(sizes.map((box) => box ?? UNLOADED), failed);
42
42
  };
43
43
  const handlers = images.map((image, at) => ({
44
- error: () => settle(at, UNLOADED),
44
+ error: () => {
45
+ failed = true;
46
+ settle(at, UNLOADED);
47
+ },
45
48
  load: () => settle(at, fit(image))
46
49
  }));
47
50
  const onPress = (event) => {
@@ -57,6 +60,9 @@ const createPendingPictures = ({ editor, mounted, writable }) => {
57
60
  image.removeEventListener("error", handlers[at].error);
58
61
  image.src = "";
59
62
  });
63
+ sources.forEach((source, at) => {
64
+ if (typeof source !== "string") view.URL.revokeObjectURL(urls[at]);
65
+ });
60
66
  view.removeEventListener("keydown", onPress, true);
61
67
  view.removeEventListener("pointerdown", onPress, true);
62
68
  view.removeEventListener("paste", drop, true);
@@ -64,10 +70,10 @@ const createPendingPictures = ({ editor, mounted, writable }) => {
64
70
  stopCommits();
65
71
  stopViewState();
66
72
  };
67
- const stopCommits = editor.subscribeCommit(({ changed }) => {
68
- if (changed.hasAny("document") || changed.hasAny("selection")) drop();
73
+ const stopCommits = editor.subscribeCommit(({ changed, tags }) => {
74
+ if (!tags.includes("upload") && (changed.hasAny("document") || changed.hasAny("selection"))) drop();
69
75
  });
70
- const stopViewState = subscribeEditorViewState(mounted, () => {
76
+ const stopViewState = subscribeEditorViewState(shapes, () => {
71
77
  if (!writable()) drop();
72
78
  });
73
79
  stop = halt;
@@ -78,7 +84,7 @@ const createPendingPictures = ({ editor, mounted, writable }) => {
78
84
  images.forEach((image, at) => {
79
85
  image.addEventListener("load", handlers[at].load);
80
86
  image.addEventListener("error", handlers[at].error);
81
- image.src = String(elements[at].url);
87
+ image.src = urls[at];
82
88
  });
83
89
  };
84
90
  return {