roosterjs-content-model-api 9.1.0 → 9.3.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.
Files changed (73) hide show
  1. package/lib/index.d.ts +2 -0
  2. package/lib/index.js +5 -1
  3. package/lib/index.js.map +1 -1
  4. package/lib/modelApi/block/setModelIndentation.d.ts +2 -2
  5. package/lib/modelApi/block/setModelIndentation.js +6 -1
  6. package/lib/modelApi/block/setModelIndentation.js.map +1 -1
  7. package/lib/modelApi/list/findListItemsInSameThread.d.ts +2 -2
  8. package/lib/modelApi/list/findListItemsInSameThread.js +8 -4
  9. package/lib/modelApi/list/findListItemsInSameThread.js.map +1 -1
  10. package/lib/modelApi/list/getListAnnounceData.d.ts +7 -0
  11. package/lib/modelApi/list/getListAnnounceData.js +69 -0
  12. package/lib/modelApi/list/getListAnnounceData.js.map +1 -0
  13. package/lib/publicApi/image/insertImage.js +2 -0
  14. package/lib/publicApi/image/insertImage.js.map +1 -1
  15. package/lib/publicApi/table/editTable.js +17 -0
  16. package/lib/publicApi/table/editTable.js.map +1 -1
  17. package/lib/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -1
  18. package/lib/publicApi/utils/formatInsertPointWithContentModel.js +5 -1
  19. package/lib/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  20. package/lib/publicApi/utils/formatSegmentWithContentModel.js +2 -1
  21. package/lib/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  22. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +3 -2
  23. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +6 -2
  24. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  25. package/lib-amd/index.d.ts +2 -0
  26. package/lib-amd/index.js +4 -2
  27. package/lib-amd/index.js.map +1 -1
  28. package/lib-amd/modelApi/block/setModelIndentation.d.ts +2 -2
  29. package/lib-amd/modelApi/block/setModelIndentation.js +5 -2
  30. package/lib-amd/modelApi/block/setModelIndentation.js.map +1 -1
  31. package/lib-amd/modelApi/list/findListItemsInSameThread.d.ts +2 -2
  32. package/lib-amd/modelApi/list/findListItemsInSameThread.js +8 -4
  33. package/lib-amd/modelApi/list/findListItemsInSameThread.js.map +1 -1
  34. package/lib-amd/modelApi/list/getListAnnounceData.d.ts +7 -0
  35. package/lib-amd/modelApi/list/getListAnnounceData.js +69 -0
  36. package/lib-amd/modelApi/list/getListAnnounceData.js.map +1 -0
  37. package/lib-amd/publicApi/image/insertImage.js +2 -0
  38. package/lib-amd/publicApi/image/insertImage.js.map +1 -1
  39. package/lib-amd/publicApi/table/editTable.js +17 -0
  40. package/lib-amd/publicApi/table/editTable.js.map +1 -1
  41. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -1
  42. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js +5 -1
  43. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  44. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js +2 -1
  45. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  46. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +3 -2
  47. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +6 -2
  48. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  49. package/lib-mjs/index.d.ts +2 -0
  50. package/lib-mjs/index.js +2 -0
  51. package/lib-mjs/index.js.map +1 -1
  52. package/lib-mjs/modelApi/block/setModelIndentation.d.ts +2 -2
  53. package/lib-mjs/modelApi/block/setModelIndentation.js +6 -1
  54. package/lib-mjs/modelApi/block/setModelIndentation.js.map +1 -1
  55. package/lib-mjs/modelApi/list/findListItemsInSameThread.d.ts +2 -2
  56. package/lib-mjs/modelApi/list/findListItemsInSameThread.js +8 -4
  57. package/lib-mjs/modelApi/list/findListItemsInSameThread.js.map +1 -1
  58. package/lib-mjs/modelApi/list/getListAnnounceData.d.ts +7 -0
  59. package/lib-mjs/modelApi/list/getListAnnounceData.js +65 -0
  60. package/lib-mjs/modelApi/list/getListAnnounceData.js.map +1 -0
  61. package/lib-mjs/publicApi/image/insertImage.js +3 -1
  62. package/lib-mjs/publicApi/image/insertImage.js.map +1 -1
  63. package/lib-mjs/publicApi/table/editTable.js +17 -0
  64. package/lib-mjs/publicApi/table/editTable.js.map +1 -1
  65. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -1
  66. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js +5 -1
  67. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  68. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js +2 -1
  69. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  70. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +3 -2
  71. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +6 -2
  72. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  73. package/package.json +3 -3
@@ -1,5 +1,9 @@
1
1
  import type { DOMInsertPoint, FormatContentModelOptions, IEditor, InsertPoint, ContentModelDocument, FormatContentModelContext } from 'roosterjs-content-model-types';
2
2
  /**
3
- * @internal
3
+ * Format content model at a given insert point with a callback function
4
+ * @param editor The editor object
5
+ * @param insertPoint The insert point to format
6
+ * @param callback The callback function to format the content model
7
+ * @param options Options to control the behavior of the formatting
4
8
  */
5
9
  export declare function formatInsertPointWithContentModel(editor: IEditor, insertPoint: DOMInsertPoint, callback: (model: ContentModelDocument, context: FormatContentModelContext, insertPoint?: InsertPoint) => void, options?: FormatContentModelOptions): void;
@@ -1,7 +1,11 @@
1
1
  import { __read, __spreadArray } from "tslib";
2
2
  import { addSegment, addTextSegment, buildSelectionMarker, getRegularSelectionOffsets, processChildNode, } from 'roosterjs-content-model-dom';
3
3
  /**
4
- * @internal
4
+ * Format content model at a given insert point with a callback function
5
+ * @param editor The editor object
6
+ * @param insertPoint The insert point to format
7
+ * @param callback The callback function to format the content model
8
+ * @param options Options to control the behavior of the formatting
5
9
  */
6
10
  export function formatInsertPointWithContentModel(editor, insertPoint, callback, options) {
7
11
  var bundle = {
@@ -1 +1 @@
1
- {"version":3,"file":"formatInsertPointWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatInsertPointWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,GACnB,MAAM,6BAA6B,CAAC;AAarC;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAC7C,MAAe,EACf,WAA2B,EAC3B,QAIS,EACT,OAAmC;IAEnC,IAAM,MAAM,GAAsB;QAC9B,KAAK,EAAE,WAAW;KACrB,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;YACV,IAAA,KAAwB,MAAM,CAAC,MAAM,EAAnC,SAAS,eAAA,EAAE,MAAM,YAAkB,CAAC;YAC5C,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAEjD,IAAI,KAAK,IAAI,CAAC,EAAE;gBACZ,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aACvC;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC,EACD,OAAO,EACP;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC;YACtC,iBAAiB,EAAE,sBAAsB,CAAC,MAAM,CAAC;S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,IAAI,MAAM,IAAI,OAAO,CAAC,IAAI,EAAE;QACxB,MAAM,CAAC,MAAM,GAAG;YACZ,IAAI,2BAAM,OAAO,CAAC,IAAI,SAAC;YACvB,SAAS,EAAE,IAAI;YACf,MAAM,QAAA;SACT,CAAC;KACL;AACL,CAAC;AAED,SAAS,yBAAyB,CAC9B,OAA0B,EAC1B,MAAyB,EACzB,gBAAsB;IAEhB,IAAA,KAAA,OAAe,0BAA0B,CAAC,OAAO,EAAE,gBAAgB,CAAC,IAAA,EAAnE,KAAK,QAAA,EAAE,GAAG,QAAyD,CAAC;IAC3E,IAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhF,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import {\n addSegment,\n addTextSegment,\n buildSelectionMarker,\n getRegularSelectionOffsets,\n processChildNode,\n} from 'roosterjs-content-model-dom';\nimport type {\n ElementProcessor,\n DOMInsertPoint,\n FormatContentModelOptions,\n IEditor,\n InsertPoint,\n DomToModelContext,\n ContentModelBlockGroup,\n ContentModelDocument,\n FormatContentModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function formatInsertPointWithContentModel(\n editor: IEditor,\n insertPoint: DOMInsertPoint,\n callback: (\n model: ContentModelDocument,\n context: FormatContentModelContext,\n insertPoint?: InsertPoint\n ) => void,\n options?: FormatContentModelOptions\n) {\n const bundle: InsertPointBundle = {\n input: insertPoint,\n };\n\n editor.formatContentModel(\n (model, context) => {\n callback(model, context, bundle.result);\n\n if (bundle?.result) {\n const { paragraph, marker } = bundle.result;\n const index = paragraph.segments.indexOf(marker);\n\n if (index >= 0) {\n paragraph.segments.splice(index, 1);\n }\n }\n return true;\n },\n options,\n {\n processorOverride: {\n child: getShadowChildProcessor(bundle),\n textWithSelection: getShadowTextProcessor(bundle),\n },\n tryGetFromCache: false,\n }\n );\n}\n\ninterface InsertPointBundle {\n input: DOMInsertPoint;\n result?: InsertPoint;\n}\n\ninterface DomToModelContextWithPath extends DomToModelContext {\n /**\n * Block group path of this insert point, from direct parent group to the root group\n */\n path?: ContentModelBlockGroup[];\n}\n\nfunction getShadowChildProcessor(bundle: InsertPointBundle): ElementProcessor<ParentNode> {\n return (group, parent, context) => {\n const contextWithPath = context as DomToModelContextWithPath;\n\n contextWithPath.path = contextWithPath.path || [];\n\n let shouldShiftPath = false;\n if (contextWithPath.path[0] != group) {\n contextWithPath.path.unshift(group);\n shouldShiftPath = true;\n }\n\n const offsets = getShadowSelectionOffsets(context, bundle, parent);\n let index = 0;\n\n for (let child = parent.firstChild; child; child = child.nextSibling) {\n handleElementShadowSelection(bundle, index, context, group, offsets, parent);\n\n processChildNode(group, child, context);\n\n index++;\n }\n\n handleElementShadowSelection(bundle, index, context, group, offsets, parent);\n\n if (shouldShiftPath) {\n contextWithPath.path.shift();\n }\n };\n}\n\nfunction handleElementShadowSelection(\n bundle: InsertPointBundle,\n index: number,\n context: DomToModelContext,\n group: ContentModelBlockGroup,\n offsets: [number, number, number],\n container?: Node\n) {\n if (\n index == offsets[2] &&\n (index <= offsets[0] || offsets[0] < 0) &&\n (index < offsets[1] || offsets[1] < 0)\n ) {\n addSelectionMarker(group, context, container, index, bundle);\n offsets[2] = -1;\n }\n\n if (index == offsets[0]) {\n context.isInSelection = true;\n addSelectionMarker(group, context, container, index);\n }\n\n if (index == offsets[2] && (index < offsets[1] || offsets[1] < 0)) {\n addSelectionMarker(group, context, container, index, bundle);\n offsets[2] = -1;\n }\n\n if (index == offsets[1]) {\n addSelectionMarker(group, context, container, index);\n context.isInSelection = false;\n }\n\n if (index == offsets[2]) {\n addSelectionMarker(group, context, container, index, bundle);\n }\n}\n\nconst getShadowTextProcessor = (bundle: InsertPointBundle): ElementProcessor<Text> => (\n group,\n textNode,\n context\n) => {\n let txt = textNode.nodeValue || '';\n const offsets = getShadowSelectionOffsets(context, bundle, textNode);\n const [start, end, shadow] = offsets;\n\n const handleTextSelection = (\n subtract: number,\n originalOffset: number,\n bundle?: InsertPointBundle\n ) => {\n addTextSegment(group, txt.substring(0, subtract), context);\n addSelectionMarker(group, context, textNode, originalOffset, bundle);\n\n offsets[0] -= subtract;\n offsets[1] -= subtract;\n offsets[2] = bundle ? -1 : offsets[2] - subtract;\n\n txt = txt.substring(subtract);\n };\n\n if (\n offsets[2] >= 0 &&\n (offsets[2] <= offsets[0] || offsets[0] < 0) &&\n (offsets[2] < offsets[1] || offsets[1] < 0)\n ) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n if (offsets[0] >= 0) {\n handleTextSelection(offsets[0], start);\n\n context.isInSelection = true;\n }\n\n if (offsets[2] >= 0 && offsets[2] > offsets[0] && (offsets[2] < offsets[1] || offsets[1] < 0)) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n if (offsets[1] >= 0) {\n handleTextSelection(offsets[1], end);\n\n context.isInSelection = false;\n }\n\n if (offsets[2] >= 0 && offsets[2] >= offsets[1]) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n addTextSegment(group, txt, context);\n};\n\nfunction addSelectionMarker(\n group: ContentModelBlockGroup,\n context: DomToModelContextWithPath,\n container?: Node,\n offset?: number,\n bundle?: InsertPointBundle\n) {\n const marker = buildSelectionMarker(group, context, container, offset);\n\n marker.isSelected = !bundle;\n\n const para = addSegment(group, marker, context.blockFormat, marker.format);\n\n if (bundle && context.path) {\n bundle.result = {\n path: [...context.path],\n paragraph: para,\n marker,\n };\n }\n}\n\nfunction getShadowSelectionOffsets(\n context: DomToModelContext,\n bundle: InsertPointBundle,\n currentContainer: Node\n): [number, number, number] {\n const [start, end] = getRegularSelectionOffsets(context, currentContainer);\n const shadow = bundle.input.node == currentContainer ? bundle.input.offset : -1;\n\n return [start, end, shadow];\n}\n"]}
1
+ {"version":3,"file":"formatInsertPointWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatInsertPointWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,GACnB,MAAM,6BAA6B,CAAC;AAarC;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAC7C,MAAe,EACf,WAA2B,EAC3B,QAIS,EACT,OAAmC;IAEnC,IAAM,MAAM,GAAsB;QAC9B,KAAK,EAAE,WAAW;KACrB,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;YACV,IAAA,KAAwB,MAAM,CAAC,MAAM,EAAnC,SAAS,eAAA,EAAE,MAAM,YAAkB,CAAC;YAC5C,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAEjD,IAAI,KAAK,IAAI,CAAC,EAAE;gBACZ,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aACvC;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC,EACD,OAAO,EACP;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC;YACtC,iBAAiB,EAAE,sBAAsB,CAAC,MAAM,CAAC;SACpD;QACD,eAAe,EAAE,KAAK;KACzB,CACJ,CAAC;AACN,CAAC;AAcD,SAAS,uBAAuB,CAAC,MAAyB;IACtD,OAAO,UAAC,KAAK,EAAE,MAAM,EAAE,OAAO;QAC1B,IAAM,eAAe,GAAG,OAAoC,CAAC;QAE7D,eAAe,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,IAA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B,EACzB,gBAAsB;IAEhB,IAAA,KAAA,OAAe,0BAA0B,CAAC,OAAO,EAAE,gBAAgB,CAAC,IAAA,EAAnE,KAAK,QAAA,EAAE,GAAG,QAAyD,CAAC;IAC3E,IAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhF,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import {\n addSegment,\n addTextSegment,\n buildSelectionMarker,\n getRegularSelectionOffsets,\n processChildNode,\n} from 'roosterjs-content-model-dom';\nimport type {\n ElementProcessor,\n DOMInsertPoint,\n FormatContentModelOptions,\n IEditor,\n InsertPoint,\n DomToModelContext,\n ContentModelBlockGroup,\n ContentModelDocument,\n FormatContentModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Format content model at a given insert point with a callback function\n * @param editor The editor object\n * @param insertPoint The insert point to format\n * @param callback The callback function to format the content model\n * @param options Options to control the behavior of the formatting\n */\nexport function formatInsertPointWithContentModel(\n editor: IEditor,\n insertPoint: DOMInsertPoint,\n callback: (\n model: ContentModelDocument,\n context: FormatContentModelContext,\n insertPoint?: InsertPoint\n ) => void,\n options?: FormatContentModelOptions\n) {\n const bundle: InsertPointBundle = {\n input: insertPoint,\n };\n\n editor.formatContentModel(\n (model, context) => {\n callback(model, context, bundle.result);\n\n if (bundle?.result) {\n const { paragraph, marker } = bundle.result;\n const index = paragraph.segments.indexOf(marker);\n\n if (index >= 0) {\n paragraph.segments.splice(index, 1);\n }\n }\n return true;\n },\n options,\n {\n processorOverride: {\n child: getShadowChildProcessor(bundle),\n textWithSelection: getShadowTextProcessor(bundle),\n },\n tryGetFromCache: false,\n }\n );\n}\n\ninterface InsertPointBundle {\n input: DOMInsertPoint;\n result?: InsertPoint;\n}\n\ninterface DomToModelContextWithPath extends DomToModelContext {\n /**\n * Block group path of this insert point, from direct parent group to the root group\n */\n path?: ContentModelBlockGroup[];\n}\n\nfunction getShadowChildProcessor(bundle: InsertPointBundle): ElementProcessor<ParentNode> {\n return (group, parent, context) => {\n const contextWithPath = context as DomToModelContextWithPath;\n\n contextWithPath.path = contextWithPath.path || [];\n\n let shouldShiftPath = false;\n if (contextWithPath.path[0] != group) {\n contextWithPath.path.unshift(group);\n shouldShiftPath = true;\n }\n\n const offsets = getShadowSelectionOffsets(context, bundle, parent);\n let index = 0;\n\n for (let child = parent.firstChild; child; child = child.nextSibling) {\n handleElementShadowSelection(bundle, index, context, group, offsets, parent);\n\n processChildNode(group, child, context);\n\n index++;\n }\n\n handleElementShadowSelection(bundle, index, context, group, offsets, parent);\n\n if (shouldShiftPath) {\n contextWithPath.path.shift();\n }\n };\n}\n\nfunction handleElementShadowSelection(\n bundle: InsertPointBundle,\n index: number,\n context: DomToModelContext,\n group: ContentModelBlockGroup,\n offsets: [number, number, number],\n container?: Node\n) {\n if (\n index == offsets[2] &&\n (index <= offsets[0] || offsets[0] < 0) &&\n (index < offsets[1] || offsets[1] < 0)\n ) {\n addSelectionMarker(group, context, container, index, bundle);\n offsets[2] = -1;\n }\n\n if (index == offsets[0]) {\n context.isInSelection = true;\n addSelectionMarker(group, context, container, index);\n }\n\n if (index == offsets[2] && (index < offsets[1] || offsets[1] < 0)) {\n addSelectionMarker(group, context, container, index, bundle);\n offsets[2] = -1;\n }\n\n if (index == offsets[1]) {\n addSelectionMarker(group, context, container, index);\n context.isInSelection = false;\n }\n\n if (index == offsets[2]) {\n addSelectionMarker(group, context, container, index, bundle);\n }\n}\n\nconst getShadowTextProcessor = (bundle: InsertPointBundle): ElementProcessor<Text> => (\n group,\n textNode,\n context\n) => {\n let txt = textNode.nodeValue || '';\n const offsets = getShadowSelectionOffsets(context, bundle, textNode);\n const [start, end, shadow] = offsets;\n\n const handleTextSelection = (\n subtract: number,\n originalOffset: number,\n bundle?: InsertPointBundle\n ) => {\n addTextSegment(group, txt.substring(0, subtract), context);\n addSelectionMarker(group, context, textNode, originalOffset, bundle);\n\n offsets[0] -= subtract;\n offsets[1] -= subtract;\n offsets[2] = bundle ? -1 : offsets[2] - subtract;\n\n txt = txt.substring(subtract);\n };\n\n if (\n offsets[2] >= 0 &&\n (offsets[2] <= offsets[0] || offsets[0] < 0) &&\n (offsets[2] < offsets[1] || offsets[1] < 0)\n ) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n if (offsets[0] >= 0) {\n handleTextSelection(offsets[0], start);\n\n context.isInSelection = true;\n }\n\n if (offsets[2] >= 0 && offsets[2] > offsets[0] && (offsets[2] < offsets[1] || offsets[1] < 0)) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n if (offsets[1] >= 0) {\n handleTextSelection(offsets[1], end);\n\n context.isInSelection = false;\n }\n\n if (offsets[2] >= 0 && offsets[2] >= offsets[1]) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n addTextSegment(group, txt, context);\n};\n\nfunction addSelectionMarker(\n group: ContentModelBlockGroup,\n context: DomToModelContextWithPath,\n container?: Node,\n offset?: number,\n bundle?: InsertPointBundle\n) {\n const marker = buildSelectionMarker(group, context, container, offset);\n\n marker.isSelected = !bundle;\n\n const para = addSegment(group, marker, context.blockFormat, marker.format);\n\n if (bundle && context.path) {\n bundle.result = {\n path: [...context.path],\n paragraph: para,\n marker,\n };\n }\n}\n\nfunction getShadowSelectionOffsets(\n context: DomToModelContext,\n bundle: InsertPointBundle,\n currentContainer: Node\n): [number, number, number] {\n const [start, end] = getRegularSelectionOffsets(context, currentContainer);\n const shadow = bundle.input.node == currentContainer ? bundle.input.offset : -1;\n\n return [start, end, shadow];\n}\n"]}
@@ -17,7 +17,8 @@ export function formatSegmentWithContentModel(editor, apiName, toggleStyleCallba
17
17
  segmentAndParagraphs[0][0].segmentType == 'SelectionMarker';
18
18
  if (isCollapsedSelection) {
19
19
  var para_1 = segmentAndParagraphs[0][1];
20
- segmentAndParagraphs = adjustWordSelection(model, segmentAndParagraphs[0][0]).map(function (x) { return [x, para_1]; });
20
+ var path_1 = segmentAndParagraphs[0][2];
21
+ segmentAndParagraphs = adjustWordSelection(model, segmentAndParagraphs[0][0]).map(function (x) { return [x, para_1, path_1]; });
21
22
  if (segmentAndParagraphs.length > 1) {
22
23
  isCollapsedSelection = false;
23
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAS/E;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAA2D;IAE3D,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,gCAAgC,CACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,CAC1B,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAAC;QAEhE,IAAI,oBAAoB,EAAE;YACtB,IAAM,MAAI,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExC,oBAAoB,GAAG,mBAAmB,CACtC,KAAK,EACL,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC7B,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,EAAE,MAAI,CAAC,EAAT,CAAS,CAAC,CAAC;YAEtB,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjC,oBAAoB,GAAG,KAAK,CAAC;aAChC;SACJ;QAED,IAAM,kBAAkB,GAIlB,oBAAoB,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAlC,CAAkC,CAAC,CAAC;QAE3E,IAAM,YAAY,GAAG,uBAAuB;YACxC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,UAAC,EAA4B;oBAA5B,KAAA,aAA4B,EAA3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;gBACjD,OAAA,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC;YAAnD,CAAmD,CACtD;YACH,CAAC,CAAC,KAAK,CAAC;QAEZ,kBAAkB,CAAC,OAAO,CAAC,UAAC,EAA4B;gBAA5B,KAAA,aAA4B,EAA3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;YACnD,OAAA,mBAAmB,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC;QAA9D,CAA8D,CACjE,CAAC;QAEF,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,KAAK,CAAC,CAAC;QAE7B,IAAI,oBAAoB,EAAE;YACtB,OAAO,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;SAChB;aAAM;YACH,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;SACxC;IACL,CAAC,EACD;QACI,OAAO,SAAA;KACV,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelSegmentFormat,\n IEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected segment using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.\n * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format\n * @param includingFormatHolder True to also include format holder of list item when search selected segments\n * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree\n */\nexport function formatSegmentWithContentModel(\n editor: IEditor,\n apiName: string,\n toggleStyleCallback: (\n format: ContentModelSegmentFormat,\n isTuringOn: boolean,\n segment: ContentModelSegment | null,\n paragraph: ContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ContentModelSegment | null,\n paragraph: ContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length == 1 &&\n segmentAndParagraphs[0][0].segmentType == 'SelectionMarker';\n\n if (isCollapsedSelection) {\n const para = segmentAndParagraphs[0][1];\n\n segmentAndParagraphs = adjustWordSelection(\n model,\n segmentAndParagraphs[0][0]\n ).map(x => [x, para]);\n\n if (segmentAndParagraphs.length > 1) {\n isCollapsedSelection = false;\n }\n }\n\n const formatsAndSegments: [\n ContentModelSegmentFormat,\n ContentModelSegment | null,\n ContentModelParagraph | null\n ][] = segmentAndParagraphs.map(item => [item[0].format, item[0], item[1]]);\n\n const isTurningOff = segmentHasStyleCallback\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\n segmentHasStyleCallback(format, segment, paragraph)\n )\n : false;\n\n formatsAndSegments.forEach(([format, segment, paragraph]) =>\n toggleStyleCallback(format, !isTurningOff, segment, paragraph)\n );\n\n afterFormatCallback?.(model);\n\n if (isCollapsedSelection) {\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\n editor.focus();\n return false;\n } else {\n return formatsAndSegments.length > 0;\n }\n },\n {\n apiName,\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAS/E;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAA2D;IAE3D,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,gCAAgC,CACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,CAC1B,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAAC;QAEhE,IAAI,oBAAoB,EAAE;YACtB,IAAM,MAAI,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,IAAM,MAAI,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExC,oBAAoB,GAAG,mBAAmB,CACtC,KAAK,EACL,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC7B,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,EAAE,MAAI,EAAE,MAAI,CAAC,EAAf,CAAe,CAAC,CAAC;YAE5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selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelSegmentFormat,\n IEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected segment using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.\n * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format\n * @param includingFormatHolder True to also include format holder of list item when search selected segments\n * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree\n */\nexport function formatSegmentWithContentModel(\n editor: IEditor,\n apiName: string,\n toggleStyleCallback: (\n format: ContentModelSegmentFormat,\n isTuringOn: boolean,\n segment: ContentModelSegment | null,\n paragraph: ContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ContentModelSegment | null,\n paragraph: ContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length == 1 &&\n segmentAndParagraphs[0][0].segmentType == 'SelectionMarker';\n\n if (isCollapsedSelection) {\n const para = segmentAndParagraphs[0][1];\n const path = segmentAndParagraphs[0][2];\n\n segmentAndParagraphs = adjustWordSelection(\n model,\n segmentAndParagraphs[0][0]\n ).map(x => [x, para, path]);\n\n if (segmentAndParagraphs.length > 1) {\n isCollapsedSelection = false;\n }\n }\n\n const formatsAndSegments: [\n ContentModelSegmentFormat,\n ContentModelSegment | null,\n ContentModelParagraph | null\n ][] = segmentAndParagraphs.map(item => [item[0].format, item[0], item[1]]);\n\n const isTurningOff = segmentHasStyleCallback\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\n segmentHasStyleCallback(format, segment, paragraph)\n )\n : false;\n\n formatsAndSegments.forEach(([format, segment, paragraph]) =>\n toggleStyleCallback(format, !isTurningOff, segment, paragraph)\n );\n\n afterFormatCallback?.(model);\n\n if (isCollapsedSelection) {\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\n editor.focus();\n return false;\n } else {\n return formatsAndSegments.length > 0;\n }\n },\n {\n apiName,\n }\n );\n}\n"]}
@@ -1,7 +1,8 @@
1
- import type { ContentModelDocument, ContentModelParagraph, ContentModelSegmentFormat, ContentModelText, FormatContentModelContext, IEditor } from 'roosterjs-content-model-types';
1
+ import type { ContentModelDocument, ContentModelParagraph, ContentModelSegmentFormat, ContentModelText, FormatContentModelContext, FormatContentModelOptions, IEditor } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * Invoke a callback to format the text segment before the selection marker using Content Model
4
4
  * @param editor The editor object
5
5
  * @param callback The callback to format the text segment.
6
+ * @returns True if the segment before cursor is found and callback is called, otherwise false
6
7
  */
7
- export declare function formatTextSegmentBeforeSelectionMarker(editor: IEditor, callback: (model: ContentModelDocument, previousSegment: ContentModelText, paragraph: ContentModelParagraph, markerFormat: ContentModelSegmentFormat, context: FormatContentModelContext) => boolean): void;
8
+ export declare function formatTextSegmentBeforeSelectionMarker(editor: IEditor, callback: (model: ContentModelDocument, previousSegment: ContentModelText, paragraph: ContentModelParagraph, markerFormat: ContentModelSegmentFormat, context: FormatContentModelContext) => boolean, options?: FormatContentModelOptions): boolean;
@@ -3,8 +3,10 @@ import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';
3
3
  * Invoke a callback to format the text segment before the selection marker using Content Model
4
4
  * @param editor The editor object
5
5
  * @param callback The callback to format the text segment.
6
+ * @returns True if the segment before cursor is found and callback is called, otherwise false
6
7
  */
7
- export function formatTextSegmentBeforeSelectionMarker(editor, callback) {
8
+ export function formatTextSegmentBeforeSelectionMarker(editor, callback, options) {
9
+ var result = false;
8
10
  editor.formatContentModel(function (model, context) {
9
11
  var selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, false /*includeFormatHolder*/);
10
12
  if (selectedSegmentsAndParagraphs.length > 0 && selectedSegmentsAndParagraphs[0][1]) {
@@ -14,11 +16,13 @@ export function formatTextSegmentBeforeSelectionMarker(editor, callback) {
14
16
  if (marker.segmentType === 'SelectionMarker' && markerIndex > 0) {
15
17
  var previousSegment = paragraph.segments[markerIndex - 1];
16
18
  if (previousSegment && previousSegment.segmentType === 'Text') {
19
+ result = true;
17
20
  return callback(model, previousSegment, paragraph, marker.format, context);
18
21
  }
19
22
  }
20
23
  }
21
24
  return false;
22
- });
25
+ }, options);
26
+ return result;
23
27
  }
24
28
  //# sourceMappingURL=formatTextSegmentBeforeSelectionMarker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatTextSegmentBeforeSelectionMarker.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAU/E;;;;GAIG;AACH,MAAM,UAAU,sCAAsC,CAClD,MAAe,EACf,QAMY;IAEZ,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,OAAO;QACrC,IAAM,6BAA6B,GAAG,gCAAgC,CAClE,KAAK,EACL,KAAK,CAAC,uBAAuB,CAChC,CAAC;QAEF,IAAI,6BAA6B,CAAC,MAAM,GAAG,CAAC,IAAI,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACjF,IAAM,MAAM,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACnD,IAAM,SAAS,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,IAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACvD,IAAI,MAAM,CAAC,WAAW,KAAK,iBAAiB,IAAI,WAAW,GAAG,CAAC,EAAE;gBAC7D,IAAM,eAAe,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;gBAC5D,IAAI,eAAe,IAAI,eAAe,CAAC,WAAW,KAAK,MAAM,EAAE;oBAC3D,OAAO,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;iBAC9E;aACJ;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n ContentModelText,\n FormatContentModelContext,\n IEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the text segment before the selection marker using Content Model\n * @param editor The editor object\n * @param callback The callback to format the text segment.\n */\nexport function formatTextSegmentBeforeSelectionMarker(\n editor: IEditor,\n callback: (\n model: ContentModelDocument,\n previousSegment: ContentModelText,\n paragraph: ContentModelParagraph,\n markerFormat: ContentModelSegmentFormat,\n context: FormatContentModelContext\n ) => boolean\n) {\n editor.formatContentModel((model, context) => {\n const selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n false /*includeFormatHolder*/\n );\n\n if (selectedSegmentsAndParagraphs.length > 0 && selectedSegmentsAndParagraphs[0][1]) {\n const marker = selectedSegmentsAndParagraphs[0][0];\n const paragraph = selectedSegmentsAndParagraphs[0][1];\n const markerIndex = paragraph.segments.indexOf(marker);\n if (marker.segmentType === 'SelectionMarker' && markerIndex > 0) {\n const previousSegment = paragraph.segments[markerIndex - 1];\n if (previousSegment && previousSegment.segmentType === 'Text') {\n return callback(model, previousSegment, paragraph, marker.format, context);\n }\n }\n }\n return false;\n });\n}\n"]}
1
+ {"version":3,"file":"formatTextSegmentBeforeSelectionMarker.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAW/E;;;;;GAKG;AACH,MAAM,UAAU,sCAAsC,CAClD,MAAe,EACf,QAMY,EACZ,OAAmC;IAEnC,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,OAAO;QACrC,IAAM,6BAA6B,GAAG,gCAAgC,CAClE,KAAK,EACL,KAAK,CAAC,uBAAuB,CAChC,CAAC;QAEF,IAAI,6BAA6B,CAAC,MAAM,GAAG,CAAC,IAAI,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACjF,IAAM,MAAM,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACnD,IAAM,SAAS,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,IAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACvD,IAAI,MAAM,CAAC,WAAW,KAAK,iBAAiB,IAAI,WAAW,GAAG,CAAC,EAAE;gBAC7D,IAAM,eAAe,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;gBAC5D,IAAI,eAAe,IAAI,eAAe,CAAC,WAAW,KAAK,MAAM,EAAE;oBAC3D,MAAM,GAAG,IAAI,CAAC;oBAEd,OAAO,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;iBAC9E;aACJ;SACJ;QAED,OAAO,KAAK,CAAC;IACjB,CAAC,EAAE,OAAO,CAAC,CAAC;IAEZ,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n ContentModelText,\n FormatContentModelContext,\n FormatContentModelOptions,\n IEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the text segment before the selection marker using Content Model\n * @param editor The editor object\n * @param callback The callback to format the text segment.\n * @returns True if the segment before cursor is found and callback is called, otherwise false\n */\nexport function formatTextSegmentBeforeSelectionMarker(\n editor: IEditor,\n callback: (\n model: ContentModelDocument,\n previousSegment: ContentModelText,\n paragraph: ContentModelParagraph,\n markerFormat: ContentModelSegmentFormat,\n context: FormatContentModelContext\n ) => boolean,\n options?: FormatContentModelOptions\n): boolean {\n let result = false;\n\n editor.formatContentModel((model, context) => {\n const selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n false /*includeFormatHolder*/\n );\n\n if (selectedSegmentsAndParagraphs.length > 0 && selectedSegmentsAndParagraphs[0][1]) {\n const marker = selectedSegmentsAndParagraphs[0][0];\n const paragraph = selectedSegmentsAndParagraphs[0][1];\n const markerIndex = paragraph.segments.indexOf(marker);\n if (marker.segmentType === 'SelectionMarker' && markerIndex > 0) {\n const previousSegment = paragraph.segments[markerIndex - 1];\n if (previousSegment && previousSegment.segmentType === 'Text') {\n result = true;\n\n return callback(model, previousSegment, paragraph, marker.format, context);\n }\n }\n }\n\n return false;\n }, options);\n\n return result;\n}\n"]}
package/package.json CHANGED
@@ -3,10 +3,10 @@
3
3
  "description": "Format API for roosterjs",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
- "roosterjs-content-model-dom": "^9.1.0",
7
- "roosterjs-content-model-types": "^9.1.0"
6
+ "roosterjs-content-model-dom": "^9.3.0",
7
+ "roosterjs-content-model-types": "^9.3.0"
8
8
  },
9
- "version": "9.1.0",
9
+ "version": "9.3.0",
10
10
  "main": "./lib/index.js",
11
11
  "typings": "./lib/index.d.ts",
12
12
  "module": "./lib-mjs/index.js",