roosterjs-content-model-plugins 0.22.1 → 0.24.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/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib/edit/ContentModelEditPlugin.js +1 -2
- package/lib/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib/edit/deleteSteps/deleteList.js +24 -0
- package/lib/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib/edit/deleteSteps/deleteWordSelection.js +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib/edit/handleKeyboardEventCommon.js +1 -1
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib/edit/keyboardDelete.d.ts +2 -2
- package/lib/edit/keyboardDelete.js +8 -1
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.d.ts +2 -2
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/paste/ContentModelPastePlugin.d.ts +3 -4
- package/lib/paste/ContentModelPastePlugin.js +17 -36
- package/lib/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib/paste/WacComponents/constants.d.ts +0 -8
- package/lib/paste/WacComponents/constants.js +1 -24
- package/lib/paste/WacComponents/constants.js.map +1 -1
- package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib/paste/WacComponents/processPastedContentWacComponents.js +61 -65
- package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib/paste/WordDesktop/getStyleMetadata.js +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -19
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/WordDesktop/processWordLists.js +39 -12
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js +14 -0
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib/paste/pasteSourceValidations/constants.js +5 -6
- package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -2
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib/paste/utils/addParser.d.ts +2 -2
- package/lib/paste/utils/addParser.js.map +1 -1
- package/lib-amd/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib-amd/edit/ContentModelEditPlugin.js +1 -2
- package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib-amd/edit/deleteSteps/deleteList.js +25 -0
- package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib-amd/edit/handleKeyboardEventCommon.js +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.d.ts +2 -2
- package/lib-amd/edit/keyboardDelete.js +8 -2
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.d.ts +2 -2
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/paste/ContentModelPastePlugin.d.ts +3 -4
- package/lib-amd/paste/ContentModelPastePlugin.js +17 -36
- package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-amd/paste/WacComponents/constants.d.ts +0 -8
- package/lib-amd/paste/WacComponents/constants.js +1 -24
- package/lib-amd/paste/WacComponents/constants.js.map +1 -1
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +61 -66
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -18
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordLists.js +39 -13
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js +16 -0
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib-amd/paste/pasteSourceValidations/constants.js +5 -6
- package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -3
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-amd/paste/utils/addParser.d.ts +2 -2
- package/lib-amd/paste/utils/addParser.js.map +1 -1
- package/lib-mjs/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib-mjs/edit/ContentModelEditPlugin.js +1 -2
- package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib-mjs/edit/deleteSteps/deleteList.js +20 -0
- package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +1 -1
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib-mjs/edit/handleKeyboardEventCommon.js +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.d.ts +2 -2
- package/lib-mjs/edit/keyboardDelete.js +8 -1
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.d.ts +2 -2
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/paste/ContentModelPastePlugin.d.ts +3 -4
- package/lib-mjs/paste/ContentModelPastePlugin.js +17 -36
- package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-mjs/paste/WacComponents/constants.d.ts +0 -8
- package/lib-mjs/paste/WacComponents/constants.js +0 -23
- package/lib-mjs/paste/WacComponents/constants.js.map +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +63 -67
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -19
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordLists.js +40 -13
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js +10 -0
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib-mjs/paste/pasteSourceValidations/constants.js +5 -6
- package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -2
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/utils/addParser.d.ts +2 -2
- package/lib-mjs/paste/utils/addParser.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":";;;;IAuBA;;;;;OAKG;IACH,SAAgB,cAAc,CAAC,MAAyB,EAAE,QAAuB;QAC7E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,4BAA4B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YACnD,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAC1B,KAAK,EACL,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,EACzD,OAAO,CACV,CAAC,YAAY,CAAC;gBAEf,OAAO,IAAA,qDAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC/E,CAAC,EACD;gBACI,QAAQ,UAAA;gBACR,YAAY,EAAE,2CAAY,CAAC,QAAQ;gBACnC,aAAa,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,EAAd,CAAc;gBACnC,OAAO,EAAE,QAAQ,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,oBAAoB;aAC/E,CACJ,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAxBD,wCAwBC;IAED,SAAS,cAAc,CAAC,QAAuB,EAAE,KAAc;QAC3D,IAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,IAAI,QAAQ,C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AAQ,CAAC,GAAG,IAAI,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;IAChE,CAAC;IAED,SAAS,cAAc,CAAC,QAAuB,EAAE,KAAY;;QACzD,OAAO,CACH,QAAQ,CAAC,GAAG,IAAI,QAAQ;YACxB,KAAK,CAAC,WAAW,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,cAAc,CAAC,SAAS,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CACxE,CAAC;IACN,CAAC","sourcesContent":["import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\nimport { deleteList } from './deleteSteps/deleteList';\nimport { isNodeOfType } from 'roosterjs-content-model-dom';\nimport {\n handleKeyboardEventResult,\n shouldDeleteAllSegmentsBefore,\n shouldDeleteWord,\n} from './handleKeyboardEventCommon';\nimport {\n backwardDeleteWordSelection,\n forwardDeleteWordSelection,\n} from './deleteSteps/deleteWordSelection';\nimport {\n backwardDeleteCollapsedSelection,\n forwardDeleteCollapsedSelection,\n} from './deleteSteps/deleteCollapsedSelection';\nimport type {\n DOMSelection,\n DeleteSelectionStep,\n IStandaloneEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Do keyboard event handling for DELETE/BACKSPACE key\n * @param editor The Content Model Editor\n * @param rawEvent DOM keyboard event\n */\nexport function keyboardDelete(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldDeleteWithContentModel(selection, rawEvent)) {\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(\n model,\n getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac),\n context\n ).deleteResult;\n\n return handleKeyboardEventResult(editor, model, rawEvent, result, context);\n },\n {\n rawEvent,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',\n }\n );\n\n return true;\n }\n}\n\nfunction getDeleteSteps(rawEvent: KeyboardEvent, isMac: boolean): (DeleteSelectionStep | null)[] {\n const isForward = rawEvent.key == 'Delete';\n const deleteAllSegmentBeforeStep =\n shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;\n const deleteWordSelection = shouldDeleteWord(rawEvent, isMac)\n ? isForward\n ? forwardDeleteWordSelection\n : backwardDeleteWordSelection\n : null;\n const deleteCollapsedSelection = isForward\n ? forwardDeleteCollapsedSelection\n : backwardDeleteCollapsedSelection;\n const deleteListStep = !isForward ? deleteList : null;\n return [\n deleteAllSegmentBeforeStep,\n deleteWordSelection,\n deleteCollapsedSelection,\n deleteListStep,\n ];\n}\n\nfunction shouldDeleteWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (selection.type != 'range' || !selection.range.collapsed) {\n return true; // Selection is not collapsed, need to delete all selections\n } else {\n const range = selection.range;\n\n // When selection is collapsed and is in middle of text node, no need to use Content Model to delete\n return !(\n isNodeOfType(range.startContainer, 'TEXT_NODE') &&\n !isModifierKey(rawEvent) &&\n (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range))\n );\n }\n}\n\nfunction canDeleteBefore(rawEvent: KeyboardEvent, range: Range) {\n return rawEvent.key == 'Backspace' && range.startOffset > 1;\n}\n\nfunction canDeleteAfter(rawEvent: KeyboardEvent, range: Range) {\n return (\n rawEvent.key == 'Delete' &&\n range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function keyboardInput(editor:
|
|
5
|
+
export declare function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,aAAa,CAAC,MAAyB,EAAE,QAAuB;QAC5E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE;YACpE,MAAM,CAAC,YAAY,EAAE,CAAC;YAEtB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEnD,0EAA0E;gBAC1E,qFAAqF;gBACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBAE/B,oJAAoJ;gBACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;oBAChC,2HAA2H;oBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;oBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;oBAE7B,sFAAsF;oBACtF,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD;gBACI,QAAQ,UAAA;aACX,CACJ,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IApCD,sCAoCC;IAED,SAAS,2BAA2B,CAChC,SAA8B,EAC9B,QAAuB,EACvB,OAAgB;QAEhB,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;SACrC;aAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;YACE,OAAO,CACH,SAAS,CAAC,IAAI,IAAI,OAAO;gBACzB,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,CACpE,CAAC,CAAC,0DAA0D;SAChE;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { DOMSelection, IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {\n editor.takeSnapshot();\n\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(model, [], context);\n\n // We have deleted selection then we will let browser to handle the input.\n // With this combined operation, we don't wan to mass up the cached model so clear it\n context.clearModelCache = true;\n\n // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation\n context.skipUndoSnapshot = true;\n\n if (result.deleteResult == 'range') {\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\n context.newPendingFormat = result.insertPoint?.marker.format;\n\n normalizeContentModel(model);\n\n // Do not preventDefault since we still want browser to handle the final input for now\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n }\n );\n\n return true;\n }\n}\n\nfunction shouldInputWithContentModel(\n selection: DOMSelection | null,\n rawEvent: KeyboardEvent,\n isInIME: boolean\n) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (\n !isModifierKey(rawEvent) &&\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\n ) {\n return (\n selection.type != 'range' ||\n (!selection.range.collapsed && !rawEvent.isComposing && !isInIME)\n ); // TODO: Also handle Enter key even selection is collapsed\n } else {\n return false;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EditorPlugin,
|
|
1
|
+
import type { EditorPlugin, IStandaloneEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
4
4
|
* 1. Content copied from Word
|
|
@@ -8,7 +8,6 @@ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types'
|
|
|
8
8
|
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
9
9
|
*/
|
|
10
10
|
export declare class ContentModelPastePlugin implements EditorPlugin {
|
|
11
|
-
private unknownTagReplacement;
|
|
12
11
|
private allowExcelNoBorderTable?;
|
|
13
12
|
private editor;
|
|
14
13
|
/**
|
|
@@ -16,7 +15,7 @@ export declare class ContentModelPastePlugin implements EditorPlugin {
|
|
|
16
15
|
* @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
|
|
17
16
|
* @param allowExcelNoBorderTable Allow table copied from Excel without border
|
|
18
17
|
*/
|
|
19
|
-
constructor(
|
|
18
|
+
constructor(allowExcelNoBorderTable?: boolean | undefined);
|
|
20
19
|
/**
|
|
21
20
|
* Get name of this plugin
|
|
22
21
|
*/
|
|
@@ -27,7 +26,7 @@ export declare class ContentModelPastePlugin implements EditorPlugin {
|
|
|
27
26
|
* editor reference so that it can call to any editor method or format API later.
|
|
28
27
|
* @param editor The editor object
|
|
29
28
|
*/
|
|
30
|
-
initialize(editor:
|
|
29
|
+
initialize(editor: IStandaloneEditor): void;
|
|
31
30
|
/**
|
|
32
31
|
* The last method that editor will call to a plugin before it is disposed.
|
|
33
32
|
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom", "
|
|
1
|
+
define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom", "./utils/deprecatedColorParser", "./pasteSourceValidations/getPasteSource", "./utils/linkParser", "./pasteSourceValidations/constants", "./Excel/processPastedContentFromExcel", "./PowerPoint/processPastedContentFromPowerPoint", "./WordDesktop/processPastedContentFromWordDesktop", "./WacComponents/processPastedContentWacComponents"], function (require, exports, addParser_1, roosterjs_content_model_dom_1, deprecatedColorParser_1, getPasteSource_1, linkParser_1, constants_1, processPastedContentFromExcel_1, processPastedContentFromPowerPoint_1, processPastedContentFromWordDesktop_1, processPastedContentWacComponents_1) {
|
|
2
2
|
"use strict";
|
|
3
|
-
var _a;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
4
|
exports.ContentModelPastePlugin = void 0;
|
|
6
|
-
// Map old PasteType to new PasteType
|
|
7
|
-
// TODO: We can remove this once we have standalone editor
|
|
8
|
-
var PasteTypeMap = (_a = {},
|
|
9
|
-
_a[3 /* AsImage */] = 'asImage',
|
|
10
|
-
_a[1 /* AsPlainText */] = 'asPlainText',
|
|
11
|
-
_a[2 /* MergeFormat */] = 'mergeFormat',
|
|
12
|
-
_a[0 /* Normal */] = 'normal',
|
|
13
|
-
_a);
|
|
14
5
|
/**
|
|
15
6
|
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
16
7
|
* 1. Content copied from Word
|
|
@@ -25,9 +16,7 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
|
|
|
25
16
|
* @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
|
|
26
17
|
* @param allowExcelNoBorderTable Allow table copied from Excel without border
|
|
27
18
|
*/
|
|
28
|
-
function ContentModelPastePlugin(
|
|
29
|
-
if (unknownTagReplacement === void 0) { unknownTagReplacement = 'SPAN'; }
|
|
30
|
-
this.unknownTagReplacement = unknownTagReplacement;
|
|
19
|
+
function ContentModelPastePlugin(allowExcelNoBorderTable) {
|
|
31
20
|
this.allowExcelNoBorderTable = allowExcelNoBorderTable;
|
|
32
21
|
this.editor = null;
|
|
33
22
|
}
|
|
@@ -62,46 +51,43 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
|
|
|
62
51
|
* @param event The event to handle:
|
|
63
52
|
*/
|
|
64
53
|
ContentModelPastePlugin.prototype.onPluginEvent = function (event) {
|
|
65
|
-
if (!this.editor || event.eventType !=
|
|
54
|
+
if (!this.editor || event.eventType != 'beforePaste') {
|
|
66
55
|
return;
|
|
67
56
|
}
|
|
68
|
-
|
|
69
|
-
if (!ev.domToModelOption) {
|
|
57
|
+
if (!event.domToModelOption) {
|
|
70
58
|
return;
|
|
71
59
|
}
|
|
72
|
-
var pasteSource = (0, getPasteSource_1.getPasteSource)(
|
|
73
|
-
var pasteType =
|
|
60
|
+
var pasteSource = (0, getPasteSource_1.getPasteSource)(event, false);
|
|
61
|
+
var pasteType = event.pasteType;
|
|
74
62
|
switch (pasteSource) {
|
|
75
63
|
case 'wordDesktop':
|
|
76
|
-
(0, processPastedContentFromWordDesktop_1.processPastedContentFromWordDesktop)(
|
|
64
|
+
(0, processPastedContentFromWordDesktop_1.processPastedContentFromWordDesktop)(event, this.editor.getTrustedHTMLHandler());
|
|
77
65
|
break;
|
|
78
66
|
case 'wacComponents':
|
|
79
|
-
(0, processPastedContentWacComponents_1.processPastedContentWacComponents)(
|
|
67
|
+
(0, processPastedContentWacComponents_1.processPastedContentWacComponents)(event);
|
|
80
68
|
break;
|
|
81
69
|
case 'excelOnline':
|
|
82
70
|
case 'excelDesktop':
|
|
83
71
|
if (pasteType === 'normal' || pasteType === 'mergeFormat') {
|
|
84
72
|
// Handle HTML copied from Excel
|
|
85
|
-
(0, processPastedContentFromExcel_1.processPastedContentFromExcel)(
|
|
73
|
+
(0, processPastedContentFromExcel_1.processPastedContentFromExcel)(event, this.editor.getTrustedHTMLHandler(), this.allowExcelNoBorderTable);
|
|
86
74
|
}
|
|
87
75
|
break;
|
|
88
76
|
case 'googleSheets':
|
|
89
|
-
|
|
77
|
+
event.domToModelOption.additionalAllowedTags.push(constants_1.PastePropertyNames.GOOGLE_SHEET_NODE_NAME);
|
|
90
78
|
break;
|
|
91
79
|
case 'powerPointDesktop':
|
|
92
|
-
(0, processPastedContentFromPowerPoint_1.processPastedContentFromPowerPoint)(
|
|
80
|
+
(0, processPastedContentFromPowerPoint_1.processPastedContentFromPowerPoint)(event, this.editor.getTrustedHTMLHandler());
|
|
93
81
|
break;
|
|
94
82
|
}
|
|
95
|
-
(0, addParser_1.default)(
|
|
96
|
-
(0, addParser_1.default)(
|
|
97
|
-
(0, addParser_1.default)(
|
|
98
|
-
(0, addParser_1.default)(
|
|
99
|
-
sanitizeBlockStyles(ev.sanitizingOption);
|
|
83
|
+
(0, addParser_1.default)(event.domToModelOption, 'link', linkParser_1.parseLink);
|
|
84
|
+
(0, addParser_1.default)(event.domToModelOption, 'tableCell', deprecatedColorParser_1.deprecatedBorderColorParser);
|
|
85
|
+
(0, addParser_1.default)(event.domToModelOption, 'tableCell', tableBorderParser);
|
|
86
|
+
(0, addParser_1.default)(event.domToModelOption, 'table', deprecatedColorParser_1.deprecatedBorderColorParser);
|
|
100
87
|
if (pasteType === 'mergeFormat') {
|
|
101
|
-
(0, addParser_1.default)(
|
|
102
|
-
(0, addParser_1.default)(
|
|
88
|
+
(0, addParser_1.default)(event.domToModelOption, 'block', blockElementParser);
|
|
89
|
+
(0, addParser_1.default)(event.domToModelOption, 'listLevel', blockElementParser);
|
|
103
90
|
}
|
|
104
|
-
ev.sanitizingOption.unknownTagReplacement = this.unknownTagReplacement;
|
|
105
91
|
};
|
|
106
92
|
return ContentModelPastePlugin;
|
|
107
93
|
}());
|
|
@@ -115,11 +101,6 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
|
|
|
115
101
|
delete format.backgroundColor;
|
|
116
102
|
}
|
|
117
103
|
};
|
|
118
|
-
function sanitizeBlockStyles(sanitizingOption) {
|
|
119
|
-
(0, roosterjs_editor_dom_1.chainSanitizerCallback)(sanitizingOption.cssStyleCallbacks, 'display', function (value) {
|
|
120
|
-
return value != 'flex'; // return whether we keep the style
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
104
|
var ElementBorderKeys = new Map([
|
|
124
105
|
['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],
|
|
125
106
|
['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentModelPastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/ContentModelPastePlugin.ts"],"names":[],"mappings":";;;;;IA4BA,qCAAqC;IACrC,0DAA0D;IAC1D,IAAM,YAAY;QACd,sBAAwB,SAAS;QACjC,0BAA4B,aAAa;QACzC,0BAA4B,aAAa;QACzC,qBAAuB,QAAQ;WAClC,CAAC;IAEF;;;;;;;OAOG;IACH;QAGI;;;;WAIG;QACH,iCACY,qBAAsC,EACtC,uBAAiC;YADjC,sCAAA,EAAA,8BAAsC;YAAtC,0BAAqB,GAArB,qBAAqB,CAAiB;YACtC,4BAAuB,GAAvB,uBAAuB,CAAU;YATrC,WAAM,GAA+B,IAAI,CAAC;QAU/C,CAAC;QAEJ;;WAEG;QACH,yCAAO,GAAP;YACI,OAAO,mBAAmB,CAAC;QAC/B,CAAC;QAED;;;;;WAKG;QACH,4CAAU,GAAV,UAAW,MAAe;YACtB,gFAAgF;YAChF,IAAI,CAAC,MAAM,GAAG,MAA6B,CAAC;QAChD,CAAC;QAED;;;;WAIG;QACH,yCAAO,GAAP;YACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,C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C,EAAE,kBAAkB,EAAE,CAAC;QACxF,CAAC,cAAc,EAAE,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC;QAC5F,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC;KACvF,CAAC,CAAC;IAEH,SAAS,iBAAiB,CAAC,MAAmC,EAAE,OAAoB;QAChF,wCAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;gBACd,IAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC5C,IACI,QAAQ;oBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;oBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;iBAC7E;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { chainSanitizerCallback } from 'roosterjs-editor-dom';\nimport { deprecatedBorderColorParser } from './utils/deprecatedColorParser';\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\nimport { parseLink } from './utils/linkParser';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { PasteType as OldPasteType, PluginEventType } from 'roosterjs-editor-types';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type {\n BorderFormat,\n ContentModelBeforePasteEvent,\n ContentModelBlockFormat,\n ContentModelTableCellFormat,\n FormatParser,\n PasteType,\n} from 'roosterjs-content-model-types';\nimport type {\n EditorPlugin,\n HtmlSanitizerOptions,\n IEditor,\n PluginEvent,\n} from 'roosterjs-editor-types';\n\n// Map old PasteType to new PasteType\n// TODO: We can remove this once we have standalone editor\nconst PasteTypeMap: Record<OldPasteType, PasteType> = {\n [OldPasteType.AsImage]: 'asImage',\n [OldPasteType.AsPlainText]: 'asPlainText',\n [OldPasteType.MergeFormat]: 'mergeFormat',\n [OldPasteType.Normal]: 'normal',\n};\n\n/**\n * Paste plugin, handles BeforePaste event and reformat some special content, including:\n * 1. Content copied from Word\n * 2. Content copied from Excel\n * 3. Content copied from Word Online or OneNote Online\n * 4. Content copied from Power Point\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class ContentModelPastePlugin implements EditorPlugin {\n private editor: IContentModelEditor | null = null;\n\n /**\n * Construct a new instance of Paste class\n * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN\n * @param allowExcelNoBorderTable Allow table copied from Excel without border\n */\n constructor(\n private unknownTagReplacement: string = 'SPAN',\n private allowExcelNoBorderTable?: boolean\n ) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelPaste';\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 // TODO: Later we may need a different interface for Content Model editor plugin\n this.editor = editor as IContentModelEditor;\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 || event.eventType != PluginEventType.BeforePaste) {\n return;\n }\n\n const ev = event as ContentModelBeforePasteEvent;\n\n if (!ev.domToModelOption) {\n return;\n }\n\n const pasteSource = getPasteSource(ev, false);\n const pasteType = PasteTypeMap[ev.pasteType];\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(ev, this.editor.getTrustedHTMLHandler());\n break;\n case 'wacComponents':\n processPastedContentWacComponents(ev);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(\n ev,\n this.editor.getTrustedHTMLHandler(),\n this.allowExcelNoBorderTable\n );\n }\n break;\n case 'googleSheets':\n ev.sanitizingOption.additionalTagReplacements[\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME\n ] = '*';\n break;\n case 'powerPointDesktop':\n processPastedContentFromPowerPoint(ev, this.editor.getTrustedHTMLHandler());\n break;\n }\n\n addParser(ev.domToModelOption, 'link', parseLink);\n addParser(ev.domToModelOption, 'tableCell', deprecatedBorderColorParser);\n addParser(ev.domToModelOption, 'tableCell', tableBorderParser);\n addParser(ev.domToModelOption, 'table', deprecatedBorderColorParser);\n sanitizeBlockStyles(ev.sanitizingOption);\n\n if (pasteType === 'mergeFormat') {\n addParser(ev.domToModelOption, 'block', blockElementParser);\n addParser(ev.domToModelOption, 'listLevel', blockElementParser);\n }\n\n ev.sanitizingOption.unknownTagReplacement = this.unknownTagReplacement;\n }\n}\n\n/**\n * For block elements that have background color style, remove the background color when user selects the merge current format\n * paste option\n */\nconst blockElementParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.backgroundColor) {\n delete format.backgroundColor;\n }\n};\n\nfunction sanitizeBlockStyles(sanitizingOption: Required<HtmlSanitizerOptions>) {\n chainSanitizerCallback(sanitizingOption.cssStyleCallbacks, 'display', (value: string) => {\n return value != 'flex'; // return whether we keep the style\n });\n}\n\nconst ElementBorderKeys = new Map<\n keyof BorderFormat,\n {\n c: keyof CSSStyleDeclaration;\n s: keyof CSSStyleDeclaration;\n w: keyof CSSStyleDeclaration;\n }\n>([\n ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],\n ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],\n ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],\n ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],\n]);\n\nfunction tableBorderParser(format: ContentModelTableCellFormat, element: HTMLElement): void {\n BorderKeys.forEach(key => {\n if (!format[key]) {\n const styleSet = ElementBorderKeys.get(key);\n if (\n styleSet &&\n element.style[styleSet.w] &&\n element.style[styleSet.s] &&\n !element.style[styleSet.c]\n ) {\n format[key] = `${element.style[styleSet.w]} ${element.style[styleSet.s]}`;\n }\n }\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContentModelPastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/ContentModelPastePlugin.ts"],"names":[],"mappings":";;;;IAoBA;;;;;;;OAOG;IACH;QAGI;;;;WAIG;QACH,iCAAoB,uBAAiC;YAAjC,4BAAuB,GAAvB,uBAAuB,CAAU;YAP7C,WAAM,GAA6B,IAAI,CAAC;QAOQ,CAAC;QAEzD;;WAEG;QACH,yCAAO,GAAP;YACI,OAAO,mBAAmB,CAAC;QAC/B,CAAC;QAED;;;;;WAKG;QACH,4CAAU,GAAV,UAAW,MAAyB;YAChC,gFAAgF;YAChF,IAAI,CAAC,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E,iBAAiB,EAAE,CAAC;KACvF,CAAC,CAAC;IAEH,SAAS,iBAAiB,CAAC,MAAmC,EAAE,OAAoB;QAChF,wCAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;gBACd,IAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC5C,IACI,QAAQ;oBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;oBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;iBAC7E;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { deprecatedBorderColorParser } from './utils/deprecatedColorParser';\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\nimport { parseLink } from './utils/linkParser';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport type {\n BorderFormat,\n ContentModelBlockFormat,\n ContentModelTableCellFormat,\n EditorPlugin,\n FormatParser,\n IStandaloneEditor,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Paste plugin, handles BeforePaste event and reformat some special content, including:\n * 1. Content copied from Word\n * 2. Content copied from Excel\n * 3. Content copied from Word Online or OneNote Online\n * 4. Content copied from Power Point\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class ContentModelPastePlugin implements EditorPlugin {\n private editor: IStandaloneEditor | null = null;\n\n /**\n * Construct a new instance of Paste class\n * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN\n * @param allowExcelNoBorderTable Allow table copied from Excel without border\n */\n constructor(private allowExcelNoBorderTable?: boolean) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelPaste';\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: IStandaloneEditor) {\n // TODO: Later we may need a different interface for Content Model editor plugin\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 || event.eventType != 'beforePaste') {\n return;\n }\n\n if (!event.domToModelOption) {\n return;\n }\n\n const pasteSource = getPasteSource(event, false);\n const pasteType = event.pasteType;\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());\n break;\n case 'wacComponents':\n processPastedContentWacComponents(event);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(\n event,\n this.editor.getTrustedHTMLHandler(),\n this.allowExcelNoBorderTable\n );\n }\n break;\n case 'googleSheets':\n event.domToModelOption.additionalAllowedTags.push(\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME as Lowercase<string>\n );\n break;\n case 'powerPointDesktop':\n processPastedContentFromPowerPoint(event, this.editor.getTrustedHTMLHandler());\n break;\n }\n\n addParser(event.domToModelOption, 'link', parseLink);\n addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);\n addParser(event.domToModelOption, 'tableCell', tableBorderParser);\n addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);\n\n if (pasteType === 'mergeFormat') {\n addParser(event.domToModelOption, 'block', blockElementParser);\n addParser(event.domToModelOption, 'listLevel', blockElementParser);\n }\n }\n}\n\n/**\n * For block elements that have background color style, remove the background color when user selects the merge current format\n * paste option\n */\nconst blockElementParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.backgroundColor) {\n delete format.backgroundColor;\n }\n};\n\nconst ElementBorderKeys = new Map<\n keyof BorderFormat,\n {\n c: keyof CSSStyleDeclaration;\n s: keyof CSSStyleDeclaration;\n w: keyof CSSStyleDeclaration;\n }\n>([\n ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],\n ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],\n ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],\n ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],\n]);\n\nfunction tableBorderParser(format: ContentModelTableCellFormat, element: HTMLElement): void {\n BorderKeys.forEach(key => {\n if (!format[key]) {\n const styleSet = ElementBorderKeys.get(key);\n if (\n styleSet &&\n element.style[styleSet.w] &&\n element.style[styleSet.s] &&\n !element.style[styleSet.c]\n ) {\n format[key] = `${element.style[styleSet.w]} ${element.style[styleSet.s]}`;\n }\n }\n });\n}\n"]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { TrustedHTMLHandler } from 'roosterjs-
|
|
2
|
-
import type { ContentModelBeforePasteEvent } from 'roosterjs-content-model-types';
|
|
1
|
+
import type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';
|
|
3
2
|
/**
|
|
4
3
|
* @internal
|
|
5
4
|
* Convert pasted content from Excel, add borders when source doc doesn't have a border
|
|
6
5
|
* @param event The BeforePaste event
|
|
7
6
|
*/
|
|
8
|
-
export declare function processPastedContentFromExcel(event:
|
|
7
|
+
export declare function processPastedContentFromExcel(event: BeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler, allowExcelNoBorderTable?: boolean): void;
|
|
9
8
|
/**
|
|
10
9
|
* @internal Export for test only
|
|
11
10
|
* @param html Source html
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";;;;IAKA,IAAM,iBAAiB,GAAG,yCAAyC,CAAC;IACpE,IAAM,iBAAiB,GAAG,4CAA4C,CAAC;IACvE,IAAM,aAAa,GAAG,iBAAiB,CAAC;IACxC,IAAM,gBAAgB,GAAG,oBAAoB,CAAC;IAC9C,IAAM,oBAAoB,GAAG,mBAAmB,CAAC;IAEjD;;;;OAIG;IAEH,SAAgB,6BAA6B,CACzC,KAAuB,EACvB,kBAAsC,EACtC,uBAAiC;QAEzB,IAAA,QAAQ,GAAgC,KAAK,SAArC,EAAE,UAAU,GAAoB,KAAK,WAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;QACtD,IAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE3F,IAAI,IAAI,IAAI,aAAa,CA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C,gBAAgB,CAAC,CAAC;YACtD,IAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrD,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAbD,oCAaC","sourcesContent":["import addParser from '../utils/addParser';\nimport { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';\n\nconst LAST_TD_END_REGEX = /<\\/\\s*td\\s*>((?!<\\/\\s*tr\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_END_REGEX = /<\\/\\s*tr\\s*>((?!<\\/\\s*table\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;\nconst LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;\nconst DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';\n\n/**\n * @internal\n * Convert pasted content from Excel, add borders when source doc doesn't have a border\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromExcel(\n event: BeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler,\n allowExcelNoBorderTable?: boolean\n) {\n const { fragment, htmlBefore, clipboardData } = event;\n const html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;\n\n if (html && clipboardData.html != html) {\n const doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');\n moveChildNodes(fragment, doc?.body);\n }\n\n // For Excel Online\n const firstChild = fragment.firstChild;\n if (\n isNodeOfType(firstChild, 'ELEMENT_NODE') &&\n firstChild.tagName == 'div' &&\n firstChild.firstChild\n ) {\n const tableFound = Array.from(firstChild.childNodes).every((child: Node) => {\n // Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag\n const tagName = isNodeOfType(child, 'ELEMENT_NODE') && child.tagName;\n\n return tagName == 'META'\n ? true\n : tagName == 'TABLE'\n ? child == firstChild.lastChild\n : false;\n });\n\n // Extract Table from Div\n if (tableFound && firstChild.lastChild) {\n event.fragment.replaceChildren(firstChild.lastChild);\n }\n }\n\n addParser(event.domToModelOption, 'tableCell', (format, element) => {\n if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {\n format.borderBottom = DEFAULT_BORDER_STYLE;\n format.borderLeft = DEFAULT_BORDER_STYLE;\n format.borderRight = DEFAULT_BORDER_STYLE;\n format.borderTop = DEFAULT_BORDER_STYLE;\n }\n });\n\n setProcessor(event.domToModelOption, 'child', (group, element, context) => {\n const segmentFormat = { ...context.segmentFormat };\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat.textColor = group.format.textColor;\n }\n\n context.defaultElementProcessors.child(group, element, context);\n\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat = segmentFormat;\n delete group.format.textColor;\n }\n });\n}\n\n/**\n * @internal Export for test only\n * @param html Source html\n */\n\nexport function excelHandler(html: string, htmlBefore: string): string {\n if (html.match(LAST_TD_END_REGEX)) {\n const trMatch = htmlBefore.match(LAST_TR_REGEX);\n const tr = trMatch ? trMatch[0] : '<TR>';\n html = tr + html + '</TR>';\n }\n if (html.match(LAST_TR_END_REGEX)) {\n const tableMatch = htmlBefore.match(LAST_TABLE_REGEX);\n const table = tableMatch ? tableMatch[0] : '<TABLE>';\n html = table + html + '</TABLE>';\n }\n\n return html;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPastedContentFromPowerPoint.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/PowerPoint/processPastedContentFromPowerPoint.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IAEH,SAAgB,kCAAkC,CAC9C,KAAuB,EACvB,kBAAsC;QAE9B,IAAA,QAAQ,GAAoB,KAAK,SAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;QAE1C,IAAI,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,EAAE;YAClE,gFAAgF;YAChF,gCAAgC;YAChC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CACvC,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,EACtC,WAAW,CACd,CAAC;YAEF,IAAA,4CAAc,EAAC,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC;SACvC;IACL,CAAC;IAhBD,gFAgBC","sourcesContent":["import { moveChildNodes } from 'roosterjs-content-model-dom';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-
|
|
1
|
+
{"version":3,"file":"processPastedContentFromPowerPoint.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/PowerPoint/processPastedContentFromPowerPoint.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IAEH,SAAgB,kCAAkC,CAC9C,KAAuB,EACvB,kBAAsC;QAE9B,IAAA,QAAQ,GAAoB,KAAK,SAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;QAE1C,IAAI,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,EAAE;YAClE,gFAAgF;YAChF,gCAAgC;YAChC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CACvC,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,EACtC,WAAW,CACd,CAAC;YAEF,IAAA,4CAAc,EAAC,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC;SACvC;IACL,CAAC;IAhBD,gFAgBC","sourcesContent":["import { moveChildNodes } from 'roosterjs-content-model-dom';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Convert pasted content from PowerPoint\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromPowerPoint(\n event: BeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler\n) {\n const { fragment, clipboardData } = event;\n\n if (clipboardData.html && !clipboardData.text && clipboardData.image) {\n // It is possible that PowerPoint copied both image and HTML but not plain text.\n // We always prefer HTML if any.\n const doc = new DOMParser().parseFromString(\n trustedHTMLHandler(clipboardData.html),\n 'text/html'\n );\n\n moveChildNodes(fragment, doc?.body);\n }\n}\n"]}
|
|
@@ -30,10 +30,6 @@ export declare const PARAGRAPH: string;
|
|
|
30
30
|
* @internal
|
|
31
31
|
**/
|
|
32
32
|
export declare const LIST_CONTAINER_ELEMENT_CLASS_NAME: string;
|
|
33
|
-
/**
|
|
34
|
-
* @internal
|
|
35
|
-
**/
|
|
36
|
-
export declare const TABLE_CONTAINER: string;
|
|
37
33
|
/**
|
|
38
34
|
* @internal
|
|
39
35
|
**/
|
|
@@ -50,7 +46,3 @@ export declare const TEMP_ELEMENTS_CLASSES: string[];
|
|
|
50
46
|
* @internal
|
|
51
47
|
**/
|
|
52
48
|
export declare const WAC_IDENTIFY_SELECTOR: string;
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
**/
|
|
56
|
-
export declare const CLASSES_TO_KEEP: string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.WAC_IDENTIFY_SELECTOR = exports.TEMP_ELEMENTS_CLASSES = exports.COMMENT_HIGHLIGHT_CLICKED_CLASS = exports.COMMENT_HIGHLIGHT_CLASS = exports.LIST_CONTAINER_ELEMENT_CLASS_NAME = exports.PARAGRAPH = exports.OUTLINE_ELEMENT = exports.IMAGE_CONTAINER = exports.IMAGE_BORDER = exports.NUMBER_LIST_STYLE = exports.BULLET_LIST_STYLE = exports.WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
**/
|
|
@@ -41,10 +41,6 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
|
|
41
41
|
* @internal
|
|
42
42
|
**/
|
|
43
43
|
exports.LIST_CONTAINER_ELEMENT_CLASS_NAME = 'ListContainerWrapper';
|
|
44
|
-
/**
|
|
45
|
-
* @internal
|
|
46
|
-
**/
|
|
47
|
-
exports.TABLE_CONTAINER = 'TableContainer';
|
|
48
44
|
/**
|
|
49
45
|
* @internal
|
|
50
46
|
**/
|
|
@@ -64,24 +60,5 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
|
|
64
60
|
**/
|
|
65
61
|
exports.WAC_IDENTIFY_SELECTOR = "ul[class^=\"" + exports.BULLET_LIST_STYLE + "\"]>." + exports.OUTLINE_ELEMENT + ",ol[class^=\"" + exports.NUMBER_LIST_STYLE + "\"]>." + exports.OUTLINE_ELEMENT + ",span." + exports.IMAGE_CONTAINER + ",span." + exports.IMAGE_BORDER + ",." + exports.COMMENT_HIGHLIGHT_CLASS + ",." + exports.COMMENT_HIGHLIGHT_CLICKED_CLASS + "," +
|
|
66
62
|
exports.WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(function (c) { return "table div[class^=\"" + c + "\"]"; }).join(',');
|
|
67
|
-
/**
|
|
68
|
-
* @internal
|
|
69
|
-
**/
|
|
70
|
-
exports.CLASSES_TO_KEEP = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([
|
|
71
|
-
exports.OUTLINE_ELEMENT,
|
|
72
|
-
exports.IMAGE_CONTAINER
|
|
73
|
-
], (0, tslib_1.__read)(exports.TEMP_ELEMENTS_CLASSES), false), [
|
|
74
|
-
exports.PARAGRAPH,
|
|
75
|
-
exports.IMAGE_BORDER,
|
|
76
|
-
exports.TABLE_CONTAINER,
|
|
77
|
-
exports.COMMENT_HIGHLIGHT_CLASS,
|
|
78
|
-
exports.COMMENT_HIGHLIGHT_CLICKED_CLASS,
|
|
79
|
-
'NumberListStyle',
|
|
80
|
-
'ListContainerWrapper',
|
|
81
|
-
'BulletListStyle',
|
|
82
|
-
'TableCellContent',
|
|
83
|
-
'WACImageContainer',
|
|
84
|
-
'LineBreakBlob',
|
|
85
|
-
], false);
|
|
86
63
|
});
|
|
87
64
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WacComponents/constants.ts"],"names":[],"mappings":";;;;IAAA;;QAEI;IACS,QAAA,sCAAsC,GAAa;QAC5D,wBAAwB;QACxB,yBAAyB;QACzB,0BAA0B;QAC1B,2BAA2B;QAC3B,wBAAwB;QACxB,qBAAqB;KACxB,CAAC;IACF;;QAEI;IACS,QAAA,iBAAiB,GAAW,iBAAiB,CAAC;IAC3D;;QAEI;IACS,QAAA,iBAAiB,GAAW,iBAAiB,CAAC;IAC3D;;QAEI;IACS,QAAA,YAAY,GAAW,gBAAgB,CAAC;IACrD;;QAEI;IACS,QAAA,eAAe,GAAW,mBAAmB,CAAC;IAC3D;;QAEI;IACS,QAAA,eAAe,GAAW,gBAAgB,CAAC;IACxD;;QAEI;IACS,QAAA,SAAS,GAAW,WAAW,CAAC;IAC7C;;QAEI;IACS,QAAA,iCAAiC,GAAW,sBAAsB,CAAC;IAChF;;QAEI;IACS,QAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WacComponents/constants.ts"],"names":[],"mappings":";;;;IAAA;;QAEI;IACS,QAAA,sCAAsC,GAAa;QAC5D,wBAAwB;QACxB,yBAAyB;QACzB,0BAA0B;QAC1B,2BAA2B;QAC3B,wBAAwB;QACxB,qBAAqB;KACxB,CAAC;IACF;;QAEI;IACS,QAAA,iBAAiB,GAAW,iBAAiB,CAAC;IAC3D;;QAEI;IACS,QAAA,iBAAiB,GAAW,iBAAiB,CAAC;IAC3D;;QAEI;IACS,QAAA,YAAY,GAAW,gBAAgB,CAAC;IACrD;;QAEI;IACS,QAAA,eAAe,GAAW,mBAAmB,CAAC;IAC3D;;QAEI;IACS,QAAA,eAAe,GAAW,gBAAgB,CAAC;IACxD;;QAEI;IACS,QAAA,SAAS,GAAW,WAAW,CAAC;IAC7C;;QAEI;IACS,QAAA,iCAAiC,GAAW,sBAAsB,CAAC;IAChF;;QAEI;IACS,QAAA,uBAAuB,GAAW,sBAAsB,CAAC;IACtE;;QAEI;IACS,QAAA,+BAA+B,GAAW,yBAAyB,CAAC;IACjF;;QAEI;IACS,QAAA,qBAAqB,iFAC3B,8CAAsC;QACzC,wBAAwB;cAC1B;IACF;;QAEI;IACS,QAAA,qBAAqB,GAC9B,iBAAc,yBAAiB,aAAO,uBAAe,qBAAe,yBAAiB,aAAO,uBAAe,cAAS,uBAAe,cAAS,oBAAY,UAAK,+BAAuB,UAAK,uCAA+B,MAAG;QAC3N,8CAAsC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,wBAAqB,CAAC,QAAI,EAA1B,CAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC","sourcesContent":["/**\n * @internal\n **/\nexport const WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES: string[] = [\n 'TableInsertRowGapBlank',\n 'TableColumnResizeHandle',\n 'TableCellTopBorderHandle',\n 'TableCellLeftBorderHandle',\n 'TableHoverColumnHandle',\n 'TableHoverRowHandle',\n];\n/**\n * @internal\n **/\nexport const BULLET_LIST_STYLE: string = 'BulletListStyle';\n/**\n * @internal\n **/\nexport const NUMBER_LIST_STYLE: string = 'NumberListStyle';\n/**\n * @internal\n **/\nexport const IMAGE_BORDER: string = 'WACImageBorder';\n/**\n * @internal\n **/\nexport const IMAGE_CONTAINER: string = 'WACImageContainer';\n/**\n * @internal\n **/\nexport const OUTLINE_ELEMENT: string = 'OutlineElement';\n/**\n * @internal\n **/\nexport const PARAGRAPH: string = 'Paragraph';\n/**\n * @internal\n **/\nexport const LIST_CONTAINER_ELEMENT_CLASS_NAME: string = 'ListContainerWrapper';\n/**\n * @internal\n **/\nexport const COMMENT_HIGHLIGHT_CLASS: string = 'CommentHighlightRest';\n/**\n * @internal\n **/\nexport const COMMENT_HIGHLIGHT_CLICKED_CLASS: string = 'CommentHighlightClicked';\n/**\n * @internal\n **/\nexport const TEMP_ELEMENTS_CLASSES: string[] = [\n ...WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES,\n 'ListMarkerWrappingSpan',\n];\n/**\n * @internal\n **/\nexport const WAC_IDENTIFY_SELECTOR: string =\n `ul[class^=\"${BULLET_LIST_STYLE}\"]>.${OUTLINE_ELEMENT},ol[class^=\"${NUMBER_LIST_STYLE}\"]>.${OUTLINE_ELEMENT},span.${IMAGE_CONTAINER},span.${IMAGE_BORDER},.${COMMENT_HIGHLIGHT_CLASS},.${COMMENT_HIGHLIGHT_CLICKED_CLASS},` +\n WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(c => `table div[class^=\"${c}\"]`).join(',');\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BeforePasteEvent } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
* Convert pasted content from Office Online
|
|
@@ -6,4 +6,4 @@ import type { ContentModelBeforePasteEvent } from 'roosterjs-content-model-types
|
|
|
6
6
|
* We need to remove the display property and margin from all the list item
|
|
7
7
|
* @param ev ContentModelBeforePasteEvent
|
|
8
8
|
*/
|
|
9
|
-
export declare function processPastedContentWacComponents(ev:
|
|
9
|
+
export declare function processPastedContentWacComponents(ev: BeforePasteEvent): void;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "../utils/addParser", "../utils/setProcessor", "./constants"], function (require, exports, tslib_1, addParser_1, setProcessor_1, constants_1) {
|
|
1
|
+
define(["require", "exports", "tslib", "../utils/addParser", "roosterjs-content-model-dom", "../utils/setProcessor", "./constants"], function (require, exports, tslib_1, addParser_1, roosterjs_content_model_dom_1, setProcessor_1, constants_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.processPastedContentWacComponents = void 0;
|
|
5
5
|
var LIST_ELEMENT_TAGS = ['UL', 'OL', 'LI'];
|
|
6
6
|
var LIST_ELEMENT_SELECTOR = LIST_ELEMENT_TAGS.join(',');
|
|
7
|
-
var COMMENT_BG_COLOR_REST = 'rgba(209, 209, 209, 0.5)';
|
|
8
|
-
var COMMENTS_TEXT_HIGHLIGHT_CLICKED = 'rgba(197, 139, 204, 0.5)';
|
|
9
7
|
/**
|
|
10
8
|
* Wac components do not use sub and super tags, instead only add vertical align to a span.
|
|
11
9
|
* This parser normalize the content for content model
|
|
@@ -51,31 +49,46 @@ define(["require", "exports", "tslib", "../utils/addParser", "../utils/setProces
|
|
|
51
49
|
* This processor calls the default list processor and then sets the correct list level and list bullet.
|
|
52
50
|
*/
|
|
53
51
|
var wacLiElementProcessor = function (group, element, context) {
|
|
54
|
-
var _a, _b, _c;
|
|
55
|
-
|
|
52
|
+
var _a, _b, _c, _d, _e;
|
|
53
|
+
var level = parseInt((_a = element.getAttribute('data-aria-level')) !== null && _a !== void 0 ? _a : '');
|
|
56
54
|
var listFormat = context.listFormat;
|
|
55
|
+
var listType = ((_b = listFormat.levels[context.listFormat.levels.length - 1]) === null || _b === void 0 ? void 0 : _b.listType) ||
|
|
56
|
+
((_c = element.closest('ol,ul')) === null || _c === void 0 ? void 0 : _c.tagName.toUpperCase());
|
|
57
|
+
var newLevel = (0, roosterjs_content_model_dom_1.createListLevel)(listType, context.blockFormat);
|
|
58
|
+
(0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.listLevelThread, newLevel.format, context);
|
|
59
|
+
(0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.listLevel, newLevel.format, context);
|
|
60
|
+
context.listFormat.levels = listFormat.currentListLevels || context.listFormat.levels;
|
|
61
|
+
if (level > 0) {
|
|
62
|
+
if (level > context.listFormat.levels.length) {
|
|
63
|
+
while (level != context.listFormat.levels.length) {
|
|
64
|
+
context.listFormat.levels.push(newLevel);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
context.listFormat.levels.splice(level, context.listFormat.levels.length - 1);
|
|
69
|
+
context.listFormat.levels[level - 1] = newLevel;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
(_e = (_d = context.defaultElementProcessors).li) === null || _e === void 0 ? void 0 : _e.call(_d, group, element, context);
|
|
57
73
|
var listParent = listFormat.listParent;
|
|
58
74
|
if (listParent) {
|
|
59
75
|
var lastblock = listParent.blocks[listParent.blocks.length - 1];
|
|
60
|
-
if (lastblock.blockType == 'BlockGroup' &&
|
|
61
|
-
lastblock.blockGroupType == 'ListItem' &&
|
|
62
|
-
context.listFormat.listParent !== lastblock) {
|
|
76
|
+
if (lastblock.blockType == 'BlockGroup' && lastblock.blockGroupType == 'ListItem') {
|
|
63
77
|
var currentLevel = lastblock.levels[lastblock.levels.length - 1];
|
|
64
|
-
|
|
65
|
-
var level = parseInt((_c = element.getAttribute('data-aria-level')) !== null && _c !== void 0 ? _c : '');
|
|
66
|
-
if (level > 0) {
|
|
67
|
-
if (level > lastblock.levels.length) {
|
|
68
|
-
while (level != lastblock.levels.length) {
|
|
69
|
-
lastblock.levels.push(currentLevel);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
lastblock.levels.splice(level, lastblock.levels.length - 1);
|
|
74
|
-
lastblock.levels[level - 1] = currentLevel;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
78
|
+
updateStartOverride(currentLevel, element, context);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
81
|
+
var newLevels = [];
|
|
82
|
+
listFormat.levels.forEach(function (v) {
|
|
83
|
+
var newValue = {
|
|
84
|
+
dataset: (0, tslib_1.__assign)({}, v.dataset),
|
|
85
|
+
format: (0, tslib_1.__assign)({}, v.format),
|
|
86
|
+
listType: v.listType,
|
|
87
|
+
};
|
|
88
|
+
newLevels.push(newValue);
|
|
89
|
+
});
|
|
90
|
+
listFormat.currentListLevels = newLevels;
|
|
91
|
+
listFormat.levels = [];
|
|
79
92
|
};
|
|
80
93
|
/**
|
|
81
94
|
* This parsers does:
|
|
@@ -119,10 +132,8 @@ define(["require", "exports", "tslib", "../utils/addParser", "../utils/setProces
|
|
|
119
132
|
!element.closest(LIST_ELEMENT_SELECTOR));
|
|
120
133
|
}
|
|
121
134
|
var wacCommentParser = function (format, element) {
|
|
122
|
-
if (
|
|
123
|
-
element.
|
|
124
|
-
(element.className.includes(constants_1.COMMENT_HIGHLIGHT_CLICKED_CLASS) &&
|
|
125
|
-
element.style.backgroundColor == COMMENTS_TEXT_HIGHLIGHT_CLICKED)) {
|
|
135
|
+
if (element.className.includes(constants_1.COMMENT_HIGHLIGHT_CLASS) ||
|
|
136
|
+
element.className.includes(constants_1.COMMENT_HIGHLIGHT_CLICKED_CLASS)) {
|
|
126
137
|
delete format.backgroundColor;
|
|
127
138
|
}
|
|
128
139
|
};
|
|
@@ -134,58 +145,42 @@ define(["require", "exports", "tslib", "../utils/addParser", "../utils/setProces
|
|
|
134
145
|
* @param ev ContentModelBeforePasteEvent
|
|
135
146
|
*/
|
|
136
147
|
function processPastedContentWacComponents(ev) {
|
|
137
|
-
var _a;
|
|
138
148
|
(0, addParser_1.default)(ev.domToModelOption, 'segment', wacSubSuperParser);
|
|
139
149
|
(0, addParser_1.default)(ev.domToModelOption, 'listItemThread', wacListItemParser);
|
|
140
150
|
(0, addParser_1.default)(ev.domToModelOption, 'listLevel', wacListLevelParser);
|
|
141
|
-
(0, addParser_1.default)(ev.domToModelOption, 'container',
|
|
151
|
+
(0, addParser_1.default)(ev.domToModelOption, 'container', wacContainerParser);
|
|
152
|
+
(0, addParser_1.default)(ev.domToModelOption, 'table', wacContainerParser);
|
|
142
153
|
(0, addParser_1.default)(ev.domToModelOption, 'segment', wacCommentParser);
|
|
143
154
|
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'element', wacElementProcessor);
|
|
144
155
|
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'li', wacLiElementProcessor);
|
|
145
|
-
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'ol', wacListProcessor);
|
|
146
|
-
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'ul', wacListProcessor);
|
|
147
|
-
(_a = ev.sanitizingOption.additionalAllowedCssClasses).push.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(constants_1.CLASSES_TO_KEEP), false));
|
|
148
156
|
}
|
|
149
157
|
exports.processPastedContentWacComponents = processPastedContentWacComponents;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
<div>
|
|
154
|
-
<ol></ol>
|
|
155
|
-
</div>
|
|
156
|
-
<div>
|
|
157
|
-
<ol></ol>
|
|
158
|
-
</div>
|
|
159
|
-
<div>
|
|
160
|
-
<ol></ol>
|
|
161
|
-
</div>
|
|
162
|
-
* Due to this the div between each of the lists we need to restore the list context to use the previous list,
|
|
163
|
-
* otherwise it could create a new list instead under the same list element
|
|
164
|
-
*/
|
|
165
|
-
var wacListProcessor = function (group, element, context) {
|
|
166
|
-
var _a, _b, _c, _d, _e;
|
|
167
|
-
var lastBlock = group.blocks[group.blocks.length - 1];
|
|
168
|
-
var isWrappedInContainer = element.closest("." + constants_1.LIST_CONTAINER_ELEMENT_CLASS_NAME);
|
|
169
|
-
if ((_a = isWrappedInContainer === null || isWrappedInContainer === void 0 ? void 0 : isWrappedInContainer.previousElementSibling) === null || _a === void 0 ? void 0 : _a.classList.contains(constants_1.LIST_CONTAINER_ELEMENT_CLASS_NAME)) {
|
|
170
|
-
if ((lastBlock === null || lastBlock === void 0 ? void 0 : lastBlock.blockType) === 'BlockGroup' && lastBlock.blockGroupType == 'ListItem') {
|
|
171
|
-
context.listFormat = {
|
|
172
|
-
threadItemCounts: [],
|
|
173
|
-
levels: lastBlock.levels,
|
|
174
|
-
listParent: group,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
158
|
+
var wacContainerParser = function (format, element) {
|
|
159
|
+
if (element.style.marginLeft.startsWith('-')) {
|
|
160
|
+
delete format.marginLeft;
|
|
177
161
|
}
|
|
178
|
-
|
|
179
|
-
|
|
162
|
+
};
|
|
163
|
+
function updateStartOverride(currentLevel, element, ctx) {
|
|
164
|
+
if (!currentLevel || currentLevel.listType == 'UL') {
|
|
165
|
+
return;
|
|
180
166
|
}
|
|
181
|
-
|
|
182
|
-
|
|
167
|
+
var list = element.closest('ol');
|
|
168
|
+
var listFormat = ctx.listFormat;
|
|
169
|
+
var _a = (0, tslib_1.__read)(extractWordListMetadata(list, element), 2), start = _a[0], listLevel = _a[1];
|
|
170
|
+
if (!listFormat.listItemThread) {
|
|
171
|
+
listFormat.listItemThread = [];
|
|
183
172
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
delete format.marginLeft;
|
|
173
|
+
var thread = listFormat.listItemThread[listLevel];
|
|
174
|
+
if (thread && start - thread != 1) {
|
|
175
|
+
currentLevel.format.startNumberOverride = start;
|
|
188
176
|
}
|
|
189
|
-
|
|
177
|
+
listFormat.listItemThread[listLevel] = start;
|
|
178
|
+
}
|
|
179
|
+
function extractWordListMetadata(list, item) {
|
|
180
|
+
var itemIndex = item && Array.from((list === null || list === void 0 ? void 0 : list.querySelectorAll('li')) || []).indexOf(item);
|
|
181
|
+
var start = parseInt((list === null || list === void 0 ? void 0 : list.getAttribute('start')) || '1') + (itemIndex && itemIndex > 0 ? itemIndex : 0);
|
|
182
|
+
var listLevel = parseInt((item === null || item === void 0 ? void 0 : item.getAttribute('data-aria-level')) || '');
|
|
183
|
+
return [start, listLevel];
|
|
184
|
+
}
|
|
190
185
|
});
|
|
191
186
|
//# sourceMappingURL=processPastedContentWacComponents.js.map
|