@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/index.d.cts CHANGED
@@ -417,6 +417,12 @@ export declare type BlockOffset = {
417
417
  offset: number
418
418
  }
419
419
 
420
+ declare type BlockPath = [
421
+ {
422
+ _key: string
423
+ },
424
+ ]
425
+
420
426
  /** @beta */
421
427
  export declare interface BlockRenderProps {
422
428
  children: ReactElement<any>
@@ -424,7 +430,7 @@ export declare interface BlockRenderProps {
424
430
  focused: boolean
425
431
  level?: number
426
432
  listItem?: string
427
- path: Path
433
+ path: BlockPath
428
434
  selected: boolean
429
435
  style?: string
430
436
  schemaType: ObjectSchemaType
@@ -3119,6 +3125,9 @@ export declare type PatchChange = {
3119
3125
  export declare type PatchesEvent = {
3120
3126
  type: 'patches'
3121
3127
  patches: Array<Patch>
3128
+ /**
3129
+ * @deprecated Unused by the editor
3130
+ */
3122
3131
  snapshot: Array<PortableTextBlock> | undefined
3123
3132
  }
3124
3133
 
package/lib/index.d.ts CHANGED
@@ -417,6 +417,12 @@ export declare type BlockOffset = {
417
417
  offset: number
418
418
  }
419
419
 
420
+ declare type BlockPath = [
421
+ {
422
+ _key: string
423
+ },
424
+ ]
425
+
420
426
  /** @beta */
421
427
  export declare interface BlockRenderProps {
422
428
  children: ReactElement<any>
@@ -424,7 +430,7 @@ export declare interface BlockRenderProps {
424
430
  focused: boolean
425
431
  level?: number
426
432
  listItem?: string
427
- path: Path
433
+ path: BlockPath
428
434
  selected: boolean
429
435
  style?: string
430
436
  schemaType: ObjectSchemaType
@@ -3119,6 +3125,9 @@ export declare type PatchChange = {
3119
3125
  export declare type PatchesEvent = {
3120
3126
  type: 'patches'
3121
3127
  patches: Array<Patch>
3128
+ /**
3129
+ * @deprecated Unused by the editor
3130
+ */
3122
3131
  snapshot: Array<PortableTextBlock> | undefined
3123
3132
  }
3124
3133
 
package/lib/index.js CHANGED
@@ -978,7 +978,13 @@ function RenderTextBlock(props) {
978
978
  schemaType: legacyListItemSchemaType
979
979
  }) : console.error(`Unable to find Schema type for text block list item ${props.textBlock.listItem}`);
980
980
  }
981
- return /* @__PURE__ */ 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", children: [
981
+ return /* @__PURE__ */ 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 ? {
982
+ "data-list-item": props.textBlock.listItem
983
+ } : {}, ...props.textBlock.level !== void 0 ? {
984
+ "data-level": props.textBlock.level
985
+ } : {}, ...props.textBlock.style !== void 0 ? {
986
+ "data-style": props.textBlock.style
987
+ } : {}, children: [
982
988
  dragPositionBlock === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null,
983
989
  /* @__PURE__ */ jsx("div", { ref: blockRef, children: props.renderBlock ? props.renderBlock({
984
990
  children,
@@ -3617,6 +3623,16 @@ function insertBlock({
3617
3623
  }
3618
3624
  if (editor.isTextBlock(endBlock) && editor.isTextBlock(block)) {
3619
3625
  const selectionStartPoint = Range.start(currentSelection);
3626
+ if (isEqualToEmptyEditor([endBlock], schema)) {
3627
+ const currentSelection2 = editor.selection;
3628
+ Transforms.insertNodes(editor, [block], {
3629
+ at: endBlockPath,
3630
+ select: !1
3631
+ }), Transforms.removeNodes(editor, {
3632
+ at: Path.next(endBlockPath)
3633
+ }), select === "start" ? Transforms.select(editor, selectionStartPoint) : select === "end" ? Transforms.select(editor, Editor.end(editor, endBlockPath)) : Transforms.select(editor, currentSelection2);
3634
+ return;
3635
+ }
3620
3636
  if (select === "end") {
3621
3637
  Transforms.insertFragment(editor, [block], {
3622
3638
  voids: !0