roosterjs-content-model-api 9.3.1 → 9.4.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.
- package/lib/modelApi/block/setModelIndentation.d.ts +2 -2
- package/lib/modelApi/block/setModelIndentation.js +1 -1
- package/lib/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib/modelApi/entity/insertEntityModel.js +2 -2
- package/lib/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib/modelApi/list/findListItemsInSameThread.d.ts +8 -2
- package/lib/modelApi/list/findListItemsInSameThread.js +0 -5
- package/lib/modelApi/list/findListItemsInSameThread.js.map +1 -1
- package/lib/modelApi/list/getListAnnounceData.d.ts +2 -2
- package/lib/modelApi/list/getListAnnounceData.js +1 -1
- package/lib/modelApi/list/getListAnnounceData.js.map +1 -1
- package/lib/modelApi/table/canMergeCells.d.ts +2 -2
- package/lib/modelApi/table/canMergeCells.js.map +1 -1
- package/lib/publicApi/image/changeImage.js +1 -1
- package/lib/publicApi/image/changeImage.js.map +1 -1
- package/lib/publicApi/table/applyTableBorderFormat.js +5 -0
- package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib/publicApi/table/setTableCellShade.js +0 -1
- package/lib/publicApi/table/setTableCellShade.js.map +1 -1
- package/lib-amd/modelApi/block/setModelIndentation.d.ts +2 -2
- package/lib-amd/modelApi/block/setModelIndentation.js +1 -1
- package/lib-amd/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib-amd/modelApi/entity/insertEntityModel.js +2 -2
- package/lib-amd/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib-amd/modelApi/list/findListItemsInSameThread.d.ts +8 -2
- package/lib-amd/modelApi/list/findListItemsInSameThread.js +0 -5
- package/lib-amd/modelApi/list/findListItemsInSameThread.js.map +1 -1
- package/lib-amd/modelApi/list/getListAnnounceData.d.ts +2 -2
- package/lib-amd/modelApi/list/getListAnnounceData.js +1 -1
- package/lib-amd/modelApi/list/getListAnnounceData.js.map +1 -1
- package/lib-amd/modelApi/table/canMergeCells.d.ts +2 -2
- package/lib-amd/modelApi/table/canMergeCells.js.map +1 -1
- package/lib-amd/publicApi/image/changeImage.js +1 -1
- package/lib-amd/publicApi/image/changeImage.js.map +1 -1
- package/lib-amd/publicApi/table/applyTableBorderFormat.js +5 -0
- package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib-amd/publicApi/table/setTableCellShade.js +0 -1
- package/lib-amd/publicApi/table/setTableCellShade.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelIndentation.d.ts +2 -2
- package/lib-mjs/modelApi/block/setModelIndentation.js +2 -2
- package/lib-mjs/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib-mjs/modelApi/entity/insertEntityModel.js +3 -3
- package/lib-mjs/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib-mjs/modelApi/list/findListItemsInSameThread.d.ts +8 -2
- package/lib-mjs/modelApi/list/findListItemsInSameThread.js +0 -5
- package/lib-mjs/modelApi/list/findListItemsInSameThread.js.map +1 -1
- package/lib-mjs/modelApi/list/getListAnnounceData.d.ts +2 -2
- package/lib-mjs/modelApi/list/getListAnnounceData.js +2 -2
- package/lib-mjs/modelApi/list/getListAnnounceData.js.map +1 -1
- package/lib-mjs/modelApi/table/canMergeCells.d.ts +2 -2
- package/lib-mjs/modelApi/table/canMergeCells.js.map +1 -1
- package/lib-mjs/publicApi/image/changeImage.js +2 -2
- package/lib-mjs/publicApi/image/changeImage.js.map +1 -1
- package/lib-mjs/publicApi/table/applyTableBorderFormat.js +6 -1
- package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib-mjs/publicApi/table/setTableCellShade.js +1 -2
- package/lib-mjs/publicApi/table/setTableCellShade.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormatContentModelContext, ReadonlyContentModelDocument } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @param model The content model to set indentation
|
|
4
4
|
* @param indentation The indentation type, 'indent' to indent, 'outdent' to outdent
|
|
5
5
|
* @param length The length of indentation in pixel, default value is 40
|
|
6
6
|
* Set indentation for selected list items or paragraphs
|
|
7
7
|
*/
|
|
8
|
-
export declare function setModelIndentation(model:
|
|
8
|
+
export declare function setModelIndentation(model: ReadonlyContentModelDocument, indentation: 'indent' | 'outdent', length?: number, context?: FormatContentModelContext): boolean;
|
|
@@ -69,7 +69,7 @@ function setModelIndentation(model, indentation, length, context) {
|
|
|
69
69
|
var currentParent = parent;
|
|
70
70
|
while (currentParent && modifiedBlocks.indexOf(currentBlock) < 0) {
|
|
71
71
|
var index = path.indexOf(currentParent);
|
|
72
|
-
var format = currentBlock.format;
|
|
72
|
+
var format = (0, roosterjs_content_model_dom_1.mutateBlock)(currentBlock).format;
|
|
73
73
|
var newValue = calculateMarginValue(format, isIndent, length);
|
|
74
74
|
if (newValue !== null) {
|
|
75
75
|
var isRtl = format.direction == 'rtl';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setModelIndentation.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelIndentation.ts"],"names":[],"mappings":";;;;AAAA,+EAA8E;AAC9E,mEAAkE;AAClE,2EAMqC;AAWrC,IAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;;;;GAKG;AACH,SAAgB,mBAAmB,CAC/B,KAA2B,EAC3B,WAAiC,EACjC,MAAkC,EAClC,OAAmC;IADnC,uBAAA,EAAA,0BAAkC;IAGlC,IAAM,mBAAmB,GAAG,IAAA,kDAAoB,EAC5C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;IACF,IAAM,QAAQ,GAAG,WAAW,IAAI,QAAQ,CAAC;IACzC,IAAM,cAAc,GAAwB,EAAE,CAAC;IAE/C,mBAAmB,CAAC,OAAO,CAAC,UAAC,EAAu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AC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACnE;IAED,IAAI,QAAQ,IAAI,aAAa,EAAE;QAC3B,oDAAoD;QACpD,OAAO,IAAI,CAAC;KACf;SAAM;QACH,OAAO,QAAQ,CAAC;KACnB;AACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { getListAnnounceData } from '../list/getListAnnounceData';\nimport {\n createListLevel,\n getOperationalBlocks,\n isBlockGroupOfType,\n parseValueWithUnit,\n updateListMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelBlockFormat,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelListItem,\n ContentModelListLevel,\n FormatContentModelContext,\n} from 'roosterjs-content-model-types';\n\nconst IndentStepInPixel = 40;\n\n/**\n * @param model The content model to set indentation\n * @param indentation The indentation type, 'indent' to indent, 'outdent' to outdent\n * @param length The length of indentation in pixel, default value is 40\n * Set indentation for selected list items or paragraphs\n */\nexport function setModelIndentation(\n model: ContentModelDocument,\n indentation: 'indent' | 'outdent',\n length: number = IndentStepInPixel,\n context?: FormatContentModelContext\n) {\n const paragraphOrListItem = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n const isIndent = indentation == 'indent';\n const modifiedBlocks: ContentModelBlock[] = [];\n\n paragraphOrListItem.forEach(({ block, parent, path }) => {\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const thread = findListItemsInSameThread(model, block);\n const firstItem = thread[0];\n //if the first item is selected and has only one level, we should add margin to the whole list\n if (isSelected(firstItem) && firstItem.levels.length == 1) {\n const level = block.levels[0];\n const { format } = level;\n const { marginLeft, marginRight } = format;\n const newValue = calculateMarginValue(format, isIndent, length);\n const isRtl = format.direction == 'rtl';\n const originalValue = parseValueWithUnit(isRtl ? marginRight : marginLeft);\n\n if (!isIndent && originalValue == 0) {\n block.levels.pop();\n } else if (newValue !== null) {\n if (isRtl) {\n level.format.marginRight = newValue + 'px';\n } else {\n level.format.marginLeft = newValue + 'px';\n }\n }\n //if block has only one level, there is not need to check if it is multilevel selection\n } else if (block.levels.length == 1 || !isMultilevelSelection(model, block, parent)) {\n if (isIndent) {\n const lastLevel = block.levels[block.levels.length - 1];\n const newLevel: ContentModelListLevel = createListLevel(\n lastLevel?.listType || 'UL',\n lastLevel?.format\n );\n\n updateListMetadata(newLevel, metadata => {\n metadata = metadata || {};\n metadata.applyListStyleFromLevel = true;\n return metadata;\n });\n\n // New level is totally new, no need to have these attributes for now\n delete newLevel.format.startNumberOverride;\n\n block.levels.push(newLevel);\n } else {\n block.levels.pop();\n }\n\n if (block.levels.length > 0 && context) {\n context.announceData = getListAnnounceData([block, ...path]);\n }\n }\n } else if (block) {\n let currentBlock: ContentModelBlock = block;\n let currentParent: ContentModelBlockGroup = parent;\n\n while (currentParent && modifiedBlocks.indexOf(currentBlock) < 0) {\n const index = path.indexOf(currentParent);\n const { format } = currentBlock;\n const newValue = calculateMarginValue(format, isIndent, length);\n\n if (newValue !== null) {\n const isRtl = format.direction == 'rtl';\n\n if (isRtl) {\n format.marginRight = newValue + 'px';\n } else {\n format.marginLeft = newValue + 'px';\n }\n\n modifiedBlocks.push(currentBlock);\n\n break;\n } else if (currentParent.blockGroupType == 'FormatContainer' && index >= 0) {\n delete currentParent.cachedElement;\n\n currentBlock = currentParent;\n currentParent = path[index + 1];\n } else {\n break;\n }\n }\n }\n });\n\n return paragraphOrListItem.length > 0;\n}\n\nfunction isSelected(listItem: ContentModelListItem) {\n return listItem.blocks.some(block => {\n if (block.blockType == 'Paragraph') {\n return block.segments.some(segment => segment.isSelected);\n }\n });\n}\n\n/*\n * Check if the selection has list items with different levels and the first item of the list is selected, do not create a sub list.\n * Otherwise, the margin of the first item will be changed, and the sub list will be created, creating a unintentional margin difference between the list items.\n */\nfunction isMultilevelSelection(\n model: ContentModelDocument,\n listItem: ContentModelListItem,\n parent: ContentModelBlockGroup\n) {\n const listIndex = parent.blocks.indexOf(listItem);\n for (let i = listIndex - 1; i >= 0; i--) {\n const block = parent.blocks[i];\n if (\n isBlockGroupOfType<ContentModelListItem>(block, 'ListItem') &&\n block.levels.length == 1 &&\n isSelected(block)\n ) {\n const firstItem = findListItemsInSameThread(model, block)[0];\n return isSelected(firstItem);\n }\n\n if (!isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n return false;\n }\n }\n return false;\n}\n\nfunction calculateMarginValue(\n format: ContentModelBlockFormat,\n isIndent: boolean,\n length: number = IndentStepInPixel\n): number | null {\n const { marginLeft, marginRight, direction } = format;\n const isRtl = direction == 'rtl';\n const originalValue = parseValueWithUnit(isRtl ? marginRight : marginLeft);\n let newValue = (isIndent ? Math.ceil : Math.floor)(originalValue / length) * length;\n\n if (newValue == originalValue) {\n newValue = Math.max(newValue + length * (isIndent ? 1 : -1), 0);\n }\n\n if (newValue == originalValue) {\n // Return null to let caller know nothing is changed\n return null;\n } else {\n return newValue;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"setModelIndentation.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelIndentation.ts"],"names":[],"mappings":";;;;AAAA,+EAA8E;AAC9E,mEAAkE;AAClE,2EAOqC;AAYrC,IAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;;;;GAKG;AACH,SAAgB,mBAAmB,CAC/B,KAAmC,EACnC,WAAiC,EACjC,MAAkC,EAClC,OAAmC;IADnC,uBAAA,EAAA,0BAAkC;IAGlC,IAAM,mBAAmB,GAAG,IAAA,kDAAoB,EAC5C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;IACF,IAAM,QAAQ,GAAG,WAAW,IAAI,QAAQ,CAAC;IACzC,IAAM,cAAc,GAAgC,EAAE,CAAC;IAEvD,mBAAmB,CAAC,OAAO,CAAC,UAAC,EAAuB;YAArB,KAAK,WAA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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACnE;IAED,IAAI,QAAQ,IAAI,aAAa,EAAE;QAC3B,oDAAoD;QACpD,OAAO,IAAI,CAAC;KACf;SAAM;QACH,OAAO,QAAQ,CAAC;KACnB;AACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { getListAnnounceData } from '../list/getListAnnounceData';\nimport {\n createListLevel,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n parseValueWithUnit,\n updateListMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlockFormat,\n ContentModelListItem,\n ContentModelListLevel,\n FormatContentModelContext,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n} from 'roosterjs-content-model-types';\n\nconst IndentStepInPixel = 40;\n\n/**\n * @param model The content model to set indentation\n * @param indentation The indentation type, 'indent' to indent, 'outdent' to outdent\n * @param length The length of indentation in pixel, default value is 40\n * Set indentation for selected list items or paragraphs\n */\nexport function setModelIndentation(\n model: ReadonlyContentModelDocument,\n indentation: 'indent' | 'outdent',\n length: number = IndentStepInPixel,\n context?: FormatContentModelContext\n) {\n const paragraphOrListItem = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n const isIndent = indentation == 'indent';\n const modifiedBlocks: ReadonlyContentModelBlock[] = [];\n\n paragraphOrListItem.forEach(({ block, parent, path }) => {\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const thread = findListItemsInSameThread(model, block);\n const firstItem = thread[0];\n //if the first item is selected and has only one level, we should add margin to the whole list\n if (isSelected(firstItem) && firstItem.levels.length == 1) {\n const level = block.levels[0];\n const { format } = level;\n const { marginLeft, marginRight } = format;\n const newValue = calculateMarginValue(format, isIndent, length);\n const isRtl = format.direction == 'rtl';\n const originalValue = parseValueWithUnit(isRtl ? marginRight : marginLeft);\n\n if (!isIndent && originalValue == 0) {\n block.levels.pop();\n } else if (newValue !== null) {\n if (isRtl) {\n level.format.marginRight = newValue + 'px';\n } else {\n level.format.marginLeft = newValue + 'px';\n }\n }\n //if block has only one level, there is not need to check if it is multilevel selection\n } else if (block.levels.length == 1 || !isMultilevelSelection(model, block, parent)) {\n if (isIndent) {\n const lastLevel = block.levels[block.levels.length - 1];\n const newLevel: ContentModelListLevel = createListLevel(\n lastLevel?.listType || 'UL',\n lastLevel?.format\n );\n\n updateListMetadata(newLevel, metadata => {\n metadata = metadata || {};\n metadata.applyListStyleFromLevel = true;\n return metadata;\n });\n\n // New level is totally new, no need to have these attributes for now\n delete newLevel.format.startNumberOverride;\n\n block.levels.push(newLevel);\n } else {\n block.levels.pop();\n }\n\n if (block.levels.length > 0 && context) {\n context.announceData = getListAnnounceData([block, ...path]);\n }\n }\n } else if (block) {\n let currentBlock: ReadonlyContentModelBlock = block;\n let currentParent: ReadonlyContentModelBlockGroup = parent;\n\n while (currentParent && modifiedBlocks.indexOf(currentBlock) < 0) {\n const index = path.indexOf(currentParent);\n const { format } = mutateBlock(currentBlock);\n const newValue = calculateMarginValue(format, isIndent, length);\n\n if (newValue !== null) {\n const isRtl = format.direction == 'rtl';\n\n if (isRtl) {\n format.marginRight = newValue + 'px';\n } else {\n format.marginLeft = newValue + 'px';\n }\n\n modifiedBlocks.push(currentBlock);\n\n break;\n } else if (currentParent.blockGroupType == 'FormatContainer' && index >= 0) {\n delete currentParent.cachedElement;\n\n currentBlock = currentParent;\n currentParent = path[index + 1];\n } else {\n break;\n }\n }\n }\n });\n\n return paragraphOrListItem.length > 0;\n}\n\nfunction isSelected(listItem: ReadonlyContentModelListItem) {\n return listItem.blocks.some(block => {\n if (block.blockType == 'Paragraph') {\n return block.segments.some(segment => segment.isSelected);\n }\n });\n}\n\n/*\n * Check if the selection has list items with different levels and the first item of the list is selected, do not create a sub list.\n * Otherwise, the margin of the first item will be changed, and the sub list will be created, creating a unintentional margin difference between the list items.\n */\nfunction isMultilevelSelection(\n model: ReadonlyContentModelDocument,\n listItem: ReadonlyContentModelListItem,\n parent: ReadonlyContentModelBlockGroup\n) {\n const listIndex = parent.blocks.indexOf(listItem);\n for (let i = listIndex - 1; i >= 0; i--) {\n const block = parent.blocks[i];\n if (\n isBlockGroupOfType<ContentModelListItem>(block, 'ListItem') &&\n block.levels.length == 1 &&\n isSelected(block)\n ) {\n const firstItem = findListItemsInSameThread(model, block)[0];\n return isSelected(firstItem);\n }\n\n if (!isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n return false;\n }\n }\n return false;\n}\n\nfunction calculateMarginValue(\n format: ContentModelBlockFormat,\n isIndent: boolean,\n length: number = IndentStepInPixel\n): number | null {\n const { marginLeft, marginRight, direction } = format;\n const isRtl = direction == 'rtl';\n const originalValue = parseValueWithUnit(isRtl ? marginRight : marginLeft);\n let newValue = (isIndent ? Math.ceil : Math.floor)(originalValue / length) * length;\n\n if (newValue == originalValue) {\n newValue = Math.max(newValue + length * (isIndent ? 1 : -1), 0);\n }\n\n if (newValue == originalValue) {\n // Return null to let caller know nothing is changed\n return null;\n } else {\n return newValue;\n }\n}\n"]}
|
|
@@ -32,7 +32,7 @@ function insertEntityModel(model, entityModel, position, isBlock, focusAfterEnti
|
|
|
32
32
|
var pathIndex = position == 'root'
|
|
33
33
|
? (0, roosterjs_content_model_dom_1.getClosestAncestorBlockGroupIndex)(path, ['TableCell', 'Document'])
|
|
34
34
|
: 0;
|
|
35
|
-
blockParent = path[pathIndex];
|
|
35
|
+
blockParent = (0, roosterjs_content_model_dom_1.mutateBlock)(path[pathIndex]);
|
|
36
36
|
var child = path[pathIndex - 1];
|
|
37
37
|
var directChild = (child === null || child === void 0 ? void 0 : child.blockGroupType) == 'FormatContainer' ||
|
|
38
38
|
(child === null || child === void 0 ? void 0 : child.blockGroupType) == 'General' ||
|
|
@@ -50,7 +50,7 @@ function insertEntityModel(model, entityModel, position, isBlock, focusAfterEnti
|
|
|
50
50
|
var nextBlock = blockParent.blocks[blockIndex];
|
|
51
51
|
blocksToInsert.push(entityModel);
|
|
52
52
|
if ((nextBlock === null || nextBlock === void 0 ? void 0 : nextBlock.blockType) == 'Paragraph') {
|
|
53
|
-
nextParagraph = nextBlock;
|
|
53
|
+
nextParagraph = (0, roosterjs_content_model_dom_1.mutateBlock)(nextBlock);
|
|
54
54
|
}
|
|
55
55
|
else if (!nextBlock || nextBlock.blockType == 'Entity' || focusAfterEntity) {
|
|
56
56
|
nextParagraph = (0, roosterjs_content_model_dom_1.createParagraph)(false /*isImplicit*/, {}, model.format);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";;;;AAAA,2EASqC;AAarC;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,KAA2B,EAC3B,WAA+B,EAC/B,QAA8B,EAC9B,OAAgB,EAChB,gBAA0B,EAC1B,OAAmC,EACnC,mBAAiC;;;IAEjC,IAAI,WAA6D,CAAC;IAClE,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;IACpB,IAAI,WAA+B,CAAC;IAEpC,IAAI,QAAQ,IAAI,OAAO,IAAI,QAAQ,IAAI,KAAK,EAAE;QAC1C,WAAW,GAAG,KAAK,CAAC;QACpB,UAAU,GAAG,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QAE3D,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;S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,cAAc,WAAE;QAE5D,IAAI,gBAAgB,IAAI,aAAa,EAAE;YACnC,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,CAAA,MAAA,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAAE,MAAM,KAAI,KAAK,CAAC,MAAM,CAAC,CAAC;YACxF,IAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;YAExC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3D,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SACvC;KACJ;AACL,CAAC;AAvFD,8CAuFC;AAED,SAAS,cAAc,CACnB,KAA2B,EAC3B,mBAAiC,EACjC,OAAmC;IAEnC,IAAI,mBAAmB,EAAE;QACrB,OAAO,mBAAmB,CAAC;KAC9B;SAAM;QACH,IAAM,YAAY,GAAG,IAAA,6CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QACzD,IAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;QAE7C,IAAI,YAAY,CAAC,YAAY,IAAI,OAAO,EAAE;YACtC,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;SAChC;QAED,OAAO,WAAW,CAAC;KACtB;AACL,CAAC","sourcesContent":["import {\n createBr,\n createParagraph,\n createSelectionMarker,\n normalizeContentModel,\n deleteSelection,\n getClosestAncestorBlockGroupIndex,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelEntity,\n FormatContentModelContext,\n InsertEntityPosition,\n InsertPoint,\n ReadonlyContentModelBlock,\n ShallowMutableContentModelBlock,\n ShallowMutableContentModelBlockGroup,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function insertEntityModel(\n model: ContentModelDocument,\n entityModel: ContentModelEntity,\n position: InsertEntityPosition,\n isBlock: boolean,\n focusAfterEntity?: boolean,\n context?: FormatContentModelContext,\n insertPointOverride?: InsertPoint\n) {\n let blockParent: ShallowMutableContentModelBlockGroup | undefined;\n let blockIndex = -1;\n let insertPoint: InsertPoint | null;\n\n if (position == 'begin' || position == 'end') {\n blockParent = model;\n blockIndex = position == 'begin' ? 0 : model.blocks.length;\n\n if (!isBlock) {\n Object.assign(entityModel.format, model.format);\n }\n } else if ((insertPoint = getInsertPoint(model, insertPointOverride, context))) {\n const { marker, paragraph, path } = insertPoint;\n\n if (!isBlock) {\n const index = paragraph.segments.indexOf(marker);\n\n Object.assign(entityModel.format, marker.format);\n\n if (index >= 0) {\n paragraph.segments.splice(focusAfterEntity ? index : index + 1, 0, entityModel);\n }\n } else {\n const pathIndex =\n position == 'root'\n ? getClosestAncestorBlockGroupIndex(path, ['TableCell', 'Document'])\n : 0;\n blockParent = mutateBlock(path[pathIndex]);\n\n const child = path[pathIndex - 1];\n const directChild: ReadonlyContentModelBlock =\n child?.blockGroupType == 'FormatContainer' ||\n child?.blockGroupType == 'General' ||\n child?.blockGroupType == 'ListItem'\n ? child\n : paragraph;\n const childIndex = blockParent.blocks.indexOf(directChild);\n blockIndex = childIndex >= 0 ? childIndex + 1 : -1;\n }\n }\n\n if (blockIndex >= 0 && blockParent) {\n const blocksToInsert: ShallowMutableContentModelBlock[] = [];\n let nextParagraph: ShallowMutableContentModelParagraph | undefined;\n\n if (isBlock) {\n const nextBlock = blockParent.blocks[blockIndex];\n\n blocksToInsert.push(entityModel);\n\n if (nextBlock?.blockType == 'Paragraph') {\n nextParagraph = mutateBlock(nextBlock);\n } else if (!nextBlock || nextBlock.blockType == 'Entity' || focusAfterEntity) {\n nextParagraph = createParagraph(false /*isImplicit*/, {}, model.format);\n nextParagraph.segments.push(createBr(model.format));\n blocksToInsert.push(nextParagraph);\n }\n } else {\n nextParagraph = createParagraph(\n false /*isImplicit*/,\n undefined /*format*/,\n model.format\n );\n\n nextParagraph.segments.push(entityModel);\n blocksToInsert.push(nextParagraph);\n }\n\n blockParent.blocks.splice(blockIndex, 0, ...blocksToInsert);\n\n if (focusAfterEntity && nextParagraph) {\n const marker = createSelectionMarker(nextParagraph.segments[0]?.format || model.format);\n const segments = nextParagraph.segments;\n\n isBlock ? segments.unshift(marker) : segments.push(marker);\n setSelection(model, marker, marker);\n }\n }\n}\n\nfunction getInsertPoint(\n model: ContentModelDocument,\n insertPointOverride?: InsertPoint,\n context?: FormatContentModelContext\n): InsertPoint | null {\n if (insertPointOverride) {\n return insertPointOverride;\n } else {\n const deleteResult = deleteSelection(model, [], context);\n const insertPoint = deleteResult.insertPoint;\n\n if (deleteResult.deleteResult == 'range') {\n normalizeContentModel(model);\n }\n\n return insertPoint;\n }\n}\n"]}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type { ContentModelBlockGroup, ContentModelListItem } from 'roosterjs-content-model-types';
|
|
1
|
+
import type { ContentModelBlockGroup, ContentModelListItem, ReadonlyContentModelBlockGroup, ReadonlyContentModelListItem } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
|
+
* Search for all list items in the same thread as the current list item
|
|
3
4
|
* @param model The content model
|
|
4
5
|
* @param currentItem The current list item
|
|
5
|
-
* Search for all list items in the same thread as the current list item
|
|
6
6
|
*/
|
|
7
7
|
export declare function findListItemsInSameThread(group: ContentModelBlockGroup, currentItem: ContentModelListItem): ContentModelListItem[];
|
|
8
|
+
/**
|
|
9
|
+
* Search for all list items in the same thread as the current list item (Readonly)
|
|
10
|
+
* @param model The content model
|
|
11
|
+
* @param currentItem The current list item
|
|
12
|
+
*/
|
|
13
|
+
export declare function findListItemsInSameThread(group: ReadonlyContentModelBlockGroup, currentItem: ReadonlyContentModelListItem): ReadonlyContentModelListItem[];
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findListItemsInSameThread = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @param model The content model
|
|
6
|
-
* @param currentItem The current list item
|
|
7
|
-
* Search for all list items in the same thread as the current list item
|
|
8
|
-
*/
|
|
9
4
|
function findListItemsInSameThread(group, currentItem) {
|
|
10
5
|
var items = [];
|
|
11
6
|
findListItems(group, items);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findListItemsInSameThread.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/findListItemsInSameThread.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"findListItemsInSameThread.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/findListItemsInSameThread.ts"],"names":[],"mappings":";;;AA2BA,SAAgB,yBAAyB,CACrC,KAAqC,EACrC,WAAyC;IAEzC,IAAM,KAAK,GAAoC,EAAE,CAAC;IAElD,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAE5B,OAAO,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC;AATD,8DASC;AAED,SAAS,aAAa,CAClB,KAAqC,EACrC,MAA+C;IAE/C,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;QACtB,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,YAAY;gBACb,IAAI,KAAK,CAAC,cAAc,IAAI,UAAU,EAAE;oBACpC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBACtB;qBAAM;oBACH,mBAAmB,CAAC,MAAM,CAAC,CAAC;oBAC5B,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBAC7B,mBAAmB,CAAC,MAAM,CAAC,CAAC;iBAC/B;gBACD,MAAM;YAEV,KAAK,WAAW;gBACZ,mBAAmB,CAAC,MAAM,CAAC,CAAC;gBAE5B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAA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BAAsB,CAC3B,SAAkD,EAClD,YAAoB,EACpB,cAAsB;IAEtB,IAAM,aAAa,GAAG,SAAS,CAAC,YAAY,CAAE,CAAC,MAAM,CAAC;IACtD,IAAM,eAAe,GAAG,SAAS,CAAC,cAAc,CAAE,CAAC,MAAM,CAAC;IAE1D,OAAO,CACH,aAAa,CAAC,MAAM,IAAI,eAAe,CAAC,MAAM;QAC9C,aAAa,CAAC,KAAK,CACf,UAAC,YAAY,EAAE,CAAC,IAAK,OAAA,YAAY,CAAC,QAAQ,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAApD,CAAoD,CAC5E,CACJ,CAAC;AACN,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAkC,EAAE,WAAmB;IACnF,OAAO,IAAI,CAAC,MAAM;SACb,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;SACrB,IAAI,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,CAAC,mBAAmB,KAAK,SAAS,EAA9C,CAA8C,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type {\n ContentModelBlockGroup,\n ContentModelListItem,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelListItem,\n} from 'roosterjs-content-model-types';\n\n/**\n * Search for all list items in the same thread as the current list item\n * @param model The content model\n * @param currentItem The current list item\n */\nexport function findListItemsInSameThread(\n group: ContentModelBlockGroup,\n currentItem: ContentModelListItem\n): ContentModelListItem[];\n\n/**\n * Search for all list items in the same thread as the current list item (Readonly)\n * @param model The content model\n * @param currentItem The current list item\n */\nexport function findListItemsInSameThread(\n group: ReadonlyContentModelBlockGroup,\n currentItem: ReadonlyContentModelListItem\n): ReadonlyContentModelListItem[];\n\nexport function findListItemsInSameThread(\n group: ReadonlyContentModelBlockGroup,\n currentItem: ReadonlyContentModelListItem\n): ReadonlyContentModelListItem[] {\n const items: (ContentModelListItem | null)[] = [];\n\n findListItems(group, items);\n\n return filterListItems(items, currentItem);\n}\n\nfunction findListItems(\n group: ReadonlyContentModelBlockGroup,\n result: (ReadonlyContentModelListItem | null)[]\n) {\n group.blocks.forEach(block => {\n switch (block.blockType) {\n case 'BlockGroup':\n if (block.blockGroupType == 'ListItem') {\n result.push(block);\n } else {\n pushNullIfNecessary(result);\n findListItems(block, result);\n pushNullIfNecessary(result);\n }\n break;\n\n case 'Paragraph':\n pushNullIfNecessary(result);\n\n block.segments.forEach(segment => {\n if (segment.segmentType == 'General') {\n findListItems(segment, result);\n }\n });\n\n pushNullIfNecessary(result);\n break;\n\n case 'Table':\n pushNullIfNecessary(result);\n\n block.rows.forEach(row =>\n row.cells.forEach(cell => {\n findListItems(cell, result);\n })\n );\n pushNullIfNecessary(result);\n\n break;\n }\n });\n}\n\nfunction pushNullIfNecessary(result: (ReadonlyContentModelListItem | null)[]) {\n const last = result[result.length - 1];\n\n if (!last || last !== null) {\n result.push(null);\n }\n}\n\nfunction filterListItems(\n items: (ReadonlyContentModelListItem | null)[],\n currentItem: ReadonlyContentModelListItem\n) {\n const result: ReadonlyContentModelListItem[] = [];\n const currentIndex = items.indexOf(currentItem);\n const levelLength = currentItem.levels.length;\n const isOrderedList = currentItem.levels[levelLength - 1]?.listType == 'OL';\n\n if (currentIndex >= 0) {\n for (let i = currentIndex; i >= 0; i--) {\n const item = items[i];\n\n if (!item) {\n if (isOrderedList) {\n continue;\n } else {\n break;\n }\n }\n\n const startNumberOverride = hasStartNumberOverride(item, levelLength);\n\n if (areListTypesCompatible(items, currentIndex, i)) {\n result.unshift(item);\n\n if (isOrderedList && startNumberOverride) {\n break;\n }\n } else if (\n !isOrderedList ||\n startNumberOverride ||\n item.levels.length < currentItem.levels.length\n ) {\n break;\n }\n }\n\n for (let i = currentIndex + 1; i < items.length; i++) {\n const item = items[i];\n\n if (!item) {\n if (isOrderedList) {\n continue;\n } else {\n break;\n }\n }\n\n const startNumberOverride = hasStartNumberOverride(item, levelLength);\n\n if (areListTypesCompatible(items, currentIndex, i) && !startNumberOverride) {\n result.push(item);\n } else if (\n !isOrderedList ||\n startNumberOverride ||\n item.levels.length < currentItem.levels.length\n ) {\n break;\n }\n }\n }\n\n return result;\n}\n\nfunction areListTypesCompatible(\n listItems: (ReadonlyContentModelListItem | null)[],\n currentIndex: number,\n compareToIndex: number\n): boolean {\n const currentLevels = listItems[currentIndex]!.levels;\n const compareToLevels = listItems[compareToIndex]!.levels;\n\n return (\n currentLevels.length <= compareToLevels.length &&\n currentLevels.every(\n (currentLevel, i) => currentLevel.listType == compareToLevels[i].listType\n )\n );\n}\n\nfunction hasStartNumberOverride(item: ReadonlyContentModelListItem, levelLength: number): boolean {\n return item.levels\n .slice(0, levelLength)\n .some(level => level.format.startNumberOverride !== undefined);\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AnnounceData,
|
|
1
|
+
import type { AnnounceData, ReadonlyContentModelBlockGroup } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Get announce data for list item
|
|
4
4
|
* @param path Content model path that include the list item
|
|
5
5
|
* @returns Announce data of current list item if any, or null
|
|
6
6
|
*/
|
|
7
|
-
export declare function getListAnnounceData(path:
|
|
7
|
+
export declare function getListAnnounceData(path: ReadonlyContentModelBlockGroup[]): AnnounceData | null;
|
|
@@ -18,7 +18,7 @@ function getListAnnounceData(path) {
|
|
|
18
18
|
}
|
|
19
19
|
else if (level.listType == 'OL') {
|
|
20
20
|
var listNumber = getListNumber(path, listItem);
|
|
21
|
-
var metadata = (0, roosterjs_content_model_dom_1.
|
|
21
|
+
var metadata = (0, roosterjs_content_model_dom_1.getListMetadata)(level);
|
|
22
22
|
var listStyle = (0, roosterjs_content_model_dom_1.getAutoListStyleType)('OL', metadata !== null && metadata !== void 0 ? metadata : {}, listItem.levels.length - 1, level.format.listStyleType);
|
|
23
23
|
return listStyle === undefined
|
|
24
24
|
? null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getListAnnounceData.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/getListAnnounceData.ts"],"names":[],"mappings":";;;AAAA,yEAAwE;AACxE,2EAKqC;
|
|
1
|
+
{"version":3,"file":"getListAnnounceData.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/getListAnnounceData.ts"],"names":[],"mappings":";;;AAAA,yEAAwE;AACxE,2EAKqC;AAQrC;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAsC;IACtE,IAAM,KAAK,GAAG,IAAA,+DAAiC,EAAC,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAEnF,IAAI,KAAK,IAAI,CAAC,EAAE;QACZ,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAyB,CAAC;QACrD,IAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE1D,IAAI,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE;YAClC,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,EAAE;YAC/B,IAAM,UAAU,GAAG,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACjD,IAAM,QAAQ,GAAG,IAAA,6CAAe,EAAC,KAAK,CAAC,CAAC;YACxC,IAAM,SAAS,GAAG,IAAA,kDAAoB,EAClC,IAAI,EACJ,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,EACd,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAC1B,KAAK,CAAC,MAAM,CAAC,aAAa,CAC7B,CAAC;YAEF,OAAO,SAAS,KAAK,SAAS;gBAC1B,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC;oBACI,cAAc,EAAE,2BAA2B;oBAC3C,aAAa,EAAE,CAAC,IAAA,qDAAuB,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;iBACl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AAE,CAAC;SAChB;KACJ;IACD,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { findListItemsInSameThread } from './findListItemsInSameThread';\nimport {\n getAutoListStyleType,\n getClosestAncestorBlockGroupIndex,\n getListMetadata,\n getOrderedListNumberStr,\n} from 'roosterjs-content-model-dom';\nimport type {\n AnnounceData,\n ContentModelListItem,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelListItem,\n} from 'roosterjs-content-model-types';\n\n/**\n * Get announce data for list item\n * @param path Content model path that include the list item\n * @returns Announce data of current list item if any, or null\n */\nexport function getListAnnounceData(path: ReadonlyContentModelBlockGroup[]): AnnounceData | null {\n const index = getClosestAncestorBlockGroupIndex(path, ['ListItem'], ['TableCell']);\n\n if (index >= 0) {\n const listItem = path[index] as ContentModelListItem;\n const level = listItem.levels[listItem.levels.length - 1];\n\n if (level.format.displayForDummyItem) {\n return null;\n } else if (level.listType == 'OL') {\n const listNumber = getListNumber(path, listItem);\n const metadata = getListMetadata(level);\n const listStyle = getAutoListStyleType(\n 'OL',\n metadata ?? {},\n listItem.levels.length - 1,\n level.format.listStyleType\n );\n\n return listStyle === undefined\n ? null\n : {\n defaultStrings: 'announceListItemNumbering',\n formatStrings: [getOrderedListNumberStr(listStyle, listNumber)],\n };\n } else {\n return {\n defaultStrings: 'announceListItemBullet',\n };\n }\n } else {\n return null;\n }\n}\n\nfunction getListNumber(\n path: ReadonlyContentModelBlockGroup[],\n listItem: ReadonlyContentModelListItem\n) {\n const items = findListItemsInSameThread(path[path.length - 1], listItem);\n let listNumber = 0;\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n\n if (listNumber == 0 && item.levels.length == listItem.levels.length) {\n listNumber = item.levels[item.levels.length - 1]?.format.startNumberOverride ?? 1;\n }\n\n if (item == listItem) {\n // Found current item, so break and return\n break;\n } else if (item.levels.length < listItem.levels.length) {\n // Found upper level item, reset list number\n listNumber = 0;\n } else if (item.levels.length > listItem.levels.length) {\n // Found deeper level item, skip\n continue;\n } else if (!item.levels[item.levels.length - 1].format.displayForDummyItem) {\n // Save level, and is not dummy, number plus one\n listNumber++;\n }\n }\n return listNumber;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function canMergeCells(rows:
|
|
5
|
+
export declare function canMergeCells(rows: ReadonlyContentModelTableRow[], firstRow: number, firstCol: number, lastRow: number, lastCol: number): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canMergeCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,aAAa,CACzB,
|
|
1
|
+
{"version":3,"file":"canMergeCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,aAAa,CACzB,IAAoC,EACpC,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,OAAe;IAEf,IAAM,WAAW,GACb,QAAQ,IAAI,OAAO;QACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,CACtB,UAAC,IAAI,EAAE,QAAQ,IAAK,OAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAA5D,CAA4D,CACnF,CAAC;IACN,IAAM,UAAU,GACZ,QAAQ,IAAI,OAAO;QACnB,IAAI,CAAC,KAAK,CACN,UAAC,GAAG,EAAE,QAAQ;YACV,OAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ;QAA1E,CAA0E,CACjF,C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E,SAAS,EAAE;YACvC,SAAS,EAAE,CAAC;SACf;aAAM;YACH,MAAM;SACT;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,iBAAiB,CACtB,IAAoC,EACpC,QAAgB,EAChB,QAAgB;;IAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,IAAG,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,MAAM,CAAA,EAAE,GAAG,EAAE,EAAE;QACpE,IAAI,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,GAAG,CAAC,0CAAE,QAAQ,EAAE;YACtC,SAAS,EAAE,CAAC;SACf;aAAM;YACH,MAAM;SACT;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function canMergeCells(\n rows: ReadonlyContentModelTableRow[],\n firstRow: number,\n firstCol: number,\n lastRow: number,\n lastCol: number\n): boolean {\n const noSpanAbove =\n firstCol == lastCol ||\n rows[firstRow].cells.every(\n (cell, colIndex) => colIndex < firstCol || colIndex > lastCol || !cell.spanAbove\n );\n const noSpanLeft =\n firstRow == lastRow ||\n rows.every(\n (row, rowIndex) =>\n rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft\n );\n\n const noDifferentBelowSpan = rows[lastRow].cells\n .map((_, colIndex) =>\n colIndex >= firstCol && colIndex <= lastCol\n ? getBelowSpanCount(rows, lastRow, colIndex)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstCol]);\n const noDifferentRightSpan = rows\n .map((_, rowIndex) =>\n rowIndex >= firstRow && rowIndex <= lastRow\n ? getRightSpanCount(rows, rowIndex, lastCol)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstRow]);\n\n return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;\n}\n\nfunction getBelowSpanCount(\n rows: ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let row = rowIndex + 1; row < rows.length; row++) {\n if (rows[row]?.cells[colIndex]?.spanAbove) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n\nfunction getRightSpanCount(\n rows: ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let col = colIndex + 1; col < rows[rowIndex]?.cells.length; col++) {\n if (rows[rowIndex]?.cells[col]?.spanLeft) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n"]}
|
|
@@ -15,7 +15,7 @@ function changeImage(editor, file) {
|
|
|
15
15
|
if (dataUrl && !editor.isDisposed() && (selection === null || selection === void 0 ? void 0 : selection.type) === 'image') {
|
|
16
16
|
(0, formatImageWithContentModel_1.formatImageWithContentModel)(editor, 'changeImage', function (image) {
|
|
17
17
|
var _a, _b;
|
|
18
|
-
var originalSrc = (_b = (_a = (0, roosterjs_content_model_dom_1.
|
|
18
|
+
var originalSrc = (_b = (_a = (0, roosterjs_content_model_dom_1.getImageMetadata)(image)) === null || _a === void 0 ? void 0 : _a.src) !== null && _b !== void 0 ? _b : '';
|
|
19
19
|
var previousSrc = image.src;
|
|
20
20
|
image.src = dataUrl;
|
|
21
21
|
image.dataset = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeImage.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/image/changeImage.ts"],"names":[],"mappings":";;;AAAA,oFAAmF;AACnF,
|
|
1
|
+
{"version":3,"file":"changeImage.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/image/changeImage.ts"],"names":[],"mappings":";;;AAAA,oFAAmF;AACnF,2EAAyE;AAGzE;;;;GAIG;AACH,SAAgB,WAAW,CAAC,MAAe,EAAE,IAAU;IACnD,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAC3C,IAAA,sCAAQ,EAAC,IAAI,EAAE,UAAA,OAAO;QAClB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,MAAK,OAAO,EAAE;YAChE,IAAA,yDAA2B,EAAC,MAAM,EAAE,aAAa,EAAE,UAAC,KAAwB;;gBACxE,IAAM,WAAW,GAAG,MAAA,MAAA,IAAA,8CAAgB,EAAC,KAAK,CAAC,0CAAE,GAAG,mCAAI,EAAE,CAAC;gBACvD,IAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC;gBAE9B,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC;gBACpB,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;gBACnB,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;gBACxB,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;gBACzB,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;gBAEf,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;oBAC7B,KAAK,EAAE,SAAS,CAAC,KAAK;oBACtB,WAAW,aAAA;oBACX,MAAM,EAAE,OAAO;oBACf,WAAW,aAAA;iBACd,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;SACN;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAzBD,kCAyBC","sourcesContent":["import { formatImageWithContentModel } from '../utils/formatImageWithContentModel';\nimport { getImageMetadata, readFile } from 'roosterjs-content-model-dom';\nimport type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Change the selected image src\n * @param editor The editor instance\n * @param file The image file\n */\nexport function changeImage(editor: IEditor, file: File) {\n editor.focus();\n\n const selection = editor.getDOMSelection();\n readFile(file, dataUrl => {\n if (dataUrl && !editor.isDisposed() && selection?.type === 'image') {\n formatImageWithContentModel(editor, 'changeImage', (image: ContentModelImage) => {\n const originalSrc = getImageMetadata(image)?.src ?? '';\n const previousSrc = image.src;\n\n image.src = dataUrl;\n image.dataset = {};\n image.format.width = '';\n image.format.height = '';\n image.alt = '';\n\n editor.triggerEvent('editImage', {\n image: selection.image,\n previousSrc,\n newSrc: dataUrl,\n originalSrc,\n });\n });\n }\n });\n}\n"]}
|
|
@@ -223,6 +223,11 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
223
223
|
//Format perimeter if necessary or possible
|
|
224
224
|
modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);
|
|
225
225
|
}
|
|
226
|
+
var tableMeta = (0, roosterjs_content_model_dom_1.hasMetadata)(tableModel) ? (0, roosterjs_content_model_dom_1.getTableMetadata)(tableModel) : {};
|
|
227
|
+
if (tableMeta) {
|
|
228
|
+
// Enforce first column format if necessary
|
|
229
|
+
(0, roosterjs_content_model_dom_1.setFirstColumnFormatBorders)(tableModel.rows, tableMeta);
|
|
230
|
+
}
|
|
226
231
|
return true;
|
|
227
232
|
}
|
|
228
233
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;;AAAA,2EAMqC;AA4BrC;;;;;GAKG;AACH,SAAgB,sBAAsB,CAClC,MAAe,EACf,MAAc,EACd,SAA2B;IAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,oBAAe,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;QAElD,IAAI,UAAU,EAAE;YACZ,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,UAAU,CAAC,CAAC;YACzC,IAAM,SAAS,GAAc;gBACzB,GAAG,EAAE,KAAK;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,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;YAClE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;SACjF;KACJ;IACD,qBAAqB;IACrB,IAAI,SAAS,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;QACzE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;YACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YACjE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;SACjF;KACJ;AACL,CAAC","sourcesContent":["import {\n extractBorderValues,\n getFirstSelectedTable,\n getSelectedCells,\n parseValueWithUnit,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport function applyTableBorderFormat(\n editor: IEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n // undefined is treated as Left to Right\n const isRtl = tableModel.format.direction == 'rtl';\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Right = true) : (perimeter.Left = true);\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Left = true) : (perimeter.Right = true);\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderLeft' : 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderRight' : 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter,\n isRtl: boolean\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderLeft' : 'borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderRight' : 'borderLeft']);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;;AAAA,2EASqC;AA4BrC;;;;;GAKG;AACH,SAAgB,sBAAsB,CAClC,MAAe,EACf,MAAc,EACd,SAA2B;IAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;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getFirstSelectedTable,\n getSelectedCells,\n getTableMetadata,\n hasMetadata,\n parseValueWithUnit,\n setFirstColumnFormatBorders,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport function applyTableBorderFormat(\n editor: IEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n // undefined is treated as Left to Right\n const isRtl = tableModel.format.direction == 'rtl';\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Right = true) : (perimeter.Left = true);\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Left = true) : (perimeter.Right = true);\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderLeft' : 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderRight' : 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);\n }\n\n const tableMeta = hasMetadata(tableModel) ? getTableMetadata(tableModel) : {};\n if (tableMeta) {\n // Enforce first column format if necessary\n setFirstColumnFormatBorders(tableModel.rows, tableMeta);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter,\n isRtl: boolean\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderLeft' : 'borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderRight' : 'borderLeft']);\n }\n }\n}\n"]}
|
|
@@ -13,7 +13,6 @@ function setTableCellShade(editor, color) {
|
|
|
13
13
|
editor.formatContentModel(function (model) {
|
|
14
14
|
var _a = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 1), table = _a[0];
|
|
15
15
|
if (table) {
|
|
16
|
-
(0, roosterjs_content_model_dom_1.normalizeTable)(table);
|
|
17
16
|
table.rows.forEach(function (row) {
|
|
18
17
|
return row.cells.forEach(function (cell) {
|
|
19
18
|
if ((0, roosterjs_content_model_dom_1.hasSelectionInBlockGroup)(cell)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTableCellShade.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/setTableCellShade.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"setTableCellShade.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/setTableCellShade.ts"],"names":[],"mappings":";;;;AAAA,2EAIqC;AAGrC;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,MAAe,EAAE,KAAoB;IACnE,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,oBAAU,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAArC,KAAK,QAAgC,CAAC;QAE7C,IAAI,KAAK,EAAE;YACP,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;gBAClB,OAAA,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;oBAClB,IAAI,IAAA,sDAAwB,EAAC,IAAI,CAAC,EAAE;wBAChC,IAAA,yDAA2B,EAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;qBACtE;gBACL,CAAC,CAAC;YAJF,CAIE,CACL,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,EAAE,mBAAmB;KAC/B,CACJ,CAAC;AACN,CAAC;AAzBD,8CAyBC","sourcesContent":["import {\n hasSelectionInBlockGroup,\n getFirstSelectedTable,\n setTableCellBackgroundColor,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set table cell shade color\n * @param editor The editor instance\n * @param color The color to set. Pass null to remove existing shade color\n */\nexport function setTableCellShade(editor: IEditor, color: string | null) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [table] = getFirstSelectedTable(model);\n\n if (table) {\n table.rows.forEach(row =>\n row.cells.forEach(cell => {\n if (hasSelectionInBlockGroup(cell)) {\n setTableCellBackgroundColor(cell, color, true /*isColorOverride*/);\n }\n })\n );\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'setTableCellShade',\n }\n );\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormatContentModelContext, ReadonlyContentModelDocument } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @param model The content model to set indentation
|
|
4
4
|
* @param indentation The indentation type, 'indent' to indent, 'outdent' to outdent
|
|
5
5
|
* @param length The length of indentation in pixel, default value is 40
|
|
6
6
|
* Set indentation for selected list items or paragraphs
|
|
7
7
|
*/
|
|
8
|
-
export declare function setModelIndentation(model:
|
|
8
|
+
export declare function setModelIndentation(model: ReadonlyContentModelDocument, indentation: 'indent' | 'outdent', length?: number, context?: FormatContentModelContext): boolean;
|
|
@@ -66,7 +66,7 @@ define(["require", "exports", "tslib", "../list/findListItemsInSameThread", "../
|
|
|
66
66
|
var currentParent = parent;
|
|
67
67
|
while (currentParent && modifiedBlocks.indexOf(currentBlock) < 0) {
|
|
68
68
|
var index = path.indexOf(currentParent);
|
|
69
|
-
var format = currentBlock.format;
|
|
69
|
+
var format = (0, roosterjs_content_model_dom_1.mutateBlock)(currentBlock).format;
|
|
70
70
|
var newValue = calculateMarginValue(format, isIndent, length);
|
|
71
71
|
if (newValue !== null) {
|
|
72
72
|
var isRtl = format.direction == 'rtl';
|