roosterjs-content-model-core 9.57.0 → 9.59.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 +8 -0
- package/lib/command/exportContent/exportContent.js +1 -1
- package/lib/command/exportContent/exportContent.js.map +1 -1
- package/lib/command/paste/mergePasteContent.js +7 -4
- package/lib/command/paste/mergePasteContent.js.map +1 -1
- package/lib/command/paste/paste.js +1 -2
- package/lib/command/paste/paste.js.map +1 -1
- package/lib/coreApi/restoreUndoSnapshot/restoreSnapshotColors.js +1 -1
- package/lib/coreApi/restoreUndoSnapshot/restoreSnapshotColors.js.map +1 -1
- package/lib/coreApi/setDOMSelection/setTableCellsStyle.d.ts +4 -0
- package/lib/coreApi/setDOMSelection/setTableCellsStyle.js +7 -4
- package/lib/coreApi/setDOMSelection/setTableCellsStyle.js.map +1 -1
- package/lib/coreApi/setDOMSelection/toggleCaret.d.ts +4 -0
- package/lib/coreApi/setDOMSelection/toggleCaret.js +6 -3
- package/lib/coreApi/setDOMSelection/toggleCaret.js.map +1 -1
- package/lib/coreApi/triggerEvent/triggerEvent.js +2 -0
- package/lib/coreApi/triggerEvent/triggerEvent.js.map +1 -1
- package/lib/corePlugin/entity/EntityPlugin.js +1 -1
- package/lib/corePlugin/entity/EntityPlugin.js.map +1 -1
- package/lib/corePlugin/selection/SelectionPlugin.js +48 -5
- package/lib/corePlugin/selection/SelectionPlugin.js.map +1 -1
- package/lib/editor/Editor.js +5 -2
- package/lib/editor/Editor.js.map +1 -1
- package/lib/editor/core/createEditorCore.js +6 -4
- package/lib/editor/core/createEditorCore.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -2
- package/lib/index.js.map +1 -1
- package/lib/utils/devtoolsHook.d.ts +35 -0
- package/lib/utils/devtoolsHook.js +89 -0
- package/lib/utils/devtoolsHook.js.map +1 -0
- package/lib-amd/command/exportContent/exportContent.js +1 -1
- package/lib-amd/command/exportContent/exportContent.js.map +1 -1
- package/lib-amd/command/paste/mergePasteContent.js +7 -4
- package/lib-amd/command/paste/mergePasteContent.js.map +1 -1
- package/lib-amd/command/paste/paste.js +2 -2
- package/lib-amd/command/paste/paste.js.map +1 -1
- package/lib-amd/coreApi/restoreUndoSnapshot/restoreSnapshotColors.js +1 -1
- package/lib-amd/coreApi/restoreUndoSnapshot/restoreSnapshotColors.js.map +1 -1
- package/lib-amd/coreApi/setDOMSelection/setTableCellsStyle.d.ts +4 -0
- package/lib-amd/coreApi/setDOMSelection/setTableCellsStyle.js +7 -4
- package/lib-amd/coreApi/setDOMSelection/setTableCellsStyle.js.map +1 -1
- package/lib-amd/coreApi/setDOMSelection/toggleCaret.d.ts +4 -0
- package/lib-amd/coreApi/setDOMSelection/toggleCaret.js +6 -3
- package/lib-amd/coreApi/setDOMSelection/toggleCaret.js.map +1 -1
- package/lib-amd/coreApi/triggerEvent/triggerEvent.js +2 -1
- package/lib-amd/coreApi/triggerEvent/triggerEvent.js.map +1 -1
- package/lib-amd/corePlugin/entity/EntityPlugin.js +1 -1
- package/lib-amd/corePlugin/entity/EntityPlugin.js.map +1 -1
- package/lib-amd/corePlugin/selection/SelectionPlugin.js +47 -6
- package/lib-amd/corePlugin/selection/SelectionPlugin.js.map +1 -1
- package/lib-amd/editor/Editor.js +5 -3
- package/lib-amd/editor/Editor.js.map +1 -1
- package/lib-amd/editor/core/createEditorCore.js +6 -4
- package/lib-amd/editor/core/createEditorCore.js.map +1 -1
- package/lib-amd/index.d.ts +1 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/utils/devtoolsHook.d.ts +35 -0
- package/lib-amd/utils/devtoolsHook.js +91 -0
- package/lib-amd/utils/devtoolsHook.js.map +1 -0
- package/lib-mjs/command/exportContent/exportContent.js +1 -1
- package/lib-mjs/command/exportContent/exportContent.js.map +1 -1
- package/lib-mjs/command/paste/mergePasteContent.js +7 -4
- package/lib-mjs/command/paste/mergePasteContent.js.map +1 -1
- package/lib-mjs/command/paste/paste.js +1 -2
- package/lib-mjs/command/paste/paste.js.map +1 -1
- package/lib-mjs/coreApi/restoreUndoSnapshot/restoreSnapshotColors.js +1 -1
- package/lib-mjs/coreApi/restoreUndoSnapshot/restoreSnapshotColors.js.map +1 -1
- package/lib-mjs/coreApi/setDOMSelection/setTableCellsStyle.d.ts +4 -0
- package/lib-mjs/coreApi/setDOMSelection/setTableCellsStyle.js +4 -1
- package/lib-mjs/coreApi/setDOMSelection/setTableCellsStyle.js.map +1 -1
- package/lib-mjs/coreApi/setDOMSelection/toggleCaret.d.ts +4 -0
- package/lib-mjs/coreApi/setDOMSelection/toggleCaret.js +4 -1
- package/lib-mjs/coreApi/setDOMSelection/toggleCaret.js.map +1 -1
- package/lib-mjs/coreApi/triggerEvent/triggerEvent.js +2 -0
- package/lib-mjs/coreApi/triggerEvent/triggerEvent.js.map +1 -1
- package/lib-mjs/corePlugin/entity/EntityPlugin.js +1 -1
- package/lib-mjs/corePlugin/entity/EntityPlugin.js.map +1 -1
- package/lib-mjs/corePlugin/selection/SelectionPlugin.js +49 -6
- package/lib-mjs/corePlugin/selection/SelectionPlugin.js.map +1 -1
- package/lib-mjs/editor/Editor.js +5 -2
- package/lib-mjs/editor/Editor.js.map +1 -1
- package/lib-mjs/editor/core/createEditorCore.js +6 -4
- package/lib-mjs/editor/core/createEditorCore.js.map +1 -1
- package/lib-mjs/index.d.ts +1 -0
- package/lib-mjs/index.js +3 -1
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/utils/devtoolsHook.d.ts +35 -0
- package/lib-mjs/utils/devtoolsHook.js +83 -0
- package/lib-mjs/utils/devtoolsHook.js.map +1 -0
- package/package.json +3 -3
- package/lib/command/paste/createPasteFragment.d.ts +0 -5
- package/lib/command/paste/createPasteFragment.js +0 -79
- package/lib/command/paste/createPasteFragment.js.map +0 -1
- package/lib-amd/command/paste/createPasteFragment.d.ts +0 -5
- package/lib-amd/command/paste/createPasteFragment.js +0 -80
- package/lib-amd/command/paste/createPasteFragment.js.map +0 -1
- package/lib-mjs/command/paste/createPasteFragment.d.ts +0 -5
- package/lib-mjs/command/paste/createPasteFragment.js +0 -75
- package/lib-mjs/command/paste/createPasteFragment.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEditorCore.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/editor/core/createEditorCore.ts"],"names":[],"mappings":";;;;IAcA;;;;OAIG;IACH,SAAgB,gBAAgB,CAAC,UAA0B,EAAE,OAAsB;;QAC/E,IAAM,WAAW,GAAG,IAAA,iDAAuB,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACjE,IAAM,UAAU,GAAG,IAAA,6BAAgB,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAEhE,qDACI,YAAY,EAAE,UAAU,EACxB,WAAW,EAAE,UAAU,EACvB,GAAG,kDAAO,uBAAU,GAAK,OAAO,CAAC,eAAe,GAChD,WAAW,4BAAO,uBAAU,GAC5B,OAAO;gBACH,WAAW,CAAC,KAAK;gBACjB,WAAW,CAAC,MAAM;gBAClB,WAAW,CAAC,SAAS;gBACrB,WAAW,CAAC,QAAQ;gBACpB,WAAW,CAAC,SAAS;gBACrB,WAAW,CAAC,MAAM;mCACf,CAAC,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC;gBAC3C,WAAW,CAAC,IAAI;gBAChB,WAAW,CAAC,WAAW;gBACvB,WAAW,CAAC,SAAS;uBAEzB,WAAW,EAAE,uBAAuB,CAAC,UAAU,EAAE,OAAO,CAAC,EACzD,gBAAgB,EAAE,IAAA,6CAAsB,EACpC,UAAU,EACV,MAAA,OAAO,CAAC,YAAY,mCAAI,oBAAoB,EAC5C,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,gBAAgB,CAC3B,EACD,kBAAkB,EACd,OAA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AFD,oDAEC","sourcesContent":["import { coreApiMap } from '../../coreApi/coreApiMap';\nimport { createDarkColorHandler } from './DarkColorHandlerImpl';\nimport { createDOMCreator, createTrustedHTMLHandler, isDOMCreator } from '../../utils/domCreator';\nimport { createDOMHelper } from './DOMHelperImpl';\nimport { createDomToModelSettings, createModelToDomSettings } from './createEditorDefaultSettings';\nimport { createEditorCorePlugins } from '../../corePlugin/createEditorCorePlugins';\nimport type {\n EditorEnvironment,\n PluginState,\n EditorCore,\n EditorCorePlugins,\n EditorOptions,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal Create core object for editor\n * @param contentDiv Editor content DIV\n * @param options Editor options\n */\nexport function createEditorCore(contentDiv: HTMLDivElement, options: EditorOptions): EditorCore {\n const corePlugins = createEditorCorePlugins(options, contentDiv);\n const domCreator = createDOMCreator(options.trustedHTMLHandler);\n\n return {\n physicalRoot: contentDiv,\n logicalRoot: contentDiv,\n api: { ...coreApiMap, ...options.coreApiOverride },\n originalApi: { ...coreApiMap },\n plugins: [\n corePlugins.cache,\n corePlugins.format,\n corePlugins.copyPaste,\n corePlugins.domEvent,\n corePlugins.selection,\n corePlugins.entity,\n ...(options.plugins ?? []).filter(x => !!x),\n corePlugins.undo,\n corePlugins.contextMenu,\n corePlugins.lifecycle,\n ],\n environment: createEditorEnvironment(contentDiv, options),\n darkColorHandler: createDarkColorHandler(\n contentDiv,\n options.getDarkColor ?? getDarkColorFallback,\n options.knownColors,\n options.generateColorKey\n ),\n trustedHTMLHandler:\n options.trustedHTMLHandler && !isDOMCreator(options.trustedHTMLHandler)\n ? options.trustedHTMLHandler\n : createTrustedHTMLHandler(domCreator),\n domCreator: domCreator,\n domHelper: createDOMHelper(contentDiv, {\n useShadowDom:\n !!options.experimentalFeatures &&\n options.experimentalFeatures.indexOf('ShadowDom') >= 0,\n }),\n ...getPluginState(corePlugins),\n disposeErrorHandler: options.disposeErrorHandler,\n onFixUpModel: options.onFixUpModel,\n experimentalFeatures: options.experimentalFeatures ? [...options.experimentalFeatures] : [],\n };\n}\n\nfunction createEditorEnvironment(\n contentDiv: HTMLElement,\n options: EditorOptions\n): EditorEnvironment {\n const navigator = contentDiv.ownerDocument.defaultView?.navigator;\n const userAgent = navigator?.userAgent ?? '';\n const appVersion = navigator?.appVersion ?? '';\n\n return {\n document: contentDiv.ownerDocument,\n domToModelSettings: createDomToModelSettings(options),\n modelToDomSettings: createModelToDomSettings(options),\n isMac: appVersion.indexOf('Mac') != -1,\n isAndroid: /android/i.test(userAgent),\n isIOS: /iPad|iPhone/.test(userAgent),\n isSafari:\n userAgent.indexOf('AppleWebKit') >= 0 &&\n userAgent.indexOf('Chrome') < 0 &&\n userAgent.indexOf('Android') < 0,\n isMobileOrTablet: getIsMobileOrTablet(userAgent),\n };\n}\n\nfunction getIsMobileOrTablet(userAgent: string) {\n // Reference: http://detectmobilebrowsers.com/\n // The default regex on the website doesn't consider tablet.\n // To support tablet, add |android|ipad|playbook|silk to the first regex according to the info in /about page\n if (\n /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(\n userAgent\n ) ||\n /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(\n userAgent.substring(0, 4)\n )\n ) {\n return true;\n }\n return false;\n}\n\nfunction getPluginState(corePlugins: EditorCorePlugins): PluginState {\n return {\n domEvent: corePlugins.domEvent.getState(),\n copyPaste: corePlugins.copyPaste.getState(),\n cache: corePlugins.cache.getState(),\n format: corePlugins.format.getState(),\n lifecycle: corePlugins.lifecycle.getState(),\n entity: corePlugins.entity.getState(),\n selection: corePlugins.selection.getState(),\n contextMenu: corePlugins.contextMenu.getState(),\n undo: corePlugins.undo.getState(),\n };\n}\n\n/**\n * @internal Export for test only\n * A fallback function, always return original color\n */\nexport function getDarkColorFallback(color: string) {\n return color;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createEditorCore.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/editor/core/createEditorCore.ts"],"names":[],"mappings":";;;;IAcA;;;;OAIG;IACH,SAAgB,gBAAgB,CAAC,UAA0B,EAAE,OAAsB;;QAC/E,IAAM,WAAW,GAAG,IAAA,iDAAuB,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACjE,IAAM,UAAU,GAAG,IAAA,6BAAgB,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAEhE,qDACI,YAAY,EAAE,UAAU,EACxB,WAAW,EAAE,UAAU,EACvB,GAAG,kDAAO,uBAAU,GAAK,OAAO,CAAC,eAAe,GAChD,WAAW,4BAAO,uBAAU,GAC5B,OAAO;gBACH,WAAW,CAAC,KAAK;gBACjB,WAAW,CAAC,MAAM;gBAClB,WAAW,CAAC,SAAS;gBACrB,WAAW,CAAC,QAAQ;gBACpB,WAAW,CAAC,SAAS;gBACrB,WAAW,CAAC,MAAM;mCACf,CAAC,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAA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AAC,QAAQ,EAAE;YACzC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3C,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE;YACrC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3C,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE;YACrC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3C,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE;YAC/C,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE;SACpC,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,SAAgB,oBAAoB,CAAC,KAAa;QAC9C,OAAO,KAAK,CAAC;IACjB,CAAC;IAFD,oDAEC","sourcesContent":["import { coreApiMap } from '../../coreApi/coreApiMap';\nimport { createDarkColorHandler } from './DarkColorHandlerImpl';\nimport { createDOMCreator, createTrustedHTMLHandler, isDOMCreator } from '../../utils/domCreator';\nimport { createDOMHelper } from './DOMHelperImpl';\nimport { createDomToModelSettings, createModelToDomSettings } from './createEditorDefaultSettings';\nimport { createEditorCorePlugins } from '../../corePlugin/createEditorCorePlugins';\nimport type {\n EditorEnvironment,\n PluginState,\n EditorCore,\n EditorCorePlugins,\n EditorOptions,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal Create core object for editor\n * @param contentDiv Editor content DIV\n * @param options Editor options\n */\nexport function createEditorCore(contentDiv: HTMLDivElement, options: EditorOptions): EditorCore {\n const corePlugins = createEditorCorePlugins(options, contentDiv);\n const domCreator = createDOMCreator(options.trustedHTMLHandler);\n\n return {\n physicalRoot: contentDiv,\n logicalRoot: contentDiv,\n api: { ...coreApiMap, ...options.coreApiOverride },\n originalApi: { ...coreApiMap },\n plugins: [\n corePlugins.cache,\n corePlugins.format,\n corePlugins.copyPaste,\n corePlugins.domEvent,\n corePlugins.selection,\n corePlugins.entity,\n ...(options.plugins ?? []).filter(x => !!x),\n corePlugins.undo,\n corePlugins.contextMenu,\n corePlugins.lifecycle,\n ],\n environment: createEditorEnvironment(contentDiv, options),\n darkColorHandler: createDarkColorHandler(\n contentDiv,\n options.getDarkColor ?? getDarkColorFallback,\n options.knownColors,\n options.generateColorKey\n ),\n trustedHTMLHandler:\n options.trustedHTMLHandler && !isDOMCreator(options.trustedHTMLHandler)\n ? options.trustedHTMLHandler\n : createTrustedHTMLHandler(domCreator),\n domCreator: domCreator,\n domHelper: createDOMHelper(contentDiv, {\n useShadowDom:\n !!options.experimentalFeatures &&\n options.experimentalFeatures.indexOf('ShadowDom') >= 0,\n }),\n ...getPluginState(corePlugins),\n disposeErrorHandler: options.disposeErrorHandler,\n onFixUpModel: options.onFixUpModel,\n experimentalFeatures: options.experimentalFeatures ? [...options.experimentalFeatures] : [],\n };\n}\n\nfunction createEditorEnvironment(\n contentDiv: HTMLElement,\n options: EditorOptions\n): EditorEnvironment {\n const defaultView = contentDiv.ownerDocument.defaultView;\n const navigator = defaultView?.navigator;\n const userAgent = navigator?.userAgent ?? '';\n const appVersion = navigator?.appVersion ?? '';\n\n return {\n document: contentDiv.ownerDocument,\n domToModelSettings: createDomToModelSettings(options),\n modelToDomSettings: createModelToDomSettings(options),\n isMac: appVersion.indexOf('Mac') != -1,\n isAndroid: /android/i.test(userAgent),\n isIOS: /iPad|iPhone/.test(userAgent),\n isSafari:\n userAgent.indexOf('AppleWebKit') >= 0 &&\n userAgent.indexOf('Chrome') < 0 &&\n userAgent.indexOf('Android') < 0,\n isMobileOrTablet: getIsMobileOrTablet(userAgent),\n isTouchSupported:\n !!defaultView && ('ontouchstart' in defaultView || !!navigator?.maxTouchPoints),\n };\n}\n\nfunction getIsMobileOrTablet(userAgent: string) {\n // Reference: http://detectmobilebrowsers.com/\n // The default regex on the website doesn't consider tablet.\n // To support tablet, add |android|ipad|playbook|silk to the first regex according to the info in /about page\n if (\n /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(\n userAgent\n ) ||\n /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(\n userAgent.substring(0, 4)\n )\n ) {\n return true;\n }\n return false;\n}\n\nfunction getPluginState(corePlugins: EditorCorePlugins): PluginState {\n return {\n domEvent: corePlugins.domEvent.getState(),\n copyPaste: corePlugins.copyPaste.getState(),\n cache: corePlugins.cache.getState(),\n format: corePlugins.format.getState(),\n lifecycle: corePlugins.lifecycle.getState(),\n entity: corePlugins.entity.getState(),\n selection: corePlugins.selection.getState(),\n contextMenu: corePlugins.contextMenu.getState(),\n undo: corePlugins.undo.getState(),\n };\n}\n\n/**\n * @internal Export for test only\n * A fallback function, always return original color\n */\nexport function getDarkColorFallback(color: string) {\n return color;\n}\n"]}
|
package/lib-amd/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export { undo } from './command/undo/undo';
|
|
|
5
5
|
export { redo } from './command/redo/redo';
|
|
6
6
|
export { paste } from './command/paste/paste';
|
|
7
7
|
export { getContentForCopy } from './command/cutCopy/getContentForCopy';
|
|
8
|
+
export { RoosterJsDevToolsHookVersion } from './utils/devtoolsHook';
|
package/lib-amd/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
define(["require", "exports", "./editor/Editor", "./command/createModelFromHtml/createModelFromHtml", "./command/exportContent/exportContent", "./command/undo/undo", "./command/redo/redo", "./command/paste/paste", "./command/cutCopy/getContentForCopy"], function (require, exports, Editor_1, createModelFromHtml_1, exportContent_1, undo_1, redo_1, paste_1, getContentForCopy_1) {
|
|
1
|
+
define(["require", "exports", "./editor/Editor", "./command/createModelFromHtml/createModelFromHtml", "./command/exportContent/exportContent", "./command/undo/undo", "./command/redo/redo", "./command/paste/paste", "./command/cutCopy/getContentForCopy", "./utils/devtoolsHook"], function (require, exports, Editor_1, createModelFromHtml_1, exportContent_1, undo_1, redo_1, paste_1, getContentForCopy_1, devtoolsHook_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getContentForCopy = exports.paste = exports.redo = exports.undo = exports.exportContent = exports.createModelFromHtml = exports.Editor = void 0;
|
|
4
|
+
exports.RoosterJsDevToolsHookVersion = exports.getContentForCopy = exports.paste = exports.redo = exports.undo = exports.exportContent = exports.createModelFromHtml = exports.Editor = void 0;
|
|
5
5
|
Object.defineProperty(exports, "Editor", { enumerable: true, get: function () { return Editor_1.Editor; } });
|
|
6
6
|
Object.defineProperty(exports, "createModelFromHtml", { enumerable: true, get: function () { return createModelFromHtml_1.createModelFromHtml; } });
|
|
7
7
|
Object.defineProperty(exports, "exportContent", { enumerable: true, get: function () { return exportContent_1.exportContent; } });
|
|
@@ -9,5 +9,6 @@ define(["require", "exports", "./editor/Editor", "./command/createModelFromHtml/
|
|
|
9
9
|
Object.defineProperty(exports, "redo", { enumerable: true, get: function () { return redo_1.redo; } });
|
|
10
10
|
Object.defineProperty(exports, "paste", { enumerable: true, get: function () { return paste_1.paste; } });
|
|
11
11
|
Object.defineProperty(exports, "getContentForCopy", { enumerable: true, get: function () { return getContentForCopy_1.getContentForCopy; } });
|
|
12
|
+
Object.defineProperty(exports, "RoosterJsDevToolsHookVersion", { enumerable: true, get: function () { return devtoolsHook_1.RoosterJsDevToolsHookVersion; } });
|
|
12
13
|
});
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/lib-amd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-core/lib/index.ts"],"names":[],"mappings":";;;;IACS,gGAAA,MAAM,OAAA;IAGN,0HAAA,mBAAmB,OAAA;IACnB,8GAAA,aAAa,OAAA;IACb,4FAAA,IAAI,OAAA;IACJ,4FAAA,IAAI,OAAA;IACJ,8FAAA,KAAK,OAAA;IAGL,sHAAA,iBAAiB,OAAA","sourcesContent":["// Editor\nexport { Editor } from './editor/Editor';\n\n// Editor command\nexport { createModelFromHtml } from './command/createModelFromHtml/createModelFromHtml';\nexport { exportContent } from './command/exportContent/exportContent';\nexport { undo } from './command/undo/undo';\nexport { redo } from './command/redo/redo';\nexport { paste } from './command/paste/paste';\n\n//Editor copy helper\nexport { getContentForCopy } from './command/cutCopy/getContentForCopy';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-core/lib/index.ts"],"names":[],"mappings":";;;;IACS,gGAAA,MAAM,OAAA;IAGN,0HAAA,mBAAmB,OAAA;IACnB,8GAAA,aAAa,OAAA;IACb,4FAAA,IAAI,OAAA;IACJ,4FAAA,IAAI,OAAA;IACJ,8FAAA,KAAK,OAAA;IAGL,sHAAA,iBAAiB,OAAA;IAGjB,4HAAA,4BAA4B,OAAA","sourcesContent":["// Editor\nexport { Editor } from './editor/Editor';\n\n// Editor command\nexport { createModelFromHtml } from './command/createModelFromHtml/createModelFromHtml';\nexport { exportContent } from './command/exportContent/exportContent';\nexport { undo } from './command/undo/undo';\nexport { redo } from './command/redo/redo';\nexport { paste } from './command/paste/paste';\n\n// Editor copy helper\nexport { getContentForCopy } from './command/cutCopy/getContentForCopy';\n\n// Editor devtools\nexport { RoosterJsDevToolsHookVersion } from './utils/devtoolsHook';\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EditorCore, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* The current version of the RoosterJS DevTools hook contract (see
|
|
4
|
+
* {@link RoosterJsDevToolsHook}). The editor stamps this onto the installed hook so a developer
|
|
5
|
+
* tool can adapt to the editor's capabilities. Bump this whenever the shape of the contract changes
|
|
6
|
+
* in a way tools may need to detect.
|
|
7
|
+
*
|
|
8
|
+
* History:
|
|
9
|
+
* - 1: onEditorCreated, onEditorDisposed, onPluginEvent
|
|
10
|
+
*/
|
|
11
|
+
export declare const RoosterJsDevToolsHookVersion: number;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* Notify developer tools that an editor has been created. Failures are swallowed so developer
|
|
15
|
+
* tools can never break the editor.
|
|
16
|
+
* @param editor The editor that was created
|
|
17
|
+
* @param core The editor core, used to attribute later plugin events to this editor
|
|
18
|
+
*/
|
|
19
|
+
export declare function notifyDevToolsEditorCreated(editor: IEditor, core: EditorCore): void;
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
* Notify developer tools that an editor is about to be disposed. Failures are swallowed so
|
|
23
|
+
* developer tools can never break the editor.
|
|
24
|
+
* @param editor The editor that is being disposed
|
|
25
|
+
* @param core The editor core to stop tracking
|
|
26
|
+
*/
|
|
27
|
+
export declare function notifyDevToolsEditorDisposed(editor: IEditor, core: EditorCore): void;
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
* Forward a plugin event to developer tools, if a hook is installed. Failures are swallowed so
|
|
31
|
+
* developer tools can never break the editor.
|
|
32
|
+
* @param core The editor core that dispatched the event
|
|
33
|
+
* @param event The plugin event being dispatched
|
|
34
|
+
*/
|
|
35
|
+
export declare function notifyDevToolsPluginEvent(core: EditorCore, event: PluginEvent): void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.notifyDevToolsPluginEvent = exports.notifyDevToolsEditorDisposed = exports.notifyDevToolsEditorCreated = exports.RoosterJsDevToolsHookVersion = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* The current version of the RoosterJS DevTools hook contract (see
|
|
7
|
+
* {@link RoosterJsDevToolsHook}). The editor stamps this onto the installed hook so a developer
|
|
8
|
+
* tool can adapt to the editor's capabilities. Bump this whenever the shape of the contract changes
|
|
9
|
+
* in a way tools may need to detect.
|
|
10
|
+
*
|
|
11
|
+
* History:
|
|
12
|
+
* - 1: onEditorCreated, onEditorDisposed, onPluginEvent
|
|
13
|
+
*/
|
|
14
|
+
exports.RoosterJsDevToolsHookVersion = 1;
|
|
15
|
+
// Maps an editor core back to its IEditor wrapper, so plugin events (which only carry the core)
|
|
16
|
+
// can be attributed to the right editor when forwarded to developer tools.
|
|
17
|
+
var coreToEditor = new WeakMap();
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* Notify developer tools that an editor has been created. Failures are swallowed so developer
|
|
21
|
+
* tools can never break the editor.
|
|
22
|
+
* @param editor The editor that was created
|
|
23
|
+
* @param core The editor core, used to attribute later plugin events to this editor
|
|
24
|
+
*/
|
|
25
|
+
function notifyDevToolsEditorCreated(editor, core) {
|
|
26
|
+
safeCall(function () {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
coreToEditor.set(core, editor);
|
|
29
|
+
var win = editor.getDocument().defaultView;
|
|
30
|
+
if (win) {
|
|
31
|
+
var editors = (_a = win.__ROOSTERJS_DEVTOOLS_EDITORS__) !== null && _a !== void 0 ? _a : [];
|
|
32
|
+
editors.push(editor);
|
|
33
|
+
win.__ROOSTERJS_DEVTOOLS_EDITORS__ = editors;
|
|
34
|
+
var hook = win.__ROOSTERJS_DEVTOOLS_HOOK__;
|
|
35
|
+
if (hook) {
|
|
36
|
+
hook.version = exports.RoosterJsDevToolsHookVersion;
|
|
37
|
+
(_b = hook.onEditorCreated) === null || _b === void 0 ? void 0 : _b.call(hook, editor);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.notifyDevToolsEditorCreated = notifyDevToolsEditorCreated;
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
* Notify developer tools that an editor is about to be disposed. Failures are swallowed so
|
|
46
|
+
* developer tools can never break the editor.
|
|
47
|
+
* @param editor The editor that is being disposed
|
|
48
|
+
* @param core The editor core to stop tracking
|
|
49
|
+
*/
|
|
50
|
+
function notifyDevToolsEditorDisposed(editor, core) {
|
|
51
|
+
safeCall(function () {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
coreToEditor.delete(core);
|
|
54
|
+
var win = editor.getDocument().defaultView;
|
|
55
|
+
if (win) {
|
|
56
|
+
var editors = win.__ROOSTERJS_DEVTOOLS_EDITORS__;
|
|
57
|
+
var index = editors ? editors.indexOf(editor) : -1;
|
|
58
|
+
if (editors && index >= 0) {
|
|
59
|
+
editors.splice(index, 1);
|
|
60
|
+
}
|
|
61
|
+
(_b = (_a = win.__ROOSTERJS_DEVTOOLS_HOOK__) === null || _a === void 0 ? void 0 : _a.onEditorDisposed) === null || _b === void 0 ? void 0 : _b.call(_a, editor);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.notifyDevToolsEditorDisposed = notifyDevToolsEditorDisposed;
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
* Forward a plugin event to developer tools, if a hook is installed. Failures are swallowed so
|
|
69
|
+
* developer tools can never break the editor.
|
|
70
|
+
* @param core The editor core that dispatched the event
|
|
71
|
+
* @param event The plugin event being dispatched
|
|
72
|
+
*/
|
|
73
|
+
function notifyDevToolsPluginEvent(core, event) {
|
|
74
|
+
safeCall(function () {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
var editor = coreToEditor.get(core);
|
|
77
|
+
var win = editor === null || editor === void 0 ? void 0 : editor.getDocument().defaultView;
|
|
78
|
+
if (editor && win) {
|
|
79
|
+
(_b = (_a = win.__ROOSTERJS_DEVTOOLS_HOOK__) === null || _a === void 0 ? void 0 : _a.onPluginEvent) === null || _b === void 0 ? void 0 : _b.call(_a, editor, event);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.notifyDevToolsPluginEvent = notifyDevToolsPluginEvent;
|
|
84
|
+
function safeCall(callback) {
|
|
85
|
+
try {
|
|
86
|
+
callback();
|
|
87
|
+
}
|
|
88
|
+
catch (_a) { }
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=devtoolsHook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtoolsHook.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts"],"names":[],"mappings":";;;;IAOA;;;;;;;;OAQG;IACU,QAAA,4BAA4B,GAAW,CAAC,CAAC;IAetD,gGAAgG;IAChG,2EAA2E;IAC3E,IAAM,YAAY,GAAG,IAAI,OAAO,EAAuB,CAAC;IAExD;;;;;;OAMG;IACH,SAAgB,2BAA2B,CAAC,MAAe,EAAE,IAAgB;QACzE,QAAQ,CAAC;;YACL,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAE/B,IAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,WAAgD,CAAC;YAElF,IAAI,GAAG,EAAE;gBACL,IAAM,OAAO,GAAG,MAAA,G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M,uBAAN,MAAM,CAAE,WAAW,GAAG,WAAgD,CAAC;YAEnF,IAAI,MAAM,IAAI,GAAG,EAAE;gBACf,MAAA,MAAA,GAAG,CAAC,2BAA2B,0CAAE,aAAa,mDAAG,MAAM,EAAE,KAAK,CAAC,CAAC;aACnE;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IATD,8DASC;IAED,SAAS,QAAQ,CAAC,QAAoB;QAClC,IAAI;YACA,QAAQ,EAAE,CAAC;SACd;QAAC,WAAM,GAAE;IACd,CAAC","sourcesContent":["import type {\n EditorCore,\n IEditor,\n PluginEvent,\n RoosterJsDevToolsHook,\n} from 'roosterjs-content-model-types';\n\n/**\n * The current version of the RoosterJS DevTools hook contract (see\n * {@link RoosterJsDevToolsHook}). The editor stamps this onto the installed hook so a developer\n * tool can adapt to the editor's capabilities. Bump this whenever the shape of the contract changes\n * in a way tools may need to detect.\n *\n * History:\n * - 1: onEditorCreated, onEditorDisposed, onPluginEvent\n */\nexport const RoosterJsDevToolsHookVersion: number = 1;\n\ninterface DevToolsGlobals {\n /**\n * The hook object installed by a developer tool to receive editor notifications\n */\n __ROOSTERJS_DEVTOOLS_HOOK__?: RoosterJsDevToolsHook;\n\n /**\n * An array maintained by the library that always tracks the currently live editor instances on\n * the page, so a tool attaching after editors are created can still discover them.\n */\n __ROOSTERJS_DEVTOOLS_EDITORS__?: IEditor[];\n}\n\n// Maps an editor core back to its IEditor wrapper, so plugin events (which only carry the core)\n// can be attributed to the right editor when forwarded to developer tools.\nconst coreToEditor = new WeakMap<EditorCore, IEditor>();\n\n/**\n * @internal\n * Notify developer tools that an editor has been created. Failures are swallowed so developer\n * tools can never break the editor.\n * @param editor The editor that was created\n * @param core The editor core, used to attribute later plugin events to this editor\n */\nexport function notifyDevToolsEditorCreated(editor: IEditor, core: EditorCore) {\n safeCall(() => {\n coreToEditor.set(core, editor);\n\n const win = editor.getDocument().defaultView as (Window & DevToolsGlobals) | null;\n\n if (win) {\n const editors = win.__ROOSTERJS_DEVTOOLS_EDITORS__ ?? [];\n\n editors.push(editor);\n win.__ROOSTERJS_DEVTOOLS_EDITORS__ = editors;\n\n const hook = win.__ROOSTERJS_DEVTOOLS_HOOK__;\n\n if (hook) {\n hook.version = RoosterJsDevToolsHookVersion;\n hook.onEditorCreated?.(editor);\n }\n }\n });\n}\n\n/**\n * @internal\n * Notify developer tools that an editor is about to be disposed. Failures are swallowed so\n * developer tools can never break the editor.\n * @param editor The editor that is being disposed\n * @param core The editor core to stop tracking\n */\nexport function notifyDevToolsEditorDisposed(editor: IEditor, core: EditorCore) {\n safeCall(() => {\n coreToEditor.delete(core);\n\n const win = editor.getDocument().defaultView as (Window & DevToolsGlobals) | null;\n\n if (win) {\n const editors = win.__ROOSTERJS_DEVTOOLS_EDITORS__;\n const index = editors ? editors.indexOf(editor) : -1;\n\n if (editors && index >= 0) {\n editors.splice(index, 1);\n }\n\n win.__ROOSTERJS_DEVTOOLS_HOOK__?.onEditorDisposed?.(editor);\n }\n });\n}\n\n/**\n * @internal\n * Forward a plugin event to developer tools, if a hook is installed. Failures are swallowed so\n * developer tools can never break the editor.\n * @param core The editor core that dispatched the event\n * @param event The plugin event being dispatched\n */\nexport function notifyDevToolsPluginEvent(core: EditorCore, event: PluginEvent) {\n safeCall(() => {\n const editor = coreToEditor.get(core);\n const win = editor?.getDocument().defaultView as (Window & DevToolsGlobals) | null;\n\n if (editor && win) {\n win.__ROOSTERJS_DEVTOOLS_HOOK__?.onPluginEvent?.(editor, event);\n }\n });\n}\n\nfunction safeCall(callback: () => void) {\n try {\n callback();\n } catch {}\n}\n"]}
|
|
@@ -15,7 +15,7 @@ export function exportContent(editor, mode, optionsOrCallbacks) {
|
|
|
15
15
|
var clonedRoot = editor.getDOMHelper().getClonedRoot();
|
|
16
16
|
if (editor.isDarkMode()) {
|
|
17
17
|
transformColor(clonedRoot, false /*includeSelf*/, 'darkToLight', editor.getColorManager(), {
|
|
18
|
-
tableBorders:
|
|
18
|
+
tableBorders: true,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
return getHTMLFromDOM(editor, clonedRoot);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/exportContent/exportContent.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GACjB,MAAM,6BAA6B,CAAC;AA6CrC,yKAAyK;AACzK,6GAA6G;AAC7G,MAAM,UAAU,aAAa,CACzB,MAAe,EACf,IAAiD,EACjD,kBAA4D;IAD5D,qBAAA,EAAA,iBAAiD;IAGjD,IAAI,KAA2B,CAAC;IAEhC,QAAQ,IAAI,EAAE;QACV,KAAK,eAAe;YAChB,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC,cAAc,EAAE,CAAC;QAClD,KAAK,WAAW;YACZ,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YAE5C,OAAO,kBAAkB,CACrB,KAAK,EACL,SAAS,CAAC,aAAa,EACvB,kBAA0C,CAC7C,CAAC;QAEN,KAAK,UAAU,CAAC;QAChB;YACI,IAAM,UAAU,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,aAAa,EAAE,CAAC;YAEzD,IAAI,MAAM,CAAC,UAAU,EAAE,EAAE;gBACrB,cAAc,CACV,UAAU,EACV,KAAK,CAAC,eAAe,EACrB,aAAa,EACb,MAAM,CAAC,eAAe,EAAE,EACxB;oBACI,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"exportContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/exportContent/exportContent.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GACjB,MAAM,6BAA6B,CAAC;AA6CrC,yKAAyK;AACzK,6GAA6G;AAC7G,MAAM,UAAU,aAAa,CACzB,MAAe,EAC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C;IAEvF,OAAO,IAAI,CAAC,SAAS,CAAC;AAC1B,CAAC","sourcesContent":["import {\n contentModelToDom,\n contentModelToText,\n createModelToDomContext,\n transformColor,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ExportContentMode,\n IEditor,\n ModelToDomOption,\n ModelToTextCallbacks,\n} from 'roosterjs-content-model-types';\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity\n * @param editor The editor to get content from\n * @param mode Specify HTML to get HTML.\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity.\n * This is a fast version, it retrieve HTML content directly from editor without going through content model conversion.\n * @param editor The editor to get content from\n * @param mode Specify HTMLFast to get HTML result. This is the default option\n */\nexport function exportContent(editor: IEditor, mode?: 'HTMLFast'): string;\n\n/**\n * Export plain text content\n * @param editor The editor to get content from\n * @param mode Specify PlainText to get plain text result\n * @param callbacks @optional Callbacks to customize conversion behavior\n */\nexport function exportContent(\n editor: IEditor,\n mode: 'PlainText',\n callbacks?: ModelToTextCallbacks\n): string;\n\n/**\n * Export plain text using editor's textContent property directly\n * @param editor The editor to get content from\n * @param mode Specify PlainTextFast to get plain text result using textContent property\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode: 'PlainTextFast'): string;\n\n// Here I didn't add 'HTMLFast' to ExportContentMode type because it will make this a breaking change and EditorAdapter will see build time error without bumping version\n// Once we are confident that 'HTMLFast' is stable, we can fully switch 'HTML' to use the 'HTMLFast' approach\nexport function exportContent(\n editor: IEditor,\n mode: ExportContentMode | 'HTMLFast' = 'HTMLFast',\n optionsOrCallbacks?: ModelToDomOption | ModelToTextCallbacks\n): string {\n let model: ContentModelDocument;\n\n switch (mode) {\n case 'PlainTextFast':\n return editor.getDOMHelper().getTextContent();\n case 'PlainText':\n model = editor.getContentModelCopy('clean');\n\n return contentModelToText(\n model,\n undefined /*separator*/,\n optionsOrCallbacks as ModelToTextCallbacks\n );\n\n case 'HTMLFast':\n default:\n const clonedRoot = editor.getDOMHelper().getClonedRoot();\n\n if (editor.isDarkMode()) {\n transformColor(\n clonedRoot,\n false /*includeSelf*/,\n 'darkToLight',\n editor.getColorManager(),\n {\n tableBorders: true,\n }\n );\n }\n\n return getHTMLFromDOM(editor, clonedRoot);\n\n case 'HTML':\n model = editor.getContentModelCopy('clean');\n\n const doc = editor.getDocument();\n const div = doc.createElement('div');\n\n contentModelToDom(\n doc,\n div,\n model,\n createModelToDomContext(\n undefined /*editorContext*/,\n optionsOrCallbacks as ModelToDomOption\n )\n );\n\n return getHTMLFromDOM(editor, div);\n }\n}\n\nfunction getHTMLFromDOM(editor: IEditor, root: HTMLElement): string {\n editor.triggerEvent('extractContentWithDom', { clonedRoot: root }, true /*broadcast*/);\n\n return root.innerHTML;\n}\n"]}
|
|
@@ -7,14 +7,15 @@ var BlackColor = 'rgb(0,0,0)';
|
|
|
7
7
|
*/
|
|
8
8
|
export function mergePasteContent(editor, eventResult, isFirstPaste) {
|
|
9
9
|
var fragment = eventResult.fragment, domToModelOption = eventResult.domToModelOption, customizedMerge = eventResult.customizedMerge, pasteType = eventResult.pasteType, clipboardData = eventResult.clipboardData, containsBlockElements = eventResult.containsBlockElements;
|
|
10
|
-
var
|
|
10
|
+
var isImageOnly = isImageOnlyFragment(fragment);
|
|
11
|
+
var shouldScrollCaretIntoView = !isImageOnly;
|
|
11
12
|
editor.formatContentModel(function (model, context) {
|
|
12
13
|
if (!isFirstPaste && clipboardData.modelBeforePaste) {
|
|
13
14
|
var clonedModel = cloneModelForPaste(clipboardData.modelBeforePaste);
|
|
14
15
|
model.blocks = clonedModel.blocks;
|
|
15
16
|
}
|
|
16
17
|
var domToModelContext = createDomToModelContextForSanitizing(editor.getDocument(), undefined /*defaultFormat*/, editor.getEnvironment().domToModelSettings.customized, domToModelOption, editor.getDOMHelper(), editor.getExperimentalFeatures());
|
|
17
|
-
domToModelContext.segmentFormat = getSegmentFormatForPaste(model, pasteType);
|
|
18
|
+
domToModelContext.segmentFormat = getSegmentFormatForPaste(model, pasteType, isImageOnly);
|
|
18
19
|
var pasteModel = domToContentModel(fragment, domToModelContext);
|
|
19
20
|
var mergeOption = {
|
|
20
21
|
mergeFormat: pasteType == 'mergeFormat' ? 'keepSourceEmphasisFormat' : 'none',
|
|
@@ -37,14 +38,16 @@ export function mergePasteContent(editor, eventResult, isFirstPaste) {
|
|
|
37
38
|
apiName: 'paste',
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
function getSegmentFormatForPaste(model, pasteType) {
|
|
41
|
+
function getSegmentFormatForPaste(model, pasteType, isImageOnly) {
|
|
41
42
|
var selectedSegment = getSelectedSegments(model, true /*includeFormatHolder*/)[0];
|
|
42
43
|
if (selectedSegment) {
|
|
43
44
|
var result = getSegmentTextFormat(selectedSegment);
|
|
44
|
-
if (pasteType == 'normal') {
|
|
45
|
+
if (pasteType == 'normal' && !isImageOnly) {
|
|
45
46
|
// When using normal paste (Keep source formatting) set the default text color to black when creating the
|
|
46
47
|
// Model from the clipboard content, so the elements that do not contain any text color in their style
|
|
47
48
|
// Are set to black. Otherwise, These segments would get the selected segments format or the default text set in the content.
|
|
49
|
+
// Skip this when pasting an image only, since there is no text to apply the default color to, and forcing
|
|
50
|
+
// black here would incorrectly become the pending format used for text typed right after the pasted image.
|
|
48
51
|
result.textColor = BlackColor;
|
|
49
52
|
}
|
|
50
53
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergePasteContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/paste/mergePasteContent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AACnH,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,kBAAkB,GACrB,MAAM,6BAA6B,CAAC;AAWrC,IAAM,UAAU,GAAG,YAAY,CAAC;AAEhC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC7B,MAAe,EACf,WAA6B,EAC7B,YAAqB;IAGjB,IAAA,QAAQ,GAMR,WAAW,SANH,EACR,gBAAgB,GAKhB,WAAW,iBALK,EAChB,eAAe,GAIf,WAAW,gBAJI,EACf,SAAS,GAGT,WAAW,UAHF,EACT,aAAa,GAEb,WAAW,cAFE,EACb,qBAAqB,GACrB,WAAW,sBADU,CACT;IAEhB,IAAM,
|
|
1
|
+
{"version":3,"file":"mergePasteContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/paste/mergePasteContent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AACnH,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,kBAAkB,GACrB,MAAM,6BAA6B,CAAC;AAWrC,IAAM,UAAU,GAAG,YAAY,CAAC;AAEhC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC7B,MAAe,EACf,WAA6B,EAC7B,YAAqB;IAGjB,IAAA,QAAQ,GAMR,WAAW,SANH,EACR,gBAAgB,GAKhB,WAAW,iBALK,EAChB,eAAe,GAIf,WAAW,gBAJI,EACf,SAAS,GAGT,WAAW,UAHF,EACT,aAAa,GAEb,WAAW,cAFE,EACb,qBAAqB,GACrB,WAAW,sBADU,CACT;IAEhB,IAAM,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAM,yBAAyB,GAAG,CAAC,WAAW,CAAC;IAE/C,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,CAAC,YAAY,IAAI,aAAa,CAAC,gBAAgB,EAAE;Y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AO,CAAC;AACxF,CAAC;AAED,SAAS,oBAAoB,CAAC,UAAgC;IAC1D,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;QACzB,IAAA,KAAA,OAAe,UAAU,CAAC,MAAM,IAAA,EAA/B,UAAU,QAAqB,CAAC;QAEvC,IAAI,UAAU,CAAC,SAAS,IAAI,WAAW,EAAE;YACrC,IAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAEpE,oBACO,OAAO,CAAC,MAAM,EACnB;SACL;KACJ;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAED,SAAS,mBAAmB,CAAC,aAA+B;;IACxD,IAAM,MAAM,GAAG,aAAa,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACrD,OAAO,CACH,MAAM,CAAC,MAAM,KAAK,CAAC;QACnB,aAAa,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;QACrC,CAAA,MAAA,aAAa,CAAC,WAAW,0CAAE,IAAI,EAAE,MAAK,EAAE,CAC3C,CAAC;AACN,CAAC","sourcesContent":["import { createDomToModelContextForSanitizing } from '../createModelFromHtml/createDomToModelContextForSanitizing';\nimport {\n ChangeSource,\n EmptySegmentFormat,\n domToContentModel,\n getSegmentTextFormat,\n getSelectedSegments,\n mergeModel,\n cloneModelForPaste,\n} from 'roosterjs-content-model-dom';\nimport type {\n BeforePasteEvent,\n ContentModelDocument,\n ContentModelSegmentFormat,\n IEditor,\n MergeModelOption,\n PasteType,\n ShallowMutableContentModelDocument,\n} from 'roosterjs-content-model-types';\n\nconst BlackColor = 'rgb(0,0,0)';\n\n/**\n * @internal\n */\nexport function mergePasteContent(\n editor: IEditor,\n eventResult: BeforePasteEvent,\n isFirstPaste: boolean\n) {\n const {\n fragment,\n domToModelOption,\n customizedMerge,\n pasteType,\n clipboardData,\n containsBlockElements,\n } = eventResult;\n\n const isImageOnly = isImageOnlyFragment(fragment);\n const shouldScrollCaretIntoView = !isImageOnly;\n\n editor.formatContentModel(\n (model, context) => {\n if (!isFirstPaste && clipboardData.modelBeforePaste) {\n const clonedModel = cloneModelForPaste(clipboardData.modelBeforePaste);\n model.blocks = clonedModel.blocks;\n }\n\n const domToModelContext = createDomToModelContextForSanitizing(\n editor.getDocument(),\n undefined /*defaultFormat*/,\n editor.getEnvironment().domToModelSettings.customized,\n domToModelOption,\n editor.getDOMHelper(),\n editor.getExperimentalFeatures()\n );\n\n domToModelContext.segmentFormat = getSegmentFormatForPaste(\n model,\n pasteType,\n isImageOnly\n );\n\n const pasteModel = domToContentModel(fragment, domToModelContext);\n const mergeOption: MergeModelOption = {\n mergeFormat: pasteType == 'mergeFormat' ? 'keepSourceEmphasisFormat' : 'none',\n mergeTable: shouldMergeTable(pasteModel),\n addParagraphAfterMergedContent: containsBlockElements,\n };\n\n const insertPoint = customizedMerge\n ? customizedMerge(model, pasteModel)\n : mergeModel(model, pasteModel, context, mergeOption);\n\n if (insertPoint) {\n context.newPendingFormat = {\n ...EmptySegmentFormat,\n ...model.format,\n ...(pasteType == 'normal' && !containsBlockElements\n ? getLastSegmentFormat(pasteModel)\n : insertPoint.marker.format),\n };\n }\n\n return true;\n },\n {\n changeSource: ChangeSource.Paste,\n getChangeData: () => clipboardData,\n scrollCaretIntoView: shouldScrollCaretIntoView,\n apiName: 'paste',\n }\n );\n}\n\nfunction getSegmentFormatForPaste(\n model: ShallowMutableContentModelDocument,\n pasteType: PasteType,\n isImageOnly: boolean\n): ContentModelSegmentFormat {\n const selectedSegment = getSelectedSegments(model, true /*includeFormatHolder*/)[0];\n\n if (selectedSegment) {\n const result = getSegmentTextFormat(selectedSegment);\n if (pasteType == 'normal' && !isImageOnly) {\n // When using normal paste (Keep source formatting) set the default text color to black when creating the\n // Model from the clipboard content, so the elements that do not contain any text color in their style\n // Are set to black. Otherwise, These segments would get the selected segments format or the default text set in the content.\n // Skip this when pasting an image only, since there is no text to apply the default color to, and forcing\n // black here would incorrectly become the pending format used for text typed right after the pasted image.\n result.textColor = BlackColor;\n }\n\n return result;\n }\n\n return {};\n}\n\nfunction shouldMergeTable(pasteModel: ContentModelDocument): boolean | undefined {\n // If model contains a table and a paragraph element after the table with a single BR segment, remove the Paragraph after the table\n if (\n pasteModel.blocks.length == 2 &&\n pasteModel.blocks[0].blockType === 'Table' &&\n pasteModel.blocks[1].blockType === 'Paragraph' &&\n pasteModel.blocks[1].segments.length === 1 &&\n pasteModel.blocks[1].segments[0].segmentType === 'Br'\n ) {\n pasteModel.blocks.splice(1);\n }\n // Only merge table when the document contain a single table.\n return pasteModel.blocks.length === 1 && pasteModel.blocks[0].blockType === 'Table';\n}\n\nfunction getLastSegmentFormat(pasteModel: ContentModelDocument): ContentModelSegmentFormat {\n if (pasteModel.blocks.length == 1) {\n const [firstBlock] = pasteModel.blocks;\n\n if (firstBlock.blockType == 'Paragraph') {\n const segment = firstBlock.segments[firstBlock.segments.length - 1];\n\n return {\n ...segment.format,\n };\n }\n }\n\n return {};\n}\n\nfunction isImageOnlyFragment(pasteFragment: DocumentFragment): boolean {\n const images = pasteFragment.querySelectorAll('img');\n return (\n images.length === 1 &&\n pasteFragment.childNodes.length === 1 &&\n pasteFragment.textContent?.trim() === ''\n );\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { cleanHtmlComments } from './cleanHtmlComments';
|
|
2
|
-
import { cloneModelForPaste } from 'roosterjs-content-model-dom';
|
|
2
|
+
import { cloneModelForPaste, createPasteFragment } from 'roosterjs-content-model-dom';
|
|
3
3
|
import { convertInlineCss } from '../createModelFromHtml/convertInlineCss';
|
|
4
|
-
import { createPasteFragment } from './createPasteFragment';
|
|
5
4
|
import { generatePasteOptionFromPlugins } from './generatePasteOptionFromPlugins';
|
|
6
5
|
import { mergePasteContent } from './mergePasteContent';
|
|
7
6
|
import { retrieveHtmlInfo } from './retrieveHtmlInfo';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paste.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/paste/paste.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"paste.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/paste/paste.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQtD;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CACjB,MAAe,EACf,aAA4B,EAC5B,iBAA+C;;IAA/C,kCAAA,EAAA,4BAA+C;IAE/C,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE;QACjC,YAAY,GAAG,IAAI,CAAC;QAEpB,MAAM,CAAC,kBAAkB,CAAC,UAAA,KAAK;YAC3B,aAAa,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAE3D,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;KACN;IAED,uBAAuB;IACvB,IAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IAC1C,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,aAAa,CAAC,OAAO,EAAE;QACjD,aAAa,CAAC,OAAO,GAAG,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;KACpE;IACD,IAAM,GAAG,GAAG,iBAAiB,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAEjE,gCAAgC;IAChC,IAAM,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IAE/D,IAAM,SAAS,GACX,OAAO,iBAAiB,IAAI,UAAU;QAClC,CAAC,CAAC,iBAAiB,CACb,GAAG,EACH,aAAa,EACb,MAAM,CAAC,cAAc,EAAE,EACvB,iBAAiB,CAAC,QAAQ,CAC7B;QACH,CAAC,CAAC,iBAAiB,CAAC;IAE5B,4BAA4B;IAC5B,IAAM,cAAc,GAAG,mBAAmB,CACtC,MAAM,CAAC,WAAW,EAAE,EACpB,aAAa,EACb,SAAS,EACT,MAAA,CAAC,aAAa,CAAC,OAAO,IAAI,aAAa,CAAC,IAAI;QACxC,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,iBAAiB,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CACtD,0CAAE,IAAI,CACV,CAAC;IAEF,oEAAoE;IACpE,IAAM,WAAW,GAAG,8BAA8B,CAC9C,MAAM,EACN,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,SAAS,CACZ,CAAC;IAEF,sCAAsC;IACtC,gBAAgB,CAAC,WAAW,CAAC,QAAQ,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAEzE,kDAAkD;IAClD,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,iBAAiB,CACtB,IAA+B,EAC/B,UAAsB;IAEtB,OAAO,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC","sourcesContent":["import { cleanHtmlComments } from './cleanHtmlComments';\nimport { cloneModelForPaste, createPasteFragment } from 'roosterjs-content-model-dom';\nimport { convertInlineCss } from '../createModelFromHtml/convertInlineCss';\nimport { generatePasteOptionFromPlugins } from './generatePasteOptionFromPlugins';\nimport { mergePasteContent } from './mergePasteContent';\nimport { retrieveHtmlInfo } from './retrieveHtmlInfo';\nimport type {\n PasteTypeOrGetter,\n ClipboardData,\n IEditor,\n DOMCreator,\n} from 'roosterjs-content-model-types';\n\n/**\n * Paste into editor using a clipboardData object\n * @param editor The Editor object.\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteTypeOrGetter Type of content to paste or function that returns the Paste Type to use based on the document and the clipboard Data. @default normal\n */\nexport function paste(\n editor: IEditor,\n clipboardData: ClipboardData,\n pasteTypeOrGetter: PasteTypeOrGetter = 'normal'\n) {\n editor.focus();\n let isFirstPaste = false;\n\n if (!clipboardData.modelBeforePaste) {\n isFirstPaste = true;\n\n editor.formatContentModel(model => {\n clipboardData.modelBeforePaste = cloneModelForPaste(model);\n\n return false;\n });\n }\n\n // 1. Prepare variables\n const domCreator = editor.getDOMCreator();\n if (!domCreator.isBypassed && clipboardData.rawHtml) {\n clipboardData.rawHtml = cleanHtmlComments(clipboardData.rawHtml);\n }\n const doc = createDOMFromHtml(clipboardData.rawHtml, domCreator);\n\n // 2. Handle HTML from clipboard\n const htmlFromClipboard = retrieveHtmlInfo(doc, clipboardData);\n\n const pasteType =\n typeof pasteTypeOrGetter == 'function'\n ? pasteTypeOrGetter(\n doc,\n clipboardData,\n editor.getEnvironment(),\n htmlFromClipboard.metadata\n )\n : pasteTypeOrGetter;\n\n // 3. Create target fragment\n const sourceFragment = createPasteFragment(\n editor.getDocument(),\n clipboardData,\n pasteType,\n (clipboardData.rawHtml == clipboardData.html\n ? doc\n : createDOMFromHtml(clipboardData.html, domCreator)\n )?.body\n );\n\n // 4. Trigger BeforePaste event to allow plugins modify the fragment\n const eventResult = generatePasteOptionFromPlugins(\n editor,\n clipboardData,\n sourceFragment,\n htmlFromClipboard,\n pasteType\n );\n\n // 5. Convert global CSS to inline CSS\n convertInlineCss(eventResult.fragment, htmlFromClipboard.globalCssRules);\n\n // 6. Merge pasted content into main Content Model\n mergePasteContent(editor, eventResult, isFirstPaste);\n}\n\nfunction createDOMFromHtml(\n html: string | null | undefined,\n domCreator: DOMCreator\n): Document | null {\n return html ? domCreator.htmlToDOM(html) : null;\n}\n"]}
|
|
@@ -7,7 +7,7 @@ export function restoreSnapshotColors(core, snapshot) {
|
|
|
7
7
|
core.darkColorHandler.updateKnownColor(isDarkMode); // Pass no parameter to force update all colors
|
|
8
8
|
if (!!snapshot.isDarkMode != !!isDarkMode) {
|
|
9
9
|
transformColor(core.physicalRoot, false /*includeSelf*/, isDarkMode ? 'lightToDark' : 'darkToLight', core.darkColorHandler, {
|
|
10
|
-
tableBorders:
|
|
10
|
+
tableBorders: true,
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreSnapshotColors.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/restoreUndoSnapshot/restoreSnapshotColors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAgB,EAAE,QAAkB;IACtE,IAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;IAE7C,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,+CAA+C;IAEnG,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,EAAE;QACvC,cAAc,CACV,IAAI,CAAC,YAAY,EACjB,KAAK,CAAC,eAAe,EACrB,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,EAC1C,IAAI,CAAC,gBAAgB,EACrB;YACI,YAAY,EAAE,IAAI
|
|
1
|
+
{"version":3,"file":"restoreSnapshotColors.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/restoreUndoSnapshot/restoreSnapshotColors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAgB,EAAE,QAAkB;IACtE,IAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;IAE7C,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,+CAA+C;IAEnG,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,EAAE;QACvC,cAAc,CACV,IAAI,CAAC,YAAY,EACjB,KAAK,CAAC,eAAe,EACrB,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,EAC1C,IAAI,CAAC,gBAAgB,EACrB;YACI,YAAY,EAAE,IAAI;SACrB,CACJ,CAAC;KACL;AACL,CAAC","sourcesContent":["import { transformColor } from 'roosterjs-content-model-dom';\nimport type { EditorCore, Snapshot } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function restoreSnapshotColors(core: EditorCore, snapshot: Snapshot) {\n const isDarkMode = core.lifecycle.isDarkMode;\n\n core.darkColorHandler.updateKnownColor(isDarkMode); // Pass no parameter to force update all colors\n\n if (!!snapshot.isDarkMode != !!isDarkMode) {\n transformColor(\n core.physicalRoot,\n false /*includeSelf*/,\n isDarkMode ? 'lightToDark' : 'darkToLight',\n core.darkColorHandler,\n {\n tableBorders: true,\n }\n );\n }\n}\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ensureUniqueId } from '../setEditorStyle/ensureUniqueId';
|
|
2
2
|
import { getSafeIdSelector, isNodeOfType, toArray } from 'roosterjs-content-model-dom';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export var DOM_SELECTION_CSS_KEY = '_DOMSelection';
|
|
4
7
|
var TABLE_ID = 'table';
|
|
5
8
|
/**
|
|
6
9
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTableCellsStyle.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/setTableCellsStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGvF,IAAM,qBAAqB,GAAG,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"setTableCellsStyle.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/setTableCellsStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGvF;;GAEG;AACH,MAAM,CAAC,IAAM,qBAAqB,GAAG,eAAe,CAAC;AACrD,IAAM,QAAQ,GAAG,OAAO,CAAC;AAEzB;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAgB;IAClD,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAC9B,IAAgB,EAChB,KAAuB,EACvB,WAAwB,EACxB,SAA8B,EAC9B,QAA6B;;IAE7B,IAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAChD,IAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACjD,IAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU;QACjD,CAAC,CAAC,I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mBAAc,OAAO,MAAG,CAAC;oBAEzH,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAC;iBAC7C;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import { ensureUniqueId } from '../setEditorStyle/ensureUniqueId';\nimport { getSafeIdSelector, isNodeOfType, toArray } from 'roosterjs-content-model-dom';\nimport type { EditorCore, ParsedTable, TableCellCoordinate } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const DOM_SELECTION_CSS_KEY = '_DOMSelection';\nconst TABLE_ID = 'table';\n\n/**\n * @internal\n * Remove table cell selection styles\n * @param core The EditorCore object\n */\nexport function removeTableCellsStyle(core: EditorCore) {\n core.api.setEditorStyle(core, DOM_SELECTION_CSS_KEY, '');\n}\n\n/**\n * @internal\n * Set style for table cells in the selection\n * @param core The EditorCore object\n * @param table The HTML table element\n * @param parsedTable The parsed table structure\n * @param firstCell The coordinates of the first selected cell\n * @param lastCell The coordinates of the last selected cell\n */\nexport function setTableCellsStyle(\n core: EditorCore,\n table: HTMLTableElement,\n parsedTable: ParsedTable,\n firstCell: TableCellCoordinate,\n lastCell: TableCellCoordinate\n) {\n const tableId = ensureUniqueId(table, TABLE_ID);\n const tableSelector = getSafeIdSelector(tableId);\n const tableSelectionColor = core.lifecycle.isDarkMode\n ? core.selection.tableCellSelectionBackgroundColorDark\n : core.selection.tableCellSelectionBackgroundColor;\n\n const tableSelectors =\n firstCell.row == 0 &&\n firstCell.col == 0 &&\n lastCell.row == parsedTable.length - 1 &&\n lastCell.col == (parsedTable[lastCell.row]?.length ?? 0) - 1\n ? [tableSelector, `${tableSelector} *`]\n : buildTableSelectors(parsedTable, tableSelector, table, firstCell, lastCell);\n\n core.api.setEditorStyle(\n core,\n DOM_SELECTION_CSS_KEY,\n `background-color:${tableSelectionColor}!important;`,\n tableSelectors\n );\n}\n\n/**\n * @internal\n * Build CSS selectors for table cells within the selection range\n */\nfunction buildTableSelectors(\n parsedTable: ParsedTable,\n tableSelector: string,\n table: HTMLTableElement,\n firstCell: TableCellCoordinate,\n lastCell: TableCellCoordinate\n): string[] {\n const selectors: string[] = [];\n\n let cont = 0;\n const indexes = toArray(table.childNodes)\n .filter(\n (node): node is HTMLTableSectionElement =>\n ['THEAD', 'TBODY', 'TFOOT'].indexOf(\n isNodeOfType(node, 'ELEMENT_NODE') ? node.tagName : ''\n ) > -1\n )\n .map(node => {\n const result = {\n el: node.tagName,\n start: cont,\n end: node.childNodes.length + cont,\n };\n\n cont = result.end;\n return result;\n });\n\n parsedTable.forEach((row, rowIndex) => {\n let tdCount = 0;\n\n const midElement = indexes.filter(ind => ind.start <= rowIndex && ind.end > rowIndex)[0];\n const middleElSelector = midElement ? '>' + midElement.el + '>' : '>';\n const currentRow =\n midElement && rowIndex + 1 >= midElement.start\n ? rowIndex + 1 - midElement.start\n : rowIndex + 1;\n\n for (let cellIndex = 0; cellIndex < row.length; cellIndex++) {\n const cell = row[cellIndex];\n\n if (typeof cell == 'object') {\n tdCount++;\n\n if (\n rowIndex >= firstCell.row &&\n rowIndex <= lastCell.row &&\n cellIndex >= firstCell.col &&\n cellIndex <= lastCell.col\n ) {\n const selector = `${tableSelector}${middleElSelector} tr:nth-child(${currentRow})>${cell.tagName}:nth-child(${tdCount})`;\n\n selectors.push(selector, selector + ' *');\n }\n }\n }\n });\n\n return selectors;\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
var CARET_CSS_RULE = 'caret-color: transparent';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export var HIDE_CURSOR_CSS_KEY = '_DOMSelectionHideCursor';
|
|
3
6
|
/**
|
|
4
7
|
* @internal Show/Hide caret in editor
|
|
5
8
|
* @param core The editor core
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleCaret.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/toggleCaret.ts"],"names":[],"mappings":"AAEA,IAAM,cAAc,GAAG,0BAA0B,CAAC;AAClD,IAAM,mBAAmB,GAAG,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"toggleCaret.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/toggleCaret.ts"],"names":[],"mappings":"AAEA,IAAM,cAAc,GAAG,0BAA0B,CAAC;AAClD;;GAEG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,QAAiB;IAC3D,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACzF,CAAC","sourcesContent":["import type { EditorCore } from 'roosterjs-content-model-types';\n\nconst CARET_CSS_RULE = 'caret-color: transparent';\n/**\n * @internal\n */\nexport const HIDE_CURSOR_CSS_KEY = '_DOMSelectionHideCursor';\n\n/**\n * @internal Show/Hide caret in editor\n * @param core The editor core\n * @param isHiding True to hide caret, false to show caret\n */\nexport function toggleCaret(core: EditorCore, isHiding: boolean) {\n core.api.setEditorStyle(core, HIDE_CURSOR_CSS_KEY, isHiding ? CARET_CSS_RULE : null);\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyDevToolsPluginEvent } from '../../utils/devtoolsHook';
|
|
1
2
|
var allowedEventsInShadowEdit = [
|
|
2
3
|
'editorReady',
|
|
3
4
|
'beforeDispose',
|
|
@@ -21,6 +22,7 @@ export var triggerEvent = function (core, pluginEvent, broadcast) {
|
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
24
|
}
|
|
25
|
+
notifyDevToolsPluginEvent(core, pluginEvent);
|
|
24
26
|
};
|
|
25
27
|
function handledExclusively(event, plugin) {
|
|
26
28
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggerEvent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/triggerEvent/triggerEvent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"triggerEvent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/triggerEvent/triggerEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAQrE,IAAM,yBAAyB,GAAsB;IACjD,aAAa;IACb,eAAe;IACf,uBAAuB;IACvB,aAAa;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,IAAM,YAAY,GAAiB,UAAC,IAAI,EAAE,WAAW,EAAE,SAAS;IACnE,IACI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB;QAC/B,yBAAyB,CAAC,OAAO,CAAC,WAAW,CAAC,SAA4B,CAAC,IAAI,CAAC,CAAC;QACrF,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,kBAAkB,CAAC,WAAW,EAAE,MAAM,CAAC,EAAvC,CAAuC,CAAC,CAAC,EACtF;QACE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM;YACvB,IAAI,MAAM,CAAC,aAAa,EAAE;gBACtB,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;aACrC;QACL,CAAC,CAAC,CAAC;KACN;IAED,yBAAyB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,SAAS,kBAAkB,CAAC,KAAkB,EAAE,MAAoB;;IAChE,IAAI,MAAM,CAAC,aAAa,KAAI,MAAA,MAAM,CAAC,0BAA0B,+CAAjC,MAAM,EAA8B,KAAK,CAAC,CAAA,EAAE;QACpE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;KACf;IAED,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import { notifyDevToolsPluginEvent } from '../../utils/devtoolsHook';\nimport type {\n EditorPlugin,\n PluginEvent,\n PluginEventType,\n TriggerEvent,\n} from 'roosterjs-content-model-types';\n\nconst allowedEventsInShadowEdit: PluginEventType[] = [\n 'editorReady',\n 'beforeDispose',\n 'extractContentWithDom',\n 'zoomChanged',\n];\n\n/**\n * @internal\n * Trigger a plugin event\n * @param core The EditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\nexport const triggerEvent: TriggerEvent = (core, pluginEvent, broadcast) => {\n if (\n (!core.lifecycle.shadowEditFragment ||\n allowedEventsInShadowEdit.indexOf(pluginEvent.eventType as PluginEventType) >= 0) &&\n (broadcast || !core.plugins.some(plugin => handledExclusively(pluginEvent, plugin)))\n ) {\n core.plugins.forEach(plugin => {\n if (plugin.onPluginEvent) {\n plugin.onPluginEvent(pluginEvent);\n }\n });\n }\n\n notifyDevToolsPluginEvent(core, pluginEvent);\n};\n\nfunction handledExclusively(event: PluginEvent, plugin: EditorPlugin): boolean {\n if (plugin.onPluginEvent && plugin.willHandleEventExclusively?.(event)) {\n plugin.onPluginEvent(event);\n return true;\n }\n\n return false;\n}\n"]}
|
|
@@ -106,7 +106,7 @@ var EntityPlugin = /** @class */ (function () {
|
|
|
106
106
|
};
|
|
107
107
|
if (editor.isDarkMode()) {
|
|
108
108
|
transformColor(wrapper, true /*includeSelf*/, 'lightToDark', editor.getColorManager(), {
|
|
109
|
-
tableBorders:
|
|
109
|
+
tableBorders: true,
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
}
|