@portabletext/editor 3.0.0 → 3.0.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.
@@ -165,7 +165,9 @@ declare function sliceBlocks({
165
165
  context,
166
166
  blocks
167
167
  }: {
168
- context: Pick<EditorContext, 'schema' | 'selection'>;
168
+ context: Pick<EditorContext, 'schema' | 'selection'> & {
169
+ keyGenerator?: () => string;
170
+ };
169
171
  blocks: Array<PortableTextBlock>;
170
172
  }): Array<PortableTextBlock>;
171
173
  /**
@@ -88,6 +88,7 @@ function mergeTextBlocks({
88
88
  context,
89
89
  block: incomingBlock,
90
90
  options: {
91
+ normalize: !1,
91
92
  removeUnusedMarkDefs: !0,
92
93
  validateFields: !1
93
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/utils/util.block-offset-to-block-selection-point.ts","../../src/utils/util.block-offset-to-selection-point.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.is-equal-selections.ts","../../src/utils/util.merge-text-blocks.ts","../../src/utils/util.reverse-selection.ts","../../src/utils/util.selection-point-to-block-offset.ts","../../src/utils/util.split-text-block.ts"],"sourcesContent":["import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\n\n/**\n * @public\n */\nexport function blockOffsetToBlockSelectionPoint({\n context,\n blockOffset,\n}: {\n context: Pick<EditorContext, 'value'>\n blockOffset: BlockOffset\n}): EditorSelectionPoint | undefined {\n let selectionPoint: EditorSelectionPoint | undefined\n\n for (const block of context.value) {\n if (block._key === blockOffset.path[0]._key) {\n selectionPoint = {\n path: [{_key: block._key}],\n offset: blockOffset.offset,\n }\n break\n }\n }\n\n return selectionPoint\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {blockOffsetToSpanSelectionPoint} from './util.block-offset'\nimport {blockOffsetToBlockSelectionPoint} from './util.block-offset-to-block-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetToSelectionPoint({\n context,\n blockOffset,\n direction,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n blockOffset: BlockOffset\n direction: 'forward' | 'backward'\n}): EditorSelectionPoint | undefined {\n const spanSelectionPoint = blockOffsetToSpanSelectionPoint({\n context,\n blockOffset,\n direction,\n })\n\n if (!spanSelectionPoint) {\n return blockOffsetToBlockSelectionPoint({\n context,\n blockOffset,\n })\n }\n\n return spanSelectionPoint\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {blockOffsetToSelectionPoint} from './util.block-offset-to-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetsToSelection({\n context,\n offsets,\n backward,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n offsets: {anchor: BlockOffset; focus: BlockOffset}\n backward?: boolean\n}): EditorSelection {\n const anchor = blockOffsetToSelectionPoint({\n context,\n blockOffset: offsets.anchor,\n direction: backward ? 'backward' : 'forward',\n })\n const focus = blockOffsetToSelectionPoint({\n context,\n blockOffset: offsets.focus,\n direction: backward ? 'forward' : 'backward',\n })\n\n if (!anchor || !focus) {\n return null\n }\n\n return {\n anchor,\n focus,\n backward,\n }\n}\n","import {isSpan, isTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from './util.selection-point'\n\n/**\n * @public\n */\nexport function childSelectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n let offset = 0\n\n const blockKey = getBlockKeyFromSelectionPoint(selectionPoint)\n const childKey = getChildKeyFromSelectionPoint(selectionPoint)\n\n if (!blockKey || !childKey) {\n return undefined\n }\n\n for (const block of context.value) {\n if (block._key !== blockKey) {\n continue\n }\n\n if (!isTextBlock(context, block)) {\n continue\n }\n\n for (const child of block.children) {\n if (child._key === childKey) {\n return {\n path: [{_key: block._key}],\n offset: offset + selectionPoint.offset,\n }\n }\n\n if (isSpan(context, child)) {\n offset += child.text.length\n }\n }\n }\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from './util.is-equal-selection-points'\n\n/**\n * @public\n */\nexport function isEqualSelections(a: EditorSelection, b: EditorSelection) {\n if (!a && !b) {\n return true\n }\n\n if (!a || !b) {\n return false\n }\n\n return (\n isEqualSelectionPoints(a.anchor, b.anchor) &&\n isEqualSelectionPoints(a.focus, b.focus)\n )\n}\n","import {isTextBlock} from '@portabletext/schema'\nimport type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {parseBlock} from './parse-blocks'\n\n/**\n * @beta\n */\nexport function mergeTextBlocks({\n context,\n targetBlock,\n incomingBlock,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n targetBlock: PortableTextTextBlock\n incomingBlock: PortableTextTextBlock\n}) {\n const parsedIncomingBlock = parseBlock({\n context,\n block: incomingBlock,\n options: {removeUnusedMarkDefs: true, validateFields: false},\n })\n\n if (!parsedIncomingBlock || !isTextBlock(context, parsedIncomingBlock)) {\n return targetBlock\n }\n\n return {\n ...targetBlock,\n children: [...targetBlock.children, ...parsedIncomingBlock.children],\n markDefs: [\n ...(targetBlock.markDefs ?? []),\n ...(parsedIncomingBlock.markDefs ?? []),\n ],\n }\n}\n","import type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport function reverseSelection<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n>(selection: TEditorSelection): TEditorSelection {\n if (!selection) {\n return selection\n }\n\n if (selection.backward) {\n return {\n anchor: selection.focus,\n focus: selection.anchor,\n backward: false,\n } as TEditorSelection\n }\n\n return {\n anchor: selection.focus,\n focus: selection.anchor,\n backward: true,\n } as TEditorSelection\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {childSelectionPointToBlockOffset} from './util.child-selection-point-to-block-offset'\nimport {getBlockKeyFromSelectionPoint} from './util.selection-point'\n\n/**\n * @public\n */\nexport function selectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n const blockKey = getBlockKeyFromSelectionPoint(selectionPoint)\n\n if (selectionPoint.path.length === 1 && blockKey !== undefined) {\n return {\n path: [{_key: blockKey}],\n offset: selectionPoint.offset,\n }\n }\n\n return childSelectionPointToBlockOffset({\n context,\n selectionPoint,\n })\n}\n","import {isSpan} from '@portabletext/schema'\nimport type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {sliceTextBlock} from './util.slice-text-block'\n\n/**\n * @beta\n */\nexport function splitTextBlock({\n context,\n block,\n point,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: PortableTextTextBlock\n point: EditorSelectionPoint\n}): {before: PortableTextTextBlock; after: PortableTextTextBlock} | undefined {\n const firstChild = block.children.at(0)\n const lastChild = block.children.at(block.children.length - 1)\n\n if (!firstChild || !lastChild) {\n return undefined\n }\n\n const before = sliceTextBlock({\n context: {\n schema: context.schema,\n selection: {\n anchor: {\n path: [{_key: block._key}, 'children', {_key: firstChild._key}],\n offset: 0,\n },\n focus: point,\n },\n },\n block,\n })\n const after = sliceTextBlock({\n context: {\n schema: context.schema,\n selection: {\n anchor: point,\n focus: {\n path: [{_key: block._key}, 'children', {_key: lastChild._key}],\n offset: isSpan(context, lastChild) ? lastChild.text.length : 0,\n },\n },\n },\n block,\n })\n\n return {before, after}\n}\n"],"names":["blockOffsetToBlockSelectionPoint","context","blockOffset","selectionPoint","block","value","_key","path","offset","blockOffsetToSelectionPoint","direction","blockOffsetToSpanSelectionPoint","blockOffsetsToSelection","offsets","backward","anchor","focus","childSelectionPointToBlockOffset","blockKey","getBlockKeyFromSelectionPoint","childKey","getChildKeyFromSelectionPoint","isTextBlock","child","children","isSpan","text","length","isEqualSelections","a","b","isEqualSelectionPoints","mergeTextBlocks","targetBlock","incomingBlock","parsedIncomingBlock","parseBlock","options","removeUnusedMarkDefs","validateFields","markDefs","reverseSelection","selection","selectionPointToBlockOffset","undefined","splitTextBlock","point","firstChild","at","lastChild","before","sliceTextBlock","schema","after"],"mappings":";;;;;;AAOO,SAASA,iCAAiC;AAAA,EAC/CC;AAAAA,EACAC;AAIF,GAAqC;AACnC,MAAIC;AAEJ,aAAWC,SAASH,QAAQI;AAC1B,QAAID,MAAME,SAASJ,YAAYK,KAAK,CAAC,EAAED,MAAM;AAC3CH,uBAAiB;AAAA,QACfI,MAAM,CAAC;AAAA,UAACD,MAAMF,MAAME;AAAAA,QAAAA,CAAK;AAAA,QACzBE,QAAQN,YAAYM;AAAAA,MAAAA;AAEtB;AAAA,IACF;AAGF,SAAOL;AACT;AClBO,SAASM,4BAA4B;AAAA,EAC1CR;AAAAA,EACAC;AAAAA,EACAQ;AAKF,GAAqC;AAOnC,SAN2BC,gCAAgC;AAAA,IACzDV;AAAAA,IACAC;AAAAA,IACAQ;AAAAA,EAAAA,CACD,KAGQV,iCAAiC;AAAA,IACtCC;AAAAA,IACAC;AAAAA,EAAAA,CACD;AAIL;ACxBO,SAASU,wBAAwB;AAAA,EACtCX;AAAAA,EACAY;AAAAA,EACAC;AAKF,GAAoB;AAClB,QAAMC,SAASN,4BAA4B;AAAA,IACzCR;AAAAA,IACAC,aAAaW,QAAQE;AAAAA,IACrBL,WAAWI,WAAW,aAAa;AAAA,EAAA,CACpC,GACKE,QAAQP,4BAA4B;AA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AAAA,GAAO,YAAY;AAAA,YAACA,MAAMyC,WAAWzC;AAAAA,UAAAA,CAAK;AAAA,UAC9DE,QAAQ;AAAA,QAAA;AAAA,QAEVQ,OAAO8B;AAAAA,MAAAA;AAAAA,IACT;AAAA,IAEF1C;AAAAA,EAAAA,CACD,GACKiD,QAAQF,eAAe;AAAA,IAC3BlD,SAAS;AAAA,MACPmD,QAAQnD,QAAQmD;AAAAA,MAChBV,WAAW;AAAA,QACT3B,QAAQ+B;AAAAA,QACR9B,OAAO;AAAA,UACLT,MAAM,CAAC;AAAA,YAACD,MAAMF,MAAME;AAAAA,UAAAA,GAAO,YAAY;AAAA,YAACA,MAAM2C,UAAU3C;AAAAA,UAAAA,CAAK;AAAA,UAC7DE,QAAQiB,OAAOxB,SAASgD,SAAS,IAAIA,UAAUvB,KAAKC,SAAS;AAAA,QAAA;AAAA,MAC/D;AAAA,IACF;AAAA,IAEFvB;AAAAA,EAAAA,CACD;AAED,SAAO;AAAA,IAAC8C;AAAAA,IAAQG;AAAAA,EAAAA;AAClB;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/utils/util.block-offset-to-block-selection-point.ts","../../src/utils/util.block-offset-to-selection-point.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.is-equal-selections.ts","../../src/utils/util.merge-text-blocks.ts","../../src/utils/util.reverse-selection.ts","../../src/utils/util.selection-point-to-block-offset.ts","../../src/utils/util.split-text-block.ts"],"sourcesContent":["import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\n\n/**\n * @public\n */\nexport function blockOffsetToBlockSelectionPoint({\n context,\n blockOffset,\n}: {\n context: Pick<EditorContext, 'value'>\n blockOffset: BlockOffset\n}): EditorSelectionPoint | undefined {\n let selectionPoint: EditorSelectionPoint | undefined\n\n for (const block of context.value) {\n if (block._key === blockOffset.path[0]._key) {\n selectionPoint = {\n path: [{_key: block._key}],\n offset: blockOffset.offset,\n }\n break\n }\n }\n\n return selectionPoint\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {blockOffsetToSpanSelectionPoint} from './util.block-offset'\nimport {blockOffsetToBlockSelectionPoint} from './util.block-offset-to-block-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetToSelectionPoint({\n context,\n blockOffset,\n direction,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n blockOffset: BlockOffset\n direction: 'forward' | 'backward'\n}): EditorSelectionPoint | undefined {\n const spanSelectionPoint = blockOffsetToSpanSelectionPoint({\n context,\n blockOffset,\n direction,\n })\n\n if (!spanSelectionPoint) {\n return blockOffsetToBlockSelectionPoint({\n context,\n blockOffset,\n })\n }\n\n return spanSelectionPoint\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {blockOffsetToSelectionPoint} from './util.block-offset-to-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetsToSelection({\n context,\n offsets,\n backward,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n offsets: {anchor: BlockOffset; focus: BlockOffset}\n backward?: boolean\n}): EditorSelection {\n const anchor = blockOffsetToSelectionPoint({\n context,\n blockOffset: offsets.anchor,\n direction: backward ? 'backward' : 'forward',\n })\n const focus = blockOffsetToSelectionPoint({\n context,\n blockOffset: offsets.focus,\n direction: backward ? 'forward' : 'backward',\n })\n\n if (!anchor || !focus) {\n return null\n }\n\n return {\n anchor,\n focus,\n backward,\n }\n}\n","import {isSpan, isTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from './util.selection-point'\n\n/**\n * @public\n */\nexport function childSelectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n let offset = 0\n\n const blockKey = getBlockKeyFromSelectionPoint(selectionPoint)\n const childKey = getChildKeyFromSelectionPoint(selectionPoint)\n\n if (!blockKey || !childKey) {\n return undefined\n }\n\n for (const block of context.value) {\n if (block._key !== blockKey) {\n continue\n }\n\n if (!isTextBlock(context, block)) {\n continue\n }\n\n for (const child of block.children) {\n if (child._key === childKey) {\n return {\n path: [{_key: block._key}],\n offset: offset + selectionPoint.offset,\n }\n }\n\n if (isSpan(context, child)) {\n offset += child.text.length\n }\n }\n }\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from './util.is-equal-selection-points'\n\n/**\n * @public\n */\nexport function isEqualSelections(a: EditorSelection, b: EditorSelection) {\n if (!a && !b) {\n return true\n }\n\n if (!a || !b) {\n return false\n }\n\n return (\n isEqualSelectionPoints(a.anchor, b.anchor) &&\n isEqualSelectionPoints(a.focus, b.focus)\n )\n}\n","import {isTextBlock} from '@portabletext/schema'\nimport type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {parseBlock} from './parse-blocks'\n\n/**\n * @beta\n */\nexport function mergeTextBlocks({\n context,\n targetBlock,\n incomingBlock,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n targetBlock: PortableTextTextBlock\n incomingBlock: PortableTextTextBlock\n}) {\n const parsedIncomingBlock = parseBlock({\n context,\n block: incomingBlock,\n options: {\n normalize: false,\n removeUnusedMarkDefs: true,\n validateFields: false,\n },\n })\n\n if (!parsedIncomingBlock || !isTextBlock(context, parsedIncomingBlock)) {\n return targetBlock\n }\n\n return {\n ...targetBlock,\n children: [...targetBlock.children, ...parsedIncomingBlock.children],\n markDefs: [\n ...(targetBlock.markDefs ?? []),\n ...(parsedIncomingBlock.markDefs ?? []),\n ],\n }\n}\n","import type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport function reverseSelection<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n>(selection: TEditorSelection): TEditorSelection {\n if (!selection) {\n return selection\n }\n\n if (selection.backward) {\n return {\n anchor: selection.focus,\n focus: selection.anchor,\n backward: false,\n } as TEditorSelection\n }\n\n return {\n anchor: selection.focus,\n focus: selection.anchor,\n backward: true,\n } as TEditorSelection\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {childSelectionPointToBlockOffset} from './util.child-selection-point-to-block-offset'\nimport {getBlockKeyFromSelectionPoint} from './util.selection-point'\n\n/**\n * @public\n */\nexport function selectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n const blockKey = getBlockKeyFromSelectionPoint(selectionPoint)\n\n if (selectionPoint.path.length === 1 && blockKey !== undefined) {\n return {\n path: [{_key: blockKey}],\n offset: selectionPoint.offset,\n }\n }\n\n return childSelectionPointToBlockOffset({\n context,\n selectionPoint,\n })\n}\n","import {isSpan} from '@portabletext/schema'\nimport type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {sliceTextBlock} from './util.slice-text-block'\n\n/**\n * @beta\n */\nexport function splitTextBlock({\n context,\n block,\n point,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: PortableTextTextBlock\n point: EditorSelectionPoint\n}): {before: PortableTextTextBlock; after: PortableTextTextBlock} | undefined {\n const firstChild = block.children.at(0)\n const lastChild = block.children.at(block.children.length - 1)\n\n if (!firstChild || !lastChild) {\n return undefined\n }\n\n const before = sliceTextBlock({\n context: {\n schema: context.schema,\n selection: {\n anchor: {\n path: [{_key: block._key}, 'children', {_key: firstChild._key}],\n offset: 0,\n },\n focus: point,\n },\n },\n block,\n })\n const after = sliceTextBlock({\n context: {\n schema: context.schema,\n selection: {\n anchor: point,\n focus: {\n path: [{_key: block._key}, 'children', {_key: lastChild._key}],\n offset: isSpan(context, lastChild) ? lastChild.text.length : 0,\n },\n },\n },\n block,\n })\n\n return {before, after}\n}\n"],"names":["blockOffsetToBlockSelectionPoint","context","blockOffset","selectionPoint","block","value","_key","path","offset","blockOffsetToSelectionPoint","direction","blockOffsetToSpanSelectionPoint","blockOffsetsToSelection","offsets","backward","anchor","focus","childSelectionPointToBlockOffset","blockKey","getBlockKeyFromSelectionPoint","childKey","getChildKeyFromSelectionPoint","isTextBlock","child","children","isSpan","text","length","isEqualSelections","a","b","isEqualSelectionPoints","mergeTextBlocks","targetBlock","incomingBlock","parsedIncomingBlock","parseBlock","options","normalize","removeUnusedMarkDefs","validateFields","markDefs","reverseSelection","selection","selectionPointToBlockOffset","undefined","splitTextBlock","point","firstChild","at","lastChild","before","sliceTextBlock","schema","after"],"mappings":";;;;;;AAOO,SAASA,iCAAiC;AAAA,EAC/CC;AAAAA,EACAC;AAIF,GAAqC;AACnC,MAAIC;AAEJ,aAAWC,SAASH,QAAQI;AAC1B,QAAID,MAAME,SAASJ,YAAYK,KAAK,CAAC,EAAED,MAAM;AAC3CH,uBAAiB;AAAA,QACfI,MAAM,CAAC;AAAA,UAACD,MAAMF,MAAME;AAAAA,QAAAA,CAAK;AAAA,QACzBE,QAAQN,YAAYM;AAAAA,MAAAA;AAEtB;AAAA,IACF;AAGF,SAAOL;AACT;AClBO,SAASM,4BAA4B;AAAA,EAC1CR;AAAAA,EACAC;AAAAA,EACAQ;AAKF,GAAqC;AAOnC,SAN2BC,gCAAgC;AAAA,IACzDV;AAAAA,IACAC;AAAAA,IACAQ;AAAAA,EAAAA,CACD,KAGQV,iCAAiC;AAAA,IACtCC;AAAAA,IACAC;AAAAA,EAAAA,CACD;AAIL;ACxBO,SAASU,wBAAwB;AAAA,EACtC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CAACqB,cAAc,CAACE;AAClB;AAGF,QAAMC,SAASC,eAAe;AAAA,IAC5BnD,SAAS;AAAA,MACPoD,QAAQpD,QAAQoD;AAAAA,MAChBV,WAAW;AAAA,QACT5B,QAAQ;AAAA,UACNR,MAAM,CAAC;AAAA,YAACD,MAAMF,MAAME;AAAAA,UAAAA,GAAO,YAAY;AAAA,YAACA,MAAM0C,WAAW1C;AAAAA,UAAAA,CAAK;AAAA,UAC9DE,QAAQ;AAAA,QAAA;AAAA,QAEVQ,OAAO+B;AAAAA,MAAAA;AAAAA,IACT;AAAA,IAEF3C;AAAAA,EAAAA,CACD,GACKkD,QAAQF,eAAe;AAAA,IAC3BnD,SAAS;AAAA,MACPoD,QAAQpD,QAAQoD;AAAAA,MAChBV,WAAW;AAAA,QACT5B,QAAQgC;AAAAA,QACR/B,OAAO;AAAA,UACLT,MAAM,CAAC;AAAA,YAACD,MAAMF,MAAME;AAAAA,UAAAA,GAAO,YAAY;AAAA,YAACA,MAAM4C,UAAU5C;AAAAA,UAAAA,CAAK;AAAA,UAC7DE,QAAQiB,OAAOxB,SAASiD,SAAS,IAAIA,UAAUxB,KAAKC,SAAS;AAAA,QAAA;AAAA,MAC/D;AAAA,IACF;AAAA,IAEFvB;AAAAA,EAAAA,CACD;AAED,SAAO;AAAA,IAAC+C;AAAAA,IAAQG;AAAAA,EAAAA;AAClB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -74,9 +74,9 @@
74
74
  "slate-react": "0.119.0",
75
75
  "xstate": "^5.24.0",
76
76
  "@portabletext/block-tools": "^4.0.2",
77
- "@portabletext/schema": "^2.0.0",
78
77
  "@portabletext/keyboard-shortcuts": "^2.1.0",
79
- "@portabletext/patches": "^2.0.0"
78
+ "@portabletext/patches": "^2.0.0",
79
+ "@portabletext/schema": "^2.0.0"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@sanity/diff-match-patch": "^3.2.0",
@@ -130,6 +130,7 @@ export const abstractSplitBehaviors = [
130
130
  }),
131
131
  context: snapshot.context,
132
132
  options: {
133
+ normalize: false,
133
134
  removeUnusedMarkDefs: true,
134
135
  validateFields: false,
135
136
  },
@@ -50,6 +50,7 @@ export const converterPortableText = defineConverter({
50
50
  context: snapshot.context,
51
51
  block,
52
52
  options: {
53
+ normalize: false,
53
54
  removeUnusedMarkDefs: true,
54
55
  validateFields: false,
55
56
  },
@@ -61,6 +61,7 @@ export function createConverterTextHtml(
61
61
  context: snapshot.context,
62
62
  block,
63
63
  options: {
64
+ normalize: false,
64
65
  removeUnusedMarkDefs: true,
65
66
  validateFields: false,
66
67
  },
@@ -85,6 +85,7 @@ export function createConverterTextPlain(
85
85
  context: snapshot.context,
86
86
  block,
87
87
  options: {
88
+ normalize: false,
88
89
  removeUnusedMarkDefs: true,
89
90
  validateFields: false,
90
91
  },
@@ -467,6 +467,7 @@ export const PortableTextEditable = forwardRef<
467
467
  },
468
468
  blocks: result.insert,
469
469
  options: {
470
+ normalize: false,
470
471
  removeUnusedMarkDefs: true,
471
472
  validateFields: false,
472
473
  },
@@ -1,12 +1,13 @@
1
- import {Editor} from 'slate'
1
+ import {Editor, Node, Text} from 'slate'
2
2
  import {slateRangeToSelection} from '../../internal-utils/slate-utils'
3
3
  import {performOperation} from '../../operations/behavior.operations'
4
4
  import type {EditorActor} from '../editor-machine'
5
+ import {isNormalizingNode} from '../with-normalizing-node'
5
6
  import {isPerformingBehaviorOperation} from '../with-performing-behavior-operation'
6
7
 
7
8
  export function createWithEventListeners(editorActor: EditorActor) {
8
9
  return function withEventListeners(editor: Editor) {
9
- const {delete: editorDelete, select} = editor
10
+ const {delete: editorDelete, insertNodes, select} = editor
10
11
 
11
12
  editor.delete = (options) => {
12
13
  if (isPerformingBehaviorOperation(editor)) {
@@ -115,6 +116,33 @@ export function createWithEventListeners(editorActor: EditorActor) {
115
116
  })
116
117
  }
117
118
 
119
+ editor.insertNodes = (nodes, options) => {
120
+ if (isNormalizingNode(editor)) {
121
+ const normalizedNodes = (Node.isNode(nodes) ? [nodes] : nodes).map(
122
+ (node) => {
123
+ if (!Text.isText(node)) {
124
+ return node
125
+ }
126
+
127
+ if (typeof node._type !== 'string') {
128
+ return {
129
+ ...(node as Node),
130
+ _type: editorActor.getSnapshot().context.schema.span.name,
131
+ }
132
+ }
133
+
134
+ return node
135
+ },
136
+ ) as Array<Node>
137
+
138
+ insertNodes(normalizedNodes, options)
139
+
140
+ return
141
+ }
142
+
143
+ insertNodes(nodes, options)
144
+ }
145
+
118
146
  editor.insertSoftBreak = () => {
119
147
  if (isPerformingBehaviorOperation(editor)) {
120
148
  performOperation({
@@ -264,7 +264,7 @@ describe('operationToPatches', () => {
264
264
  `)
265
265
  })
266
266
 
267
- it('produce correct insert child patch', () => {
267
+ test('produce correct insert child patch', () => {
268
268
  expect(
269
269
  insertNodePatch(
270
270
  schema,
@@ -283,30 +283,28 @@ describe('operationToPatches', () => {
283
283
 
284
284
  createDefaultValue(),
285
285
  ),
286
- ).toMatchInlineSnapshot(`
287
- [
288
- {
289
- "items": [
290
- {
291
- "_key": "c130395c640c",
292
- "_type": "someObject",
293
- "title": "The Object",
294
- },
295
- ],
296
- "path": [
297
- {
298
- "_key": "1f2e64b47787",
299
- },
300
- "children",
301
- {
302
- "_key": "fd9b4a4e6c0b",
303
- },
304
- ],
305
- "position": "after",
306
- "type": "insert",
307
- },
308
- ]
309
- `)
286
+ ).toEqual([
287
+ {
288
+ items: [
289
+ {
290
+ _key: 'c130395c640c',
291
+ _type: 'someObject',
292
+ title: 'The Object',
293
+ },
294
+ ],
295
+ path: [
296
+ {
297
+ _key: '1f2e64b47787',
298
+ },
299
+ 'children',
300
+ {
301
+ _key: 'fd9b4a4e6c0b',
302
+ },
303
+ ],
304
+ position: 'after',
305
+ type: 'insert',
306
+ },
307
+ ])
310
308
  })
311
309
 
312
310
  it('produce correct insert text patch', () => {
@@ -309,32 +309,41 @@ export function insertNodePatch(
309
309
  block.children.length === 0 || !block.children[operation.path[1] - 1]
310
310
  ? 'before'
311
311
  : 'after'
312
- const node = {...operation.node} as Descendant
313
- if (!node._type && Text.isText(node)) {
314
- node._type = 'span'
315
- node.marks = []
312
+ const path =
313
+ block.children.length <= 1 || !block.children[operation.path[1] - 1]
314
+ ? [{_key: block._key}, 'children', 0]
315
+ : [
316
+ {_key: block._key},
317
+ 'children',
318
+ {_key: block.children[operation.path[1] - 1]._key},
319
+ ]
320
+
321
+ if (Text.isText(operation.node)) {
322
+ return [insert([operation.node], position, path)]
316
323
  }
317
- const blk = fromSlateValue(
318
- [
319
- {
320
- _key: 'bogus',
321
- _type: schema.block.name,
322
- children: [node],
323
- },
324
- ],
325
- schema.block.name,
326
- )[0] as PortableTextTextBlock
327
- const child = blk.children[0]
324
+
325
+ const _type = operation.node._type
326
+ const _key = operation.node._key
327
+ const value =
328
+ 'value' in operation.node && typeof operation.node.value === 'object'
329
+ ? operation.node.value
330
+ : ({} satisfies Record<string, unknown>)
331
+
328
332
  return [
329
- insert([child], position, [
330
- {_key: block._key},
331
- 'children',
332
- block.children.length <= 1 || !block.children[operation.path[1] - 1]
333
- ? 0
334
- : {_key: block.children[operation.path[1] - 1]._key},
335
- ]),
333
+ insert(
334
+ [
335
+ {
336
+ _type,
337
+ _key,
338
+ ...value,
339
+ },
340
+ ],
341
+ position,
342
+ path,
343
+ ),
336
344
  ]
337
345
  }
346
+
338
347
  return []
339
348
  }
340
349
 
@@ -1,8 +1,10 @@
1
1
  import {compileSchema, defineSchema} from '@portabletext/schema'
2
+ import {createTestKeyGenerator} from '@portabletext/test'
2
3
  import {expect, test} from 'vitest'
3
4
  import {getSelectionText} from './selection-text'
4
5
 
5
6
  test(getSelectionText.name, () => {
7
+ const keyGenerator = createTestKeyGenerator()
6
8
  const schema = compileSchema(defineSchema({}))
7
9
  const splitBlock = {
8
10
  _type: 'block',
@@ -18,6 +20,7 @@ test(getSelectionText.name, () => {
18
20
 
19
21
  expect(
20
22
  getSelectionText({
23
+ keyGenerator,
21
24
  schema,
22
25
  value: [splitBlock],
23
26
  selection: {
@@ -3,14 +3,17 @@ import type {EditorContext} from '../editor/editor-snapshot'
3
3
  import {sliceBlocks} from '../utils/util.slice-blocks'
4
4
 
5
5
  export function getSelectionText(
6
- context: Pick<EditorContext, 'schema' | 'value' | 'selection'>,
6
+ context: Pick<
7
+ EditorContext,
8
+ 'keyGenerator' | 'schema' | 'value' | 'selection'
9
+ >,
7
10
  ) {
8
11
  if (!context.selection) {
9
12
  return []
10
13
  }
11
14
 
12
15
  const slice = sliceBlocks({
13
- context: {schema: context.schema, selection: context.selection},
16
+ context,
14
17
  blocks: context.value,
15
18
  })
16
19
 
@@ -42,6 +42,7 @@ export function toSlateBlock(
42
42
  ): Descendant {
43
43
  const {_type, _key, ...rest} = block
44
44
  const isPortableText = block && block._type === schemaTypes.block.name
45
+
45
46
  if (isPortableText) {
46
47
  const textBlock = block as PortableTextTextBlock
47
48
  let hasInlines = false
@@ -50,35 +51,44 @@ export function toSlateBlock(
50
51
  const hasMissingChildren = typeof textBlock.children === 'undefined'
51
52
 
52
53
  const children = (textBlock.children || []).map((child) => {
53
- const {_type: cType, _key: cKey, ...cRest} = child
54
- // Return 'slate' version of inline object where the actual
55
- // value is stored in the `value` property.
56
- // In slate, inline objects are represented as regular
57
- // children with actual text node in order to be able to
58
- // be selected the same way as the rest of the (text) content.
59
- if (cType !== 'span') {
54
+ const {_type: childType, _key: childKey, ...childProps} = child
55
+ const propKeys = Object.keys(childProps)
56
+
57
+ if (childType !== schemaTypes.span.name) {
58
+ if (propKeys.length === 1 && propKeys.at(0) === 'text') {
59
+ return child
60
+ }
61
+
62
+ // Return 'slate' version of inline object where the actual
63
+ // value is stored in the `value` property.
64
+ // In slate, inline objects are represented as regular
65
+ // children with actual text node in order to be able to
66
+ // be selected the same way as the rest of the (text) content.
60
67
  hasInlines = true
68
+
61
69
  return keepObjectEquality(
62
70
  {
63
- _type: cType,
64
- _key: cKey,
71
+ _type: childType,
72
+ _key: childKey,
65
73
  children: [
66
74
  {
67
75
  _key: VOID_CHILD_KEY,
68
- _type: 'span',
76
+ _type: schemaTypes.span.name,
69
77
  text: '',
70
78
  marks: [],
71
79
  },
72
80
  ],
73
- value: cRest,
81
+ value: childProps,
74
82
  __inline: true,
75
83
  },
76
84
  keyMap,
77
85
  )
78
86
  }
87
+
79
88
  // Original child object (span)
80
89
  return child
81
90
  })
91
+
82
92
  // Return original block
83
93
  if (
84
94
  !hasMissingStyle &&
@@ -90,10 +100,12 @@ export function toSlateBlock(
90
100
  // Original object
91
101
  return block
92
102
  }
103
+
93
104
  // TODO: remove this when we have a better way to handle missing style
94
105
  if (hasMissingStyle) {
95
106
  rest.style = schemaTypes.styles[0].name
96
107
  }
108
+
97
109
  return keepObjectEquality(
98
110
  {_type, _key, ...rest, children},
99
111
  keyMap,
@@ -31,6 +31,7 @@ export const blockSetOperationImplementation: BehaviorOperationImplementation<
31
31
  context,
32
32
  block: updatedBlock,
33
33
  options: {
34
+ normalize: false,
34
35
  removeUnusedMarkDefs: false,
35
36
  validateFields: true,
36
37
  },
@@ -52,6 +52,7 @@ export const blockUnsetOperationImplementation: BehaviorOperationImplementation<
52
52
  context,
53
53
  block: omit(parsedBlock, propsToRemove),
54
54
  options: {
55
+ normalize: false,
55
56
  removeUnusedMarkDefs: true,
56
57
  validateFields: true,
57
58
  },
@@ -85,6 +86,7 @@ export const blockUnsetOperationImplementation: BehaviorOperationImplementation<
85
86
  operation.props.filter((prop) => prop !== '_type'),
86
87
  ),
87
88
  options: {
89
+ normalize: false,
88
90
  removeUnusedMarkDefs: true,
89
91
  validateFields: true,
90
92
  },
@@ -28,6 +28,7 @@ export const insertBlockOperationImplementation: BehaviorOperationImplementation
28
28
  block: operation.block,
29
29
  context,
30
30
  options: {
31
+ normalize: true,
31
32
  removeUnusedMarkDefs: true,
32
33
  validateFields: true,
33
34
  },
@@ -114,6 +114,7 @@ export const stepDefinitions = [
114
114
  },
115
115
  blocks: JSON.parse(blocks),
116
116
  options: {
117
+ normalize: false,
117
118
  removeUnusedMarkDefs: false,
118
119
  validateFields: true,
119
120
  },
@@ -561,6 +562,7 @@ export const stepDefinitions = [
561
562
  },
562
563
  blocks: JSON.parse(blocks),
563
564
  options: {
565
+ normalize: false,
564
566
  removeUnusedMarkDefs: false,
565
567
  validateFields: true,
566
568
  },