@opentiny/fluent-editor 3.19.4 → 3.20.1
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 +99 -99
- package/es/attributors/index.es.js +1 -1
- package/es/attributors/line-height.es.js.map +1 -1
- package/es/config/base64-image.es.js.map +1 -1
- package/es/config/editor.config.es.js.map +1 -1
- package/es/config/editor.utils.es.js +12 -12
- package/es/config/editor.utils.es.js.map +1 -1
- package/es/config/i18n/en-us.es.js.map +1 -1
- package/es/config/i18n/zh-cn.es.js.map +1 -1
- package/es/config/icons.config.es.js +4 -4
- package/es/config/icons.config.es.js.map +1 -1
- package/es/config/types/index.es.js +2 -2
- package/es/config.es.js +1 -1
- package/es/config.es.js.map +1 -1
- package/es/counter/index.es.js.map +1 -1
- package/es/custom-clipboard.es.js +14 -14
- package/es/custom-clipboard.es.js.map +1 -1
- package/es/custom-image/BlotFormatter.es.js +1 -1
- package/es/custom-image/BlotFormatter.es.js.map +1 -1
- package/es/custom-image/Options.es.js.map +1 -1
- package/es/custom-image/actions/Action.es.js.map +1 -1
- package/es/custom-image/actions/CustomResizeAction.es.js +6 -4
- package/es/custom-image/actions/CustomResizeAction.es.js.map +1 -1
- package/es/custom-image/actions/DeleteAction.es.js.map +1 -1
- package/es/custom-image/image.es.js +3 -3
- package/es/custom-image/image.es.js.map +1 -1
- package/es/custom-image/specs/BlotSpec.es.js.map +1 -1
- package/es/custom-image/specs/CustomImageSpec.es.js.map +1 -1
- package/es/custom-image/specs/ImageSpec.es.js.map +1 -1
- package/es/custom-uploader.es.js +4 -7
- package/es/custom-uploader.es.js.map +1 -1
- package/es/emoji/emoji-list/people.es.js.map +1 -1
- package/es/emoji/emoji-list.es.js.map +1 -1
- package/es/emoji/emoji-map.es.js.map +1 -1
- package/es/emoji/formats/emoji-blot.es.js +2 -2
- package/es/emoji/formats/emoji-blot.es.js.map +1 -1
- package/es/emoji/index.es.js.map +1 -1
- package/es/emoji/modules/emoji.es.js +7 -7
- package/es/emoji/modules/emoji.es.js.map +1 -1
- package/es/emoji/modules/toolbar-emoji.es.js +15 -15
- package/es/emoji/modules/toolbar-emoji.es.js.map +1 -1
- package/es/emoji/utils.es.js.map +1 -1
- package/es/file/formats/file.es.js.map +1 -1
- package/es/file/index.es.js.map +1 -1
- package/es/file/modules/file-bar.es.js +3 -3
- package/es/file/modules/file-bar.es.js.map +1 -1
- package/es/fluent-editor.es.js +6 -5
- package/es/fluent-editor.es.js.map +1 -1
- package/es/format-painter/index.es.js.map +1 -1
- package/es/global-link/constants.es.js.map +1 -1
- package/es/global-link/formats/customer-widget-link.es.js.map +1 -1
- package/es/global-link/formats/doc-link.es.js.map +1 -1
- package/es/global-link/formats/wiki-link.es.js.map +1 -1
- package/es/global-link/formats/work-item-link.es.js.map +1 -1
- package/es/global-link/index.es.js +1 -1
- package/es/global-link/index.es.js.map +1 -1
- package/es/global-link/utils/createTable.es.js.map +1 -1
- package/es/link/formats/link.es.js +1 -1
- package/es/link/formats/link.es.js.map +1 -1
- package/es/link/index.es.js.map +1 -1
- package/es/link/modules/tooltip.es.js +3 -3
- package/es/link/modules/tooltip.es.js.map +1 -1
- package/es/mention/Mention.es.js +7 -12
- package/es/mention/Mention.es.js.map +1 -1
- package/es/mention/MentionLink.es.js.map +1 -1
- package/es/mention/constants.es.js.map +1 -1
- package/es/quick-menu/index.es.js +1 -1
- package/es/quick-menu/index.es.js.map +1 -1
- package/es/screenshot/index.es.js +172 -135
- package/es/screenshot/index.es.js.map +1 -1
- package/es/soft-break/index.es.js.map +1 -1
- package/es/strike/index.es.js.map +1 -1
- package/es/syntax/index.es.js.map +1 -1
- package/es/table/better-table.es.js +4 -5
- package/es/table/better-table.es.js.map +1 -1
- package/es/table/formats/header.es.js.map +1 -1
- package/es/table/formats/list.es.js +3 -3
- package/es/table/formats/list.es.js.map +1 -1
- package/es/table/formats/table.es.js +26 -27
- package/es/table/formats/table.es.js.map +1 -1
- package/es/table/modules/table-column-tool.es.js +8 -8
- package/es/table/modules/table-column-tool.es.js.map +1 -1
- package/es/table/modules/table-operation-menu.es.js +7 -8
- package/es/table/modules/table-operation-menu.es.js.map +1 -1
- package/es/table/modules/table-scroll-bar.es.js +1 -1
- package/es/table/modules/table-scroll-bar.es.js.map +1 -1
- package/es/table/modules/table-selection.es.js +0 -1
- package/es/table/modules/table-selection.es.js.map +1 -1
- package/es/table/table-config.es.js.map +1 -1
- package/es/table/utils/index.es.js.map +1 -1
- package/es/table/utils/node-matchers.es.js +14 -14
- package/es/table/utils/node-matchers.es.js.map +1 -1
- package/es/toolbar/better-picker.es.js.map +1 -1
- package/es/toolbar/index.es.js +1 -1
- package/es/toolbar/index.es.js.map +1 -1
- package/es/utils/debounce.es.js.map +1 -1
- package/es/utils/image.es.js +26 -0
- package/es/utils/image.es.js.map +1 -0
- package/es/utils/method.es.js +2 -2
- package/es/utils/method.es.js.map +1 -1
- package/es/utils/scroll-lock.es.js +47 -0
- package/es/utils/scroll-lock.es.js.map +1 -0
- package/es/video/index.es.js +6 -3
- package/es/video/index.es.js.map +1 -1
- package/lib/attributors/index.cjs.js +2 -2
- package/lib/attributors/line-height.cjs.js.map +1 -1
- package/lib/config/base64-image.cjs.js.map +1 -1
- package/lib/config/editor.config.cjs.js.map +1 -1
- package/lib/config/editor.utils.cjs.js +12 -12
- package/lib/config/editor.utils.cjs.js.map +1 -1
- package/lib/config/i18n/en-us.cjs.js.map +1 -1
- package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
- package/lib/config/icons.config.cjs.js +4 -4
- package/lib/config/icons.config.cjs.js.map +1 -1
- package/lib/config/types/index.cjs.js +2 -2
- package/lib/config.cjs.js +1 -1
- package/lib/config.cjs.js.map +1 -1
- package/lib/counter/index.cjs.js.map +1 -1
- package/lib/custom-clipboard.cjs.js +14 -14
- package/lib/custom-clipboard.cjs.js.map +1 -1
- package/lib/custom-image/BlotFormatter.cjs.js +1 -1
- package/lib/custom-image/BlotFormatter.cjs.js.map +1 -1
- package/lib/custom-image/Options.cjs.js.map +1 -1
- package/lib/custom-image/actions/Action.cjs.js.map +1 -1
- package/lib/custom-image/actions/CustomResizeAction.cjs.js +6 -4
- package/lib/custom-image/actions/CustomResizeAction.cjs.js.map +1 -1
- package/lib/custom-image/actions/DeleteAction.cjs.js.map +1 -1
- package/lib/custom-image/image.cjs.js +3 -3
- package/lib/custom-image/image.cjs.js.map +1 -1
- package/lib/custom-image/specs/BlotSpec.cjs.js.map +1 -1
- package/lib/custom-image/specs/CustomImageSpec.cjs.js.map +1 -1
- package/lib/custom-image/specs/ImageSpec.cjs.js.map +1 -1
- package/lib/custom-uploader.cjs.js +4 -7
- package/lib/custom-uploader.cjs.js.map +1 -1
- package/lib/emoji/emoji-list/people.cjs.js.map +1 -1
- package/lib/emoji/emoji-list.cjs.js.map +1 -1
- package/lib/emoji/emoji-map.cjs.js.map +1 -1
- package/lib/emoji/formats/emoji-blot.cjs.js +2 -2
- package/lib/emoji/formats/emoji-blot.cjs.js.map +1 -1
- package/lib/emoji/index.cjs.js.map +1 -1
- package/lib/emoji/modules/emoji.cjs.js +7 -7
- package/lib/emoji/modules/emoji.cjs.js.map +1 -1
- package/lib/emoji/modules/toolbar-emoji.cjs.js +15 -15
- package/lib/emoji/modules/toolbar-emoji.cjs.js.map +1 -1
- package/lib/emoji/utils.cjs.js.map +1 -1
- package/lib/file/formats/file.cjs.js.map +1 -1
- package/lib/file/index.cjs.js.map +1 -1
- package/lib/file/modules/file-bar.cjs.js +3 -3
- package/lib/file/modules/file-bar.cjs.js.map +1 -1
- package/lib/fluent-editor.cjs.js +25 -24
- package/lib/fluent-editor.cjs.js.map +1 -1
- package/lib/format-painter/index.cjs.js.map +1 -1
- package/lib/global-link/constants.cjs.js.map +1 -1
- package/lib/global-link/formats/customer-widget-link.cjs.js.map +1 -1
- package/lib/global-link/formats/doc-link.cjs.js.map +1 -1
- package/lib/global-link/formats/wiki-link.cjs.js.map +1 -1
- package/lib/global-link/formats/work-item-link.cjs.js.map +1 -1
- package/lib/global-link/index.cjs.js +1 -1
- package/lib/global-link/index.cjs.js.map +1 -1
- package/lib/global-link/utils/createTable.cjs.js.map +1 -1
- package/lib/link/formats/link.cjs.js +1 -1
- package/lib/link/formats/link.cjs.js.map +1 -1
- package/lib/link/index.cjs.js.map +1 -1
- package/lib/link/modules/tooltip.cjs.js +3 -3
- package/lib/link/modules/tooltip.cjs.js.map +1 -1
- package/lib/mention/Mention.cjs.js +7 -12
- package/lib/mention/Mention.cjs.js.map +1 -1
- package/lib/mention/MentionLink.cjs.js.map +1 -1
- package/lib/mention/constants.cjs.js.map +1 -1
- package/lib/quick-menu/index.cjs.js +1 -1
- package/lib/quick-menu/index.cjs.js.map +1 -1
- package/lib/screenshot/index.cjs.js +173 -136
- package/lib/screenshot/index.cjs.js.map +1 -1
- package/lib/soft-break/index.cjs.js.map +1 -1
- package/lib/strike/index.cjs.js.map +1 -1
- package/lib/syntax/index.cjs.js.map +1 -1
- package/lib/table/better-table.cjs.js +4 -5
- package/lib/table/better-table.cjs.js.map +1 -1
- package/lib/table/formats/header.cjs.js.map +1 -1
- package/lib/table/formats/list.cjs.js +3 -3
- package/lib/table/formats/list.cjs.js.map +1 -1
- package/lib/table/formats/table.cjs.js +26 -27
- package/lib/table/formats/table.cjs.js.map +1 -1
- package/lib/table/modules/table-column-tool.cjs.js +8 -8
- package/lib/table/modules/table-column-tool.cjs.js.map +1 -1
- package/lib/table/modules/table-operation-menu.cjs.js +7 -8
- package/lib/table/modules/table-operation-menu.cjs.js.map +1 -1
- package/lib/table/modules/table-scroll-bar.cjs.js +1 -1
- package/lib/table/modules/table-scroll-bar.cjs.js.map +1 -1
- package/lib/table/modules/table-selection.cjs.js +0 -1
- package/lib/table/modules/table-selection.cjs.js.map +1 -1
- package/lib/table/table-config.cjs.js.map +1 -1
- package/lib/table/utils/index.cjs.js.map +1 -1
- package/lib/table/utils/node-matchers.cjs.js +14 -14
- package/lib/table/utils/node-matchers.cjs.js.map +1 -1
- package/lib/toolbar/better-picker.cjs.js.map +1 -1
- package/lib/toolbar/index.cjs.js +1 -1
- package/lib/toolbar/index.cjs.js.map +1 -1
- package/lib/utils/debounce.cjs.js.map +1 -1
- package/lib/utils/image.cjs.js +26 -0
- package/lib/utils/image.cjs.js.map +1 -0
- package/lib/utils/method.cjs.js +2 -2
- package/lib/utils/method.cjs.js.map +1 -1
- package/lib/utils/scroll-lock.cjs.js +47 -0
- package/lib/utils/scroll-lock.cjs.js.map +1 -0
- package/lib/video/index.cjs.js +6 -3
- package/lib/video/index.cjs.js.map +1 -1
- package/package.json +61 -55
- package/{style.css → theme/style.css} +100 -14
- package/es/types/vue.d.es.js +0 -2
- package/es/types/vue.d.es.js.map +0 -1
- package/lib/types/vue.d.cjs.js +0 -2
- package/lib/types/vue.d.cjs.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"better-table.es.js","sources":["../../../src/table/better-table.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport {\r\n getEventComposedPath,\r\n insideTable,\r\n isNullOrUndefined,\r\n isPureIE,\r\n} from '../config/editor.utils'\r\nimport Header from './formats/header'\r\nimport List from './formats/list'\r\nimport {\r\n cellId,\r\n rowId,\r\n TableBody,\r\n TableCell,\r\n TableCellLine,\r\n TableCol,\r\n TableColGroup,\r\n TableContainer,\r\n TableRow,\r\n TableViewWrapper,\r\n} from './formats/table'\r\nimport TableColumnTool from './modules/table-column-tool'\r\nimport TableOperationMenu from './modules/table-operation-menu'\r\nimport TableScrollBar from './modules/table-scroll-bar'\r\nimport TableSelection from './modules/table-selection'\r\n// import table node matchers\r\nimport {\r\n matchHeader,\r\n matchInline,\r\n matchList,\r\n matchMentionLink,\r\n matchTable,\r\n matchTableCell,\r\n matchTableHeader,\r\n matchTableRow,\r\n matchWordShapeImage,\r\n} from './utils/node-matchers'\r\n\r\nconst Block = Quill.imports['blots/block']\r\nconst Delta = Quill.imports['delta']\r\nconst Module = Quill.imports['core/module']\r\n\r\n// @dynamic\r\nclass BetterTable extends Module {\r\n static keyboardBindings: any\r\n isComposition: boolean\r\n quill: any\r\n table: any\r\n modulesContainer: any\r\n tableSelection: any\r\n subscriber: any\r\n tableOperationMenu: any\r\n columnTool: TableColumnTool\r\n tableScrollBar: TableScrollBar\r\n\r\n static register() {\r\n Quill.register(TableCol, true)\r\n Quill.register(TableColGroup, true)\r\n Quill.register(TableCellLine, true)\r\n Quill.register(TableCell, true)\r\n Quill.register(TableRow, true)\r\n Quill.register(TableBody, true)\r\n Quill.register(TableContainer, true)\r\n Quill.register(TableViewWrapper, true)\r\n // register customized Header, overwriting quill built-in Header\r\n Quill.register('formats/header', Header, true)\r\n // register customized List, overwriting quill built-in Header\r\n Quill.register('formats/list', List, true)\r\n }\r\n\r\n constructor(quill, options) {\r\n super(quill, options)\r\n\r\n // handle click on quill-better-table\r\n this.isComposition = false\r\n this.quill.root.addEventListener('mousedown', event => this.handleMouseDown(event, quill), false)\r\n this.quill.root.addEventListener('compositionend', () => this.handleCompositionend(quill), false)\r\n this.quill.root.addEventListener('compositionstart', () => this.handleCompositionstart(quill), false)\r\n this.quill.root.addEventListener('keypress', event => this.handleKeyDown(event, quill), false)\r\n\r\n // handle right click on quill-better-table\r\n this.quill.root.addEventListener(\r\n 'contextmenu',\r\n (evt) => {\r\n if (!this.table) return true\r\n evt.preventDefault()\r\n\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n\r\n const tableNode = path.filter((node) => {\r\n return (\r\n node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n )\r\n })[0]\r\n\r\n const rowNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const cellNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const isTargetCellSelected = this.tableSelection.selectedTds\r\n .map(tableCell => tableCell.domNode)\r\n .includes(cellNode)\r\n\r\n if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) {\r\n this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect())\r\n }\r\n\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu = this.tableOperationMenu.destroy()\r\n }\r\n\r\n if (tableNode) {\r\n this.tableOperationMenu = new TableOperationMenu(\r\n {\r\n table: tableNode,\r\n row: rowNode,\r\n cell: cellNode,\r\n left: evt.x + 15,\r\n top: evt.y,\r\n },\r\n quill,\r\n options.operationMenu,\r\n )\r\n }\r\n },\r\n false,\r\n )\r\n\r\n // add keyboard binding:Backspace\r\n // prevent user hits backspace to delete table cell\r\n quill.keyboard.addBinding({ key: 'Backspace' }, {}, (range, context) => {\r\n if (range.index === 0 || this.quill.getLength() <= 1) return true\r\n if (context.offset === 0 && range.length === 0) {\r\n const [prev] = this.quill.getLine(range.index - 1)\r\n const [line] = this.quill.getLine(range.index)\r\n if (!isNullOrUndefined(prev)) {\r\n if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = prev.parent.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n return false\r\n }\r\n }\r\n }\r\n return true\r\n })\r\n // since only one matched bindings callback will execute.\r\n // expected my binding callback execute first\r\n // I changed the order of binding callbacks\r\n const thisBinding = quill.keyboard.bindings['Backspace'].pop()\r\n quill.keyboard.bindings['Backspace'].splice(1, 0, thisBinding)\r\n\r\n // add Matchers to match and render quill-better-table for initialization\r\n // or pasting\r\n quill.clipboard.addMatcher('td', matchTableCell)\r\n quill.clipboard.addMatcher('th', matchTableHeader)\r\n quill.clipboard.addMatcher('table', matchTable)\r\n quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader)\r\n quill.clipboard.addMatcher('ol, ul', matchList)\r\n quill.clipboard.addMatcher('span', matchMentionLink)\r\n quill.clipboard.addMatcher('v:imageData', matchWordShapeImage)\r\n quill.clipboard.addMatcher(Node.ELEMENT_NODE, matchInline)\r\n\r\n // remove matcher for tr tag\r\n quill.clipboard.matchers = quill.clipboard.matchers.filter((matcher) => {\r\n return matcher[0] !== 'tr'\r\n })\r\n\r\n // fix: 处理空<tr>标签被忽略的情况\r\n quill.clipboard.addMatcher('tr', matchTableRow)\r\n\r\n this.quill.on('editor-change', () => {\r\n const tableContainer = Quill.find(this.table)\r\n if (!tableContainer) {\r\n this.hideTableTools()\r\n }\r\n })\r\n\r\n this.quill.on(Quill.events.SELECTION_CHANGE, (range, _oldRange, source) => {\r\n if (!range) return\r\n const selectionStart = range.index\r\n const selectionEnd = range.index + range.length\r\n if (source === Quill.sources.USER) {\r\n const tables = this.quill.root.getElementsByTagName('table')\r\n if (tables && tables.length) {\r\n [].forEach.call(tables, (table) => {\r\n const tableContainer = Quill.find(table)\r\n if (tableContainer) {\r\n const tableStart = tableContainer.offset(this.quill.scroll)\r\n const tableEnd = tableStart + tableContainer.length()\r\n // @ts-ignore\r\n const classes = Array.from(table.parentNode.classList)\r\n\r\n if (selectionStart <= tableStart && tableEnd <= selectionEnd) {\r\n // @ts-ignore\r\n table.parentNode.classList.add('quill-better-table-selected')\r\n }\r\n else if (classes.indexOf('quill-better-table-selected') >= 0) {\r\n // @ts-ignore\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n }\r\n }\r\n })\r\n }\r\n }\r\n })\r\n }\r\n\r\n handleMouseDown(evt, quill) {\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n const tableNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n })[0]\r\n if (tableNode) {\r\n tableNode.parentNode.classList.remove('quill-better-table-selected')\r\n // current table clicked\r\n if (this.table === tableNode) return\r\n // other table clicked\r\n if (this.table) {\r\n this.hideTableTools()\r\n }\r\n if (!quill.options.readOnly) { // not show table tool in readonly mode\r\n this.showTableTools(tableNode, quill)\r\n }\r\n }\r\n else if (this.table) {\r\n // other clicked\r\n this.hideTableTools()\r\n }\r\n }\r\n\r\n handleKeyDown(evt, quill) {\r\n const key = evt.key\r\n const range = quill.getSelection()\r\n if (this.isComposition || !range) return\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (key && key !== 'Delete' && col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.insertText(range.index, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionstart(quill) {\r\n this.isComposition = true\r\n const range = quill.getSelection()\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n\\t', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionend(quill) {\r\n // fix: 解决在空行行首用中文输入法输入字符,然后按退格导致插入多余空行的问题\r\n const range = quill.getSelection()\r\n const [line] = quill.getLine(range.index)\r\n const domNode = line.domNode\r\n const isInParagraph = domNode.nodeName === 'P'\r\n const isInTableCell = line.statics.blotName === 'table-cell-line'\r\n if ((isInParagraph || isInTableCell)\r\n && domNode.childNodes.length > 1\r\n && domNode.childNodes[0].nodeName === 'BR') {\r\n domNode.childNodes[0].remove()\r\n }\r\n\r\n if (isPureIE && line instanceof Block) {\r\n // 设置光标位置防止跳入下一行\r\n quill.setSelection(range.index, 0, Quill.sources.SILENT)\r\n }\r\n\r\n this.isComposition = false\r\n }\r\n\r\n getTable(range = this.quill.getSelection()) {\r\n if (isNullOrUndefined(range)) return [null, null, null, -1]\r\n const [cellLine, offset] = this.quill.getLine(range.index)\r\n if (isNullOrUndefined(cellLine) || cellLine.statics.blotName !== TableCellLine.blotName) {\r\n return [null, null, null, -1]\r\n }\r\n const cell = cellLine.tableCell()\r\n const row = cell.row()\r\n const table = row.table()\r\n return [table, row, cell, offset]\r\n }\r\n\r\n insertTable(rows, columns) {\r\n const range = this.quill.getSelection(true)\r\n const isInsideTable = insideTable(range, this.quill)\r\n if (isNullOrUndefined(range) || isInsideTable) return\r\n // let currentBlot = this.quill.getLeaf(range.index)[0]\r\n // let nextBlot = this.quill.getLeaf(range.index + 1)[0]\r\n let delta = new Delta().retain(range.index)\r\n\r\n delta.insert('\\n')\r\n // insert table column\r\n delta = new Array(columns).fill('\\n').reduce((memo, text) => {\r\n memo.insert(text, { 'table-col': true })\r\n return memo\r\n }, delta)\r\n // insert table cell line with empty line\r\n delta = new Array(rows).fill(0).reduce((memo) => {\r\n const tableRowId = rowId()\r\n return new Array(columns).fill('\\n').reduce((op, text) => {\r\n op.insert(text, { 'table-cell-line': { row: tableRowId, cell: cellId() } })\r\n return op\r\n }, memo)\r\n }, delta)\r\n\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n delta.insert('\\n')\r\n }\r\n\r\n this.quill.updateContents(delta, Quill.sources.USER)\r\n\r\n // feature: 新增表格后首格自动激活编辑状态,initEvent兼容IE\r\n const [cellLine] = this.quill.getLine(range.index + columns + 1)\r\n if (cellLine) {\r\n const cell = cellLine.tableCell()\r\n const td = cell.domNode\r\n const mousedownEvent = document.createEvent('MouseEvent')\r\n const mouseupEvent = document.createEvent('MouseEvent')\r\n const keyEvent = document.createEvent('Event')\r\n mousedownEvent.initEvent('mousedown', true, false)\r\n mouseupEvent.initEvent('mouseup', true, false)\r\n keyEvent.initEvent('keypress', true, false)\r\n td.dispatchEvent(mousedownEvent)\r\n td.dispatchEvent(mouseupEvent)\r\n td.dispatchEvent(keyEvent)\r\n this.tableSelection.endTd = td\r\n }\r\n }\r\n\r\n showTableTools(table, quill) {\r\n this.table = table\r\n this.modulesContainer = document.createElement('div')\r\n this.modulesContainer.classList.add('qlbt-modules-container')\r\n // fix:表格容器插入时获取ql-tooltip容器,用insertBefore插入到它前面,避免遮挡链接浮窗\r\n const linkContainer = this.quill.root.parentNode.querySelector('.ql-tooltip ')\r\n this.quill.root.parentNode.insertBefore(this.modulesContainer, linkContainer)\r\n this.tableSelection = new TableSelection(table, quill, this.modulesContainer)\r\n this.columnTool = new TableColumnTool(table, quill, this.modulesContainer)\r\n this.tableScrollBar = new TableScrollBar(table, quill, this.modulesContainer)\r\n let timeoutID\r\n this.subscriber = () => {\r\n clearTimeout(timeoutID)\r\n timeoutID = setTimeout(this.hideTableTools, 300)\r\n }\r\n window.addEventListener('resize', this.subscriber, false)\r\n }\r\n\r\n hideTableTools() {\r\n if (this.columnTool) {\r\n this.columnTool.destroy()\r\n }\r\n if (this.tableSelection) {\r\n this.tableSelection.destroy()\r\n }\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu.destroy()\r\n }\r\n if (this.tableScrollBar) {\r\n this.tableScrollBar.destroy()\r\n }\r\n if (this.modulesContainer) {\r\n this.modulesContainer.remove()\r\n }\r\n this.columnTool = null\r\n this.tableSelection = null\r\n this.tableOperationMenu = null\r\n this.tableScrollBar = null\r\n this.modulesContainer = null\r\n this.table = null\r\n if (this.subscriber) {\r\n window.removeEventListener('resize', this.subscriber)\r\n }\r\n }\r\n}\r\n\r\nBetterTable.keyboardBindings = {\r\n 'line delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: { 'table-col': false, 'table-cell-line': false },\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n // fix: 当光标在编辑器最前且之后为表格时按delete不执行操作\r\n if (range.index === 0 && context.line.next && context.line.next.statics.blotName === 'table-view') {\r\n const [p] = this.quill.getLine(range.index - 1)\r\n const [col] = this.quill.getLine(range.index + 1)\r\n if (p && p.statics.blotName === 'block' && col && col.statics.blotName === 'table-col') {\r\n return false\r\n }\r\n }\r\n return true\r\n },\r\n },\r\n 'table-col enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n this.quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n this.quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n },\r\n },\r\n 'table-col delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = col.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n }\r\n }\r\n },\r\n },\r\n 'table-col backspace': {\r\n key: 'Backspace',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n handler() { },\r\n },\r\n 'table-cell-line backspace': {\r\n key: 'Backspace',\r\n format: ['table-cell-line'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range) {\r\n const [line] = this.quill.getLine(range.index)\r\n // 移除原有对非table-cell-line的阻止条件,使table-cell-line前的list等内容可以被删除\r\n if (!line.prev) {\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line delete': {\r\n key: 'Delete',\r\n format: ['table-cell-line'],\r\n handler(range, _context) {\r\n // 获取table-cell-line的索引和长度\r\n const [line] = this.quill.getLine(range.index)\r\n const index = this.quill.getIndex(line)\r\n const length = line.length()\r\n if (!line.next // 当无下一个元素且满足以下情况阻止删除操作\r\n && ((!line.prev && length === 1) // 单元格内只有一个table-cell-line且无内容\r\n || (range.index !== index && range.index + 1 >= index + length))) { // 光标在有内容的table-cell-line最后\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-cell-line'],\r\n handler(range, context) {\r\n // fix:通过window的光标选区当前指向判断,如果为HTMLElement且为表格容器则定位至下一行\r\n const node = window.getSelection().anchorNode\r\n if (node instanceof HTMLDivElement && node.classList.contains('quill-better-table-wrapper')) {\r\n this.quill.setSelection(range.index + 1, 0, Quill.sources.USER)\r\n this.quill.focus()\r\n return\r\n }\r\n // bugfix: a unexpected new line inserted when user compositionend with hitting Enter\r\n if (this.quill.selection && this.quill.selection.composing) return\r\n const Scope = Quill.imports.parchment.Scope\r\n if (range.length > 0) {\r\n this.quill.scroll.deleteAt(range.index, range.length) // So we do not trigger text-change\r\n }\r\n const lineFormats = Object.keys(context.format).reduce((formats, format) => {\r\n if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) {\r\n formats[format] = context.format[format]\r\n }\r\n return formats\r\n }, {})\r\n // insert new cellLine with lineFormats\r\n this.quill.insertText(range.index, '\\n', lineFormats['table-cell-line'], Quill.sources.USER)\r\n // Earlier scroll.deleteAt might have messed up our selection,\r\n // so insertText's built in selection preservation is not reliable\r\n this.quill.setSelection(range.index + 1, Quill.sources.SILENT)\r\n this.quill.focus()\r\n Object.keys(context.format).forEach((name) => {\r\n if (!isNullOrUndefined(lineFormats[name])) return\r\n if (Array.isArray(context.format[name])) return\r\n if (name === 'link') return\r\n this.quill.format(name, context.format[name], Quill.sources.USER)\r\n })\r\n },\r\n },\r\n}\r\n\r\nexport default BetterTable\r\n"],"names":["List"],"mappings":";;;;;;;;;;AAsCA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,MAAM,QAAQ,MAAM,QAAQ,OAAO;AACnC,MAAM,SAAS,MAAM,QAAQ,aAAa;AAG1C,MAAM,oBAAoB,OAAO;AAAA,EAY/B,OAAO,WAAW;AACV,UAAA,SAAS,UAAU,IAAI;AACvB,UAAA,SAAS,eAAe,IAAI;AAC5B,UAAA,SAAS,eAAe,IAAI;AAC5B,UAAA,SAAS,WAAW,IAAI;AACxB,UAAA,SAAS,UAAU,IAAI;AACvB,UAAA,SAAS,WAAW,IAAI;AACxB,UAAA,SAAS,gBAAgB,IAAI;AAC7B,UAAA,SAAS,kBAAkB,IAAI;AAE/B,UAAA,SAAS,kBAAkB,QAAQ,IAAI;AAEvC,UAAA,SAAS,gBAAgBA,UAAM,IAAI;AAAA,EAC3C;AAAA,EAEA,YAAY,OAAO,SAAS;AAC1B,UAAM,OAAO,OAAO;AAGpB,SAAK,gBAAgB;AAChB,SAAA,MAAM,KAAK,iBAAiB,aAAa,CAAA,UAAS,KAAK,gBAAgB,OAAO,KAAK,GAAG,KAAK;AAC3F,SAAA,MAAM,KAAK,iBAAiB,kBAAkB,MAAM,KAAK,qBAAqB,KAAK,GAAG,KAAK;AAC3F,SAAA,MAAM,KAAK,iBAAiB,oBAAoB,MAAM,KAAK,uBAAuB,KAAK,GAAG,KAAK;AAC/F,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Q,GAAG,MAAM,QAAQ,MAAM;AAC7D,WAAK,MAAM;AACX,aAAO,KAAK,QAAQ,MAAM,EAAE,QAAQ,CAAC,SAAS;AAC5C,YAAI,CAAC,kBAAkB,YAAY,IAAI,CAAC,EAAG;AAC3C,YAAI,MAAM,QAAQ,QAAQ,OAAO,IAAI,CAAC,EAAG;AACzC,YAAI,SAAS,OAAQ;AAChB,aAAA,MAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,GAAG,MAAM,QAAQ,IAAI;AAAA,MAAA,CACjE;AAAA,IACH;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"better-table.es.js","sources":["../../../src/table/better-table.ts"],"sourcesContent":["import Quill from 'quill'\nimport {\n getEventComposedPath,\n insideTable,\n isNullOrUndefined,\n isPureIE,\n} from '../config/editor.utils'\nimport Header from './formats/header'\nimport List from './formats/list'\nimport {\n cellId,\n rowId,\n TableBody,\n TableCell,\n TableCellLine,\n TableCol,\n TableColGroup,\n TableContainer,\n TableRow,\n TableViewWrapper,\n} from './formats/table'\nimport TableColumnTool from './modules/table-column-tool'\nimport TableOperationMenu from './modules/table-operation-menu'\nimport TableScrollBar from './modules/table-scroll-bar'\nimport TableSelection from './modules/table-selection'\n// import table node matchers\nimport {\n matchHeader,\n matchInline,\n matchList,\n matchMentionLink,\n matchTable,\n matchTableCell,\n matchTableHeader,\n matchTableRow,\n matchWordShapeImage,\n} from './utils/node-matchers'\n\nconst Block = Quill.imports['blots/block']\nconst Delta = Quill.imports.delta\nconst Module = Quill.imports['core/module']\n\n// @dynamic\nclass BetterTable extends Module {\n static keyboardBindings: any\n isComposition: boolean\n quill: any\n table: any\n modulesContainer: any\n tableSelection: any\n subscriber: any\n tableOperationMenu: any\n columnTool: TableColumnTool\n tableScrollBar: TableScrollBar\n\n static register() {\n Quill.register(TableCol, true)\n Quill.register(TableColGroup, true)\n Quill.register(TableCellLine, true)\n Quill.register(TableCell, true)\n Quill.register(TableRow, true)\n Quill.register(TableBody, true)\n Quill.register(TableContainer, true)\n Quill.register(TableViewWrapper, true)\n // register customized Header, overwriting quill built-in Header\n Quill.register('formats/header', Header, true)\n // register customized List, overwriting quill built-in Header\n Quill.register('formats/list', List, true)\n }\n\n constructor(quill, options) {\n super(quill, options)\n\n // handle click on quill-better-table\n this.isComposition = false\n this.quill.root.addEventListener('mousedown', event => this.handleMouseDown(event, quill), false)\n this.quill.root.addEventListener('compositionend', () => this.handleCompositionend(quill), false)\n this.quill.root.addEventListener('compositionstart', () => this.handleCompositionstart(quill), false)\n this.quill.root.addEventListener('keypress', event => this.handleKeyDown(event, quill), false)\n\n // handle right click on quill-better-table\n this.quill.root.addEventListener(\n 'contextmenu',\n (evt) => {\n if (!this.table) return true\n evt.preventDefault()\n\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\n const path = getEventComposedPath(evt)\n if (!path || path.length <= 0) return\n\n const tableNode = path.filter((node) => {\n return (\n node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\n )\n })[0]\n\n const rowNode = path.filter((node) => {\n return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row')\n })[0]\n\n const cellNode = path.filter((node) => {\n return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row')\n })[0]\n\n const isTargetCellSelected = this.tableSelection.selectedTds\n .map(tableCell => tableCell.domNode)\n .includes(cellNode)\n\n if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) {\n this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect())\n }\n\n if (this.tableOperationMenu) {\n this.tableOperationMenu = this.tableOperationMenu.destroy()\n }\n\n if (tableNode) {\n this.tableOperationMenu = new TableOperationMenu(\n {\n table: tableNode,\n row: rowNode,\n cell: cellNode,\n left: evt.x + 15,\n top: evt.y,\n },\n quill,\n options.operationMenu,\n )\n }\n },\n false,\n )\n\n // add keyboard binding:Backspace\n // prevent user hits backspace to delete table cell\n quill.keyboard.addBinding({ key: 'Backspace' }, {}, (range, context) => {\n if (range.index === 0 || this.quill.getLength() <= 1) return true\n if (context.offset === 0 && range.length === 0) {\n const [prev] = this.quill.getLine(range.index - 1)\n const [line] = this.quill.getLine(range.index)\n if (!isNullOrUndefined(prev)) {\n if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') {\n const betterTableModule = this.quill.getModule('better-table')\n let tableBlot\n try {\n tableBlot = prev.parent.parent.parent.parent\n }\n catch (_e) { }\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\n betterTableModule.hideTableTools()\n tableBlot.remove()\n this.quill.update(Quill.sources.USER)\n }\n return false\n }\n }\n }\n return true\n })\n // since only one matched bindings callback will execute.\n // expected my binding callback execute first\n // I changed the order of binding callbacks\n const thisBinding = quill.keyboard.bindings.Backspace.pop()\n quill.keyboard.bindings.Backspace.splice(1, 0, thisBinding)\n\n // add Matchers to match and render quill-better-table for initialization\n // or pasting\n quill.clipboard.addMatcher('td', matchTableCell)\n quill.clipboard.addMatcher('th', matchTableHeader)\n quill.clipboard.addMatcher('table', matchTable)\n quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader)\n quill.clipboard.addMatcher('ol, ul', matchList)\n quill.clipboard.addMatcher('span', matchMentionLink)\n quill.clipboard.addMatcher('v:imageData', matchWordShapeImage)\n quill.clipboard.addMatcher(Node.ELEMENT_NODE, matchInline)\n\n // remove matcher for tr tag\n quill.clipboard.matchers = quill.clipboard.matchers.filter((matcher) => {\n return matcher[0] !== 'tr'\n })\n\n // fix: 处理空<tr>标签被忽略的情况\n quill.clipboard.addMatcher('tr', matchTableRow)\n\n this.quill.on('editor-change', () => {\n const tableContainer = Quill.find(this.table)\n if (!tableContainer) {\n this.hideTableTools()\n }\n })\n\n this.quill.on(Quill.events.SELECTION_CHANGE, (range, _oldRange, source) => {\n if (!range) return\n const selectionStart = range.index\n const selectionEnd = range.index + range.length\n if (source === Quill.sources.USER) {\n const tables = this.quill.root.getElementsByTagName('table')\n if (tables && tables.length) {\n [].forEach.call(tables, (table) => {\n const tableContainer = Quill.find(table)\n if (tableContainer) {\n const tableStart = tableContainer.offset(this.quill.scroll)\n const tableEnd = tableStart + tableContainer.length()\n // @ts-ignore\n const classes = Array.from(table.parentNode.classList)\n\n if (selectionStart <= tableStart && tableEnd <= selectionEnd) {\n // @ts-ignore\n table.parentNode.classList.add('quill-better-table-selected')\n }\n else if (classes.includes('quill-better-table-selected')) {\n // @ts-ignore\n table.parentNode.classList.remove('quill-better-table-selected')\n }\n }\n })\n }\n }\n })\n }\n\n handleMouseDown(evt, quill) {\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\n const path = getEventComposedPath(evt)\n if (!path || path.length <= 0) return\n const tableNode = path.filter((node) => {\n return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\n })[0]\n if (tableNode) {\n tableNode.parentNode.classList.remove('quill-better-table-selected')\n // current table clicked\n if (this.table === tableNode) return\n // other table clicked\n if (this.table) {\n this.hideTableTools()\n }\n if (!quill.options.readOnly) { // not show table tool in readonly mode\n this.showTableTools(tableNode, quill)\n }\n }\n else if (this.table) {\n // other clicked\n this.hideTableTools()\n }\n }\n\n handleKeyDown(evt, quill) {\n const key = evt.key\n const range = quill.getSelection()\n if (this.isComposition || !range) return\n const [col] = quill.getLine(range.index)\n const [td] = quill.getLine(range.index - 1)\n if (key && key !== 'Delete' && col && range) {\n if (col.statics.blotName === 'table-col') {\n const betterTableModule = this.quill.getModule('better-table')\n betterTableModule.hideTableTools()\n quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\n quill.setSelection(range.index, 0, Quill.sources.USER)\n }\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\n quill.insertText(range.index, '\\n', Quill.sources.USER)\n quill.setSelection(range.index, 0, Quill.sources.USER)\n }\n }\n }\n\n handleCompositionstart(quill) {\n this.isComposition = true\n const range = quill.getSelection()\n const [col] = quill.getLine(range.index)\n const [td] = quill.getLine(range.index - 1)\n if (col && range) {\n if (col.statics.blotName === 'table-col') {\n const betterTableModule = this.quill.getModule('better-table')\n betterTableModule.hideTableTools()\n quill.insertText(range.index - 1, '\\n\\t', Quill.sources.USER)\n quill.setSelection(range.index, 0, Quill.sources.USER)\n }\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\n quill.setSelection(range.index, 0, Quill.sources.USER)\n }\n }\n }\n\n handleCompositionend(quill) {\n // fix: 解决在空行行首用中文输入法输入字符,然后按退格导致插入多余空行的问题\n const range = quill.getSelection()\n const [line] = quill.getLine(range.index)\n const domNode = line.domNode\n const isInParagraph = domNode.nodeName === 'P'\n const isInTableCell = line.statics.blotName === 'table-cell-line'\n if ((isInParagraph || isInTableCell)\n && domNode.childNodes.length > 1\n && domNode.childNodes[0].nodeName === 'BR') {\n domNode.childNodes[0].remove()\n }\n\n if (isPureIE && line instanceof Block) {\n // 设置光标位置防止跳入下一行\n quill.setSelection(range.index, 0, Quill.sources.SILENT)\n }\n\n this.isComposition = false\n }\n\n getTable(range = this.quill.getSelection()) {\n if (isNullOrUndefined(range)) return [null, null, null, -1]\n const [cellLine, offset] = this.quill.getLine(range.index)\n if (isNullOrUndefined(cellLine) || cellLine.statics.blotName !== TableCellLine.blotName) {\n return [null, null, null, -1]\n }\n const cell = cellLine.tableCell()\n const row = cell.row()\n const table = row.table()\n return [table, row, cell, offset]\n }\n\n insertTable(rows, columns) {\n const range = this.quill.getSelection(true)\n const isInsideTable = insideTable(range, this.quill)\n if (isNullOrUndefined(range) || isInsideTable) return\n // let currentBlot = this.quill.getLeaf(range.index)[0]\n // let nextBlot = this.quill.getLeaf(range.index + 1)[0]\n let delta = new Delta().retain(range.index)\n\n delta.insert('\\n')\n // insert table column\n delta = new Array(columns).fill('\\n').reduce((memo, text) => {\n memo.insert(text, { 'table-col': true })\n return memo\n }, delta)\n // insert table cell line with empty line\n delta = new Array(rows).fill(0).reduce((memo) => {\n const tableRowId = rowId()\n return new Array(columns).fill('\\n').reduce((op, text) => {\n op.insert(text, { 'table-cell-line': { row: tableRowId, cell: cellId() } })\n return op\n }, memo)\n }, delta)\n\n const [col] = this.quill.getLine(range.index)\n if (col && col.statics.blotName === 'table-col') {\n delta.insert('\\n')\n }\n\n this.quill.updateContents(delta, Quill.sources.USER)\n\n // feature: 新增表格后首格自动激活编辑状态,initEvent兼容IE\n const [cellLine] = this.quill.getLine(range.index + columns + 1)\n if (cellLine) {\n const cell = cellLine.tableCell()\n const td = cell.domNode\n const mousedownEvent = document.createEvent('MouseEvent')\n const mouseupEvent = document.createEvent('MouseEvent')\n const keyEvent = document.createEvent('Event')\n mousedownEvent.initEvent('mousedown', true, false)\n mouseupEvent.initEvent('mouseup', true, false)\n keyEvent.initEvent('keypress', true, false)\n td.dispatchEvent(mousedownEvent)\n td.dispatchEvent(mouseupEvent)\n td.dispatchEvent(keyEvent)\n this.tableSelection.endTd = td\n }\n }\n\n showTableTools(table, quill) {\n this.table = table\n this.modulesContainer = document.createElement('div')\n this.modulesContainer.classList.add('qlbt-modules-container')\n // fix:表格容器插入时获取ql-tooltip容器,用insertBefore插入到它前面,避免遮挡链接浮窗\n const linkContainer = this.quill.root.parentNode.querySelector('.ql-tooltip ')\n this.quill.root.parentNode.insertBefore(this.modulesContainer, linkContainer)\n this.tableSelection = new TableSelection(table, quill, this.modulesContainer)\n this.columnTool = new TableColumnTool(table, quill, this.modulesContainer)\n this.tableScrollBar = new TableScrollBar(table, quill, this.modulesContainer)\n let timeoutID\n this.subscriber = () => {\n clearTimeout(timeoutID)\n timeoutID = setTimeout(this.hideTableTools, 300)\n }\n window.addEventListener('resize', this.subscriber, false)\n }\n\n hideTableTools() {\n if (this.columnTool) {\n this.columnTool.destroy()\n }\n if (this.tableSelection) {\n this.tableSelection.destroy()\n }\n if (this.tableOperationMenu) {\n this.tableOperationMenu.destroy()\n }\n if (this.tableScrollBar) {\n this.tableScrollBar.destroy()\n }\n if (this.modulesContainer) {\n this.modulesContainer.remove()\n }\n this.columnTool = null\n this.tableSelection = null\n this.tableOperationMenu = null\n this.tableScrollBar = null\n this.modulesContainer = null\n this.table = null\n if (this.subscriber) {\n window.removeEventListener('resize', this.subscriber)\n }\n }\n}\n\nBetterTable.keyboardBindings = {\n 'line delete': {\n key: 'Delete',\n shiftKey: null,\n format: { 'table-col': false, 'table-cell-line': false },\n collapsed: true,\n offset: 0,\n handler(range, context) {\n // fix: 当光标在编辑器最前且之后为表格时按delete不执行操作\n if (range.index === 0 && context.line.next && context.line.next.statics.blotName === 'table-view') {\n const [p] = this.quill.getLine(range.index - 1)\n const [col] = this.quill.getLine(range.index + 1)\n if (p && p.statics.blotName === 'block' && col && col.statics.blotName === 'table-col') {\n return false\n }\n }\n return true\n },\n },\n 'table-col enter': {\n key: 'Enter',\n shiftKey: null,\n format: ['table-col'],\n collapsed: true,\n offset: 0,\n handler(range, context) {\n if (context.offset === 0 && range.length === 0) {\n const [col] = this.quill.getLine(range.index)\n if (col && col.statics.blotName === 'table-col') {\n const betterTableModule = this.quill.getModule('better-table')\n betterTableModule.hideTableTools()\n this.quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\n this.quill.setSelection(range.index, 0, Quill.sources.USER)\n }\n }\n },\n },\n 'table-col delete': {\n key: 'Delete',\n shiftKey: null,\n format: ['table-col'],\n collapsed: true,\n offset: 0,\n handler(range, context) {\n if (context.offset === 0 && range.length === 0) {\n const [col] = this.quill.getLine(range.index)\n if (col && col.statics.blotName === 'table-col') {\n const betterTableModule = this.quill.getModule('better-table')\n let tableBlot\n try {\n tableBlot = col.parent.parent.parent\n }\n catch (_e) { }\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\n betterTableModule.hideTableTools()\n tableBlot.remove()\n this.quill.update(Quill.sources.USER)\n }\n }\n }\n },\n },\n 'table-col backspace': {\n key: 'Backspace',\n shiftKey: null,\n format: ['table-col'],\n collapsed: true,\n offset: 0,\n handler() { },\n },\n 'table-cell-line backspace': {\n key: 'Backspace',\n format: ['table-cell-line'],\n collapsed: true,\n offset: 0,\n handler(range) {\n const [line] = this.quill.getLine(range.index)\n // 移除原有对非table-cell-line的阻止条件,使table-cell-line前的list等内容可以被删除\n if (!line.prev) {\n return false\n }\n return true\n },\n },\n 'table-cell-line delete': {\n key: 'Delete',\n format: ['table-cell-line'],\n handler(range, _context) {\n // 获取table-cell-line的索引和长度\n const [line] = this.quill.getLine(range.index)\n const index = this.quill.getIndex(line)\n const length = line.length()\n if (!line.next // 当无下一个元素且满足以下情况阻止删除操作\n && ((!line.prev && length === 1) // 单元格内只有一个table-cell-line且无内容\n || (range.index !== index && range.index + 1 >= index + length))) { // 光标在有内容的table-cell-line最后\n return false\n }\n return true\n },\n },\n 'table-cell-line enter': {\n key: 'Enter',\n shiftKey: null,\n format: ['table-cell-line'],\n handler(range, context) {\n // fix:通过window的光标选区当前指向判断,如果为HTMLElement且为表格容器则定位至下一行\n const node = window.getSelection().anchorNode\n if (node instanceof HTMLDivElement && node.classList.contains('quill-better-table-wrapper')) {\n this.quill.setSelection(range.index + 1, 0, Quill.sources.USER)\n this.quill.focus()\n return\n }\n // bugfix: a unexpected new line inserted when user compositionend with hitting Enter\n if (this.quill.selection && this.quill.selection.composing) return\n const Scope = Quill.imports.parchment.Scope\n if (range.length > 0) {\n this.quill.scroll.deleteAt(range.index, range.length) // So we do not trigger text-change\n }\n const lineFormats = Object.keys(context.format).reduce((formats, format) => {\n if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) {\n formats[format] = context.format[format]\n }\n return formats\n }, {})\n // insert new cellLine with lineFormats\n this.quill.insertText(range.index, '\\n', lineFormats['table-cell-line'], Quill.sources.USER)\n // Earlier scroll.deleteAt might have messed up our selection,\n // so insertText's built in selection preservation is not reliable\n this.quill.setSelection(range.index + 1, Quill.sources.SILENT)\n this.quill.focus()\n Object.keys(context.format).forEach((name) => {\n if (!isNullOrUndefined(lineFormats[name])) return\n if (Array.isArray(context.format[name])) return\n if (name === 'link') return\n this.quill.format(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IACH;AAAA,EACF;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.es.js","sources":["../../../../src/table/formats/header.ts"],"sourcesContent":["import Quill from 'quill'\
|
|
1
|
+
{"version":3,"file":"header.es.js","sources":["../../../../src/table/formats/header.ts"],"sourcesContent":["import Quill from 'quill'\nimport { isNullOrUndefined } from '../../config/editor.utils'\nimport { CELL_ATTRIBUTES, CELL_IDENTITY_KEYS } from '../table-config'\n\nconst Block = Quill.imports['blots/block']\n\n// @dynamic\nclass Header extends Block {\n static tagName: any\n static blotName: string\n domNode: any\n replaceWith: any\n parent: any\n wrap: any\n enforceAllowedChildren: any\n uiNode: any\n children: any\n statics: any\n appendChild: any\n remove: any\n cache: Record<string, any>\n scroll: any\n static create(value) {\n if (typeof value === 'string') {\n value = { value }\n }\n\n const node = super.create(value.value)\n\n CELL_IDENTITY_KEYS.forEach((key) => {\n if (value[key]) {\n node.setAttribute(`data-${key}`, value[key])\n }\n })\n\n CELL_ATTRIBUTES.forEach((key) => {\n if (value[key]) {\n node.setAttribute(`data-${key}`, value[key])\n }\n })\n\n return node\n }\n\n static formats(domNode) {\n const formats: any = {}\n formats.value = this.tagName.indexOf(domNode.tagName) + 1\n\n return CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).reduce((tableFormats, attribute) => {\n if (domNode.hasAttribute(`data-${attribute}`)) {\n tableFormats[attribute] = domNode.getAttribute(`data-${attribute}`) || undefined\n }\n return tableFormats\n }, formats)\n }\n\n format(name, value) {\n // fix: 在标题处粘贴内容,会导致该粘贴内容的格式错误\n if (Object.prototype.toString.call(value) === '[object Object]') {\n value = value.value\n }\n const headerDom: any = Header.formats(this.domNode)\n const { row, cell, rowspan, colspan } = headerDom\n if (name === Header.blotName) {\n if (value) {\n super.format(name, {\n value,\n row,\n cell,\n rowspan,\n colspan,\n })\n }\n else {\n if (row) {\n this.replaceWith('table-cell-line', {\n row,\n cell,\n rowspan,\n colspan,\n })\n }\n else {\n super.format(name, value)\n }\n }\n }\n else {\n super.format(name, value)\n }\n }\n\n optimize(_context) {\n const { row, cell, rowspan, colspan } = Header.formats(this.domNode)\n\n if (row && this.parent.statics.blotName !== 'table') {\n this.wrap('table', {\n row,\n cell,\n colspan,\n rowspan,\n })\n }\n\n // ShadowBlot optimize\n this.enforceAllowedChildren()\n if (!isNullOrUndefined(this.uiNode) && this.uiNode !== this.domNode.firstChild) {\n this.domNode.insertBefore(this.uiNode, this.domNode.firstChild)\n }\n if (this.children.length === 0) {\n if (!isNullOrUndefined(this.statics.defaultChild)) {\n const child = this.scroll.create(this.statics.defaultChild.blotName)\n this.appendChild(child)\n // TODO double check if necessary\n // child.optimize(context);\n }\n else {\n this.remove()\n }\n }\n // Block optimize\n this.cache = {}\n }\n}\n\nHeader.blotName = 'header'\nHeader.tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6']\n\nexport default Header\n"],"names":[],"mappings":";;;AAIA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AAGzC,MAAM,eAAe,MAAM;AAAA,EAezB,OAAO,OAAO,OAAO;AACf,QAAA,OAAO,UAAU,UAAU;AAC7B,cAAQ,EAAE;IACZ;AAEA,UAAM,OAAO,MAAM,OAAO,MAAM,KAAK;AAElB,uBAAA,QAAQ,CAAC,QAAQ;AAC9B,UAAA,MAAM,GAAG,GAAG;AACd,aAAK,aAAa,QAAQ,GAAG,IAAI,MAAM,GAAG,CAAC;AAAA,MAC7C;AAAA,IAAA,CACD;AAEe,oBAAA,QAAQ,CAAC,QAAQ;AAC3B,UAAA,MAAM,GAAG,GAAG;AACd,aAAK,aAAa,QAAQ,GAAG,IAAI,MAAM,GAAG,CAAC;AAAA,MAC7C;AAAA,IAAA,CACD;AAEM,WAAA;AAAA,EACT;AAAA,EAEA,OAAO,QAAQ,SAAS;AACtB,UAAM,UAAe,CAAA;AACrB,YAAQ,QAAQ,KAAK,QAAQ,QAAQ,QAAQ,OAAO,IAAI;AAExD,WAAO,gBAAgB,OAAO,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A,KAAK,SAAS,WAAW,GAAG;AAC9B,UAAI,CAAC,kBAAkB,KAAK,QAAQ,YAAY,GAAG;AACjD,cAAM,QAAQ,KAAK,OAAO,OAAO,KAAK,QAAQ,aAAa,QAAQ;AACnE,aAAK,YAAY,KAAK;AAAA,MAAA,OAInB;AACH,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAEA,SAAK,QAAQ;EACf;AACF;AAEA,OAAO,WAAW;AAClB,OAAO,UAAU,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI;"}
|
|
@@ -104,7 +104,7 @@ class ListItem extends Block {
|
|
|
104
104
|
}
|
|
105
105
|
optimize(context) {
|
|
106
106
|
const tail = this.prev && this.prev.domNode.lastChild;
|
|
107
|
-
if (tail && tail.className && tail.className.
|
|
107
|
+
if (tail && tail.className && tail.className.includes("ql-soft-break")) {
|
|
108
108
|
this.domNode.childNodes.forEach((v, i) => {
|
|
109
109
|
if (i > 0) {
|
|
110
110
|
this.prev.domNode.appendChild(v);
|
|
@@ -129,7 +129,7 @@ class ListItem extends Block {
|
|
|
129
129
|
if (data.cell && !parentFormats.cell) {
|
|
130
130
|
[...CELL_IDENTITY_KEYS, ...CELL_ATTRIBUTES].forEach((key) => (formats[key] || data[key]) && this.parent.domNode.setAttribute(`data-${key}`, formats[key] || data[key]));
|
|
131
131
|
if (this.parent.parent.statics.blotName !== "table") {
|
|
132
|
-
delete formats
|
|
132
|
+
delete formats.list;
|
|
133
133
|
this.wrap("table", formats);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -147,7 +147,7 @@ ListItem.requiredContainer = ListContainer;
|
|
|
147
147
|
function getFormats(dom) {
|
|
148
148
|
const formats = {};
|
|
149
149
|
if (dom.tagName === "OL") {
|
|
150
|
-
formats
|
|
150
|
+
formats.list = dom.classList.item(0);
|
|
151
151
|
}
|
|
152
152
|
return [...CELL_ATTRIBUTES, ...CELL_IDENTITY_KEYS].reduce((tableFormats, attribute) => {
|
|
153
153
|
if (dom.hasAttribute(`data-${attribute}`)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.es.js","sources":["../../../../src/table/formats/list.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport { CELL_ATTRIBUTES, CELL_IDENTITY_KEYS } from '../table-config'\r\n\r\nconst Block = Quill.imports['blots/block']\r\nconst Container = Quill.imports['blots/container']\r\n\r\n// @dynamic\r\nclass ListContainer extends Container {\r\n static allowedChildren: any\r\n static blotName: string\r\n static tagName: string\r\n replaceWith: any\r\n domNode: any\r\n parent: any\r\n statics: any\r\n wrap: any\r\n\r\n format(name, value) {\r\n const { row, cell, rowspan, colspan } = this.domNode.dataset\r\n if (name === ListContainer.blotName) {\r\n if (value) {\r\n super.format(name, { row, cell, rowspan, colspan })\r\n }\r\n else if (row) {\r\n this.replaceWith('table-cell-line', { row, cell, rowspan, colspan })\r\n }\r\n }\r\n }\r\n}\r\n/**\r\n * bugfix: quill源码中(quill/core/editor.js 272行)在处理拷贝时\r\n * hard code了这个blotName用于处理ol中的li。所以在quill\r\n * 源码内写法不变的情况下这个名字不能改,否则拷贝有bug\r\n */\r\nListContainer.blotName = 'list-container'\r\nListContainer.tagName = 'OL'\r\n\r\n// @dynamic\r\nclass ListItem extends Block {\r\n static blotName: string\r\n static tagName: string\r\n static requiredContainer: typeof ListContainer\r\n statics: any\r\n attachUI: any\r\n domNode: any\r\n replaceWith: any\r\n parent: any\r\n wrap: any\r\n children: any\r\n prev: any\r\n remove: () => void\r\n\r\n static create(value) {\r\n const node = super.create()\r\n if (typeof value === 'string') {\r\n value = { value }\r\n }\r\n else {\r\n [...CELL_IDENTITY_KEYS, ...CELL_ATTRIBUTES].forEach((key) => {\r\n if (value[key]) {\r\n node.dataset[key] = value[key]\r\n }\r\n })\r\n }\r\n node.classList.add(value.value)\r\n return node\r\n }\r\n\r\n static formats(domNode) {\r\n const formats: any = {}\r\n formats.value = domNode.classList.item(0) || undefined\r\n\r\n return [...CELL_ATTRIBUTES, ...CELL_IDENTITY_KEYS].reduce((tableFormats, key) => {\r\n if (domNode.dataset[key]) {\r\n tableFormats[key] = domNode.dataset[key]\r\n }\r\n return tableFormats\r\n }, formats)\r\n }\r\n\r\n static register() {\r\n Quill.register({ 'formats/list-container': ListContainer }, true)\r\n }\r\n\r\n constructor(scroll, domNode) {\r\n super(scroll, domNode)\r\n const quill = Quill.find(scroll.domNode.parentNode)\r\n const range = quill.getSelection()\r\n if (range) {\r\n const [line] = quill.getLine(range.index)\r\n const td = line.domNode.closest('td')\r\n if (td) {\r\n [...CELL_IDENTITY_KEYS, ...CELL_ATTRIBUTES].forEach(key =>\r\n td.dataset[key] && domNode.setAttribute(`data-${key}`, td.dataset[key]))\r\n }\r\n }\r\n\r\n const ui = domNode.ownerDocument.createElement('span')\r\n const listEventHandler = (e) => {\r\n if (!scroll.isEnabled()) return\r\n const { value } = this.statics.formats(domNode, scroll)\r\n if (value === 'checked') {\r\n this.format('list', 'unchecked')\r\n e.preventDefault()\r\n }\r\n else if (value === 'unchecked') {\r\n this.format('list', 'checked')\r\n e.preventDefault()\r\n }\r\n }\r\n ui.addEventListener('mousedown', listEventHandler)\r\n ui.addEventListener('touchstart', listEventHandler)\r\n this.attachUI(ui)\r\n }\r\n\r\n format(name, value) {\r\n if (name !== ListItem.blotName) {\r\n super.format(name, value)\r\n return\r\n }\r\n const type = (value && typeof value === 'object') ? value.value : value\r\n const oldClass = this.domNode.classList[0]\r\n const tdDom = this.domNode.closest('.editing-select-able')\r\n const tableCellBlot = tdDom && Quill.find(tdDom)\r\n const images = this.domNode.querySelectorAll('img[data-image-id]')\r\n if (!type || type === oldClass) {\r\n // 消除格式或相同list抵消格式时恢复图片对齐,li转化为table-cell-line\r\n if (images && images.length) {\r\n images.forEach((img) => {\r\n img.style.verticalAlign = 'baseLine'\r\n })\r\n }\r\n if (tableCellBlot && tableCellBlot.statics.blotName === 'table') {\r\n const tableCellFormats = tableCellBlot.formats()\r\n this.replaceWith('table-cell-line', tableCellFormats)\r\n // fix: 移除list格式时移除父级的ol或ul,避免table-cell-line判断无td自动生成td容器\r\n if (this.parent.statics.blotName === ListContainer.blotName) {\r\n this.parent.unwrap()\r\n }\r\n }\r\n else {\r\n super.format(name, value)\r\n }\r\n }\r\n else if (oldClass) {\r\n this.domNode.className = this.domNode.className.replace(oldClass, type)\r\n }\r\n else {\r\n this.domNode.classList.add(type)\r\n }\r\n }\r\n\r\n optimize(context) {\r\n // 判断前一个li是否包含软回车,如果包含则将当前li与之合并后移除\r\n const tail = this.prev && this.prev.domNode.lastChild\r\n if (tail && tail.className && tail.className.indexOf('ql-soft-break') >= 0) {\r\n // 合并dom\r\n this.domNode.childNodes.forEach((v, i) => {\r\n if (i > 0) {\r\n this.prev.domNode.appendChild(v)\r\n }\r\n })\r\n this.remove()\r\n return\r\n }\r\n\r\n super.optimize(context)\r\n\r\n // list类型\r\n const parentFormats = getFormats(this.parent.domNode)\r\n const formats = ListItem.formats(this.domNode)\r\n // 单元格属性\r\n const data = this.domNode.dataset || []\r\n const images = this.domNode.querySelectorAll('img[data-image-id]')\r\n\r\n // li更新后判断父容器的对应属性是否与自身一致,如果不一致则向上覆盖\r\n if (parentFormats.list !== formats.value) {\r\n const oldClass = this.parent.domNode.classList[0]\r\n if (oldClass) {\r\n this.parent.domNode.className = this.parent.domNode.className.replace(oldClass, formats.value)\r\n }\r\n else {\r\n this.parent.domNode.classList.add(formats.value)\r\n }\r\n }\r\n\r\n if (data.cell && !parentFormats.cell) {\r\n [...CELL_IDENTITY_KEYS, ...CELL_ATTRIBUTES].forEach(key =>\r\n (formats[key] || data[key]) && this.parent.domNode.setAttribute(`data-${key}`, formats[key] || data[key]))\r\n // 如果父容器不在表格内则用单元格包裹\r\n if (this.parent.parent.statics.blotName !== 'table') {\r\n delete formats['list']\r\n this.wrap('table', formats)\r\n }\r\n }\r\n\r\n // 当list中包含图片时,设置图片顶对齐\r\n if (images) {\r\n images.forEach((img) => {\r\n img.style.verticalAlign = 'top'\r\n })\r\n }\r\n }\r\n}\r\n\r\nListItem.blotName = 'list'\r\nListItem.tagName = 'LI'\r\n\r\nListContainer.allowedChildren = [ListItem]\r\nListItem.requiredContainer = ListContainer\r\n\r\n// 属性读取方法:兼容table-cell-line、ol、li\r\n// 因为构造时当前range对应的元素最开始是table-cell-line,然后是li,且ol的formats方法不允许覆写,会导致报错,所以整合一个兼容方法来读取需要的属性。\r\nfunction getFormats(dom): any {\r\n const formats = {}\r\n\r\n if (dom.tagName === 'OL') {\r\n formats['list'] = dom.classList.item(0)\r\n }\r\n\r\n return [...CELL_ATTRIBUTES, ...CELL_IDENTITY_KEYS].reduce((tableFormats, attribute) => {\r\n if (dom.hasAttribute(`data-${attribute}`)) {\r\n tableFormats[attribute] = dom.getAttribute(`data-${attribute}`) || undefined\r\n }\r\n return tableFormats\r\n }, formats)\r\n}\r\n\r\nexport { ListContainer, ListItem as default }\r\n"],"names":[],"mappings":";;AAGA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,MAAM,YAAY,MAAM,QAAQ,iBAAiB;AAGjD,MAAM,sBAAsB,UAAU;AAAA,EAUpC,OAAO,MAAM,OAAO;AAClB,UAAM,EAAE,KAAK,MAAM,SAAS,QAAQ,IAAI,KAAK,QAAQ;AACjD,QAAA,SAAS,cAAc,UAAU;AACnC,UAAI,OAAO;AACT,cAAM,OAAO,MAAM,EAAE,KAAK,MAAM,SAAS,SAAS;AAAA,iBAE3C,KAAK;AACZ,aAAK,YAAY,mBAAmB,EAAE,KAAK,MAAM,SAAS,SAAS;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AACF;AAMA,cAAc,WAAW;AACzB,cAAc,UAAU;AAGxB,MAAM,iBAAiB,MAAM;AAAA,EAc3B,OAAO,OAAO,OAAO;AACb,UAAA,OAAO,MAAM;AACf,QAAA,OAAO,UAAU,UAAU;AAC7B,cAAQ,EAAE;IAAM,OAEb;AACH,OAAC,GAAG,oBAAoB,GAAG,eAAe,EAAE,QAAQ,CAAC,QAAQ;AACvD,Y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pB,SAAS,UAAU;AAEnB,cAAc,kBAAkB,CAAC,QAAQ;AACzC,SAAS,oBAAoB;AAI7B,SAAS,WAAW,KAAU;AAC5B,QAAM,UAAU,CAAA;AAEZ,MAAA,IAAI,YAAY,MAAM;AACxB,YAAQ,MAAM,IAAI,IAAI,UAAU,KAAK,CAAC;AAAA,EACxC;AAEO,SAAA,CAAC,GAAG,iBAAiB,GAAG,kBAAkB,EAAE,OAAO,CAAC,cAAc,cAAc;AACrF,QAAI,IAAI,aAAa,QAAQ,SAAS,EAAE,GAAG;AACzC,mBAAa,SAAS,IAAI,IAAI,aAAa,QAAQ,SAAS,EAAE,KAAK;AAAA,IACrE;AACO,WAAA;AAAA,KACN,OAAO;AACZ;"}
|
|
1
|
+
{"version":3,"file":"list.es.js","sources":["../../../../src/table/formats/list.ts"],"sourcesContent":["import Quill from 'quill'\nimport { CELL_ATTRIBUTES, CELL_IDENTITY_KEYS } from '../table-config'\n\nconst Block = Quill.imports['blots/block']\nconst Container = Quill.imports['blots/container']\n\n// @dynamic\nclass ListContainer extends Container {\n static allowedChildren: any\n static blotName: string\n static tagName: string\n replaceWith: any\n domNode: any\n parent: any\n statics: any\n wrap: any\n\n format(name, value) {\n const { row, cell, rowspan, colspan } = this.domNode.dataset\n if (name === ListContainer.blotName) {\n if (value) {\n super.format(name, { row, cell, rowspan, colspan })\n }\n else if (row) {\n this.replaceWith('table-cell-line', { row, cell, rowspan, colspan })\n }\n }\n }\n}\n/**\n * bugfix: quill源码中(quill/core/editor.js 272行)在处理拷贝时\n * hard code了这个blotName用于处理ol中的li。所以在quill\n * 源码内写法不变的情况下这个名字不能改,否则拷贝有bug\n */\nListContainer.blotName = 'list-container'\nListContainer.tagName = 'OL'\n\n// @dynamic\nclass ListItem extends Block {\n static blotName: string\n static tagName: string\n static requiredContainer: typeof ListContainer\n statics: any\n attachUI: any\n domNode: any\n replaceWith: any\n parent: any\n wrap: any\n children: any\n prev: any\n remove: () => void\n\n static create(value) {\n const node = super.create()\n if (typeof value === 'string') {\n value = { value }\n }\n else {\n [...CELL_IDENTITY_KEYS, ...CELL_ATTRIBUTES].forEach((key) => {\n if (value[key]) {\n node.dataset[key] = value[key]\n }\n })\n }\n node.classList.add(value.value)\n return node\n }\n\n static formats(domNode) {\n const formats: any = {}\n formats.value = domNode.classList.item(0) || undefined\n\n return [...CELL_ATTRIBUTES, ...CELL_IDENTITY_KEYS].reduce((tableFormats, key) => {\n if (domNode.dataset[key]) {\n tableFormats[key] = domNode.dataset[key]\n }\n return tableFormats\n }, formats)\n }\n\n static register() {\n Quill.register({ 'formats/list-container': ListContainer }, true)\n }\n\n constructor(scroll, domNode) {\n super(scroll, domNode)\n const quill = Quill.find(scroll.domNode.parentNode)\n const range = quill.getSelection()\n if (range) {\n const [line] = quill.getLine(range.index)\n const td = line.domNode.closest('td')\n if (td) {\n [...CELL_IDENTITY_KEYS, ...CELL_ATTRIBUTES].forEach(key =>\n td.dataset[key] && domNode.setAttribute(`data-${key}`, td.dataset[key]))\n }\n }\n\n const ui = domNode.ownerDocument.createElement('span')\n const listEventHandler = (e) => {\n if (!scroll.isEnabled()) return\n const { value } = this.statics.formats(domNode, scroll)\n if (value === 'checked') {\n this.format('list', 'unchecked')\n e.preventDefault()\n }\n else if (value === 'unchecked') {\n this.format('list', 'checked')\n e.preventDefault()\n }\n }\n ui.addEventListener('mousedown', listEventHandler)\n ui.addEventListener('touchstart', listEventHandler)\n this.attachUI(ui)\n }\n\n format(name, value) {\n if (name !== ListItem.blotName) {\n super.format(name, value)\n return\n }\n const type = (value && typeof value === 'object') ? value.value : value\n const oldClass = this.domNode.classList[0]\n const tdDom = this.domNode.closest('.editing-select-able')\n const tableCellBlot = tdDom && Quill.find(tdDom)\n const images = this.domNode.querySelectorAll('img[data-image-id]')\n if (!type || type === oldClass) {\n // 消除格式或相同list抵消格式时恢复图片对齐,li转化为table-cell-line\n if (images && images.length) {\n images.forEach((img) => {\n img.style.verticalAlign = 'baseLine'\n })\n }\n if (tableCellBlot && tableCellBlot.statics.blotName === 'table') {\n const tableCellFormats = tableCellBlot.formats()\n this.replaceWith('table-cell-line', tableCellFormats)\n // fix: 移除list格式时移除父级的ol或ul,避免table-cell-line判断无td自动生成td容器\n if (this.parent.statics.blotName === ListContainer.blotName) {\n this.parent.unwrap()\n }\n }\n else {\n super.format(name, value)\n }\n }\n else if (oldClass) {\n this.domNode.className = this.domNode.className.replace(oldClass, type)\n }\n else {\n this.domNode.classList.add(type)\n }\n }\n\n optimize(context) {\n // 判断前一个li是否包含软回车,如果包含则将当前li与之合并后移除\n const tail = this.prev && this.prev.domNode.lastChild\n if (tail && tail.className && tail.className.includes('ql-soft-break')) {\n // 合并dom\n this.domNode.childNodes.forEach((v, i) => {\n if (i > 0) {\n this.prev.domNode.appendChild(v)\n }\n })\n this.remove()\n return\n }\n\n super.optimize(context)\n\n // list类型\n const parentFormats = getFormats(this.parent.domNode)\n const formats = ListItem.formats(this.domNode)\n // 单元格属性\n const data = this.domNode.dataset || []\n const images = this.domNode.querySelectorAll('img[data-image-id]')\n\n // li更新后判断父容器的对应属性是否与自身一致,如果不一致则向上覆盖\n if (parentFormats.list !== formats.value) {\n const oldClass = this.parent.domNode.classList[0]\n if (oldClass) {\n this.parent.domNode.className = this.parent.domNode.className.replace(oldClass, formats.value)\n }\n else {\n this.parent.domNode.classList.add(formats.value)\n }\n }\n\n if (data.cell && !parentFormats.cell) {\n [...CELL_IDENTITY_KEYS, ...CELL_ATTRIBUTES].forEach(key =>\n (formats[key] || data[key]) && this.parent.domNode.setAttribute(`data-${key}`, formats[key] || data[key]))\n // 如果父容器不在表格内则用单元格包裹\n if (this.parent.parent.statics.blotName !== 'table') {\n delete formats.list\n this.wrap('table', formats)\n }\n }\n\n // 当list中包含图片时,设置图片顶对齐\n if (images) {\n images.forEach((img) => {\n img.style.verticalAlign = 'top'\n })\n }\n }\n}\n\nListItem.blotName = 'list'\nListItem.tagName = 'LI'\n\nListContainer.allowedChildren = [ListItem]\nListItem.requiredContainer = ListContainer\n\n// 属性读取方法:兼容table-cell-line、ol、li\n// 因为构造时当前range对应的元素最开始是table-cell-line,然后是li,且ol的formats方法不允许覆写,会导致报错,所以整合一个兼容方法来读取需要的属性。\nfunction getFormats(dom): any {\n const formats = {}\n\n if (dom.tagName === 'OL') {\n formats.list = dom.classList.item(0)\n }\n\n return [...CELL_ATTRIBUTES, ...CELL_IDENTITY_KEYS].reduce((tableFormats, attribute) => {\n if (dom.hasAttribute(`data-${attribute}`)) {\n tableFormats[attribute] = dom.getAttribute(`data-${attribute}`) || undefined\n }\n return tableFormats\n }, formats)\n}\n\nexport { ListContainer, ListItem as default }\n"],"names":[],"mappings":";;AAGA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,MAAM,YAAY,MAAM,QAAQ,iBAAiB;AAGjD,MAAM,sBAAsB,UAAU;AAAA,EAUpC,OAAO,MAAM,OAAO;AAClB,UAAM,EAAE,KAAK,MAAM,SAAS,QAAQ,IAAI,KAAK,QAAQ;AACjD,QAAA,SAAS,cAAc,UAAU;AACnC,UAAI,OAAO;AACT,cAAM,OAAO,MAAM,EAAE,KAAK,MAAM,SAAS,SAAS;AAAA,iBAE3C,KAAK;AACZ,aAAK,YAAY,mBAAmB,EAAE,KAAK,MAAM,SAAS,SAAS;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AACF;AAMA,cAAc,WAAW;AACzB,cAAc,UAAU;AAGxB,MAAM,iBAAiB,MAAM;AAAA,EAc3B,OAAO,OAAO,OAAO;AACb,UAAA,OAAO,MAAM;AACf,QAAA,OAAO,UAAU,UAAU;AAC7B,cAAQ,EAAE;IAAM,OAEb;AACH,OAAC,GAAG,oBAAoB,GAAG,eAAe,EAAE,QAAQ,CAAC,QAAQ;AACvD,YAAA,MAAM,GAAG,GAAG;AACd,eAAK,QAAQ,GAAG,IAAI,MAAM,GAAG;AAAA,QAC/B;AAAA,MAAA,CACD;AAAA,IACH;AACK,SAAA,UAAU,IAAI,MAAM,KAAK;AACvB,WAAA;A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AAO,IAAI,UAAU,KAAK,CAAC;AAAA,EACrC;AAEO,SAAA,CAAC,GAAG,iBAAiB,GAAG,kBAAkB,EAAE,OAAO,CAAC,cAAc,cAAc;AACrF,QAAI,IAAI,aAAa,QAAQ,SAAS,EAAE,GAAG;AACzC,mBAAa,SAAS,IAAI,IAAI,aAAa,QAAQ,SAAS,EAAE,KAAK;AAAA,IACrE;AACO,WAAA;AAAA,KACN,OAAO;AACZ;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Quill from "quill";
|
|
2
|
-
import { compare } from "../../utils/method.es.js";
|
|
3
2
|
import { isNullOrUndefined } from "../../config/editor.utils.es.js";
|
|
3
|
+
import { compare } from "../../utils/method.es.js";
|
|
4
4
|
import { CELL_IDENTITY_KEYS, CELL_ATTRIBUTES, CELL_DEFAULT, COL_ATTRIBUTES, COL_DEFAULT, ERROR_LIMIT, CELL_MIN_HEIGHT } from "../table-config.es.js";
|
|
5
5
|
import { getRelativeRect } from "../utils/index.es.js";
|
|
6
6
|
import Header from "./header.es.js";
|
|
@@ -30,8 +30,8 @@ class TableCellLine extends Block {
|
|
|
30
30
|
}
|
|
31
31
|
static formats(domNode) {
|
|
32
32
|
const formats = {};
|
|
33
|
-
if (formats
|
|
34
|
-
formats
|
|
33
|
+
if (formats.list) {
|
|
34
|
+
formats.list = domNode.classList.item(0);
|
|
35
35
|
}
|
|
36
36
|
return reduceFormats(domNode, formats);
|
|
37
37
|
}
|
|
@@ -56,7 +56,7 @@ class TableCellLine extends Block {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
format(name, value) {
|
|
59
|
-
if ([...CELL_ATTRIBUTES, ...CELL_IDENTITY_KEYS, "parent-bg"].
|
|
59
|
+
if ([...CELL_ATTRIBUTES, ...CELL_IDENTITY_KEYS, "parent-bg"].includes(name)) {
|
|
60
60
|
if (value) {
|
|
61
61
|
this.domNode.setAttribute(`data-${name}`, value);
|
|
62
62
|
} else {
|
|
@@ -165,10 +165,10 @@ class TableCell extends Container {
|
|
|
165
165
|
formats() {
|
|
166
166
|
const formats = {};
|
|
167
167
|
if (this.domNode.hasAttribute("data-row")) {
|
|
168
|
-
formats
|
|
168
|
+
formats.row = this.domNode.getAttribute("data-row");
|
|
169
169
|
}
|
|
170
170
|
if (this.domNode.hasAttribute("data-cell")) {
|
|
171
|
-
formats
|
|
171
|
+
formats.cell = this.domNode.getAttribute("data-cell");
|
|
172
172
|
}
|
|
173
173
|
return CELL_ATTRIBUTES.reduce((tableFormats, attribute) => {
|
|
174
174
|
if (this.domNode.hasAttribute(attribute)) {
|
|
@@ -189,7 +189,8 @@ class TableCell extends Container {
|
|
|
189
189
|
child.format(name, value);
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* this method is for TableCellLine to change cell background color
|
|
193
194
|
* if use `format('cell-bg', value)` will loop trigger
|
|
194
195
|
* TableCellLine.optimize -> TableCell.format -> TableCellLine.optimize ...
|
|
195
196
|
*/
|
|
@@ -203,10 +204,10 @@ class TableCell extends Container {
|
|
|
203
204
|
format(name, value) {
|
|
204
205
|
const quill = Quill.find(this.scroll.domNode.parentNode);
|
|
205
206
|
switch (true) {
|
|
206
|
-
case CELL_ATTRIBUTES.
|
|
207
|
+
case CELL_ATTRIBUTES.includes(name):
|
|
207
208
|
this.toggleAttribute(name, value);
|
|
208
209
|
break;
|
|
209
|
-
case ["row", "cell"].
|
|
210
|
+
case ["row", "cell"].includes(name):
|
|
210
211
|
this.toggleAttribute(`data-${name}`, value);
|
|
211
212
|
break;
|
|
212
213
|
case name === "background": {
|
|
@@ -224,12 +225,14 @@ class TableCell extends Container {
|
|
|
224
225
|
quill.setSelection(start, length, Quill.sources.USER);
|
|
225
226
|
quill.format(name, value, Quill.sources.USER);
|
|
226
227
|
quill.setSelection(start);
|
|
228
|
+
break;
|
|
227
229
|
}
|
|
228
230
|
case name === "cell-bg": {
|
|
229
231
|
this.toggleAttribute("data-cell-bg", value);
|
|
230
232
|
this.toggleAttribute("data-parent-bg", value);
|
|
231
233
|
this.formatChildren(name, value);
|
|
232
234
|
this.setCellBg(value);
|
|
235
|
+
break;
|
|
233
236
|
}
|
|
234
237
|
}
|
|
235
238
|
}
|
|
@@ -270,7 +273,7 @@ class TableCell extends Container {
|
|
|
270
273
|
const formats = {};
|
|
271
274
|
const firstChild = domNode.childNodes[0];
|
|
272
275
|
if (firstChild && domNode.tagName === "OL") {
|
|
273
|
-
formats
|
|
276
|
+
formats.list = firstChild.classList.item(0);
|
|
274
277
|
}
|
|
275
278
|
return reduceFormats(domNode, formats);
|
|
276
279
|
}
|
|
@@ -373,7 +376,7 @@ class TableCol extends Block {
|
|
|
373
376
|
}, {});
|
|
374
377
|
}
|
|
375
378
|
format(name, value) {
|
|
376
|
-
if (COL_ATTRIBUTES.
|
|
379
|
+
if (COL_ATTRIBUTES.includes(name)) {
|
|
377
380
|
this.domNode.setAttribute(`${name}`, value || COL_DEFAULT[name]);
|
|
378
381
|
} else {
|
|
379
382
|
super.format(name, value);
|
|
@@ -471,7 +474,7 @@ class TableContainer extends Container {
|
|
|
471
474
|
const tableCol = col.formats()[TableCol.blotName];
|
|
472
475
|
let tableColWidth = COL_DEFAULT.width;
|
|
473
476
|
if (tableCol && tableCol.width) {
|
|
474
|
-
tableColWidth = parseInt(tableCol.width, 10);
|
|
477
|
+
tableColWidth = Number.parseInt(tableCol.width, 10);
|
|
475
478
|
}
|
|
476
479
|
sumWidth = sumWidth + tableColWidth;
|
|
477
480
|
return sumWidth;
|
|
@@ -493,8 +496,8 @@ class TableContainer extends Container {
|
|
|
493
496
|
}
|
|
494
497
|
colGroup.children.forEach((col) => {
|
|
495
498
|
if (maxTds && col.domNode.width === "auto") {
|
|
496
|
-
const width = getComputedStyle(maxTds[tdIndex])
|
|
497
|
-
const num = parseInt(width, 10);
|
|
499
|
+
const width = getComputedStyle(maxTds[tdIndex]).width;
|
|
500
|
+
const num = Number.parseInt(width, 10);
|
|
498
501
|
col.domNode.width = num < COL_DEFAULT.width && COL_DEFAULT.width || num;
|
|
499
502
|
}
|
|
500
503
|
tdIndex++;
|
|
@@ -540,7 +543,7 @@ class TableContainer extends Container {
|
|
|
540
543
|
cell.remove();
|
|
541
544
|
});
|
|
542
545
|
modifiedCells.forEach((cell) => {
|
|
543
|
-
const cellColspan = parseInt(cell.formats().colspan, 10);
|
|
546
|
+
const cellColspan = Number.parseInt(cell.formats().colspan, 10);
|
|
544
547
|
cell.format("colspan", cellColspan - delIndexes.length);
|
|
545
548
|
});
|
|
546
549
|
this.updateTableWidth();
|
|
@@ -596,7 +599,7 @@ class TableContainer extends Container {
|
|
|
596
599
|
});
|
|
597
600
|
});
|
|
598
601
|
modifiedCells.forEach((cell) => {
|
|
599
|
-
const cellRowspan = parseInt(cell.formats().rowspan, 10);
|
|
602
|
+
const cellRowspan = Number.parseInt(cell.formats().rowspan, 10);
|
|
600
603
|
const curRowspan = cellRowspan - removedRowsLength;
|
|
601
604
|
cell.domNode.removeAttribute("style");
|
|
602
605
|
cell.format("rowspan", curRowspan);
|
|
@@ -674,11 +677,7 @@ class TableContainer extends Container {
|
|
|
674
677
|
const cellFormats = cell.formats();
|
|
675
678
|
const tableCell = this.scroll.create(
|
|
676
679
|
TableCell.blotName,
|
|
677
|
-
{
|
|
678
|
-
...CELL_DEFAULT,
|
|
679
|
-
row: rId,
|
|
680
|
-
rowspan: cellFormats.rowspan
|
|
681
|
-
}
|
|
680
|
+
{ ...CELL_DEFAULT, row: rId, rowspan: cellFormats.rowspan }
|
|
682
681
|
);
|
|
683
682
|
const cellLine = this.scroll.create(TableCellLine.blotName, {
|
|
684
683
|
row: rId,
|
|
@@ -707,7 +706,7 @@ class TableContainer extends Container {
|
|
|
707
706
|
}
|
|
708
707
|
modifiedCells.forEach((cell) => {
|
|
709
708
|
const cellColspan = cell.formats().colspan;
|
|
710
|
-
cell.format("colspan", parseInt(cellColspan, 10) + 1);
|
|
709
|
+
cell.format("colspan", Number.parseInt(cellColspan, 10) + 1);
|
|
711
710
|
affectedCells.push(cell);
|
|
712
711
|
});
|
|
713
712
|
affectedCells.sort((cellA, cellB) => {
|
|
@@ -772,7 +771,7 @@ class TableContainer extends Container {
|
|
|
772
771
|
affectedCells.push(tableCell);
|
|
773
772
|
});
|
|
774
773
|
modifiedCells.forEach((cell) => {
|
|
775
|
-
const cellRowspan = parseInt(cell.formats().rowspan, 10);
|
|
774
|
+
const cellRowspan = Number.parseInt(cell.formats().rowspan, 10);
|
|
776
775
|
cell.format("rowspan", cellRowspan + 1);
|
|
777
776
|
affectedCells.push(cell);
|
|
778
777
|
});
|
|
@@ -801,7 +800,7 @@ class TableContainer extends Container {
|
|
|
801
800
|
result = tableCell;
|
|
802
801
|
if (rowspan > 1) {
|
|
803
802
|
const minHeight = CELL_MIN_HEIGHT * rowspan + rowspan - 1;
|
|
804
|
-
const cellHeight = parseInt(tableCell.domNode.style.height, 10) || 0;
|
|
803
|
+
const cellHeight = Number.parseInt(tableCell.domNode.style.height, 10) || 0;
|
|
805
804
|
if (cellHeight < minHeight) {
|
|
806
805
|
tableCell.domNode.style.height = `${minHeight}px`;
|
|
807
806
|
}
|
|
@@ -813,10 +812,10 @@ class TableContainer extends Container {
|
|
|
813
812
|
const cId = mergedCell.children.head.domNode.getAttribute("data-cell");
|
|
814
813
|
mergedCell.children.forEach((cellLine) => {
|
|
815
814
|
cellLine.domNode.setAttribute("data-parent-bg", mergedCell.domNode.style.backgroundColor);
|
|
816
|
-
if (cellLine.children
|
|
817
|
-
cellLine.children
|
|
815
|
+
if (cellLine.children.head.domNode.style) {
|
|
816
|
+
cellLine.children.head.domNode.style.backgroundColor = mergedCell.domNode.style.backgroundColor;
|
|
818
817
|
}
|
|
819
|
-
if (!cellLine.prev || cellLine.domNode.
|
|
818
|
+
if (!cellLine.prev || cellLine.domNode.textContent.trim()) {
|
|
820
819
|
cellLine.format("cell", cId);
|
|
821
820
|
cellLine.format("row", rId);
|
|
822
821
|
cellLine.format("colspan", colspan);
|