roosterjs-content-model-api 9.12.0 → 9.14.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.
@@ -1,6 +1,7 @@
1
- import type { IEditor, ContentModelFormatState } from 'roosterjs-content-model-types';
1
+ import type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * Get current format state
4
4
  * @param editor The editor to get format from
5
+ * @param conflictSolution The strategy for handling format conflicts
5
6
  */
6
- export declare function getFormatState(editor: IEditor): ContentModelFormatState;
7
+ export declare function getFormatState(editor: IEditor, conflictSolution?: ConflictFormatSolution): ContentModelFormatState;
@@ -6,8 +6,10 @@ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
6
6
  /**
7
7
  * Get current format state
8
8
  * @param editor The editor to get format from
9
+ * @param conflictSolution The strategy for handling format conflicts
9
10
  */
10
- function getFormatState(editor) {
11
+ function getFormatState(editor, conflictSolution) {
12
+ if (conflictSolution === void 0) { conflictSolution = 'remove'; }
11
13
  var pendingFormat = editor.getPendingFormat();
12
14
  var manager = editor.getSnapshotsManager();
13
15
  var result = {
@@ -16,7 +18,7 @@ function getFormatState(editor) {
16
18
  isDarkMode: editor.isDarkMode(),
17
19
  };
18
20
  editor.formatContentModel(function (model) {
19
- (0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result);
21
+ (0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result, conflictSolution);
20
22
  return false;
21
23
  }, undefined /*options*/, {
22
24
  processorOverride: {
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;AAAA,+FAA8F;AAC9F,2EAAuE;AAGvE;;;GAGG;AACH,SAAgB,cAAc,CAAC,MAAe;IAC1C,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC7C,IAAM,MAAM,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;KAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACD,IAAA,sDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO,KAAK,CAAC;IACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,uDAA0B;SACpC;QACD,eAAe,EAAE,IAAI;KACxB,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC;AAzBD,wCAyBC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n */\nexport function getFormatState(editor: IEditor): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;AAAA,+FAA8F;AAC9F,2EAAuE;AAGvE;;;;GAIG;AACH,SAAgB,cAAc,CAC1B,MAAe,EACf,gBAAmD;IAAnD,iCAAA,EAAA,2BAAmD;IAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC7C,IAAM,MAAM,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;KAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACD,IAAA,sDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAEzE,OAAO,KAAK,CAAC;IACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,uDAA0B;SACpC;QACD,eAAe,EAAE,IAAI;KACxB,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC;AA5BD,wCA4BC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result, conflictSolution);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
@@ -35,9 +35,15 @@ function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, seg
35
35
  : false;
36
36
  formatsAndSegments.forEach(function (_a) {
37
37
  var _b = (0, tslib_1.__read)(_a, 3), format = _b[0], segment = _b[1], paragraph = _b[2];
38
- return toggleStyleCallback(format, !isTurningOff, segment, paragraph);
38
+ toggleStyleCallback(format, !isTurningOff, segment, paragraph);
39
39
  });
40
40
  afterFormatCallback === null || afterFormatCallback === void 0 ? void 0 : afterFormatCallback(model);
41
+ formatsAndSegments.forEach(function (_a) {
42
+ var _b = (0, tslib_1.__read)(_a, 3), _ = _b[0], __ = _b[1], paragraph = _b[2];
43
+ if (paragraph) {
44
+ (0, roosterjs_content_model_dom_1.mergeTextSegments)(paragraph);
45
+ }
46
+ });
41
47
  if (isCollapsedSelection) {
42
48
  context.newPendingFormat = segmentAndParagraphs[0][0].format;
43
49
  editor.focus();
@@ -1 +1 @@
1
- {"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,oFAAmF;AACnF,2EAA+E;AAS/E;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;IAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,IAAA,8DAAgC,EACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,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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;AAzED,sEAyEC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\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: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[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 ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | 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,oFAAmF;AACnF,2EAAkG;AASlG;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;IAEnE,MAAM,CA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,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,0BAA4B,EAA3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;YACnD,mBAAmB,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,KAAK,CAAC,CAAC;QAE7B,kBAAkB,CAAC,OAAO,CAAC,UAAC,EAAkB;gBAAlB,KAAA,0BAAkB,EAAjB,CAAC,QAAA,EAAE,EAAE,QAAA,EAAE,SAAS,QAAA;YACzC,IAAI,SAAS,EAAE;gBACX,IAAA,+CAAiB,EAAC,SAAS,CAAC,CAAC;aAChC;QACL,CAAC,CAAC,CAAC;QAEH,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;AA/ED,sEA+EC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs, mergeTextSegments } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\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: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[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 ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | 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 formatsAndSegments.forEach(([_, __, paragraph]) => {\n if (paragraph) {\n mergeTextSegments(paragraph);\n }\n });\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,6 +1,7 @@
1
- import type { IEditor, ContentModelFormatState } from 'roosterjs-content-model-types';
1
+ import type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * Get current format state
4
4
  * @param editor The editor to get format from
5
+ * @param conflictSolution The strategy for handling format conflicts
5
6
  */
6
- export declare function getFormatState(editor: IEditor): ContentModelFormatState;
7
+ export declare function getFormatState(editor: IEditor, conflictSolution?: ConflictFormatSolution): ContentModelFormatState;
@@ -5,8 +5,10 @@ define(["require", "exports", "../../modelApi/common/reducedModelChildProcessor"
5
5
  /**
6
6
  * Get current format state
7
7
  * @param editor The editor to get format from
8
+ * @param conflictSolution The strategy for handling format conflicts
8
9
  */
9
- function getFormatState(editor) {
10
+ function getFormatState(editor, conflictSolution) {
11
+ if (conflictSolution === void 0) { conflictSolution = 'remove'; }
10
12
  var pendingFormat = editor.getPendingFormat();
11
13
  var manager = editor.getSnapshotsManager();
12
14
  var result = {
@@ -15,7 +17,7 @@ define(["require", "exports", "../../modelApi/common/reducedModelChildProcessor"
15
17
  isDarkMode: editor.isDarkMode(),
16
18
  };
17
19
  editor.formatContentModel(function (model) {
18
- (0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result);
20
+ (0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result, conflictSolution);
19
21
  return false;
20
22
  }, undefined /*options*/, {
21
23
  processorOverride: {
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;;IAIA;;;OAGG;IACH,SAAgB,cAAc,CAAC,MAAe;QAC1C,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC7C,IAAM,MAAM,GAA4B;YACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;SAClC,CAAC;QAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,IAAA,sDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;YAEvD,OAAO,KAAK,CAAC;QACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;YACI,iBAAiB,EAAE;gBACf,KAAK,EAAE,uDAA0B;aACpC;YACD,eAAe,EAAE,IAAI;SACxB,CACJ,CAAC;QAEF,OAAO,MAAM,CAAC;IAClB,CAAC;IAzBD,wCAyBC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n */\nexport function getFormatState(editor: IEditor): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;;IAIA;;;;OAIG;IACH,SAAgB,cAAc,CAC1B,MAAe,EACf,gBAAmD;QAAnD,iCAAA,EAAA,2BAAmD;QAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC7C,IAAM,MAAM,GAA4B;YACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;SAClC,CAAC;QAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,IAAA,sDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;YAEzE,OAAO,KAAK,CAAC;QACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;YACI,iBAAiB,EAAE;gBACf,KAAK,EAAE,uDAA0B;aACpC;YACD,eAAe,EAAE,IAAI;SACxB,CACJ,CAAC;QAEF,OAAO,MAAM,CAAC;IAClB,CAAC;IA5BD,wCA4BC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result, conflictSolution);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
@@ -33,9 +33,15 @@ define(["require", "exports", "tslib", "../../modelApi/selection/adjustWordSelec
33
33
  : false;
34
34
  formatsAndSegments.forEach(function (_a) {
35
35
  var _b = (0, tslib_1.__read)(_a, 3), format = _b[0], segment = _b[1], paragraph = _b[2];
36
- return toggleStyleCallback(format, !isTurningOff, segment, paragraph);
36
+ toggleStyleCallback(format, !isTurningOff, segment, paragraph);
37
37
  });
38
38
  afterFormatCallback === null || afterFormatCallback === void 0 ? void 0 : afterFormatCallback(model);
39
+ formatsAndSegments.forEach(function (_a) {
40
+ var _b = (0, tslib_1.__read)(_a, 3), _ = _b[0], __ = _b[1], paragraph = _b[2];
41
+ if (paragraph) {
42
+ (0, roosterjs_content_model_dom_1.mergeTextSegments)(paragraph);
43
+ }
44
+ });
39
45
  if (isCollapsedSelection) {
40
46
  context.newPendingFormat = segmentAndParagraphs[0][0].format;
41
47
  editor.focus();
@@ -1 +1 @@
1
- {"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";;;;IAUA;;;;;;;;OAQG;IACH,SAAgB,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;QAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAI,oBAAoB,GAAG,IAAA,8DAAgC,EACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAA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AC,UAAC,EAA4B;oBAA5B,KAAA,0BAA4B,EAA3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;gBACnD,OAAA,mBAAmB,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC;YAA9D,CAA8D,CACjE,CAAC;YAEF,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,KAAK,CAAC,CAAC;YAE7B,IAAI,oBAAoB,EAAE;gBACtB,OAAO,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;gBAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,KAAK,CAAC;aAChB;iBAAM;gBACH,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;aACxC;QACL,CAAC,EACD;YACI,OAAO,SAAA;SACV,CACJ,CAAC;IACN,CAAC;IAzED,sEAyEC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\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: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[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 ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | 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":";;;;IAUA;;;;;;;;OAQG;IACH,SAAgB,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EAC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,KAAA,0BAA4B,EAA3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;oBACjD,OAAA,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC;gBAAnD,CAAmD,CACtD;gBACH,CAAC,CAAC,KAAK,CAAC;YAEZ,kBAAkB,CAAC,OAAO,CAAC,UAAC,EAA4B;oBAA5B,KAAA,0BAA4B,EAA3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;gBACnD,mBAAmB,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;YAEH,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,KAAK,CAAC,CAAC;YAE7B,kBAAkB,CAAC,OAAO,CAAC,UAAC,EAAkB;oBAAlB,KAAA,0BAAkB,EAAjB,CAAC,QAAA,EAAE,EAAE,QAAA,EAAE,SAAS,QAAA;gBACzC,IAAI,SAAS,EAAE;oBACX,IAAA,+CAAiB,EAAC,SAAS,CAAC,CAAC;iBAChC;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,oBAAoB,EAAE;gBACtB,OAAO,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;gBAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,KAAK,CAAC;aAChB;iBAAM;gBACH,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;aACxC;QACL,CAAC,EACD;YACI,OAAO,SAAA;SACV,CACJ,CAAC;IACN,CAAC;IA/ED,sEA+EC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs, mergeTextSegments } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\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: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[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 ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | 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 formatsAndSegments.forEach(([_, __, paragraph]) => {\n if (paragraph) {\n mergeTextSegments(paragraph);\n }\n });\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,6 +1,7 @@
1
- import type { IEditor, ContentModelFormatState } from 'roosterjs-content-model-types';
1
+ import type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * Get current format state
4
4
  * @param editor The editor to get format from
5
+ * @param conflictSolution The strategy for handling format conflicts
5
6
  */
6
- export declare function getFormatState(editor: IEditor): ContentModelFormatState;
7
+ export declare function getFormatState(editor: IEditor, conflictSolution?: ConflictFormatSolution): ContentModelFormatState;
@@ -3,8 +3,10 @@ import { retrieveModelFormatState } from 'roosterjs-content-model-dom';
3
3
  /**
4
4
  * Get current format state
5
5
  * @param editor The editor to get format from
6
+ * @param conflictSolution The strategy for handling format conflicts
6
7
  */
7
- export function getFormatState(editor) {
8
+ export function getFormatState(editor, conflictSolution) {
9
+ if (conflictSolution === void 0) { conflictSolution = 'remove'; }
8
10
  var pendingFormat = editor.getPendingFormat();
9
11
  var manager = editor.getSnapshotsManager();
10
12
  var result = {
@@ -13,7 +15,7 @@ export function getFormatState(editor) {
13
15
  isDarkMode: editor.isDarkMode(),
14
16
  };
15
17
  editor.formatContentModel(function (model) {
16
- retrieveModelFormatState(model, pendingFormat, result);
18
+ retrieveModelFormatState(model, pendingFormat, result, conflictSolution);
17
19
  return false;
18
20
  }, undefined /*options*/, {
19
21
  processorOverride: {
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAGvE;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAe;IAC1C,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC7C,IAAM,MAAM,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;KAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACD,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO,KAAK,CAAC;IACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,0BAA0B;SACpC;QACD,eAAe,EAAE,IAAI;KACxB,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n */\nexport function getFormatState(editor: IEditor): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAGvE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC1B,MAAe,EACf,gBAAmD;IAAnD,iCAAA,EAAA,2BAAmD;IAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC7C,IAAM,MAAM,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;KAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACD,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAEzE,OAAO,KAAK,CAAC;IACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,0BAA0B;SACpC;QACD,eAAe,EAAE,IAAI;KACxB,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result, conflictSolution);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { __read } from "tslib";
2
2
  import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';
3
- import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';
3
+ import { getSelectedSegmentsAndParagraphs, mergeTextSegments } from 'roosterjs-content-model-dom';
4
4
  /**
5
5
  * Invoke a callback to format the selected segment using Content Model
6
6
  * @param editor The editor object
@@ -32,9 +32,15 @@ export function formatSegmentWithContentModel(editor, apiName, toggleStyleCallba
32
32
  : false;
33
33
  formatsAndSegments.forEach(function (_a) {
34
34
  var _b = __read(_a, 3), format = _b[0], segment = _b[1], paragraph = _b[2];
35
- return toggleStyleCallback(format, !isTurningOff, segment, paragraph);
35
+ toggleStyleCallback(format, !isTurningOff, segment, paragraph);
36
36
  });
37
37
  afterFormatCallback === null || afterFormatCallback === void 0 ? void 0 : afterFormatCallback(model);
38
+ formatsAndSegments.forEach(function (_a) {
39
+ var _b = __read(_a, 3), _ = _b[0], __ = _b[1], paragraph = _b[2];
40
+ if (paragraph) {
41
+ mergeTextSegments(paragraph);
42
+ }
43
+ });
38
44
  if (isCollapsedSelection) {
39
45
  context.newPendingFormat = segmentAndParagraphs[0][0].format;
40
46
  editor.focus();
@@ -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,mBAAmE;IAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,gCAAgC,CACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAArC,CAAqC,CAAC,CAAC;QAE3E,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;YAE5B,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 ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\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: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[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 ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | 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,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AASlG;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;IAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,gCAAgC,CACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAArC,CAAqC,CAAC,CAAC;QAE3E,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,C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CAAC,CAAC;QAEH,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, mergeTextSegments } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\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: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[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 ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | 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 formatsAndSegments.forEach(([_, __, paragraph]) => {\n if (paragraph) {\n mergeTextSegments(paragraph);\n }\n });\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"]}
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.12.0",
7
- "roosterjs-content-model-types": "^9.12.0"
6
+ "roosterjs-content-model-dom": "^9.14.0",
7
+ "roosterjs-content-model-types": "^9.14.0"
8
8
  },
9
- "version": "9.12.0",
9
+ "version": "9.14.0",
10
10
  "main": "./lib/index.js",
11
11
  "typings": "./lib/index.d.ts",
12
12
  "module": "./lib-mjs/index.js",