@portabletext/editor 1.36.0 → 1.36.2

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 (70) hide show
  1. package/lib/_chunks-cjs/editor-provider.cjs +25 -13
  2. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  3. package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +1 -1
  4. package/lib/_chunks-cjs/util.block-offsets-to-selection.cjs.map +1 -1
  5. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
  6. package/lib/_chunks-es/editor-provider.js +25 -13
  7. package/lib/_chunks-es/editor-provider.js.map +1 -1
  8. package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
  9. package/lib/_chunks-es/util.block-offsets-to-selection.js.map +1 -1
  10. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  11. package/lib/behaviors/index.d.cts +7 -10
  12. package/lib/behaviors/index.d.ts +7 -10
  13. package/lib/index.cjs +140 -104
  14. package/lib/index.cjs.map +1 -1
  15. package/lib/index.d.cts +13 -26
  16. package/lib/index.d.ts +13 -26
  17. package/lib/index.js +142 -106
  18. package/lib/index.js.map +1 -1
  19. package/lib/plugins/index.cjs.map +1 -1
  20. package/lib/plugins/index.d.cts +2 -7
  21. package/lib/plugins/index.d.ts +2 -7
  22. package/lib/plugins/index.js.map +1 -1
  23. package/lib/selectors/index.cjs.map +1 -1
  24. package/lib/selectors/index.d.cts +8 -13
  25. package/lib/selectors/index.d.ts +8 -13
  26. package/lib/selectors/index.js.map +1 -1
  27. package/lib/utils/index.cjs.map +1 -1
  28. package/lib/utils/index.d.cts +3 -6
  29. package/lib/utils/index.d.ts +3 -6
  30. package/lib/utils/index.js.map +1 -1
  31. package/package.json +14 -13
  32. package/src/behavior-actions/behavior.actions.ts +2 -2
  33. package/src/behaviors/behavior.decorator-pair.ts +2 -1
  34. package/src/behaviors/index.ts +0 -8
  35. package/src/converters/converter.text-html.deserialize.test.ts +1 -1
  36. package/src/converters/converter.text-html.serialize.test.ts +1 -1
  37. package/src/converters/converter.text-html.ts +8 -0
  38. package/src/converters/converter.text-plain.test.ts +1 -1
  39. package/src/converters/converter.text-plain.ts +8 -0
  40. package/src/editor/Editable.tsx +1 -1
  41. package/src/editor/__tests__/PortableTextEditor.test.tsx +16 -20
  42. package/src/editor/components/Element.tsx +26 -18
  43. package/src/editor/components/drop-indicator.tsx +14 -0
  44. package/src/editor/components/{DraggableBlock.tsx → use-draggable.ts} +42 -163
  45. package/src/editor/components/use-droppable.ts +135 -0
  46. package/src/editor/create-slate-editor.tsx +0 -3
  47. package/src/editor/sync-machine.ts +1 -0
  48. package/src/index.ts +48 -12
  49. package/src/internal-utils/create-test-snapshot.ts +1 -1
  50. package/src/plugins/plugin.decorator-shortcut.ts +1 -1
  51. package/src/plugins/plugin.markdown.tsx +1 -0
  52. package/src/selectors/index.ts +0 -8
  53. package/src/selectors/selector.get-active-annotations.test.ts +1 -1
  54. package/src/selectors/selector.get-caret-word-selection.test.ts +1 -1
  55. package/src/selectors/selector.get-selected-spans.test.ts +2 -1
  56. package/src/selectors/selector.get-selection-end-point.ts +1 -1
  57. package/src/selectors/selector.get-selection-start-point.ts +1 -1
  58. package/src/selectors/selector.get-selection-text.test.ts +1 -1
  59. package/src/selectors/selector.get-selection.ts +2 -1
  60. package/src/selectors/selector.get-value.ts +1 -1
  61. package/src/selectors/selector.is-active-decorator.test.ts +1 -1
  62. package/src/types/editor.ts +6 -16
  63. package/src/types/slate.ts +1 -1
  64. package/src/utils/index.ts +0 -1
  65. package/src/utils/util.block-offsets-to-selection.ts +1 -1
  66. package/src/utils/util.is-span.ts +1 -1
  67. package/src/utils/util.is-text-block.ts +1 -1
  68. package/src/utils/util.merge-text-blocks.ts +1 -1
  69. package/src/utils/util.slice-blocks.ts +1 -1
  70. package/src/utils/util.split-text-block.ts +4 -2
package/lib/index.cjs CHANGED
@@ -81,136 +81,158 @@ function DefaultInlineObject(props) {
81
81
  "]"
82
82
  ] }), $[1] = props.value._key, $[2] = props.value._type, $[3] = t1) : t1 = $[3], t1;
83
83
  }
84
- const debug$3 = editorProvider.debugWithName("components:DraggableBlock"), DraggableBlock = (t0) => {
85
- const $ = reactCompilerRuntime.c(51), {
86
- children,
87
- element,
88
- readOnly,
89
- blockRef
90
- } = t0, editor = slateReact.useSlateStatic(), dragGhostRef = React.useRef(void 0), [isDragOver, setIsDragOver] = React.useState(!1);
91
- let t1, t2;
92
- $[0] !== editor || $[1] !== element ? (t2 = slate.Editor.isVoid(editor, element), $[0] = editor, $[1] = element, $[2] = t2) : t2 = $[2], t1 = t2;
93
- const isVoid = t1;
94
- let t3, t4;
95
- $[3] !== editor || $[4] !== element ? (t4 = slate.Editor.isInline(editor, element), $[3] = editor, $[4] = element, $[5] = t4) : t4 = $[5], t3 = t4;
96
- const isInline = t3, [blockElement, setBlockElement] = React.useState(null);
97
- let t5, t6;
98
- $[6] !== blockRef || $[7] !== editor || $[8] !== element ? (t5 = () => setBlockElement(blockRef ? blockRef.current : slateReact.ReactEditor.toDOMNode(editor, element)), t6 = [editor, element, blockRef], $[6] = blockRef, $[7] = editor, $[8] = element, $[9] = t5, $[10] = t6) : (t5 = $[9], t6 = $[10]), React.useEffect(t5, t6);
99
- let t7;
100
- $[11] !== blockElement || $[12] !== editor || $[13] !== element ? (t7 = (event) => {
101
- const isMyDragOver = editorProvider.IS_DRAGGING_BLOCK_ELEMENT.get(editor);
102
- if (!isMyDragOver || !blockElement)
103
- return;
104
- event.preventDefault(), event.dataTransfer.dropEffect = "move", editorProvider.IS_DRAGGING_ELEMENT_TARGET.set(editor, element);
105
- const elementRect = blockElement.getBoundingClientRect(), offset = elementRect.top, height = elementRect.height, Y = event.pageY, loc = Math.abs(offset - Y);
106
- if (element === editor.children[0] || (loc < height / 2 ? editorProvider.IS_DRAGGING_BLOCK_TARGET_POSITION.set(editor, "top") : editorProvider.IS_DRAGGING_BLOCK_TARGET_POSITION.set(editor, "bottom")), isMyDragOver === element) {
107
- event.dataTransfer.dropEffect = "none";
108
- return;
109
- }
110
- setIsDragOver(!0);
111
- }, $[11] = blockElement, $[12] = editor, $[13] = element, $[14] = t7) : t7 = $[14];
112
- const handleDragOver = t7;
113
- let t8;
114
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => {
115
- setIsDragOver(!1);
116
- }, $[15] = t8) : t8 = $[15];
117
- const handleDragLeave = t8;
118
- let t9;
119
- $[16] !== editor || $[17] !== element ? (t9 = (event_0) => {
84
+ function DropIndicator() {
85
+ const $ = reactCompilerRuntime.c(1);
86
+ let t0;
87
+ return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-drop-indicator", style: {
88
+ position: "absolute",
89
+ width: "100%",
90
+ height: 1,
91
+ borderBottom: "1px solid currentColor",
92
+ zIndex: 5
93
+ } }), $[0] = t0) : t0 = $[0], t0;
94
+ }
95
+ const debug$4 = editorProvider.debugWithName("useDraggable");
96
+ function useDraggable(props) {
97
+ const $ = reactCompilerRuntime.c(20), editor = slateReact.useSlateStatic(), dragGhostRef = React.useRef(void 0), [blockElement, setBlockElement] = React.useState(null);
98
+ let t0, t1;
99
+ $[0] !== editor || $[1] !== props.blockRef || $[2] !== props.element ? (t0 = () => setBlockElement(props.blockRef ? props.blockRef.current : slateReact.ReactEditor.toDOMNode(editor, props.element)), t1 = [editor, props.element, props.blockRef], $[0] = editor, $[1] = props.blockRef, $[2] = props.element, $[3] = t0, $[4] = t1) : (t0 = $[3], t1 = $[4]), React.useEffect(t0, t1);
100
+ let t2;
101
+ $[5] !== editor || $[6] !== props.element ? (t2 = (event) => {
120
102
  const targetBlock = editorProvider.IS_DRAGGING_ELEMENT_TARGET.get(editor);
121
103
  if (targetBlock) {
122
- editorProvider.IS_DRAGGING.set(editor, !1), event_0.preventDefault(), event_0.stopPropagation(), editorProvider.IS_DRAGGING_ELEMENT_TARGET.delete(editor), dragGhostRef.current && (debug$3("Removing drag ghost"), document.body.removeChild(dragGhostRef.current));
104
+ editorProvider.IS_DRAGGING.set(editor, !1), event.preventDefault(), event.stopPropagation(), editorProvider.IS_DRAGGING_ELEMENT_TARGET.delete(editor), dragGhostRef.current && (debug$4("Removing drag ghost"), document.body.removeChild(dragGhostRef.current));
123
105
  const dragPosition = editorProvider.IS_DRAGGING_BLOCK_TARGET_POSITION.get(editor);
124
106
  editorProvider.IS_DRAGGING_BLOCK_TARGET_POSITION.delete(editor);
125
107
  let targetPath = slateReact.ReactEditor.findPath(editor, targetBlock);
126
- const myPath = slateReact.ReactEditor.findPath(editor, element), isBefore = slate.Path.isBefore(myPath, targetPath);
108
+ const myPath = slateReact.ReactEditor.findPath(editor, props.element), isBefore = slate.Path.isBefore(myPath, targetPath);
127
109
  if (dragPosition === "bottom" && !isBefore) {
128
110
  if (targetPath[0] >= editor.children.length - 1) {
129
- debug$3("target is already at the bottom, not moving");
111
+ debug$4("target is already at the bottom, not moving");
130
112
  return;
131
113
  }
132
114
  const originalPath = targetPath;
133
- targetPath = slate.Path.next(targetPath), debug$3(`Adjusting targetPath from ${JSON.stringify(originalPath)} to ${JSON.stringify(targetPath)}`);
115
+ targetPath = slate.Path.next(targetPath), debug$4(`Adjusting targetPath from ${JSON.stringify(originalPath)} to ${JSON.stringify(targetPath)}`);
134
116
  }
135
117
  if (dragPosition === "top" && isBefore && targetPath[0] !== editor.children.length - 1) {
136
118
  const originalPath_0 = targetPath;
137
- targetPath = slate.Path.previous(targetPath), debug$3(`Adjusting targetPath from ${JSON.stringify(originalPath_0)} to ${JSON.stringify(targetPath)}`);
119
+ targetPath = slate.Path.previous(targetPath), debug$4(`Adjusting targetPath from ${JSON.stringify(originalPath_0)} to ${JSON.stringify(targetPath)}`);
138
120
  }
139
121
  if (slate.Path.equals(targetPath, myPath)) {
140
- event_0.preventDefault(), debug$3("targetPath and myPath is the same, not moving");
122
+ event.preventDefault(), debug$4("targetPath and myPath is the same, not moving");
141
123
  return;
142
124
  }
143
- debug$3(`Moving element ${element._key} from path ${JSON.stringify(myPath)} to ${JSON.stringify(targetPath)} (${dragPosition})`), slate.Transforms.moveNodes(editor, {
125
+ debug$4(`Moving element ${props.element._key} from path ${JSON.stringify(myPath)} to ${JSON.stringify(targetPath)} (${dragPosition})`), slate.Transforms.moveNodes(editor, {
144
126
  at: myPath,
145
127
  to: targetPath
146
128
  }), editor.onChange();
147
129
  return;
148
130
  }
149
- debug$3("No target element, not doing anything");
150
- }, $[16] = editor, $[17] = element, $[18] = t9) : t9 = $[18];
151
- const handleDragEnd = t9;
152
- let t10;
153
- $[19] !== editor || $[20] !== element ? (t10 = (event_1) => {
154
- editorProvider.IS_DRAGGING_BLOCK_ELEMENT.get(editor) && (debug$3("On drop (prevented)", element), event_1.preventDefault(), event_1.stopPropagation(), setIsDragOver(!1));
155
- }, $[19] = editor, $[20] = element, $[21] = t10) : t10 = $[21];
156
- const handleDrop = t10;
157
- let t11;
158
- $[22] !== editor || $[23] !== element || $[24] !== isVoid ? (t11 = (event_2) => {
159
- if (!isVoid) {
160
- editorProvider.IS_DRAGGING_BLOCK_ELEMENT.delete(editor);
161
- return;
162
- }
163
- editorProvider.IS_DRAGGING.set(editor, !0), editorProvider.IS_DRAGGING_BLOCK_ELEMENT.set(editor, element), event_2.stopPropagation();
164
- const target = event_2.target;
131
+ debug$4("No target element, not doing anything");
132
+ }, $[5] = editor, $[6] = props.element, $[7] = t2) : t2 = $[7];
133
+ const handleDragEnd = t2;
134
+ let t3;
135
+ $[8] !== editor || $[9] !== props.element ? (t3 = (event_0) => {
136
+ editorProvider.IS_DRAGGING.set(editor, !0), editorProvider.IS_DRAGGING_BLOCK_ELEMENT.set(editor, props.element), event_0.stopPropagation();
137
+ const target = event_0.target;
165
138
  target instanceof HTMLElement && (target.style.opacity = "1");
166
- }, $[22] = editor, $[23] = element, $[24] = isVoid, $[25] = t11) : t11 = $[25];
167
- const handleDrag = t11;
168
- let t12;
169
- $[26] !== blockElement || $[27] !== editor || $[28] !== handleDrag || $[29] !== isInline || $[30] !== isVoid ? (t12 = (event_3) => {
170
- if (!isVoid || isInline) {
171
- debug$3("Not dragging block"), editorProvider.IS_DRAGGING_BLOCK_ELEMENT.delete(editor), editorProvider.IS_DRAGGING.set(editor, !1);
172
- return;
173
- }
174
- if (debug$3("Drag start"), editorProvider.IS_DRAGGING.set(editor, !0), event_3.dataTransfer && (event_3.dataTransfer.setData("application/portable-text", "something"), event_3.dataTransfer.effectAllowed = "move"), blockElement && blockElement instanceof HTMLElement) {
139
+ }, $[8] = editor, $[9] = props.element, $[10] = t3) : t3 = $[10];
140
+ const handleDrag = t3;
141
+ let t4;
142
+ $[11] !== blockElement || $[12] !== editor || $[13] !== handleDrag ? (t4 = (event_1) => {
143
+ if (debug$4("Drag start"), editorProvider.IS_DRAGGING.set(editor, !0), event_1.dataTransfer && (event_1.dataTransfer.setData("application/portable-text", "something"), event_1.dataTransfer.effectAllowed = "move"), blockElement && blockElement instanceof HTMLElement) {
175
144
  let dragGhost = blockElement.cloneNode(!0);
176
145
  const customGhost = dragGhost.querySelector("[data-pt-drag-ghost-element]");
177
146
  if (customGhost && (dragGhost = customGhost), dragGhost.setAttribute("data-dragged", ""), document.body) {
178
147
  dragGhostRef.current = dragGhost, dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost);
179
- const rect = blockElement.getBoundingClientRect(), x = event_3.clientX - rect.left, y = event_3.clientY - rect.top;
180
- dragGhost.style.width = `${rect.width}px`, dragGhost.style.height = `${rect.height}px`, event_3.dataTransfer.setDragImage(dragGhost, x, y);
148
+ const rect = blockElement.getBoundingClientRect(), x = event_1.clientX - rect.left, y = event_1.clientY - rect.top;
149
+ dragGhost.style.width = `${rect.width}px`, dragGhost.style.height = `${rect.height}px`, event_1.dataTransfer.setDragImage(dragGhost, x, y);
181
150
  }
182
151
  }
183
- handleDrag(event_3);
184
- }, $[26] = blockElement, $[27] = editor, $[28] = handleDrag, $[29] = isInline, $[30] = isVoid, $[31] = t12) : t12 = $[31];
185
- const handleDragStart = t12;
186
- let t13;
187
- $[32] !== editor || $[33] !== isDragOver ? (t13 = isDragOver && editor.children[0] === editorProvider.IS_DRAGGING_ELEMENT_TARGET.get(editor), $[32] = editor, $[33] = isDragOver, $[34] = t13) : t13 = $[34];
188
- const isDraggingOverFirstBlock = t13;
189
- let t14;
190
- $[35] !== editor || $[36] !== isDragOver ? (t14 = isDragOver && editor.children[editor.children.length - 1] === editorProvider.IS_DRAGGING_ELEMENT_TARGET.get(editor), $[35] = editor, $[36] = isDragOver, $[37] = t14) : t14 = $[37];
191
- const isDraggingOverLastBlock = t14, dragPosition_0 = editorProvider.IS_DRAGGING_BLOCK_TARGET_POSITION.get(editor), isDraggingOverTop = isDraggingOverFirstBlock || isDragOver && !isDraggingOverFirstBlock && !isDraggingOverLastBlock && dragPosition_0 === "top", isDraggingOverBottom = isDraggingOverLastBlock || isDragOver && !isDraggingOverFirstBlock && !isDraggingOverLastBlock && dragPosition_0 === "bottom";
192
- let t15, t16;
193
- $[38] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-drop-indicator", style: {
194
- position: "absolute",
195
- width: "100%",
196
- height: 1,
197
- borderBottom: "1px solid currentColor",
198
- zIndex: 5
199
- } }), $[38] = t16) : t16 = $[38], t15 = t16;
200
- const dropIndicator = t15;
201
- if (readOnly) {
202
- let t172;
203
- return $[39] !== children ? (t172 = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }), $[39] = children, $[40] = t172) : t172 = $[40], t172;
152
+ handleDrag(event_1);
153
+ }, $[11] = blockElement, $[12] = editor, $[13] = handleDrag, $[14] = t4) : t4 = $[14];
154
+ const handleDragStart = t4;
155
+ if (props.readOnly) {
156
+ let t52;
157
+ return $[15] === Symbol.for("react.memo_cache_sentinel") ? (t52 = {
158
+ draggableProps: {
159
+ draggable: !1,
160
+ onDragStart: void 0,
161
+ onDrag: void 0,
162
+ onDragEnd: void 0
163
+ }
164
+ }, $[15] = t52) : t52 = $[15], t52;
204
165
  }
205
- const t17 = isDraggingOverTop && dropIndicator, t18 = isDraggingOverBottom && dropIndicator;
206
- let t19;
207
- return $[41] !== children || $[42] !== handleDrag || $[43] !== handleDragEnd || $[44] !== handleDragOver || $[45] !== handleDragStart || $[46] !== handleDrop || $[47] !== isVoid || $[48] !== t17 || $[49] !== t18 ? (t19 = /* @__PURE__ */ jsxRuntime.jsxs("div", { draggable: isVoid, onDragStart: handleDragStart, onDrag: handleDrag, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDragEnd: handleDragEnd, onDrop: handleDrop, children: [
208
- t17,
209
- children,
210
- t18
211
- ] }), $[41] = children, $[42] = handleDrag, $[43] = handleDragEnd, $[44] = handleDragOver, $[45] = handleDragStart, $[46] = handleDrop, $[47] = isVoid, $[48] = t17, $[49] = t18, $[50] = t19) : t19 = $[50], t19;
212
- };
213
- DraggableBlock.displayName = "DraggableBlock";
166
+ let t5;
167
+ return $[16] !== handleDrag || $[17] !== handleDragEnd || $[18] !== handleDragStart ? (t5 = {
168
+ draggableProps: {
169
+ draggable: !0,
170
+ onDragStart: handleDragStart,
171
+ onDrag: handleDrag,
172
+ onDragEnd: handleDragEnd
173
+ }
174
+ }, $[16] = handleDrag, $[17] = handleDragEnd, $[18] = handleDragStart, $[19] = t5) : t5 = $[19], t5;
175
+ }
176
+ const debug$3 = editorProvider.debugWithName("useDroppable");
177
+ function useDroppable(props) {
178
+ const $ = reactCompilerRuntime.c(27), editor = slateReact.useSlateStatic(), [isDragOver, setIsDragOver] = React.useState(!1), [blockElement, setBlockElement] = React.useState(null);
179
+ let t0, t1;
180
+ $[0] !== editor || $[1] !== props.blockRef || $[2] !== props.element ? (t0 = () => setBlockElement(props.blockRef ? props.blockRef.current : slateReact.ReactEditor.toDOMNode(editor, props.element)), t1 = [editor, props.element, props.blockRef], $[0] = editor, $[1] = props.blockRef, $[2] = props.element, $[3] = t0, $[4] = t1) : (t0 = $[3], t1 = $[4]), React.useEffect(t0, t1);
181
+ let t2;
182
+ $[5] !== blockElement || $[6] !== editor || $[7] !== props.element ? (t2 = (event) => {
183
+ const isMyDragOver = editorProvider.IS_DRAGGING_BLOCK_ELEMENT.get(editor);
184
+ if (!isMyDragOver || !blockElement)
185
+ return;
186
+ event.preventDefault(), event.dataTransfer.dropEffect = "move", editorProvider.IS_DRAGGING_ELEMENT_TARGET.set(editor, props.element);
187
+ const elementRect = blockElement.getBoundingClientRect(), offset = elementRect.top, height = elementRect.height, Y = event.pageY, loc = Math.abs(offset - Y);
188
+ if (props.element === editor.children[0] || (loc < height / 2 ? editorProvider.IS_DRAGGING_BLOCK_TARGET_POSITION.set(editor, "top") : editorProvider.IS_DRAGGING_BLOCK_TARGET_POSITION.set(editor, "bottom")), isMyDragOver === props.element) {
189
+ event.dataTransfer.dropEffect = "none";
190
+ return;
191
+ }
192
+ setIsDragOver(!0);
193
+ }, $[5] = blockElement, $[6] = editor, $[7] = props.element, $[8] = t2) : t2 = $[8];
194
+ const handleDragOver = t2;
195
+ let t3;
196
+ $[9] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => {
197
+ setIsDragOver(!1);
198
+ }, $[9] = t3) : t3 = $[9];
199
+ const handleDragLeave = t3;
200
+ let t4;
201
+ $[10] !== editor || $[11] !== props.element ? (t4 = (event_0) => {
202
+ editorProvider.IS_DRAGGING_BLOCK_ELEMENT.get(editor) && (debug$3("On drop (prevented)", props.element), event_0.preventDefault(), event_0.stopPropagation(), setIsDragOver(!1));
203
+ }, $[10] = editor, $[11] = props.element, $[12] = t4) : t4 = $[12];
204
+ const handleDrop = t4;
205
+ let t5;
206
+ $[13] !== editor || $[14] !== isDragOver ? (t5 = isDragOver && editor.children[0] === editorProvider.IS_DRAGGING_ELEMENT_TARGET.get(editor), $[13] = editor, $[14] = isDragOver, $[15] = t5) : t5 = $[15];
207
+ const isDraggingOverFirstBlock = t5;
208
+ let t6;
209
+ $[16] !== editor || $[17] !== isDragOver ? (t6 = isDragOver && editor.children[editor.children.length - 1] === editorProvider.IS_DRAGGING_ELEMENT_TARGET.get(editor), $[16] = editor, $[17] = isDragOver, $[18] = t6) : t6 = $[18];
210
+ const isDraggingOverLastBlock = t6, dragPosition = editorProvider.IS_DRAGGING_BLOCK_TARGET_POSITION.get(editor), isDraggingOverTop = isDraggingOverFirstBlock || isDragOver && !isDraggingOverFirstBlock && !isDraggingOverLastBlock && dragPosition === "top", isDraggingOverBottom = isDraggingOverLastBlock || isDragOver && !isDraggingOverFirstBlock && !isDraggingOverLastBlock && dragPosition === "bottom";
211
+ if (props.readOnly) {
212
+ let t72;
213
+ return $[19] === Symbol.for("react.memo_cache_sentinel") ? (t72 = {
214
+ droppableProps: {
215
+ onDragOver: void 0,
216
+ onDragLeave: void 0,
217
+ onDrop: void 0
218
+ },
219
+ isDraggingOverTop: !1,
220
+ isDraggingOverBottom: !1
221
+ }, $[19] = t72) : t72 = $[19], t72;
222
+ }
223
+ let t7;
224
+ $[20] !== handleDragOver || $[21] !== handleDrop ? (t7 = {
225
+ onDragOver: handleDragOver,
226
+ onDragLeave: handleDragLeave,
227
+ onDrop: handleDrop
228
+ }, $[20] = handleDragOver, $[21] = handleDrop, $[22] = t7) : t7 = $[22];
229
+ let t8;
230
+ return $[23] !== isDraggingOverBottom || $[24] !== isDraggingOverTop || $[25] !== t7 ? (t8 = {
231
+ droppableProps: t7,
232
+ isDraggingOverTop,
233
+ isDraggingOverBottom
234
+ }, $[23] = isDraggingOverBottom, $[24] = isDraggingOverTop, $[25] = t7, $[26] = t8) : t8 = $[26], t8;
235
+ }
214
236
  editorProvider.debugWithName("components:Element");
215
237
  const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
216
238
  display: "inline-block"
@@ -226,7 +248,15 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
226
248
  renderStyle,
227
249
  spellCheck
228
250
  }) => {
229
- const editor = slateReact.useSlateStatic(), selected = slateReact.useSelected(), blockRef = React.useRef(null), inlineBlockObjectRef = React.useRef(null), focused = selected && editor.selection && slate.Range.isCollapsed(editor.selection) || !1, value = React.useMemo(() => editorProvider.fromSlateValue([element], schemaTypes.block.name, editorProvider.KEY_TO_VALUE_ELEMENT.get(editor))[0], [editor, element, schemaTypes.block.name]);
251
+ const editor = slateReact.useSlateStatic(), selected = slateReact.useSelected(), blockRef = React.useRef(null), inlineBlockObjectRef = React.useRef(null), focused = selected && editor.selection && slate.Range.isCollapsed(editor.selection) || !1, droppable = useDroppable({
252
+ element,
253
+ blockRef,
254
+ readOnly
255
+ }), draggable = useDraggable({
256
+ element,
257
+ blockRef,
258
+ readOnly
259
+ }), value = React.useMemo(() => editorProvider.fromSlateValue([element], schemaTypes.block.name, editorProvider.KEY_TO_VALUE_ELEMENT.get(editor))[0], [editor, element, schemaTypes.block.name]);
230
260
  let renderedBlock = children, className;
231
261
  const blockPath = React.useMemo(() => [{
232
262
  _key: element._key
@@ -315,7 +345,11 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
315
345
  return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaTypes.block;
316
346
  }
317
347
  }), propsOrDefaultRendered = renderBlock ? renderBlock(renderProps) : children;
318
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ...attributes, className, spellCheck, children: /* @__PURE__ */ jsxRuntime.jsx(DraggableBlock, { element, readOnly, blockRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, children: propsOrDefaultRendered }) }) }, element._key);
348
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...attributes, className, spellCheck, ...droppable.droppableProps, children: [
349
+ droppable.isDraggingOverTop ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null,
350
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, children: propsOrDefaultRendered }),
351
+ droppable.isDraggingOverBottom ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null
352
+ ] }, element._key);
319
353
  }
320
354
  const schemaType_0 = schemaTypes.blockObjects.find((_type_0) => _type_0.name === element._type);
321
355
  if (!schemaType_0)
@@ -340,9 +374,11 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
340
374
  });
341
375
  renderedBlockFromProps = renderBlock(_props);
342
376
  }
343
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...attributes, className, children: [
377
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...attributes, className, ...droppable.droppableProps, ...draggable.draggableProps, children: [
378
+ droppable.isDraggingOverTop ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null,
344
379
  children,
345
- /* @__PURE__ */ jsxRuntime.jsx(DraggableBlock, { element, readOnly, blockRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, contentEditable: !1, children: renderedBlockFromProps || /* @__PURE__ */ jsxRuntime.jsx(DefaultBlockObject, { value }) }) })
380
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, contentEditable: !1, children: renderedBlockFromProps || /* @__PURE__ */ jsxRuntime.jsx(DefaultBlockObject, { value }) }),
381
+ droppable.isDraggingOverBottom ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null
346
382
  ] }, element._key);
347
383
  };
348
384
  Element.displayName = "Element";