roosterjs-content-model-api 0.24.0 → 0.25.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/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/modelApi/block/setModelDirection.js +0 -1
- package/lib/modelApi/block/setModelDirection.js.map +1 -1
- package/lib/modelApi/block/toggleModelBlockQuote.d.ts +1 -1
- package/lib/modelApi/block/toggleModelBlockQuote.js +6 -4
- package/lib/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib/modelApi/common/retrieveModelFormatState.js +0 -2
- package/lib/modelApi/common/retrieveModelFormatState.js.map +1 -1
- package/lib/modelApi/common/wrapBlock.d.ts +2 -2
- package/lib/modelApi/common/wrapBlock.js +8 -4
- package/lib/modelApi/common/wrapBlock.js.map +1 -1
- package/lib/modelApi/link/matchLink.d.ts +29 -0
- package/lib/modelApi/link/matchLink.js +95 -0
- package/lib/modelApi/link/matchLink.js.map +1 -0
- package/lib/modelApi/list/setListType.d.ts +3 -1
- package/lib/modelApi/list/setListType.js +6 -9
- package/lib/modelApi/list/setListType.js.map +1 -1
- package/lib/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib/publicApi/block/toggleBlockQuote.js +10 -6
- package/lib/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib/publicApi/entity/insertEntity.js +6 -10
- package/lib/publicApi/entity/insertEntity.js.map +1 -1
- package/lib/publicApi/format/getFormatState.d.ts +1 -21
- package/lib/publicApi/format/getFormatState.js +1 -69
- package/lib/publicApi/format/getFormatState.js.map +1 -1
- package/lib/publicApi/link/insertLink.js +3 -12
- package/lib/publicApi/link/insertLink.js.map +1 -1
- package/lib/publicApi/segment/changeCapitalization.js +0 -1
- package/lib/publicApi/segment/changeCapitalization.js.map +1 -1
- package/lib-amd/index.d.ts +1 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/modelApi/block/setModelDirection.js +0 -1
- package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-amd/modelApi/block/toggleModelBlockQuote.d.ts +1 -1
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js +6 -4
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-amd/modelApi/common/retrieveModelFormatState.js +0 -2
- package/lib-amd/modelApi/common/retrieveModelFormatState.js.map +1 -1
- package/lib-amd/modelApi/common/wrapBlock.d.ts +2 -2
- package/lib-amd/modelApi/common/wrapBlock.js +8 -4
- package/lib-amd/modelApi/common/wrapBlock.js.map +1 -1
- package/lib-amd/modelApi/link/matchLink.d.ts +29 -0
- package/lib-amd/modelApi/link/matchLink.js +95 -0
- package/lib-amd/modelApi/link/matchLink.js.map +1 -0
- package/lib-amd/modelApi/list/setListType.d.ts +3 -1
- package/lib-amd/modelApi/list/setListType.js +6 -9
- package/lib-amd/modelApi/list/setListType.js.map +1 -1
- package/lib-amd/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib-amd/publicApi/block/toggleBlockQuote.js +10 -6
- package/lib-amd/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib-amd/publicApi/entity/insertEntity.js +6 -10
- package/lib-amd/publicApi/entity/insertEntity.js.map +1 -1
- package/lib-amd/publicApi/format/getFormatState.d.ts +1 -21
- package/lib-amd/publicApi/format/getFormatState.js +2 -67
- package/lib-amd/publicApi/format/getFormatState.js.map +1 -1
- package/lib-amd/publicApi/link/insertLink.js +3 -12
- package/lib-amd/publicApi/link/insertLink.js.map +1 -1
- package/lib-amd/publicApi/segment/changeCapitalization.js +0 -1
- package/lib-amd/publicApi/segment/changeCapitalization.js.map +1 -1
- package/lib-mjs/index.d.ts +1 -0
- package/lib-mjs/index.js +1 -0
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelDirection.js +0 -1
- package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.d.ts +1 -1
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js +6 -4
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-mjs/modelApi/common/retrieveModelFormatState.js +0 -2
- package/lib-mjs/modelApi/common/retrieveModelFormatState.js.map +1 -1
- package/lib-mjs/modelApi/common/wrapBlock.d.ts +2 -2
- package/lib-mjs/modelApi/common/wrapBlock.js +8 -4
- package/lib-mjs/modelApi/common/wrapBlock.js.map +1 -1
- package/lib-mjs/modelApi/link/matchLink.d.ts +29 -0
- package/lib-mjs/modelApi/link/matchLink.js +91 -0
- package/lib-mjs/modelApi/link/matchLink.js.map +1 -0
- package/lib-mjs/modelApi/list/setListType.d.ts +3 -1
- package/lib-mjs/modelApi/list/setListType.js +6 -9
- package/lib-mjs/modelApi/list/setListType.js.map +1 -1
- package/lib-mjs/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib-mjs/publicApi/block/toggleBlockQuote.js +10 -6
- package/lib-mjs/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib-mjs/publicApi/entity/insertEntity.js +6 -10
- package/lib-mjs/publicApi/entity/insertEntity.js.map +1 -1
- package/lib-mjs/publicApi/format/getFormatState.d.ts +1 -21
- package/lib-mjs/publicApi/format/getFormatState.js +1 -67
- package/lib-mjs/publicApi/format/getFormatState.js.map +1 -1
- package/lib-mjs/publicApi/link/insertLink.js +2 -11
- package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
- package/lib-mjs/publicApi/segment/changeCapitalization.js +0 -1
- package/lib-mjs/publicApi/segment/changeCapitalization.js.map +1 -1
- package/package.json +4 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/retrieveModelFormatState.ts"],"names":[],"mappings":";;;;IAqBA;;OAEG;IACH,SAAgB,wBAAwB,CACpC,KAA2B,EAC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,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;YACnD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;SACtB;IACL,CAAC;IAED,SAAS,KAAK,CAAC,EAAU;QACrB,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;YACzC,uHAAuH;YACvH,wBAAwB;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;SAC9D;QACD,OAAO,EAAE,CAAC;IACd,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getClosestAncestorBlockGroupIndex,\n isBold,\n iterateSelections,\n updateTableMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n ContentModelFormatState,\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelImage,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function retrieveModelFormatState(\n model: ContentModelDocument,\n pendingFormat: ContentModelSegmentFormat | null,\n formatState: ContentModelFormatState\n) {\n let firstTableContext: TableSelectionContext | undefined;\n let firstBlock: ContentModelBlock | undefined;\n let isFirst = true;\n let isFirstImage = true;\n let isFirstSegment = true;\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n // Structure formats\n retrieveStructureFormat(formatState, path, isFirst);\n\n // Multiple line format\n if (block) {\n if (firstBlock) {\n formatState.isMultilineSelection = true;\n } else {\n firstBlock = block;\n }\n }\n\n if (block?.blockType == 'Paragraph') {\n // Paragraph formats\n retrieveParagraphFormat(formatState, block, isFirst);\n\n // Segment formats\n segments?.forEach(segment => {\n if (isFirstSegment || segment.segmentType != 'SelectionMarker') {\n const modelFormat = Object.assign({}, model.format);\n delete modelFormat?.italic;\n delete modelFormat?.underline;\n delete modelFormat?.fontWeight;\n\n retrieveSegmentFormat(\n formatState,\n isFirst,\n Object.assign(\n {},\n modelFormat,\n block.format,\n block.decorator?.format,\n segment.format,\n segment.code?.format,\n segment.link?.format,\n pendingFormat\n )\n );\n\n mergeValue(formatState, 'isCodeInline', !!segment?.code, isFirst);\n }\n\n // We only care the format of selection marker when it is the first selected segment. This is because when selection marker\n // is after some other selected segments, it mostly like appears at the beginning of a seconde line when the whole first line\n // is selected (e.g. triple-click on a line) then the second selection marker doesn't contain a correct format, so we need to\n // ignore it\n isFirstSegment = false;\n\n formatState.canUnlink = formatState.canUnlink || !!segment.link;\n formatState.canAddImageAltText =\n formatState.canAddImageAltText ||\n segments.some(segment => segment.segmentType == 'Image');\n\n isFirst = false;\n\n if (segment.segmentType === 'Image') {\n if (isFirstImage) {\n retrieveImageFormat(segment, formatState);\n isFirstImage = false;\n } else {\n formatState.imageFormat = undefined;\n }\n }\n });\n\n isFirst = false;\n }\n\n if (tableContext) {\n if (firstTableContext) {\n const { table, colIndex, rowIndex } = firstTableContext;\n\n // Merge table format\n if (\n tableContext.table == table &&\n (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)\n ) {\n formatState.canMergeTableCell = true;\n formatState.isMultilineSelection = true;\n }\n } else {\n // Table formats\n retrieveTableFormat(tableContext, formatState);\n firstTableContext = tableContext;\n }\n }\n\n // TODO: Support Code block in format state for Content Model\n },\n {\n includeListFormatHolder: 'never',\n }\n );\n\n if (formatState.fontSize) {\n formatState.fontSize = px2Pt(formatState.fontSize);\n }\n}\n\nfunction retrieveSegmentFormat(\n result: ContentModelFormatState,\n isFirst: boolean,\n mergedFormat: ContentModelSegmentFormat\n) {\n const superOrSubscript = mergedFormat.superOrSubScriptSequence?.split(' ')?.pop();\n\n mergeValue(result, 'isBold', isBold(mergedFormat.fontWeight), isFirst);\n mergeValue(result, 'isItalic', mergedFormat.italic, isFirst);\n mergeValue(result, 'isUnderline', mergedFormat.underline, isFirst);\n mergeValue(result, 'isStrikeThrough', mergedFormat.strikethrough, isFirst);\n mergeValue(result, 'isSuperscript', superOrSubscript == 'super', isFirst);\n mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst);\n mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst);\n\n mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst);\n mergeValue(\n result,\n 'fontSize',\n mergedFormat.fontSize,\n isFirst,\n val => parseValueWithUnit(val, undefined, 'pt') + 'pt'\n );\n mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst);\n mergeValue(result, 'textColor', mergedFormat.textColor, isFirst);\n mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst);\n\n //TODO: handle block owning segments with different line-heights\n mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst);\n}\n\nfunction retrieveParagraphFormat(\n result: ContentModelFormatState,\n paragraph: ContentModelParagraph,\n isFirst: boolean\n) {\n const headingLevel = parseInt((paragraph.decorator?.tagName || '').substring(1));\n const validHeadingLevel = headingLevel >= 1 && headingLevel <= 6 ? headingLevel : undefined;\n\n mergeValue(result, 'marginBottom', paragraph.format.marginBottom, isFirst);\n mergeValue(result, 'marginTop', paragraph.format.marginTop, isFirst);\n mergeValue(result, 'headingLevel', validHeadingLevel, isFirst);\n mergeValue(result, 'textAlign', paragraph.format.textAlign, isFirst);\n mergeValue(result, 'direction', paragraph.format.direction, isFirst);\n}\n\nfunction retrieveStructureFormat(\n result: ContentModelFormatState,\n path: ContentModelBlockGroup[],\n isFirst: boolean\n) {\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], []);\n const containerIndex = getClosestAncestorBlockGroupIndex(path, ['FormatContainer'], []);\n\n if (listItemIndex >= 0) {\n const listItem = path[listItemIndex] as ContentModelListItem;\n const listType = listItem?.levels[listItem.levels.length - 1]?.listType;\n\n mergeValue(result, 'isBullet', listType == 'UL', isFirst);\n mergeValue(result, 'isNumbering', listType == 'OL', isFirst);\n }\n\n mergeValue(\n result,\n 'isBlockQuote',\n containerIndex >= 0 &&\n (path[containerIndex] as ContentModelFormatContainer)?.tagName == 'blockquote',\n isFirst\n );\n}\n\nfunction retrieveTableFormat(tableContext: TableSelectionContext, result: ContentModelFormatState) {\n const tableFormat = updateTableMetadata(tableContext.table);\n\n result.isInTable = true;\n result.tableHasHeader = tableContext.table.rows.some(row =>\n row.cells.some(cell => cell.isHeader)\n );\n\n if (tableFormat) {\n result.tableFormat = tableFormat;\n }\n}\n\nfunction retrieveImageFormat(image: ContentModelImage, result: ContentModelFormatState) {\n const { format } = image;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n result.imageFormat = {\n borderColor,\n borderWidth,\n borderStyle,\n boxShadow: format.boxShadow,\n borderRadius: format.borderRadius,\n };\n}\n\nfunction mergeValue<K extends keyof ContentModelFormatState>(\n format: ContentModelFormatState,\n key: K,\n newValue: ContentModelFormatState[K] | undefined,\n isFirst: boolean,\n parseFn: (val: ContentModelFormatState[K]) => ContentModelFormatState[K] = val => val\n) {\n if (isFirst) {\n if (newValue !== undefined) {\n format[key] = newValue;\n }\n } else if (parseFn(newValue) !== parseFn(format[key])) {\n delete format[key];\n }\n}\n\nfunction px2Pt(px: string) {\n if (px && px.indexOf('px') == px.length - 2) {\n // Edge may not handle the floating computing well which causes the calculated value is a little less than actual value\n // So add 0.05 to fix it\n return Math.round(parseFloat(px) * 75 + 0.05) / 100 + 'pt';\n }\n return px;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/retrieveModelFormatState.ts"],"names":[],"mappings":";;;;IAqBA;;OAEG;IACH,SAAgB,wBAAwB,CACpC,KAA2B,EAC3B,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AG,CAAC,CAAC,EAAE;YACnD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;SACtB;IACL,CAAC;IAED,SAAS,KAAK,CAAC,EAAU;QACrB,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;YACzC,uHAAuH;YACvH,wBAAwB;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;SAC9D;QACD,OAAO,EAAE,CAAC;IACd,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getClosestAncestorBlockGroupIndex,\n isBold,\n iterateSelections,\n updateTableMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n ContentModelFormatState,\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelImage,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function retrieveModelFormatState(\n model: ContentModelDocument,\n pendingFormat: ContentModelSegmentFormat | null,\n formatState: ContentModelFormatState\n) {\n let firstTableContext: TableSelectionContext | undefined;\n let firstBlock: ContentModelBlock | undefined;\n let isFirst = true;\n let isFirstImage = true;\n let isFirstSegment = true;\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n // Structure formats\n retrieveStructureFormat(formatState, path, isFirst);\n\n // Multiple line format\n if (block) {\n if (firstBlock) {\n formatState.isMultilineSelection = true;\n } else {\n firstBlock = block;\n }\n }\n\n if (block?.blockType == 'Paragraph') {\n // Paragraph formats\n retrieveParagraphFormat(formatState, block, isFirst);\n\n // Segment formats\n segments?.forEach(segment => {\n if (isFirstSegment || segment.segmentType != 'SelectionMarker') {\n const modelFormat = Object.assign({}, model.format);\n delete modelFormat?.italic;\n delete modelFormat?.underline;\n delete modelFormat?.fontWeight;\n\n retrieveSegmentFormat(\n formatState,\n isFirst,\n Object.assign(\n {},\n modelFormat,\n block.format,\n block.decorator?.format,\n segment.format,\n segment.code?.format,\n segment.link?.format,\n pendingFormat\n )\n );\n\n mergeValue(formatState, 'isCodeInline', !!segment?.code, isFirst);\n }\n\n // We only care the format of selection marker when it is the first selected segment. This is because when selection marker\n // is after some other selected segments, it mostly like appears at the beginning of a seconde line when the whole first line\n // is selected (e.g. triple-click on a line) then the second selection marker doesn't contain a correct format, so we need to\n // ignore it\n isFirstSegment = false;\n\n formatState.canUnlink = formatState.canUnlink || !!segment.link;\n formatState.canAddImageAltText =\n formatState.canAddImageAltText ||\n segments.some(segment => segment.segmentType == 'Image');\n\n isFirst = false;\n\n if (segment.segmentType === 'Image') {\n if (isFirstImage) {\n retrieveImageFormat(segment, formatState);\n isFirstImage = false;\n } else {\n formatState.imageFormat = undefined;\n }\n }\n });\n\n isFirst = false;\n }\n\n if (tableContext) {\n if (firstTableContext) {\n const { table, colIndex, rowIndex } = firstTableContext;\n\n // Merge table format\n if (\n tableContext.table == table &&\n (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)\n ) {\n formatState.canMergeTableCell = true;\n formatState.isMultilineSelection = true;\n }\n } else {\n // Table formats\n retrieveTableFormat(tableContext, formatState);\n firstTableContext = tableContext;\n }\n }\n },\n {\n includeListFormatHolder: 'never',\n }\n );\n\n if (formatState.fontSize) {\n formatState.fontSize = px2Pt(formatState.fontSize);\n }\n}\n\nfunction retrieveSegmentFormat(\n result: ContentModelFormatState,\n isFirst: boolean,\n mergedFormat: ContentModelSegmentFormat\n) {\n const superOrSubscript = mergedFormat.superOrSubScriptSequence?.split(' ')?.pop();\n\n mergeValue(result, 'isBold', isBold(mergedFormat.fontWeight), isFirst);\n mergeValue(result, 'isItalic', mergedFormat.italic, isFirst);\n mergeValue(result, 'isUnderline', mergedFormat.underline, isFirst);\n mergeValue(result, 'isStrikeThrough', mergedFormat.strikethrough, isFirst);\n mergeValue(result, 'isSuperscript', superOrSubscript == 'super', isFirst);\n mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst);\n mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst);\n\n mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst);\n mergeValue(\n result,\n 'fontSize',\n mergedFormat.fontSize,\n isFirst,\n val => parseValueWithUnit(val, undefined, 'pt') + 'pt'\n );\n mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst);\n mergeValue(result, 'textColor', mergedFormat.textColor, isFirst);\n mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst);\n mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst);\n}\n\nfunction retrieveParagraphFormat(\n result: ContentModelFormatState,\n paragraph: ContentModelParagraph,\n isFirst: boolean\n) {\n const headingLevel = parseInt((paragraph.decorator?.tagName || '').substring(1));\n const validHeadingLevel = headingLevel >= 1 && headingLevel <= 6 ? headingLevel : undefined;\n\n mergeValue(result, 'marginBottom', paragraph.format.marginBottom, isFirst);\n mergeValue(result, 'marginTop', paragraph.format.marginTop, isFirst);\n mergeValue(result, 'headingLevel', validHeadingLevel, isFirst);\n mergeValue(result, 'textAlign', paragraph.format.textAlign, isFirst);\n mergeValue(result, 'direction', paragraph.format.direction, isFirst);\n}\n\nfunction retrieveStructureFormat(\n result: ContentModelFormatState,\n path: ContentModelBlockGroup[],\n isFirst: boolean\n) {\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], []);\n const containerIndex = getClosestAncestorBlockGroupIndex(path, ['FormatContainer'], []);\n\n if (listItemIndex >= 0) {\n const listItem = path[listItemIndex] as ContentModelListItem;\n const listType = listItem?.levels[listItem.levels.length - 1]?.listType;\n\n mergeValue(result, 'isBullet', listType == 'UL', isFirst);\n mergeValue(result, 'isNumbering', listType == 'OL', isFirst);\n }\n\n mergeValue(\n result,\n 'isBlockQuote',\n containerIndex >= 0 &&\n (path[containerIndex] as ContentModelFormatContainer)?.tagName == 'blockquote',\n isFirst\n );\n}\n\nfunction retrieveTableFormat(tableContext: TableSelectionContext, result: ContentModelFormatState) {\n const tableFormat = updateTableMetadata(tableContext.table);\n\n result.isInTable = true;\n result.tableHasHeader = tableContext.table.rows.some(row =>\n row.cells.some(cell => cell.isHeader)\n );\n\n if (tableFormat) {\n result.tableFormat = tableFormat;\n }\n}\n\nfunction retrieveImageFormat(image: ContentModelImage, result: ContentModelFormatState) {\n const { format } = image;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n result.imageFormat = {\n borderColor,\n borderWidth,\n borderStyle,\n boxShadow: format.boxShadow,\n borderRadius: format.borderRadius,\n };\n}\n\nfunction mergeValue<K extends keyof ContentModelFormatState>(\n format: ContentModelFormatState,\n key: K,\n newValue: ContentModelFormatState[K] | undefined,\n isFirst: boolean,\n parseFn: (val: ContentModelFormatState[K]) => ContentModelFormatState[K] = val => val\n) {\n if (isFirst) {\n if (newValue !== undefined) {\n format[key] = newValue;\n }\n } else if (parseFn(newValue) !== parseFn(format[key])) {\n delete format[key];\n }\n}\n\nfunction px2Pt(px: string) {\n if (px && px.indexOf('px') == px.length - 2) {\n // Edge may not handle the floating computing well which causes the calculated value is a little less than actual value\n // So add 0.05 to fix it\n return Math.round(parseFloat(px) * 75 + 0.05) / 100 + 'pt';\n }\n return px;\n}\n"]}
|
|
@@ -9,8 +9,8 @@ export interface WrapBlockStep1Result<T extends ContentModelBlockGroup & Content
|
|
|
9
9
|
/**
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export declare function wrapBlockStep1<T extends ContentModelBlockGroup & ContentModelBlock>(step1Result: WrapBlockStep1Result<T>[], parent: ContentModelBlockGroup | null, blockToWrap: ContentModelBlock, creator: () => T, canMerge: (target: ContentModelBlock) => target is T): void;
|
|
12
|
+
export declare function wrapBlockStep1<T extends ContentModelBlockGroup & ContentModelBlock>(step1Result: WrapBlockStep1Result<T>[], parent: ContentModelBlockGroup | null, blockToWrap: ContentModelBlock, creator: (isRtl: boolean) => T, canMerge: (isRtl: boolean, target: ContentModelBlock) => target is T): void;
|
|
13
13
|
/**
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
export declare function wrapBlockStep2<T extends ContentModelBlockGroup & ContentModelBlock>(step1Result: WrapBlockStep1Result<T>[], canMerge: (target: ContentModelBlock, current: T) => target is T): void;
|
|
16
|
+
export declare function wrapBlockStep2<T extends ContentModelBlockGroup & ContentModelBlock>(step1Result: WrapBlockStep1Result<T>[], canMerge: (isRtl: boolean, target: ContentModelBlock, current: T) => target is T): void;
|
|
@@ -11,7 +11,10 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
11
11
|
if (parent && index >= 0) {
|
|
12
12
|
parent.blocks.splice(index, 1);
|
|
13
13
|
var prevBlock = parent.blocks[index - 1];
|
|
14
|
-
var
|
|
14
|
+
var isRtl = blockToWrap.format.direction == 'rtl';
|
|
15
|
+
var wrapper = canMerge(isRtl, prevBlock)
|
|
16
|
+
? prevBlock
|
|
17
|
+
: createAndAdd(parent, index, creator, isRtl);
|
|
15
18
|
(0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(blockToWrap);
|
|
16
19
|
(0, roosterjs_content_model_dom_1.addBlock)(wrapper, blockToWrap);
|
|
17
20
|
// Use reverse order, so that we can merge from last to first to avoid modifying unmerged quotes
|
|
@@ -28,7 +31,8 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
28
31
|
var parent = _a.parent, wrapper = _a.wrapper;
|
|
29
32
|
var index = parent.blocks.indexOf(wrapper);
|
|
30
33
|
var nextBlock = parent.blocks[index + 1];
|
|
31
|
-
|
|
34
|
+
var isRtl = wrapper.format.direction == 'rtl';
|
|
35
|
+
if (index >= 0 && canMerge(isRtl, nextBlock, wrapper)) {
|
|
32
36
|
wrapper.blocks.forEach(roosterjs_content_model_dom_1.setParagraphNotImplicit);
|
|
33
37
|
(_b = wrapper.blocks).push.apply(_b, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(nextBlock.blocks), false));
|
|
34
38
|
parent.blocks.splice(index + 1, 1);
|
|
@@ -36,8 +40,8 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
exports.wrapBlockStep2 = wrapBlockStep2;
|
|
39
|
-
function createAndAdd(parent, index, creator) {
|
|
40
|
-
var block = creator();
|
|
43
|
+
function createAndAdd(parent, index, creator, isRtl) {
|
|
44
|
+
var block = creator(isRtl);
|
|
41
45
|
parent.blocks.splice(index, 0, block);
|
|
42
46
|
return block;
|
|
43
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/wrapBlock.ts"],"names":[],"mappings":";;;;IAWA;;OAEG;IACH,SAAgB,cAAc,CAC1B,WAAsC,EACtC,MAAqC,EACrC,WAA8B,EAC9B,
|
|
1
|
+
{"version":3,"file":"wrapBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/wrapBlock.ts"],"names":[],"mappings":";;;;IAWA;;OAEG;IACH,SAAgB,cAAc,CAC1B,WAAsC,EACtC,MAAqC,EACrC,WAA8B,EAC9B,OAA8B,EAC9B,QAAoE;;QAEpE,IAAM,KAAK,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,mCAAI,CAAC,CAAC,CAAC;QAExD,IAAI,MAAM,IAAI,KAAK,IAAI,CAAC,EAAE;YACtB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAE/B,IA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,CAAC,CAAC,CAAC;aACtC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAfD,wCAeC;IAED,SAAS,YAAY,CACjB,MAA8B,EAC9B,KAAa,EACb,OAA8B,EAC9B,KAAc;QAEd,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAE7B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC;IACjB,CAAC","sourcesContent":["import { addBlock, setParagraphNotImplicit } from 'roosterjs-content-model-dom';\nimport type { ContentModelBlock, ContentModelBlockGroup } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport interface WrapBlockStep1Result<T extends ContentModelBlockGroup & ContentModelBlock> {\n parent: ContentModelBlockGroup;\n wrapper: T;\n}\n\n/**\n * @internal\n */\nexport function wrapBlockStep1<T extends ContentModelBlockGroup & ContentModelBlock>(\n step1Result: WrapBlockStep1Result<T>[],\n parent: ContentModelBlockGroup | null,\n blockToWrap: ContentModelBlock,\n creator: (isRtl: boolean) => T,\n canMerge: (isRtl: boolean, target: ContentModelBlock) => target is T\n) {\n const index = parent?.blocks.indexOf(blockToWrap) ?? -1;\n\n if (parent && index >= 0) {\n parent.blocks.splice(index, 1);\n\n const prevBlock: ContentModelBlock = parent.blocks[index - 1];\n const isRtl = blockToWrap.format.direction == 'rtl';\n const wrapper = canMerge(isRtl, prevBlock)\n ? prevBlock\n : createAndAdd(parent, index, creator, isRtl);\n\n setParagraphNotImplicit(blockToWrap);\n addBlock(wrapper, blockToWrap);\n\n // Use reverse order, so that we can merge from last to first to avoid modifying unmerged quotes\n step1Result.unshift({ parent, wrapper });\n }\n}\n\n/**\n * @internal\n */\nexport function wrapBlockStep2<T extends ContentModelBlockGroup & ContentModelBlock>(\n step1Result: WrapBlockStep1Result<T>[],\n canMerge: (isRtl: boolean, target: ContentModelBlock, current: T) => target is T\n) {\n step1Result.forEach(({ parent, wrapper }) => {\n const index = parent.blocks.indexOf(wrapper);\n const nextBlock = parent.blocks[index + 1];\n const isRtl = wrapper.format.direction == 'rtl';\n\n if (index >= 0 && canMerge(isRtl, nextBlock, wrapper)) {\n wrapper.blocks.forEach(setParagraphNotImplicit);\n wrapper.blocks.push(...nextBlock.blocks);\n parent.blocks.splice(index + 1, 1);\n }\n });\n}\n\nfunction createAndAdd<T extends ContentModelBlockGroup & ContentModelBlock>(\n parent: ContentModelBlockGroup,\n index: number,\n creator: (isRtl: boolean) => T,\n isRtl: boolean\n): T {\n const block = creator(isRtl);\n\n parent.blocks.splice(index, 0, block);\n return block;\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export interface LinkData {
|
|
5
|
+
/**
|
|
6
|
+
* Schema of a hyperlink
|
|
7
|
+
*/
|
|
8
|
+
scheme: string;
|
|
9
|
+
/**
|
|
10
|
+
* Original url of a hyperlink
|
|
11
|
+
*/
|
|
12
|
+
originalUrl: string;
|
|
13
|
+
/**
|
|
14
|
+
* Normalized url of a hyperlink
|
|
15
|
+
*/
|
|
16
|
+
normalizedUrl: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* Try to match a given string with link match rules, return matched link
|
|
21
|
+
* @param url Input url to match
|
|
22
|
+
* @param option Link match option, exact or partial. If it is exact match, we need
|
|
23
|
+
* to check the length of matched link and url
|
|
24
|
+
* @param rules Optional link match rules, if not passed, only the default link match
|
|
25
|
+
* rules will be applied
|
|
26
|
+
* @returns The matched link data, or null if no match found.
|
|
27
|
+
* The link data includes an original url and a normalized url
|
|
28
|
+
*/
|
|
29
|
+
export declare function matchLink(url: string): LinkData | null;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.matchLink = void 0;
|
|
5
|
+
// http exclude matching regex
|
|
6
|
+
// invalid URL example (in particular on IE and Edge):
|
|
7
|
+
// - http://www.bing.com%00, %00 before ? (question mark) is considered invalid. IE/Edge throws invalid argument exception
|
|
8
|
+
// - http://www.bing.com%1, %1 is invalid
|
|
9
|
+
// - http://www.bing.com%g, %g is invalid (IE and Edge expects a two hex value after a %)
|
|
10
|
+
// - http://www.bing.com%, % as ending is invalid (IE and Edge expects a two hex value after a %)
|
|
11
|
+
// All above % cases if they're after ? (question mark) is then considered valid again
|
|
12
|
+
// Similar for @, it needs to be after / (forward slash), or ? (question mark). Otherwise IE/Edge will throw security exception
|
|
13
|
+
// - http://www.bing.com@name, @name before ? (question mark) is considered invalid
|
|
14
|
+
// - http://www.bing.com/@name, is valid sine it is after / (forward slash)
|
|
15
|
+
// - http://www.bing.com?@name, is also valid since it is after ? (question mark)
|
|
16
|
+
// The regex below is essentially a break down of:
|
|
17
|
+
// ^[^?]+%[^0-9a-f]+ => to exclude URL like www.bing.com%%
|
|
18
|
+
// ^[^?]+%[0-9a-f][^0-9a-f]+ => to exclude URL like www.bing.com%1
|
|
19
|
+
// ^[^?]+%00 => to exclude URL like www.bing.com%00
|
|
20
|
+
// ^[^?]+%$ => to exclude URL like www.bing.com%
|
|
21
|
+
// ^https?:\/\/[^?\/]+@ => to exclude URL like http://www.bing.com@name
|
|
22
|
+
// ^www\.[^?\/]+@ => to exclude URL like www.bing.com@name
|
|
23
|
+
// , => to exclude url like www.bing,,com
|
|
24
|
+
var httpExcludeRegEx = /^[^?]+%[^0-9a-f]+|^[^?]+%[0-9a-f][^0-9a-f]+|^[^?]+%00|^[^?]+%$|^https?:\/\/[^?\/]+@|^www\.[^?\/]+@/i;
|
|
25
|
+
// via https://tools.ietf.org/html/rfc1035 Page 7
|
|
26
|
+
var labelRegEx = '[a-z0-9](?:[a-z0-9-]*[a-z0-9])?'; // We're using case insensitive regexps below so don't bother including A-Z
|
|
27
|
+
var domainNameRegEx = "(?:" + labelRegEx + "\\.)*" + labelRegEx;
|
|
28
|
+
var domainPortRegEx = domainNameRegEx + "(?:\\:[0-9]+)?";
|
|
29
|
+
var domainPortWithUrlRegEx = domainPortRegEx + "(?:[\\/\\?]\\S*)?";
|
|
30
|
+
var linkMatchRules = {
|
|
31
|
+
http: {
|
|
32
|
+
match: new RegExp("^(?:microsoft-edge:)?http:\\/\\/" + domainPortWithUrlRegEx + "|www\\." + domainPortWithUrlRegEx, 'i'),
|
|
33
|
+
except: httpExcludeRegEx,
|
|
34
|
+
normalizeUrl: function (url) {
|
|
35
|
+
return new RegExp('^(?:microsoft-edge:)?http:\\/\\/', 'i').test(url) ? url : 'http://' + url;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
https: {
|
|
39
|
+
match: new RegExp("^(?:microsoft-edge:)?https:\\/\\/" + domainPortWithUrlRegEx, 'i'),
|
|
40
|
+
except: httpExcludeRegEx,
|
|
41
|
+
},
|
|
42
|
+
mailto: { match: new RegExp('^mailto:\\S+@\\S+\\.\\S+', 'i') },
|
|
43
|
+
notes: { match: new RegExp('^notes:\\/\\/\\S+', 'i') },
|
|
44
|
+
file: { match: new RegExp('^file:\\/\\/\\/?\\S+', 'i') },
|
|
45
|
+
unc: { match: new RegExp('^\\\\\\\\\\S+', 'i') },
|
|
46
|
+
ftp: {
|
|
47
|
+
match: new RegExp("^ftp:\\/\\/" + domainPortWithUrlRegEx + "|ftp\\." + domainPortWithUrlRegEx, 'i'),
|
|
48
|
+
normalizeUrl: function (url) { return (new RegExp('^ftp:\\/\\/', 'i').test(url) ? url : 'ftp://' + url); },
|
|
49
|
+
},
|
|
50
|
+
news: { match: new RegExp("^news:(\\/\\/)?" + domainPortWithUrlRegEx, 'i') },
|
|
51
|
+
telnet: { match: new RegExp("^telnet:(\\/\\/)?" + domainPortWithUrlRegEx, 'i') },
|
|
52
|
+
gopher: { match: new RegExp("^gopher:\\/\\/" + domainPortWithUrlRegEx, 'i') },
|
|
53
|
+
wais: { match: new RegExp("^wais:(\\/\\/)?" + domainPortWithUrlRegEx, 'i') },
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* Try to match a given string with link match rules, return matched link
|
|
58
|
+
* @param url Input url to match
|
|
59
|
+
* @param option Link match option, exact or partial. If it is exact match, we need
|
|
60
|
+
* to check the length of matched link and url
|
|
61
|
+
* @param rules Optional link match rules, if not passed, only the default link match
|
|
62
|
+
* rules will be applied
|
|
63
|
+
* @returns The matched link data, or null if no match found.
|
|
64
|
+
* The link data includes an original url and a normalized url
|
|
65
|
+
*/
|
|
66
|
+
function matchLink(url) {
|
|
67
|
+
var e_1, _a;
|
|
68
|
+
if (url) {
|
|
69
|
+
try {
|
|
70
|
+
for (var _b = (0, tslib_1.__values)((0, roosterjs_content_model_dom_1.getObjectKeys)(linkMatchRules)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
71
|
+
var schema = _c.value;
|
|
72
|
+
var rule = linkMatchRules[schema];
|
|
73
|
+
var matches = url.match(rule.match);
|
|
74
|
+
if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {
|
|
75
|
+
return {
|
|
76
|
+
scheme: schema,
|
|
77
|
+
originalUrl: url,
|
|
78
|
+
normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
84
|
+
finally {
|
|
85
|
+
try {
|
|
86
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
87
|
+
}
|
|
88
|
+
finally { if (e_1) throw e_1.error; }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
exports.matchLink = matchLink;
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=matchLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchLink.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/link/matchLink.ts"],"names":[],"mappings":";;;;IA4BA,8BAA8B;IAC9B,sDAAsD;IACtD,0HAA0H;IAC1H,yCAAyC;IACzC,yFAAyF;IACzF,iGAAiG;IACjG,sFAAsF;IACtF,+HAA+H;IAC/H,mFAAmF;IACnF,2EAA2E;IAC3E,iFAAiF;IACjF,kDAAkD;IAClD,0DAA0D;IAC1D,kEAAkE;IAClE,mDAAmD;IACnD,gDAAgD;IAChD,uEAAuE;IACvE,0DAA0D;IAC1D,yCAAyC;IACzC,IAAM,gBAAgB,GAAG,qGAAqG,CAAC;IAE/H,iDAAiD;IACjD,IAAM,UAAU,GAAG,iCAAiC,CAAC,CAAC,2EAA2E;IACjI,IAAM,eAAe,GAAG,QAAM,UAAU,aAAQ,UAAY,CAAC;IAC7D,IAAM,eAAe,GAAM,eAAe,mBAAgB,CAAC;IAC3D,IAAM,sBAAsB,GAAM,eAAe,sBAAmB,CAAC;IAErE,IAAM,cAAc,GAAkC;QAClD,IAAI,EAAE;YACF,KAAK,EAAE,IAAI,MAAM,CACb,qCAAmC,sBAAsB,eAAU,sBAAwB,EAC3F,GAAG,CACN;YACD,MAAM,EAAE,gBAAgB;YACxB,YAAY,EAAE,UAAA,GAAG;gBACb,OAAA,IAAI,MAAM,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;YAArF,CAAqF;SAC5F;QACD,KAAK,EAAE;YACH,KAAK,EAAE,IAAI,MAAM,CAAC,sCAAoC,sBAAwB,EAAE,GAAG,CAAC;YACpF,MAAM,EAAE,gBAAgB;SAC3B;QACD,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,0BAA0B,EAAE,GAAG,CAAC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AG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACtC,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;wBAC1E,OAAO;4BACH,MAAM,EAAE,MAAM;4BACd,WAAW,EAAE,GAAG;4BAChB,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;yBAClE,CAAC;qBACL;iBACJ;;;;;;;;;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAhBD,8BAgBC","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\n\n/**\n * @internal\n */\nexport interface LinkData {\n /**\n * Schema of a hyperlink\n */\n scheme: string;\n\n /**\n * Original url of a hyperlink\n */\n originalUrl: string;\n\n /**\n * Normalized url of a hyperlink\n */\n normalizedUrl: string;\n}\n\ninterface LinkMatchRule {\n match: RegExp;\n except?: RegExp;\n normalizeUrl?: (url: string) => string;\n}\n\n// http exclude matching regex\n// invalid URL example (in particular on IE and Edge):\n// - http://www.bing.com%00, %00 before ? (question mark) is considered invalid. IE/Edge throws invalid argument exception\n// - http://www.bing.com%1, %1 is invalid\n// - http://www.bing.com%g, %g is invalid (IE and Edge expects a two hex value after a %)\n// - http://www.bing.com%, % as ending is invalid (IE and Edge expects a two hex value after a %)\n// All above % cases if they're after ? (question mark) is then considered valid again\n// Similar for @, it needs to be after / (forward slash), or ? (question mark). Otherwise IE/Edge will throw security exception\n// - http://www.bing.com@name, @name before ? (question mark) is considered invalid\n// - http://www.bing.com/@name, is valid sine it is after / (forward slash)\n// - http://www.bing.com?@name, is also valid since it is after ? (question mark)\n// The regex below is essentially a break down of:\n// ^[^?]+%[^0-9a-f]+ => to exclude URL like www.bing.com%%\n// ^[^?]+%[0-9a-f][^0-9a-f]+ => to exclude URL like www.bing.com%1\n// ^[^?]+%00 => to exclude URL like www.bing.com%00\n// ^[^?]+%$ => to exclude URL like www.bing.com%\n// ^https?:\\/\\/[^?\\/]+@ => to exclude URL like http://www.bing.com@name\n// ^www\\.[^?\\/]+@ => to exclude URL like www.bing.com@name\n// , => to exclude url like www.bing,,com\nconst httpExcludeRegEx = /^[^?]+%[^0-9a-f]+|^[^?]+%[0-9a-f][^0-9a-f]+|^[^?]+%00|^[^?]+%$|^https?:\\/\\/[^?\\/]+@|^www\\.[^?\\/]+@/i;\n\n// via https://tools.ietf.org/html/rfc1035 Page 7\nconst labelRegEx = '[a-z0-9](?:[a-z0-9-]*[a-z0-9])?'; // We're using case insensitive regexps below so don't bother including A-Z\nconst domainNameRegEx = `(?:${labelRegEx}\\\\.)*${labelRegEx}`;\nconst domainPortRegEx = `${domainNameRegEx}(?:\\\\:[0-9]+)?`;\nconst domainPortWithUrlRegEx = `${domainPortRegEx}(?:[\\\\/\\\\?]\\\\S*)?`;\n\nconst linkMatchRules: Record<string, LinkMatchRule> = {\n http: {\n match: new RegExp(\n `^(?:microsoft-edge:)?http:\\\\/\\\\/${domainPortWithUrlRegEx}|www\\\\.${domainPortWithUrlRegEx}`,\n 'i'\n ),\n except: httpExcludeRegEx,\n normalizeUrl: url =>\n new RegExp('^(?:microsoft-edge:)?http:\\\\/\\\\/', 'i').test(url) ? url : 'http://' + url,\n },\n https: {\n match: new RegExp(`^(?:microsoft-edge:)?https:\\\\/\\\\/${domainPortWithUrlRegEx}`, 'i'),\n except: httpExcludeRegEx,\n },\n mailto: { match: new RegExp('^mailto:\\\\S+@\\\\S+\\\\.\\\\S+', 'i') },\n notes: { match: new RegExp('^notes:\\\\/\\\\/\\\\S+', 'i') },\n file: { match: new RegExp('^file:\\\\/\\\\/\\\\/?\\\\S+', 'i') },\n unc: { match: new RegExp('^\\\\\\\\\\\\\\\\\\\\S+', 'i') },\n ftp: {\n match: new RegExp(\n `^ftp:\\\\/\\\\/${domainPortWithUrlRegEx}|ftp\\\\.${domainPortWithUrlRegEx}`,\n 'i'\n ),\n normalizeUrl: url => (new RegExp('^ftp:\\\\/\\\\/', 'i').test(url) ? url : 'ftp://' + url),\n },\n news: { match: new RegExp(`^news:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n telnet: { match: new RegExp(`^telnet:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n gopher: { match: new RegExp(`^gopher:\\\\/\\\\/${domainPortWithUrlRegEx}`, 'i') },\n wais: { match: new RegExp(`^wais:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n};\n\n/**\n * @internal\n * Try to match a given string with link match rules, return matched link\n * @param url Input url to match\n * @param option Link match option, exact or partial. If it is exact match, we need\n * to check the length of matched link and url\n * @param rules Optional link match rules, if not passed, only the default link match\n * rules will be applied\n * @returns The matched link data, or null if no match found.\n * The link data includes an original url and a normalized url\n */\nexport function matchLink(url: string): LinkData | null {\n if (url) {\n for (const schema of getObjectKeys(linkMatchRules)) {\n const rule = linkMatchRules[schema];\n const matches = url.match(rule.match);\n if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {\n return {\n scheme: schema,\n originalUrl: url,\n normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,\n };\n }\n }\n }\n\n return null;\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ContentModelDocument } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Set a list type to content model
|
|
4
|
+
* @param model the model document
|
|
5
|
+
* @param listType the list type OL | UL
|
|
4
6
|
*/
|
|
5
7
|
export declare function setListType(model: ContentModelDocument, listType: 'OL' | 'UL'): boolean;
|
|
@@ -3,7 +3,9 @@ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.setListType = void 0;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Set a list type to content model
|
|
7
|
+
* @param model the model document
|
|
8
|
+
* @param listType the list type OL | UL
|
|
7
9
|
*/
|
|
8
10
|
function setListType(model, listType) {
|
|
9
11
|
var paragraphOrListItems = (0, roosterjs_content_model_core_1.getOperationalBlocks)(model, ['ListItem'], [] // Set stop types to be empty so we can find list items even cross the boundary of table, then we can always operation on the list item if any
|
|
@@ -16,7 +18,6 @@ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content
|
|
|
16
18
|
: shouldIgnoreBlock(block);
|
|
17
19
|
});
|
|
18
20
|
var existingListItems = [];
|
|
19
|
-
var hasIgnoredParagraphBefore = false;
|
|
20
21
|
paragraphOrListItems.forEach(function (_a, itemIndex) {
|
|
21
22
|
var _b, _c;
|
|
22
23
|
var block = _a.block, parent = _a.parent;
|
|
@@ -60,9 +61,8 @@ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content
|
|
|
60
61
|
: 1,
|
|
61
62
|
direction: block.format.direction,
|
|
62
63
|
textAlign: block.format.textAlign,
|
|
63
|
-
marginTop:
|
|
64
|
-
|
|
65
|
-
marginBlockStart: '0px',
|
|
64
|
+
marginTop: '0px',
|
|
65
|
+
marginBottom: '0px',
|
|
66
66
|
}),
|
|
67
67
|
],
|
|
68
68
|
// For list bullet, we only want to carry over these formats from segments:
|
|
@@ -71,8 +71,6 @@ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content
|
|
|
71
71
|
fontSize: segmentFormat.fontSize,
|
|
72
72
|
textColor: segmentFormat.textColor,
|
|
73
73
|
});
|
|
74
|
-
// Since there is only one paragraph under the list item, no need to keep its paragraph element (DIV).
|
|
75
|
-
// TODO: Do we need to keep the CSS styles applied to original DIV?
|
|
76
74
|
if (block.blockType == 'Paragraph') {
|
|
77
75
|
block.isImplicit = true;
|
|
78
76
|
}
|
|
@@ -92,8 +90,7 @@ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content
|
|
|
92
90
|
existingListItems.push(newListItem);
|
|
93
91
|
}
|
|
94
92
|
else {
|
|
95
|
-
|
|
96
|
-
existingListItems.forEach(function (x) { return (x.levels[0].format.marginBottom = '0'); });
|
|
93
|
+
existingListItems.forEach(function (x) { return (x.levels[0].format.marginBottom = '0px'); });
|
|
97
94
|
existingListItems = [];
|
|
98
95
|
}
|
|
99
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":";;;;IAaA
|
|
1
|
+
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":";;;;IAaA;;;;OAIG;IACH,SAAgB,WAAW,CAAC,KAA2B,EAAE,QAAqB;QAC1E,IAAM,oBAAoB,GAAG,IAAA,mDAAoB,EAC7C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,EAAE,CAAC,8IAA8I;SACpJ,CAAC;QACF,IAAM,qBAAqB,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAC,EAAS;;gBAAP,KAAK,WAAA;YAC7D,OAAA,IAAA,iDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC;gBACvD,CAAC,CAAC,CAAA,MAAA,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,QAAQ,KAAI,QAAQ;gBAC7D,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;SAAA,CACjC,CAAC;QACF,IAAI,iBAAiB,GAA2B,EAAE,CAAC;QAEnD,oBAAoB,CAAC,OAAO,CAAC,UAAC,EAAiB,EAAE,SAAS;;gBAA1B,KAAK,WAAA,EAAE,MAAM,YAAA;YACzC,IAAI,IAAA,iDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,E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EAAE;4BACzB,WAAW,CAAC,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;4BACxD,KAAK,CAAC,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;yBACvC;wBAED,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;4BACxB,WAAW,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;yBACzD;wBAED,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;wBAC5C,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;qBACvC;yBAAM;wBACH,iBAAiB,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC,EAAzC,CAAyC,CAAC,CAAC;wBAC1E,iBAAiB,GAAG,EAAE,CAAC;qBAC1B;iBACJ;aACJ;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;QAE7B,OAAO,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,CAAC;IAxGD,kCAwGC;IAED,SAAS,iBAAiB,CAAC,KAAwB;QAC/C,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,OAAO;gBACR,OAAO,KAAK,CAAC;YACjB,KAAK,WAAW;gBACZ,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CACvB,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAA3D,CAA2D,CACnE,CAAC;YACN;gBACI,OAAO,IAAI,CAAC;SACnB;IACL,CAAC","sourcesContent":["import { getOperationalBlocks, isBlockGroupOfType } from 'roosterjs-content-model-core';\nimport {\n createListItem,\n createListLevel,\n normalizeContentModel,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelDocument,\n ContentModelListItem,\n} from 'roosterjs-content-model-types';\n\n/**\n * Set a list type to content model\n * @param model the model document\n * @param listType the list type OL | UL\n */\nexport function setListType(model: ContentModelDocument, listType: 'OL' | 'UL') {\n const paragraphOrListItems = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n [] // Set stop types to be empty so we can find list items even cross the boundary of table, then we can always operation on the list item if any\n );\n const alreadyInExpectedType = paragraphOrListItems.every(({ block }) =>\n isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')\n ? block.levels[block.levels.length - 1]?.listType == listType\n : shouldIgnoreBlock(block)\n );\n let existingListItems: ContentModelListItem[] = [];\n\n paragraphOrListItems.forEach(({ block, parent }, itemIndex) => {\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const level = block.levels.pop();\n\n if (!alreadyInExpectedType && level) {\n level.listType = listType;\n block.levels.push(level);\n } else if (block.blocks.length == 1) {\n setParagraphNotImplicit(block.blocks[0]);\n }\n\n if (alreadyInExpectedType) {\n //if the list item has margins or textAlign, we need to apply them to the block to preserve the indention and alignment\n block.blocks.forEach(x => {\n if (block.format.marginLeft) {\n x.format.marginLeft = block.format.marginLeft;\n }\n\n if (block.format.marginRight) {\n x.format.marginRight = block.format.marginRight;\n }\n\n if (block.format.textAlign) {\n x.format.textAlign = block.format.textAlign;\n }\n });\n }\n } else {\n const index = parent.blocks.indexOf(block);\n\n if (index >= 0) {\n if (paragraphOrListItems.length == 1 || !shouldIgnoreBlock(block)) {\n const prevBlock = parent.blocks[index - 1];\n const segmentFormat =\n (block.blockType == 'Paragraph' && block.segments[0]?.format) || {};\n const newListItem = createListItem(\n [\n createListLevel(listType, {\n startNumberOverride:\n itemIndex > 0 ||\n (prevBlock?.blockType == 'BlockGroup' &&\n prevBlock.blockGroupType == 'ListItem' &&\n prevBlock.levels[0]?.listType == 'OL')\n ? undefined\n : 1,\n direction: block.format.direction,\n textAlign: block.format.textAlign,\n marginTop: '0px',\n marginBottom: '0px',\n }),\n ],\n // For list bullet, we only want to carry over these formats from segments:\n {\n fontFamily: segmentFormat.fontFamily,\n fontSize: segmentFormat.fontSize,\n textColor: segmentFormat.textColor,\n }\n );\n\n if (block.blockType == 'Paragraph') {\n block.isImplicit = true;\n }\n\n newListItem.blocks.push(block);\n\n if (block.format.marginRight) {\n newListItem.format.marginRight = block.format.marginRight;\n block.format.marginRight = undefined;\n }\n if (block.format.marginLeft) {\n newListItem.format.marginLeft = block.format.marginLeft;\n block.format.marginLeft = undefined;\n }\n\n if (block.format.textAlign) {\n newListItem.format.textAlign = block.format.textAlign;\n }\n\n parent.blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n } else {\n existingListItems.forEach(x => (x.levels[0].format.marginBottom = '0px'));\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ContentModelBlock) {\n switch (block.blockType) {\n case 'Table':\n return false;\n case 'Paragraph':\n return block.segments.every(\n x => x.segmentType == 'Br' || x.segmentType == 'SelectionMarker'\n );\n default:\n return true;\n }\n}\n"]}
|
|
@@ -6,4 +6,4 @@ import type { ContentModelFormatContainerFormat, IStandaloneEditor } from 'roost
|
|
|
6
6
|
* @param editor The editor object to toggle BLOCKQUOTE onto
|
|
7
7
|
* @param quoteFormat @optional Block format for the new quote object
|
|
8
8
|
*/
|
|
9
|
-
export default function toggleBlockQuote(editor: IStandaloneEditor, quoteFormat?: ContentModelFormatContainerFormat): void;
|
|
9
|
+
export default function toggleBlockQuote(editor: IStandaloneEditor, quoteFormat?: ContentModelFormatContainerFormat, quoteFormatRtl?: ContentModelFormatContainerFormat): void;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
define(["require", "exports", "tslib", "../../modelApi/block/toggleModelBlockQuote"], function (require, exports, tslib_1, toggleModelBlockQuote_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
var
|
|
4
|
+
var DefaultQuoteFormatLtr = {
|
|
5
5
|
borderLeft: '3px solid rgb(200, 200, 200)',
|
|
6
6
|
textColor: 'rgb(102, 102, 102)',
|
|
7
7
|
};
|
|
8
|
+
var DefaultQuoteFormatRtl = {
|
|
9
|
+
borderRight: '3px solid rgb(200, 200, 200)',
|
|
10
|
+
textColor: 'rgb(102, 102, 102)',
|
|
11
|
+
};
|
|
8
12
|
var BuildInQuoteFormat = {
|
|
9
13
|
marginTop: '1em',
|
|
10
14
|
marginBottom: '1em',
|
|
11
15
|
marginLeft: '40px',
|
|
12
16
|
marginRight: '40px',
|
|
13
|
-
paddingLeft: '10px',
|
|
14
17
|
};
|
|
15
18
|
/**
|
|
16
19
|
* Toggle BLOCKQUOTE state of selected paragraphs.
|
|
@@ -19,13 +22,14 @@ define(["require", "exports", "tslib", "../../modelApi/block/toggleModelBlockQuo
|
|
|
19
22
|
* @param editor The editor object to toggle BLOCKQUOTE onto
|
|
20
23
|
* @param quoteFormat @optional Block format for the new quote object
|
|
21
24
|
*/
|
|
22
|
-
function toggleBlockQuote(editor, quoteFormat) {
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
+
function toggleBlockQuote(editor, quoteFormat, quoteFormatRtl) {
|
|
26
|
+
var _a;
|
|
27
|
+
var fullQuoteFormatLtr = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, BuildInQuoteFormat), { paddingLeft: '10px' }), (quoteFormat !== null && quoteFormat !== void 0 ? quoteFormat : DefaultQuoteFormatLtr));
|
|
28
|
+
var fullQuoteFormatRtl = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, BuildInQuoteFormat), { paddingRight: '10px', direction: 'rtl' }), ((_a = quoteFormatRtl !== null && quoteFormatRtl !== void 0 ? quoteFormatRtl : quoteFormat) !== null && _a !== void 0 ? _a : DefaultQuoteFormatRtl));
|
|
25
29
|
editor.focus();
|
|
26
30
|
editor.formatContentModel(function (model, context) {
|
|
27
31
|
context.newPendingFormat = 'preserve';
|
|
28
|
-
return (0, toggleModelBlockQuote_1.toggleModelBlockQuote)(model,
|
|
32
|
+
return (0, toggleModelBlockQuote_1.toggleModelBlockQuote)(model, fullQuoteFormatLtr, fullQuoteFormatRtl);
|
|
29
33
|
}, {
|
|
30
34
|
apiName: 'toggleBlockQuote',
|
|
31
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleBlockQuote.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/block/toggleBlockQuote.ts"],"names":[],"mappings":";;;IAMA,IAAM,
|
|
1
|
+
{"version":3,"file":"toggleBlockQuote.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/block/toggleBlockQuote.ts"],"names":[],"mappings":";;;IAMA,IAAM,qBAAqB,GAAsC;QAC7D,UAAU,EAAE,8BAA8B;QAC1C,SAAS,EAAE,oBAAoB;KAClC,CAAC;IACF,IAAM,qBAAqB,GAAsC;QAC7D,WAAW,EAAE,8BAA8B;QAC3C,SAAS,EAAE,oBAAoB;KAClC,CAAC;IACF,IAAM,kBAAkB,GAAsC;QAC1D,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,MAAM;QAClB,WAAW,EAAE,MAAM;KACtB,CAAC;IAEF;;;;;;OAMG;IACH,SAAwB,gBAAgB,CACpC,MAAyB,EACzB,WAA+C,EAC/C,cAAkD;;QAElD,IAAM,kBAAkB,yEACjB,kBAAkB,KACrB,WAAW,EAAE,MAAM,KAChB,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,qBAAqB,CAAC,CAC5C,CAAC;QACF,IAAM,kBAAkB,yEACjB,kBAAkB,KACrB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,KAAK,KACb,CAAC,MAAA,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,WAAW,mCAAI,qBAAqB,CAAC,CAC9D,CAAC;QAEF,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,OAAO,CAAC,gBAAgB,GAAG,UAAU,CAAC;YAEtC,OAAO,IAAA,6CAAqB,EAAC,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;QAChF,CAAC,EACD;YACI,OAAO,EAAE,kBAAkB;SAC9B,CACJ,CAAC;IACN,CAAC;IA7BD,mCA6BC","sourcesContent":["import { toggleModelBlockQuote } from '../../modelApi/block/toggleModelBlockQuote';\nimport type {\n ContentModelFormatContainerFormat,\n IStandaloneEditor,\n} from 'roosterjs-content-model-types';\n\nconst DefaultQuoteFormatLtr: ContentModelFormatContainerFormat = {\n borderLeft: '3px solid rgb(200, 200, 200)',\n textColor: 'rgb(102, 102, 102)',\n};\nconst DefaultQuoteFormatRtl: ContentModelFormatContainerFormat = {\n borderRight: '3px solid rgb(200, 200, 200)',\n textColor: 'rgb(102, 102, 102)',\n};\nconst BuildInQuoteFormat: ContentModelFormatContainerFormat = {\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: '40px',\n marginRight: '40px',\n};\n\n/**\n * Toggle BLOCKQUOTE state of selected paragraphs.\n * If any selected paragraph is not under a BLOCKQUOTE, wrap them into a BLOCKQUOTE.\n * Otherwise, unwrap all related BLOCKQUOTEs.\n * @param editor The editor object to toggle BLOCKQUOTE onto\n * @param quoteFormat @optional Block format for the new quote object\n */\nexport default function toggleBlockQuote(\n editor: IStandaloneEditor,\n quoteFormat?: ContentModelFormatContainerFormat,\n quoteFormatRtl?: ContentModelFormatContainerFormat\n) {\n const fullQuoteFormatLtr: ContentModelFormatContainerFormat = {\n ...BuildInQuoteFormat,\n paddingLeft: '10px',\n ...(quoteFormat ?? DefaultQuoteFormatLtr),\n };\n const fullQuoteFormatRtl: ContentModelFormatContainerFormat = {\n ...BuildInQuoteFormat,\n paddingRight: '10px',\n direction: 'rtl',\n ...(quoteFormatRtl ?? quoteFormat ?? DefaultQuoteFormatRtl),\n };\n\n editor.focus();\n\n editor.formatContentModel(\n (model, context) => {\n context.newPendingFormat = 'preserve';\n\n return toggleModelBlockQuote(model, fullQuoteFormatLtr, fullQuoteFormatRtl);\n },\n {\n apiName: 'toggleBlockQuote',\n }\n );\n}\n"]}
|
|
@@ -21,16 +21,12 @@ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content
|
|
|
21
21
|
}, {
|
|
22
22
|
selectionOverride: typeof position === 'object' ? position : undefined,
|
|
23
23
|
changeSource: roosterjs_content_model_core_1.ChangeSource.InsertEntity,
|
|
24
|
-
getChangeData: function () {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
isReadonly: true,
|
|
31
|
-
};
|
|
32
|
-
return entity;
|
|
33
|
-
},
|
|
24
|
+
getChangeData: function () { return ({
|
|
25
|
+
wrapper: wrapper,
|
|
26
|
+
type: type,
|
|
27
|
+
id: '',
|
|
28
|
+
isReadonly: true,
|
|
29
|
+
}); },
|
|
34
30
|
apiName: 'insertEntity',
|
|
35
31
|
});
|
|
36
32
|
return entityModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertEntity.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/entity/insertEntity.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"insertEntity.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/entity/insertEntity.ts"],"names":[],"mappings":";;;IAWA,IAAM,cAAc,GAAG,KAAK,CAAC;IAC7B,IAAM,eAAe,GAAG,MAAM,CAAC;IAwC/B,SAAwB,YAAY,CAChC,MAAyB,EACzB,IAAY,EACZ,OAAgB,EAChB,QAA8C,EAC9C,OAA6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YAAY;YACvC,aAAa,EAAE,cAAM,OAAA,CAAC;gBAClB,OAAO,SAAA;gBACP,IAAI,MAAA;gBACJ,EAAE,EAAE,EAAE;gBACN,UAAU,EAAE,IAAI;aACnB,CAAC,EALmB,CAKnB;YACF,OAAO,EAAE,cAAc;SAC1B,CACJ,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;IAnDD,+BAmDC","sourcesContent":["import { ChangeSource } from 'roosterjs-content-model-core';\nimport { createEntity, normalizeContentModel } from 'roosterjs-content-model-dom';\nimport { insertEntityModel } from '../../modelApi/entity/insertEntityModel';\nimport type {\n ContentModelEntity,\n DOMSelection,\n InsertEntityPosition,\n InsertEntityOptions,\n IStandaloneEditor,\n} from 'roosterjs-content-model-types';\n\nconst BlockEntityTag = 'div';\nconst InlineEntityTag = 'span';\n\n/**\n * Insert an entity into editor\n * @param editor The Content Model editor\n * @param type Type of entity\n * @param isBlock True to insert a block entity, false to insert an inline entity\n * @param position Position of the entity to insert. It can be\n * Value of InsertEntityPosition: see InsertEntityPosition\n * selectionRangeEx: Use this range instead of current focus position to insert. After insert, focus will be moved to\n * the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)\n * @param options Move options to insert. See InsertEntityOptions\n */\nexport default function insertEntity(\n editor: IStandaloneEditor,\n type: string,\n isBlock: boolean,\n position: 'focus' | 'begin' | 'end' | DOMSelection,\n options?: InsertEntityOptions\n): ContentModelEntity | null;\n\n/**\n * Insert a block entity into editor\n * @param editor The Content Model editor\n * @param type Type of entity\n * @param isBlock Must be true for a block entity\n * @param position Position of the entity to insert. It can be\n * Value of InsertEntityPosition: see InsertEntityPosition\n * selectionRangeEx: Use this range instead of current focus position to insert. After insert, focus will be moved to\n * the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)\n * @param options Move options to insert. See InsertEntityOptions\n */\nexport default function insertEntity(\n editor: IStandaloneEditor,\n type: string,\n isBlock: true,\n position: InsertEntityPosition | DOMSelection,\n options?: InsertEntityOptions\n): ContentModelEntity | null;\n\nexport default function insertEntity(\n editor: IStandaloneEditor,\n type: string,\n isBlock: boolean,\n position?: InsertEntityPosition | DOMSelection,\n options?: InsertEntityOptions\n): ContentModelEntity | null {\n const { contentNode, focusAfterEntity, wrapperDisplay, skipUndoSnapshot } = options || {};\n const wrapper = editor.getDocument().createElement(isBlock ? BlockEntityTag : InlineEntityTag);\n const display = wrapperDisplay ?? (isBlock ? undefined : 'inline-block');\n\n wrapper.style.setProperty('display', display || null);\n\n if (contentNode) {\n wrapper.appendChild(contentNode);\n }\n\n const entityModel = createEntity(wrapper, true /*isReadonly*/, undefined /*format*/, type);\n\n editor.formatContentModel(\n (model, context) => {\n insertEntityModel(\n model,\n entityModel,\n typeof position == 'string' ? position : 'focus',\n isBlock,\n focusAfterEntity,\n context\n );\n\n normalizeContentModel(model);\n\n context.skipUndoSnapshot = skipUndoSnapshot;\n context.newEntities.push(entityModel);\n\n return true;\n },\n {\n selectionOverride: typeof position === 'object' ? position : undefined,\n changeSource: ChangeSource.InsertEntity,\n getChangeData: () => ({\n wrapper,\n type,\n id: '',\n isReadonly: true,\n }),\n apiName: 'insertEntity',\n }\n );\n\n return entityModel;\n}\n"]}
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import type { IStandaloneEditor,
|
|
1
|
+
import type { IStandaloneEditor, ContentModelFormatState } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Get current format state
|
|
4
4
|
* @param editor The editor to get format from
|
|
5
5
|
*/
|
|
6
6
|
export default function getFormatState(editor: IStandaloneEditor): ContentModelFormatState;
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
interface FormatStateContext extends DomToModelContext {
|
|
11
|
-
/**
|
|
12
|
-
* An optional stack of parent elements to process. When provided, the child nodes of current parent element will be ignored,
|
|
13
|
-
* but use the top element in this stack instead in childProcessor.
|
|
14
|
-
*/
|
|
15
|
-
nodeStack?: Node[];
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @internal
|
|
19
|
-
* Export for test only
|
|
20
|
-
* In order to get format, we can still use the regular child processor. However, to improve performance, we don't need to create
|
|
21
|
-
* content model for the whole doc, instead we only need to traverse the tree path that can arrive current selected node.
|
|
22
|
-
* This "reduced" child processor will first create a node stack that stores DOM node from root to current common ancestor node of selection,
|
|
23
|
-
* then use this stack as a faked DOM tree to create a reduced content model which we can use to retrieve format state
|
|
24
|
-
*/
|
|
25
|
-
export declare function reducedModelChildProcessor(group: ContentModelBlockGroup, parent: ParentNode, context: FormatStateContext): void;
|
|
26
|
-
export {};
|