@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.
- package/lib/_chunks-cjs/editor-provider.cjs +25 -13
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +1 -1
- package/lib/_chunks-cjs/util.block-offsets-to-selection.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +25 -13
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
- package/lib/_chunks-es/util.block-offsets-to-selection.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/behaviors/index.d.cts +7 -10
- package/lib/behaviors/index.d.ts +7 -10
- package/lib/index.cjs +140 -104
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +13 -26
- package/lib/index.d.ts +13 -26
- package/lib/index.js +142 -106
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2 -7
- package/lib/plugins/index.d.ts +2 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +8 -13
- package/lib/selectors/index.d.ts +8 -13
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +3 -6
- package/lib/utils/index.d.ts +3 -6
- package/lib/utils/index.js.map +1 -1
- package/package.json +14 -13
- package/src/behavior-actions/behavior.actions.ts +2 -2
- package/src/behaviors/behavior.decorator-pair.ts +2 -1
- package/src/behaviors/index.ts +0 -8
- package/src/converters/converter.text-html.deserialize.test.ts +1 -1
- package/src/converters/converter.text-html.serialize.test.ts +1 -1
- package/src/converters/converter.text-html.ts +8 -0
- package/src/converters/converter.text-plain.test.ts +1 -1
- package/src/converters/converter.text-plain.ts +8 -0
- package/src/editor/Editable.tsx +1 -1
- package/src/editor/__tests__/PortableTextEditor.test.tsx +16 -20
- package/src/editor/components/Element.tsx +26 -18
- package/src/editor/components/drop-indicator.tsx +14 -0
- package/src/editor/components/{DraggableBlock.tsx → use-draggable.ts} +42 -163
- package/src/editor/components/use-droppable.ts +135 -0
- package/src/editor/create-slate-editor.tsx +0 -3
- package/src/editor/sync-machine.ts +1 -0
- package/src/index.ts +48 -12
- package/src/internal-utils/create-test-snapshot.ts +1 -1
- package/src/plugins/plugin.decorator-shortcut.ts +1 -1
- package/src/plugins/plugin.markdown.tsx +1 -0
- package/src/selectors/index.ts +0 -8
- package/src/selectors/selector.get-active-annotations.test.ts +1 -1
- package/src/selectors/selector.get-caret-word-selection.test.ts +1 -1
- package/src/selectors/selector.get-selected-spans.test.ts +2 -1
- package/src/selectors/selector.get-selection-end-point.ts +1 -1
- package/src/selectors/selector.get-selection-start-point.ts +1 -1
- package/src/selectors/selector.get-selection-text.test.ts +1 -1
- package/src/selectors/selector.get-selection.ts +2 -1
- package/src/selectors/selector.get-value.ts +1 -1
- package/src/selectors/selector.is-active-decorator.test.ts +1 -1
- package/src/types/editor.ts +6 -16
- package/src/types/slate.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/util.block-offsets-to-selection.ts +1 -1
- package/src/utils/util.is-span.ts +1 -1
- package/src/utils/util.is-text-block.ts +1 -1
- package/src/utils/util.merge-text-blocks.ts +1 -1
- package/src/utils/util.slice-blocks.ts +1 -1
- 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
|
-
|
|
85
|
-
const $ = reactCompilerRuntime.c(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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),
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
-
|
|
122
|
+
event.preventDefault(), debug$4("targetPath and myPath is the same, not moving");
|
|
141
123
|
return;
|
|
142
124
|
}
|
|
143
|
-
debug$
|
|
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$
|
|
150
|
-
}, $[
|
|
151
|
-
const handleDragEnd =
|
|
152
|
-
let
|
|
153
|
-
$[
|
|
154
|
-
editorProvider.
|
|
155
|
-
|
|
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
|
-
}, $[
|
|
167
|
-
const handleDrag =
|
|
168
|
-
let
|
|
169
|
-
$[
|
|
170
|
-
if (!
|
|
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 =
|
|
180
|
-
dragGhost.style.width = `${rect.width}px`, dragGhost.style.height = `${rect.height}px`,
|
|
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(
|
|
184
|
-
}, $[
|
|
185
|
-
const handleDragStart =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
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,
|
|
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.
|
|
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(
|
|
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";
|