@portabletext/editor 1.40.4 → 1.41.0
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 +11 -6
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs +4 -0
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +11 -6
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/util.is-selection-collapsed.js +4 -0
- package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -1
- package/lib/index.cjs +260 -131
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +262 -133
- package/lib/index.js.map +1 -1
- package/lib/utils/index.cjs +5 -0
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +22 -0
- package/lib/utils/index.d.ts +22 -0
- package/lib/utils/index.js +6 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/converters/converter.text-plain.ts +24 -11
- package/src/editor/Editable.tsx +336 -223
- package/src/editor/components/drop-indicator.tsx +4 -1
- package/src/internal-utils/dragging-on-drag-origin.ts +22 -0
- package/src/internal-utils/event-position.ts +32 -4
- package/src/internal-utils/slate-utils.ts +18 -9
- package/src/utils/index.ts +2 -0
- package/src/utils/util.get-selection-end-point.ts +20 -0
- package/src/utils/util.get-selection-start-point.ts +20 -0
|
@@ -331,14 +331,17 @@ function getFocusChild({
|
|
|
331
331
|
const focusChild = slate.Node.child(focusBlock, childIndex);
|
|
332
332
|
return focusChild ? [focusChild, [...focusBlockPath, childIndex]] : [void 0, void 0];
|
|
333
333
|
}
|
|
334
|
+
function getFirstBlock({
|
|
335
|
+
editor
|
|
336
|
+
}) {
|
|
337
|
+
const firstBlockPath = slate.Editor.start(editor, []).path.at(0);
|
|
338
|
+
return firstBlockPath !== void 0 ? slate.Editor.node(editor, [firstBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
|
|
339
|
+
}
|
|
334
340
|
function getLastBlock({
|
|
335
341
|
editor
|
|
336
342
|
}) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
at: [],
|
|
340
|
-
reverse: !0
|
|
341
|
-
})).at(0) ?? [void 0, void 0];
|
|
343
|
+
const lastBlockPath = slate.Editor.end(editor, []).path.at(0);
|
|
344
|
+
return lastBlockPath !== void 0 ? slate.Editor.node(editor, [lastBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
|
|
342
345
|
}
|
|
343
346
|
function getNodeBlock({
|
|
344
347
|
editor,
|
|
@@ -2591,7 +2594,7 @@ const converterJson = {
|
|
|
2591
2594
|
data: util_sliceBlocks.sliceBlocks({
|
|
2592
2595
|
blocks: snapshot.context.value,
|
|
2593
2596
|
selection
|
|
2594
|
-
}).map((block) => types.isPortableTextTextBlock(block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : "").join("") : "").filter((block) => block !== "").join(`
|
|
2597
|
+
}).map((block) => types.isPortableTextTextBlock(block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
|
|
2595
2598
|
|
|
2596
2599
|
`),
|
|
2597
2600
|
mimeType: "text/plain",
|
|
@@ -7704,6 +7707,8 @@ exports.defaultKeyGenerator = defaultKeyGenerator;
|
|
|
7704
7707
|
exports.defineSchema = defineSchema;
|
|
7705
7708
|
exports.fromSlateValue = fromSlateValue;
|
|
7706
7709
|
exports.getEditorSnapshot = getEditorSnapshot;
|
|
7710
|
+
exports.getFirstBlock = getFirstBlock;
|
|
7711
|
+
exports.getLastBlock = getLastBlock;
|
|
7707
7712
|
exports.getNodeBlock = getNodeBlock;
|
|
7708
7713
|
exports.isEqualToEmptyEditor = isEqualToEmptyEditor;
|
|
7709
7714
|
exports.moveRangeByOperation = moveRangeByOperation;
|