roosterjs-content-model-plugins 0.28.2 → 9.0.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/README.md +47 -37
- package/lib/autoFormat/AutoFormatPlugin.d.ts +5 -2
- package/lib/autoFormat/AutoFormatPlugin.js +23 -11
- package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib/autoFormat/link/createLinkAfterSpace.js +28 -22
- package/lib/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib/autoFormat/link/getLinkSegment.js +2 -2
- package/lib/autoFormat/link/getLinkSegment.js.map +1 -1
- package/lib/autoFormat/list/getListTypeStyle.js +14 -14
- package/lib/autoFormat/list/getListTypeStyle.js.map +1 -1
- package/lib/autoFormat/list/getNumberingListStyle.js +29 -29
- package/lib/autoFormat/list/getNumberingListStyle.js.map +1 -1
- package/lib/autoFormat/list/keyboardListTrigger.d.ts +1 -1
- package/lib/autoFormat/list/keyboardListTrigger.js +10 -11
- package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +2 -2
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js +4 -5
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib/edit/deleteSteps/deleteEmptyQuote.js +2 -3
- package/lib/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
- package/lib/edit/deleteSteps/deleteList.js +3 -5
- package/lib/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.js +3 -4
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib/edit/inputSteps/handleEnterOnList.js +2 -3
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib/edit/keyboardDelete.js +4 -5
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.js +3 -4
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/edit/keyboardTab.js +3 -3
- package/lib/edit/keyboardTab.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/markdown/MarkdownPlugin.d.ts +55 -0
- package/lib/markdown/MarkdownPlugin.js +177 -0
- package/lib/markdown/MarkdownPlugin.js.map +1 -0
- package/lib/markdown/utils/setFormat.d.ts +5 -0
- package/lib/markdown/utils/setFormat.js +46 -0
- package/lib/markdown/utils/setFormat.js.map +1 -0
- package/lib/paste/WordDesktop/processWordLists.js +2 -3
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib/pluginUtils/splitTextSegment.d.ts +5 -0
- package/lib/pluginUtils/splitTextSegment.js +26 -0
- package/lib/pluginUtils/splitTextSegment.js.map +1 -0
- package/lib/shortcut/ShortcutPlugin.js +2 -2
- package/lib/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib/shortcut/utils/setShortcutIndentationCommand.js +2 -2
- package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib/tableEdit/editors/features/CellResizer.js +5 -6
- package/lib/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib/tableEdit/editors/features/TableResizer.js +2 -3
- package/lib/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib/watermark/WatermarkFormat.d.ts +5 -0
- package/lib/watermark/WatermarkFormat.js +3 -0
- package/lib/watermark/WatermarkFormat.js.map +1 -0
- package/lib/watermark/WatermarkPlugin.d.ts +37 -0
- package/lib/watermark/WatermarkPlugin.js +99 -0
- package/lib/watermark/WatermarkPlugin.js.map +1 -0
- package/lib/watermark/isModelEmptyFast.d.ts +6 -0
- package/lib/watermark/isModelEmptyFast.js +35 -0
- package/lib/watermark/isModelEmptyFast.js.map +1 -0
- package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +5 -2
- package/lib-amd/autoFormat/AutoFormatPlugin.js +23 -11
- package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js +28 -22
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib-amd/autoFormat/link/getLinkSegment.js +2 -2
- package/lib-amd/autoFormat/link/getLinkSegment.js.map +1 -1
- package/lib-amd/autoFormat/list/getListTypeStyle.js +14 -14
- package/lib-amd/autoFormat/list/getListTypeStyle.js.map +1 -1
- package/lib-amd/autoFormat/list/getNumberingListStyle.js +29 -29
- package/lib-amd/autoFormat/list/getNumberingListStyle.js.map +1 -1
- package/lib-amd/autoFormat/list/keyboardListTrigger.d.ts +1 -1
- package/lib-amd/autoFormat/list/keyboardListTrigger.js +11 -11
- package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +2 -2
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +5 -5
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js +3 -3
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteList.js +3 -5
- package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js +4 -4
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +3 -3
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.js +4 -4
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.js +3 -3
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/edit/keyboardTab.js +3 -3
- package/lib-amd/edit/keyboardTab.js.map +1 -1
- package/lib-amd/index.d.ts +3 -0
- package/lib-amd/index.js +4 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/markdown/MarkdownPlugin.d.ts +55 -0
- package/lib-amd/markdown/MarkdownPlugin.js +178 -0
- package/lib-amd/markdown/MarkdownPlugin.js.map +1 -0
- package/lib-amd/markdown/utils/setFormat.d.ts +5 -0
- package/lib-amd/markdown/utils/setFormat.js +45 -0
- package/lib-amd/markdown/utils/setFormat.js.map +1 -0
- package/lib-amd/paste/WordDesktop/processWordLists.js +3 -3
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-amd/pluginUtils/splitTextSegment.d.ts +5 -0
- package/lib-amd/pluginUtils/splitTextSegment.js +26 -0
- package/lib-amd/pluginUtils/splitTextSegment.js.map +1 -0
- package/lib-amd/shortcut/ShortcutPlugin.js +2 -2
- package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +2 -2
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/CellResizer.js +6 -6
- package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableResizer.js +3 -3
- package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-amd/watermark/WatermarkFormat.d.ts +5 -0
- package/lib-amd/watermark/WatermarkFormat.js +5 -0
- package/lib-amd/watermark/WatermarkFormat.js.map +1 -0
- package/lib-amd/watermark/WatermarkPlugin.d.ts +37 -0
- package/lib-amd/watermark/WatermarkPlugin.js +99 -0
- package/lib-amd/watermark/WatermarkPlugin.js.map +1 -0
- package/lib-amd/watermark/isModelEmptyFast.d.ts +6 -0
- package/lib-amd/watermark/isModelEmptyFast.js +37 -0
- package/lib-amd/watermark/isModelEmptyFast.js.map +1 -0
- package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +5 -2
- package/lib-mjs/autoFormat/AutoFormatPlugin.js +23 -11
- package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js +28 -22
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib-mjs/autoFormat/link/getLinkSegment.js +1 -1
- package/lib-mjs/autoFormat/link/getLinkSegment.js.map +1 -1
- package/lib-mjs/autoFormat/list/getListTypeStyle.js +2 -2
- package/lib-mjs/autoFormat/list/getListTypeStyle.js.map +1 -1
- package/lib-mjs/autoFormat/list/getNumberingListStyle.js +1 -1
- package/lib-mjs/autoFormat/list/getNumberingListStyle.js.map +1 -1
- package/lib-mjs/autoFormat/list/keyboardListTrigger.d.ts +1 -1
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js +11 -12
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +1 -1
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +1 -2
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js +1 -2
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteList.js +2 -4
- package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +1 -2
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +1 -2
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.js +1 -2
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.js +1 -2
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/edit/keyboardTab.js +1 -1
- package/lib-mjs/edit/keyboardTab.js.map +1 -1
- package/lib-mjs/index.d.ts +3 -0
- package/lib-mjs/index.js +2 -0
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/markdown/MarkdownPlugin.d.ts +55 -0
- package/lib-mjs/markdown/MarkdownPlugin.js +174 -0
- package/lib-mjs/markdown/MarkdownPlugin.js.map +1 -0
- package/lib-mjs/markdown/utils/setFormat.d.ts +5 -0
- package/lib-mjs/markdown/utils/setFormat.js +42 -0
- package/lib-mjs/markdown/utils/setFormat.js.map +1 -0
- package/lib-mjs/paste/WordDesktop/processWordLists.js +1 -2
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-mjs/pluginUtils/splitTextSegment.d.ts +5 -0
- package/lib-mjs/pluginUtils/splitTextSegment.js +22 -0
- package/lib-mjs/pluginUtils/splitTextSegment.js.map +1 -0
- package/lib-mjs/shortcut/ShortcutPlugin.js +1 -1
- package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +1 -1
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/CellResizer.js +1 -2
- package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableResizer.js +1 -2
- package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-mjs/watermark/WatermarkFormat.d.ts +5 -0
- package/lib-mjs/watermark/WatermarkFormat.js +2 -0
- package/lib-mjs/watermark/WatermarkFormat.js.map +1 -0
- package/lib-mjs/watermark/WatermarkPlugin.d.ts +37 -0
- package/lib-mjs/watermark/WatermarkPlugin.js +96 -0
- package/lib-mjs/watermark/WatermarkPlugin.js.map +1 -0
- package/lib-mjs/watermark/isModelEmptyFast.d.ts +6 -0
- package/lib-mjs/watermark/isModelEmptyFast.js +31 -0
- package/lib-mjs/watermark/isModelEmptyFast.js.map +1 -0
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "../../../pluginUtils/CreateElement/createElement", "../../../pluginUtils/DragAndDrop/DragAndDropHelper", "roosterjs-content-model-
|
|
1
|
+
define(["require", "exports", "../../../pluginUtils/CreateElement/createElement", "../../../pluginUtils/DragAndDrop/DragAndDropHelper", "roosterjs-content-model-dom"], function (require, exports, createElement_1, DragAndDropHelper_1, roosterjs_content_model_dom_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.createTableResizer = void 0;
|
|
@@ -58,7 +58,7 @@ define(["require", "exports", "../../../pluginUtils/CreateElement/createElement"
|
|
|
58
58
|
table: table,
|
|
59
59
|
});
|
|
60
60
|
// Get the table content model
|
|
61
|
-
var cmTable = (0,
|
|
61
|
+
var cmTable = (0, roosterjs_content_model_dom_1.getFirstSelectedTable)(editor.getContentModelCopy('disconnected'))[0];
|
|
62
62
|
// Restore selection
|
|
63
63
|
editor.setDOMSelection(selection);
|
|
64
64
|
// Save original widths and heights
|
|
@@ -106,7 +106,7 @@ define(["require", "exports", "../../../pluginUtils/CreateElement/createElement"
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
// Normalize the table
|
|
109
|
-
(0,
|
|
109
|
+
(0, roosterjs_content_model_dom_1.normalizeTable)(cmTable);
|
|
110
110
|
// Writeback CM Table size changes to DOM Table
|
|
111
111
|
for (var row = 0; row < table.rows.length; row++) {
|
|
112
112
|
var tableRow = table.rows[row];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableResizer.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableResizer.ts"],"names":[],"mappings":";;;;IAOA,IAAM,oBAAoB,GAAG,EAAE,CAAC;IAChC,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;IAE1C;;OAEG;IACH,SAAgB,kBAAkB,CAC9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,IAAI,GAAG,KAAK;gBACtB,CAAC,CAAI,IAAI,CAAC,IAAI,GAAG,oBAAoB,GAAG,CAAC,OAAI;gBAC7C,CAAC,CAAI,IAAI,CAAC,KAAK,OAAI,CAAC;SAC3B;IACL,CAAC;IAED,SAAS,WAAW,CAAC,OAA2B,EAAE,OAAoB;QAClE,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;IACxC,CAAC;IAED,SAAS,oBAAoB,CACzB,MAAe,EACf,IAAiB,EACjB,UAAwB;QAExB,IAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACpD,IAAI,IAAA,0CAAY,EAAC,UAAU,EAAE,cAAc,CAAC,IAAI,eAAe,IAAI,IAAI,EAAE;YACrE,IAAM,aAAa,GAAG,IAAA,2CAAa,EAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;YAExE,OAAO,CACH,CAAC,CAAC,aAAa;gBACf,aAAa,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;gBACnC,eAAe,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CACxC,CAAC;SACL;QAED,OAAO,IAAI,CAAC;IAChB,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport { getFirstSelectedTable, normalizeTable } from 'roosterjs-content-model-core';\nimport { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable, IEditor, Rect } from 'roosterjs-content-model-types';\nimport type { TableEditFeature } from './TableEditFeature';\n\nconst TABLE_RESIZER_LENGTH = 12;\nconst TABLE_RESIZER_ID = '_Table_Resizer';\n\n/**\n * @internal\n */\nexport function createTableResizer(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onStart: () => void,\n onEnd: () => false,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableBottomVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const document = table.ownerDocument;\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const createElementData = {\n tag: 'div',\n style: `position: fixed; cursor: ${\n isRTL ? 'ne' : 'nw'\n }-resize; user-select: none; border: 1px solid #808080`,\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_RESIZER_ID;\n div.style.width = `${TABLE_RESIZER_LENGTH}px`;\n div.style.height = `${TABLE_RESIZER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: DragAndDropContext = {\n isRTL,\n table,\n zoomScale,\n onStart,\n onEnd,\n div,\n editor,\n contentDiv,\n };\n\n setDivPosition(context, div);\n\n const featureHandler = new DragAndDropHelper<DragAndDropContext, DragAndDropInitValue>(\n div,\n context,\n hideResizer, // Resizer is hidden while dragging only\n {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n zoomScale,\n editor.getEnvironment().isMobileOrTablet\n );\n\n return { node: table, div, featureHandler };\n}\n\ninterface DragAndDropContext {\n table: HTMLTableElement;\n isRTL: boolean;\n zoomScale: number;\n onStart: () => void;\n onEnd: () => false;\n div: HTMLDivElement;\n editor: IEditor;\n contentDiv?: EventTarget | null;\n}\n\ninterface DragAndDropInitValue {\n originalRect: DOMRect;\n originalHeights: number[];\n originalWidths: number[];\n cmTable: ContentModelTable | undefined;\n}\n\nfunction onDragStart(context: DragAndDropContext, event: MouseEvent) {\n context.onStart();\n\n const { editor, table } = context;\n\n // Get current selection\n const selection = editor.getDOMSelection();\n\n // Select first cell of the table\n editor.setDOMSelection({\n type: 'table',\n firstColumn: 0,\n firstRow: 0,\n lastColumn: 0,\n lastRow: 0,\n table: table,\n });\n\n // Get the table content model\n const cmTable = getFirstSelectedTable(editor.getContentModelCopy('disconnected'))[0];\n\n // Restore selection\n editor.setDOMSelection(selection);\n\n // Save original widths and heights\n const heights: number[] = [];\n cmTable?.rows.forEach(row => {\n heights.push(row.height);\n });\n const widths: number[] = [];\n cmTable?.widths.forEach(width => {\n widths.push(width);\n });\n\n return {\n originalRect: table.getBoundingClientRect(),\n cmTable,\n originalHeights: heights ?? [],\n originalWidths: widths ?? [],\n };\n}\n\nfunction onDragging(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue,\n deltaX: number,\n deltaY: number\n) {\n const { isRTL, zoomScale, table } = context;\n const { originalRect, originalHeights, originalWidths, cmTable } = initValue;\n\n const ratioX = 1.0 + (deltaX / originalRect.width) * zoomScale * (isRTL ? -1 : 1);\n const ratioY = 1.0 + (deltaY / originalRect.height) * zoomScale;\n const shouldResizeX = Math.abs(ratioX - 1.0) > 1e-3;\n const shouldResizeY = Math.abs(ratioY - 1.0) > 1e-3;\n\n // If the width of some external table is fixed, we need to make it resizable\n table.style.setProperty('width', null);\n // If the height of some external table is fixed, we need to make it resizable\n table.style.setProperty('height', null);\n\n // Assign new widths and heights to the CM table\n if (cmTable && cmTable.rows && (shouldResizeX || shouldResizeY)) {\n // Modify the CM Table size\n for (let i = 0; i < cmTable.rows.length; i++) {\n for (let j = 0; j < cmTable.rows[i].cells.length; j++) {\n const cell = cmTable.rows[i].cells[j];\n if (cell) {\n if (shouldResizeX && i == 0) {\n cmTable.widths[j] = (originalWidths[j] ?? 0) * ratioX;\n }\n if (shouldResizeY && j == 0) {\n cmTable.rows[i].height = (originalHeights[i] ?? 0) * ratioY;\n }\n }\n }\n }\n\n // Normalize the table\n normalizeTable(cmTable);\n\n // Writeback CM Table size changes to DOM Table\n for (let row = 0; row < table.rows.length; row++) {\n const tableRow = table.rows[row];\n\n if (tableRow.cells.length == 0) {\n // Skip empty row\n continue;\n }\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n const td = tableRow.cells[col];\n td.style.width = cmTable.widths[col] + 'px';\n td.style.height = cmTable.rows[row].height + 'px';\n }\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction onDragEnd(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue | undefined\n) {\n if (context.editor.isDisposed()) {\n return false;\n }\n if (\n isTableBottomVisible(\n context.editor,\n normalizeRect(context.table.getBoundingClientRect()),\n context.contentDiv as Node\n )\n ) {\n context.div.style.visibility = 'visible';\n setDivPosition(context, context.div);\n }\n context.onEnd();\n return false;\n}\n\nfunction setDivPosition(context: DragAndDropContext, trigger: HTMLElement) {\n const { table, isRTL } = context;\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (rect) {\n trigger.style.top = `${rect.bottom}px`;\n trigger.style.left = isRTL\n ? `${rect.left - TABLE_RESIZER_LENGTH - 2}px`\n : `${rect.right}px`;\n }\n}\n\nfunction hideResizer(context: DragAndDropContext, trigger: HTMLElement) {\n trigger.style.visibility = 'hidden';\n}\n\nfunction isTableBottomVisible(\n editor: IEditor,\n rect: Rect | null,\n contentDiv?: Node | null\n): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return (\n !!containerRect &&\n containerRect.bottom >= rect.bottom &&\n visibleViewport.bottom >= rect.bottom\n );\n }\n\n return true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TableResizer.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableResizer.ts"],"names":[],"mappings":";;;;IAWA,IAAM,oBAAoB,GAAG,EAAE,CAAC;IAChC,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;IAE1C;;OAEG;IACH,SAAgB,kBAAkB,CAC9B,KAAuB,EACvB,MAAe,EACf,KAAc,EACd,OAAmB,EACnB,KAAkB,EAClB,UAA+B,EAC/B,eAA6B;QAE7B,IAAM,IAAI,GAAG,IAAA,2CAAa,EAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,IAAI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KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;IACxC,CAAC;IAED,SAAS,oBAAoB,CACzB,MAAe,EACf,IAAiB,EACjB,UAAwB;QAExB,IAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACpD,IAAI,IAAA,0CAAY,EAAC,UAAU,EAAE,cAAc,CAAC,IAAI,eAAe,IAAI,IAAI,EAAE;YACrE,IAAM,aAAa,GAAG,IAAA,2CAAa,EAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;YAExE,OAAO,CACH,CAAC,CAAC,aAAa;gBACf,aAAa,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;gBACnC,eAAe,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CACxC,CAAC;SACL;QAED,OAAO,IAAI,CAAC;IAChB,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport {\n getFirstSelectedTable,\n isNodeOfType,\n normalizeRect,\n normalizeTable,\n} from 'roosterjs-content-model-dom';\nimport type { ContentModelTable, IEditor, Rect } from 'roosterjs-content-model-types';\nimport type { TableEditFeature } from './TableEditFeature';\n\nconst TABLE_RESIZER_LENGTH = 12;\nconst TABLE_RESIZER_ID = '_Table_Resizer';\n\n/**\n * @internal\n */\nexport function createTableResizer(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onStart: () => void,\n onEnd: () => false,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableBottomVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const document = table.ownerDocument;\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const createElementData = {\n tag: 'div',\n style: `position: fixed; cursor: ${\n isRTL ? 'ne' : 'nw'\n }-resize; user-select: none; border: 1px solid #808080`,\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_RESIZER_ID;\n div.style.width = `${TABLE_RESIZER_LENGTH}px`;\n div.style.height = `${TABLE_RESIZER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: DragAndDropContext = {\n isRTL,\n table,\n zoomScale,\n onStart,\n onEnd,\n div,\n editor,\n contentDiv,\n };\n\n setDivPosition(context, div);\n\n const featureHandler = new DragAndDropHelper<DragAndDropContext, DragAndDropInitValue>(\n div,\n context,\n hideResizer, // Resizer is hidden while dragging only\n {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n zoomScale,\n editor.getEnvironment().isMobileOrTablet\n );\n\n return { node: table, div, featureHandler };\n}\n\ninterface DragAndDropContext {\n table: HTMLTableElement;\n isRTL: boolean;\n zoomScale: number;\n onStart: () => void;\n onEnd: () => false;\n div: HTMLDivElement;\n editor: IEditor;\n contentDiv?: EventTarget | null;\n}\n\ninterface DragAndDropInitValue {\n originalRect: DOMRect;\n originalHeights: number[];\n originalWidths: number[];\n cmTable: ContentModelTable | undefined;\n}\n\nfunction onDragStart(context: DragAndDropContext, event: MouseEvent) {\n context.onStart();\n\n const { editor, table } = context;\n\n // Get current selection\n const selection = editor.getDOMSelection();\n\n // Select first cell of the table\n editor.setDOMSelection({\n type: 'table',\n firstColumn: 0,\n firstRow: 0,\n lastColumn: 0,\n lastRow: 0,\n table: table,\n });\n\n // Get the table content model\n const cmTable = getFirstSelectedTable(editor.getContentModelCopy('disconnected'))[0];\n\n // Restore selection\n editor.setDOMSelection(selection);\n\n // Save original widths and heights\n const heights: number[] = [];\n cmTable?.rows.forEach(row => {\n heights.push(row.height);\n });\n const widths: number[] = [];\n cmTable?.widths.forEach(width => {\n widths.push(width);\n });\n\n return {\n originalRect: table.getBoundingClientRect(),\n cmTable,\n originalHeights: heights ?? [],\n originalWidths: widths ?? [],\n };\n}\n\nfunction onDragging(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue,\n deltaX: number,\n deltaY: number\n) {\n const { isRTL, zoomScale, table } = context;\n const { originalRect, originalHeights, originalWidths, cmTable } = initValue;\n\n const ratioX = 1.0 + (deltaX / originalRect.width) * zoomScale * (isRTL ? -1 : 1);\n const ratioY = 1.0 + (deltaY / originalRect.height) * zoomScale;\n const shouldResizeX = Math.abs(ratioX - 1.0) > 1e-3;\n const shouldResizeY = Math.abs(ratioY - 1.0) > 1e-3;\n\n // If the width of some external table is fixed, we need to make it resizable\n table.style.setProperty('width', null);\n // If the height of some external table is fixed, we need to make it resizable\n table.style.setProperty('height', null);\n\n // Assign new widths and heights to the CM table\n if (cmTable && cmTable.rows && (shouldResizeX || shouldResizeY)) {\n // Modify the CM Table size\n for (let i = 0; i < cmTable.rows.length; i++) {\n for (let j = 0; j < cmTable.rows[i].cells.length; j++) {\n const cell = cmTable.rows[i].cells[j];\n if (cell) {\n if (shouldResizeX && i == 0) {\n cmTable.widths[j] = (originalWidths[j] ?? 0) * ratioX;\n }\n if (shouldResizeY && j == 0) {\n cmTable.rows[i].height = (originalHeights[i] ?? 0) * ratioY;\n }\n }\n }\n }\n\n // Normalize the table\n normalizeTable(cmTable);\n\n // Writeback CM Table size changes to DOM Table\n for (let row = 0; row < table.rows.length; row++) {\n const tableRow = table.rows[row];\n\n if (tableRow.cells.length == 0) {\n // Skip empty row\n continue;\n }\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n const td = tableRow.cells[col];\n td.style.width = cmTable.widths[col] + 'px';\n td.style.height = cmTable.rows[row].height + 'px';\n }\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction onDragEnd(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue | undefined\n) {\n if (context.editor.isDisposed()) {\n return false;\n }\n if (\n isTableBottomVisible(\n context.editor,\n normalizeRect(context.table.getBoundingClientRect()),\n context.contentDiv as Node\n )\n ) {\n context.div.style.visibility = 'visible';\n setDivPosition(context, context.div);\n }\n context.onEnd();\n return false;\n}\n\nfunction setDivPosition(context: DragAndDropContext, trigger: HTMLElement) {\n const { table, isRTL } = context;\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (rect) {\n trigger.style.top = `${rect.bottom}px`;\n trigger.style.left = isRTL\n ? `${rect.left - TABLE_RESIZER_LENGTH - 2}px`\n : `${rect.right}px`;\n }\n}\n\nfunction hideResizer(context: DragAndDropContext, trigger: HTMLElement) {\n trigger.style.visibility = 'hidden';\n}\n\nfunction isTableBottomVisible(\n editor: IEditor,\n rect: Rect | null,\n contentDiv?: Node | null\n): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return (\n !!containerRect &&\n containerRect.bottom >= rect.bottom &&\n visibleViewport.bottom >= rect.bottom\n );\n }\n\n return true;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WatermarkFormat.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/watermark/WatermarkFormat.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n FontFamilyFormat,\n FontSizeFormat,\n TextColorFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * Format type of watermark text\n */\nexport type WatermarkFormat = FontFamilyFormat & FontSizeFormat & TextColorFormat;\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { WatermarkFormat } from './WatermarkFormat';
|
|
2
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
3
|
+
/**
|
|
4
|
+
* A watermark plugin to manage watermark string for roosterjs
|
|
5
|
+
*/
|
|
6
|
+
export declare class WatermarkPlugin implements EditorPlugin {
|
|
7
|
+
private watermark;
|
|
8
|
+
private editor;
|
|
9
|
+
private format;
|
|
10
|
+
private isShowing;
|
|
11
|
+
/**
|
|
12
|
+
* Create an instance of Watermark plugin
|
|
13
|
+
* @param watermark The watermark string
|
|
14
|
+
*/
|
|
15
|
+
constructor(watermark: string, format?: WatermarkFormat);
|
|
16
|
+
/**
|
|
17
|
+
* Get a friendly name of this plugin
|
|
18
|
+
*/
|
|
19
|
+
getName(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Initialize this plugin. This should only be called from Editor
|
|
22
|
+
* @param editor Editor instance
|
|
23
|
+
*/
|
|
24
|
+
initialize(editor: IEditor): void;
|
|
25
|
+
/**
|
|
26
|
+
* Dispose this plugin
|
|
27
|
+
*/
|
|
28
|
+
dispose(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Handle events triggered from editor
|
|
31
|
+
* @param event PluginEvent object
|
|
32
|
+
*/
|
|
33
|
+
onPluginEvent(event: PluginEvent): void;
|
|
34
|
+
private showHide;
|
|
35
|
+
protected show(editor: IEditor): void;
|
|
36
|
+
protected hide(editor: IEditor): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom", "./isModelEmptyFast"], function (require, exports, roosterjs_content_model_dom_1, isModelEmptyFast_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.WatermarkPlugin = void 0;
|
|
5
|
+
var WATERMARK_CONTENT_KEY = '_WatermarkContent';
|
|
6
|
+
var styleMap = {
|
|
7
|
+
fontFamily: 'font-family',
|
|
8
|
+
fontSize: 'font-size',
|
|
9
|
+
textColor: 'color',
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A watermark plugin to manage watermark string for roosterjs
|
|
13
|
+
*/
|
|
14
|
+
var WatermarkPlugin = /** @class */ (function () {
|
|
15
|
+
/**
|
|
16
|
+
* Create an instance of Watermark plugin
|
|
17
|
+
* @param watermark The watermark string
|
|
18
|
+
*/
|
|
19
|
+
function WatermarkPlugin(watermark, format) {
|
|
20
|
+
this.watermark = watermark;
|
|
21
|
+
this.editor = null;
|
|
22
|
+
this.isShowing = false;
|
|
23
|
+
this.format = format || {
|
|
24
|
+
fontSize: '14px',
|
|
25
|
+
textColor: '#AAAAAA',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a friendly name of this plugin
|
|
30
|
+
*/
|
|
31
|
+
WatermarkPlugin.prototype.getName = function () {
|
|
32
|
+
return 'Watermark';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Initialize this plugin. This should only be called from Editor
|
|
36
|
+
* @param editor Editor instance
|
|
37
|
+
*/
|
|
38
|
+
WatermarkPlugin.prototype.initialize = function (editor) {
|
|
39
|
+
this.editor = editor;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Dispose this plugin
|
|
43
|
+
*/
|
|
44
|
+
WatermarkPlugin.prototype.dispose = function () {
|
|
45
|
+
this.editor = null;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Handle events triggered from editor
|
|
49
|
+
* @param event PluginEvent object
|
|
50
|
+
*/
|
|
51
|
+
WatermarkPlugin.prototype.onPluginEvent = function (event) {
|
|
52
|
+
var _this = this;
|
|
53
|
+
var editor = this.editor;
|
|
54
|
+
if (!editor) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (event.eventType == 'input' && event.rawEvent.inputType == 'insertText') {
|
|
58
|
+
// When input text, editor must not be empty, so we can do hide watermark now without checking content model
|
|
59
|
+
this.showHide(editor, false /*isEmpty*/);
|
|
60
|
+
}
|
|
61
|
+
else if (event.eventType == 'editorReady' ||
|
|
62
|
+
event.eventType == 'contentChanged' ||
|
|
63
|
+
event.eventType == 'input' ||
|
|
64
|
+
event.eventType == 'beforeDispose') {
|
|
65
|
+
editor.formatContentModel(function (model) {
|
|
66
|
+
var isEmpty = (0, isModelEmptyFast_1.isModelEmptyFast)(model);
|
|
67
|
+
_this.showHide(editor, isEmpty);
|
|
68
|
+
return false;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
WatermarkPlugin.prototype.showHide = function (editor, isEmpty) {
|
|
73
|
+
if (this.isShowing && !isEmpty) {
|
|
74
|
+
this.hide(editor);
|
|
75
|
+
}
|
|
76
|
+
else if (!this.isShowing && isEmpty) {
|
|
77
|
+
this.show(editor);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
WatermarkPlugin.prototype.show = function (editor) {
|
|
81
|
+
var _this = this;
|
|
82
|
+
var rule = "position: absolute; pointer-events: none; content: \"" + this.watermark + "\";";
|
|
83
|
+
(0, roosterjs_content_model_dom_1.getObjectKeys)(styleMap).forEach(function (x) {
|
|
84
|
+
if (_this.format[x]) {
|
|
85
|
+
rule += styleMap[x] + ": " + _this.format[x] + "!important;";
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
editor.setEditorStyle(WATERMARK_CONTENT_KEY, rule, 'before');
|
|
89
|
+
this.isShowing = true;
|
|
90
|
+
};
|
|
91
|
+
WatermarkPlugin.prototype.hide = function (editor) {
|
|
92
|
+
editor.setEditorStyle(WATERMARK_CONTENT_KEY, null);
|
|
93
|
+
this.isShowing = false;
|
|
94
|
+
};
|
|
95
|
+
return WatermarkPlugin;
|
|
96
|
+
}());
|
|
97
|
+
exports.WatermarkPlugin = WatermarkPlugin;
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=WatermarkPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WatermarkPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/watermark/WatermarkPlugin.ts"],"names":[],"mappings":";;;;IAKA,IAAM,qBAAqB,GAAG,mBAAmB,CAAC;IAClD,IAAM,QAAQ,GAA0C;QACpD,UAAU,EAAE,aAAa;QACzB,QAAQ,EAAE,WAAW;QACrB,SAAS,EAAE,OAAO;KACrB,CAAC;IAEF;;OAEG;IACH;QAKI;;;WAGG;QACH,yBAAoB,SAAiB,EAAE,MAAwB;YAA3C,cAAS,GAAT,SAAS,CAAQ;YAR7B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IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;gBAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACrB;iBAAM,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,EAAE;gBACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACrB;QACL,CAAC;QAES,8BAAI,GAAd,UAAe,MAAe;YAA9B,iBAYC;YAXG,IAAI,IAAI,GAAG,0DAAuD,IAAI,CAAC,SAAS,QAAI,CAAC;YAErF,IAAA,2CAAa,EAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC;gBAC7B,IAAI,KAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;oBAChB,IAAI,IAAO,QAAQ,CAAC,CAAC,CAAC,UAAK,KAAI,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAa,CAAC;iBAC1D;YACL,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,cAAc,CAAC,qBAAqB,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAE7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAC1B,CAAC;QAES,8BAAI,GAAd,UAAe,MAAe;YAC1B,MAAM,CAAC,cAAc,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;YACnD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAC3B,CAAC;QACL,sBAAC;IAAD,CAAC,AA9FD,IA8FC;IA9FY,0CAAe","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { isModelEmptyFast } from './isModelEmptyFast';\nimport type { WatermarkFormat } from './WatermarkFormat';\nimport type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';\n\nconst WATERMARK_CONTENT_KEY = '_WatermarkContent';\nconst styleMap: Record<keyof WatermarkFormat, string> = {\n fontFamily: 'font-family',\n fontSize: 'font-size',\n textColor: 'color',\n};\n\n/**\n * A watermark plugin to manage watermark string for roosterjs\n */\nexport class WatermarkPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private format: WatermarkFormat;\n private isShowing = false;\n\n /**\n * Create an instance of Watermark plugin\n * @param watermark The watermark string\n */\n constructor(private watermark: string, format?: WatermarkFormat) {\n this.format = format || {\n fontSize: '14px',\n textColor: '#AAAAAA',\n };\n }\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'Watermark';\n }\n\n /**\n * Initialize this plugin. This should only be called from Editor\n * @param editor Editor instance\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * Dispose this plugin\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Handle events triggered from editor\n * @param event PluginEvent object\n */\n onPluginEvent(event: PluginEvent) {\n const editor = this.editor;\n\n if (!editor) {\n return;\n }\n\n if (event.eventType == 'input' && event.rawEvent.inputType == 'insertText') {\n // When input text, editor must not be empty, so we can do hide watermark now without checking content model\n this.showHide(editor, false /*isEmpty*/);\n } else if (\n event.eventType == 'editorReady' ||\n event.eventType == 'contentChanged' ||\n event.eventType == 'input' ||\n event.eventType == 'beforeDispose'\n ) {\n editor.formatContentModel(model => {\n const isEmpty = isModelEmptyFast(model);\n\n this.showHide(editor, isEmpty);\n\n return false;\n });\n }\n }\n\n private showHide(editor: IEditor, isEmpty: boolean) {\n if (this.isShowing && !isEmpty) {\n this.hide(editor);\n } else if (!this.isShowing && isEmpty) {\n this.show(editor);\n }\n }\n\n protected show(editor: IEditor) {\n let rule = `position: absolute; pointer-events: none; content: \"${this.watermark}\";`;\n\n getObjectKeys(styleMap).forEach(x => {\n if (this.format[x]) {\n rule += `${styleMap[x]}: ${this.format[x]}!important;`;\n }\n });\n\n editor.setEditorStyle(WATERMARK_CONTENT_KEY, rule, 'before');\n\n this.isShowing = true;\n }\n\n protected hide(editor: IEditor) {\n editor.setEditorStyle(WATERMARK_CONTENT_KEY, null);\n this.isShowing = false;\n }\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isModelEmptyFast = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* A fast way to check if content model is empty
|
|
8
|
+
*/
|
|
9
|
+
function isModelEmptyFast(model) {
|
|
10
|
+
var firstBlock = model.blocks[0];
|
|
11
|
+
if (model.blocks.length > 1) {
|
|
12
|
+
return false; // Multiple blocks, treat as not empty
|
|
13
|
+
}
|
|
14
|
+
else if (!firstBlock) {
|
|
15
|
+
return true; // No block, it is empty
|
|
16
|
+
}
|
|
17
|
+
else if (firstBlock.blockType != 'Paragraph') {
|
|
18
|
+
return false; // First block is not paragraph, treat as not empty
|
|
19
|
+
}
|
|
20
|
+
else if (firstBlock.segments.length == 0) {
|
|
21
|
+
return true; // No segment, it is empty
|
|
22
|
+
}
|
|
23
|
+
else if (firstBlock.segments.some(function (x) {
|
|
24
|
+
return x.segmentType == 'Entity' ||
|
|
25
|
+
x.segmentType == 'Image' ||
|
|
26
|
+
x.segmentType == 'General' ||
|
|
27
|
+
(x.segmentType == 'Text' && x.text);
|
|
28
|
+
})) {
|
|
29
|
+
return false; // Has meaningful segments, it is not empty
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return firstBlock.segments.filter(function (x) { return x.segmentType == 'Br'; }).length <= 1; // If there are more than one BR, it is not empty, otherwise it is empty
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.isModelEmptyFast = isModelEmptyFast;
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=isModelEmptyFast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isModelEmptyFast.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/watermark/isModelEmptyFast.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,gBAAgB,CAAC,KAA2B;QACxD,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAEnC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,OAAO,KAAK,CAAC,CAAC,sCAAsC;SACvD;aAAM,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,IAAI,CAAC,CAAC,wBAAwB;SACxC;aAAM,IAAI,UAAU,CAAC,SAAS,IAAI,WAAW,EAAE;YAC5C,OAAO,KAAK,CAAC,CAAC,mDAAmD;SACpE;aAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE;YACxC,OAAO,IAAI,CAAC,CAAC,0BAA0B;SAC1C;aAAM,IACH,UAAU,CAAC,QAAQ,CAAC,IAAI,CACpB,UAAA,CAAC;YACG,OAAA,CAAC,CAAC,WAAW,IAAI,QAAQ;gBACzB,CAAC,CAAC,WAAW,IAAI,OAAO;gBACxB,CAAC,CAAC,WAAW,IAAI,SAAS;gBAC1B,CAAC,CAAC,CAAC,WAAW,IAAI,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC;QAHnC,CAGmC,CAC1C,EACH;YACE,OAAO,KAAK,CAAC,CAAC,2CAA2C;SAC5D;aAAM;YACH,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,IAAI,EAArB,CAAqB,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,wEAAwE;SACtJ;IACL,CAAC;IAxBD,4CAwBC","sourcesContent":["import type { ContentModelDocument } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * A fast way to check if content model is empty\n */\nexport function isModelEmptyFast(model: ContentModelDocument): boolean {\n const firstBlock = model.blocks[0];\n\n if (model.blocks.length > 1) {\n return false; // Multiple blocks, treat as not empty\n } else if (!firstBlock) {\n return true; // No block, it is empty\n } else if (firstBlock.blockType != 'Paragraph') {\n return false; // First block is not paragraph, treat as not empty\n } else if (firstBlock.segments.length == 0) {\n return true; // No segment, it is empty\n } else if (\n firstBlock.segments.some(\n x =>\n x.segmentType == 'Entity' ||\n x.segmentType == 'Image' ||\n x.segmentType == 'General' ||\n (x.segmentType == 'Text' && x.text)\n )\n ) {\n return false; // Has meaningful segments, it is not empty\n } else {\n return firstBlock.segments.filter(x => x.segmentType == 'Br').length <= 1; // If there are more than one BR, it is not empty, otherwise it is empty\n }\n}\n"]}
|
|
@@ -29,8 +29,10 @@ export declare class AutoFormatPlugin implements EditorPlugin {
|
|
|
29
29
|
private editor;
|
|
30
30
|
/**
|
|
31
31
|
* @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:
|
|
32
|
-
* - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to
|
|
33
|
-
* - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to
|
|
32
|
+
* - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to false.
|
|
33
|
+
* - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.
|
|
34
|
+
* - autoLink: A boolean that enables or disables automatic hyperlink creation when pasting or typing content. Defaults to false.
|
|
35
|
+
* - autoUnlink: A boolean that enables or disables automatic hyperlink removal when pressing backspace. Defaults to false.
|
|
34
36
|
*/
|
|
35
37
|
constructor(options?: AutoFormatOptions);
|
|
36
38
|
/**
|
|
@@ -57,6 +59,7 @@ export declare class AutoFormatPlugin implements EditorPlugin {
|
|
|
57
59
|
* @param event The event to handle:
|
|
58
60
|
*/
|
|
59
61
|
onPluginEvent(event: PluginEvent): void;
|
|
62
|
+
private handleEditorInputEvent;
|
|
60
63
|
private handleKeyDownEvent;
|
|
61
64
|
private handleContentChangedEvent;
|
|
62
65
|
}
|
|
@@ -6,10 +6,10 @@ import { unlink } from './link/unlink';
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
var DefaultOptions = {
|
|
9
|
-
autoBullet:
|
|
10
|
-
autoNumbering:
|
|
9
|
+
autoBullet: false,
|
|
10
|
+
autoNumbering: false,
|
|
11
11
|
autoUnlink: false,
|
|
12
|
-
autoLink:
|
|
12
|
+
autoLink: false,
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
|
|
@@ -18,8 +18,10 @@ var DefaultOptions = {
|
|
|
18
18
|
var AutoFormatPlugin = /** @class */ (function () {
|
|
19
19
|
/**
|
|
20
20
|
* @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:
|
|
21
|
-
* - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to
|
|
22
|
-
* - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to
|
|
21
|
+
* - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to false.
|
|
22
|
+
* - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.
|
|
23
|
+
* - autoLink: A boolean that enables or disables automatic hyperlink creation when pasting or typing content. Defaults to false.
|
|
24
|
+
* - autoUnlink: A boolean that enables or disables automatic hyperlink removal when pressing backspace. Defaults to false.
|
|
23
25
|
*/
|
|
24
26
|
function AutoFormatPlugin(options) {
|
|
25
27
|
if (options === void 0) { options = DefaultOptions; }
|
|
@@ -58,6 +60,9 @@ var AutoFormatPlugin = /** @class */ (function () {
|
|
|
58
60
|
AutoFormatPlugin.prototype.onPluginEvent = function (event) {
|
|
59
61
|
if (this.editor) {
|
|
60
62
|
switch (event.eventType) {
|
|
63
|
+
case 'input':
|
|
64
|
+
this.handleEditorInputEvent(this.editor, event);
|
|
65
|
+
break;
|
|
61
66
|
case 'keyDown':
|
|
62
67
|
this.handleKeyDownEvent(this.editor, event);
|
|
63
68
|
break;
|
|
@@ -67,19 +72,26 @@ var AutoFormatPlugin = /** @class */ (function () {
|
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
};
|
|
70
|
-
AutoFormatPlugin.prototype.
|
|
75
|
+
AutoFormatPlugin.prototype.handleEditorInputEvent = function (editor, event) {
|
|
71
76
|
var rawEvent = event.rawEvent;
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
switch (rawEvent.key) {
|
|
77
|
+
if (rawEvent.inputType === 'insertText') {
|
|
78
|
+
switch (rawEvent.data) {
|
|
75
79
|
case ' ':
|
|
76
|
-
|
|
80
|
+
var _a = this.options, autoBullet = _a.autoBullet, autoNumbering = _a.autoNumbering, autoLink = _a.autoLink;
|
|
81
|
+
keyboardListTrigger(editor, autoBullet, autoNumbering);
|
|
77
82
|
if (autoLink) {
|
|
78
83
|
createLinkAfterSpace(editor);
|
|
79
84
|
}
|
|
80
85
|
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
AutoFormatPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
90
|
+
var rawEvent = event.rawEvent;
|
|
91
|
+
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
92
|
+
switch (rawEvent.key) {
|
|
81
93
|
case 'Backspace':
|
|
82
|
-
if (autoUnlink) {
|
|
94
|
+
if (this.options.autoUnlink) {
|
|
83
95
|
unlink(editor, rawEvent);
|
|
84
96
|
}
|
|
85
97
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoFormatPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoFormatPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts"],"names":[],"mappings":"AAAA,OA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O,iDAAsB,GAA9B,UAA+B,MAAe,EAAE,KAAuB;QACnE,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAI,QAAQ,CAAC,SAAS,KAAK,YAAY,EAAE;YACrC,QAAQ,QAAQ,CAAC,IAAI,EAAE;gBACnB,KAAK,GAAG;oBACE,IAAA,KAA0C,IAAI,CAAC,OAAO,EAApD,UAAU,gBAAA,EAAE,aAAa,mBAAA,EAAE,QAAQ,cAAiB,CAAC;oBAC7D,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;oBACvD,IAAI,QAAQ,EAAE;wBACV,oBAAoB,CAAC,MAAM,CAAC,CAAC;qBAChC;oBACD,MAAM;aACb;SACJ;IACL,CAAC;IAEO,6CAAkB,GAA1B,UAA2B,MAAe,EAAE,KAAmB;QAC3D,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;YAC3D,QAAQ,QAAQ,CAAC,GAAG,EAAE;gBAClB,KAAK,WAAW;oBACZ,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;wBACzB,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;qBAC5B;oBACD,MAAM;aACb;SACJ;IACL,CAAC;IAEO,oDAAyB,GAAjC,UAAkC,MAAe,EAAE,KAA0B;QACjE,IAAA,QAAQ,GAAK,IAAI,CAAC,OAAO,SAAjB,CAAkB;QAClC,IAAI,KAAK,CAAC,MAAM,IAAI,OAAO,IAAI,QAAQ,EAAE;YACrC,UAAU,CAAC,MAAM,CAAC,CAAC;SACtB;IACL,CAAC;IACL,uBAAC;AAAD,CAAC,AA9FD,IA8FC","sourcesContent":["import { createLink } from './link/createLink';\nimport { createLinkAfterSpace } from './link/createLinkAfterSpace';\nimport { keyboardListTrigger } from './list/keyboardListTrigger';\nimport { unlink } from './link/unlink';\nimport type {\n ContentChangedEvent,\n EditorInputEvent,\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Options to customize the Content Model Auto Format Plugin\n */\nexport type AutoFormatOptions = {\n /**\n * When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true\n */\n autoBullet: boolean;\n\n /**\n * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true\n */\n autoNumbering: boolean;\n\n /**\n * When press backspace before a link, remove the hyperlink\n */\n autoUnlink: boolean;\n\n /**\n * When paste content, create hyperlink for the pasted link\n */\n autoLink: boolean;\n};\n\n/**\n * @internal\n */\nconst DefaultOptions: Required<AutoFormatOptions> = {\n autoBullet: false,\n autoNumbering: false,\n autoUnlink: false,\n autoLink: false,\n};\n\n/**\n * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.\n * It can be customized with options to enable or disable auto list features.\n */\nexport class AutoFormatPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n\n /**\n * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:\n * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to false.\n * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.\n * - autoLink: A boolean that enables or disables automatic hyperlink creation when pasting or typing content. Defaults to false.\n * - autoUnlink: A boolean that enables or disables automatic hyperlink removal when pressing backspace. Defaults to false.\n */\n constructor(private options: AutoFormatOptions = DefaultOptions) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'AutoFormat';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case 'input':\n this.handleEditorInputEvent(this.editor, event);\n break;\n case 'keyDown':\n this.handleKeyDownEvent(this.editor, event);\n break;\n case 'contentChanged':\n this.handleContentChangedEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleEditorInputEvent(editor: IEditor, event: EditorInputEvent) {\n const rawEvent = event.rawEvent;\n if (rawEvent.inputType === 'insertText') {\n switch (rawEvent.data) {\n case ' ':\n const { autoBullet, autoNumbering, autoLink } = this.options;\n keyboardListTrigger(editor, autoBullet, autoNumbering);\n if (autoLink) {\n createLinkAfterSpace(editor);\n }\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n switch (rawEvent.key) {\n case 'Backspace':\n if (this.options.autoUnlink) {\n unlink(editor, rawEvent);\n }\n break;\n }\n }\n }\n\n private handleContentChangedEvent(editor: IEditor, event: ContentChangedEvent) {\n const { autoLink } = this.options;\n if (event.source == 'Paste' && autoLink) {\n createLink(editor);\n }\n }\n}\n"]}
|
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-core';
|
|
1
|
+
import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';
|
|
3
2
|
import { matchLink } from 'roosterjs-content-model-api';
|
|
3
|
+
import { splitTextSegment } from '../../pluginUtils/splitTextSegment';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
7
|
export function createLinkAfterSpace(editor) {
|
|
8
|
-
editor.formatContentModel(function (model) {
|
|
8
|
+
editor.formatContentModel(function (model, context) {
|
|
9
9
|
var selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, false /* includingFormatHolder */);
|
|
10
|
-
if (selectedSegmentsAndParagraphs
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
textSegment.
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
if (selectedSegmentsAndParagraphs.length > 0 && selectedSegmentsAndParagraphs[0][1]) {
|
|
11
|
+
var markerIndex = selectedSegmentsAndParagraphs[0][1].segments.findIndex(function (segment) { return segment.segmentType == 'SelectionMarker'; });
|
|
12
|
+
var paragraph = selectedSegmentsAndParagraphs[0][1];
|
|
13
|
+
if (markerIndex > 0) {
|
|
14
|
+
var textSegment = paragraph.segments[markerIndex - 1];
|
|
15
|
+
var marker = paragraph.segments[markerIndex];
|
|
16
|
+
if (marker.segmentType == 'SelectionMarker' &&
|
|
17
|
+
textSegment &&
|
|
18
|
+
textSegment.segmentType == 'Text' &&
|
|
19
|
+
!textSegment.link) {
|
|
20
|
+
var link = textSegment.text.split(' ').pop();
|
|
21
|
+
var url = link === null || link === void 0 ? void 0 : link.trim();
|
|
22
|
+
var linkData = null;
|
|
23
|
+
if (url && link && (linkData = matchLink(url))) {
|
|
24
|
+
var linkSegment = splitTextSegment(textSegment, paragraph, textSegment.text.length - link.trimLeft().length, textSegment.text.trimRight().length);
|
|
25
|
+
linkSegment.link = {
|
|
26
|
+
format: {
|
|
27
|
+
href: linkData.normalizedUrl,
|
|
28
|
+
underline: true,
|
|
29
|
+
},
|
|
30
|
+
dataset: {},
|
|
31
|
+
};
|
|
32
|
+
context.canUndoByBackspace = true;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLinkAfterSpace.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"createLinkAfterSpace.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAe;IAChD,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,OAAO;QACrC,IAAM,6BAA6B,GAAG,gCAAgC,CAClE,KAAK,EACL,KAAK,CAAC,2BAA2B,CACpC,CAAC;QACF,IAAI,6BAA6B,CAAC,MAAM,GAAG,CAAC,IAAI,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACjF,IAAM,WAAW,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CACtE,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,WAAW,IAAI,iBAAiB,EAAxC,CAAwC,CACtD,CAAC;YACF,IAAM,SAAS,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,IAAI,WAAW,GAAG,CAAC,EAAE;gBACjB,IAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;gBACxD,IAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;gBAC/C,IACI,MAAM,CAAC,WAAW,IAAI,iBAAiB;oBACvC,WAAW;oBACX,WAAW,CAAC,WAAW,IAAI,MAAM;oBACjC,CAAC,WAAW,CAAC,IAAI,EACnB;oBACE,IAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;oBAC/C,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;oBACzB,IAAI,QAAQ,GAAoB,IAAI,CAAC;oBACrC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE;wBAC5C,IAAM,WAAW,GAAG,gBAAgB,CAChC,WAAW,EACX,SAAS,EACT,WAAW,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAChD,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CACtC,CAAC;wBACF,WAAW,CAAC,IAAI,GAAG;4BACf,MAAM,EAAE;gCACJ,IAAI,EAAE,QAAQ,CAAC,aAAa;gCAC5B,SAAS,EAAE,IAAI;6BAClB;4BACD,OAAO,EAAE,EAAE;yBACd,CAAC;wBAEF,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;wBAElC,OAAO,IAAI,CAAC;qBACf;iBACJ;aACJ;SACJ;QAED,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport { matchLink } from 'roosterjs-content-model-api';\nimport { splitTextSegment } from '../../pluginUtils/splitTextSegment';\nimport type { IEditor, LinkData } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function createLinkAfterSpace(editor: IEditor) {\n editor.formatContentModel((model, context) => {\n const selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n false /* includingFormatHolder */\n );\n if (selectedSegmentsAndParagraphs.length > 0 && selectedSegmentsAndParagraphs[0][1]) {\n const markerIndex = selectedSegmentsAndParagraphs[0][1].segments.findIndex(\n segment => segment.segmentType == 'SelectionMarker'\n );\n const paragraph = selectedSegmentsAndParagraphs[0][1];\n if (markerIndex > 0) {\n const textSegment = paragraph.segments[markerIndex - 1];\n const marker = paragraph.segments[markerIndex];\n if (\n marker.segmentType == 'SelectionMarker' &&\n textSegment &&\n textSegment.segmentType == 'Text' &&\n !textSegment.link\n ) {\n const link = textSegment.text.split(' ').pop();\n const url = link?.trim();\n let linkData: LinkData | null = null;\n if (url && link && (linkData = matchLink(url))) {\n const linkSegment = splitTextSegment(\n textSegment,\n paragraph,\n textSegment.text.length - link.trimLeft().length,\n textSegment.text.trimRight().length\n );\n linkSegment.link = {\n format: {\n href: linkData.normalizedUrl,\n underline: true,\n },\n dataset: {},\n };\n\n context.canUndoByBackspace = true;\n\n return true;\n }\n }\n }\n }\n\n return false;\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLinkSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/getLinkSegment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getLinkSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/getLinkSegment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAGxD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAA2B;IACtD,IAAM,6BAA6B,GAAG,gCAAgC,CAClE,KAAK,EACL,KAAK,CAAC,2BAA2B,CACpC,CAAC;IACF,IAAI,6BAA6B,CAAC,MAAM,IAAI,CAAC,IAAI,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;QAClF,IAAM,iBAAiB,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,IAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjF,IAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/E,IACI,MAAM;YACN,IAAI;YACJ,MAAM,CAAC,WAAW,KAAK,iBAAiB;YACxC,MAAM,CAAC,UAAU;YACjB,IAAI,CAAC,WAAW,KAAK,MAAM;YAC3B,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EACrC;YACE,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport { matchLink } from 'roosterjs-content-model-api';\nimport type { ContentModelDocument } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function getLinkSegment(model: ContentModelDocument) {\n const selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n false /* includingFormatHolder */\n );\n if (selectedSegmentsAndParagraphs.length == 1 && selectedSegmentsAndParagraphs[0][1]) {\n const selectedParagraph = selectedSegmentsAndParagraphs[0][1];\n const marker = selectedParagraph.segments[selectedParagraph.segments.length - 1];\n const link = selectedParagraph.segments[selectedParagraph.segments.length - 2];\n if (\n marker &&\n link &&\n marker.segmentType === 'SelectionMarker' &&\n marker.isSelected &&\n link.segmentType === 'Text' &&\n (matchLink(link.text) || link.link)\n ) {\n return link;\n }\n }\n return undefined;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { findListItemsInSameThread } from 'roosterjs-content-model-api';
|
|
2
2
|
import { getNumberingListStyle } from './getNumberingListStyle';
|
|
3
|
-
import { BulletListType, isBlockGroupOfType, updateListMetadata, getOperationalBlocks, getSelectedSegmentsAndParagraphs, } from 'roosterjs-content-model-
|
|
3
|
+
import { BulletListType, isBlockGroupOfType, updateListMetadata, getOperationalBlocks, getSelectedSegmentsAndParagraphs, } from 'roosterjs-content-model-dom';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
@@ -80,7 +80,7 @@ var bulletListType = {
|
|
|
80
80
|
'—': BulletListType.Hyphen,
|
|
81
81
|
};
|
|
82
82
|
var isNewList = function (listMarker) {
|
|
83
|
-
var marker = listMarker.replace(/[^\w\s]/g, '');
|
|
83
|
+
var marker = listMarker.replace(/[^\w\s]/g, '').trim();
|
|
84
84
|
var pattern = /^[1aAiI]$/;
|
|
85
85
|
return pattern.test(marker);
|
|
86
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getListTypeStyle.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/list/getListTypeStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,OAAO,EACH,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,gCAAgC,GACnC,MAAM,
|
|
1
|
+
{"version":3,"file":"getListTypeStyle.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/list/getListTypeStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,OAAO,EACH,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,gCAAgC,GACnC,MAAM,6BAA6B,CAAC;AAWrC;;GAEG;AACH,MAAM,UAAU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AM,CAAC,CAAC,EAAE,OAAO,EAAE;QACzB,OAAO,MAAA,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,0CAAE,gBAAgB,CAAC;KAC/D;AACL,CAAC,CAAC;AAEF,IAAM,cAAc,GAA2B;IAC3C,GAAG,EAAE,cAAc,CAAC,IAAI;IACxB,GAAG,EAAE,cAAc,CAAC,IAAI;IACxB,IAAI,EAAE,cAAc,CAAC,MAAM;IAC3B,IAAI,EAAE,cAAc,CAAC,SAAS;IAC9B,KAAK,EAAE,cAAc,CAAC,eAAe;IACrC,IAAI,EAAE,cAAc,CAAC,aAAa;IAClC,GAAG,EAAE,cAAc,CAAC,UAAU;IAC9B,GAAG,EAAE,cAAc,CAAC,MAAM;CAC7B,CAAC;AAEF,IAAM,SAAS,GAAG,UAAC,UAAkB;IACjC,IAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACzD,IAAM,OAAO,GAAG,WAAW,CAAC;IAC5B,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["import { findListItemsInSameThread } from 'roosterjs-content-model-api';\nimport { getNumberingListStyle } from './getNumberingListStyle';\nimport type {\n ContentModelDocument,\n ContentModelListItem,\n ContentModelParagraph,\n} from 'roosterjs-content-model-types';\nimport {\n BulletListType,\n isBlockGroupOfType,\n updateListMetadata,\n getOperationalBlocks,\n getSelectedSegmentsAndParagraphs,\n} from 'roosterjs-content-model-dom';\n\n/**\n * @internal\n */\ninterface ListTypeStyle {\n listType: 'UL' | 'OL';\n styleType: number;\n index?: number;\n}\n\n/**\n * @internal\n */\nexport function getListTypeStyle(\n model: ContentModelDocument,\n shouldSearchForBullet: boolean = true,\n shouldSearchForNumbering: boolean = true\n): ListTypeStyle | undefined {\n const selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, true);\n if (!selectedSegmentsAndParagraphs[0]) {\n return undefined;\n }\n const marker = selectedSegmentsAndParagraphs[0][0];\n const paragraph = selectedSegmentsAndParagraphs[0][1];\n const listMarkerSegment = paragraph?.segments[0];\n\n if (\n marker &&\n marker.segmentType == 'SelectionMarker' &&\n listMarkerSegment &&\n listMarkerSegment.segmentType == 'Text'\n ) {\n const listMarker = listMarkerSegment.text;\n const bulletType = bulletListType[listMarker];\n\n if (bulletType && shouldSearchForBullet) {\n return { listType: 'UL', styleType: bulletType };\n } else if (shouldSearchForNumbering) {\n const previousList = getPreviousListLevel(model, paragraph);\n const previousIndex = getPreviousListIndex(model, previousList);\n const previousListStyle = getPreviousListStyle(previousList);\n const numberingType = getNumberingListStyle(\n listMarker,\n previousIndex,\n previousListStyle\n );\n\n if (numberingType) {\n return {\n listType: 'OL',\n styleType: numberingType,\n index:\n !isNewList(listMarker) &&\n previousListStyle === numberingType &&\n previousIndex\n ? previousIndex + 1\n : undefined,\n };\n }\n }\n }\n return undefined;\n}\n\nconst getPreviousListIndex = (\n model: ContentModelDocument,\n previousListItem?: ContentModelListItem\n) => {\n return previousListItem ? findListItemsInSameThread(model, previousListItem).length : undefined;\n};\n\nconst getPreviousListLevel = (model: ContentModelDocument, paragraph: ContentModelParagraph) => {\n const blocks = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n )[0];\n let listItem: ContentModelListItem | undefined = undefined;\n if (blocks) {\n const listBlockIndex = blocks.parent.blocks.indexOf(paragraph);\n\n if (listBlockIndex > -1) {\n for (let i = listBlockIndex - 1; i > -1; i--) {\n const item = blocks.parent.blocks[i];\n if (isBlockGroupOfType<ContentModelListItem>(item, 'ListItem')) {\n listItem = item;\n break;\n }\n }\n }\n }\n\n return listItem;\n};\n\nconst getPreviousListStyle = (list?: ContentModelListItem) => {\n if (list?.levels[0].dataset) {\n return updateListMetadata(list.levels[0])?.orderedStyleType;\n }\n};\n\nconst bulletListType: Record<string, number> = {\n '*': BulletListType.Disc,\n '-': BulletListType.Dash,\n '--': BulletListType.Square,\n '->': BulletListType.LongArrow,\n '-->': BulletListType.DoubleLongArrow,\n '=>': BulletListType.UnfilledArrow,\n '>': BulletListType.ShortArrow,\n '—': BulletListType.Hyphen,\n};\n\nconst isNewList = (listMarker: string) => {\n const marker = listMarker.replace(/[^\\w\\s]/g, '').trim();\n const pattern = /^[1aAiI]$/;\n return pattern.test(marker);\n};\n"]}
|