@portabletext/editor 1.49.13 → 1.50.1
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/behaviors/index.d.cts +3 -0
- package/lib/behaviors/index.d.ts +3 -0
- package/lib/index.cjs +17 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +10 -1
- package/lib/index.d.ts +10 -1
- package/lib/index.js +17 -1
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -0
- package/lib/plugins/index.d.ts +3 -0
- package/lib/selectors/index.cjs +95 -1
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +28 -0
- package/lib/selectors/index.d.ts +28 -0
- package/lib/selectors/index.js +97 -3
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.d.cts +3 -0
- package/lib/utils/index.d.ts +3 -0
- package/package.json +5 -5
- package/src/editor/__tests__/PortableTextEditor.test.tsx +1 -0
- package/src/editor/components/render-text-block.tsx +15 -0
- package/src/editor/editor-machine.ts +3 -0
- package/src/operations/behavior.operation.insert.block.ts +20 -0
- package/src/selectors/index.ts +1 -0
- package/src/selectors/selector.get-list-state.test.ts +202 -0
- package/src/selectors/selector.get-list-state.ts +175 -0
- package/src/types/editor.ts +2 -1
- package/src/types/paths.ts +1 -0
|
@@ -2627,6 +2627,9 @@ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
|
2627
2627
|
declare type PatchesEvent = {
|
|
2628
2628
|
type: 'patches'
|
|
2629
2629
|
patches: Array<Patch>
|
|
2630
|
+
/**
|
|
2631
|
+
* @deprecated Unused by the editor
|
|
2632
|
+
*/
|
|
2630
2633
|
snapshot: Array<PortableTextBlock> | undefined
|
|
2631
2634
|
}
|
|
2632
2635
|
|
package/lib/behaviors/index.d.ts
CHANGED
|
@@ -2627,6 +2627,9 @@ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
|
2627
2627
|
declare type PatchesEvent = {
|
|
2628
2628
|
type: 'patches'
|
|
2629
2629
|
patches: Array<Patch>
|
|
2630
|
+
/**
|
|
2631
|
+
* @deprecated Unused by the editor
|
|
2632
|
+
*/
|
|
2630
2633
|
snapshot: Array<PortableTextBlock> | undefined
|
|
2631
2634
|
}
|
|
2632
2635
|
|
package/lib/index.cjs
CHANGED
|
@@ -950,7 +950,13 @@ function RenderTextBlock(props) {
|
|
|
950
950
|
schemaType: legacyListItemSchemaType
|
|
951
951
|
}) : console.error(`Unable to find Schema type for text block list item ${props.textBlock.listItem}`);
|
|
952
952
|
}
|
|
953
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...props.attributes, className: ["pt-block", "pt-text-block", ...props.textBlock.style ? [`pt-text-block-style-${props.textBlock.style}`] : [], ...props.textBlock.listItem ? ["pt-list-item", `pt-list-item-${props.textBlock.listItem}`, `pt-list-item-level-${props.textBlock.level ?? 1}`] : []].join(" "), spellCheck: props.spellCheck, "data-block-key": props.textBlock._key, "data-block-name": props.textBlock._type, "data-block-type": "text",
|
|
953
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...props.attributes, className: ["pt-block", "pt-text-block", ...props.textBlock.style ? [`pt-text-block-style-${props.textBlock.style}`] : [], ...props.textBlock.listItem ? ["pt-list-item", `pt-list-item-${props.textBlock.listItem}`, `pt-list-item-level-${props.textBlock.level ?? 1}`] : []].join(" "), spellCheck: props.spellCheck, "data-block-key": props.textBlock._key, "data-block-name": props.textBlock._type, "data-block-type": "text", ...props.textBlock.listItem !== void 0 ? {
|
|
954
|
+
"data-list-item": props.textBlock.listItem
|
|
955
|
+
} : {}, ...props.textBlock.level !== void 0 ? {
|
|
956
|
+
"data-level": props.textBlock.level
|
|
957
|
+
} : {}, ...props.textBlock.style !== void 0 ? {
|
|
958
|
+
"data-style": props.textBlock.style
|
|
959
|
+
} : {}, children: [
|
|
954
960
|
dragPositionBlock === "start" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null,
|
|
955
961
|
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, children: props.renderBlock ? props.renderBlock({
|
|
956
962
|
children,
|
|
@@ -3589,6 +3595,16 @@ function insertBlock({
|
|
|
3589
3595
|
}
|
|
3590
3596
|
if (editor.isTextBlock(endBlock) && editor.isTextBlock(block)) {
|
|
3591
3597
|
const selectionStartPoint = slate.Range.start(currentSelection);
|
|
3598
|
+
if (isEqualToEmptyEditor([endBlock], schema2)) {
|
|
3599
|
+
const currentSelection2 = editor.selection;
|
|
3600
|
+
slate.Transforms.insertNodes(editor, [block], {
|
|
3601
|
+
at: endBlockPath,
|
|
3602
|
+
select: !1
|
|
3603
|
+
}), slate.Transforms.removeNodes(editor, {
|
|
3604
|
+
at: slate.Path.next(endBlockPath)
|
|
3605
|
+
}), select === "start" ? slate.Transforms.select(editor, selectionStartPoint) : select === "end" ? slate.Transforms.select(editor, slate.Editor.end(editor, endBlockPath)) : slate.Transforms.select(editor, currentSelection2);
|
|
3606
|
+
return;
|
|
3607
|
+
}
|
|
3592
3608
|
if (select === "end") {
|
|
3593
3609
|
slate.Transforms.insertFragment(editor, [block], {
|
|
3594
3610
|
voids: !0
|