roosterjs-content-model-api 9.34.0 → 9.35.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/toggleModelBlockQuote.js +3 -1
- package/lib/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib/modelApi/link/promoteLink.js +3 -0
- package/lib/modelApi/link/promoteLink.js.map +1 -1
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js +3 -1
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-amd/modelApi/link/promoteLink.js +3 -0
- package/lib-amd/modelApi/link/promoteLink.js.map +1 -1
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js +3 -1
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-mjs/modelApi/link/promoteLink.js +3 -0
- package/lib-mjs/modelApi/link/promoteLink.js.map +1 -1
- package/package.json +3 -3
|
@@ -9,7 +9,9 @@ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
|
9
9
|
*/
|
|
10
10
|
function toggleModelBlockQuote(model, formatLtr, formatRtl) {
|
|
11
11
|
(0, splitSelectedParagraphByBr_1.splitSelectedParagraphByBr)(model);
|
|
12
|
-
var paragraphOfQuote = (0, roosterjs_content_model_dom_1.getOperationalBlocks)(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst
|
|
12
|
+
var paragraphOfQuote = (0, roosterjs_content_model_dom_1.getOperationalBlocks)(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/, function (block) {
|
|
13
|
+
return block.blockGroupType == 'FormatContainer' ? block.tagName == 'blockquote' : true;
|
|
14
|
+
});
|
|
13
15
|
if (areAllBlockQuotes(paragraphOfQuote)) {
|
|
14
16
|
// All selections are already in quote, we need to unquote them
|
|
15
17
|
paragraphOfQuote.forEach(function (_a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.ts"],"names":[],"mappings":";;;AAAA,2EAA0E;AAC1E,iDAAqE;AACrE,2EAMqC;AAerC;;GAEG;AACH,SAAgB,qBAAqB,CACjC,KAAmC,EACnC,SAA4C,EAC5C,SAA4C;IAE5C,IAAA,uDAA0B,EAAC,KAAK,CAAC,CAAC;IAElC,IAAM,gBAAgB,GAAG,IAAA,kDAAoB,EAE3C,KAAK,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.ts"],"names":[],"mappings":";;;AAAA,2EAA0E;AAC1E,iDAAqE;AACrE,2EAMqC;AAerC;;GAEG;AACH,SAAgB,qBAAqB,CACjC,KAAmC,EACnC,SAA4C,EAC5C,SAA4C;IAE5C,IAAA,uDAA0B,EAAC,KAAK,CAAC,CAAC;IAElC,IAAM,gBAAgB,GAAG,IAAA,kDAAoB,EAE3C,KAAK,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,UAAA,KAAK;QAC9E,OAAO,KAAK,CAAC,cAAc,IAAI,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5F,CAAC,CAAC,CAAC;IAEH,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,EAAE;QACrC,+DAA+D;QAC/D,gBAAgB,CAAC,OAAO,CAAC,UAAC,EAAiB;gBAAf,KAAK,WAAA,EAAE,MAAM,YAAA;YACrC,IAAA,yCAAW,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC,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;IAMH,OAAO,eAAe,CAAC,KAAK,CAAC,UAAA,cAAc,IAAI,OAAA,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport { wrapBlockStep1, wrapBlockStep2 } from '../common/wrapBlock';\nimport {\n getOperationalBlocks,\n isBlockGroupOfType,\n areSameFormats,\n createFormatContainer,\n unwrapBlock,\n} from 'roosterjs-content-model-dom';\nimport type { WrapBlockStep1Result } from '../common/wrapBlock';\nimport type {\n ContentModelBlockGroup,\n ContentModelFormatContainer,\n ContentModelFormatContainerFormat,\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelFormatContainer,\n ReadonlyContentModelListItem,\n ReadonlyOperationalBlocks,\n ShallowMutableContentModelBlock,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function toggleModelBlockQuote(\n model: ReadonlyContentModelDocument,\n formatLtr: ContentModelFormatContainerFormat,\n formatRtl: ContentModelFormatContainerFormat\n): boolean {\n splitSelectedParagraphByBr(model);\n\n const paragraphOfQuote = getOperationalBlocks<\n ContentModelFormatContainer | ContentModelListItem\n >(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/, block => {\n return block.blockGroupType == 'FormatContainer' ? block.tagName == 'blockquote' : true;\n });\n\n if (areAllBlockQuotes(paragraphOfQuote)) {\n // All selections are already in quote, we need to unquote them\n paragraphOfQuote.forEach(({ block, parent }) => {\n unwrapBlock(parent, block);\n });\n } else {\n const step1Results: WrapBlockStep1Result<ContentModelFormatContainer>[] = [];\n const creator = (isRtl: boolean) =>\n createFormatContainer('blockquote', isRtl ? formatRtl : formatLtr);\n const canMerge = (\n isRtl: boolean,\n target: ShallowMutableContentModelBlock,\n current?: ContentModelFormatContainer\n ): target is ContentModelFormatContainer =>\n canMergeQuote(target, current?.format || (isRtl ? formatRtl : formatLtr));\n\n paragraphOfQuote.forEach(({ block, parent }) => {\n if (isQuote(block)) {\n // Already in quote, no op\n } else {\n wrapBlockStep1(step1Results, parent, block, creator, canMerge);\n }\n });\n\n wrapBlockStep2(step1Results, canMerge);\n }\n\n return paragraphOfQuote.length > 0;\n}\n\nfunction canMergeQuote(\n target: ShallowMutableContentModelBlock,\n format: ContentModelFormatContainerFormat\n): target is ContentModelFormatContainer {\n return isQuote(target) && areSameFormats(format, target.format);\n}\n\nfunction isQuote(block: ReadonlyContentModelBlock): block is ReadonlyContentModelFormatContainer {\n return (\n isBlockGroupOfType<ContentModelFormatContainer>(block, 'FormatContainer') &&\n block.tagName == 'blockquote'\n );\n}\n\nfunction areAllBlockQuotes(\n blockAndParents: ReadonlyOperationalBlocks<\n ReadonlyContentModelFormatContainer | ReadonlyContentModelListItem\n >[]\n): blockAndParents is {\n block: ContentModelFormatContainer;\n parent: ContentModelBlockGroup;\n path: ContentModelBlockGroup[];\n}[] {\n return blockAndParents.every(blockAndParent => isQuote(blockAndParent.block));\n}\n"]}
|
|
@@ -15,6 +15,9 @@ var splitTextSegment_1 = require("../../publicApi/segment/splitTextSegment");
|
|
|
15
15
|
* @returns If a link is promoted, return this segment. Otherwise return null
|
|
16
16
|
*/
|
|
17
17
|
function promoteLink(segment, paragraph, autoLinkOptions) {
|
|
18
|
+
if (segment.link) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
18
21
|
var link = segment.text.split(' ').pop();
|
|
19
22
|
var url = link === null || link === void 0 ? void 0 : link.trim();
|
|
20
23
|
var linkUrl = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promoteLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/link/promoteLink.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,6EAA4E;AAO5E;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CACvB,OAAyB,EACzB,SAA8C,EAC9C,eAAgC;IAEhC,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC3C,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;IACzB,IAAI,OAAO,GAAuB,SAAS,CAAC;IAE5C,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,OAAO,GAAG,IAAA,uBAAU,EAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE;QAC7D,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAChC,OAAO,EACP,SAAS,EACT,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAC5C,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAClC,CAAC;QACF,WAAW,CAAC,IAAI,GAAG;YACf,MAAM,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,IAAI;aAClB;YACD,OAAO,EAAE,EAAE;SACd,CAAC;QAEF,OAAO,WAAW,CAAC;KACtB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;
|
|
1
|
+
{"version":3,"file":"promoteLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/link/promoteLink.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,6EAA4E;AAO5E;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CACvB,OAAyB,EACzB,SAA8C,EAC9C,eAAgC;IAEhC,IAAI,OAAO,CAAC,IAAI,EAAE;QACd,OAAO,IAAI,CAAC;KACf;IACD,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC3C,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;IACzB,IAAI,OAAO,GAAuB,SAAS,CAAC;IAE5C,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,OAAO,GAAG,IAAA,uBAAU,EAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE;QAC7D,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAChC,OAAO,EACP,SAAS,EACT,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAC5C,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAClC,CAAC;QACF,WAAW,CAAC,IAAI,GAAG;YACf,MAAM,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,IAAI;aAClB;YACD,OAAO,EAAE,EAAE;SACd,CAAC;QAEF,OAAO,WAAW,CAAC;KACtB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AA/BD,kCA+BC","sourcesContent":["import { getLinkUrl } from './getLinkUrl';\nimport { splitTextSegment } from '../../publicApi/segment/splitTextSegment';\nimport type {\n AutoLinkOptions,\n ContentModelText,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Promote the given text segment to a hyper link when the segment text is ending with a valid link format.\n * When the whole text segment if of a link, promote the whole segment.\n * When the text segment ends with a link format, split the segment and promote the second part\n * When link is in middle of the text segment, no action.\n * This is mainly used for doing auto link when there is a link before cursor\n * @param segment The text segment to search link text from\n * @param paragraph Parent paragraph of the segment\n * @param options Options of auto link\n * @returns If a link is promoted, return this segment. Otherwise return null\n */\nexport function promoteLink(\n segment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n autoLinkOptions: AutoLinkOptions\n): ContentModelText | null {\n if (segment.link) {\n return null;\n }\n const link = segment.text.split(' ').pop();\n const url = link?.trim();\n let linkUrl: string | undefined = undefined;\n\n if (url && link && (linkUrl = getLinkUrl(url, autoLinkOptions))) {\n const linkSegment = splitTextSegment(\n segment,\n paragraph,\n segment.text.length - link.trimLeft().length,\n segment.text.trimRight().length\n );\n linkSegment.link = {\n format: {\n href: linkUrl,\n underline: true,\n },\n dataset: {},\n };\n\n return linkSegment;\n }\n\n return null;\n}\n"]}
|
|
@@ -7,7 +7,9 @@ define(["require", "exports", "./splitSelectedParagraphByBr", "../common/wrapBlo
|
|
|
7
7
|
*/
|
|
8
8
|
function toggleModelBlockQuote(model, formatLtr, formatRtl) {
|
|
9
9
|
(0, splitSelectedParagraphByBr_1.splitSelectedParagraphByBr)(model);
|
|
10
|
-
var paragraphOfQuote = (0, roosterjs_content_model_dom_1.getOperationalBlocks)(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst
|
|
10
|
+
var paragraphOfQuote = (0, roosterjs_content_model_dom_1.getOperationalBlocks)(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/, function (block) {
|
|
11
|
+
return block.blockGroupType == 'FormatContainer' ? block.tagName == 'blockquote' : true;
|
|
12
|
+
});
|
|
11
13
|
if (areAllBlockQuotes(paragraphOfQuote)) {
|
|
12
14
|
// All selections are already in quote, we need to unquote them
|
|
13
15
|
paragraphOfQuote.forEach(function (_a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.ts"],"names":[],"mappings":";;;;IAuBA;;OAEG;IACH,SAAgB,qBAAqB,CACjC,KAAmC,EACnC,SAA4C,EAC5C,SAA4C;QAE5C,IAAA,uDAA0B,EAAC,KAAK,CAAC,CAAC;QAElC,IAAM,gBAAgB,GAAG,IAAA,kDAAoB,EAE3C,KAAK,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.ts"],"names":[],"mappings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AAK,CAAC,EAAE;oBAChB,0BAA0B;iBAC7B;qBAAM;oBACH,IAAA,0BAAc,EAAC,cAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAO,EAAE,UAAQ,CAAC,CAAC;iBAClE;YACL,CAAC,CAAC,CAAC;YAEH,IAAA,0BAAc,EAAC,cAAY,EAAE,UAAQ,CAAC,CAAC;SAC1C;QAED,OAAO,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;IACvC,CAAC;IAzCD,sDAyCC;IAED,SAAS,aAAa,CAClB,MAAuC,EACvC,MAAyC;QAEzC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,IAAA,4CAAc,EAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACpE,CAAC;IAED,SAAS,OAAO,CAAC,KAAgC;QAC7C,OAAO,CACH,IAAA,gDAAkB,EAA8B,KAAK,EAAE,iBAAiB,CAAC;YACzE,KAAK,CAAC,OAAO,IAAI,YAAY,CAChC,CAAC;IACN,CAAC;IAED,SAAS,iBAAiB,CACtB,eAEG;QAMH,OAAO,eAAe,CAAC,KAAK,CAAC,UAAA,cAAc,IAAI,OAAA,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC,CAAC;IAClF,CAAC","sourcesContent":["import { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport { wrapBlockStep1, wrapBlockStep2 } from '../common/wrapBlock';\nimport {\n getOperationalBlocks,\n isBlockGroupOfType,\n areSameFormats,\n createFormatContainer,\n unwrapBlock,\n} from 'roosterjs-content-model-dom';\nimport type { WrapBlockStep1Result } from '../common/wrapBlock';\nimport type {\n ContentModelBlockGroup,\n ContentModelFormatContainer,\n ContentModelFormatContainerFormat,\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelFormatContainer,\n ReadonlyContentModelListItem,\n ReadonlyOperationalBlocks,\n ShallowMutableContentModelBlock,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function toggleModelBlockQuote(\n model: ReadonlyContentModelDocument,\n formatLtr: ContentModelFormatContainerFormat,\n formatRtl: ContentModelFormatContainerFormat\n): boolean {\n splitSelectedParagraphByBr(model);\n\n const paragraphOfQuote = getOperationalBlocks<\n ContentModelFormatContainer | ContentModelListItem\n >(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/, block => {\n return block.blockGroupType == 'FormatContainer' ? block.tagName == 'blockquote' : true;\n });\n\n if (areAllBlockQuotes(paragraphOfQuote)) {\n // All selections are already in quote, we need to unquote them\n paragraphOfQuote.forEach(({ block, parent }) => {\n unwrapBlock(parent, block);\n });\n } else {\n const step1Results: WrapBlockStep1Result<ContentModelFormatContainer>[] = [];\n const creator = (isRtl: boolean) =>\n createFormatContainer('blockquote', isRtl ? formatRtl : formatLtr);\n const canMerge = (\n isRtl: boolean,\n target: ShallowMutableContentModelBlock,\n current?: ContentModelFormatContainer\n ): target is ContentModelFormatContainer =>\n canMergeQuote(target, current?.format || (isRtl ? formatRtl : formatLtr));\n\n paragraphOfQuote.forEach(({ block, parent }) => {\n if (isQuote(block)) {\n // Already in quote, no op\n } else {\n wrapBlockStep1(step1Results, parent, block, creator, canMerge);\n }\n });\n\n wrapBlockStep2(step1Results, canMerge);\n }\n\n return paragraphOfQuote.length > 0;\n}\n\nfunction canMergeQuote(\n target: ShallowMutableContentModelBlock,\n format: ContentModelFormatContainerFormat\n): target is ContentModelFormatContainer {\n return isQuote(target) && areSameFormats(format, target.format);\n}\n\nfunction isQuote(block: ReadonlyContentModelBlock): block is ReadonlyContentModelFormatContainer {\n return (\n isBlockGroupOfType<ContentModelFormatContainer>(block, 'FormatContainer') &&\n block.tagName == 'blockquote'\n );\n}\n\nfunction areAllBlockQuotes(\n blockAndParents: ReadonlyOperationalBlocks<\n ReadonlyContentModelFormatContainer | ReadonlyContentModelListItem\n >[]\n): blockAndParents is {\n block: ContentModelFormatContainer;\n parent: ContentModelBlockGroup;\n path: ContentModelBlockGroup[];\n}[] {\n return blockAndParents.every(blockAndParent => isQuote(blockAndParent.block));\n}\n"]}
|
|
@@ -14,6 +14,9 @@ define(["require", "exports", "./getLinkUrl", "../../publicApi/segment/splitText
|
|
|
14
14
|
* @returns If a link is promoted, return this segment. Otherwise return null
|
|
15
15
|
*/
|
|
16
16
|
function promoteLink(segment, paragraph, autoLinkOptions) {
|
|
17
|
+
if (segment.link) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
17
20
|
var link = segment.text.split(' ').pop();
|
|
18
21
|
var url = link === null || link === void 0 ? void 0 : link.trim();
|
|
19
22
|
var linkUrl = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promoteLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/link/promoteLink.ts"],"names":[],"mappings":";;;;IAQA;;;;;;;;;;OAUG;IACH,SAAgB,WAAW,CACvB,OAAyB,EACzB,SAA8C,EAC9C,eAAgC;QAEhC,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QAC3C,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;QACzB,IAAI,OAAO,GAAuB,SAAS,CAAC;QAE5C,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,OAAO,GAAG,IAAA,uBAAU,EAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE;YAC7D,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAChC,OAAO,EACP,SAAS,EACT,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAC5C,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAClC,CAAC;YACF,WAAW,CAAC,IAAI,GAAG;gBACf,MAAM,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,SAAS,EAAE,IAAI;iBAClB;gBACD,OAAO,EAAE,EAAE;aACd,CAAC;YAEF,OAAO,WAAW,CAAC;SACtB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;
|
|
1
|
+
{"version":3,"file":"promoteLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/link/promoteLink.ts"],"names":[],"mappings":";;;;IAQA;;;;;;;;;;OAUG;IACH,SAAgB,WAAW,CACvB,OAAyB,EACzB,SAA8C,EAC9C,eAAgC;QAEhC,IAAI,OAAO,CAAC,IAAI,EAAE;YACd,OAAO,IAAI,CAAC;SACf;QACD,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QAC3C,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;QACzB,IAAI,OAAO,GAAuB,SAAS,CAAC;QAE5C,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,OAAO,GAAG,IAAA,uBAAU,EAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE;YAC7D,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAChC,OAAO,EACP,SAAS,EACT,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAC5C,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAClC,CAAC;YACF,WAAW,CAAC,IAAI,GAAG;gBACf,MAAM,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,SAAS,EAAE,IAAI;iBAClB;gBACD,OAAO,EAAE,EAAE;aACd,CAAC;YAEF,OAAO,WAAW,CAAC;SACtB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IA/BD,kCA+BC","sourcesContent":["import { getLinkUrl } from './getLinkUrl';\nimport { splitTextSegment } from '../../publicApi/segment/splitTextSegment';\nimport type {\n AutoLinkOptions,\n ContentModelText,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Promote the given text segment to a hyper link when the segment text is ending with a valid link format.\n * When the whole text segment if of a link, promote the whole segment.\n * When the text segment ends with a link format, split the segment and promote the second part\n * When link is in middle of the text segment, no action.\n * This is mainly used for doing auto link when there is a link before cursor\n * @param segment The text segment to search link text from\n * @param paragraph Parent paragraph of the segment\n * @param options Options of auto link\n * @returns If a link is promoted, return this segment. Otherwise return null\n */\nexport function promoteLink(\n segment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n autoLinkOptions: AutoLinkOptions\n): ContentModelText | null {\n if (segment.link) {\n return null;\n }\n const link = segment.text.split(' ').pop();\n const url = link?.trim();\n let linkUrl: string | undefined = undefined;\n\n if (url && link && (linkUrl = getLinkUrl(url, autoLinkOptions))) {\n const linkSegment = splitTextSegment(\n segment,\n paragraph,\n segment.text.length - link.trimLeft().length,\n segment.text.trimRight().length\n );\n linkSegment.link = {\n format: {\n href: linkUrl,\n underline: true,\n },\n dataset: {},\n };\n\n return linkSegment;\n }\n\n return null;\n}\n"]}
|
|
@@ -6,7 +6,9 @@ import { getOperationalBlocks, isBlockGroupOfType, areSameFormats, createFormatC
|
|
|
6
6
|
*/
|
|
7
7
|
export function toggleModelBlockQuote(model, formatLtr, formatRtl) {
|
|
8
8
|
splitSelectedParagraphByBr(model);
|
|
9
|
-
var paragraphOfQuote = getOperationalBlocks(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst
|
|
9
|
+
var paragraphOfQuote = getOperationalBlocks(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/, function (block) {
|
|
10
|
+
return block.blockGroupType == 'FormatContainer' ? block.tagName == 'blockquote' : true;
|
|
11
|
+
});
|
|
10
12
|
if (areAllBlockQuotes(paragraphOfQuote)) {
|
|
11
13
|
// All selections are already in quote, we need to unquote them
|
|
12
14
|
paragraphOfQuote.forEach(function (_a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,WAAW,GACd,MAAM,6BAA6B,CAAC;AAerC;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACjC,KAAmC,EACnC,SAA4C,EAC5C,SAA4C;IAE5C,0BAA0B,CAAC,KAAK,CAAC,CAAC;IAElC,IAAM,gBAAgB,GAAG,oBAAoB,CAE3C,KAAK,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,WAAW,GACd,MAAM,6BAA6B,CAAC;AAerC;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACjC,KAAmC,EACnC,SAA4C,EAC5C,SAA4C;IAE5C,0BAA0B,CAAC,KAAK,CAAC,CAAC;IAElC,IAAM,gBAAgB,GAAG,oBAAoB,CAE3C,KAAK,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,UAAA,K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B,MAAuC,EACvC,MAAyC;IAEzC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,OAAO,CAAC,KAAgC;IAC7C,OAAO,CACH,kBAAkB,CAA8B,KAAK,EAAE,iBAAiB,CAAC;QACzE,KAAK,CAAC,OAAO,IAAI,YAAY,CAChC,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CACtB,eAEG;IAMH,OAAO,eAAe,CAAC,KAAK,CAAC,UAAA,cAAc,IAAI,OAAA,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport { wrapBlockStep1, wrapBlockStep2 } from '../common/wrapBlock';\nimport {\n getOperationalBlocks,\n isBlockGroupOfType,\n areSameFormats,\n createFormatContainer,\n unwrapBlock,\n} from 'roosterjs-content-model-dom';\nimport type { WrapBlockStep1Result } from '../common/wrapBlock';\nimport type {\n ContentModelBlockGroup,\n ContentModelFormatContainer,\n ContentModelFormatContainerFormat,\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelFormatContainer,\n ReadonlyContentModelListItem,\n ReadonlyOperationalBlocks,\n ShallowMutableContentModelBlock,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function toggleModelBlockQuote(\n model: ReadonlyContentModelDocument,\n formatLtr: ContentModelFormatContainerFormat,\n formatRtl: ContentModelFormatContainerFormat\n): boolean {\n splitSelectedParagraphByBr(model);\n\n const paragraphOfQuote = getOperationalBlocks<\n ContentModelFormatContainer | ContentModelListItem\n >(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/, block => {\n return block.blockGroupType == 'FormatContainer' ? block.tagName == 'blockquote' : true;\n });\n\n if (areAllBlockQuotes(paragraphOfQuote)) {\n // All selections are already in quote, we need to unquote them\n paragraphOfQuote.forEach(({ block, parent }) => {\n unwrapBlock(parent, block);\n });\n } else {\n const step1Results: WrapBlockStep1Result<ContentModelFormatContainer>[] = [];\n const creator = (isRtl: boolean) =>\n createFormatContainer('blockquote', isRtl ? formatRtl : formatLtr);\n const canMerge = (\n isRtl: boolean,\n target: ShallowMutableContentModelBlock,\n current?: ContentModelFormatContainer\n ): target is ContentModelFormatContainer =>\n canMergeQuote(target, current?.format || (isRtl ? formatRtl : formatLtr));\n\n paragraphOfQuote.forEach(({ block, parent }) => {\n if (isQuote(block)) {\n // Already in quote, no op\n } else {\n wrapBlockStep1(step1Results, parent, block, creator, canMerge);\n }\n });\n\n wrapBlockStep2(step1Results, canMerge);\n }\n\n return paragraphOfQuote.length > 0;\n}\n\nfunction canMergeQuote(\n target: ShallowMutableContentModelBlock,\n format: ContentModelFormatContainerFormat\n): target is ContentModelFormatContainer {\n return isQuote(target) && areSameFormats(format, target.format);\n}\n\nfunction isQuote(block: ReadonlyContentModelBlock): block is ReadonlyContentModelFormatContainer {\n return (\n isBlockGroupOfType<ContentModelFormatContainer>(block, 'FormatContainer') &&\n block.tagName == 'blockquote'\n );\n}\n\nfunction areAllBlockQuotes(\n blockAndParents: ReadonlyOperationalBlocks<\n ReadonlyContentModelFormatContainer | ReadonlyContentModelListItem\n >[]\n): blockAndParents is {\n block: ContentModelFormatContainer;\n parent: ContentModelBlockGroup;\n path: ContentModelBlockGroup[];\n}[] {\n return blockAndParents.every(blockAndParent => isQuote(blockAndParent.block));\n}\n"]}
|
|
@@ -12,6 +12,9 @@ import { splitTextSegment } from '../../publicApi/segment/splitTextSegment';
|
|
|
12
12
|
* @returns If a link is promoted, return this segment. Otherwise return null
|
|
13
13
|
*/
|
|
14
14
|
export function promoteLink(segment, paragraph, autoLinkOptions) {
|
|
15
|
+
if (segment.link) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
15
18
|
var link = segment.text.split(' ').pop();
|
|
16
19
|
var url = link === null || link === void 0 ? void 0 : link.trim();
|
|
17
20
|
var linkUrl = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promoteLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/link/promoteLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAO5E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACvB,OAAyB,EACzB,SAA8C,EAC9C,eAAgC;IAEhC,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC3C,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;IACzB,IAAI,OAAO,GAAuB,SAAS,CAAC;IAE5C,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE;QAC7D,IAAM,WAAW,GAAG,gBAAgB,CAChC,OAAO,EACP,SAAS,EACT,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAC5C,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAClC,CAAC;QACF,WAAW,CAAC,IAAI,GAAG;YACf,MAAM,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,IAAI;aAClB;YACD,OAAO,EAAE,EAAE;SACd,CAAC;QAEF,OAAO,WAAW,CAAC;KACtB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { getLinkUrl } from './getLinkUrl';\nimport { splitTextSegment } from '../../publicApi/segment/splitTextSegment';\nimport type {\n AutoLinkOptions,\n ContentModelText,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Promote the given text segment to a hyper link when the segment text is ending with a valid link format.\n * When the whole text segment if of a link, promote the whole segment.\n * When the text segment ends with a link format, split the segment and promote the second part\n * When link is in middle of the text segment, no action.\n * This is mainly used for doing auto link when there is a link before cursor\n * @param segment The text segment to search link text from\n * @param paragraph Parent paragraph of the segment\n * @param options Options of auto link\n * @returns If a link is promoted, return this segment. Otherwise return null\n */\nexport function promoteLink(\n segment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n autoLinkOptions: AutoLinkOptions\n): ContentModelText | null {\n const link = segment.text.split(' ').pop();\n const url = link?.trim();\n let linkUrl: string | undefined = undefined;\n\n if (url && link && (linkUrl = getLinkUrl(url, autoLinkOptions))) {\n const linkSegment = splitTextSegment(\n segment,\n paragraph,\n segment.text.length - link.trimLeft().length,\n segment.text.trimRight().length\n );\n linkSegment.link = {\n format: {\n href: linkUrl,\n underline: true,\n },\n dataset: {},\n };\n\n return linkSegment;\n }\n\n return null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"promoteLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/link/promoteLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAO5E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACvB,OAAyB,EACzB,SAA8C,EAC9C,eAAgC;IAEhC,IAAI,OAAO,CAAC,IAAI,EAAE;QACd,OAAO,IAAI,CAAC;KACf;IACD,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC3C,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;IACzB,IAAI,OAAO,GAAuB,SAAS,CAAC;IAE5C,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE;QAC7D,IAAM,WAAW,GAAG,gBAAgB,CAChC,OAAO,EACP,SAAS,EACT,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAC5C,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAClC,CAAC;QACF,WAAW,CAAC,IAAI,GAAG;YACf,MAAM,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,IAAI;aAClB;YACD,OAAO,EAAE,EAAE;SACd,CAAC;QAEF,OAAO,WAAW,CAAC;KACtB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { getLinkUrl } from './getLinkUrl';\nimport { splitTextSegment } from '../../publicApi/segment/splitTextSegment';\nimport type {\n AutoLinkOptions,\n ContentModelText,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Promote the given text segment to a hyper link when the segment text is ending with a valid link format.\n * When the whole text segment if of a link, promote the whole segment.\n * When the text segment ends with a link format, split the segment and promote the second part\n * When link is in middle of the text segment, no action.\n * This is mainly used for doing auto link when there is a link before cursor\n * @param segment The text segment to search link text from\n * @param paragraph Parent paragraph of the segment\n * @param options Options of auto link\n * @returns If a link is promoted, return this segment. Otherwise return null\n */\nexport function promoteLink(\n segment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n autoLinkOptions: AutoLinkOptions\n): ContentModelText | null {\n if (segment.link) {\n return null;\n }\n const link = segment.text.split(' ').pop();\n const url = link?.trim();\n let linkUrl: string | undefined = undefined;\n\n if (url && link && (linkUrl = getLinkUrl(url, autoLinkOptions))) {\n const linkSegment = splitTextSegment(\n segment,\n paragraph,\n segment.text.length - link.trimLeft().length,\n segment.text.trimRight().length\n );\n linkSegment.link = {\n format: {\n href: linkUrl,\n underline: true,\n },\n dataset: {},\n };\n\n return linkSegment;\n }\n\n return null;\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.
|
|
7
|
-
"roosterjs-content-model-types": "^9.
|
|
6
|
+
"roosterjs-content-model-dom": "^9.35.0",
|
|
7
|
+
"roosterjs-content-model-types": "^9.35.0"
|
|
8
8
|
},
|
|
9
|
-
"version": "9.
|
|
9
|
+
"version": "9.35.0",
|
|
10
10
|
"main": "./lib/index.js",
|
|
11
11
|
"typings": "./lib/index.d.ts",
|
|
12
12
|
"module": "./lib-mjs/index.js",
|