@portabletext/editor 2.12.2 → 2.12.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/lib/_chunks-dts/behavior.types.action.d.cts +9 -9
- package/lib/_chunks-dts/behavior.types.action.d.ts +9 -9
- package/lib/index.cjs +5 -39
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +5 -39
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/lib/plugins/index.d.ts +3 -3
- package/lib/utils/index.d.ts +2 -2
- package/package.json +6 -6
- package/src/editor/Editable.tsx +1 -90
- package/src/test/vitest/step-definitions.tsx +1 -8
package/lib/index.js
CHANGED
|
@@ -1734,7 +1734,7 @@ function createDecorate(schema, slateEditor) {
|
|
|
1734
1734
|
};
|
|
1735
1735
|
}
|
|
1736
1736
|
const RelayActorContext = createContext({}), debug$d = debugWithName("component:Editable"), PortableTextEditable = forwardRef(function(props, forwardedRef) {
|
|
1737
|
-
const $ = c(
|
|
1737
|
+
const $ = c(171);
|
|
1738
1738
|
let hotkeys, onBeforeInput, onBlur, onClick, onCopy, onCut, onDrag, onDragEnd, onDragEnter, onDragLeave, onDragOver, onDragStart, onDrop, onFocus, onPaste, propsSelection, rangeDecorations, renderAnnotation, renderBlock, renderChild, renderDecorator, renderListItem, renderPlaceholder, renderStyle, restProps, scrollSelectionIntoView, spellCheck;
|
|
1739
1739
|
$[0] !== props ? ({
|
|
1740
1740
|
hotkeys,
|
|
@@ -2271,50 +2271,16 @@ const RelayActorContext = createContext({}), debug$d = debugWithName("component:
|
|
|
2271
2271
|
}, $[140] = editorActor, $[141] = onDragLeave, $[142] = slateEditor, $[143] = t34) : t34 = $[143];
|
|
2272
2272
|
const handleDragLeave = t34;
|
|
2273
2273
|
let t35;
|
|
2274
|
-
$[144] !== forwardedRef
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
validateSelection(slateEditor, node);
|
|
2278
|
-
});
|
|
2279
|
-
return mutationObserver.observe(node, {
|
|
2280
|
-
attributeOldValue: !1,
|
|
2281
|
-
attributes: !1,
|
|
2282
|
-
characterData: !1,
|
|
2283
|
-
childList: !0,
|
|
2284
|
-
subtree: !0
|
|
2285
|
-
}), () => {
|
|
2286
|
-
mutationObserver.disconnect();
|
|
2287
|
-
};
|
|
2288
|
-
}
|
|
2289
|
-
}, $[144] = forwardedRef, $[145] = slateEditor, $[146] = t35) : t35 = $[146];
|
|
2274
|
+
$[144] !== forwardedRef ? (t35 = (node) => {
|
|
2275
|
+
typeof forwardedRef == "function" ? forwardedRef(node) : forwardedRef && (forwardedRef.current = node);
|
|
2276
|
+
}, $[144] = forwardedRef, $[145] = t35) : t35 = $[145];
|
|
2290
2277
|
const callbackRef = t35;
|
|
2291
2278
|
if (!portableTextEditor)
|
|
2292
2279
|
return null;
|
|
2293
2280
|
let t36;
|
|
2294
|
-
return $[
|
|
2281
|
+
return $[146] !== callbackRef || $[147] !== decorate || $[148] !== handleClick || $[149] !== handleCopy || $[150] !== handleCut || $[151] !== handleDrag || $[152] !== handleDragEnd || $[153] !== handleDragEnter || $[154] !== handleDragLeave || $[155] !== handleDragOver || $[156] !== handleDragStart || $[157] !== handleDrop || $[158] !== handleKeyDown || $[159] !== handleKeyUp || $[160] !== handleOnBeforeInput || $[161] !== handleOnBlur || $[162] !== handleOnFocus || $[163] !== handlePaste || $[164] !== hasInvalidValue || $[165] !== readOnly || $[166] !== renderElement || $[167] !== renderLeaf || $[168] !== restProps || $[169] !== scrollSelectionIntoViewToSlate ? (t36 = hasInvalidValue ? null : /* @__PURE__ */ jsx(Editable, { ...restProps, ref: callbackRef, "data-read-only": readOnly, autoFocus: !1, className: restProps.className || "pt-editable", decorate, onBlur: handleOnBlur, onCopy: handleCopy, onCut: handleCut, onClick: handleClick, onDOMBeforeInput: handleOnBeforeInput, onDragStart: handleDragStart, onDrag: handleDrag, onDragEnd: handleDragEnd, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDrop: handleDrop, onDragLeave: handleDragLeave, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onPaste: handlePaste, readOnly, renderPlaceholder: void 0, renderElement, renderLeaf, renderText, scrollSelectionIntoView: scrollSelectionIntoViewToSlate }), $[146] = callbackRef, $[147] = decorate, $[148] = handleClick, $[149] = handleCopy, $[150] = handleCut, $[151] = handleDrag, $[152] = handleDragEnd, $[153] = handleDragEnter, $[154] = handleDragLeave, $[155] = handleDragOver, $[156] = handleDragStart, $[157] = handleDrop, $[158] = handleKeyDown, $[159] = handleKeyUp, $[160] = handleOnBeforeInput, $[161] = handleOnBlur, $[162] = handleOnFocus, $[163] = handlePaste, $[164] = hasInvalidValue, $[165] = readOnly, $[166] = renderElement, $[167] = renderLeaf, $[168] = restProps, $[169] = scrollSelectionIntoViewToSlate, $[170] = t36) : t36 = $[170], t36;
|
|
2295
2282
|
});
|
|
2296
2283
|
PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
|
|
2297
|
-
function validateSelection(slateEditor, activeElement) {
|
|
2298
|
-
if (!slateEditor.selection)
|
|
2299
|
-
return;
|
|
2300
|
-
let root;
|
|
2301
|
-
try {
|
|
2302
|
-
root = ReactEditor.findDocumentOrShadowRoot(slateEditor);
|
|
2303
|
-
} catch {
|
|
2304
|
-
}
|
|
2305
|
-
if (!root || activeElement !== root.activeElement)
|
|
2306
|
-
return;
|
|
2307
|
-
const domSelection = ReactEditor.getWindow(slateEditor).getSelection();
|
|
2308
|
-
if (!domSelection || domSelection.rangeCount === 0)
|
|
2309
|
-
return;
|
|
2310
|
-
const existingDOMRange = domSelection.getRangeAt(0);
|
|
2311
|
-
try {
|
|
2312
|
-
const newDOMRange = ReactEditor.toDOMRange(slateEditor, slateEditor.selection);
|
|
2313
|
-
(newDOMRange.startOffset !== existingDOMRange.startOffset || newDOMRange.endOffset !== existingDOMRange.endOffset) && (debug$d("DOM range out of sync, validating selection"), domSelection?.removeAllRanges(), domSelection.addRange(newDOMRange));
|
|
2314
|
-
} catch {
|
|
2315
|
-
debug$d("Could not resolve selection, selecting top document"), Transforms.deselect(slateEditor), slateEditor.children.length > 0 && Transforms.select(slateEditor, [0, 0]), slateEditor.onChange();
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
2284
|
function _temp(s) {
|
|
2319
2285
|
return s.matches({
|
|
2320
2286
|
"edit mode": "read only"
|