@opentiny/fluent-editor 3.25.1 → 3.25.3-alpha.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 +105 -105
- 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.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/index.es.js.map +1 -1
- package/es/core/fluent-editor.es.js.map +1 -1
- package/es/fluent-editor.es.js.map +1 -1
- package/es/formats/soft-break.es.js.map +1 -1
- package/es/formats/strike.es.js.map +1 -1
- package/es/formats/video.es.js.map +1 -1
- package/es/modules/counter.es.js.map +1 -1
- package/es/modules/custom-clipboard.es.js.map +1 -1
- package/es/modules/custom-image/BlotFormatter.es.js +28 -0
- package/es/modules/custom-image/BlotFormatter.es.js.map +1 -1
- package/es/modules/custom-image/Options.es.js.map +1 -1
- package/es/modules/custom-image/actions/Action.es.js.map +1 -1
- package/es/modules/custom-image/actions/CustomResizeAction.es.js.map +1 -1
- package/es/modules/custom-image/actions/DeleteAction.es.js.map +1 -1
- package/es/modules/custom-image/image-bar.es.js +126 -0
- package/es/modules/custom-image/image-bar.es.js.map +1 -0
- package/es/modules/custom-image/image.es.js.map +1 -1
- package/es/modules/custom-image/specs/BlotSpec.es.js.map +1 -1
- package/es/modules/custom-image/specs/CustomImageSpec.es.js.map +1 -1
- package/es/modules/custom-image/specs/ImageSpec.es.js.map +1 -1
- package/es/modules/custom-uploader.es.js.map +1 -1
- package/es/modules/divider.es.js.map +1 -1
- package/es/modules/emoji/emoji-list/people.es.js.map +1 -1
- package/es/modules/emoji/emoji-list.es.js.map +1 -1
- package/es/modules/emoji/emoji-map.es.js.map +1 -1
- package/es/modules/emoji/emoji-sprite.es.js.map +1 -1
- package/es/modules/emoji/formats/emoji-blot.es.js.map +1 -1
- package/es/modules/emoji/index.es.js.map +1 -1
- package/es/modules/emoji/modules/emoji.es.js.map +1 -1
- package/es/modules/emoji/modules/toolbar-emoji.es.js.map +1 -1
- package/es/modules/emoji/utils.es.js.map +1 -1
- package/es/modules/file/formats/file.es.js.map +1 -1
- package/es/modules/file/index.es.js.map +1 -1
- package/es/modules/file/modules/file-bar.es.js.map +1 -1
- package/es/modules/global-link/constants.es.js.map +1 -1
- package/es/modules/global-link/formats/customer-widget-link.es.js.map +1 -1
- package/es/modules/global-link/formats/doc-link.es.js.map +1 -1
- package/es/modules/global-link/formats/wiki-link.es.js.map +1 -1
- package/es/modules/global-link/formats/work-item-link.es.js.map +1 -1
- package/es/modules/global-link/index.es.js.map +1 -1
- package/es/modules/global-link/utils/createTable.es.js.map +1 -1
- package/es/modules/link/formats/link.es.js.map +1 -1
- package/es/modules/link/index.es.js.map +1 -1
- package/es/modules/link/modules/tooltip.es.js.map +1 -1
- package/es/modules/mathlive/formats.es.js.map +1 -1
- package/es/modules/mathlive/index.es.js.map +1 -1
- package/es/modules/mathlive/tooltip.es.js.map +1 -1
- package/es/modules/mention/Mention.es.js.map +1 -1
- package/es/modules/mention/MentionLink.es.js.map +1 -1
- package/es/modules/mention/constants.es.js.map +1 -1
- package/es/modules/quick-menu.es.js.map +1 -1
- package/es/modules/syntax.es.js.map +1 -1
- package/es/modules/table/better-table.es.js.map +1 -1
- package/es/modules/table/formats/header.es.js.map +1 -1
- package/es/modules/table/formats/list.es.js.map +1 -1
- package/es/modules/table/formats/table.es.js.map +1 -1
- package/es/modules/table/modules/table-column-tool.es.js.map +1 -1
- package/es/modules/table/modules/table-operation-menu.es.js.map +1 -1
- package/es/modules/table/modules/table-scroll-bar.es.js.map +1 -1
- package/es/modules/table/modules/table-selection.es.js.map +1 -1
- package/es/modules/table/modules/table-selector.es.js.map +1 -1
- package/es/modules/table/table-config.es.js.map +1 -1
- package/es/modules/table/utils/index.es.js.map +1 -1
- package/es/modules/table/utils/node-matchers.es.js.map +1 -1
- package/es/modules/toolbar/better-picker.es.js.map +1 -1
- package/es/modules/toolbar/index.es.js.map +1 -1
- package/es/themes/snow.es.js.map +1 -1
- package/es/tools/screenshot.es.js.map +1 -1
- package/es/ui/icons.config.es.js.map +1 -1
- package/es/ui/icons.es.js.map +1 -1
- package/es/utils/debounce.es.js.map +1 -1
- package/es/utils/method.es.js.map +1 -1
- 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.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/index.cjs.js.map +1 -1
- package/lib/core/fluent-editor.cjs.js.map +1 -1
- package/lib/fluent-editor.cjs.js.map +1 -1
- package/lib/formats/soft-break.cjs.js.map +1 -1
- package/lib/formats/strike.cjs.js.map +1 -1
- package/lib/formats/video.cjs.js.map +1 -1
- package/lib/modules/counter.cjs.js.map +1 -1
- package/lib/modules/custom-clipboard.cjs.js.map +1 -1
- package/lib/modules/custom-image/BlotFormatter.cjs.js +28 -0
- package/lib/modules/custom-image/BlotFormatter.cjs.js.map +1 -1
- package/lib/modules/custom-image/Options.cjs.js.map +1 -1
- package/lib/modules/custom-image/actions/Action.cjs.js.map +1 -1
- package/lib/modules/custom-image/actions/CustomResizeAction.cjs.js.map +1 -1
- package/lib/modules/custom-image/actions/DeleteAction.cjs.js.map +1 -1
- package/lib/modules/custom-image/image-bar.cjs.js +126 -0
- package/lib/modules/custom-image/image-bar.cjs.js.map +1 -0
- package/lib/modules/custom-image/image.cjs.js.map +1 -1
- package/lib/modules/custom-image/specs/BlotSpec.cjs.js.map +1 -1
- package/lib/modules/custom-image/specs/CustomImageSpec.cjs.js.map +1 -1
- package/lib/modules/custom-image/specs/ImageSpec.cjs.js.map +1 -1
- package/lib/modules/custom-uploader.cjs.js.map +1 -1
- package/lib/modules/divider.cjs.js.map +1 -1
- package/lib/modules/emoji/emoji-list/people.cjs.js.map +1 -1
- package/lib/modules/emoji/emoji-list.cjs.js.map +1 -1
- package/lib/modules/emoji/emoji-map.cjs.js.map +1 -1
- package/lib/modules/emoji/emoji-sprite.cjs.js.map +1 -1
- package/lib/modules/emoji/formats/emoji-blot.cjs.js.map +1 -1
- package/lib/modules/emoji/index.cjs.js.map +1 -1
- package/lib/modules/emoji/modules/emoji.cjs.js.map +1 -1
- package/lib/modules/emoji/modules/toolbar-emoji.cjs.js.map +1 -1
- package/lib/modules/emoji/utils.cjs.js.map +1 -1
- package/lib/modules/file/formats/file.cjs.js.map +1 -1
- package/lib/modules/file/index.cjs.js.map +1 -1
- package/lib/modules/file/modules/file-bar.cjs.js.map +1 -1
- package/lib/modules/global-link/constants.cjs.js.map +1 -1
- package/lib/modules/global-link/formats/customer-widget-link.cjs.js.map +1 -1
- package/lib/modules/global-link/formats/doc-link.cjs.js.map +1 -1
- package/lib/modules/global-link/formats/wiki-link.cjs.js.map +1 -1
- package/lib/modules/global-link/formats/work-item-link.cjs.js.map +1 -1
- package/lib/modules/global-link/index.cjs.js.map +1 -1
- package/lib/modules/global-link/utils/createTable.cjs.js.map +1 -1
- package/lib/modules/link/formats/link.cjs.js.map +1 -1
- package/lib/modules/link/index.cjs.js.map +1 -1
- package/lib/modules/link/modules/tooltip.cjs.js.map +1 -1
- package/lib/modules/mathlive/formats.cjs.js.map +1 -1
- package/lib/modules/mathlive/index.cjs.js.map +1 -1
- package/lib/modules/mathlive/tooltip.cjs.js.map +1 -1
- package/lib/modules/mention/Mention.cjs.js.map +1 -1
- package/lib/modules/mention/MentionLink.cjs.js.map +1 -1
- package/lib/modules/mention/constants.cjs.js.map +1 -1
- package/lib/modules/quick-menu.cjs.js.map +1 -1
- package/lib/modules/syntax.cjs.js.map +1 -1
- package/lib/modules/table/better-table.cjs.js.map +1 -1
- package/lib/modules/table/formats/header.cjs.js.map +1 -1
- package/lib/modules/table/formats/list.cjs.js.map +1 -1
- package/lib/modules/table/formats/table.cjs.js.map +1 -1
- package/lib/modules/table/modules/table-column-tool.cjs.js.map +1 -1
- package/lib/modules/table/modules/table-operation-menu.cjs.js.map +1 -1
- package/lib/modules/table/modules/table-scroll-bar.cjs.js.map +1 -1
- package/lib/modules/table/modules/table-selection.cjs.js.map +1 -1
- package/lib/modules/table/modules/table-selector.cjs.js.map +1 -1
- package/lib/modules/table/table-config.cjs.js.map +1 -1
- package/lib/modules/table/utils/index.cjs.js.map +1 -1
- package/lib/modules/table/utils/node-matchers.cjs.js.map +1 -1
- package/lib/modules/toolbar/better-picker.cjs.js.map +1 -1
- package/lib/modules/toolbar/index.cjs.js.map +1 -1
- package/lib/themes/snow.cjs.js.map +1 -1
- package/lib/tools/screenshot.cjs.js.map +1 -1
- package/lib/ui/icons.cjs.js.map +1 -1
- package/lib/ui/icons.config.cjs.js.map +1 -1
- package/lib/utils/debounce.cjs.js.map +1 -1
- package/lib/utils/method.cjs.js.map +1 -1
- package/package.json +57 -56
- package/style.css +193 -0
- package/types/attributors/font-size.d.ts +1 -1
- package/types/attributors/font-style.d.ts +1 -1
- package/types/attributors/index.d.ts +4 -4
- package/types/attributors/line-height.d.ts +1 -1
- package/types/attributors/text-indent.d.ts +1 -1
- package/types/config/base64-image.d.ts +2 -2
- package/types/config/editor.config.d.ts +229 -229
- package/types/config/editor.utils.d.ts +42 -42
- package/types/config/i18n/en-us.d.ts +108 -108
- package/types/config/i18n/zh-cn.d.ts +108 -108
- package/types/config/index.d.ts +6 -6
- package/types/config/types/additional-toolbar-item.interface.d.ts +7 -6
- package/types/config/types/content-change.interface.d.ts +13 -13
- package/types/config/types/content-save.interface.d.ts +6 -6
- package/types/config/types/counter-option.interface.d.ts +8 -7
- package/types/config/types/editor-config.interface.d.ts +34 -33
- package/types/config/types/editor-modules.interface.d.ts +30 -29
- package/types/config/types/editor-toolbar.interface.d.ts +4 -3
- package/types/config/types/file-operation.interface.d.ts +11 -10
- package/types/config/types/focus-change.interface.d.ts +4 -4
- package/types/config/types/fullscreen-module.interface.d.ts +4 -4
- package/types/config/types/help-panel-item.interface.d.ts +5 -5
- package/types/config/types/help-panel-option.interface.d.ts +6 -5
- package/types/config/types/image-module.interface.d.ts +3 -3
- package/types/config/types/image-upload.interface.d.ts +6 -5
- package/types/config/types/index.d.ts +23 -23
- package/types/config/types/load-on-demand-module.interface.d.ts +5 -5
- package/types/config/types/mention-module.interface.d.ts +8 -8
- package/types/config/types/paste-change.interface.d.ts +5 -4
- package/types/config/types/quick-menu-module.interface.d.ts +3 -3
- package/types/config/types/range.interface.d.ts +4 -4
- package/types/config/types/registry-options.interface.d.ts +5 -5
- package/types/config/types/selection-change.interface.d.ts +7 -6
- package/types/config/types/toolbar-item.interface.d.ts +13 -13
- package/types/config/types/type.d.ts +5 -4
- package/types/config/types/validate-error.interface.d.ts +13 -13
- package/types/core/fluent-editor.d.ts +10 -9
- package/types/fluent-editor.d.ts +2 -1
- package/types/formats/soft-break.d.ts +14 -14
- package/types/formats/strike.d.ts +7 -7
- package/types/formats/video.d.ts +15 -14
- package/types/index.d.ts +4 -3
- package/types/modules/counter.d.ts +15 -14
- package/types/modules/custom-clipboard.d.ts +27 -26
- package/types/modules/custom-image/BlotFormatter.d.ts +26 -20
- package/types/modules/custom-image/Options.d.ts +36 -36
- package/types/modules/custom-image/actions/Action.d.ts +7 -7
- package/types/modules/custom-image/actions/CustomResizeAction.d.ts +23 -22
- package/types/modules/custom-image/actions/DeleteAction.d.ts +6 -5
- package/types/modules/custom-image/image-bar.d.ts +15 -0
- package/types/modules/custom-image/image.d.ts +28 -28
- package/types/modules/custom-image/specs/BlotSpec.d.ts +11 -10
- package/types/modules/custom-image/specs/CustomImageSpec.d.ts +18 -17
- package/types/modules/custom-image/specs/ImageSpec.d.ts +9 -8
- package/types/modules/custom-uploader.d.ts +30 -29
- package/types/modules/divider.d.ts +7 -7
- package/types/modules/emoji/emoji-list/index.d.ts +1 -1
- package/types/modules/emoji/emoji-list/people.d.ts +1 -1
- package/types/modules/emoji/emoji-list.d.ts +2 -2
- package/types/modules/emoji/emoji-map.d.ts +2 -2
- package/types/modules/emoji/emoji-sprite.d.ts +1 -1
- package/types/modules/emoji/formats/emoji-blot.d.ts +13 -13
- package/types/modules/emoji/index.d.ts +7 -6
- package/types/modules/emoji/modules/emoji.d.ts +38 -38
- package/types/modules/emoji/modules/toolbar-emoji.d.ts +8 -8
- package/types/modules/emoji/utils.d.ts +1 -1
- package/types/modules/file/formats/file.d.ts +15 -15
- package/types/modules/file/index.d.ts +10 -9
- package/types/modules/file/modules/file-bar.d.ts +14 -14
- package/types/modules/global-link/constants.d.ts +3 -3
- package/types/modules/global-link/formats/customer-widget-link.d.ts +14 -14
- package/types/modules/global-link/formats/doc-link.d.ts +17 -17
- package/types/modules/global-link/formats/wiki-link.d.ts +16 -16
- package/types/modules/global-link/formats/work-item-link.d.ts +16 -16
- package/types/modules/global-link/global-link-panel.d.ts +18 -17
- package/types/modules/global-link/index.d.ts +18 -18
- package/types/modules/global-link/utils/createTable.d.ts +1 -1
- package/types/modules/i18n.d.ts +15 -14
- package/types/modules/link/formats/link.d.ts +15 -14
- package/types/modules/link/index.d.ts +6 -6
- package/types/modules/link/modules/tooltip.d.ts +32 -31
- package/types/modules/mathlive/formats.d.ts +21 -20
- package/types/modules/mathlive/index.d.ts +7 -6
- package/types/modules/mathlive/tooltip.d.ts +15 -14
- package/types/modules/mention/Mention.d.ts +54 -53
- package/types/modules/mention/MentionLink.d.ts +15 -14
- package/types/modules/mention/constants.d.ts +3 -3
- package/types/modules/quick-menu.d.ts +21 -20
- package/types/modules/syntax.d.ts +13 -12
- package/types/modules/table/better-table.d.ts +32 -31
- package/types/modules/table/formats/header.d.ts +22 -21
- package/types/modules/table/formats/list.d.ts +34 -34
- package/types/modules/table/formats/table.d.ts +146 -145
- package/types/modules/table/modules/table-column-tool.d.ts +23 -23
- package/types/modules/table/modules/table-operation-menu.d.ts +38 -38
- package/types/modules/table/modules/table-scroll-bar.d.ts +33 -33
- package/types/modules/table/modules/table-selection.d.ts +37 -37
- package/types/modules/table/modules/table-selector.d.ts +22 -22
- package/types/modules/table/table-config.d.ts +38 -38
- package/types/modules/table/utils/index.d.ts +17 -17
- package/types/modules/table/utils/node-matchers.d.ts +9 -9
- package/types/modules/toolbar/better-picker.d.ts +1 -1
- package/types/modules/toolbar/index.d.ts +8 -7
- package/types/modules/toolbar/toolbar-tip.d.ts +8 -7
- package/types/themes/snow.d.ts +3 -2
- package/types/tools/format-painter.d.ts +14 -13
- package/types/tools/fullscreen.d.ts +2 -1
- package/types/tools/screenshot.d.ts +18 -17
- package/types/ui/icons.config.d.ts +36 -36
- package/types/ui/icons.d.ts +6 -6
- package/types/utils/debounce.d.ts +6 -6
- package/types/utils/image.d.ts +1 -1
- package/types/utils/is.d.ts +4 -4
- package/types/utils/method.d.ts +6 -6
- package/types/utils/scroll-lock.d.ts +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-operation-menu.es.js","sources":["../../../../../src/modules/table/modules/table-operation-menu.ts"],"sourcesContent":["import Quill from 'quill'\nimport { CHANGE_LANGUAGE_EVENT } from '../../../config'\nimport {\n ERROR_LIMIT,\n MENU_ITEM_HEIGHT,\n MENU_MIN_HEIGHT,\n MENU_WIDTH,\n OPERATE_MENU_COLORPICKER_CLASS,\n OPERATE_MENU_COLORPICKER_ITEM_CLASS,\n OPERATE_MENU_DIVIDING_CLASS,\n OPERATE_MENU_ITEM_CLASS,\n OPERATE_MENU_SUBTITLE_CLASS,\n} from '../table-config'\nimport { arrayFrom, css, elementRemove, getRelativeRect } from '../utils'\n\nconst DEFAULT_CELL_COLORS = ['white', 'red', 'yellow', 'blue']\nconst NODE_EVENT_MAP = new WeakMap()\nexport default class TableOperationMenu {\n tableSelection: any\n table: any\n quill: any\n options: any\n menuItems: any\n tableColumnTool: any\n tableScrollBar: any\n boundary: any\n selectedTds: any\n destroyHandler: any\n columnToolCells: any\n colorSubTitle: any\n cellColors: any\n domNode: any\n DEFAULT_COLOR_SUBTITLE: string\n DEFAULT_MENU: Record<string, {\n text: string\n handler: () => void\n }>\n\n constructor(params, quill, options) {\n const betterTableModule = quill.getModule('better-table')\n this.tableSelection = betterTableModule.tableSelection\n this.table = params.table\n this.quill = quill\n this.options = options\n this.setDefaultMenu()\n this.menuItems = { ...this.DEFAULT_MENU, ...options.items }\n this.tableColumnTool = betterTableModule.columnTool\n // this.tableRowTool = betterTableModule.rowTool\n this.tableScrollBar = betterTableModule.tableScrollBar\n this.boundary = this.tableSelection.boundary\n this.selectedTds = this.tableSelection.selectedTds\n this.destroyHandler = this.destroy.bind(this)\n this.columnToolCells = this.tableColumnTool.colToolCells()\n this.DEFAULT_COLOR_SUBTITLE = this.quill.getLangText('sub-title-bg-color')\n this.colorSubTitle\n = options.color && options.color.text\n ? options.color.text\n : this.DEFAULT_COLOR_SUBTITLE\n this.cellColors\n = options.color && options.color.colors\n ? options.color.colors\n : DEFAULT_CELL_COLORS\n\n this.menuInitial(params)\n this.mount()\n document.addEventListener('click', this.destroyHandler, false)\n this.quill.emitter.on(CHANGE_LANGUAGE_EVENT, () => {\n this.destroy()\n this.DEFAULT_COLOR_SUBTITLE = this.quill.getLangText('sub-title-bg-color')\n this.setDefaultMenu()\n })\n }\n\n setDefaultMenu() {\n this.DEFAULT_MENU = {\n copyCells: {\n text: this.quill.getLangText('copy-cells'),\n handler() {\n this.onCopy('copy')\n },\n },\n copyTable: {\n text: this.quill.getLangText('copy-table'),\n async handler() {\n this.tableColumnTool.destroy()\n this.tableScrollBar.destroy()\n this.tableSelection.clearSelection()\n const dom = this.table.cloneNode(true)\n const trArr = dom.querySelectorAll('tr[data-row]')\n trArr.forEach(tr => tr.removeAttribute('data-row'))\n this.setCopyRange(dom)\n const blob = new Blob([dom.outerHTML], { type: 'text/html' })\n const clipboardItem = new ClipboardItem({ 'text/html': blob })\n try {\n await navigator.clipboard.write([clipboardItem])\n }\n catch (_e) {\n throw new Error('Failed to write to clipboard.')\n }\n },\n },\n cutCells: {\n text: this.quill.getLangText('cut-cells'),\n handler() {\n this.onCopy('cut')\n },\n },\n emptyCells: {\n text: this.quill.getLangText('empty-cells'),\n handler() {\n const tableContainer = Quill.find(this.table)\n const { selectedTds } = this.tableSelection\n tableContainer.emptyCells(selectedTds)\n },\n },\n insertColumnRight: {\n text: this.quill.getLangText('insert-column-right'),\n handler() {\n const tableContainer = Quill.find(this.table)\n const colIndex = getColToolCellIndexByBoundary(\n this.columnToolCells,\n this.boundary,\n (cellRect, boundary) => {\n return Math.abs(cellRect.x + cellRect.width - boundary.x1) <= ERROR_LIMIT\n },\n this.quill.root.parentNode,\n )\n\n const newColumn = tableContainer.insertColumn(this.boundary, colIndex, true, this.quill.root.parentNode)\n\n this.tableColumnTool.updateColToolCells()\n this.quill.update(Quill.sources.USER)\n // fix: the scroll bar will go to the top when insert row/column to the table\n // this.quill.setSelection(\n // this.quill.getIndex(newColumn[0]),\n // 0,\n // Quill.sources.SILENT\n // )\n this.tableSelection.setSelection(\n newColumn[0].domNode.getBoundingClientRect(),\n newColumn[0].domNode.getBoundingClientRect(),\n )\n\n setTimeout(() => this.tableScrollBar.updateScrollBar())\n },\n },\n insertColumnLeft: {\n text: this.quill.getLangText('insert-column-left'),\n handler() {\n const tableContainer = Quill.find(this.table)\n const colIndex = getColToolCellIndexByBoundary(\n this.columnToolCells,\n this.boundary,\n (cellRect, boundary) => {\n return Math.abs(cellRect.x - boundary.x) <= ERROR_LIMIT\n },\n this.quill.root.parentNode,\n )\n\n const newColumn = tableContainer.insertColumn(this.boundary, colIndex, false, this.quill.root.parentNode)\n\n this.tableColumnTool.updateColToolCells()\n this.quill.update(Quill.sources.USER)\n // this.quill.setSelection(\n // this.quill.getIndex(newColumn[0]),\n // 0,\n // Quill.sources.SILENT\n // )\n this.tableSelection.setSelection(\n newColumn[0].domNode.getBoundingClientRect(),\n newColumn[0].domNode.getBoundingClientRect(),\n )\n\n setTimeout(() => this.tableScrollBar.updateScrollBar())\n },\n },\n insertRowUp: {\n text: this.quill.getLangText('insert-row-up'),\n handler() {\n const tableContainer = Quill.find(this.table)\n const affectedCells = tableContainer.insertRow(this.boundary, false, this.quill.root.parentNode)\n\n this.tableColumnTool.updateRowToolCells()\n this.quill.update(Quill.sources.USER)\n // this.quill.setSelection(\n // this.quill.getIndex(affectedCells[0]),\n // 0,\n // Quill.sources.SILENT\n // )\n this.tableSelection.setSelection(\n affectedCells[0].domNode.getBoundingClientRect(),\n affectedCells[0].domNode.getBoundingClientRect(),\n )\n\n setTimeout(() => this.tableScrollBar.resetTableHeight(this.table))\n },\n },\n insertRowDown: {\n text: this.quill.getLangText('insert-row-down'),\n handler() {\n const tableContainer = Quill.find(this.table)\n const affectedCells = tableContainer.insertRow(this.boundary, true, this.quill.root.parentNode)\n\n this.tableColumnTool.updateRowToolCells()\n this.quill.update(Quill.sources.USER)\n // this.quill.setSelection(\n // this.quill.getIndex(affectedCells[0]),\n // 0,\n // Quill.sources.SILENT\n // )\n this.tableSelection.setSelection(\n affectedCells[0].domNode.getBoundingClientRect(),\n affectedCells[0].domNode.getBoundingClientRect(),\n )\n\n setTimeout(() => this.tableScrollBar.resetTableHeight(this.table))\n },\n },\n mergeCells: {\n text: this.quill.getLangText('merge-cells'),\n handler() {\n const tableContainer = Quill.find(this.table)\n // compute merged Cell rowspan, equal to length of selected rows\n const rowspan = tableContainer.rows().reduce((sum, row) => {\n const rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), this.quill.root.parentNode)\n if (\n rowRect.y > this.boundary.y - ERROR_LIMIT\n && rowRect.y + rowRect.height < this.boundary.y + this.boundary.height + ERROR_LIMIT\n ) {\n sum += 1\n }\n return sum\n }, 0)\n\n // compute merged cell colspan, equal to length of selected cols\n const colspan = this.columnToolCells.reduce((sum, cell) => {\n const cellRect = getRelativeRect(cell.getBoundingClientRect(), this.quill.root.parentNode)\n if (\n cellRect.x > this.boundary.x - ERROR_LIMIT\n && cellRect.x + cellRect.width < this.boundary.x + this.boundary.width + ERROR_LIMIT\n ) {\n sum += 1\n }\n return sum\n }, 0)\n\n const mergedCell = tableContainer.mergeCells(\n this.boundary,\n this.selectedTds,\n rowspan,\n colspan,\n this.quill.root.parentNode,\n )\n this.quill.update(Quill.sources.USER)\n this.tableSelection.setSelection(\n mergedCell.domNode.getBoundingClientRect(),\n mergedCell.domNode.getBoundingClientRect(),\n )\n },\n },\n unmergeCells: {\n text: this.quill.getLangText('unmerge-cells'),\n handler() {\n const tableContainer = Quill.find(this.table)\n tableContainer.unmergeCells(this.selectedTds, this.quill.root.parentNode)\n this.quill.update(Quill.sources.USER)\n this.tableSelection.clearSelection()\n },\n },\n deleteColumn: {\n text: this.quill.getLangText('delete-column'),\n handler() {\n const tableContainer = Quill.find(this.table)\n const colIndexes = getColToolCellIndexesByBoundary(\n this.columnToolCells,\n this.boundary,\n (cellRect, boundary) => {\n return cellRect.x + ERROR_LIMIT > boundary.x && cellRect.x + cellRect.width - ERROR_LIMIT < boundary.x1\n },\n this.quill.root.parentNode,\n )\n\n const isDeleteTable = tableContainer.deleteColumns(this.boundary, colIndexes, this.quill.root.parentNode)\n if (!isDeleteTable) {\n this.tableColumnTool.updateColToolCells()\n this.quill.update(Quill.sources.USER)\n this.tableSelection.clearSelection()\n }\n\n setTimeout(() => this.tableScrollBar.updateScrollBar())\n },\n },\n deleteRow: {\n text: this.quill.getLangText('delete-row'),\n handler() {\n const tableContainer = Quill.find(this.table)\n const isDeleteTable = tableContainer.deleteRow(this.boundary, this.quill.root.parentNode)\n if (!isDeleteTable) {\n this.tableColumnTool.updateRowToolCells()\n this.quill.update(Quill.sources.USER)\n this.tableSelection.clearSelection()\n }\n },\n },\n deleteTable: {\n text: this.quill.getLangText('delete-table'),\n handler() {\n const betterTableModule = this.quill.getModule('better-table')\n const tableContainer = Quill.find(this.table)\n betterTableModule.hideTableTools()\n tableContainer.remove()\n this.quill.update(Quill.sources.USER)\n // fix: 右键菜单删除表格后编辑器失焦\n this.quill.focus()\n },\n },\n }\n }\n\n mount() {\n this.quill.root.parentNode.appendChild(this.domNode)\n }\n\n destroy() {\n const menuItems = arrayFrom(\n this.domNode.querySelectorAll(`.${OPERATE_MENU_ITEM_CLASS}`),\n )\n const colorPickerItems = arrayFrom(\n this.domNode.querySelectorAll(`.${OPERATE_MENU_COLORPICKER_ITEM_CLASS}`),\n )\n const nodes = menuItems.concat(colorPickerItems)\n\n nodes.forEach((node) => {\n if (NODE_EVENT_MAP.has(node)) {\n const unregister = NODE_EVENT_MAP.get(node)\n\n if (unregister && typeof unregister === 'function') {\n unregister()\n }\n }\n })\n\n elementRemove(this.domNode)\n document.removeEventListener('mousedown', this.destroyHandler, false)\n\n return null\n }\n\n menuInitial({ cell, left, top }) {\n const rowspan = cell.getAttribute('rowspan')\n const colspan = cell.getAttribute('colspan')\n const winHeight = window.innerHeight || Math.max(document.documentElement.clientHeight, document.body.clientHeight)\n const num = Object.keys(this.menuItems) || []\n const menuHeight = MENU_ITEM_HEIGHT * num.length || MENU_MIN_HEIGHT\n const transformOffset = checkAndGetViewPointChange(this.quill.root.parentNode, left, top)\n const leftPos = left - transformOffset.offsetX\n const topPos = top - transformOffset.offsetY\n\n const cssContent = {\n 'left': `${leftPos}px`,\n 'top': `${topPos}px`,\n 'min-height': `${MENU_MIN_HEIGHT}px`,\n 'max-height': `${winHeight - topPos}px`,\n 'width': `${MENU_WIDTH}px`,\n 'overflow-y': 'auto',\n }\n // fix: 处理菜单超出屏幕\n if (menuHeight + top > winHeight || topPos > winHeight / 2) {\n delete cssContent.top\n cssContent['max-height'] = `${winHeight - 20}px`\n cssContent.bottom = '10px'\n }\n\n this.domNode = document.createElement('div')\n this.domNode.classList.add('qlbt-operation-menu')\n css(this.domNode, cssContent)\n const fragment = document.createDocumentFragment()\n\n for (const name in this.menuItems) {\n if (this.menuItems[name]) {\n const item = { ...this.DEFAULT_MENU[name], ...this.menuItems[name] }\n const dom = this.menuItemCreator(item)\n if (\n (name === 'mergeCells' && this.tableSelection.selectedTds.length === 1)\n || (name === 'unmergeCells' && rowspan === 1 && colspan === 1)\n ) {\n dom.classList.add('qlbt-operation-menu-disabled')\n }\n else {\n dom.addEventListener('mouseup', item.handler.bind(this), false)\n }\n fragment.appendChild(dom)\n }\n }\n this.domNode.appendChild(fragment)\n\n // if colors option is false, disabled bg color\n if (this.options.color && this.options.color !== false) {\n this.domNode.appendChild(dividingCreator())\n this.domNode.appendChild(subTitleCreator(this.colorSubTitle))\n this.domNode.appendChild(this.colorsItemCreator(this.cellColors))\n }\n\n // create dividing line\n function dividingCreator() {\n const dividing = document.createElement('div')\n dividing.classList.add(OPERATE_MENU_DIVIDING_CLASS)\n return dividing\n }\n\n // create subtitle for menu\n function subTitleCreator(title) {\n const subTitle = document.createElement('div')\n subTitle.classList.add(OPERATE_MENU_SUBTITLE_CLASS)\n subTitle.textContent = title\n return subTitle\n }\n }\n\n colorsItemCreator(colors) {\n const self = this\n const node = document.createElement('div')\n node.classList.add(OPERATE_MENU_COLORPICKER_CLASS)\n\n colors.forEach((color) => {\n const colorBox = colorBoxCreator(color)\n node.appendChild(colorBox)\n })\n\n function colorBoxCreator(color) {\n const box = document.createElement('div')\n box.classList.add(OPERATE_MENU_COLORPICKER_ITEM_CLASS)\n box.setAttribute('data-color', color)\n box.style.backgroundColor = color\n\n const clickHandler = function () {\n const selectedTds = self.tableSelection.selectedTds\n if (selectedTds && selectedTds.length > 0) {\n selectedTds.forEach((tableCell) => {\n tableCell.domNode.children[0].setAttribute('data-parent-bg', color)\n tableCell.format('cell-bg', color)\n })\n }\n }\n\n box.addEventListener('click', clickHandler, false)\n\n NODE_EVENT_MAP.set(box, () => {\n box.removeEventListener('click', clickHandler, false)\n })\n\n return box\n }\n\n return node\n }\n\n menuItemCreator({ text }) {\n const node = document.createElement('div')\n node.classList.add('qlbt-operation-menu-item')\n node.style.height = `${MENU_ITEM_HEIGHT}px`\n node.textContent = text\n // node.addEventListener('click', handler.bind(this), false)\n return node\n }\n\n async onCopy(operation) {\n const { selectedTds } = this.tableSelection\n const virtualTable = this.createVirtualTable(selectedTds, operation)\n this.setCopyRange(virtualTable)\n this.tableSelection.preSelectedTable = virtualTable\n this.tableSelection.preSelectedTds = selectedTds\n const blob = new Blob([this.tableSelection.preSelectedTable.outerHTML], { type: 'text/html' })\n const clipboardItem = new ClipboardItem({ 'text/html': blob })\n try {\n await navigator.clipboard.write([clipboardItem])\n }\n catch (_e) {\n throw new Error('Failed to write to clipboard.')\n }\n if (operation === 'cut') {\n const tableContainer = Quill.find(this.table)\n tableContainer.emptyCells(selectedTds)\n }\n }\n\n createVirtualTable(selectedTds, _operation) {\n const virtualTable: any = document.createElement('table')\n virtualTable.style.position = 'fixed'\n virtualTable.style.top = 0\n virtualTable.style.left = 0\n virtualTable.style.clip = 'rect(0,0,0,0)'\n let preParentSign = ''\n let virtualTr = null\n selectedTds.forEach((selectedCell) => {\n const { domNode, parent } = selectedCell\n const currentParentSign = parent.domNode.getAttribute('data-row')\n const rowspan = domNode.firstChild.dataset.rowspan\n const colspan = domNode.firstChild.dataset.colspan\n const row = domNode.firstChild.dataset.row\n const cell = domNode.firstChild.dataset.cell\n\n selectedCell.dataCell = cell\n selectedCell.dataRow = row\n selectedCell.dataColSpan = colspan\n selectedCell.dataRowSpan = rowspan\n\n if (currentParentSign !== preParentSign) {\n if (preParentSign !== '') {\n virtualTable.appendChild(virtualTr)\n }\n virtualTr = document.createElement('tr')\n preParentSign = currentParentSign\n }\n\n const domNodeWidth = domNode.offsetWidth\n const cloneNode = domNode.cloneNode(true)\n cloneNode.setAttribute('width', domNodeWidth)\n\n virtualTr.appendChild(cloneNode)\n })\n virtualTable.appendChild(virtualTr)\n return virtualTable\n }\n\n setCopyRange(selectedNodes) {\n const range = document.createRange()\n const windowSelectionRange = window.getSelection()\n range.selectNodeContents(selectedNodes)\n windowSelectionRange.removeAllRanges()\n windowSelectionRange.addRange(range)\n }\n\n groupTableCell(selectedTds) {\n const rowGroup = []\n let dataRow = ''\n let preDataRow = ''\n let index = 0\n selectedTds.forEach((tableCell) => {\n dataRow = tableCell.parent.domNode.getAttribute('data-row')\n\n if (dataRow !== preDataRow) {\n if (preDataRow !== '') {\n index++\n }\n rowGroup[index] = []\n preDataRow = dataRow\n }\n\n rowGroup[index].push(tableCell)\n })\n return rowGroup\n }\n}\n\nfunction getColToolCellIndexByBoundary(cells, boundary, conditionFn, container) {\n return cells.reduce((findIndex, cell) => {\n const cellRect = getRelativeRect(cell.getBoundingClientRect(), container)\n if (conditionFn(cellRect, boundary)) {\n findIndex = cells.indexOf(cell)\n }\n return findIndex\n }, false)\n}\n\nfunction getColToolCellIndexesByBoundary(cells, boundary, conditionFn, container) {\n return cells.reduce((findIndexes, cell) => {\n const cellRect = getRelativeRect(cell.getBoundingClientRect(), container)\n if (conditionFn(cellRect, boundary)) {\n findIndexes.push(cells.indexOf(cell))\n }\n return findIndexes\n }, [])\n}\n\nfunction checkAndGetViewPointChange(parentContainer: HTMLElement, left: number, top: number) {\n if (!parentContainer) {\n return {\n offsetX: 0,\n offsetY: 0,\n }\n }\n // 模拟一个元素测预测位置和最终位置是否符合,如果不符合则是有transform等造成的偏移\n const testEl = document.createElement('div')\n css(testEl, {\n opacity: '0',\n position: 'fixed',\n left: `${left}px`,\n top: `${top}px`,\n width: '1px',\n height: '1px',\n zIndex: '-999999',\n })\n parentContainer.appendChild(testEl)\n const testElPosition = testEl.getBoundingClientRect()\n parentContainer.removeChild(testEl)\n return {\n offsetX: testElPosition.left - left,\n offsetY: testElPosition.top - top,\n }\n}\n"],"names":[],"mappings":";;;;;AAeA,MAAM,sBAAsB,CAAC,SAAS,OAAO,UAAU,MAAM;AAC7D,MAAM,qCAAqB,QAAQ;AACnC,MAAqB,mBAAmB;AAAA,EAqBtC,YAAY,QAAQ,OAAO,SAAS;AAC5B,UAAA,oBAAoB,MAAM,UAAU,cAAc;AACxD,SAAK,iBAAiB,kBAAkB;AACxC,SAAK,QAAQ,OAAO;AACpB,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SA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AAM,WAAW,gBAAgB,KAAK,sBAAA,GAAyB,SAAS;AACpE,QAAA,YAAY,UAAU,QAAQ,GAAG;AACvB,kBAAA,MAAM,QAAQ,IAAI;AAAA,IAAA;AAEzB,WAAA;AAAA,KACN,KAAK;AACV;AAEA,SAAS,gCAAgC,OAAO,UAAU,aAAa,WAAW;AAChF,SAAO,MAAM,OAAO,CAAC,aAAa,SAAS;AACzC,UAAM,WAAW,gBAAgB,KAAK,sBAAA,GAAyB,SAAS;AACpE,QAAA,YAAY,UAAU,QAAQ,GAAG;AACnC,kBAAY,KAAK,MAAM,QAAQ,IAAI,CAAC;AAAA,IAAA;AAE/B,WAAA;AAAA,EACT,GAAG,EAAE;AACP;AAEA,SAAS,2BAA2B,iBAA8B,MAAc,KAAa;AAC3F,MAAI,CAAC,iBAAiB;AACb,WAAA;AAAA,MACL,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EAAA;AAGI,QAAA,SAAS,SAAS,cAAc,KAAK;AAC3C,MAAI,QAAQ;AAAA,IACV,SAAS;AAAA,IACT,UAAU;AAAA,IACV,MAAM,GAAG,IAAI;AAAA,IACb,KAAK,GAAG,GAAG;AAAA,IACX,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,EAAA,CACT;AACD,kBAAgB,YAAY,MAAM;AAC5B,QAAA,iBAAiB,OAAO,sBAAsB;AACpD,kBAAgB,YAAY,MAAM;AAC3B,SAAA;AAAA,IACL,SAAS,eAAe,OAAO;AAAA,IAC/B,SAAS,eAAe,MAAM;AAAA,EAChC;AACF;"}
|
|
1
|
+
{"version":3,"file":"table-operation-menu.es.js","sources":["../../../../../src/modules/table/modules/table-operation-menu.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport { CHANGE_LANGUAGE_EVENT } from '../../../config'\r\nimport {\r\n ERROR_LIMIT,\r\n MENU_ITEM_HEIGHT,\r\n MENU_MIN_HEIGHT,\r\n MENU_WIDTH,\r\n OPERATE_MENU_COLORPICKER_CLASS,\r\n OPERATE_MENU_COLORPICKER_ITEM_CLASS,\r\n OPERATE_MENU_DIVIDING_CLASS,\r\n OPERATE_MENU_ITEM_CLASS,\r\n OPERATE_MENU_SUBTITLE_CLASS,\r\n} from '../table-config'\r\nimport { arrayFrom, css, elementRemove, getRelativeRect } from '../utils'\r\n\r\nconst DEFAULT_CELL_COLORS = ['white', 'red', 'yellow', 'blue']\r\nconst NODE_EVENT_MAP = new WeakMap()\r\nexport default class TableOperationMenu {\r\n tableSelection: any\r\n table: any\r\n quill: any\r\n options: any\r\n menuItems: any\r\n tableColumnTool: any\r\n tableScrollBar: any\r\n boundary: any\r\n selectedTds: any\r\n destroyHandler: any\r\n columnToolCells: any\r\n colorSubTitle: any\r\n cellColors: any\r\n domNode: any\r\n DEFAULT_COLOR_SUBTITLE: string\r\n DEFAULT_MENU: Record<string, {\r\n text: string\r\n handler: () => void\r\n }>\r\n\r\n constructor(params, quill, options) {\r\n const betterTableModule = quill.getModule('better-table')\r\n this.tableSelection = betterTableModule.tableSelection\r\n this.table = params.table\r\n this.quill = quill\r\n this.options = options\r\n this.setDefaultMenu()\r\n this.menuItems = { ...this.DEFAULT_MENU, ...options.items }\r\n this.tableColumnTool = betterTableModule.columnTool\r\n // this.tableRowTool = betterTableModule.rowTool\r\n this.tableScrollBar = betterTableModule.tableScrollBar\r\n this.boundary = this.tableSelection.boundary\r\n this.selectedTds = this.tableSelection.selectedTds\r\n this.destroyHandler = this.destroy.bind(this)\r\n this.columnToolCells = this.tableColumnTool.colToolCells()\r\n this.DEFAULT_COLOR_SUBTITLE = this.quill.getLangText('sub-title-bg-color')\r\n this.colorSubTitle\r\n = options.color && options.color.text\r\n ? options.color.text\r\n : this.DEFAULT_COLOR_SUBTITLE\r\n this.cellColors\r\n = options.color && options.color.colors\r\n ? options.color.colors\r\n : DEFAULT_CELL_COLORS\r\n\r\n this.menuInitial(params)\r\n this.mount()\r\n document.addEventListener('click', this.destroyHandler, false)\r\n this.quill.emitter.on(CHANGE_LANGUAGE_EVENT, () => {\r\n this.destroy()\r\n this.DEFAULT_COLOR_SUBTITLE = this.quill.getLangText('sub-title-bg-color')\r\n this.setDefaultMenu()\r\n })\r\n }\r\n\r\n setDefaultMenu() {\r\n this.DEFAULT_MENU = {\r\n copyCells: {\r\n text: this.quill.getLangText('copy-cells'),\r\n handler() {\r\n this.onCopy('copy')\r\n },\r\n },\r\n copyTable: {\r\n text: this.quill.getLangText('copy-table'),\r\n async handler() {\r\n this.tableColumnTool.destroy()\r\n this.tableScrollBar.destroy()\r\n this.tableSelection.clearSelection()\r\n const dom = this.table.cloneNode(true)\r\n const trArr = dom.querySelectorAll('tr[data-row]')\r\n trArr.forEach(tr => tr.removeAttribute('data-row'))\r\n this.setCopyRange(dom)\r\n const blob = new Blob([dom.outerHTML], { type: 'text/html' })\r\n const clipboardItem = new ClipboardItem({ 'text/html': blob })\r\n try {\r\n await navigator.clipboard.write([clipboardItem])\r\n }\r\n catch (_e) {\r\n throw new Error('Failed to write to clipboard.')\r\n }\r\n },\r\n },\r\n cutCells: {\r\n text: this.quill.getLangText('cut-cells'),\r\n handler() {\r\n this.onCopy('cut')\r\n },\r\n },\r\n emptyCells: {\r\n text: this.quill.getLangText('empty-cells'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n const { selectedTds } = this.tableSelection\r\n tableContainer.emptyCells(selectedTds)\r\n },\r\n },\r\n insertColumnRight: {\r\n text: this.quill.getLangText('insert-column-right'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n const colIndex = getColToolCellIndexByBoundary(\r\n this.columnToolCells,\r\n this.boundary,\r\n (cellRect, boundary) => {\r\n return Math.abs(cellRect.x + cellRect.width - boundary.x1) <= ERROR_LIMIT\r\n },\r\n this.quill.root.parentNode,\r\n )\r\n\r\n const newColumn = tableContainer.insertColumn(this.boundary, colIndex, true, this.quill.root.parentNode)\r\n\r\n this.tableColumnTool.updateColToolCells()\r\n this.quill.update(Quill.sources.USER)\r\n // fix: the scroll bar will go to the top when insert row/column to the table\r\n // this.quill.setSelection(\r\n // this.quill.getIndex(newColumn[0]),\r\n // 0,\r\n // Quill.sources.SILENT\r\n // )\r\n this.tableSelection.setSelection(\r\n newColumn[0].domNode.getBoundingClientRect(),\r\n newColumn[0].domNode.getBoundingClientRect(),\r\n )\r\n\r\n setTimeout(() => this.tableScrollBar.updateScrollBar())\r\n },\r\n },\r\n insertColumnLeft: {\r\n text: this.quill.getLangText('insert-column-left'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n const colIndex = getColToolCellIndexByBoundary(\r\n this.columnToolCells,\r\n this.boundary,\r\n (cellRect, boundary) => {\r\n return Math.abs(cellRect.x - boundary.x) <= ERROR_LIMIT\r\n },\r\n this.quill.root.parentNode,\r\n )\r\n\r\n const newColumn = tableContainer.insertColumn(this.boundary, colIndex, false, this.quill.root.parentNode)\r\n\r\n this.tableColumnTool.updateColToolCells()\r\n this.quill.update(Quill.sources.USER)\r\n // this.quill.setSelection(\r\n // this.quill.getIndex(newColumn[0]),\r\n // 0,\r\n // Quill.sources.SILENT\r\n // )\r\n this.tableSelection.setSelection(\r\n newColumn[0].domNode.getBoundingClientRect(),\r\n newColumn[0].domNode.getBoundingClientRect(),\r\n )\r\n\r\n setTimeout(() => this.tableScrollBar.updateScrollBar())\r\n },\r\n },\r\n insertRowUp: {\r\n text: this.quill.getLangText('insert-row-up'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n const affectedCells = tableContainer.insertRow(this.boundary, false, this.quill.root.parentNode)\r\n\r\n this.tableColumnTool.updateRowToolCells()\r\n this.quill.update(Quill.sources.USER)\r\n // this.quill.setSelection(\r\n // this.quill.getIndex(affectedCells[0]),\r\n // 0,\r\n // Quill.sources.SILENT\r\n // )\r\n this.tableSelection.setSelection(\r\n affectedCells[0].domNode.getBoundingClientRect(),\r\n affectedCells[0].domNode.getBoundingClientRect(),\r\n )\r\n\r\n setTimeout(() => this.tableScrollBar.resetTableHeight(this.table))\r\n },\r\n },\r\n insertRowDown: {\r\n text: this.quill.getLangText('insert-row-down'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n const affectedCells = tableContainer.insertRow(this.boundary, true, this.quill.root.parentNode)\r\n\r\n this.tableColumnTool.updateRowToolCells()\r\n this.quill.update(Quill.sources.USER)\r\n // this.quill.setSelection(\r\n // this.quill.getIndex(affectedCells[0]),\r\n // 0,\r\n // Quill.sources.SILENT\r\n // )\r\n this.tableSelection.setSelection(\r\n affectedCells[0].domNode.getBoundingClientRect(),\r\n affectedCells[0].domNode.getBoundingClientRect(),\r\n )\r\n\r\n setTimeout(() => this.tableScrollBar.resetTableHeight(this.table))\r\n },\r\n },\r\n mergeCells: {\r\n text: this.quill.getLangText('merge-cells'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n // compute merged Cell rowspan, equal to length of selected rows\r\n const rowspan = tableContainer.rows().reduce((sum, row) => {\r\n const rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), this.quill.root.parentNode)\r\n if (\r\n rowRect.y > this.boundary.y - ERROR_LIMIT\r\n && rowRect.y + rowRect.height < this.boundary.y + this.boundary.height + ERROR_LIMIT\r\n ) {\r\n sum += 1\r\n }\r\n return sum\r\n }, 0)\r\n\r\n // compute merged cell colspan, equal to length of selected cols\r\n const colspan = this.columnToolCells.reduce((sum, cell) => {\r\n const cellRect = getRelativeRect(cell.getBoundingClientRect(), this.quill.root.parentNode)\r\n if (\r\n cellRect.x > this.boundary.x - ERROR_LIMIT\r\n && cellRect.x + cellRect.width < this.boundary.x + this.boundary.width + ERROR_LIMIT\r\n ) {\r\n sum += 1\r\n }\r\n return sum\r\n }, 0)\r\n\r\n const mergedCell = tableContainer.mergeCells(\r\n this.boundary,\r\n this.selectedTds,\r\n rowspan,\r\n colspan,\r\n this.quill.root.parentNode,\r\n )\r\n this.quill.update(Quill.sources.USER)\r\n this.tableSelection.setSelection(\r\n mergedCell.domNode.getBoundingClientRect(),\r\n mergedCell.domNode.getBoundingClientRect(),\r\n )\r\n },\r\n },\r\n unmergeCells: {\r\n text: this.quill.getLangText('unmerge-cells'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n tableContainer.unmergeCells(this.selectedTds, this.quill.root.parentNode)\r\n this.quill.update(Quill.sources.USER)\r\n this.tableSelection.clearSelection()\r\n },\r\n },\r\n deleteColumn: {\r\n text: this.quill.getLangText('delete-column'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n const colIndexes = getColToolCellIndexesByBoundary(\r\n this.columnToolCells,\r\n this.boundary,\r\n (cellRect, boundary) => {\r\n return cellRect.x + ERROR_LIMIT > boundary.x && cellRect.x + cellRect.width - ERROR_LIMIT < boundary.x1\r\n },\r\n this.quill.root.parentNode,\r\n )\r\n\r\n const isDeleteTable = tableContainer.deleteColumns(this.boundary, colIndexes, this.quill.root.parentNode)\r\n if (!isDeleteTable) {\r\n this.tableColumnTool.updateColToolCells()\r\n this.quill.update(Quill.sources.USER)\r\n this.tableSelection.clearSelection()\r\n }\r\n\r\n setTimeout(() => this.tableScrollBar.updateScrollBar())\r\n },\r\n },\r\n deleteRow: {\r\n text: this.quill.getLangText('delete-row'),\r\n handler() {\r\n const tableContainer = Quill.find(this.table)\r\n const isDeleteTable = tableContainer.deleteRow(this.boundary, this.quill.root.parentNode)\r\n if (!isDeleteTable) {\r\n this.tableColumnTool.updateRowToolCells()\r\n this.quill.update(Quill.sources.USER)\r\n this.tableSelection.clearSelection()\r\n }\r\n },\r\n },\r\n deleteTable: {\r\n text: this.quill.getLangText('delete-table'),\r\n handler() {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n const tableContainer = Quill.find(this.table)\r\n betterTableModule.hideTableTools()\r\n tableContainer.remove()\r\n this.quill.update(Quill.sources.USER)\r\n // fix: 右键菜单删除表格后编辑器失焦\r\n this.quill.focus()\r\n },\r\n },\r\n }\r\n }\r\n\r\n mount() {\r\n this.quill.root.parentNode.appendChild(this.domNode)\r\n }\r\n\r\n destroy() {\r\n const menuItems = arrayFrom(\r\n this.domNode.querySelectorAll(`.${OPERATE_MENU_ITEM_CLASS}`),\r\n )\r\n const colorPickerItems = arrayFrom(\r\n this.domNode.querySelectorAll(`.${OPERATE_MENU_COLORPICKER_ITEM_CLASS}`),\r\n )\r\n const nodes = menuItems.concat(colorPickerItems)\r\n\r\n nodes.forEach((node) => {\r\n if (NODE_EVENT_MAP.has(node)) {\r\n const unregister = NODE_EVENT_MAP.get(node)\r\n\r\n if (unregister && typeof unregister === 'function') {\r\n unregister()\r\n }\r\n }\r\n })\r\n\r\n elementRemove(this.domNode)\r\n document.removeEventListener('mousedown', this.destroyHandler, false)\r\n\r\n return null\r\n }\r\n\r\n menuInitial({ cell, left, top }) {\r\n const rowspan = cell.getAttribute('rowspan')\r\n const colspan = cell.getAttribute('colspan')\r\n const winHeight = window.innerHeight || Math.max(document.documentElement.clientHeight, document.body.clientHeight)\r\n const num = Object.keys(this.menuItems) || []\r\n const menuHeight = MENU_ITEM_HEIGHT * num.length || MENU_MIN_HEIGHT\r\n const transformOffset = checkAndGetViewPointChange(this.quill.root.parentNode, left, top)\r\n const leftPos = left - transformOffset.offsetX\r\n const topPos = top - transformOffset.offsetY\r\n\r\n const cssContent = {\r\n 'left': `${leftPos}px`,\r\n 'top': `${topPos}px`,\r\n 'min-height': `${MENU_MIN_HEIGHT}px`,\r\n 'max-height': `${winHeight - topPos}px`,\r\n 'width': `${MENU_WIDTH}px`,\r\n 'overflow-y': 'auto',\r\n }\r\n // fix: 处理菜单超出屏幕\r\n if (menuHeight + top > winHeight || topPos > winHeight / 2) {\r\n delete cssContent.top\r\n cssContent['max-height'] = `${winHeight - 20}px`\r\n cssContent.bottom = '10px'\r\n }\r\n\r\n this.domNode = document.createElement('div')\r\n this.domNode.classList.add('qlbt-operation-menu')\r\n css(this.domNode, cssContent)\r\n const fragment = document.createDocumentFragment()\r\n\r\n for (const name in this.menuItems) {\r\n if (this.menuItems[name]) {\r\n const item = { ...this.DEFAULT_MENU[name], ...this.menuItems[name] }\r\n const dom = this.menuItemCreator(item)\r\n if (\r\n (name === 'mergeCells' && this.tableSelection.selectedTds.length === 1)\r\n || (name === 'unmergeCells' && rowspan === 1 && colspan === 1)\r\n ) {\r\n dom.classList.add('qlbt-operation-menu-disabled')\r\n }\r\n else {\r\n dom.addEventListener('mouseup', item.handler.bind(this), false)\r\n }\r\n fragment.appendChild(dom)\r\n }\r\n }\r\n this.domNode.appendChild(fragment)\r\n\r\n // if colors option is false, disabled bg color\r\n if (this.options.color && this.options.color !== false) {\r\n this.domNode.appendChild(dividingCreator())\r\n this.domNode.appendChild(subTitleCreator(this.colorSubTitle))\r\n this.domNode.appendChild(this.colorsItemCreator(this.cellColors))\r\n }\r\n\r\n // create dividing line\r\n function dividingCreator() {\r\n const dividing = document.createElement('div')\r\n dividing.classList.add(OPERATE_MENU_DIVIDING_CLASS)\r\n return dividing\r\n }\r\n\r\n // create subtitle for menu\r\n function subTitleCreator(title) {\r\n const subTitle = document.createElement('div')\r\n subTitle.classList.add(OPERATE_MENU_SUBTITLE_CLASS)\r\n subTitle.textContent = title\r\n return subTitle\r\n }\r\n }\r\n\r\n colorsItemCreator(colors) {\r\n const self = this\r\n const node = document.createElement('div')\r\n node.classList.add(OPERATE_MENU_COLORPICKER_CLASS)\r\n\r\n colors.forEach((color) => {\r\n const colorBox = colorBoxCreator(color)\r\n node.appendChild(colorBox)\r\n })\r\n\r\n function colorBoxCreator(color) {\r\n const box = document.createElement('div')\r\n box.classList.add(OPERATE_MENU_COLORPICKER_ITEM_CLASS)\r\n box.setAttribute('data-color', color)\r\n box.style.backgroundColor = color\r\n\r\n const clickHandler = function () {\r\n const selectedTds = self.tableSelection.selectedTds\r\n if (selectedTds && selectedTds.length > 0) {\r\n selectedTds.forEach((tableCell) => {\r\n tableCell.domNode.children[0].setAttribute('data-parent-bg', color)\r\n tableCell.format('cell-bg', color)\r\n })\r\n }\r\n }\r\n\r\n box.addEventListener('click', clickHandler, false)\r\n\r\n NODE_EVENT_MAP.set(box, () => {\r\n box.removeEventListener('click', clickHandler, false)\r\n })\r\n\r\n return box\r\n }\r\n\r\n return node\r\n }\r\n\r\n menuItemCreator({ text }) {\r\n const node = document.createElement('div')\r\n node.classList.add('qlbt-operation-menu-item')\r\n node.style.height = `${MENU_ITEM_HEIGHT}px`\r\n node.textContent = text\r\n // node.addEventListener('click', handler.bind(this), false)\r\n return node\r\n }\r\n\r\n async onCopy(operation) {\r\n const { selectedTds } = this.tableSelection\r\n const virtualTable = this.createVirtualTable(selectedTds, operation)\r\n this.setCopyRange(virtualTable)\r\n this.tableSelection.preSelectedTable = virtualTable\r\n this.tableSelection.preSelectedTds = selectedTds\r\n const blob = new Blob([this.tableSelection.preSelectedTable.outerHTML], { type: 'text/html' })\r\n const clipboardItem = new ClipboardItem({ 'text/html': blob })\r\n try {\r\n await navigator.clipboard.write([clipboardItem])\r\n }\r\n catch (_e) {\r\n throw new Error('Failed to write to clipboard.')\r\n }\r\n if (operation === 'cut') {\r\n const tableContainer = Quill.find(this.table)\r\n tableContainer.emptyCells(selectedTds)\r\n }\r\n }\r\n\r\n createVirtualTable(selectedTds, _operation) {\r\n const virtualTable: any = document.createElement('table')\r\n virtualTable.style.position = 'fixed'\r\n virtualTable.style.top = 0\r\n virtualTable.style.left = 0\r\n virtualTable.style.clip = 'rect(0,0,0,0)'\r\n let preParentSign = ''\r\n let virtualTr = null\r\n selectedTds.forEach((selectedCell) => {\r\n const { domNode, parent } = selectedCell\r\n const currentParentSign = parent.domNode.getAttribute('data-row')\r\n const rowspan = domNode.firstChild.dataset.rowspan\r\n const colspan = domNode.firstChild.dataset.colspan\r\n const row = domNode.firstChild.dataset.row\r\n const cell = domNode.firstChild.dataset.cell\r\n\r\n selectedCell.dataCell = cell\r\n selectedCell.dataRow = row\r\n selectedCell.dataColSpan = colspan\r\n selectedCell.dataRowSpan = rowspan\r\n\r\n if (currentParentSign !== preParentSign) {\r\n if (preParentSign !== '') {\r\n virtualTable.appendChild(virtualTr)\r\n }\r\n virtualTr = document.createElement('tr')\r\n preParentSign = currentParentSign\r\n }\r\n\r\n const domNodeWidth = domNode.offsetWidth\r\n const cloneNode = domNode.cloneNode(true)\r\n cloneNode.setAttribute('width', domNodeWidth)\r\n\r\n virtualTr.appendChild(cloneNode)\r\n })\r\n virtualTable.appendChild(virtualTr)\r\n return virtualTable\r\n }\r\n\r\n setCopyRange(selectedNodes) {\r\n const range = document.createRange()\r\n const windowSelectionRange = window.getSelection()\r\n range.selectNodeContents(selectedNodes)\r\n windowSelectionRange.removeAllRanges()\r\n windowSelectionRange.addRange(range)\r\n }\r\n\r\n groupTableCell(selectedTds) {\r\n const rowGroup = []\r\n let dataRow = ''\r\n let preDataRow = ''\r\n let index = 0\r\n selectedTds.forEach((tableCell) => {\r\n dataRow = tableCell.parent.domNode.getAttribute('data-row')\r\n\r\n if (dataRow !== preDataRow) {\r\n if (preDataRow !== '') {\r\n index++\r\n }\r\n rowGroup[index] = []\r\n preDataRow = dataRow\r\n }\r\n\r\n rowGroup[index].push(tableCell)\r\n })\r\n return rowGroup\r\n }\r\n}\r\n\r\nfunction getColToolCellIndexByBoundary(cells, boundary, conditionFn, container) {\r\n return cells.reduce((findIndex, cell) => {\r\n const cellRect = getRelativeRect(cell.getBoundingClientRect(), container)\r\n if (conditionFn(cellRect, boundary)) {\r\n findIndex = cells.indexOf(cell)\r\n }\r\n return findIndex\r\n }, false)\r\n}\r\n\r\nfunction getColToolCellIndexesByBoundary(cells, boundary, conditionFn, container) {\r\n return cells.reduce((findIndexes, cell) => {\r\n const cellRect = getRelativeRect(cell.getBoundingClientRect(), container)\r\n if (conditionFn(cellRect, boundary)) {\r\n findIndexes.push(cells.indexOf(cell))\r\n }\r\n return findIndexes\r\n }, [])\r\n}\r\n\r\nfunction checkAndGetViewPointChange(parentContainer: HTMLElement, left: number, top: number) {\r\n if (!parentContainer) {\r\n return {\r\n offsetX: 0,\r\n offsetY: 0,\r\n }\r\n }\r\n // 模拟一个元素测预测位置和最终位置是否符合,如果不符合则是有transform等造成的偏移\r\n const testEl = document.createElement('div')\r\n css(testEl, {\r\n opacity: '0',\r\n position: 'fixed',\r\n left: `${left}px`,\r\n top: `${top}px`,\r\n width: '1px',\r\n height: '1px',\r\n zIndex: '-999999',\r\n })\r\n parentContainer.appendChild(testEl)\r\n const testElPosition = testEl.getBoundingClientRect()\r\n parentContainer.removeChild(testEl)\r\n return {\r\n offsetX: testElPosition.left - left,\r\n offsetY: testElPosition.top - top,\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;AAeA,MAAM,sBAAsB,CAAC,SAAS,OAAO,UAAU,MAAM;AAC7D,MAAM,qCAAqB,QAAQ;AACnC,MAAqB,mBAAmB;AAAA,EAqBtC,YAAY,QAAQ,OAAO,SAAS;AAC5B,UAAA,oBAAoB,MAAM,UAAU,cAAc;AACxD,SAAK,iBAAiB,kBAAkB;AACxC,SAAK,QAAQ,OAAO;AACpB,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,YAAY,EAAE,GAAG,KAAK,cAAc,GAAG,QAAQ,MAAM;AAC1D,SAAK,kBAAkB,kBAAkB;AAEzC,SAAK,iBAAiB,kBAAkB;AACnC,SAAA,WAAW,KAAK,eAAe;AAC/B,SAAA,cAAc,KAAK,eAAe;AACvC,SAAK,iBAAiB,KAAK,QAAQ,KAAK,IAAI;AACvC,SAAA,kBAAkB,KAAK,gBAAgB,aAAa;AACzD,SAAK,yBAAyB,KAAK,MAAM,YAAY,oBAAoB;AACpE,SAAA,gBACD,QAAQ,SAAS,QAAQ,MAAM,OAC7B,QAAQ,MAAM,OACd,KAAK;AACN,SAAA,aACD,QAAQ,SAAS,QAAQ,MAAM,SAC7B,QAAQ,MAAM,SACd;AAEN,SAAK,YAAY,MAAM;AACvB,SAAK,MAAM;AACX,aAAS,iBAAiB,SAAS,KAAK,gBAAgB,KAAK;AAC7D,SAAK,MAAM,QAAQ,GAAG,uBAAuB,MAAM;AACjD,WAAK,QAAQ;AACb,W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AAAA,IACV,SAAS;AAAA,IACT,UAAU;AAAA,IACV,MAAM,GAAG,IAAI;AAAA,IACb,KAAK,GAAG,GAAG;AAAA,IACX,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,EAAA,CACT;AACD,kBAAgB,YAAY,MAAM;AAC5B,QAAA,iBAAiB,OAAO,sBAAsB;AACpD,kBAAgB,YAAY,MAAM;AAC3B,SAAA;AAAA,IACL,SAAS,eAAe,OAAO;AAAA,IAC/B,SAAS,eAAe,MAAM;AAAA,EAChC;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-scroll-bar.es.js","sources":["../../../../../src/modules/table/modules/table-scroll-bar.ts"],"sourcesContent":["import { SCROLL_BAR_PANEL_HEIGHT } from '../table-config'\nimport { css } from '../utils'\n\nexport default class TableScrollBar {\n table: any\n quill: any\n modulesContainer: any\n domNode: any\n oldRootScrollTop: any\n // @ts-ignore\n prev: number\n columnToolDomNode: any\n columnCtrlPanel: any\n leftMask: any\n tableViewRect: any\n tableRect: any\n containerRect: any\n subscriber: any\n // @ts-ignore\n tableMoveDistance: number\n // @ts-ignore\n maxBarLeft: number\n // @ts-ignore\n scrollBar: Element\n // @ts-ignore\n isTableOverflow: boolean // 表格是否溢出开关,判断开关值后只改变样式一次,不重复修改\n\n constructor(table, quill, dom) {\n if (!table) {\n return\n }\n this.table = table\n this.quill = quill\n this.modulesContainer = dom\n this.domNode = null\n this.oldRootScrollTop = this.quill.root.scrollTop\n this.prev = 0\n\n const betterTableModule = this.quill.getModule('better-table')\n const tableColumnTool = betterTableModule.columnTool\n this.columnToolDomNode = tableColumnTool.domNode\n this.columnCtrlPanel = tableColumnTool.columnCtrlPanel\n this.leftMask = tableColumnTool.leftMask\n\n this.updateScrollBar()\n\n if (this.quill.root === this.quill.scrollingContainer) {\n this.quill.root.addEventListener('scroll', this.handleQuillRootScroll.bind(this))\n }\n }\n\n handleQuillRootScroll() {\n if (!this.domNode) {\n return\n }\n const curTableRect = this.table.getBoundingClientRect()\n const curContainerRect = this.quill.root.parentNode.getBoundingClientRect()\n const tableTop = curTableRect.top + SCROLL_BAR_PANEL_HEIGHT\n const tableBottom = curTableRect.top + curTableRect.height - 1\n const containerBottom = curContainerRect.top + curContainerRect.height\n if (containerBottom < tableBottom && containerBottom > tableTop) { // 表格下端溢出容器下端\n if (!this.isTableOverflow) {\n this.isTableOverflow = true\n css(this.domNode, {\n display: 'block',\n top: `${this.containerRect.height - SCROLL_BAR_PANEL_HEIGHT}px`,\n marginTop: '0px',\n })\n }\n }\n else if (containerBottom <= tableTop) { // 表格上端溢出容器下端\n this.isTableOverflow = false\n this.domNode.style.display = 'none'\n }\n else { // 表格下端在容器内\n this.setScrollBarToBottom()\n css(this.domNode, { marginTop: `${this.oldRootScrollTop - this.quill.root.scrollTop}px` })\n }\n }\n\n setScrollBarToBottom() {\n if (this.isTableOverflow) {\n this.isTableOverflow = false\n const barPos = this.tableRect.top + this.tableRect.height - this.containerRect.top - 1\n css(this.domNode, { display: 'block', top: `${barPos}px` })\n }\n }\n\n resetTableHeight(table) {\n if (this.domNode) {\n // 表格的高度改变,重置初始化tableRect的高度,但不重置其他坐标值\n this.tableRect.height = table.getBoundingClientRect().height\n this.isTableOverflow = !this.isTableOverflow\n this.handleQuillRootScroll()\n }\n }\n\n setScrollBarMove(pos, isMouse) {\n // 获取当前滑块左边距和鼠标两次事件节点之间的位移差,计算当前滑块位置及是否显示左右遮罩层,通过比例计算表格位移并赋值\n const currentBarLeft = Number.parseInt(getComputedStyle(this.scrollBar).left, 10)\n let left = isMouse ? pos - this.prev + currentBarLeft : currentBarLeft + pos\n this.showMask(left)\n left = this.getLimitedDistance(left)\n const scale = this.tableViewRect.width / this.tableRect.width\n const move = left / scale\n const columnCtrlPanelLeft = this.tableViewRect.left - this.containerRect.left - move\n css(this.scrollBar, { left: `${left}px` }) // 移动表格滚动条\n css(this.columnCtrlPanel, { left: `${columnCtrlPanelLeft}px` }) // 移动顶部列宽控制条\n this.table.parentNode.scrollLeft = move // 移动表格\n if (isMouse) {\n this.prev = pos\n }\n\n // fix: 拖动滚动条时修正选区位置\n const tableSelection = this.quill.getModule('better-table').tableSelection\n if (tableSelection && tableSelection.selectedTds.length) {\n tableSelection.refreshHelpLinesPosition()\n }\n }\n\n handleScrollBarMouseDown(mouseDownEvent) {\n mouseDownEvent.preventDefault()\n\n this.prev = mouseDownEvent.clientX\n this.subscriber = (mouseMoveEvent: any) => {\n mouseMoveEvent.preventDefault()\n mouseMoveEvent.stopPropagation()\n this.setScrollBarMove(mouseMoveEvent.clientX, true)\n }\n this.quill.root.parentNode.addEventListener('mousemove', this.subscriber, false)\n document.addEventListener('mouseup', this.handleScrollBarMouseup.bind(this), false)\n }\n\n handleScrollBarMouseup(event) {\n event.preventDefault()\n this.quill.root.parentNode.removeEventListener('mousemove', this.subscriber)\n document.removeEventListener('mouseup', this.handleScrollBarMouseup.bind(this), false)\n }\n\n handleWheel(event) {\n // 按住 Shift 滚动鼠标滚轮,可以对表格进行横向滚动\n if (event.shiftKey) {\n const { deltaY } = event // 每次滚动鼠标滚轮移动的距离\n this.setScrollBarMove(deltaY, false)\n }\n }\n\n showMask(distance) {\n // 根据当前滑块左边距判断是否显示左右遮罩层\n if (distance >= Math.floor(this.maxBarLeft)) {\n css(this.leftMask, { display: 'block' })\n }\n else if (distance <= 0) {\n css(this.leftMask, { display: 'none' })\n }\n else {\n css(this.leftMask, { display: 'block' })\n }\n }\n\n getLimitedDistance(distance) {\n if (distance >= Math.floor(this.maxBarLeft)) {\n distance = this.maxBarLeft\n }\n else if (distance <= 0) {\n distance = 0\n }\n return distance\n }\n\n updateScrollBar() {\n if (!this.table?.parentNode) {\n return\n }\n // 获取表格尺寸和表格容器尺寸\n const tableRect = this.table.getBoundingClientRect()\n const tableViewRect = this.table.parentNode.getBoundingClientRect()\n const tableMoveDistance = tableRect.width - tableViewRect.width // 表格最大移动距离\n this.tableRect = tableRect\n this.tableViewRect = tableViewRect\n this.tableMoveDistance = tableMoveDistance\n this.oldRootScrollTop = this.quill.root.scrollTop\n\n if (tableMoveDistance > 0) {\n this.createScrollBar()\n }\n else {\n this.destroyScrollBar()\n }\n }\n\n createScrollBar() {\n // 列控制条增加表格相应位移\n const parent = this.quill.root.parentNode\n const containerRect = parent.getBoundingClientRect() // 编辑器容器宽度\n this.containerRect = containerRect\n css(this.columnCtrlPanel, {\n left: `${this.tableViewRect.left - containerRect.left - this.table.parentNode.scrollLeft}px`,\n })\n\n // 创建滚动条\n if (this.domNode) {\n this.domNode.remove()\n }\n this.domNode = document.createElement('div')\n this.domNode.classList.add('qlbt-table-scroll-bar-panel')\n this.scrollBar = document.createElement('div')\n this.scrollBar.classList.add('qlbt-table-scroll-bar')\n this.scrollBar.addEventListener('mousedown', this.handleScrollBarMouseDown.bind(this), false)\n const scale = this.tableViewRect.width / this.tableRect.width\n const barWidth = this.tableViewRect.width - this.tableMoveDistance * scale // 滑块宽度\n css(this.scrollBar, { width: `${barWidth}px` })\n this.domNode.appendChild(this.scrollBar)\n\n // 判断当前表格是否存在位移,如存在通过比例计算滑块当前位移并赋值\n const tableScrollLeft = this.table.parentNode.scrollLeft\n this.maxBarLeft = this.tableMoveDistance * scale // 滑块最大移动距离\n if (tableScrollLeft) {\n const barLeft = tableScrollLeft * scale\n this.showMask(barLeft)\n css(this.scrollBar, { left: `${this.getLimitedDistance(barLeft)}px` })\n }\n\n // 将滚动条插入到 table control panel 中\n const barPos = this.tableRect.top + this.tableRect.height - containerRect.top - 1\n this.isTableOverflow = containerRect.top + containerRect.height < this.tableRect.top + this.tableRect.height\n this.modulesContainer.appendChild(this.domNode)\n css(this.domNode, { top: `${Math.min(containerRect.height - SCROLL_BAR_PANEL_HEIGHT, barPos)}px` })\n\n // 绑定鼠标滚轮事件:Shift+鼠标滚轮,滚动表格横向滚动条\n document.addEventListener('wheel', this.handleWheel.bind(this))\n }\n\n destroyScrollBar() {\n css(this.leftMask, { display: 'none' })\n this.columnCtrlPanel.removeAttribute('style')\n this.maxBarLeft = null\n this.destroy()\n }\n\n destroy() {\n if (this.domNode) {\n this.domNode.remove()\n }\n this.quill.root.removeEventListener('scroll', this.handleQuillRootScroll.bind(this))\n document.removeEventListener('wheel', this.handleWheel.bind(this))\n }\n}\n"],"names":[],"mappings":";;AAGA,MAAqB,eAAe;AAAA;AAAA,EAwBlC,YAAY,OAAO,OAAO,KAAK;AAC7B,QAAI,CAAC,OAAO;AACV;AAAA,IAAA;AAEF,SAAK,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,mBAAmB;AACxB,SAAK,UAAU;AACV,SAAA,mBAAmB,KAAK,MAAM,KAAK;AACxC,SAAK,OAAO;AAEZ,UAAM,oBAAoB,KAAK,MAAM,UAAU,cAAc;AAC7D,UAAM,kBAAkB,kBAAkB;AAC1C,SAAK,oBAAoB,gBAAgB;AACzC,SAAK,kBAAkB,gBAAgB;AACvC,SAAK,WAAW,gBAAgB;AAEhC,SAAK,gBAAgB;AAErB,QAAI,KAAK,MAAM,SAAS,KAAK,MAAM,oBAAoB;AAChD,WAAA,MAAM,KAAK,iBAAiB,UAAU,KAAK,sBAAsB,KAAK,IAAI,CAAC;AAAA,IAAA;AAAA,EAClF;AAAA,EAGF,wBAAwB;AAClB,QAAA,CAAC,KAAK,SAAS;AACjB;AAAA,IAAA;AAEI,UAAA,eAAe,KAAK,MAAM,sBAAsB;AACtD,UAAM,mBAAmB,KAAK,MAAM,KAAK,WAAW,sBAAsB;AACpE,UAAA,WAAW,aAAa,MAAM;AACpC,UAAM,cAAc,aAAa,MAAM,aAAa,SAAS;AACvD,UAAA,kBAAkB,iBAAiB,MAAM,iBAAiB;AAC5D,QAAA,kBAAkB,eAAe,kBAAkB,UAAU;AAC3D,UAAA,CAAC,KAAK,iBAAiB;AACzB,aAAK,kBAAkB;AACvB,YAAI,KAAK,SAAS;AAAA,UAChB,SAAS;AAAA,UACT,KAAK,GAAG,KAAK,cAAc,SAAS,uBAAuB;AAAA,UAC3D,WAAW;A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U,kBAAkB;AAClC,WAAK,SAAS,OAAO;AACjB,UAAA,KAAK,WAAW,EAAE,MAAM,GAAG,KAAK,mBAAmB,OAAO,CAAC,KAAA,CAAM;AAAA,IAAA;AAIjE,UAAA,SAAS,KAAK,UAAU,MAAM,KAAK,UAAU,SAAS,cAAc,MAAM;AAC3E,SAAA,kBAAkB,cAAc,MAAM,cAAc,SAAS,KAAK,UAAU,MAAM,KAAK,UAAU;AACjG,SAAA,iBAAiB,YAAY,KAAK,OAAO;AAC9C,QAAI,KAAK,SAAS,EAAE,KAAK,GAAG,KAAK,IAAI,cAAc,SAAS,yBAAyB,MAAM,CAAC,MAAM;AAGlG,aAAS,iBAAiB,SAAS,KAAK,YAAY,KAAK,IAAI,CAAC;AAAA,EAAA;AAAA,EAGhE,mBAAmB;AACjB,QAAI,KAAK,UAAU,EAAE,SAAS,QAAQ;AACjC,SAAA,gBAAgB,gBAAgB,OAAO;AAC5C,SAAK,aAAa;AAClB,SAAK,QAAQ;AAAA,EAAA;AAAA,EAGf,UAAU;AACR,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,OAAO;AAAA,IAAA;AAEjB,SAAA,MAAM,KAAK,oBAAoB,UAAU,KAAK,sBAAsB,KAAK,IAAI,CAAC;AACnF,aAAS,oBAAoB,SAAS,KAAK,YAAY,KAAK,IAAI,CAAC;AAAA,EAAA;AAErE;"}
|
|
1
|
+
{"version":3,"file":"table-scroll-bar.es.js","sources":["../../../../../src/modules/table/modules/table-scroll-bar.ts"],"sourcesContent":["import { SCROLL_BAR_PANEL_HEIGHT } from '../table-config'\r\nimport { css } from '../utils'\r\n\r\nexport default class TableScrollBar {\r\n table: any\r\n quill: any\r\n modulesContainer: any\r\n domNode: any\r\n oldRootScrollTop: any\r\n // @ts-ignore\r\n prev: number\r\n columnToolDomNode: any\r\n columnCtrlPanel: any\r\n leftMask: any\r\n tableViewRect: any\r\n tableRect: any\r\n containerRect: any\r\n subscriber: any\r\n // @ts-ignore\r\n tableMoveDistance: number\r\n // @ts-ignore\r\n maxBarLeft: number\r\n // @ts-ignore\r\n scrollBar: Element\r\n // @ts-ignore\r\n isTableOverflow: boolean // 表格是否溢出开关,判断开关值后只改变样式一次,不重复修改\r\n\r\n constructor(table, quill, dom) {\r\n if (!table) {\r\n return\r\n }\r\n this.table = table\r\n this.quill = quill\r\n this.modulesContainer = dom\r\n this.domNode = null\r\n this.oldRootScrollTop = this.quill.root.scrollTop\r\n this.prev = 0\r\n\r\n const betterTableModule = this.quill.getModule('better-table')\r\n const tableColumnTool = betterTableModule.columnTool\r\n this.columnToolDomNode = tableColumnTool.domNode\r\n this.columnCtrlPanel = tableColumnTool.columnCtrlPanel\r\n this.leftMask = tableColumnTool.leftMask\r\n\r\n this.updateScrollBar()\r\n\r\n if (this.quill.root === this.quill.scrollingContainer) {\r\n this.quill.root.addEventListener('scroll', this.handleQuillRootScroll.bind(this))\r\n }\r\n }\r\n\r\n handleQuillRootScroll() {\r\n if (!this.domNode) {\r\n return\r\n }\r\n const curTableRect = this.table.getBoundingClientRect()\r\n const curContainerRect = this.quill.root.parentNode.getBoundingClientRect()\r\n const tableTop = curTableRect.top + SCROLL_BAR_PANEL_HEIGHT\r\n const tableBottom = curTableRect.top + curTableRect.height - 1\r\n const containerBottom = curContainerRect.top + curContainerRect.height\r\n if (containerBottom < tableBottom && containerBottom > tableTop) { // 表格下端溢出容器下端\r\n if (!this.isTableOverflow) {\r\n this.isTableOverflow = true\r\n css(this.domNode, {\r\n display: 'block',\r\n top: `${this.containerRect.height - SCROLL_BAR_PANEL_HEIGHT}px`,\r\n marginTop: '0px',\r\n })\r\n }\r\n }\r\n else if (containerBottom <= tableTop) { // 表格上端溢出容器下端\r\n this.isTableOverflow = false\r\n this.domNode.style.display = 'none'\r\n }\r\n else { // 表格下端在容器内\r\n this.setScrollBarToBottom()\r\n css(this.domNode, { marginTop: `${this.oldRootScrollTop - this.quill.root.scrollTop}px` })\r\n }\r\n }\r\n\r\n setScrollBarToBottom() {\r\n if (this.isTableOverflow) {\r\n this.isTableOverflow = false\r\n const barPos = this.tableRect.top + this.tableRect.height - this.containerRect.top - 1\r\n css(this.domNode, { display: 'block', top: `${barPos}px` })\r\n }\r\n }\r\n\r\n resetTableHeight(table) {\r\n if (this.domNode) {\r\n // 表格的高度改变,重置初始化tableRect的高度,但不重置其他坐标值\r\n this.tableRect.height = table.getBoundingClientRect().height\r\n this.isTableOverflow = !this.isTableOverflow\r\n this.handleQuillRootScroll()\r\n }\r\n }\r\n\r\n setScrollBarMove(pos, isMouse) {\r\n // 获取当前滑块左边距和鼠标两次事件节点之间的位移差,计算当前滑块位置及是否显示左右遮罩层,通过比例计算表格位移并赋值\r\n const currentBarLeft = Number.parseInt(getComputedStyle(this.scrollBar).left, 10)\r\n let left = isMouse ? pos - this.prev + currentBarLeft : currentBarLeft + pos\r\n this.showMask(left)\r\n left = this.getLimitedDistance(left)\r\n const scale = this.tableViewRect.width / this.tableRect.width\r\n const move = left / scale\r\n const columnCtrlPanelLeft = this.tableViewRect.left - this.containerRect.left - move\r\n css(this.scrollBar, { left: `${left}px` }) // 移动表格滚动条\r\n css(this.columnCtrlPanel, { left: `${columnCtrlPanelLeft}px` }) // 移动顶部列宽控制条\r\n this.table.parentNode.scrollLeft = move // 移动表格\r\n if (isMouse) {\r\n this.prev = pos\r\n }\r\n\r\n // fix: 拖动滚动条时修正选区位置\r\n const tableSelection = this.quill.getModule('better-table').tableSelection\r\n if (tableSelection && tableSelection.selectedTds.length) {\r\n tableSelection.refreshHelpLinesPosition()\r\n }\r\n }\r\n\r\n handleScrollBarMouseDown(mouseDownEvent) {\r\n mouseDownEvent.preventDefault()\r\n\r\n this.prev = mouseDownEvent.clientX\r\n this.subscriber = (mouseMoveEvent: any) => {\r\n mouseMoveEvent.preventDefault()\r\n mouseMoveEvent.stopPropagation()\r\n this.setScrollBarMove(mouseMoveEvent.clientX, true)\r\n }\r\n this.quill.root.parentNode.addEventListener('mousemove', this.subscriber, false)\r\n document.addEventListener('mouseup', this.handleScrollBarMouseup.bind(this), false)\r\n }\r\n\r\n handleScrollBarMouseup(event) {\r\n event.preventDefault()\r\n this.quill.root.parentNode.removeEventListener('mousemove', this.subscriber)\r\n document.removeEventListener('mouseup', this.handleScrollBarMouseup.bind(this), false)\r\n }\r\n\r\n handleWheel(event) {\r\n // 按住 Shift 滚动鼠标滚轮,可以对表格进行横向滚动\r\n if (event.shiftKey) {\r\n const { deltaY } = event // 每次滚动鼠标滚轮移动的距离\r\n this.setScrollBarMove(deltaY, false)\r\n }\r\n }\r\n\r\n showMask(distance) {\r\n // 根据当前滑块左边距判断是否显示左右遮罩层\r\n if (distance >= Math.floor(this.maxBarLeft)) {\r\n css(this.leftMask, { display: 'block' })\r\n }\r\n else if (distance <= 0) {\r\n css(this.leftMask, { display: 'none' })\r\n }\r\n else {\r\n css(this.leftMask, { display: 'block' })\r\n }\r\n }\r\n\r\n getLimitedDistance(distance) {\r\n if (distance >= Math.floor(this.maxBarLeft)) {\r\n distance = this.maxBarLeft\r\n }\r\n else if (distance <= 0) {\r\n distance = 0\r\n }\r\n return distance\r\n }\r\n\r\n updateScrollBar() {\r\n if (!this.table?.parentNode) {\r\n return\r\n }\r\n // 获取表格尺寸和表格容器尺寸\r\n const tableRect = this.table.getBoundingClientRect()\r\n const tableViewRect = this.table.parentNode.getBoundingClientRect()\r\n const tableMoveDistance = tableRect.width - tableViewRect.width // 表格最大移动距离\r\n this.tableRect = tableRect\r\n this.tableViewRect = tableViewRect\r\n this.tableMoveDistance = tableMoveDistance\r\n this.oldRootScrollTop = this.quill.root.scrollTop\r\n\r\n if (tableMoveDistance > 0) {\r\n this.createScrollBar()\r\n }\r\n else {\r\n this.destroyScrollBar()\r\n }\r\n }\r\n\r\n createScrollBar() {\r\n // 列控制条增加表格相应位移\r\n const parent = this.quill.root.parentNode\r\n const containerRect = parent.getBoundingClientRect() // 编辑器容器宽度\r\n this.containerRect = containerRect\r\n css(this.columnCtrlPanel, {\r\n left: `${this.tableViewRect.left - containerRect.left - this.table.parentNode.scrollLeft}px`,\r\n })\r\n\r\n // 创建滚动条\r\n if (this.domNode) {\r\n this.domNode.remove()\r\n }\r\n this.domNode = document.createElement('div')\r\n this.domNode.classList.add('qlbt-table-scroll-bar-panel')\r\n this.scrollBar = document.createElement('div')\r\n this.scrollBar.classList.add('qlbt-table-scroll-bar')\r\n this.scrollBar.addEventListener('mousedown', this.handleScrollBarMouseDown.bind(this), false)\r\n const scale = this.tableViewRect.width / this.tableRect.width\r\n const barWidth = this.tableViewRect.width - this.tableMoveDistance * scale // 滑块宽度\r\n css(this.scrollBar, { width: `${barWidth}px` })\r\n this.domNode.appendChild(this.scrollBar)\r\n\r\n // 判断当前表格是否存在位移,如存在通过比例计算滑块当前位移并赋值\r\n const tableScrollLeft = this.table.parentNode.scrollLeft\r\n this.maxBarLeft = this.tableMoveDistance * scale // 滑块最大移动距离\r\n if (tableScrollLeft) {\r\n const barLeft = tableScrollLeft * scale\r\n this.showMask(barLeft)\r\n css(this.scrollBar, { left: `${this.getLimitedDistance(barLeft)}px` })\r\n }\r\n\r\n // 将滚动条插入到 table control panel 中\r\n const barPos = this.tableRect.top + this.tableRect.height - containerRect.top - 1\r\n this.isTableOverflow = containerRect.top + containerRect.height < this.tableRect.top + this.tableRect.height\r\n this.modulesContainer.appendChild(this.domNode)\r\n css(this.domNode, { top: `${Math.min(containerRect.height - SCROLL_BAR_PANEL_HEIGHT, barPos)}px` })\r\n\r\n // 绑定鼠标滚轮事件:Shift+鼠标滚轮,滚动表格横向滚动条\r\n document.addEventListener('wheel', this.handleWheel.bind(this))\r\n }\r\n\r\n destroyScrollBar() {\r\n css(this.leftMask, { display: 'none' })\r\n this.columnCtrlPanel.removeAttribute('style')\r\n this.maxBarLeft = null\r\n this.destroy()\r\n }\r\n\r\n destroy() {\r\n if (this.domNode) {\r\n this.domNode.remove()\r\n }\r\n this.quill.root.removeEventListener('scroll', this.handleQuillRootScroll.bind(this))\r\n document.removeEventListener('wheel', this.handleWheel.bind(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AAK,UAAU,MAAM,KAAK,UAAU,SAAS,cAAc,MAAM;AAC3E,SAAA,kBAAkB,cAAc,MAAM,cAAc,SAAS,KAAK,UAAU,MAAM,KAAK,UAAU;AACjG,SAAA,iBAAiB,YAAY,KAAK,OAAO;AAC9C,QAAI,KAAK,SAAS,EAAE,KAAK,GAAG,KAAK,IAAI,cAAc,SAAS,yBAAyB,MAAM,CAAC,MAAM;AAGlG,aAAS,iBAAiB,SAAS,KAAK,YAAY,KAAK,IAAI,CAAC;AAAA,EAAA;AAAA,EAGhE,mBAAmB;AACjB,QAAI,KAAK,UAAU,EAAE,SAAS,QAAQ;AACjC,SAAA,gBAAgB,gBAAgB,OAAO;AAC5C,SAAK,aAAa;AAClB,SAAK,QAAQ;AAAA,EAAA;AAAA,EAGf,UAAU;AACR,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,OAAO;AAAA,IAAA;AAEjB,SAAA,MAAM,KAAK,oBAAoB,UAAU,KAAK,sBAAsB,KAAK,IAAI,CAAC;AACnF,aAAS,oBAAoB,SAAS,KAAK,YAAY,KAAK,IAAI,CAAC;AAAA,EAAA;AAErE;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-selection.es.js","sources":["../../../../../src/modules/table/modules/table-selection.ts"],"sourcesContent":["import Quill from 'quill'\nimport { TableCell } from '../formats/table'\nimport { ERROR_LIMIT, LINE_POSITIONS, PRIMARY_COLOR } from '../table-config'\nimport { css, getRelativeRect } from '../utils'\n\nexport default class TableSelection {\n table: any\n quill: any\n modulesContainer: any\n parent: any\n boundary: any\n // @ts-ignore\n selectedTds: any[]\n // @ts-ignore\n dragging: boolean\n preSelectedTable: any\n oldRootScrollTop: any\n selectingHandler: any\n tdEditHandler: any\n tdResizeHandler: any\n endTd: any\n startTd: any\n editTd: any\n left: any\n bottom: any\n top: any\n right: any\n\n constructor(table, quill, dom) {\n if (!table) {\n return null\n }\n this.table = table\n this.quill = quill\n this.modulesContainer = dom\n this.parent = this.quill.root.parentNode\n this.boundary = {} // params for selected square\n this.selectedTds = [] // array for selected table-cells\n this.dragging = false\n this.preSelectedTable = null\n this.oldRootScrollTop = this.quill.root.scrollTop\n\n this.selectingHandler = this.mouseDownHandler.bind(this)\n\n this.tdEditHandler = this.setTdEditable.bind(this)\n this.tdResizeHandler = this.resizeTd.bind(this)\n\n this.helpLinesInitial()\n this.isEditorHasScrollBar()\n\n this.quill.root.parentNode.addEventListener('mousedown', this.selectingHandler, false)\n this.quill.on('text-change', this.tdResizeHandler)\n if (this.quill.root === this.quill.scrollingContainer) {\n this.quill.root.addEventListener('scroll', this.handleQuillRootScroll.bind(this))\n }\n }\n\n handleQuillRootScroll() {\n LINE_POSITIONS.forEach((direction) => {\n const selectionLine = this[direction]\n if (selectionLine) {\n selectionLine.style.marginTop = `${this.oldRootScrollTop - this.quill.root.scrollTop}px`\n }\n })\n }\n\n isEditorHasScrollBar() {\n if (this.quill.root.scrollHeight > this.quill.root.clientHeight) {\n css(this.modulesContainer, { width: 'calc(100% - 23px)' })\n }\n else {\n this.modulesContainer.removeAttribute('style')\n }\n }\n\n helpLinesInitial() {\n LINE_POSITIONS.forEach((direction) => {\n this[direction] = document.createElement('div')\n this[direction].classList.add('qlbt-selection-line')\n if (direction === 'left') {\n this[direction].classList.add('qlbt-selection-line-first')\n const ctrlPointLeft = document.createElement('div')\n this[direction].appendChild(ctrlPointLeft)\n }\n if (direction === 'bottom') {\n this[direction].classList.add('qlbt-selection-line-last')\n const ctrlPointRight = document.createElement('div')\n this[direction].appendChild(ctrlPointRight)\n }\n css(this[direction], {\n 'position': 'absolute',\n 'display': 'none',\n 'background-color': PRIMARY_COLOR,\n })\n this.modulesContainer.appendChild(this[direction])\n })\n }\n\n mouseDownHandler(e) {\n if (e.button !== 0) {\n return\n }\n const self: any = this\n const betterTableModule = this.quill.getModule('better-table')\n const tableColumnTool = betterTableModule.columnTool\n if (tableColumnTool.activeToolCell) {\n tableColumnTool.activeToolCell.classList.remove('qlbt-tool-cell-on')\n tableColumnTool.activeToolCell = null\n }\n if (e.target.closest('.quill-better-table')) {\n if (e.shiftKey) {\n this.endTd = e.target.closest('td[data-row]')\n this.drawSelection(this, true)\n // avoid select text in multiple table-cell\n if (this.startTd !== this.endTd) {\n this.quill.blur()\n }\n }\n else {\n this.startTd = e.target.closest('td[data-row]')\n this.drawSelection(this, false)\n this.dragging = true\n\n this.parent.addEventListener('mousemove', mouseMoveHandler, false)\n document.addEventListener('mouseup', mouseUpHandler, false)\n }\n }\n else if (e.target.closest('.qlbt-selection-line')) {\n this.parent.addEventListener('mousemove', mouseMoveHandler, false)\n document.addEventListener('mouseup', mouseUpHandler, false)\n }\n\n function mouseMoveHandler(event) {\n event.stopPropagation()\n\n if (event.button !== 0 || !event.target.closest('.quill-better-table')) {\n return\n }\n self.endTd = event.target.closest('td[data-row]')\n if (!self.endTd) {\n return\n }\n self.drawSelection(self, true)\n // avoid select text in multiple table-cell\n if (self.startTd !== self.endTd) {\n self.quill.blur()\n }\n }\n\n function mouseUpHandler() {\n self.parent.removeEventListener('mousemove', mouseMoveHandler, false)\n document.removeEventListener('mouseup', mouseUpHandler, false)\n self.dragging = false\n }\n }\n\n drawSelection(self, end) {\n // fix: 如果滚动条拖动,startTd的位置已经改变了,需要重置startTdRect\n self.startTdRect = getRelativeRect(self.startTd.getBoundingClientRect(), self.quill.root.parentNode)\n let endTdRect = self.startTdRect\n if (end) {\n self.endTdRect = getRelativeRect(self.endTd.getBoundingClientRect(), self.quill.root.parentNode)\n endTdRect = self.endTdRect\n }\n self.boundary = computeBoundaryFromRects(self.startTdRect, endTdRect)\n self.selectedTds = self.computeSelectedTds()\n self.repositionHelpLines()\n }\n\n setTdEditable(e) {\n if (!this.editTd) {\n return\n }\n this.parent.removeEventListener('keypress', this.tdEditHandler, false)\n const dom = this.editTd.domNode\n dom.removeEventListener('click', this.tdEditHandler, false)\n dom.classList.add('editing-select-able')\n dom.setAttribute('contenteditable', true)\n if (e.type === 'keypress') {\n if (dom.childNodes.length > 1 || dom.firstChild.innerHTML !== '<br>') {\n const blank = dom.firstChild.cloneNode()\n blank.innerHTML = '<br>'\n dom.innerHTML = ''\n dom.appendChild(blank)\n }\n dom.focus()\n }\n }\n\n resizeTd() {\n if (!this.editTd || (this.left && !this.left.offsetParent)) {\n return\n }\n if (this.selectedTds.length > 1) {\n this.refreshHelpLinesPosition()\n }\n else {\n const dom = this.editTd.domNode\n const domRect = getRelativeRect(dom.getBoundingClientRect(), this.quill.root.parentNode)\n this.boundary = computeBoundaryFromRects(domRect, domRect)\n this.repositionHelpLines()\n }\n\n // 判断编辑器是否有滚动条,调整遮罩宽度\n this.isEditorHasScrollBar()\n\n // 更新行高 更新滑块位置\n const betterTableModule = this.quill.getModule('better-table')\n const tableColumnTool = betterTableModule.columnTool\n if (tableColumnTool) {\n tableColumnTool.updateRowToolCells()\n const tableViewRect = this.table.parentNode.getBoundingClientRect()\n if (tableColumnTool.leftMask) {\n css(tableColumnTool.leftMask, { height: `${tableViewRect.height + 50}px` })\n }\n }\n\n const tableScrollBar = betterTableModule.tableScrollBar\n tableScrollBar.resetTableHeight(this.table)\n }\n\n resetTd(e) {\n const dom = e.target\n dom.classList.remove('editing-select-able')\n dom.setAttribute('contenteditable', false)\n dom.removeAttribute('contenteditable')\n }\n\n correctBoundary() {\n const tableContainer = Quill.find(this.table)\n const tableCells = tableContainer.descendants(TableCell)\n\n tableCells.forEach((tableCell) => {\n const { x, y, width, height } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode)\n const isCellIntersected\n = ((x + ERROR_LIMIT >= this.boundary.x && x + ERROR_LIMIT <= this.boundary.x1)\n || (x - ERROR_LIMIT + width >= this.boundary.x && x - ERROR_LIMIT + width <= this.boundary.x1))\n && ((y + ERROR_LIMIT >= this.boundary.y && y + ERROR_LIMIT <= this.boundary.y1)\n || (y - ERROR_LIMIT + height >= this.boundary.y && y - ERROR_LIMIT + height <= this.boundary.y1))\n if (isCellIntersected) {\n this.boundary = computeBoundaryFromRects(this.boundary, { x, y, width, height })\n }\n })\n }\n\n computeSelectedTds() {\n const tableContainer = Quill.find(this.table)\n const tableCells = tableContainer.descendants(TableCell)\n\n const result = tableCells.reduce((selectedCells, tableCell) => {\n const { x, y, width, height } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode)\n const isCellIncluded\n = x + ERROR_LIMIT >= this.boundary.x\n && x - ERROR_LIMIT + width <= this.boundary.x1\n && y + ERROR_LIMIT >= this.boundary.y\n && y - ERROR_LIMIT + height <= this.boundary.y1\n\n if (isCellIncluded) {\n selectedCells.push(tableCell)\n }\n\n return selectedCells\n }, [])\n\n if (result.length === 1 && this.editTd !== result[0]) {\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\n resetTds.forEach(td => this.resetTd({ target: td }))\n this.editTd = result[0]\n this.editTd.domNode.addEventListener('mousedown', this.tdEditHandler, false)\n this.parent.addEventListener('keypress', this.tdEditHandler, false)\n }\n\n return result\n }\n\n repositionHelpLines() {\n this.oldRootScrollTop = this.quill.root.scrollTop\n if (!this.left) {\n return\n }\n\n css(this.left, {\n 'display': 'block',\n 'left': `${this.boundary.x - 1}px`,\n 'top': `${this.boundary.y}px`,\n 'height': `${this.boundary.height + 1}px`,\n 'width': '1px',\n 'margin-top': '0px',\n })\n\n css(this.right, {\n 'display': 'block',\n 'left': `${this.boundary.x1}px`,\n 'top': `${this.boundary.y - 1}px`,\n 'height': `${this.boundary.height + 1}px`,\n 'width': '1px',\n 'margin-top': '0px',\n })\n\n css(this.top, {\n 'display': 'block',\n 'left': `${this.boundary.x - 1}px`,\n 'top': `${this.boundary.y - 1}px`,\n 'width': `${this.boundary.width + 1}px`,\n 'height': '1px',\n 'margin-top': '0px',\n })\n\n css(this.bottom, {\n 'display': 'block',\n 'left': `${this.boundary.x - 1}px`,\n 'top': `${this.boundary.y1}px`,\n 'width': `${this.boundary.width + 1}px`,\n 'height': '1px',\n 'margin-top': '0px',\n })\n }\n\n // based on selectedTds compute positions of help lines\n // It is useful when selectedTds are not changed\n refreshHelpLinesPosition() {\n const startRect = getRelativeRect(this.selectedTds[0].domNode.getBoundingClientRect(), this.quill.root.parentNode)\n const endRect = getRelativeRect(\n this.selectedTds[this.selectedTds.length - 1].domNode.getBoundingClientRect(),\n this.quill.root.parentNode,\n )\n this.boundary = computeBoundaryFromRects(startRect, endRect)\n this.repositionHelpLines()\n }\n\n destroy() {\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\n resetTds.forEach(td => this.resetTd({ target: td }))\n\n LINE_POSITIONS.forEach((direction) => {\n if (this[direction]) {\n this[direction].remove()\n this[direction] = null\n }\n })\n\n this.quill.root.parentNode.removeEventListener('mousedown', this.selectingHandler, false)\n\n delete this.editTd\n\n return null\n }\n\n setSelection(startRect, endRect) {\n this.boundary = computeBoundaryFromRects(\n getRelativeRect(startRect, this.quill.root.parentNode),\n getRelativeRect(endRect, this.quill.root.parentNode),\n )\n this.correctBoundary()\n this.selectedTds = this.computeSelectedTds()\n this.repositionHelpLines()\n }\n\n clearSelection() {\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\n resetTds.forEach(td => this.resetTd({ target: td }))\n this.boundary = {}\n this.selectedTds = []\n LINE_POSITIONS.forEach((direction) => {\n if (this[direction]) {\n css(this[direction], {\n display: 'none',\n })\n }\n })\n }\n}\n\nfunction computeBoundaryFromRects(startRect, endRect) {\n const x = Math.min(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1)\n\n const x1 = Math.max(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1)\n\n const y = Math.min(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1)\n\n const y1 = Math.max(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1)\n\n const width = x1 - x\n const height = y1 - y\n\n return { x, x1, y, y1, width, height }\n}\n"],"names":[],"mappings":";;;;AAKA,MAAqB,eAAe;AAAA,EAuBlC,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QAAQ,CAAC,cAAc;AAChC,UAAA,KAAK,SAAS,GAAG;AACf,YAAA,KAAK,SAAS,GAAG;AAAA,UACnB,SAAS;AAAA,QAAA,CACV;AAAA,MAAA;AAAA,IACH,CACD;AAAA,EAAA;AAEL;AAEA,SAAS,yBAAyB,WAAW,SAAS;AACpD,QAAM,IAAI,KAAK,IAAI,UAAU,GAAG,QAAQ,GAAG,UAAU,IAAI,UAAU,QAAQ,GAAG,QAAQ,IAAI,QAAQ,QAAQ,CAAC;AAE3G,QAAM,KAAK,KAAK,IAAI,UAAU,GAAG,QAAQ,GAAG,UAAU,IAAI,UAAU,QAAQ,GAAG,QAAQ,IAAI,QAAQ,QAAQ,CAAC;AAE5G,QAAM,IAAI,KAAK,IAAI,UAAU,GAAG,QAAQ,GAAG,UAAU,IAAI,UAAU,SAAS,GAAG,QAAQ,IAAI,QAAQ,SAAS,CAAC;AAE7G,QAAM,KAAK,KAAK,IAAI,UAAU,GAAG,QAAQ,GAAG,UAAU,IAAI,UAAU,SAAS,GAAG,QAAQ,IAAI,QAAQ,SAAS,CAAC;AAE9G,QAAM,QAAQ,KAAK;AACnB,QAAM,SAAS,KAAK;AAEpB,SAAO,EAAE,GAAG,IAAI,GAAG,IAAI,OAAO,OAAO;AACvC;"}
|
|
1
|
+
{"version":3,"file":"table-selection.es.js","sources":["../../../../../src/modules/table/modules/table-selection.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport { TableCell } from '../formats/table'\r\nimport { ERROR_LIMIT, LINE_POSITIONS, PRIMARY_COLOR } from '../table-config'\r\nimport { css, getRelativeRect } from '../utils'\r\n\r\nexport default class TableSelection {\r\n table: any\r\n quill: any\r\n modulesContainer: any\r\n parent: any\r\n boundary: any\r\n // @ts-ignore\r\n selectedTds: any[]\r\n // @ts-ignore\r\n dragging: boolean\r\n preSelectedTable: any\r\n oldRootScrollTop: any\r\n selectingHandler: any\r\n tdEditHandler: any\r\n tdResizeHandler: any\r\n endTd: any\r\n startTd: any\r\n editTd: any\r\n left: any\r\n bottom: any\r\n top: any\r\n right: any\r\n\r\n constructor(table, quill, dom) {\r\n if (!table) {\r\n return null\r\n }\r\n this.table = table\r\n this.quill = quill\r\n this.modulesContainer = dom\r\n this.parent = this.quill.root.parentNode\r\n this.boundary = {} // params for selected square\r\n this.selectedTds = [] // array for selected table-cells\r\n this.dragging = false\r\n this.preSelectedTable = null\r\n this.oldRootScrollTop = this.quill.root.scrollTop\r\n\r\n this.selectingHandler = this.mouseDownHandler.bind(this)\r\n\r\n this.tdEditHandler = this.setTdEditable.bind(this)\r\n this.tdResizeHandler = this.resizeTd.bind(this)\r\n\r\n this.helpLinesInitial()\r\n this.isEditorHasScrollBar()\r\n\r\n this.quill.root.parentNode.addEventListener('mousedown', this.selectingHandler, false)\r\n this.quill.on('text-change', this.tdResizeHandler)\r\n if (this.quill.root === this.quill.scrollingContainer) {\r\n this.quill.root.addEventListener('scroll', this.handleQuillRootScroll.bind(this))\r\n }\r\n }\r\n\r\n handleQuillRootScroll() {\r\n LINE_POSITIONS.forEach((direction) => {\r\n const selectionLine = this[direction]\r\n if (selectionLine) {\r\n selectionLine.style.marginTop = `${this.oldRootScrollTop - this.quill.root.scrollTop}px`\r\n }\r\n })\r\n }\r\n\r\n isEditorHasScrollBar() {\r\n if (this.quill.root.scrollHeight > this.quill.root.clientHeight) {\r\n css(this.modulesContainer, { width: 'calc(100% - 23px)' })\r\n }\r\n else {\r\n this.modulesContainer.removeAttribute('style')\r\n }\r\n }\r\n\r\n helpLinesInitial() {\r\n LINE_POSITIONS.forEach((direction) => {\r\n this[direction] = document.createElement('div')\r\n this[direction].classList.add('qlbt-selection-line')\r\n if (direction === 'left') {\r\n this[direction].classList.add('qlbt-selection-line-first')\r\n const ctrlPointLeft = document.createElement('div')\r\n this[direction].appendChild(ctrlPointLeft)\r\n }\r\n if (direction === 'bottom') {\r\n this[direction].classList.add('qlbt-selection-line-last')\r\n const ctrlPointRight = document.createElement('div')\r\n this[direction].appendChild(ctrlPointRight)\r\n }\r\n css(this[direction], {\r\n 'position': 'absolute',\r\n 'display': 'none',\r\n 'background-color': PRIMARY_COLOR,\r\n })\r\n this.modulesContainer.appendChild(this[direction])\r\n })\r\n }\r\n\r\n mouseDownHandler(e) {\r\n if (e.button !== 0) {\r\n return\r\n }\r\n const self: any = this\r\n const betterTableModule = this.quill.getModule('better-table')\r\n const tableColumnTool = betterTableModule.columnTool\r\n if (tableColumnTool.activeToolCell) {\r\n tableColumnTool.activeToolCell.classList.remove('qlbt-tool-cell-on')\r\n tableColumnTool.activeToolCell = null\r\n }\r\n if (e.target.closest('.quill-better-table')) {\r\n if (e.shiftKey) {\r\n this.endTd = e.target.closest('td[data-row]')\r\n this.drawSelection(this, true)\r\n // avoid select text in multiple table-cell\r\n if (this.startTd !== this.endTd) {\r\n this.quill.blur()\r\n }\r\n }\r\n else {\r\n this.startTd = e.target.closest('td[data-row]')\r\n this.drawSelection(this, false)\r\n this.dragging = true\r\n\r\n this.parent.addEventListener('mousemove', mouseMoveHandler, false)\r\n document.addEventListener('mouseup', mouseUpHandler, false)\r\n }\r\n }\r\n else if (e.target.closest('.qlbt-selection-line')) {\r\n this.parent.addEventListener('mousemove', mouseMoveHandler, false)\r\n document.addEventListener('mouseup', mouseUpHandler, false)\r\n }\r\n\r\n function mouseMoveHandler(event) {\r\n event.stopPropagation()\r\n\r\n if (event.button !== 0 || !event.target.closest('.quill-better-table')) {\r\n return\r\n }\r\n self.endTd = event.target.closest('td[data-row]')\r\n if (!self.endTd) {\r\n return\r\n }\r\n self.drawSelection(self, true)\r\n // avoid select text in multiple table-cell\r\n if (self.startTd !== self.endTd) {\r\n self.quill.blur()\r\n }\r\n }\r\n\r\n function mouseUpHandler() {\r\n self.parent.removeEventListener('mousemove', mouseMoveHandler, false)\r\n document.removeEventListener('mouseup', mouseUpHandler, false)\r\n self.dragging = false\r\n }\r\n }\r\n\r\n drawSelection(self, end) {\r\n // fix: 如果滚动条拖动,startTd的位置已经改变了,需要重置startTdRect\r\n self.startTdRect = getRelativeRect(self.startTd.getBoundingClientRect(), self.quill.root.parentNode)\r\n let endTdRect = self.startTdRect\r\n if (end) {\r\n self.endTdRect = getRelativeRect(self.endTd.getBoundingClientRect(), self.quill.root.parentNode)\r\n endTdRect = self.endTdRect\r\n }\r\n self.boundary = computeBoundaryFromRects(self.startTdRect, endTdRect)\r\n self.selectedTds = self.computeSelectedTds()\r\n self.repositionHelpLines()\r\n }\r\n\r\n setTdEditable(e) {\r\n if (!this.editTd) {\r\n return\r\n }\r\n this.parent.removeEventListener('keypress', this.tdEditHandler, false)\r\n const dom = this.editTd.domNode\r\n dom.removeEventListener('click', this.tdEditHandler, false)\r\n dom.classList.add('editing-select-able')\r\n dom.setAttribute('contenteditable', true)\r\n if (e.type === 'keypress') {\r\n if (dom.childNodes.length > 1 || dom.firstChild.innerHTML !== '<br>') {\r\n const blank = dom.firstChild.cloneNode()\r\n blank.innerHTML = '<br>'\r\n dom.innerHTML = ''\r\n dom.appendChild(blank)\r\n }\r\n dom.focus()\r\n }\r\n }\r\n\r\n resizeTd() {\r\n if (!this.editTd || (this.left && !this.left.offsetParent)) {\r\n return\r\n }\r\n if (this.selectedTds.length > 1) {\r\n this.refreshHelpLinesPosition()\r\n }\r\n else {\r\n const dom = this.editTd.domNode\r\n const domRect = getRelativeRect(dom.getBoundingClientRect(), this.quill.root.parentNode)\r\n this.boundary = computeBoundaryFromRects(domRect, domRect)\r\n this.repositionHelpLines()\r\n }\r\n\r\n // 判断编辑器是否有滚动条,调整遮罩宽度\r\n this.isEditorHasScrollBar()\r\n\r\n // 更新行高 更新滑块位置\r\n const betterTableModule = this.quill.getModule('better-table')\r\n const tableColumnTool = betterTableModule.columnTool\r\n if (tableColumnTool) {\r\n tableColumnTool.updateRowToolCells()\r\n const tableViewRect = this.table.parentNode.getBoundingClientRect()\r\n if (tableColumnTool.leftMask) {\r\n css(tableColumnTool.leftMask, { height: `${tableViewRect.height + 50}px` })\r\n }\r\n }\r\n\r\n const tableScrollBar = betterTableModule.tableScrollBar\r\n tableScrollBar.resetTableHeight(this.table)\r\n }\r\n\r\n resetTd(e) {\r\n const dom = e.target\r\n dom.classList.remove('editing-select-able')\r\n dom.setAttribute('contenteditable', false)\r\n dom.removeAttribute('contenteditable')\r\n }\r\n\r\n correctBoundary() {\r\n const tableContainer = Quill.find(this.table)\r\n const tableCells = tableContainer.descendants(TableCell)\r\n\r\n tableCells.forEach((tableCell) => {\r\n const { x, y, width, height } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode)\r\n const isCellIntersected\r\n = ((x + ERROR_LIMIT >= this.boundary.x && x + ERROR_LIMIT <= this.boundary.x1)\r\n || (x - ERROR_LIMIT + width >= this.boundary.x && x - ERROR_LIMIT + width <= this.boundary.x1))\r\n && ((y + ERROR_LIMIT >= this.boundary.y && y + ERROR_LIMIT <= this.boundary.y1)\r\n || (y - ERROR_LIMIT + height >= this.boundary.y && y - ERROR_LIMIT + height <= this.boundary.y1))\r\n if (isCellIntersected) {\r\n this.boundary = computeBoundaryFromRects(this.boundary, { x, y, width, height })\r\n }\r\n })\r\n }\r\n\r\n computeSelectedTds() {\r\n const tableContainer = Quill.find(this.table)\r\n const tableCells = tableContainer.descendants(TableCell)\r\n\r\n const result = tableCells.reduce((selectedCells, tableCell) => {\r\n const { x, y, width, height } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode)\r\n const isCellIncluded\r\n = x + ERROR_LIMIT >= this.boundary.x\r\n && x - ERROR_LIMIT + width <= this.boundary.x1\r\n && y + ERROR_LIMIT >= this.boundary.y\r\n && y - ERROR_LIMIT + height <= this.boundary.y1\r\n\r\n if (isCellIncluded) {\r\n selectedCells.push(tableCell)\r\n }\r\n\r\n return selectedCells\r\n }, [])\r\n\r\n if (result.length === 1 && this.editTd !== result[0]) {\r\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\r\n resetTds.forEach(td => this.resetTd({ target: td }))\r\n this.editTd = result[0]\r\n this.editTd.domNode.addEventListener('mousedown', this.tdEditHandler, false)\r\n this.parent.addEventListener('keypress', this.tdEditHandler, false)\r\n }\r\n\r\n return result\r\n }\r\n\r\n repositionHelpLines() {\r\n this.oldRootScrollTop = this.quill.root.scrollTop\r\n if (!this.left) {\r\n return\r\n }\r\n\r\n css(this.left, {\r\n 'display': 'block',\r\n 'left': `${this.boundary.x - 1}px`,\r\n 'top': `${this.boundary.y}px`,\r\n 'height': `${this.boundary.height + 1}px`,\r\n 'width': '1px',\r\n 'margin-top': '0px',\r\n })\r\n\r\n css(this.right, {\r\n 'display': 'block',\r\n 'left': `${this.boundary.x1}px`,\r\n 'top': `${this.boundary.y - 1}px`,\r\n 'height': `${this.boundary.height + 1}px`,\r\n 'width': '1px',\r\n 'margin-top': '0px',\r\n })\r\n\r\n css(this.top, {\r\n 'display': 'block',\r\n 'left': `${this.boundary.x - 1}px`,\r\n 'top': `${this.boundary.y - 1}px`,\r\n 'width': `${this.boundary.width + 1}px`,\r\n 'height': '1px',\r\n 'margin-top': '0px',\r\n })\r\n\r\n css(this.bottom, {\r\n 'display': 'block',\r\n 'left': `${this.boundary.x - 1}px`,\r\n 'top': `${this.boundary.y1}px`,\r\n 'width': `${this.boundary.width + 1}px`,\r\n 'height': '1px',\r\n 'margin-top': '0px',\r\n })\r\n }\r\n\r\n // based on selectedTds compute positions of help lines\r\n // It is useful when selectedTds are not changed\r\n refreshHelpLinesPosition() {\r\n const startRect = getRelativeRect(this.selectedTds[0].domNode.getBoundingClientRect(), this.quill.root.parentNode)\r\n const endRect = getRelativeRect(\r\n this.selectedTds[this.selectedTds.length - 1].domNode.getBoundingClientRect(),\r\n this.quill.root.parentNode,\r\n )\r\n this.boundary = computeBoundaryFromRects(startRect, endRect)\r\n this.repositionHelpLines()\r\n }\r\n\r\n destroy() {\r\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\r\n resetTds.forEach(td => this.resetTd({ target: td }))\r\n\r\n LINE_POSITIONS.forEach((direction) => {\r\n if (this[direction]) {\r\n this[direction].remove()\r\n this[direction] = null\r\n }\r\n })\r\n\r\n this.quill.root.parentNode.removeEventListener('mousedown', this.selectingHandler, false)\r\n\r\n delete this.editTd\r\n\r\n return null\r\n }\r\n\r\n setSelection(startRect, endRect) {\r\n this.boundary = computeBoundaryFromRects(\r\n getRelativeRect(startRect, this.quill.root.parentNode),\r\n getRelativeRect(endRect, this.quill.root.parentNode),\r\n )\r\n this.correctBoundary()\r\n this.selectedTds = this.computeSelectedTds()\r\n this.repositionHelpLines()\r\n }\r\n\r\n clearSelection() {\r\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\r\n resetTds.forEach(td => this.resetTd({ target: td }))\r\n this.boundary = {}\r\n this.selectedTds = []\r\n LINE_POSITIONS.forEach((direction) => {\r\n if (this[direction]) {\r\n css(this[direction], {\r\n display: 'none',\r\n })\r\n }\r\n })\r\n }\r\n}\r\n\r\nfunction computeBoundaryFromRects(startRect, endRect) {\r\n const x = Math.min(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1)\r\n\r\n const x1 = Math.max(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1)\r\n\r\n const y = Math.min(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1)\r\n\r\n const y1 = Math.max(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1)\r\n\r\n const width = x1 - x\r\n const height = y1 - y\r\n\r\n return { x, x1, y, y1, width, height }\r\n}\r\n"],"names":[],"mappings":";;;;AAKA,MAAqB,eAAe;AAAA,EAuBlC,YAAY,OAAO,OAAO,KAAK;AAC7B,QAAI,CAAC,OAAO;AACH,aAAA;AAAA,IAAA;AAET,SAAK,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,mBAAmB;AACnB,SAAA,SAAS,KAAK,MAAM,KAAK;AAC9B,SAAK,WAAW,CAAC;AACjB,SAAK,cAAc,CAAC;AACpB,SAAK,WAAW;AAChB,SA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,GAAG,UAAU,IAAI,UAAU,QAAQ,GAAG,QAAQ,IAAI,QAAQ,QAAQ,CAAC;AAE3G,QAAM,KAAK,KAAK,IAAI,UAAU,GAAG,QAAQ,GAAG,UAAU,IAAI,UAAU,QAAQ,GAAG,QAAQ,IAAI,QAAQ,QAAQ,CAAC;AAE5G,QAAM,IAAI,KAAK,IAAI,UAAU,GAAG,QAAQ,GAAG,UAAU,IAAI,UAAU,SAAS,GAAG,QAAQ,IAAI,QAAQ,SAAS,CAAC;AAE7G,QAAM,KAAK,KAAK,IAAI,UAAU,GAAG,QAAQ,GAAG,UAAU,IAAI,UAAU,SAAS,GAAG,QAAQ,IAAI,QAAQ,SAAS,CAAC;AAE9G,QAAM,QAAQ,KAAK;AACnB,QAAM,SAAS,KAAK;AAEpB,SAAO,EAAE,GAAG,IAAI,GAAG,IAAI,OAAO,OAAO;AACvC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-selector.es.js","sources":["../../../../../src/modules/table/modules/table-selector.ts"],"sourcesContent":["import { css } from '../utils'\n\n// 配置\nconst GRID_SIZE = {\n ROWS: 10,\n COLS: 10,\n CELL_SIZE: 15,\n}\n\nconst STYLES = {\n container: {\n 'position': 'absolute',\n 'z-index': '1000',\n 'background': 'white',\n 'border': '1px solid #ccc',\n 'padding': '5px',\n 'box-shadow': '0 2px 8px rgba(0,0,0,0.1)',\n },\n grid: {\n 'display': 'grid',\n 'grid-template-columns': `repeat(${GRID_SIZE.COLS}, ${GRID_SIZE.CELL_SIZE - 1}px)`,\n 'grid-template-rows': `repeat(${GRID_SIZE.ROWS}, ${GRID_SIZE.CELL_SIZE - 1}px)`,\n 'gap': '0px',\n },\n row: {\n display: 'contents',\n },\n cell: {\n 'width': `${GRID_SIZE.CELL_SIZE}px`,\n 'height': `${GRID_SIZE.CELL_SIZE}px`,\n 'border': '1px solid #ddd',\n 'background-color': '#fff',\n 'box-sizing': 'border-box',\n },\n label: {\n 'text-align': 'center',\n 'margin-top': '5px',\n 'font-size': '12px',\n 'color': '#666',\n },\n}\n\nfunction createCell(\n row: number,\n col: number,\n handleMouseOver: (row: number, col: number) => void,\n handleClick: () => void,\n): { cellDiv: HTMLDivElement, removeListeners: () => void } {\n const cellDiv = document.createElement('div')\n cellDiv.className = 'cell'\n css(cellDiv, STYLES.cell)\n\n const mouseOverListener = () => handleMouseOver(row + 1, col + 1)\n const clickListener = () => handleClick()\n\n cellDiv.addEventListener('mouseover', mouseOverListener)\n cellDiv.addEventListener('click', clickListener)\n\n const removeListeners = () => {\n cellDiv.removeEventListener('mouseover', mouseOverListener)\n cellDiv.removeEventListener('click', clickListener)\n }\n\n return { cellDiv, removeListeners }\n}\n\nfunction createRow(\n rowIndex: number,\n handleMouseOver: (row: number, col: number) => void,\n handleClick: () => void,\n): { rowDiv: HTMLDivElement, removeListeners: () => void } {\n const rowDiv = document.createElement('div')\n rowDiv.className = 'row'\n css(rowDiv, STYLES.row)\n\n const fragment = document.createDocumentFragment()\n const removeListenersArray: (() => void)[] = []\n\n for (let col = 0; col < GRID_SIZE.COLS; col++) {\n const { cellDiv, removeListeners } = createCell(rowIndex, col, handleMouseOver, handleClick)\n fragment.appendChild(cellDiv)\n removeListenersArray.push(removeListeners)\n }\n\n rowDiv.appendChild(fragment)\n\n const removeListeners = () => {\n removeListenersArray.forEach(remove => remove())\n }\n\n return { rowDiv, removeListeners }\n}\n\nclass TableSelector {\n private onSelect: (rows: number, cols: number) => void\n container: HTMLDivElement\n private grid: HTMLDivElement\n private label: HTMLDivElement\n private rows: number = 0\n private cols: number = 0\n private removeListenersArray: (() => void)[] = []\n\n constructor({ onSelect }: { onSelect: (rows: number, cols: number) => void }) {\n this.onSelect = onSelect\n this.initContainer()\n this.initGrid()\n this.initLabel()\n }\n\n // init table-selector container\n private initContainer() {\n this.container = document.createElement('div')\n this.container.className = 'table-selector'\n css(this.container, STYLES.container)\n }\n\n // init grid\n private initGrid() {\n this.grid = document.createElement('div')\n this.grid.className = 'grid'\n css(this.grid, STYLES.grid)\n\n const fragment = document.createDocumentFragment()\n\n for (let row = 0; row < GRID_SIZE.ROWS; row++) {\n const { rowDiv, removeListeners } = createRow(\n row,\n this.handleMouseOver.bind(this),\n this.handleClick.bind(this),\n )\n fragment.appendChild(rowDiv)\n this.removeListenersArray.push(removeListeners)\n }\n this.grid.appendChild(fragment)\n this.container.appendChild(this.grid)\n }\n\n // init label\n private initLabel() {\n this.label = document.createElement('div')\n this.label.className = 'label'\n css(this.label, STYLES.label)\n this.container.appendChild(this.label)\n }\n\n private handleMouseOver(row: number, col: number) {\n this.rows = row\n this.cols = col\n this.updateGrid()\n }\n\n private handleClick() {\n this.onSelect(this.rows, this.cols)\n this.hide()\n }\n\n updateGrid() {\n const cells = this.grid.getElementsByClassName('cell')\n for (let i = 0; i < cells.length; i++) {\n const cell = cells[i] as HTMLElement\n const row = Math.floor(i / GRID_SIZE.COLS)\n const col = i % GRID_SIZE.COLS\n css(cell, {\n 'background-color': row < this.rows && col < this.cols ? '#e6f3ff' : '#fff',\n })\n }\n this.label.textContent = `${this.rows} x ${this.cols}`\n }\n\n show(x: number, y: number) {\n css(this.container, {\n 'left': `${x}px`,\n 'top': `${y}px`,\n 'display': 'block',\n 'margin-top': '1px',\n })\n }\n\n hide() {\n css(this.container, { display: 'none' })\n }\n\n destroy() {\n this.removeListenersArray.forEach(remove => remove())\n this.removeListenersArray = []\n\n this.hide()\n if (this.container.parentNode) {\n this.container.parentNode.removeChild(this.container)\n }\n this.rows = 0\n this.cols = 0\n return null\n }\n}\n\nexport default TableSelector\n"],"names":["removeListeners"],"mappings":";AAGA,MAAM,YAAY;AAAA,EAChB,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AACb;AAEA,MAAM,SAAS;AAAA,EACb,WAAW;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,cAAc;AAAA,IACd,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,MAAM;A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AAChD,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAAA;AAAA,EAGV,cAAc;AACpB,SAAK,SAAS,KAAK,MAAM,KAAK,IAAI;AAClC,SAAK,KAAK;AAAA,EAAA;AAAA,EAGZ,aAAa;AACX,UAAM,QAAQ,KAAK,KAAK,uBAAuB,MAAM;AACrD,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAC/B,YAAA,OAAO,MAAM,CAAC;AACpB,YAAM,MAAM,KAAK,MAAM,IAAI,UAAU,IAAI;AACnC,YAAA,MAAM,IAAI,UAAU;AAC1B,UAAI,MAAM;AAAA,QACR,oBAAoB,MAAM,KAAK,QAAQ,MAAM,KAAK,OAAO,YAAY;AAAA,MAAA,CACtE;AAAA,IAAA;AAEH,SAAK,MAAM,cAAc,GAAG,KAAK,IAAI,MAAM,KAAK,IAAI;AAAA,EAAA;AAAA,EAGtD,KAAK,GAAW,GAAW;AACzB,QAAI,KAAK,WAAW;AAAA,MAClB,QAAQ,GAAG,CAAC;AAAA,MACZ,OAAO,GAAG,CAAC;AAAA,MACX,WAAW;AAAA,MACX,cAAc;AAAA,IAAA,CACf;AAAA,EAAA;AAAA,EAGH,OAAO;AACL,QAAI,KAAK,WAAW,EAAE,SAAS,QAAQ;AAAA,EAAA;AAAA,EAGzC,UAAU;AACR,SAAK,qBAAqB,QAAQ,CAAU,WAAA,OAAA,CAAQ;AACpD,SAAK,uBAAuB,CAAC;AAE7B,SAAK,KAAK;AACN,QAAA,KAAK,UAAU,YAAY;AAC7B,WAAK,UAAU,WAAW,YAAY,KAAK,SAAS;AAAA,IAAA;AAEtD,SAAK,OAAO;AACZ,SAAK,OAAO;AACL,WAAA;AAAA,EAAA;AAEX;"}
|
|
1
|
+
{"version":3,"file":"table-selector.es.js","sources":["../../../../../src/modules/table/modules/table-selector.ts"],"sourcesContent":["import { css } from '../utils'\r\n\r\n// 配置\r\nconst GRID_SIZE = {\r\n ROWS: 10,\r\n COLS: 10,\r\n CELL_SIZE: 15,\r\n}\r\n\r\nconst STYLES = {\r\n container: {\r\n 'position': 'absolute',\r\n 'z-index': '1000',\r\n 'background': 'white',\r\n 'border': '1px solid #ccc',\r\n 'padding': '5px',\r\n 'box-shadow': '0 2px 8px rgba(0,0,0,0.1)',\r\n },\r\n grid: {\r\n 'display': 'grid',\r\n 'grid-template-columns': `repeat(${GRID_SIZE.COLS}, ${GRID_SIZE.CELL_SIZE - 1}px)`,\r\n 'grid-template-rows': `repeat(${GRID_SIZE.ROWS}, ${GRID_SIZE.CELL_SIZE - 1}px)`,\r\n 'gap': '0px',\r\n },\r\n row: {\r\n display: 'contents',\r\n },\r\n cell: {\r\n 'width': `${GRID_SIZE.CELL_SIZE}px`,\r\n 'height': `${GRID_SIZE.CELL_SIZE}px`,\r\n 'border': '1px solid #ddd',\r\n 'background-color': '#fff',\r\n 'box-sizing': 'border-box',\r\n },\r\n label: {\r\n 'text-align': 'center',\r\n 'margin-top': '5px',\r\n 'font-size': '12px',\r\n 'color': '#666',\r\n },\r\n}\r\n\r\nfunction createCell(\r\n row: number,\r\n col: number,\r\n handleMouseOver: (row: number, col: number) => void,\r\n handleClick: () => void,\r\n): { cellDiv: HTMLDivElement, removeListeners: () => void } {\r\n const cellDiv = document.createElement('div')\r\n cellDiv.className = 'cell'\r\n css(cellDiv, STYLES.cell)\r\n\r\n const mouseOverListener = () => handleMouseOver(row + 1, col + 1)\r\n const clickListener = () => handleClick()\r\n\r\n cellDiv.addEventListener('mouseover', mouseOverListener)\r\n cellDiv.addEventListener('click', clickListener)\r\n\r\n const removeListeners = () => {\r\n cellDiv.removeEventListener('mouseover', mouseOverListener)\r\n cellDiv.removeEventListener('click', clickListener)\r\n }\r\n\r\n return { cellDiv, removeListeners }\r\n}\r\n\r\nfunction createRow(\r\n rowIndex: number,\r\n handleMouseOver: (row: number, col: number) => void,\r\n handleClick: () => void,\r\n): { rowDiv: HTMLDivElement, removeListeners: () => void } {\r\n const rowDiv = document.createElement('div')\r\n rowDiv.className = 'row'\r\n css(rowDiv, STYLES.row)\r\n\r\n const fragment = document.createDocumentFragment()\r\n const removeListenersArray: (() => void)[] = []\r\n\r\n for (let col = 0; col < GRID_SIZE.COLS; col++) {\r\n const { cellDiv, removeListeners } = createCell(rowIndex, col, handleMouseOver, handleClick)\r\n fragment.appendChild(cellDiv)\r\n removeListenersArray.push(removeListeners)\r\n }\r\n\r\n rowDiv.appendChild(fragment)\r\n\r\n const removeListeners = () => {\r\n removeListenersArray.forEach(remove => remove())\r\n }\r\n\r\n return { rowDiv, removeListeners }\r\n}\r\n\r\nclass TableSelector {\r\n private onSelect: (rows: number, cols: number) => void\r\n container: HTMLDivElement\r\n private grid: HTMLDivElement\r\n private label: HTMLDivElement\r\n private rows: number = 0\r\n private cols: number = 0\r\n private removeListenersArray: (() => void)[] = []\r\n\r\n constructor({ onSelect }: { onSelect: (rows: number, cols: number) => void }) {\r\n this.onSelect = onSelect\r\n this.initContainer()\r\n this.initGrid()\r\n this.initLabel()\r\n }\r\n\r\n // init table-selector container\r\n private initContainer() {\r\n this.container = document.createElement('div')\r\n this.container.className = 'table-selector'\r\n css(this.container, STYLES.container)\r\n }\r\n\r\n // init grid\r\n private initGrid() {\r\n this.grid = document.createElement('div')\r\n this.grid.className = 'grid'\r\n css(this.grid, STYLES.grid)\r\n\r\n const fragment = document.createDocumentFragment()\r\n\r\n for (let row = 0; row < GRID_SIZE.ROWS; row++) {\r\n const { rowDiv, removeListeners } = createRow(\r\n row,\r\n this.handleMouseOver.bind(this),\r\n this.handleClick.bind(this),\r\n )\r\n fragment.appendChild(rowDiv)\r\n this.removeListenersArray.push(removeListeners)\r\n }\r\n this.grid.appendChild(fragment)\r\n this.container.appendChild(this.grid)\r\n }\r\n\r\n // init label\r\n private initLabel() {\r\n this.label = document.createElement('div')\r\n this.label.className = 'label'\r\n css(this.label, STYLES.label)\r\n this.container.appendChild(this.label)\r\n }\r\n\r\n private handleMouseOver(row: number, col: number) {\r\n this.rows = row\r\n this.cols = col\r\n this.updateGrid()\r\n }\r\n\r\n private handleClick() {\r\n this.onSelect(this.rows, this.cols)\r\n this.hide()\r\n }\r\n\r\n updateGrid() {\r\n const cells = this.grid.getElementsByClassName('cell')\r\n for (let i = 0; i < cells.length; i++) {\r\n const cell = cells[i] as HTMLElement\r\n const row = Math.floor(i / GRID_SIZE.COLS)\r\n const col = i % GRID_SIZE.COLS\r\n css(cell, {\r\n 'background-color': row < this.rows && col < this.cols ? '#e6f3ff' : '#fff',\r\n })\r\n }\r\n this.label.textContent = `${this.rows} x ${this.cols}`\r\n }\r\n\r\n show(x: number, y: number) {\r\n css(this.container, {\r\n 'left': `${x}px`,\r\n 'top': `${y}px`,\r\n 'display': 'block',\r\n 'margin-top': '1px',\r\n })\r\n }\r\n\r\n hide() {\r\n css(this.container, { display: 'none' })\r\n }\r\n\r\n destroy() {\r\n this.removeListenersArray.forEach(remove => remove())\r\n this.removeListenersArray = []\r\n\r\n this.hide()\r\n if (this.container.parentNode) {\r\n this.container.parentNode.removeChild(this.container)\r\n }\r\n this.rows = 0\r\n this.cols = 0\r\n return null\r\n }\r\n}\r\n\r\nexport default TableSelector\r\n"],"names":["removeListeners"],"mappings":";AAGA,MAAM,YAAY;AAAA,EAChB,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AACb;AAEA,MAAM,SAAS;AAAA,EACb,WAAW;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,cAAc;AAAA,IACd,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,MAAM;AAAA,IACJ,WAAW;AAAA,IACX,yBAAyB,UAAU,UAAU,IAAI,KAAK,UAAU,YAAY,CAAC;AAAA,IAC7E,sBAAsB,UAAU,UAAU,IAAI,KAAK,UAAU,YAAY,CAAC;AAAA,IAC1E,OAAO;AAAA,EACT;AAAA,EACA,KAAK;AAAA,IACH,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACJ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,IAAI,MAAM,QAAQ,KAAK;AAC/B,YAAA,OAAO,MAAM,CAAC;AACpB,YAAM,MAAM,KAAK,MAAM,IAAI,UAAU,IAAI;AACnC,YAAA,MAAM,IAAI,UAAU;AAC1B,UAAI,MAAM;AAAA,QACR,oBAAoB,MAAM,KAAK,QAAQ,MAAM,KAAK,OAAO,YAAY;AAAA,MAAA,CACtE;AAAA,IAAA;AAEH,SAAK,MAAM,cAAc,GAAG,KAAK,IAAI,MAAM,KAAK,IAAI;AAAA,EAAA;AAAA,EAGtD,KAAK,GAAW,GAAW;AACzB,QAAI,KAAK,WAAW;AAAA,MAClB,QAAQ,GAAG,CAAC;AAAA,MACZ,OAAO,GAAG,CAAC;AAAA,MACX,WAAW;AAAA,MACX,cAAc;AAAA,IAAA,CACf;AAAA,EAAA;AAAA,EAGH,OAAO;AACL,QAAI,KAAK,WAAW,EAAE,SAAS,QAAQ;AAAA,EAAA;AAAA,EAGzC,UAAU;AACR,SAAK,qBAAqB,QAAQ,CAAU,WAAA,OAAA,CAAQ;AACpD,SAAK,uBAAuB,CAAC;AAE7B,SAAK,KAAK;AACN,QAAA,KAAK,UAAU,YAAY;AAC7B,WAAK,UAAU,WAAW,YAAY,KAAK,SAAS;AAAA,IAAA;AAEtD,SAAK,OAAO;AACZ,SAAK,OAAO;AACL,WAAA;AAAA,EAAA;AAEX;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-config.es.js","sources":["../../../../src/modules/table/table-config.ts"],"sourcesContent":["export const TABLE_CELL_LINE_CLASS = 'qlrte__better-table-cell-line'\nexport const ROW_TOOL_CLASS = 'qlrte__row-tool'\nexport const ROW_TOOL_CELL_CLASS = 'qlrte__row-tool-cell'\nexport const ROW_TOOL_CELL_HOLDER_CLASS = 'qlrte__row-tool-cell-holder'\nexport const COL_TOOL_CLASS = 'qlrte__col-tool'\nexport const COL_TOOL_CELL_CLASS = 'qlrte__col-tool-cell'\nexport const COL_TOOL_CELL_HOLDER_CLASS = 'qlrte__col-tool-cell-holder'\nexport const SELECT_LINE_CLASS = 'qlrte__selection-line'\nexport const OPERATE_MENU_CLASS = 'qlrte__op-menu'\nexport const OPERATE_MENU_ITEM_CLASS = 'qlrte__op-menu-item'\nexport const OPERATE_MENU_ICON_CLASS = 'qlrte__op-menu-icon'\nexport const OPERATE_MENU_ICON_PREFIX_CLASS = 'qlrte__op-menu-icon-prefix'\nexport const OPERATE_MENU_TEXT_CLASS = 'qlrte__op-menu-text'\nexport const OPERATE_MENU_DIVIDING_CLASS = 'qlrte__op-menu-dividing'\nexport const OPERATE_MENU_SUBTITLE_CLASS = 'qlrte__op-menu-subtitle'\nexport const OPERATE_MENU_COLORPICKER_CLASS = 'qlrte__op-menu-color-picker'\nexport const OPERATE_MENU_COLORPICKER_ITEM_CLASS\n = 'qlrte__op-menu-color-picker-item'\nexport const COL_ATTRIBUTES = ['width']\nexport const COL_DEFAULT = {\n width: 100,\n}\nexport const CELL_IDENTITY_KEYS = ['row', 'cell']\nexport const CELL_ATTRIBUTES = ['rowspan', 'colspan', 'cell-bg', 'list']\nexport const CELL_DEFAULT = {\n rowspan: 1,\n colspan: 1,\n}\nexport const ERROR_LIMIT = 5\n\nexport const SCROLL_BAR_PANEL_HEIGHT = 32\nexport const ROW_TOOL_WIDTH = 16\nexport const COL_TOOL_HEIGHT = 16\nexport const CELL_MIN_WIDTH = 50\nexport const CELL_MIN_HEIGHT = 29\nexport const PRIMARY_COLOR = ['#5170ff', 'var(--brand-1, #5170ff)']\n\nexport const MENU_ITEM_HEIGHT = 40\nexport const MENU_MIN_HEIGHT = 150\nexport const MENU_WIDTH = 205\n\nexport const LINE_POSITIONS = ['left', 'right', 'top', 'bottom']\n"],"names":[],"mappings":"AAAO,MAAM,wBAAwB;AAC9B,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,6BAA6B;AACnC,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,6BAA6B;AACnC,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,0BAA0B;AAChC,MAAM,0BAA0B;AAChC,MAAM,iCAAiC;AACvC,MAAM,0BAA0B;AAChC,MAAM,8BAA8B;AACpC,MAAM,8BAA8B;AACpC,MAAM,iCAAiC;AACvC,MAAM,sCACT;AACS,MAAA,iBAAiB,CAAC,OAAO;AAC/B,MAAM,cAAc;AAAA,EACzB,OAAO;AACT;AACa,MAAA,qBAAqB,CAAC,OAAO,MAAM;AACzC,MAAM,kBAAkB,CAAC,WAAW,WAAW,WAAW,MAAM;AAChE,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,SAAS;AACX;AACO,MAAM,cAAc;AAEpB,MAAM,0BAA0B;AAChC,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAClB,MAAA,gBAAgB,CAAC,WAAW,yBAAyB;AAE3D,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AACxB,MAAM,aAAa;AAEnB,MAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO,QAAQ;"}
|
|
1
|
+
{"version":3,"file":"table-config.es.js","sources":["../../../../src/modules/table/table-config.ts"],"sourcesContent":["export const TABLE_CELL_LINE_CLASS = 'qlrte__better-table-cell-line'\r\nexport const ROW_TOOL_CLASS = 'qlrte__row-tool'\r\nexport const ROW_TOOL_CELL_CLASS = 'qlrte__row-tool-cell'\r\nexport const ROW_TOOL_CELL_HOLDER_CLASS = 'qlrte__row-tool-cell-holder'\r\nexport const COL_TOOL_CLASS = 'qlrte__col-tool'\r\nexport const COL_TOOL_CELL_CLASS = 'qlrte__col-tool-cell'\r\nexport const COL_TOOL_CELL_HOLDER_CLASS = 'qlrte__col-tool-cell-holder'\r\nexport const SELECT_LINE_CLASS = 'qlrte__selection-line'\r\nexport const OPERATE_MENU_CLASS = 'qlrte__op-menu'\r\nexport const OPERATE_MENU_ITEM_CLASS = 'qlrte__op-menu-item'\r\nexport const OPERATE_MENU_ICON_CLASS = 'qlrte__op-menu-icon'\r\nexport const OPERATE_MENU_ICON_PREFIX_CLASS = 'qlrte__op-menu-icon-prefix'\r\nexport const OPERATE_MENU_TEXT_CLASS = 'qlrte__op-menu-text'\r\nexport const OPERATE_MENU_DIVIDING_CLASS = 'qlrte__op-menu-dividing'\r\nexport const OPERATE_MENU_SUBTITLE_CLASS = 'qlrte__op-menu-subtitle'\r\nexport const OPERATE_MENU_COLORPICKER_CLASS = 'qlrte__op-menu-color-picker'\r\nexport const OPERATE_MENU_COLORPICKER_ITEM_CLASS\r\n = 'qlrte__op-menu-color-picker-item'\r\nexport const COL_ATTRIBUTES = ['width']\r\nexport const COL_DEFAULT = {\r\n width: 100,\r\n}\r\nexport const CELL_IDENTITY_KEYS = ['row', 'cell']\r\nexport const CELL_ATTRIBUTES = ['rowspan', 'colspan', 'cell-bg', 'list']\r\nexport const CELL_DEFAULT = {\r\n rowspan: 1,\r\n colspan: 1,\r\n}\r\nexport const ERROR_LIMIT = 5\r\n\r\nexport const SCROLL_BAR_PANEL_HEIGHT = 32\r\nexport const ROW_TOOL_WIDTH = 16\r\nexport const COL_TOOL_HEIGHT = 16\r\nexport const CELL_MIN_WIDTH = 50\r\nexport const CELL_MIN_HEIGHT = 29\r\nexport const PRIMARY_COLOR = ['#5170ff', 'var(--brand-1, #5170ff)']\r\n\r\nexport const MENU_ITEM_HEIGHT = 40\r\nexport const MENU_MIN_HEIGHT = 150\r\nexport const MENU_WIDTH = 205\r\n\r\nexport const LINE_POSITIONS = ['left', 'right', 'top', 'bottom']\r\n"],"names":[],"mappings":"AAAO,MAAM,wBAAwB;AAC9B,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,6BAA6B;AACnC,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,6BAA6B;AACnC,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,0BAA0B;AAChC,MAAM,0BAA0B;AAChC,MAAM,iCAAiC;AACvC,MAAM,0BAA0B;AAChC,MAAM,8BAA8B;AACpC,MAAM,8BAA8B;AACpC,MAAM,iCAAiC;AACvC,MAAM,sCACT;AACS,MAAA,iBAAiB,CAAC,OAAO;AAC/B,MAAM,cAAc;AAAA,EACzB,OAAO;AACT;AACa,MAAA,qBAAqB,CAAC,OAAO,MAAM;AACzC,MAAM,kBAAkB,CAAC,WAAW,WAAW,WAAW,MAAM;AAChE,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,SAAS;AACX;AACO,MAAM,cAAc;AAEpB,MAAM,0BAA0B;AAChC,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAClB,MAAA,gBAAgB,CAAC,WAAW,yBAAyB;AAE3D,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AACxB,MAAM,aAAa;AAEnB,MAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO,QAAQ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../../../src/modules/table/utils/index.ts"],"sourcesContent":["export function css(domNode, rules) {\n if (typeof rules === 'object') {\n for (const prop in rules) {\n if (prop) {\n if (Array.isArray(rules[prop])) {\n // 兼容IE11浏览器\n rules[prop].forEach((val) => {\n domNode.style[prop] = val\n })\n }\n else {\n domNode.style[prop] = rules[prop]\n }\n }\n }\n }\n}\n\n/**\n * getRelativeRect\n * @param targetRect rect data for target element {Object}\n * @param container container element {Element}\n * @return an object with rect data {Object}\n */\nexport function getRelativeRect(targetRect, container) {\n const containerRect = container.getBoundingClientRect()\n\n return { // ie浏览器中getBoundingClientRect输出为left、right、top、bottom,与chrome的x、y不同\n x: (targetRect.x || targetRect.left) - (containerRect.x || containerRect.left) - container.scrollLeft,\n y: (targetRect.y || targetRect.top) - (containerRect.y || containerRect.top) - container.scrollTop,\n x1: (targetRect.x || targetRect.left) - (containerRect.x || containerRect.left) - container.scrollLeft + targetRect.width,\n y1: (targetRect.y || targetRect.top) - (containerRect.y || containerRect.top) - container.scrollTop + targetRect.height,\n width: targetRect.width,\n height: targetRect.height,\n }\n}\n\nexport const elementRemove = function (node) {\n node && node.parentNode && node.parentNode.removeChild(node)\n}\n\nexport const arrayFrom = function (arrayLike, mapFn?, thisArg?) {\n if (!arrayLike) {\n throw new TypeError(\n 'Array.from requires an array-like object - not null or undefined',\n )\n }\n\n const length = arrayLike.length\n const resArray = []\n\n for (let i = 0; i < length; i++) {\n if (typeof mapFn === 'function') {\n resArray.push(mapFn.call(thisArg, arrayLike[i]))\n }\n else {\n resArray.push(arrayLike[i])\n }\n }\n\n return resArray\n}\n"],"names":[],"mappings":"AAAgB,SAAA,IAAI,SAAS,OAAO;AAC9B,MAAA,OAAO,UAAU,UAAU;AAC7B,eAAW,QAAQ,OAAO;AACxB,UAAI,MAAM;AACR,YAAI,MAAM,QAAQ,MAAM,IAAI,CAAC,GAAG;AAE9B,gBAAM,IAAI,EAAE,QAAQ,CAAC,QAAQ;AACnB,oBAAA,MAAM,IAAI,IAAI;AAAA,UAAA,CACvB;AAAA,QAAA,OAEE;AACH,kBAAQ,MAAM,IAAI,IAAI,MAAM,IAAI;AAAA,QAAA;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAEJ;AAQgB,SAAA,gBAAgB,YAAY,WAAW;AAC/C,QAAA,gBAAgB,UAAU,sBAAsB;AAE/C,SAAA;AAAA;AAAA,IACL,IAAI,WAAW,KAAK,WAAW,SAAS,cAAc,KAAK,cAAc,QAAQ,UAAU;AAAA,IAC3F,IAAI,WAAW,KAAK,WAAW,QAAQ,cAAc,KAAK,cAAc,OAAO,UAAU;AAAA,IACzF,KAAK,WAAW,KAAK,WAAW,SAAS,cAAc,KAAK,cAAc,QAAQ,UAAU,aAAa,WAAW;AAAA,IACpH,KAAK,WAAW,KAAK,WAAW,QAAQ,cAAc,KAAK,cAAc,OAAO,UAAU,YAAY,WAAW;AAAA,IACjH,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW;AAAA,EACrB;AACF;AAEa,MAAA,gBAAgB,SAAU,MAAM;AAC3C,UAAQ,KAAK,cAAc,KAAK,WAAW,YAAY,IAAI;AAC7D;AAEO,MAAM,YAAY,SAAU,WAAW,OAAQ,SAAU;AAC9D,MAAI,CAAC,WAAW;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,SAAS,UAAU;AACzB,QAAM,WAAW,CAAC;AAElB,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC3B,QAAA,OAAO,UAAU,YAAY;AAC/B,eAAS,KAAK,MAAM,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC;AAAA,IAAA,OAE5C;AACM,eAAA,KAAK,UAAU,CAAC,CAAC;AAAA,IAAA;AAAA,EAC5B;AAGK,SAAA;AACT;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../../src/modules/table/utils/index.ts"],"sourcesContent":["export function css(domNode, rules) {\r\n if (typeof rules === 'object') {\r\n for (const prop in rules) {\r\n if (prop) {\r\n if (Array.isArray(rules[prop])) {\r\n // 兼容IE11浏览器\r\n rules[prop].forEach((val) => {\r\n domNode.style[prop] = val\r\n })\r\n }\r\n else {\r\n domNode.style[prop] = rules[prop]\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * getRelativeRect\r\n * @param targetRect rect data for target element {Object}\r\n * @param container container element {Element}\r\n * @return an object with rect data {Object}\r\n */\r\nexport function getRelativeRect(targetRect, container) {\r\n const containerRect = container.getBoundingClientRect()\r\n\r\n return { // ie浏览器中getBoundingClientRect输出为left、right、top、bottom,与chrome的x、y不同\r\n x: (targetRect.x || targetRect.left) - (containerRect.x || containerRect.left) - container.scrollLeft,\r\n y: (targetRect.y || targetRect.top) - (containerRect.y || containerRect.top) - container.scrollTop,\r\n x1: (targetRect.x || targetRect.left) - (containerRect.x || containerRect.left) - container.scrollLeft + targetRect.width,\r\n y1: (targetRect.y || targetRect.top) - (containerRect.y || containerRect.top) - container.scrollTop + targetRect.height,\r\n width: targetRect.width,\r\n height: targetRect.height,\r\n }\r\n}\r\n\r\nexport const elementRemove = function (node) {\r\n node && node.parentNode && node.parentNode.removeChild(node)\r\n}\r\n\r\nexport const arrayFrom = function (arrayLike, mapFn?, thisArg?) {\r\n if (!arrayLike) {\r\n throw new TypeError(\r\n 'Array.from requires an array-like object - not null or undefined',\r\n )\r\n }\r\n\r\n const length = arrayLike.length\r\n const resArray = []\r\n\r\n for (let i = 0; i < length; i++) {\r\n if (typeof mapFn === 'function') {\r\n resArray.push(mapFn.call(thisArg, arrayLike[i]))\r\n }\r\n else {\r\n resArray.push(arrayLike[i])\r\n }\r\n }\r\n\r\n return resArray\r\n}\r\n"],"names":[],"mappings":"AAAgB,SAAA,IAAI,SAAS,OAAO;AAC9B,MAAA,OAAO,UAAU,UAAU;AAC7B,eAAW,QAAQ,OAAO;AACxB,UAAI,MAAM;AACR,YAAI,MAAM,QAAQ,MAAM,IAAI,CAAC,GAAG;AAE9B,gBAAM,IAAI,EAAE,QAAQ,CAAC,QAAQ;AACnB,oBAAA,MAAM,IAAI,IAAI;AAAA,UAAA,CACvB;AAAA,QAAA,OAEE;AACH,kBAAQ,MAAM,IAAI,IAAI,MAAM,IAAI;AAAA,QAAA;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAEJ;AAQgB,SAAA,gBAAgB,YAAY,WAAW;AAC/C,QAAA,gBAAgB,UAAU,sBAAsB;AAE/C,SAAA;AAAA;AAAA,IACL,IAAI,WAAW,KAAK,WAAW,SAAS,cAAc,KAAK,cAAc,QAAQ,UAAU;AAAA,IAC3F,IAAI,WAAW,KAAK,WAAW,QAAQ,cAAc,KAAK,cAAc,OAAO,UAAU;AAAA,IACzF,KAAK,WAAW,KAAK,WAAW,SAAS,cAAc,KAAK,cAAc,QAAQ,UAAU,aAAa,WAAW;AAAA,IACpH,KAAK,WAAW,KAAK,WAAW,QAAQ,cAAc,KAAK,cAAc,OAAO,UAAU,YAAY,WAAW;AAAA,IACjH,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW;AAAA,EACrB;AACF;AAEa,MAAA,gBAAgB,SAAU,MAAM;AAC3C,UAAQ,KAAK,cAAc,KAAK,WAAW,YAAY,IAAI;AAC7D;AAEO,MAAM,YAAY,SAAU,WAAW,OAAQ,SAAU;AAC9D,MAAI,CAAC,WAAW;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,SAAS,UAAU;AACzB,QAAM,WAAW,CAAC;AAElB,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC3B,QAAA,OAAO,UAAU,YAAY;AAC/B,eAAS,KAAK,MAAM,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC;AAAA,IAAA,OAE5C;AACM,eAAA,KAAK,UAAU,CAAC,CAAC;AAAA,IAAA;AAAA,EAC5B;AAGK,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-matchers.es.js","sources":["../../../../../src/modules/table/utils/node-matchers.ts"],"sourcesContent":["import Quill from 'quill'\nimport { omit, splitWithBreak } from '../../../config/editor.utils'\nimport { cellId as tableCellId, rowId as tableRowId, TableViewWrapper } from '../formats/table'\nimport { CELL_MIN_WIDTH } from '../table-config'\n\nconst Delta = Quill.imports.delta\nconst InlineBlot = Quill.imports.parchment.InlineBlot\n\n// rebuild delta\nexport function matchTableCell(node, delta) {\n // fix: 移除旧数据中的pt高度,避免由于高度平均分导致无法插入行\n if (node.style.height.indexOf('pt')) {\n node.removeAttribute('style')\n }\n\n const row = node.parentNode\n let rowId = row.dataset.row\n if (!rowId) {\n rowId = row.dataset.row = tableRowId()\n }\n let cellId = node.dataset.cell\n // fix: dataset.cell in td will be 'undefined' when insert row/column\n if (!cellId || cellId === 'undefined') {\n cellId = tableCellId()\n }\n const colspan = node.getAttribute('colspan') || 1\n const rowspan = node.getAttribute('rowspan') || 1\n\n // fix: empty table cells copied from other place will be removed unexpectedly\n if (delta.length() === 0) {\n delta = new Delta().insert('\\n', {\n 'table-cell-line': { row: rowId, cell: cellId, rowspan, colspan },\n })\n return delta\n }\n\n delta = delta.reduce((newDelta, op) => {\n if (op.insert && typeof op.insert === 'string') {\n const lines = splitWithBreak(op.insert)\n\n lines.forEach((text) => {\n if (text === '\\n') {\n let attributes = {}\n const cellAttributes = {\n row: rowId,\n cell: cellId,\n rowspan,\n colspan,\n }\n if (op.attributes.table) {\n delete op.attributes.table\n }\n switch (true) {\n case !!op.attributes.header:\n attributes = Object.assign(op.attributes.header, cellAttributes)\n break\n case !!op.attributes.list:\n attributes = { list: Object.assign(op.attributes.list, cellAttributes) }\n break\n default:\n attributes = { 'table-cell-line': cellAttributes }\n }\n // fix: when td has background-color, quill can't set it to table-cell bolt\n if (op.attributes.background && attributes['table-cell-line']) {\n attributes['table-cell-line'].tdBgColor = op.attributes.background\n }\n newDelta.insert('\\n', Object.assign(op.attributes, attributes))\n }\n else {\n newDelta.insert(text, omit(op.attributes, ['table', 'table-cell-line', 'header', 'list']))\n }\n })\n }\n else {\n newDelta.insert(op.insert, op.attributes)\n }\n\n return newDelta\n }, new Delta())\n\n // fix: table cell height becomes larger(because insert unnecessary <div> on both sides of cell) when init table ngModel\n const regexp = /^[\\n]+$/\n const firstDelta = delta.ops[0]\n if (delta.ops.length >= 3) {\n const lastDelta = delta.ops[delta.ops.length - 1]\n if (regexp.test(firstDelta.insert) && firstDelta.attributes['table-cell-line']) {\n delta.ops.splice(0, 1)\n }\n if (regexp.test(lastDelta.insert) && lastDelta.attributes['table-cell-line']) {\n delta.ops[delta.ops.length - 1].insert = '\\n'\n }\n }\n else if (delta.ops.length === 1 && regexp.test(firstDelta.insert) && firstDelta.attributes['table-cell-line']) {\n delta.ops[0].insert = '\\n'\n }\n\n return delta\n}\n\n// replace th tag with td tag\nexport function matchTableHeader(node, delta, _scroll) {\n const row = node.parentNode\n const cells = Array.from(row.querySelectorAll('th'))\n let rowId = row.dataset.row\n if (!rowId) {\n rowId = row.dataset.row = tableRowId()\n }\n const cellId = cells.indexOf(node) + 1\n const colspan = node.getAttribute('colspan') || false\n const rowspan = node.getAttribute('rowspan') || false\n\n // fix: empty table cells copied from other place will be removed unexpectedly\n if (delta.length() === 0) {\n delta = new Delta().insert('\\n', {\n 'table-cell-line': { row: rowId, cell: cellId, rowspan, colspan },\n })\n return delta\n }\n\n delta = delta.reduce((newDelta, op) => {\n if (op.insert && typeof op.insert === 'string') {\n const lines = splitWithBreak(op.insert)\n\n // fix: no '\\n' in the end of op.insert, push a '\\n' to lines\n if (lines[lines.length - 1] !== '\\n') {\n lines.push('\\n')\n }\n\n lines.forEach((text) => {\n text === '\\n'\n ? newDelta.insert('\\n', { 'table-cell-line': { row: rowId, cell: cellId, rowspan, colspan } })\n : newDelta.insert(text, op.attributes)\n })\n }\n else {\n newDelta.insert(op.insert, op.attributes)\n }\n\n return newDelta\n }, new Delta())\n\n delta = delta.reduce((newDelta, op) => {\n if (op.insert && typeof op.insert === 'string' && op.insert.startsWith('\\n')) {\n newDelta.insert(op.insert, { 'table-cell-line': { row: rowId, cell: cellId, rowspan, colspan } })\n }\n else {\n newDelta.insert(op.insert, { ...omit(op.attributes, ['table', 'table-cell-line']) })\n }\n\n return newDelta\n }, new Delta())\n\n return delta\n}\n\n// supplement colgroup and col\nexport function matchTable(node, delta, scroll) {\n const isWordTable = node.children.length === 1\n if (!(node instanceof Element)) {\n return\n }\n const getMaxColNumber = (tds) => {\n if (isWordTable) {\n return tds.length\n }\n let colsNumber = 0\n tds.forEach((td) => {\n colsNumber += td.colSpan\n })\n return Math.max(tds.length, colsNumber)\n }\n\n const checkMinWidth = (width) => {\n if (Number.isNaN(width)) {\n // 无指定值时默认为auto,待渲染后修正\n return { 'table-col': { width: 'auto' } }\n }\n else if (width < CELL_MIN_WIDTH) {\n // 当列宽度小于默认宽度时取默认宽度\n return { 'table-col': true }\n }\n else {\n // 大于默认值取实际指定值\n return { 'table-col': { width } }\n }\n }\n\n // fix: a table with an empty tr is invalid, should not be displayed\n const rows = node.querySelectorAll('tr')\n const topRow = rows[0]\n const onlyEmptyTr = rows.length === 1 && !topRow.querySelector('td')\n\n // fix: empty table will return empty delta\n if (!topRow || onlyEmptyTr) {\n return new Delta().insert('\\n')\n }\n\n const colsNumber = node.querySelectorAll('col').length\n let maxCellsNumber = 0\n let maxCells\n // 遍历行获取最大列数和该行的所有单元格\n Array.prototype.slice.call(rows).forEach((row) => {\n const tds = row.querySelectorAll('td')\n maxCellsNumber = Math.max(getMaxColNumber(tds), maxCellsNumber)\n maxCells = tds\n })\n\n // 列的累计器\n let colCount = 0\n delta = delta.reduce((newDelta, op) => {\n // 当colCount与colsNumber相等时,则补充相差列\n if (colCount === colsNumber) {\n const fillNumber = maxCellsNumber - colCount\n const outset = colCount\n // index为差值列索引,通过遍历差值得到mexCells行中对应索引的单元格宽度\n for (let i = 0; i < fillNumber; i++) {\n const index = outset + i\n const colWidth = Number.parseInt(\n index < maxCells.length\n ? maxCells[index].width\n // maxCells[index].style && maxCells[index].style.width ? maxCells[index].style.width :\n : maxCells[maxCells.length - 1].width,\n 10,\n )\n newDelta.insert('\\n', checkMinWidth(colWidth))\n colCount++\n }\n }\n const attr = op.attributes || {}\n switch (true) {\n case !!attr['table-col']:\n // 只有当前列数小于实际总列数才操作,所以不存在大于的情况\n if (colCount < maxCellsNumber) {\n // 当table-col宽度一致时会合并为单一insert,insert长度大于1,截取符合实际总列数的长度来插入\n const insert = op.insert.slice(0, maxCellsNumber)\n const colWidth = Number.parseInt(attr['table-col'].width, 10)\n newDelta.insert(insert, checkMinWidth(colWidth))\n colCount += insert.length\n }\n break\n case !!attr.notFilled:\n { // 将标记的空tr填充对应列数的单元格\n const rowId = tableRowId()\n for (let x = 0; x < maxCellsNumber; x++) {\n newDelta.insert('\\n', { 'table-cell-line': { row: rowId, cell: tableCellId(), rowspan: 1, colspan: 1 } })\n }\n break }\n default:\n newDelta.insert(op.insert, op.attributes)\n }\n return newDelta\n }, new Delta())\n\n const tableItem = node.closest('.quill-better-table-wrapper') || node\n const prevBlot = tableItem.previousElementSibling && scroll.query(tableItem.previousElementSibling)\n const nextBlot = tableItem.nextElementSibling && scroll.query(tableItem.nextElementSibling)\n // fix: prevent two adjacent tables from sticking together\n if (!nextBlot || nextBlot.prototype instanceof InlineBlot) {\n delta = delta.insert('\\n')\n }\n // fix: When there is no line break in front of the table, pressing the Enter key will cause a problem with the table.\n if (!prevBlot || prevBlot.prototype instanceof InlineBlot) {\n const newLine = new Delta().insert('\\n')\n delta = newLine.concat(delta)\n }\n if (nextBlot === TableViewWrapper) {\n delta = delta.insert('\\n')\n }\n\n return delta\n}\n\nexport function matchTableRow(_node, delta) {\n // fix: 处理空<tr>标签被忽略的情况\n if (delta.ops.length === 1 && !delta.ops[0].attributes) {\n delta = new Delta().insert('\\n', { notFilled: true })\n }\n return delta\n}\n\n// match h tags, distinguish between headers in the table and headers outside the table\nexport function matchHeader(node, delta) {\n const newDelta = new Delta()\n const fontSize = node.style.fontSize\n delta.forEach((op) => {\n newDelta.insert(\n op.insert,\n Object.assign({}, op.attributes, {\n size: fontSize,\n }),\n )\n })\n return newDelta\n}\n\nexport function matchList(node, delta) {\n const value = node.tagName === 'UL' ? 'bullet' : 'ordered'\n delta.forEach((op) => {\n if (typeof op.attributes.list === 'string') {\n delete op.attributes.list\n }\n else if (typeof op.attributes.list === 'object' && !op.attributes.list.value) {\n op.attributes.list.value = value\n }\n })\n return delta\n}\n\nexport function matchInline(node, delta, scroll) {\n const quill = Quill.find(scroll.domNode.parentNode)\n const currentRange = quill.getSelection()\n const formats = currentRange && quill.getFormat(currentRange)\n if (\n formats\n && formats['table-cell-line'] // 当前光标节点在表格内,否则不操作delta\n && node.nextElementSibling\n ) {\n // 插入节点是否存在下一个兄弟元素\n const match = scroll.query(node)\n const nodeHtml = node.nextElementSibling.innerHTML\n const nodeText = node.nextElementSibling.textContent\n if (\n (match && match.prototype instanceof InlineBlot) // 判断当前节点是否为内联\n || (node.tagName === 'P' && nodeHtml !== nodeText)\n ) {\n // 非内联时如果为P且下一个不为text节点\n delta.forEach((op) => {\n op.insert += '\\n'\n })\n }\n }\n return delta\n}\n\n// 匹配 word 自带的 v:shape 标签中的图片 v:imageData\nexport function matchWordShapeImage(node, delta) {\n if (node) {\n const imageUrl = node.attributes.src?.nodeValue\n delta = new Delta().insert({ image: imageUrl })\n }\n return delta\n}\n\nexport function matchMentionLink(node, delta, scroll) {\n const name = node.dataset.mentionId\n if (name) {\n const quill = Quill.find(scroll.domNode.parentNode)\n const mention = quill.getModule('mention')\n if (mention) {\n mention.options.search(name).then((res) => {\n const [item] = res\n if (item) {\n mention.options.select(item)\n }\n })\n }\n }\n return delta\n}\n"],"names":["rowId","tableRowId","cellId","tableCellId","colsNumber"],"mappings":";;;;AAKA,MAAM,QAAQ,MAAM,QAAQ;AAC5B,MAAM,aAAa,MAAM,QAAQ,UAAU;AAG3B,SAAA,eAAe,MAAM,OAAO;AAE1C,MAAI,KAAK,MAAM,OAAO,QAAQ,IAAI,GAAG;AACnC,SAAK,gBAAgB,OAAO;AAAA,EAAA;AAG9B,QAAM,MAAM,KAAK;AACb,MAAAA,UAAQ,IAAI,QAAQ;AACxB,MAAI,CAACA,SAAO;AACFA,cAAA,IAAI,QAAQ,MAAMC,MAAW;AAAA,EAAA;AAEnC,MAAAC,WAAS,KAAK,QAAQ;AAEtB,MAAA,CAACA,YAAUA,aAAW,aAAa;AACrCA,eAASC,OAAY;AAAA,EAAA;AAEvB,QAAM,UAAU,KAAK,aAAa,SAAS,KAAK;AAChD,QAAM,UAAU,KAAK,aAAa,SAAS,KAAK;AAG5C,MAAA,MAAM,OAAO,MAAM,GAAG;AACxB,YAAQ,IAAI,QAAQ,OAAO,MAAM;AAAA,MAC/B,mBAAmB,EAAE,KAAKH,SAAO,MAAME,UAAQ,SAAS,QAAQ;AAAA,IAAA,CACjE;AACM,WAAA;AAAA,EAAA;AAGT,UAAQ,MAAM,OA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AAS;AACzC,QAAI,SAAS;AACX,cAAQ,QAAQ,OAAO,IAAI,EAAE,KAAK,CAAC,QAAQ;AACnC,cAAA,CAAC,IAAI,IAAI;AACf,YAAI,MAAM;AACA,kBAAA,QAAQ,OAAO,IAAI;AAAA,QAAA;AAAA,MAC7B,CACD;AAAA,IAAA;AAAA,EACH;AAEK,SAAA;AACT;"}
|
|
1
|
+
{"version":3,"file":"node-matchers.es.js","sources":["../../../../../src/modules/table/utils/node-matchers.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport { omit, splitWithBreak } from '../../../config/editor.utils'\r\nimport { cellId as tableCellId, rowId as tableRowId, TableViewWrapper } from '../formats/table'\r\nimport { CELL_MIN_WIDTH } from '../table-config'\r\n\r\nconst Delta = Quill.imports.delta\r\nconst InlineBlot = Quill.imports.parchment.InlineBlot\r\n\r\n// rebuild delta\r\nexport function matchTableCell(node, delta) {\r\n // fix: 移除旧数据中的pt高度,避免由于高度平均分导致无法插入行\r\n if (node.style.height.indexOf('pt')) {\r\n node.removeAttribute('style')\r\n }\r\n\r\n const row = node.parentNode\r\n let rowId = row.dataset.row\r\n if (!rowId) {\r\n rowId = row.dataset.row = tableRowId()\r\n }\r\n let cellId = node.dataset.cell\r\n // fix: dataset.cell in td will be 'undefined' when insert row/column\r\n if (!cellId || cellId === 'undefined') {\r\n cellId = tableCellId()\r\n }\r\n const colspan = node.getAttribute('colspan') || 1\r\n const rowspan = node.getAttribute('rowspan') || 1\r\n\r\n // fix: empty table cells copied from other place will be removed unexpectedly\r\n if (delta.length() === 0) {\r\n delta = new Delta().insert('\\n', {\r\n 'table-cell-line': { row: rowId, cell: cellId, rowspan, colspan },\r\n })\r\n return delta\r\n }\r\n\r\n delta = delta.reduce((newDelta, op) => {\r\n if (op.insert && typeof op.insert === 'string') {\r\n const lines = splitWithBreak(op.insert)\r\n\r\n lines.forEach((text) => {\r\n if (text === '\\n') {\r\n let attributes = {}\r\n const cellAttributes = {\r\n row: rowId,\r\n cell: cellId,\r\n rowspan,\r\n colspan,\r\n }\r\n if (op.attributes.table) {\r\n delete op.attributes.table\r\n }\r\n switch (true) {\r\n case !!op.attributes.header:\r\n attributes = Object.assign(op.attributes.header, cellAttributes)\r\n break\r\n case !!op.attributes.list:\r\n attributes = { list: Object.assign(op.attributes.list, cellAttributes) }\r\n break\r\n default:\r\n attributes = { 'table-cell-line': cellAttributes }\r\n }\r\n // fix: when td has background-color, quill can't set it to table-cell bolt\r\n if (op.attributes.background && attributes['table-cell-line']) {\r\n attributes['table-cell-line'].tdBgColor = op.attributes.background\r\n }\r\n newDelta.insert('\\n', Object.assign(op.attributes, attributes))\r\n }\r\n else {\r\n newDelta.insert(text, omit(op.attributes, ['table', 'table-cell-line', 'header', 'list']))\r\n }\r\n })\r\n }\r\n else {\r\n newDelta.insert(op.insert, op.attributes)\r\n }\r\n\r\n return newDelta\r\n }, new Delta())\r\n\r\n // fix: table cell height becomes larger(because insert unnecessary <div> on both sides of cell) when init table ngModel\r\n const regexp = /^[\\n]+$/\r\n const firstDelta = delta.ops[0]\r\n if (delta.ops.length >= 3) {\r\n const lastDelta = delta.ops[delta.ops.length - 1]\r\n if (regexp.test(firstDelta.insert) && firstDelta.attributes['table-cell-line']) {\r\n delta.ops.splice(0, 1)\r\n }\r\n if (regexp.test(lastDelta.insert) && lastDelta.attributes['table-cell-line']) {\r\n delta.ops[delta.ops.length - 1].insert = '\\n'\r\n }\r\n }\r\n else if (delta.ops.length === 1 && regexp.test(firstDelta.insert) && firstDelta.attributes['table-cell-line']) {\r\n delta.ops[0].insert = '\\n'\r\n }\r\n\r\n return delta\r\n}\r\n\r\n// replace th tag with td tag\r\nexport function matchTableHeader(node, delta, _scroll) {\r\n const row = node.parentNode\r\n const cells = Array.from(row.querySelectorAll('th'))\r\n let rowId = row.dataset.row\r\n if (!rowId) {\r\n rowId = row.dataset.row = tableRowId()\r\n }\r\n const cellId = cells.indexOf(node) + 1\r\n const colspan = node.getAttribute('colspan') || false\r\n const rowspan = node.getAttribute('rowspan') || false\r\n\r\n // fix: empty table cells copied from other place will be removed unexpectedly\r\n if (delta.length() === 0) {\r\n delta = new Delta().insert('\\n', {\r\n 'table-cell-line': { row: rowId, cell: cellId, rowspan, colspan },\r\n })\r\n return delta\r\n }\r\n\r\n delta = delta.reduce((newDelta, op) => {\r\n if (op.insert && typeof op.insert === 'string') {\r\n const lines = splitWithBreak(op.insert)\r\n\r\n // fix: no '\\n' in the end of op.insert, push a '\\n' to lines\r\n if (lines[lines.length - 1] !== '\\n') {\r\n lines.push('\\n')\r\n }\r\n\r\n lines.forEach((text) => {\r\n text === '\\n'\r\n ? newDelta.insert('\\n', { 'table-cell-line': { row: rowId, cell: cellId, rowspan, colspan } })\r\n : newDelta.insert(text, op.attributes)\r\n })\r\n }\r\n else {\r\n newDelta.insert(op.insert, op.attributes)\r\n }\r\n\r\n return newDelta\r\n }, new Delta())\r\n\r\n delta = delta.reduce((newDelta, op) => {\r\n if (op.insert && typeof op.insert === 'string' && op.insert.startsWith('\\n')) {\r\n newDelta.insert(op.insert, { 'table-cell-line': { row: rowId, cell: cellId, rowspan, colspan } })\r\n }\r\n else {\r\n newDelta.insert(op.insert, { ...omit(op.attributes, ['table', 'table-cell-line']) })\r\n }\r\n\r\n return newDelta\r\n }, new Delta())\r\n\r\n return delta\r\n}\r\n\r\n// supplement colgroup and col\r\nexport function matchTable(node, delta, scroll) {\r\n const isWordTable = node.children.length === 1\r\n if (!(node instanceof Element)) {\r\n return\r\n }\r\n const getMaxColNumber = (tds) => {\r\n if (isWordTable) {\r\n return tds.length\r\n }\r\n let colsNumber = 0\r\n tds.forEach((td) => {\r\n colsNumber += td.colSpan\r\n })\r\n return Math.max(tds.length, colsNumber)\r\n }\r\n\r\n const checkMinWidth = (width) => {\r\n if (Number.isNaN(width)) {\r\n // 无指定值时默认为auto,待渲染后修正\r\n return { 'table-col': { width: 'auto' } }\r\n }\r\n else if (width < CELL_MIN_WIDTH) {\r\n // 当列宽度小于默认宽度时取默认宽度\r\n return { 'table-col': true }\r\n }\r\n else {\r\n // 大于默认值取实际指定值\r\n return { 'table-col': { width } }\r\n }\r\n }\r\n\r\n // fix: a table with an empty tr is invalid, should not be displayed\r\n const rows = node.querySelectorAll('tr')\r\n const topRow = rows[0]\r\n const onlyEmptyTr = rows.length === 1 && !topRow.querySelector('td')\r\n\r\n // fix: empty table will return empty delta\r\n if (!topRow || onlyEmptyTr) {\r\n return new Delta().insert('\\n')\r\n }\r\n\r\n const colsNumber = node.querySelectorAll('col').length\r\n let maxCellsNumber = 0\r\n let maxCells\r\n // 遍历行获取最大列数和该行的所有单元格\r\n Array.prototype.slice.call(rows).forEach((row) => {\r\n const tds = row.querySelectorAll('td')\r\n maxCellsNumber = Math.max(getMaxColNumber(tds), maxCellsNumber)\r\n maxCells = tds\r\n })\r\n\r\n // 列的累计器\r\n let colCount = 0\r\n delta = delta.reduce((newDelta, op) => {\r\n // 当colCount与colsNumber相等时,则补充相差列\r\n if (colCount === colsNumber) {\r\n const fillNumber = maxCellsNumber - colCount\r\n const outset = colCount\r\n // index为差值列索引,通过遍历差值得到mexCells行中对应索引的单元格宽度\r\n for (let i = 0; i < fillNumber; i++) {\r\n const index = outset + i\r\n const colWidth = Number.parseInt(\r\n index < maxCells.length\r\n ? maxCells[index].width\r\n // maxCells[index].style && maxCells[index].style.width ? maxCells[index].style.width :\r\n : maxCells[maxCells.length - 1].width,\r\n 10,\r\n )\r\n newDelta.insert('\\n', checkMinWidth(colWidth))\r\n colCount++\r\n }\r\n }\r\n const attr = op.attributes || {}\r\n switch (true) {\r\n case !!attr['table-col']:\r\n // 只有当前列数小于实际总列数才操作,所以不存在大于的情况\r\n if (colCount < maxCellsNumber) {\r\n // 当table-col宽度一致时会合并为单一insert,insert长度大于1,截取符合实际总列数的长度来插入\r\n const insert = op.insert.slice(0, maxCellsNumber)\r\n const colWidth = Number.parseInt(attr['table-col'].width, 10)\r\n newDelta.insert(insert, checkMinWidth(colWidth))\r\n colCount += insert.length\r\n }\r\n break\r\n case !!attr.notFilled:\r\n { // 将标记的空tr填充对应列数的单元格\r\n const rowId = tableRowId()\r\n for (let x = 0; x < maxCellsNumber; x++) {\r\n newDelta.insert('\\n', { 'table-cell-line': { row: rowId, cell: tableCellId(), rowspan: 1, colspan: 1 } })\r\n }\r\n break }\r\n default:\r\n newDelta.insert(op.insert, op.attributes)\r\n }\r\n return newDelta\r\n }, new Delta())\r\n\r\n const tableItem = node.closest('.quill-better-table-wrapper') || node\r\n const prevBlot = tableItem.previousElementSibling && scroll.query(tableItem.previousElementSibling)\r\n const nextBlot = tableItem.nextElementSibling && scroll.query(tableItem.nextElementSibling)\r\n // fix: prevent two adjacent tables from sticking together\r\n if (!nextBlot || nextBlot.prototype instanceof InlineBlot) {\r\n delta = delta.insert('\\n')\r\n }\r\n // fix: When there is no line break in front of the table, pressing the Enter key will cause a problem with the table.\r\n if (!prevBlot || prevBlot.prototype instanceof InlineBlot) {\r\n const newLine = new Delta().insert('\\n')\r\n delta = newLine.concat(delta)\r\n }\r\n if (nextBlot === TableViewWrapper) {\r\n delta = delta.insert('\\n')\r\n }\r\n\r\n return delta\r\n}\r\n\r\nexport function matchTableRow(_node, delta) {\r\n // fix: 处理空<tr>标签被忽略的情况\r\n if (delta.ops.length === 1 && !delta.ops[0].attributes) {\r\n delta = new Delta().insert('\\n', { notFilled: true })\r\n }\r\n return delta\r\n}\r\n\r\n// match h tags, distinguish between headers in the table and headers outside the table\r\nexport function matchHeader(node, delta) {\r\n const newDelta = new Delta()\r\n const fontSize = node.style.fontSize\r\n delta.forEach((op) => {\r\n newDelta.insert(\r\n op.insert,\r\n Object.assign({}, op.attributes, {\r\n size: fontSize,\r\n }),\r\n )\r\n })\r\n return newDelta\r\n}\r\n\r\nexport function matchList(node, delta) {\r\n const value = node.tagName === 'UL' ? 'bullet' : 'ordered'\r\n delta.forEach((op) => {\r\n if (typeof op.attributes.list === 'string') {\r\n delete op.attributes.list\r\n }\r\n else if (typeof op.attributes.list === 'object' && !op.attributes.list.value) {\r\n op.attributes.list.value = value\r\n }\r\n })\r\n return delta\r\n}\r\n\r\nexport function matchInline(node, delta, scroll) {\r\n const quill = Quill.find(scroll.domNode.parentNode)\r\n const currentRange = quill.getSelection()\r\n const formats = currentRange && quill.getFormat(currentRange)\r\n if (\r\n formats\r\n && formats['table-cell-line'] // 当前光标节点在表格内,否则不操作delta\r\n && node.nextElementSibling\r\n ) {\r\n // 插入节点是否存在下一个兄弟元素\r\n const match = scroll.query(node)\r\n const nodeHtml = node.nextElementSibling.innerHTML\r\n const nodeText = node.nextElementSibling.textContent\r\n if (\r\n (match && match.prototype instanceof InlineBlot) // 判断当前节点是否为内联\r\n || (node.tagName === 'P' && nodeHtml !== nodeText)\r\n ) {\r\n // 非内联时如果为P且下一个不为text节点\r\n delta.forEach((op) => {\r\n op.insert += '\\n'\r\n })\r\n }\r\n }\r\n return delta\r\n}\r\n\r\n// 匹配 word 自带的 v:shape 标签中的图片 v:imageData\r\nexport function matchWordShapeImage(node, delta) {\r\n if (node) {\r\n const imageUrl = node.attributes.src?.nodeValue\r\n delta = new Delta().insert({ image: imageUrl })\r\n }\r\n return delta\r\n}\r\n\r\nexport function matchMentionLink(node, delta, scroll) {\r\n const name = node.dataset.mentionId\r\n if (name) {\r\n const quill = Quill.find(scroll.domNode.parentNode)\r\n const mention = quill.getModule('mention')\r\n if (mention) {\r\n mention.options.search(name).then((res) => {\r\n const [item] = res\r\n if (item) {\r\n mention.options.select(item)\r\n }\r\n })\r\n }\r\n }\r\n return delta\r\n}\r\n"],"names":["rowId","tableRowId","cellId","tableCellId","colsNumber"],"mappings":";;;;AAKA,MAAM,QAAQ,MAAM,QAAQ;AAC5B,MAAM,aAAa,MAAM,QAAQ,UAAU;AAG3B,SAAA,eAAe,MAAM,OAAO;AAE1C,MAAI,KAAK,MAAM,OAAO,QAAQ,IAAI,GAAG;AACnC,SAAK,gBAAgB,OAAO;AAAA,EAAA;AAG9B,QAAM,MAAM,KAAK;AACb,MAAAA,UAAQ,I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