roosterjs-content-model-api 9.29.3 → 9.31.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.
@@ -12,6 +12,7 @@ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
12
12
  * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection
13
13
  */
14
14
  function formatTableWithContentModel(editor, apiName, callback, selectionOverride) {
15
+ editor.focus();
15
16
  editor.formatContentModel(function (model) {
16
17
  var _a = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 2), readonlyTableModel = _a[0], path = _a[1];
17
18
  if (readonlyTableModel) {
@@ -1 +1 @@
1
- {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,0GAAyG;AACzG,2EAUqC;AAOrC;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,oBAA6B,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,IAAA,yCAAW,EAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,IAAA,iDAAmB,EAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,IAAA,mEAAgC,EAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;oBACnC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,IAAA,4CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;gBACzB,IAAA,8CAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,EACD;QACI,oBAAoB,EAAE,UAAU;KACnC,CACJ,CAAC;AACN,CAAC;AA9CD,kEA8CC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table 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 callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,0GAAyG;AACzG,2EAUqC;AAOrC;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,oBAA6B,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,IAAA,yCAAW,EAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,IAAA,iDAAmB,EAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,IAAA,mEAAgC,EAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;oBACnC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,IAAA,4CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;gBACzB,IAAA,8CAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,EACD;QACI,oBAAoB,EAAE,UAAU;KACnC,CACJ,CAAC;AACN,CAAC;AA/CD,kEA+CC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table 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 callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.focus();\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
@@ -10,6 +10,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/ensureFocusablePara
10
10
  * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection
11
11
  */
12
12
  function formatTableWithContentModel(editor, apiName, callback, selectionOverride) {
13
+ editor.focus();
13
14
  editor.formatContentModel(function (model) {
14
15
  var _a = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 2), readonlyTableModel = _a[0], path = _a[1];
15
16
  if (readonlyTableModel) {
@@ -1 +1 @@
1
- {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";;;;IAkBA;;;;;;OAMG;IACH,SAAgB,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;QAElC,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAA6B,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;YAEhE,IAAI,kBAAkB,EAAE;gBACpB,IAAM,UAAU,GAAG,IAAA,yCAAW,EAAC,kBAAkB,CAAC,CAAC;gBAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;gBAErB,IAAI,CAAC,IAAA,iDAAmB,EAAC,UAAU,CAAC,EAAE;oBAClC,IAAM,SAAS,GAAG,IAAA,mEAAgC,EAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;oBAE5E,IAAI,SAAS,EAAE;wBACX,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;wBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;wBACnC,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;wBACnC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;qBAC/B;iBACJ;gBAED,IAAA,4CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;oBACzB,IAAA,8CAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;iBACjF;gBAED,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,SAAA;YACP,iBAAiB,mBAAA;SACpB,EACD;YACI,oBAAoB,EAAE,UAAU;SACnC,CACJ,CAAC;IACN,CAAC;IA9CD,kEA8CC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table 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 callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";;;;IAkBA;;;;;;OAMG;IACH,SAAgB,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;QAElC,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAA6B,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;YAEhE,IAAI,kBAAkB,EAAE;gBACpB,IAAM,UAAU,GAAG,IAAA,yCAAW,EAAC,kBAAkB,CAAC,CAAC;gBAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;gBAErB,IAAI,CAAC,IAAA,iDAAmB,EAAC,UAAU,CAAC,EAAE;oBAClC,IAAM,SAAS,GAAG,IAAA,mEAAgC,EAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;oBAE5E,IAAI,SAAS,EAAE;wBACX,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;wBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;wBACnC,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;wBACnC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;qBAC/B;iBACJ;gBAED,IAAA,4CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;oBACzB,IAAA,8CAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;iBACjF;gBAED,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,SAAA;YACP,iBAAiB,mBAAA;SACpB,EACD;YACI,oBAAoB,EAAE,UAAU;SACnC,CACJ,CAAC;IACN,CAAC;IA/CD,kEA+CC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table 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 callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.focus();\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
@@ -9,6 +9,7 @@ import { createSelectionMarker, hasMetadata, setParagraphNotImplicit, hasSelecti
9
9
  * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection
10
10
  */
11
11
  export function formatTableWithContentModel(editor, apiName, callback, selectionOverride) {
12
+ editor.focus();
12
13
  editor.formatContentModel(function (model) {
13
14
  var _a = __read(getFirstSelectedTable(model), 2), readonlyTableModel = _a[0], path = _a[1];
14
15
  if (readonlyTableModel) {
@@ -1 +1 @@
1
- {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,uDAAuD,CAAC;AACzG,OAAO,EACH,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,WAAW,GACd,MAAM,6BAA6B,CAAC;AAOrC;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,OAA6B,qBAAqB,CAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,gCAAgC,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,uBAAuB,CAAC,SAAS,CAAC,CAAC;oBACnC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;gBACzB,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,EACD;QACI,oBAAoB,EAAE,UAAU;KACnC,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table 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 callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,uDAAuD,CAAC;AACzG,OAAO,EACH,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,WAAW,GACd,MAAM,6BAA6B,CAAC;AAOrC;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,OAA6B,qBAAqB,CAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,gCAAgC,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,uBAAuB,CAAC,SAAS,CAAC,CAAC;oBACnC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;gBACzB,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,EACD;QACI,oBAAoB,EAAE,UAAU;KACnC,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table 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 callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.focus();\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\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.29.3",
7
- "roosterjs-content-model-types": "^9.29.3"
6
+ "roosterjs-content-model-dom": "^9.31.0",
7
+ "roosterjs-content-model-types": "^9.31.0"
8
8
  },
9
- "version": "9.29.3",
9
+ "version": "9.31.0",
10
10
  "main": "./lib/index.js",
11
11
  "typings": "./lib/index.d.ts",
12
12
  "module": "./lib-mjs/index.js",