@opentiny/fluent-editor 3.23.3 → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/fluent-editor.es.js +4 -1
- package/es/fluent-editor.es.js.map +1 -1
- package/es/table/better-table.es.js +53 -1
- package/es/table/better-table.es.js.map +1 -1
- package/es/table/modules/table-selector.es.js +158 -0
- package/es/table/modules/table-selector.es.js.map +1 -0
- package/lib/fluent-editor.cjs.js +4 -1
- package/lib/fluent-editor.cjs.js.map +1 -1
- package/lib/table/better-table.cjs.js +55 -3
- package/lib/table/better-table.cjs.js.map +1 -1
- package/lib/table/modules/table-selector.cjs.js +158 -0
- package/lib/table/modules/table-selector.cjs.js.map +1 -0
- package/package.json +2 -2
- package/style.css +3 -3
- package/types/table/better-table.d.ts +8 -0
- package/types/table/modules/table-selector.d.ts +22 -0
package/es/fluent-editor.es.js
CHANGED
|
@@ -133,7 +133,10 @@ const registerModules = function() {
|
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
[FormatPainter.toolName]: FormatPainter,
|
|
136
|
-
[Screenshot.toolName]: Screenshot
|
|
136
|
+
[Screenshot.toolName]: Screenshot,
|
|
137
|
+
"lineheight": function(value) {
|
|
138
|
+
this.quill.format("line-height", value);
|
|
139
|
+
}
|
|
137
140
|
}
|
|
138
141
|
},
|
|
139
142
|
"better-table": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluent-editor.es.js","sources":["../../src/fluent-editor.ts"],"sourcesContent":["import type { ExpandedQuillOptions, Module, Parchment as TypeParchment } from 'quill'\r\nimport type { IEditorConfig } from './config/types'\r\nimport Quill from 'quill'\r\nimport { FontStyle, LineHeightStyle, SizeStyle, TextIndentStyle } from './attributors'\r\nimport { CHANGE_LANGUAGE_EVENT, defaultLanguage, getListValue, ICONS_CONFIG, inputFile, LANG_CONF } from './config'\r\nimport Counter from './counter' // 字符统计\r\nimport CustomClipboard from './custom-clipboard' // 粘贴板\r\nimport CustomImage from './custom-image/BlotFormatter' // 图片\r\nimport { CustomImageSpec } from './custom-image/specs/CustomImageSpec' // 图片拉伸模块\r\nimport CustomUploader from './custom-uploader' // 上传\r\nimport Emoji from './emoji' // 表情\r\nimport FileModule from './file' // 文件\r\nimport { FormatPainter } from './format-painter'\r\nimport { fullscreenHandler } from './fullscreen/handler'\r\nimport Link from './link' // 超链接\r\nimport MathliveModule from './mathlive' // latex公式\r\nimport MathliveBlot from './mathlive/formats'\r\nimport Mention from './mention/Mention' // @提醒\r\nimport { Screenshot } from './screenshot'// 截图\r\nimport SoftBreak from './soft-break' // 软回车\r\nimport Strike from './strike' // 删除线\r\nimport CustomSyntax from './syntax' // 代码块高亮\r\nimport BetterTable from './table/better-table' // 表格\r\nimport Toolbar, { ToolbarTip } from './toolbar' // 工具栏\r\nimport { isUndefined } from './utils/is'\r\nimport Video from './video' // 视频\r\n// import GlobalLink from './global-link' // 全局链接\r\n// import QuickMenu from './quick-menu' // 快捷菜单\r\nexport interface I18NOptions {\r\n lang: string\r\n langText: Record<string, string>\r\n}\r\nfunction resolveLanguageOption(options: Partial<I18NOptions>): I18NOptions {\r\n if (isUndefined(options.lang)) {\r\n options.lang = defaultLanguage\r\n }\r\n if (!(options.lang in LANG_CONF)) {\r\n console.warn(`The language ${options.lang} is not supported. Use the default language: ${defaultLanguage}`)\r\n options.lang = defaultLanguage\r\n }\r\n return {\r\n lang: options.lang,\r\n langText: Object.assign({}, LANG_CONF[options.lang], options.langText || {}),\r\n }\r\n}\r\nexport class FluentEditor extends Quill {\r\n isFullscreen: boolean = false\r\n options: IEditorConfig & ExpandedQuillOptions\r\n constructor(container: HTMLElement | string, options: IEditorConfig = {}) {\r\n options = Object.assign(options, resolveLanguageOption(options || {}))\r\n super(container, options)\r\n }\r\n\r\n changeLanguage(options: Partial<I18NOptions>) {\r\n const langOps = resolveLanguageOption(options)\r\n if (langOps.lang === this.options.lang) return\r\n this.options.lang = langOps.lang\r\n this.options.langText = langOps.langText\r\n this.emitter.emit(CHANGE_LANGUAGE_EVENT, this.options.lang, this.options.langText)\r\n }\r\n}\r\n\r\nconst registerModules = function () {\r\n const Icons = Quill.import('ui/icons')\r\n Object.entries(ICONS_CONFIG).forEach(([key, icon]) => {\r\n Icons[key] = icon\r\n })\r\n\r\n const SnowTheme = Quill.imports['themes/snow'] as typeof Module\r\n SnowTheme.DEFAULTS = {\r\n modules: {\r\n 'keyboard': {\r\n bindings: {\r\n ...BetterTable.keyboardBindings,\r\n },\r\n },\r\n 'toolbar': {\r\n handlers: {\r\n ...(SnowTheme.DEFAULTS as Record<string, any>).modules.toolbar.handlers,\r\n 'formula': function () {\r\n if (!this.quill.isEnabled()) return\r\n const mathlive = this.quill.getModule('mathlive')\r\n if (!mathlive) {\r\n this.quill.theme.tooltip.edit('formula')\r\n }\r\n else {\r\n mathlive.createDialog()\r\n }\r\n },\r\n 'undo': function () {\r\n this.quill.history.undo()\r\n },\r\n 'redo': function () {\r\n this.quill.history.redo()\r\n },\r\n 'better-table': function () {\r\n this.quill.getModule('better-table').insertTable(3, 3)\r\n },\r\n 'file': function () {\r\n const accept = this.quill.options?.uploadOption?.fileAccept\r\n inputFile.call(this, 'file', accept)\r\n },\r\n 'image': function () {\r\n const accept = this.quill.options?.uploadOption?.imageAccept\r\n inputFile.call(this, 'image', accept)\r\n },\r\n 'emoji': function () {},\r\n 'fullscreen': fullscreenHandler,\r\n 'list': function (value) {\r\n const range = this.quill.getSelection()\r\n const formats = this.quill.getFormat(range)\r\n const preListValue = Array.isArray(formats.list) ? formats.list[0]?.value : formats.list?.value\r\n const curListValue = getListValue(value, preListValue)\r\n // 如果设置list的选区中有表格,判断第一个table-col位置,将表格前的内容设置为list格式\r\n const lines = this.quill.getLines(range.index, range.length)\r\n const tableCols = lines.filter(line => line.statics.blotName === 'table-col' && !line.prev)\r\n if (tableCols.length) {\r\n let start = range.index\r\n // 遍历table-col群组,以之获取表格,将表格前选区设置为对应list格式\r\n tableCols.forEach((item, index) => {\r\n const table = item.domNode.closest('table.quill-better-table')\r\n const tableBlot = Quill.find(table) as TypeParchment.Blot\r\n const tableLength = tableBlot.length()\r\n const tableStart = this.quill.getIndex(item)\r\n const tableEnd = tableStart + tableLength\r\n const beforeTableRangeLength = tableStart - start\r\n // 在表格前设置列表\r\n this.quill.setSelection(start, beforeTableRangeLength, Quill.sources.SILENT)\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n // 当前表格末尾为下一个选取的开始\r\n start = tableEnd\r\n if (index === tableCols.length - 1) {\r\n // 将最后一个表格之后所有选区内容设置list格式\r\n this.quill.setSelection(tableEnd, range.index + range.length - tableEnd)\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n }\r\n })\r\n }\r\n else {\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n }\r\n },\r\n [FormatPainter.toolName]: FormatPainter,\r\n [Screenshot.toolName]: Screenshot,\r\n },\r\n },\r\n 'better-table': {\r\n operationMenu: {\r\n color: true,\r\n },\r\n },\r\n 'image': {\r\n specs: [CustomImageSpec],\r\n overlay: {\r\n style: {\r\n border: '1px dashed rgb(68, 68, 68)',\r\n },\r\n },\r\n align: {\r\n icons: {\r\n left: '<i class=\"icon-text-align-left\"></i>',\r\n center: '<i class=\"icon-text-align-center\"></i>',\r\n right: '<i class=\"icon-text-align-right\"></i>',\r\n },\r\n },\r\n },\r\n [ToolbarTip.moduleName]: true,\r\n },\r\n }\r\n\r\n FluentEditor.register(\r\n {\r\n 'modules/toolbar': Toolbar,\r\n 'modules/mention': Mention,\r\n 'modules/better-table': BetterTable,\r\n 'modules/clipboard': CustomClipboard,\r\n 'modules/uploader': CustomUploader, // 三者关联性最强\r\n 'modules/image': CustomImage, // 三者关联性最强\r\n 'modules/file': FileModule, // 三者关联性最强\r\n 'modules/counter': Counter,\r\n 'modules/emoji-toolbar': Emoji.ToolbarEmoji,\r\n 'modules/emoji-shortname': Emoji.ShortNameEmoji,\r\n // 'modules/global-link': GlobalLink,//暂未开发\r\n 'modules/link': Link, // 报错\r\n // 'modules/quickmenu': QuickMenu,//暂未开发\r\n 'modules/syntax': CustomSyntax,\r\n 'modules/mathlive': MathliveModule,\r\n [`modules/${ToolbarTip.moduleName}`]: ToolbarTip,\r\n\r\n 'formats/strike': Strike,\r\n 'formats/softBreak': SoftBreak,\r\n 'formats/video': Video,\r\n 'formats/emoji': Emoji.EmojiBlot,\r\n 'formats/font': FontStyle,\r\n 'formats/size': SizeStyle,\r\n 'formats/line-height': LineHeightStyle,\r\n 'formats/text-indent': TextIndentStyle,\r\n [`formats/${MathliveBlot.blotName}`]: MathliveBlot,\r\n },\r\n true, // 覆盖内部模块\r\n )\r\n\r\n return FluentEditor\r\n}\r\n\r\nexport default registerModules()\r\n"],"names":["Toolbar","CustomImage","Strike"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,sBAAsB,SAA4C;AACrE,MAAA,YAAY,QAAQ,IAAI,GAAG;AAC7B,YAAQ,OAAO;AAAA,EACjB;AACI,MAAA,EAAE,QAAQ,QAAQ,YAAY;AAChC,YAAQ,KAAK,gBAAgB,QAAQ,IAAI,gDAAgD,eAAe,EAAE;AAC1G,YAAQ,OAAO;AAAA,EACjB;AACO,SAAA;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,UAAU,OAAO,OAAO,CAAA,GAAI,UAAU,QAAQ,IAAI,GAAG,QAAQ,YAAY,EAAE;AAAA,EAAA;AAE/E;AACO,MAAM,qBAAqB,MAAM;AAAA,EAGtC,YAAY,WAAiC,UAAyB,IAAI;AACxE,cAAU,OAAO,OAAO,SAAS,sBAAsB,WAAW,CAAE,CAAA,CAAC;AACrE,UAAM,WAAW,OAAO;AAJF,SAAA,eAAA;AAAA,EAKxB;AAAA,EAEA,eAAe,SAA+B;AACtC,UAAA,UAAU,sBAAsB,OAAO;AAC7C,QAAI,QAAQ,SAAS,KAAK,QAAQ,KAAM;AACnC,SAAA,Q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version":3,"file":"fluent-editor.es.js","sources":["../../src/fluent-editor.ts"],"sourcesContent":["import type { ExpandedQuillOptions, Module, Parchment as TypeParchment } from 'quill'\r\nimport type { IEditorConfig } from './config/types'\r\nimport Quill from 'quill'\r\nimport { FontStyle, LineHeightStyle, SizeStyle, TextIndentStyle } from './attributors'\r\nimport { CHANGE_LANGUAGE_EVENT, defaultLanguage, getListValue, ICONS_CONFIG, inputFile, LANG_CONF } from './config'\r\nimport Counter from './counter' // 字符统计\r\nimport CustomClipboard from './custom-clipboard' // 粘贴板\r\nimport CustomImage from './custom-image/BlotFormatter' // 图片\r\nimport { CustomImageSpec } from './custom-image/specs/CustomImageSpec' // 图片拉伸模块\r\nimport CustomUploader from './custom-uploader' // 上传\r\nimport Emoji from './emoji' // 表情\r\nimport FileModule from './file' // 文件\r\nimport { FormatPainter } from './format-painter'\r\nimport { fullscreenHandler } from './fullscreen/handler'\r\nimport Link from './link' // 超链接\r\nimport MathliveModule from './mathlive' // latex公式\r\nimport MathliveBlot from './mathlive/formats'\r\nimport Mention from './mention/Mention' // @提醒\r\nimport { Screenshot } from './screenshot'// 截图\r\nimport SoftBreak from './soft-break' // 软回车\r\nimport Strike from './strike' // 删除线\r\nimport CustomSyntax from './syntax' // 代码块高亮\r\nimport BetterTable from './table/better-table' // 表格\r\nimport Toolbar, { ToolbarTip } from './toolbar' // 工具栏\r\nimport { isUndefined } from './utils/is'\r\nimport Video from './video' // 视频\r\n// import GlobalLink from './global-link' // 全局链接\r\n// import QuickMenu from './quick-menu' // 快捷菜单\r\nexport interface I18NOptions {\r\n lang: string\r\n langText: Record<string, string>\r\n}\r\nfunction resolveLanguageOption(options: Partial<I18NOptions>): I18NOptions {\r\n if (isUndefined(options.lang)) {\r\n options.lang = defaultLanguage\r\n }\r\n if (!(options.lang in LANG_CONF)) {\r\n console.warn(`The language ${options.lang} is not supported. Use the default language: ${defaultLanguage}`)\r\n options.lang = defaultLanguage\r\n }\r\n return {\r\n lang: options.lang,\r\n langText: Object.assign({}, LANG_CONF[options.lang], options.langText || {}),\r\n }\r\n}\r\nexport class FluentEditor extends Quill {\r\n isFullscreen: boolean = false\r\n options: IEditorConfig & ExpandedQuillOptions\r\n constructor(container: HTMLElement | string, options: IEditorConfig = {}) {\r\n options = Object.assign(options, resolveLanguageOption(options || {}))\r\n super(container, options)\r\n }\r\n\r\n changeLanguage(options: Partial<I18NOptions>) {\r\n const langOps = resolveLanguageOption(options)\r\n if (langOps.lang === this.options.lang) return\r\n this.options.lang = langOps.lang\r\n this.options.langText = langOps.langText\r\n this.emitter.emit(CHANGE_LANGUAGE_EVENT, this.options.lang, this.options.langText)\r\n }\r\n}\r\n\r\nconst registerModules = function () {\r\n const Icons = Quill.import('ui/icons')\r\n Object.entries(ICONS_CONFIG).forEach(([key, icon]) => {\r\n Icons[key] = icon\r\n })\r\n\r\n const SnowTheme = Quill.imports['themes/snow'] as typeof Module\r\n SnowTheme.DEFAULTS = {\r\n modules: {\r\n 'keyboard': {\r\n bindings: {\r\n ...BetterTable.keyboardBindings,\r\n },\r\n },\r\n 'toolbar': {\r\n handlers: {\r\n ...(SnowTheme.DEFAULTS as Record<string, any>).modules.toolbar.handlers,\r\n 'formula': function () {\r\n if (!this.quill.isEnabled()) return\r\n const mathlive = this.quill.getModule('mathlive')\r\n if (!mathlive) {\r\n this.quill.theme.tooltip.edit('formula')\r\n }\r\n else {\r\n mathlive.createDialog()\r\n }\r\n },\r\n 'undo': function () {\r\n this.quill.history.undo()\r\n },\r\n 'redo': function () {\r\n this.quill.history.redo()\r\n },\r\n 'better-table': function () {\r\n this.quill.getModule('better-table').insertTable(3, 3)\r\n },\r\n 'file': function () {\r\n const accept = this.quill.options?.uploadOption?.fileAccept\r\n inputFile.call(this, 'file', accept)\r\n },\r\n 'image': function () {\r\n const accept = this.quill.options?.uploadOption?.imageAccept\r\n inputFile.call(this, 'image', accept)\r\n },\r\n 'emoji': function () {},\r\n 'fullscreen': fullscreenHandler,\r\n 'list': function (value) {\r\n const range = this.quill.getSelection()\r\n const formats = this.quill.getFormat(range)\r\n const preListValue = Array.isArray(formats.list) ? formats.list[0]?.value : formats.list?.value\r\n const curListValue = getListValue(value, preListValue)\r\n // 如果设置list的选区中有表格,判断第一个table-col位置,将表格前的内容设置为list格式\r\n const lines = this.quill.getLines(range.index, range.length)\r\n const tableCols = lines.filter(line => line.statics.blotName === 'table-col' && !line.prev)\r\n if (tableCols.length) {\r\n let start = range.index\r\n // 遍历table-col群组,以之获取表格,将表格前选区设置为对应list格式\r\n tableCols.forEach((item, index) => {\r\n const table = item.domNode.closest('table.quill-better-table')\r\n const tableBlot = Quill.find(table) as TypeParchment.Blot\r\n const tableLength = tableBlot.length()\r\n const tableStart = this.quill.getIndex(item)\r\n const tableEnd = tableStart + tableLength\r\n const beforeTableRangeLength = tableStart - start\r\n // 在表格前设置列表\r\n this.quill.setSelection(start, beforeTableRangeLength, Quill.sources.SILENT)\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n // 当前表格末尾为下一个选取的开始\r\n start = tableEnd\r\n if (index === tableCols.length - 1) {\r\n // 将最后一个表格之后所有选区内容设置list格式\r\n this.quill.setSelection(tableEnd, range.index + range.length - tableEnd)\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n }\r\n })\r\n }\r\n else {\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n }\r\n },\r\n [FormatPainter.toolName]: FormatPainter,\r\n [Screenshot.toolName]: Screenshot,\r\n 'lineheight': function (value) {\r\n this.quill.format('line-height', value)\r\n },\r\n },\r\n },\r\n 'better-table': {\r\n operationMenu: {\r\n color: true,\r\n },\r\n },\r\n 'image': {\r\n specs: [CustomImageSpec],\r\n overlay: {\r\n style: {\r\n border: '1px dashed rgb(68, 68, 68)',\r\n },\r\n },\r\n align: {\r\n icons: {\r\n left: '<i class=\"icon-text-align-left\"></i>',\r\n center: '<i class=\"icon-text-align-center\"></i>',\r\n right: '<i class=\"icon-text-align-right\"></i>',\r\n },\r\n },\r\n },\r\n [ToolbarTip.moduleName]: true,\r\n },\r\n }\r\n\r\n FluentEditor.register(\r\n {\r\n 'modules/toolbar': Toolbar,\r\n 'modules/mention': Mention,\r\n 'modules/better-table': BetterTable,\r\n 'modules/clipboard': CustomClipboard,\r\n 'modules/uploader': CustomUploader, // 三者关联性最强\r\n 'modules/image': CustomImage, // 三者关联性最强\r\n 'modules/file': FileModule, // 三者关联性最强\r\n 'modules/counter': Counter,\r\n 'modules/emoji-toolbar': Emoji.ToolbarEmoji,\r\n 'modules/emoji-shortname': Emoji.ShortNameEmoji,\r\n // 'modules/global-link': GlobalLink,//暂未开发\r\n 'modules/link': Link, // 报错\r\n // 'modules/quickmenu': QuickMenu,//暂未开发\r\n 'modules/syntax': CustomSyntax,\r\n 'modules/mathlive': MathliveModule,\r\n [`modules/${ToolbarTip.moduleName}`]: ToolbarTip,\r\n\r\n 'formats/strike': Strike,\r\n 'formats/softBreak': SoftBreak,\r\n 'formats/video': Video,\r\n 'formats/emoji': Emoji.EmojiBlot,\r\n 'formats/font': FontStyle,\r\n 'formats/size': SizeStyle,\r\n 'formats/line-height': LineHeightStyle,\r\n 'formats/text-indent': TextIndentStyle,\r\n [`formats/${MathliveBlot.blotName}`]: MathliveBlot,\r\n },\r\n true, // 覆盖内部模块\r\n )\r\n\r\n return FluentEditor\r\n}\r\n\r\nexport default registerModules()\r\n"],"names":["Toolbar","CustomImage","Strike"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,sBAAsB,SAA4C;AACrE,MAAA,YAAY,QAAQ,IAAI,GAAG;AAC7B,YAAQ,OAAO;AAAA,EACjB;AACI,MAAA,EAAE,QAAQ,QAAQ,YAAY;AAChC,YAAQ,KAAK,gBAAgB,QAAQ,IAAI,gDAAgD,eAAe,EAAE;AAC1G,YAAQ,OAAO;AAAA,EACjB;AACO,SAAA;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,UAAU,OAAO,OAA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AAAA;AAAA,MAEjC,gBAAgB;AAAA;AAAA;AAAA,MAEhB,kBAAkB;AAAA,MAClB,oBAAoB;AAAA,MACpB,CAAC,WAAW,WAAW,UAAU,EAAE,GAAG;AAAA,MAEtC,kBAAkBC;AAAAA,MAClB,qBAAqB;AAAA,MACrB,iBAAiB;AAAA,MACjB,iBAAiB,MAAM;AAAA,MACvB,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,MAChB,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,MACvB,CAAC,WAAW,aAAa,QAAQ,EAAE,GAAG;AAAA,IACxC;AAAA,IACA;AAAA;AAAA,EAAA;AAGK,SAAA;AACT;AAEA,MAAA,iBAAe,gBAAgB;"}
|
|
@@ -7,6 +7,8 @@ import TableColumnTool from "./modules/table-column-tool.es.js";
|
|
|
7
7
|
import TableOperationMenu from "./modules/table-operation-menu.es.js";
|
|
8
8
|
import TableScrollBar from "./modules/table-scroll-bar.es.js";
|
|
9
9
|
import TableSelection from "./modules/table-selection.es.js";
|
|
10
|
+
import TableSelector from "./modules/table-selector.es.js";
|
|
11
|
+
import { css } from "./utils/index.es.js";
|
|
10
12
|
import { matchTableCell, matchTableHeader, matchTable, matchHeader, matchList, matchMentionLink, matchWordShapeImage, matchInline, matchTableRow } from "./utils/node-matchers.es.js";
|
|
11
13
|
const Block = Quill.imports["blots/block"];
|
|
12
14
|
const Delta = Quill.imports.delta;
|
|
@@ -27,6 +29,7 @@ class BetterTable extends Module {
|
|
|
27
29
|
constructor(quill, options) {
|
|
28
30
|
super(quill, options);
|
|
29
31
|
this.isComposition = false;
|
|
32
|
+
this.isTableSelectorVisible = false;
|
|
30
33
|
this.quill.root.addEventListener("mousedown", (event) => this.handleMouseDown(event, quill), false);
|
|
31
34
|
this.quill.root.addEventListener("compositionend", () => this.handleCompositionend(quill), false);
|
|
32
35
|
this.quill.root.addEventListener("compositionstart", () => this.handleCompositionstart(quill), false);
|
|
@@ -108,7 +111,7 @@ class BetterTable extends Module {
|
|
|
108
111
|
return matcher[0] !== "tr";
|
|
109
112
|
});
|
|
110
113
|
quill.clipboard.addMatcher("tr", matchTableRow);
|
|
111
|
-
this.quill.on(
|
|
114
|
+
this.quill.on(Quill.events.EDITOR_CHANGE, () => {
|
|
112
115
|
const tableContainer = Quill.find(this.table);
|
|
113
116
|
if (!tableContainer) {
|
|
114
117
|
this.hideTableTools();
|
|
@@ -137,6 +140,32 @@ class BetterTable extends Module {
|
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
});
|
|
143
|
+
this.initTableSelector();
|
|
144
|
+
}
|
|
145
|
+
initTableSelector() {
|
|
146
|
+
const toolbar = this.quill.getModule("toolbar");
|
|
147
|
+
if (!toolbar) return;
|
|
148
|
+
const tableButton = toolbar.container.querySelector(".ql-better-table");
|
|
149
|
+
if (!tableButton) return;
|
|
150
|
+
const tableSelectorWrapper = this.tableSelectorWrapperCreator();
|
|
151
|
+
tableButton.parentNode.insertBefore(tableSelectorWrapper, tableButton);
|
|
152
|
+
tableSelectorWrapper.appendChild(tableButton);
|
|
153
|
+
this.tableSelectorWrapper = tableSelectorWrapper;
|
|
154
|
+
tableSelectorWrapper.addEventListener("mouseenter", this.handleTableSelectorHover.bind(this), false);
|
|
155
|
+
tableSelectorWrapper.addEventListener("mouseleave", this.handleTableSelectorMouseOut.bind(this), false);
|
|
156
|
+
}
|
|
157
|
+
tableSelectorWrapperCreator() {
|
|
158
|
+
const wrapper = document.createElement("div");
|
|
159
|
+
wrapper.className = "ql-better-table-wrapper";
|
|
160
|
+
const cssContent = {
|
|
161
|
+
position: "relative",
|
|
162
|
+
display: "flex",
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
justifyContent: "center",
|
|
165
|
+
boxSizing: "border-box"
|
|
166
|
+
};
|
|
167
|
+
css(wrapper, cssContent);
|
|
168
|
+
return wrapper;
|
|
140
169
|
}
|
|
141
170
|
handleMouseDown(evt, quill) {
|
|
142
171
|
const path = getEventComposedPath(evt);
|
|
@@ -205,6 +234,29 @@ class BetterTable extends Module {
|
|
|
205
234
|
}
|
|
206
235
|
this.isComposition = false;
|
|
207
236
|
}
|
|
237
|
+
// 触发table selector
|
|
238
|
+
handleTableSelectorHover() {
|
|
239
|
+
if (this.isTableSelectorVisible) return;
|
|
240
|
+
if (!this.tableSelectorWrapper) return;
|
|
241
|
+
this.isTableSelectorVisible = true;
|
|
242
|
+
this.tableSelector = new TableSelector({
|
|
243
|
+
onSelect: (rows, cols) => this.insertTable(rows, cols)
|
|
244
|
+
});
|
|
245
|
+
this.tableSelectorWrapper.appendChild(this.tableSelector.container);
|
|
246
|
+
const buttonRect = this.tableSelectorWrapper.getBoundingClientRect();
|
|
247
|
+
this.tableSelector.show(
|
|
248
|
+
0,
|
|
249
|
+
buttonRect.height
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
// table selector 鼠标离开
|
|
253
|
+
handleTableSelectorMouseOut() {
|
|
254
|
+
if (this.tableSelector) {
|
|
255
|
+
this.tableSelector.destroy();
|
|
256
|
+
}
|
|
257
|
+
this.tableSelector = null;
|
|
258
|
+
this.isTableSelectorVisible = false;
|
|
259
|
+
}
|
|
208
260
|
getTable(range = this.quill.getSelection()) {
|
|
209
261
|
if (isNullOrUndefined(range)) return [null, null, null, -1];
|
|
210
262
|
const [cellLine, offset] = this.quill.getLine(range.index);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"better-table.es.js","sources":["../../../src/table/better-table.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport {\r\n getEventComposedPath,\r\n insideTable,\r\n isNullOrUndefined,\r\n isPureIE,\r\n} from '../config/editor.utils'\r\nimport Header from './formats/header'\r\nimport List from './formats/list'\r\nimport {\r\n cellId,\r\n rowId,\r\n TableBody,\r\n TableCell,\r\n TableCellLine,\r\n TableCol,\r\n TableColGroup,\r\n TableContainer,\r\n TableRow,\r\n TableViewWrapper,\r\n} from './formats/table'\r\nimport TableColumnTool from './modules/table-column-tool'\r\nimport TableOperationMenu from './modules/table-operation-menu'\r\nimport TableScrollBar from './modules/table-scroll-bar'\r\nimport TableSelection from './modules/table-selection'\r\n// import table node matchers\r\nimport {\r\n matchHeader,\r\n matchInline,\r\n matchList,\r\n matchMentionLink,\r\n matchTable,\r\n matchTableCell,\r\n matchTableHeader,\r\n matchTableRow,\r\n matchWordShapeImage,\r\n} from './utils/node-matchers'\r\n\r\nconst Block = Quill.imports['blots/block']\r\nconst Delta = Quill.imports.delta\r\nconst Module = Quill.imports['core/module']\r\n\r\n// @dynamic\r\nclass BetterTable extends Module {\r\n static keyboardBindings: any\r\n isComposition: boolean\r\n quill: any\r\n table: any\r\n modulesContainer: any\r\n tableSelection: any\r\n subscriber: any\r\n tableOperationMenu: any\r\n columnTool: TableColumnTool\r\n tableScrollBar: TableScrollBar\r\n\r\n static register() {\r\n Quill.register(TableCol, true)\r\n Quill.register(TableColGroup, true)\r\n Quill.register(TableCellLine, true)\r\n Quill.register(TableCell, true)\r\n Quill.register(TableRow, true)\r\n Quill.register(TableBody, true)\r\n Quill.register(TableContainer, true)\r\n Quill.register(TableViewWrapper, true)\r\n // register customized Header, overwriting quill built-in Header\r\n Quill.register('formats/header', Header, true)\r\n // register customized List, overwriting quill built-in Header\r\n Quill.register('formats/list', List, true)\r\n }\r\n\r\n constructor(quill, options) {\r\n super(quill, options)\r\n\r\n // handle click on quill-better-table\r\n this.isComposition = false\r\n this.quill.root.addEventListener('mousedown', event => this.handleMouseDown(event, quill), false)\r\n this.quill.root.addEventListener('compositionend', () => this.handleCompositionend(quill), false)\r\n this.quill.root.addEventListener('compositionstart', () => this.handleCompositionstart(quill), false)\r\n this.quill.root.addEventListener('keypress', event => this.handleKeyDown(event, quill), false)\r\n\r\n // handle right click on quill-better-table\r\n this.quill.root.addEventListener(\r\n 'contextmenu',\r\n (evt) => {\r\n if (!this.table) return true\r\n evt.preventDefault()\r\n\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n\r\n const tableNode = path.filter((node) => {\r\n return (\r\n node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n )\r\n })[0]\r\n\r\n const rowNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const cellNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const isTargetCellSelected = this.tableSelection.selectedTds\r\n .map(tableCell => tableCell.domNode)\r\n .includes(cellNode)\r\n\r\n if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) {\r\n this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect())\r\n }\r\n\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu = this.tableOperationMenu.destroy()\r\n }\r\n\r\n if (tableNode) {\r\n this.tableOperationMenu = new TableOperationMenu(\r\n {\r\n table: tableNode,\r\n row: rowNode,\r\n cell: cellNode,\r\n left: evt.x + 15,\r\n top: evt.y,\r\n },\r\n quill,\r\n options.operationMenu,\r\n )\r\n }\r\n },\r\n false,\r\n )\r\n\r\n // add keyboard binding:Backspace\r\n // prevent user hits backspace to delete table cell\r\n quill.keyboard.addBinding({ key: 'Backspace' }, {}, (range, context) => {\r\n if (range.index === 0 || this.quill.getLength() <= 1) return true\r\n if (context.offset === 0 && range.length === 0) {\r\n const [prev] = this.quill.getLine(range.index - 1)\r\n const [line] = this.quill.getLine(range.index)\r\n if (!isNullOrUndefined(prev)) {\r\n if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = prev.parent.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n return false\r\n }\r\n }\r\n }\r\n return true\r\n })\r\n // since only one matched bindings callback will execute.\r\n // expected my binding callback execute first\r\n // I changed the order of binding callbacks\r\n const thisBinding = quill.keyboard.bindings.Backspace.pop()\r\n quill.keyboard.bindings.Backspace.splice(1, 0, thisBinding)\r\n\r\n // add Matchers to match and render quill-better-table for initialization\r\n // or pasting\r\n quill.clipboard.addMatcher('td', matchTableCell)\r\n quill.clipboard.addMatcher('th', matchTableHeader)\r\n quill.clipboard.addMatcher('table', matchTable)\r\n quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader)\r\n quill.clipboard.addMatcher('ol, ul', matchList)\r\n quill.clipboard.addMatcher('span', matchMentionLink)\r\n quill.clipboard.addMatcher('v:imageData', matchWordShapeImage)\r\n quill.clipboard.addMatcher(Node.ELEMENT_NODE, matchInline)\r\n\r\n // remove matcher for tr tag\r\n quill.clipboard.matchers = quill.clipboard.matchers.filter((matcher) => {\r\n return matcher[0] !== 'tr'\r\n })\r\n\r\n // fix: 处理空<tr>标签被忽略的情况\r\n quill.clipboard.addMatcher('tr', matchTableRow)\r\n\r\n this.quill.on('editor-change', () => {\r\n const tableContainer = Quill.find(this.table)\r\n if (!tableContainer) {\r\n this.hideTableTools()\r\n }\r\n })\r\n\r\n this.quill.on(Quill.events.SELECTION_CHANGE, (range, _oldRange, source) => {\r\n if (!range) return\r\n const selectionStart = range.index\r\n const selectionEnd = range.index + range.length\r\n if (source === Quill.sources.USER) {\r\n const tables = this.quill.root.getElementsByTagName('table')\r\n if (tables && tables.length) {\r\n [].forEach.call(tables, (table) => {\r\n const tableContainer = Quill.find(table)\r\n if (tableContainer) {\r\n const tableStart = tableContainer.offset(this.quill.scroll)\r\n const tableEnd = tableStart + tableContainer.length()\r\n // @ts-ignore\r\n const classes = Array.from(table.parentNode.classList)\r\n\r\n if (selectionStart <= tableStart && tableEnd <= selectionEnd) {\r\n // @ts-ignore\r\n table.parentNode.classList.add('quill-better-table-selected')\r\n }\r\n else if (classes.includes('quill-better-table-selected')) {\r\n // @ts-ignore\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n }\r\n }\r\n })\r\n }\r\n }\r\n })\r\n }\r\n\r\n handleMouseDown(evt, quill) {\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n const tableNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n })[0]\r\n if (tableNode) {\r\n tableNode.parentNode.classList.remove('quill-better-table-selected')\r\n // current table clicked\r\n if (this.table === tableNode) return\r\n // other table clicked\r\n if (this.table) {\r\n this.hideTableTools()\r\n }\r\n if (!quill.options.readOnly) { // not show table tool in readonly mode\r\n this.showTableTools(tableNode, quill)\r\n }\r\n }\r\n else if (this.table) {\r\n // other clicked\r\n this.hideTableTools()\r\n }\r\n }\r\n\r\n handleKeyDown(evt, quill) {\r\n const key = evt.key\r\n const range = quill.getSelection()\r\n if (this.isComposition || !range) return\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (key && key !== 'Delete' && col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.insertText(range.index, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionstart(quill) {\r\n this.isComposition = true\r\n const range = quill.getSelection()\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n\\t', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionend(quill) {\r\n // fix: 解决在空行行首用中文输入法输入字符,然后按退格导致插入多余空行的问题\r\n const range = quill.getSelection()\r\n const [line] = quill.getLine(range.index)\r\n const domNode = line.domNode\r\n const isInParagraph = domNode.nodeName === 'P'\r\n const isInTableCell = line.statics.blotName === 'table-cell-line'\r\n if ((isInParagraph || isInTableCell)\r\n && domNode.childNodes.length > 1\r\n && domNode.childNodes[0].nodeName === 'BR') {\r\n domNode.childNodes[0].remove()\r\n }\r\n\r\n if (isPureIE && line instanceof Block) {\r\n // 设置光标位置防止跳入下一行\r\n quill.setSelection(range.index, 0, Quill.sources.SILENT)\r\n }\r\n\r\n this.isComposition = false\r\n }\r\n\r\n getTable(range = this.quill.getSelection()) {\r\n if (isNullOrUndefined(range)) return [null, null, null, -1]\r\n const [cellLine, offset] = this.quill.getLine(range.index)\r\n if (isNullOrUndefined(cellLine) || cellLine.statics.blotName !== TableCellLine.blotName) {\r\n return [null, null, null, -1]\r\n }\r\n const cell = cellLine.tableCell()\r\n const row = cell.row()\r\n const table = row.table()\r\n return [table, row, cell, offset]\r\n }\r\n\r\n insertTable(rows, columns) {\r\n const range = this.quill.getSelection(true)\r\n const isInsideTable = insideTable(range, this.quill)\r\n if (isNullOrUndefined(range) || isInsideTable) return\r\n // let currentBlot = this.quill.getLeaf(range.index)[0]\r\n // let nextBlot = this.quill.getLeaf(range.index + 1)[0]\r\n let delta = new Delta().retain(range.index)\r\n\r\n delta.insert('\\n')\r\n // insert table column\r\n delta = new Array(columns).fill('\\n').reduce((memo, text) => {\r\n memo.insert(text, { 'table-col': true })\r\n return memo\r\n }, delta)\r\n // insert table cell line with empty line\r\n delta = new Array(rows).fill(0).reduce((memo) => {\r\n const tableRowId = rowId()\r\n return new Array(columns).fill('\\n').reduce((op, text) => {\r\n op.insert(text, { 'table-cell-line': { row: tableRowId, cell: cellId() } })\r\n return op\r\n }, memo)\r\n }, delta)\r\n\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n delta.insert('\\n')\r\n }\r\n\r\n this.quill.updateContents(delta, Quill.sources.USER)\r\n\r\n // feature: 新增表格后首格自动激活编辑状态,initEvent兼容IE\r\n const [cellLine] = this.quill.getLine(range.index + columns + 1)\r\n if (cellLine) {\r\n const cell = cellLine.tableCell()\r\n const td = cell.domNode\r\n const mousedownEvent = document.createEvent('MouseEvent')\r\n const mouseupEvent = document.createEvent('MouseEvent')\r\n const keyEvent = document.createEvent('Event')\r\n mousedownEvent.initEvent('mousedown', true, false)\r\n mouseupEvent.initEvent('mouseup', true, false)\r\n keyEvent.initEvent('keypress', true, false)\r\n td.dispatchEvent(mousedownEvent)\r\n td.dispatchEvent(mouseupEvent)\r\n td.dispatchEvent(keyEvent)\r\n this.tableSelection.endTd = td\r\n }\r\n }\r\n\r\n showTableTools(table, quill) {\r\n this.table = table\r\n this.modulesContainer = document.createElement('div')\r\n this.modulesContainer.classList.add('qlbt-modules-container')\r\n // fix:表格容器插入时获取ql-tooltip容器,用insertBefore插入到它前面,避免遮挡链接浮窗\r\n const linkContainer = this.quill.root.parentNode.querySelector('.ql-tooltip ')\r\n this.quill.root.parentNode.insertBefore(this.modulesContainer, linkContainer)\r\n this.tableSelection = new TableSelection(table, quill, this.modulesContainer)\r\n this.columnTool = new TableColumnTool(table, quill, this.modulesContainer)\r\n this.tableScrollBar = new TableScrollBar(table, quill, this.modulesContainer)\r\n let timeoutID\r\n this.subscriber = () => {\r\n clearTimeout(timeoutID)\r\n timeoutID = setTimeout(this.hideTableTools, 300)\r\n }\r\n window.addEventListener('resize', this.subscriber, false)\r\n }\r\n\r\n hideTableTools() {\r\n if (this.columnTool) {\r\n this.columnTool.destroy()\r\n }\r\n if (this.tableSelection) {\r\n this.tableSelection.destroy()\r\n }\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu.destroy()\r\n }\r\n if (this.tableScrollBar) {\r\n this.tableScrollBar.destroy()\r\n }\r\n if (this.modulesContainer) {\r\n this.modulesContainer.remove()\r\n }\r\n this.columnTool = null\r\n this.tableSelection = null\r\n this.tableOperationMenu = null\r\n this.tableScrollBar = null\r\n this.modulesContainer = null\r\n this.table = null\r\n if (this.subscriber) {\r\n window.removeEventListener('resize', this.subscriber)\r\n }\r\n }\r\n}\r\n\r\nBetterTable.keyboardBindings = {\r\n 'line delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: { 'table-col': false, 'table-cell-line': false },\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n // fix: 当光标在编辑器最前且之后为表格时按delete不执行操作\r\n if (range.index === 0 && context.line.next && context.line.next.statics.blotName === 'table-view') {\r\n const [p] = this.quill.getLine(range.index - 1)\r\n const [col] = this.quill.getLine(range.index + 1)\r\n if (p && p.statics.blotName === 'block' && col && col.statics.blotName === 'table-col') {\r\n return false\r\n }\r\n }\r\n return true\r\n },\r\n },\r\n 'table-col enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n this.quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n this.quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n },\r\n },\r\n 'table-col delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = col.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n }\r\n }\r\n },\r\n },\r\n 'table-col backspace': {\r\n key: 'Backspace',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler() { },\r\n },\r\n 'table-cell-line backspace': {\r\n key: 'Backspace',\r\n format: ['table-cell-line'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range) {\r\n const [line] = this.quill.getLine(range.index)\r\n // 移除原有对非table-cell-line的阻止条件,使table-cell-line前的list等内容可以被删除\r\n if (!line.prev) {\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line delete': {\r\n key: 'Delete',\r\n format: ['table-cell-line'],\r\n handler(range, _context) {\r\n // 获取table-cell-line的索引和长度\r\n const [line] = this.quill.getLine(range.index)\r\n const index = this.quill.getIndex(line)\r\n const length = line.length()\r\n if (!line.next // 当无下一个元素且满足以下情况阻止删除操作\r\n && ((!line.prev && length === 1) // 单元格内只有一个table-cell-line且无内容\r\n || (range.index !== index && range.index + 1 >= index + length))) { // 光标在有内容的table-cell-line最后\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-cell-line'],\r\n handler(range, context) {\r\n // fix:通过window的光标选区当前指向判断,如果为HTMLElement且为表格容器则定位至下一行\r\n const node = window.getSelection().anchorNode\r\n if (node instanceof HTMLDivElement && node.classList.contains('quill-better-table-wrapper')) {\r\n this.quill.setSelection(range.index + 1, 0, Quill.sources.USER)\r\n this.quill.focus()\r\n return\r\n }\r\n // bugfix: a unexpected new line inserted when user compositionend with hitting Enter\r\n if (this.quill.selection && this.quill.selection.composing) return\r\n const Scope = Quill.imports.parchment.Scope\r\n if (range.length > 0) {\r\n this.quill.scroll.deleteAt(range.index, range.length) // So we do not trigger text-change\r\n }\r\n const lineFormats = Object.keys(context.format).reduce((formats, format) => {\r\n if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) {\r\n formats[format] = context.format[format]\r\n }\r\n return formats\r\n }, {})\r\n // insert new cellLine with lineFormats\r\n this.quill.insertText(range.index, '\\n', lineFormats['table-cell-line'], Quill.sources.USER)\r\n // Earlier scroll.deleteAt might have messed up our selection,\r\n // so insertText's built in selection preservation is not reliable\r\n this.quill.setSelection(range.index + 1, Quill.sources.SILENT)\r\n this.quill.focus()\r\n Object.keys(context.format).forEach((name) => {\r\n if (!isNullOrUndefined(lineFormats[name])) return\r\n if (Array.isArray(context.format[name])) return\r\n if (name === 'link') return\r\n this.quill.format(name, context.format[name], Quill.sources.USER)\r\n })\r\n },\r\n },\r\n}\r\n\r\nexport default BetterTable\r\n"],"names":["List"],"mappings":";;;;;;;;;;AAsCA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,MAAM,QAAQ,MAAM,QAAQ;AAC5B,MAAM,SAAS,MAAM,QAAQ,aAAa;AAG1C,MAAM,oBAAoB,OAAO;AAAA,EAY/B,OAAO,WAAW;AACV,UAAA,SAAS,UAAU,IAAI;AACvB,UAAA,SAAS,eAAe,IAAI;AAC5B,UAAA,SAAS,eAAe,IAAI;AAC5B,UAAA,SAAS,WAAW,IAAI;AACxB,UAAA,SAAS,UAAU,IAAI;AACvB,UAAA,SAAS,WAAW,IAAI;AACxB,UAAA,SAAS,gBAAgB,IAAI;AAC7B,UAAA,SAAS,kBAAkB,IAAI;AAE/B,UAAA,SAAS,kBAAkB,QAAQ,IAAI;AAEvC,UAAA,SAAS,gBAAgBA,UAAM,IAAI;AAAA,EAC3C;AAAA,EAEA,YAAY,OAAO,SAAS;AAC1B,UAAM,OAAO,OAAO;AAGpB,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AQ,OAAO,MAAM,CAAC,GAAG;AAC1F,kBAAQ,MAAM,IAAI,QAAQ,OAAO,MAAM;AAAA,QACzC;AACO,eAAA;AAAA,MACT,GAAG,CAAE,CAAA;AAEA,WAAA,MAAM,WAAW,MAAM,OAAO,MAAM,YAAY,iBAAiB,GAAG,MAAM,QAAQ,IAAI;AAG3F,WAAK,MAAM,aAAa,MAAM,QAAQ,GAAG,MAAM,QAAQ,MAAM;AAC7D,WAAK,MAAM;AACX,aAAO,KAAK,QAAQ,MAAM,EAAE,QAAQ,CAAC,SAAS;AAC5C,YAAI,CAAC,kBAAkB,YAAY,IAAI,CAAC,EAAG;AAC3C,YAAI,MAAM,QAAQ,QAAQ,OAAO,IAAI,CAAC,EAAG;AACzC,YAAI,SAAS,OAAQ;AAChB,aAAA,MAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,GAAG,MAAM,QAAQ,IAAI;AAAA,MAAA,CACjE;AAAA,IACH;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"better-table.es.js","sources":["../../../src/table/better-table.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport {\r\n getEventComposedPath,\r\n insideTable,\r\n isNullOrUndefined,\r\n isPureIE,\r\n} from '../config/editor.utils'\r\nimport Header from './formats/header'\r\nimport List from './formats/list'\r\nimport {\r\n cellId,\r\n rowId,\r\n TableBody,\r\n TableCell,\r\n TableCellLine,\r\n TableCol,\r\n TableColGroup,\r\n TableContainer,\r\n TableRow,\r\n TableViewWrapper,\r\n} from './formats/table'\r\nimport TableColumnTool from './modules/table-column-tool'\r\nimport TableOperationMenu from './modules/table-operation-menu'\r\nimport TableScrollBar from './modules/table-scroll-bar'\r\nimport TableSelection from './modules/table-selection'\r\nimport TableSelector from './modules/table-selector'\r\nimport { css } from './utils'\r\n// import table node matchers\r\nimport {\r\n matchHeader,\r\n matchInline,\r\n matchList,\r\n matchMentionLink,\r\n matchTable,\r\n matchTableCell,\r\n matchTableHeader,\r\n matchTableRow,\r\n matchWordShapeImage,\r\n} from './utils/node-matchers'\r\n\r\nconst Block = Quill.imports['blots/block']\r\nconst Delta = Quill.imports.delta\r\nconst Module = Quill.imports['core/module']\r\n\r\n// @dynamic\r\nclass BetterTable extends Module {\r\n static keyboardBindings: any\r\n isComposition: boolean\r\n quill: any\r\n table: any\r\n modulesContainer: any\r\n tableSelection: any\r\n subscriber: any\r\n tableOperationMenu: any\r\n columnTool: TableColumnTool\r\n tableScrollBar: TableScrollBar\r\n tableSelector: TableSelector\r\n isTableSelectorVisible: boolean\r\n tableSelectorWrapper: HTMLDivElement\r\n\r\n static register() {\r\n Quill.register(TableCol, true)\r\n Quill.register(TableColGroup, true)\r\n Quill.register(TableCellLine, true)\r\n Quill.register(TableCell, true)\r\n Quill.register(TableRow, true)\r\n Quill.register(TableBody, true)\r\n Quill.register(TableContainer, true)\r\n Quill.register(TableViewWrapper, true)\r\n // register customized Header, overwriting quill built-in Header\r\n Quill.register('formats/header', Header, true)\r\n // register customized List, overwriting quill built-in Header\r\n Quill.register('formats/list', List, true)\r\n }\r\n\r\n constructor(quill, options) {\r\n super(quill, options)\r\n\r\n // handle click on quill-better-table\r\n this.isComposition = false\r\n this.isTableSelectorVisible = false\r\n this.quill.root.addEventListener('mousedown', event => this.handleMouseDown(event, quill), false)\r\n this.quill.root.addEventListener('compositionend', () => this.handleCompositionend(quill), false)\r\n this.quill.root.addEventListener('compositionstart', () => this.handleCompositionstart(quill), false)\r\n this.quill.root.addEventListener('keypress', event => this.handleKeyDown(event, quill), false)\r\n\r\n // handle right click on quill-better-table\r\n this.quill.root.addEventListener(\r\n 'contextmenu',\r\n (evt) => {\r\n if (!this.table) return true\r\n evt.preventDefault()\r\n\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n\r\n const tableNode = path.filter((node) => {\r\n return (\r\n node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n )\r\n })[0]\r\n\r\n const rowNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const cellNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const isTargetCellSelected = this.tableSelection.selectedTds\r\n .map(tableCell => tableCell.domNode)\r\n .includes(cellNode)\r\n\r\n if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) {\r\n this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect())\r\n }\r\n\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu = this.tableOperationMenu.destroy()\r\n }\r\n\r\n if (tableNode) {\r\n this.tableOperationMenu = new TableOperationMenu(\r\n {\r\n table: tableNode,\r\n row: rowNode,\r\n cell: cellNode,\r\n left: evt.x + 15,\r\n top: evt.y,\r\n },\r\n quill,\r\n options.operationMenu,\r\n )\r\n }\r\n },\r\n false,\r\n )\r\n\r\n // add keyboard binding:Backspace\r\n // prevent user hits backspace to delete table cell\r\n quill.keyboard.addBinding({ key: 'Backspace' }, {}, (range, context) => {\r\n if (range.index === 0 || this.quill.getLength() <= 1) return true\r\n if (context.offset === 0 && range.length === 0) {\r\n const [prev] = this.quill.getLine(range.index - 1)\r\n const [line] = this.quill.getLine(range.index)\r\n if (!isNullOrUndefined(prev)) {\r\n if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = prev.parent.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n return false\r\n }\r\n }\r\n }\r\n return true\r\n })\r\n // since only one matched bindings callback will execute.\r\n // expected my binding callback execute first\r\n // I changed the order of binding callbacks\r\n const thisBinding = quill.keyboard.bindings.Backspace.pop()\r\n quill.keyboard.bindings.Backspace.splice(1, 0, thisBinding)\r\n\r\n // add Matchers to match and render quill-better-table for initialization\r\n // or pasting\r\n quill.clipboard.addMatcher('td', matchTableCell)\r\n quill.clipboard.addMatcher('th', matchTableHeader)\r\n quill.clipboard.addMatcher('table', matchTable)\r\n quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader)\r\n quill.clipboard.addMatcher('ol, ul', matchList)\r\n quill.clipboard.addMatcher('span', matchMentionLink)\r\n quill.clipboard.addMatcher('v:imageData', matchWordShapeImage)\r\n quill.clipboard.addMatcher(Node.ELEMENT_NODE, matchInline)\r\n\r\n // remove matcher for tr tag\r\n quill.clipboard.matchers = quill.clipboard.matchers.filter((matcher) => {\r\n return matcher[0] !== 'tr'\r\n })\r\n\r\n // fix: 处理空<tr>标签被忽略的情况\r\n quill.clipboard.addMatcher('tr', matchTableRow)\r\n\r\n this.quill.on(Quill.events.EDITOR_CHANGE, () => {\r\n const tableContainer = Quill.find(this.table)\r\n if (!tableContainer) {\r\n this.hideTableTools()\r\n }\r\n })\r\n\r\n this.quill.on(Quill.events.SELECTION_CHANGE, (range, _oldRange, source) => {\r\n if (!range) return\r\n const selectionStart = range.index\r\n const selectionEnd = range.index + range.length\r\n if (source === Quill.sources.USER) {\r\n const tables = this.quill.root.getElementsByTagName('table')\r\n if (tables && tables.length) {\r\n [].forEach.call(tables, (table) => {\r\n const tableContainer = Quill.find(table)\r\n if (tableContainer) {\r\n const tableStart = tableContainer.offset(this.quill.scroll)\r\n const tableEnd = tableStart + tableContainer.length()\r\n // @ts-ignore\r\n const classes = Array.from(table.parentNode.classList)\r\n\r\n if (selectionStart <= tableStart && tableEnd <= selectionEnd) {\r\n // @ts-ignore\r\n table.parentNode.classList.add('quill-better-table-selected')\r\n }\r\n else if (classes.includes('quill-better-table-selected')) {\r\n // @ts-ignore\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n }\r\n }\r\n })\r\n }\r\n }\r\n })\r\n this.initTableSelector()\r\n }\r\n\r\n initTableSelector() {\r\n // feat table selector ,在better-table按钮上套一层容器,往容器添加table selector\r\n const toolbar = this.quill.getModule('toolbar')\r\n if (!toolbar) return\r\n const tableButton = toolbar.container.querySelector('.ql-better-table')\r\n if (!tableButton) return\r\n const tableSelectorWrapper = this.tableSelectorWrapperCreator()\r\n tableButton.parentNode.insertBefore(tableSelectorWrapper, tableButton)\r\n tableSelectorWrapper.appendChild(tableButton)\r\n this.tableSelectorWrapper = tableSelectorWrapper\r\n tableSelectorWrapper.addEventListener('mouseenter', this.handleTableSelectorHover.bind(this), false)\r\n tableSelectorWrapper.addEventListener('mouseleave', this.handleTableSelectorMouseOut.bind(this), false)\r\n }\r\n\r\n tableSelectorWrapperCreator() {\r\n const wrapper = document.createElement('div')\r\n wrapper.className = 'ql-better-table-wrapper'\r\n const cssContent = {\r\n position: 'relative',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n boxSizing: 'border-box',\r\n }\r\n css(wrapper, cssContent)\r\n return wrapper\r\n }\r\n\r\n handleMouseDown(evt, quill) {\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n const tableNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n })[0]\r\n if (tableNode) {\r\n tableNode.parentNode.classList.remove('quill-better-table-selected')\r\n // current table clicked\r\n if (this.table === tableNode) return\r\n // other table clicked\r\n if (this.table) {\r\n this.hideTableTools()\r\n }\r\n if (!quill.options.readOnly) { // not show table tool in readonly mode\r\n this.showTableTools(tableNode, quill)\r\n }\r\n }\r\n else if (this.table) {\r\n // other clicked\r\n this.hideTableTools()\r\n }\r\n }\r\n\r\n handleKeyDown(evt, quill) {\r\n const key = evt.key\r\n const range = quill.getSelection()\r\n if (this.isComposition || !range) return\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (key && key !== 'Delete' && col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.insertText(range.index, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionstart(quill) {\r\n this.isComposition = true\r\n const range = quill.getSelection()\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n\\t', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionend(quill) {\r\n // fix: 解决在空行行首用中文输入法输入字符,然后按退格导致插入多余空行的问题\r\n const range = quill.getSelection()\r\n const [line] = quill.getLine(range.index)\r\n const domNode = line.domNode\r\n const isInParagraph = domNode.nodeName === 'P'\r\n const isInTableCell = line.statics.blotName === 'table-cell-line'\r\n if ((isInParagraph || isInTableCell)\r\n && domNode.childNodes.length > 1\r\n && domNode.childNodes[0].nodeName === 'BR') {\r\n domNode.childNodes[0].remove()\r\n }\r\n\r\n if (isPureIE && line instanceof Block) {\r\n // 设置光标位置防止跳入下一行\r\n quill.setSelection(range.index, 0, Quill.sources.SILENT)\r\n }\r\n\r\n this.isComposition = false\r\n }\r\n\r\n // 触发table selector\r\n handleTableSelectorHover() {\r\n if (this.isTableSelectorVisible) return\r\n if (!this.tableSelectorWrapper) return\r\n this.isTableSelectorVisible = true\r\n this.tableSelector = new TableSelector({\r\n onSelect: (rows, cols) => this.insertTable(rows, cols),\r\n })\r\n this.tableSelectorWrapper.appendChild(this.tableSelector.container)\r\n const buttonRect = this.tableSelectorWrapper.getBoundingClientRect()\r\n this.tableSelector.show(\r\n 0,\r\n buttonRect.height,\r\n )\r\n }\r\n\r\n // table selector 鼠标离开\r\n handleTableSelectorMouseOut() {\r\n if (this.tableSelector) {\r\n this.tableSelector.destroy()\r\n }\r\n this.tableSelector = null\r\n this.isTableSelectorVisible = false\r\n }\r\n\r\n getTable(range = this.quill.getSelection()) {\r\n if (isNullOrUndefined(range)) return [null, null, null, -1]\r\n const [cellLine, offset] = this.quill.getLine(range.index)\r\n if (isNullOrUndefined(cellLine) || cellLine.statics.blotName !== TableCellLine.blotName) {\r\n return [null, null, null, -1]\r\n }\r\n const cell = cellLine.tableCell()\r\n const row = cell.row()\r\n const table = row.table()\r\n return [table, row, cell, offset]\r\n }\r\n\r\n insertTable(rows, columns) {\r\n const range = this.quill.getSelection(true)\r\n const isInsideTable = insideTable(range, this.quill)\r\n if (isNullOrUndefined(range) || isInsideTable) return\r\n // let currentBlot = this.quill.getLeaf(range.index)[0]\r\n // let nextBlot = this.quill.getLeaf(range.index + 1)[0]\r\n let delta = new Delta().retain(range.index)\r\n\r\n delta.insert('\\n')\r\n // insert table column\r\n delta = new Array(columns).fill('\\n').reduce((memo, text) => {\r\n memo.insert(text, { 'table-col': true })\r\n return memo\r\n }, delta)\r\n // insert table cell line with empty line\r\n delta = new Array(rows).fill(0).reduce((memo) => {\r\n const tableRowId = rowId()\r\n return new Array(columns).fill('\\n').reduce((op, text) => {\r\n op.insert(text, { 'table-cell-line': { row: tableRowId, cell: cellId() } })\r\n return op\r\n }, memo)\r\n }, delta)\r\n\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n delta.insert('\\n')\r\n }\r\n\r\n this.quill.updateContents(delta, Quill.sources.USER)\r\n\r\n // feature: 新增表格后首格自动激活编辑状态,initEvent兼容IE\r\n const [cellLine] = this.quill.getLine(range.index + columns + 1)\r\n if (cellLine) {\r\n const cell = cellLine.tableCell()\r\n const td = cell.domNode\r\n const mousedownEvent = document.createEvent('MouseEvent')\r\n const mouseupEvent = document.createEvent('MouseEvent')\r\n const keyEvent = document.createEvent('Event')\r\n mousedownEvent.initEvent('mousedown', true, false)\r\n mouseupEvent.initEvent('mouseup', true, false)\r\n keyEvent.initEvent('keypress', true, false)\r\n td.dispatchEvent(mousedownEvent)\r\n td.dispatchEvent(mouseupEvent)\r\n td.dispatchEvent(keyEvent)\r\n this.tableSelection.endTd = td\r\n }\r\n }\r\n\r\n showTableTools(table, quill) {\r\n this.table = table\r\n this.modulesContainer = document.createElement('div')\r\n this.modulesContainer.classList.add('qlbt-modules-container')\r\n // fix:表格容器插入时获取ql-tooltip容器,用insertBefore插入到它前面,避免遮挡链接浮窗\r\n const linkContainer = this.quill.root.parentNode.querySelector('.ql-tooltip ')\r\n this.quill.root.parentNode.insertBefore(this.modulesContainer, linkContainer)\r\n this.tableSelection = new TableSelection(table, quill, this.modulesContainer)\r\n this.columnTool = new TableColumnTool(table, quill, this.modulesContainer)\r\n this.tableScrollBar = new TableScrollBar(table, quill, this.modulesContainer)\r\n let timeoutID\r\n this.subscriber = () => {\r\n clearTimeout(timeoutID)\r\n timeoutID = setTimeout(this.hideTableTools, 300)\r\n }\r\n window.addEventListener('resize', this.subscriber, false)\r\n }\r\n\r\n hideTableTools() {\r\n if (this.columnTool) {\r\n this.columnTool.destroy()\r\n }\r\n if (this.tableSelection) {\r\n this.tableSelection.destroy()\r\n }\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu.destroy()\r\n }\r\n if (this.tableScrollBar) {\r\n this.tableScrollBar.destroy()\r\n }\r\n if (this.modulesContainer) {\r\n this.modulesContainer.remove()\r\n }\r\n this.columnTool = null\r\n this.tableSelection = null\r\n this.tableOperationMenu = null\r\n this.tableScrollBar = null\r\n this.modulesContainer = null\r\n this.table = null\r\n if (this.subscriber) {\r\n window.removeEventListener('resize', this.subscriber)\r\n }\r\n }\r\n}\r\n\r\nBetterTable.keyboardBindings = {\r\n 'line delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: { 'table-col': false, 'table-cell-line': false },\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n // fix: 当光标在编辑器最前且之后为表格时按delete不执行操作\r\n if (range.index === 0 && context.line.next && context.line.next.statics.blotName === 'table-view') {\r\n const [p] = this.quill.getLine(range.index - 1)\r\n const [col] = this.quill.getLine(range.index + 1)\r\n if (p && p.statics.blotName === 'block' && col && col.statics.blotName === 'table-col') {\r\n return false\r\n }\r\n }\r\n return true\r\n },\r\n },\r\n 'table-col enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n this.quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n this.quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n },\r\n },\r\n 'table-col delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = col.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n }\r\n }\r\n },\r\n },\r\n 'table-col backspace': {\r\n key: 'Backspace',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler() { },\r\n },\r\n 'table-cell-line backspace': {\r\n key: 'Backspace',\r\n format: ['table-cell-line'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range) {\r\n const [line] = this.quill.getLine(range.index)\r\n // 移除原有对非table-cell-line的阻止条件,使table-cell-line前的list等内容可以被删除\r\n if (!line.prev) {\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line delete': {\r\n key: 'Delete',\r\n format: ['table-cell-line'],\r\n handler(range, _context) {\r\n // 获取table-cell-line的索引和长度\r\n const [line] = this.quill.getLine(range.index)\r\n const index = this.quill.getIndex(line)\r\n const length = line.length()\r\n if (!line.next // 当无下一个元素且满足以下情况阻止删除操作\r\n && ((!line.prev && length === 1) // 单元格内只有一个table-cell-line且无内容\r\n || (range.index !== index && range.index + 1 >= index + length))) { // 光标在有内容的table-cell-line最后\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-cell-line'],\r\n handler(range, context) {\r\n // fix:通过window的光标选区当前指向判断,如果为HTMLElement且为表格容器则定位至下一行\r\n const node = window.getSelection().anchorNode\r\n if (node instanceof HTMLDivElement && node.classList.contains('quill-better-table-wrapper')) {\r\n this.quill.setSelection(range.index + 1, 0, Quill.sources.USER)\r\n this.quill.focus()\r\n return\r\n }\r\n // bugfix: a unexpected new line inserted when user compositionend with hitting Enter\r\n if (this.quill.selection && this.quill.selection.composing) return\r\n const Scope = Quill.imports.parchment.Scope\r\n if (range.length > 0) {\r\n this.quill.scroll.deleteAt(range.index, range.length) // So we do not trigger text-change\r\n }\r\n const lineFormats = Object.keys(context.format).reduce((formats, format) => {\r\n if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) {\r\n formats[format] = context.format[format]\r\n }\r\n return formats\r\n }, {})\r\n // insert new cellLine with lineFormats\r\n this.quill.insertText(range.index, '\\n', lineFormats['table-cell-line'], Quill.sources.USER)\r\n // Earlier scroll.deleteAt might have messed up our selection,\r\n // so insertText's built in selection preservation is not reliable\r\n this.quill.setSelection(range.index + 1, Quill.sources.SILENT)\r\n this.quill.focus()\r\n Object.keys(context.format).forEach((name) => {\r\n if (!isNullOrUndefined(lineFormats[name])) return\r\n if (Array.isArray(context.format[name])) return\r\n if (name === 'link') return\r\n this.quill.format(name, context.format[name], Quill.sources.USER)\r\n })\r\n },\r\n },\r\n}\r\n\r\nexport default BetterTable\r\n"],"names":["List"],"mappings":";;;;;;;;;;;;AAwCA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,MAAM,QAAQ,MAAM,QAAQ;AAC5B,MAAM,SAAS,MAAM,QAAQ,aAAa;AAG1C,MAAM,oBAAoB,OAAO;AAAA,EAe/B,OAAO,WAAW;AACV,UAAA,SAAS,UAAU,IAAI;AACvB,UAAA,SAAS,eAAe,IAAI;AAC5B,UAAA,SAAS,eAAe,IAAI;AAC5B,UAAA,SAAS,WAAW,IAAI;AACxB,UAAA,SAAS,UAAU,IAAI;AACvB,UAAA,SAAS,WAAW,IAAI;AACxB,UAAA,SAAS,gBAAgB,IAAI;AAC7B,UAAA,SAAS,kBAAkB,IAAI;AAE/B,UAAA,SAAS,kBAAkB,QAAQ,IAAI;AAEvC,UAAA,SAAS,gBAAgBA,UAAM,IAAI;AAAA,EAC3C;AAAA,EAEA,YAAY,OAAO,SAAS;AAC1B,UAAM,OAAO,OAAO;AAGpB,SAAK,gBAAgB;AACrB,SAAK,yBAAyB;AACzB,SAAA,MAAM,KAAK,iBAAiB,aAAa,CAAA,UAAS,KAAK,gBAAgB,OAAO,KAAK,GAAG,KAAK;AAC3F,SAAA,MAAM,KAAK,iBAAiB,kBAAkB,MAAM,KAAK,qBAAqB,KAAK,GAAG,KAAK;AAC3F,SAAA,MAAM,KAAK,iB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GAAG,MAAM,QAAQ,MAAM;AAC7D,WAAK,MAAM;AACX,aAAO,KAAK,QAAQ,MAAM,EAAE,QAAQ,CAAC,SAAS;AAC5C,YAAI,CAAC,kBAAkB,YAAY,IAAI,CAAC,EAAG;AAC3C,YAAI,MAAM,QAAQ,QAAQ,OAAO,IAAI,CAAC,EAAG;AACzC,YAAI,SAAS,OAAQ;AAChB,aAAA,MAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,GAAG,MAAM,QAAQ,IAAI;AAAA,MAAA,CACjE;AAAA,IACH;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { css } from "../utils/index.es.js";
|
|
2
|
+
const GRID_SIZE = {
|
|
3
|
+
ROWS: 10,
|
|
4
|
+
COLS: 10,
|
|
5
|
+
CELL_SIZE: 15
|
|
6
|
+
};
|
|
7
|
+
const STYLES = {
|
|
8
|
+
container: {
|
|
9
|
+
"position": "absolute",
|
|
10
|
+
"z-index": "1000",
|
|
11
|
+
"background": "white",
|
|
12
|
+
"border": "1px solid #ccc",
|
|
13
|
+
"padding": "5px",
|
|
14
|
+
"box-shadow": "0 2px 8px rgba(0,0,0,0.1)"
|
|
15
|
+
},
|
|
16
|
+
grid: {
|
|
17
|
+
"display": "grid",
|
|
18
|
+
"grid-template-columns": `repeat(${GRID_SIZE.COLS}, ${GRID_SIZE.CELL_SIZE - 1}px)`,
|
|
19
|
+
"grid-template-rows": `repeat(${GRID_SIZE.ROWS}, ${GRID_SIZE.CELL_SIZE - 1}px)`,
|
|
20
|
+
"gap": "0px"
|
|
21
|
+
},
|
|
22
|
+
row: {
|
|
23
|
+
display: "contents"
|
|
24
|
+
},
|
|
25
|
+
cell: {
|
|
26
|
+
"width": `${GRID_SIZE.CELL_SIZE}px`,
|
|
27
|
+
"height": `${GRID_SIZE.CELL_SIZE}px`,
|
|
28
|
+
"border": "1px solid #ddd",
|
|
29
|
+
"background-color": "#fff",
|
|
30
|
+
"box-sizing": "border-box"
|
|
31
|
+
},
|
|
32
|
+
label: {
|
|
33
|
+
"text-align": "center",
|
|
34
|
+
"margin-top": "5px",
|
|
35
|
+
"font-size": "12px",
|
|
36
|
+
"color": "#666"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
function createCell(row, col, handleMouseOver, handleClick) {
|
|
40
|
+
const cellDiv = document.createElement("div");
|
|
41
|
+
cellDiv.className = "cell";
|
|
42
|
+
css(cellDiv, STYLES.cell);
|
|
43
|
+
const mouseOverListener = () => handleMouseOver(row + 1, col + 1);
|
|
44
|
+
const clickListener = () => handleClick();
|
|
45
|
+
cellDiv.addEventListener("mouseover", mouseOverListener);
|
|
46
|
+
cellDiv.addEventListener("click", clickListener);
|
|
47
|
+
const removeListeners = () => {
|
|
48
|
+
cellDiv.removeEventListener("mouseover", mouseOverListener);
|
|
49
|
+
cellDiv.removeEventListener("click", clickListener);
|
|
50
|
+
};
|
|
51
|
+
return { cellDiv, removeListeners };
|
|
52
|
+
}
|
|
53
|
+
function createRow(rowIndex, handleMouseOver, handleClick) {
|
|
54
|
+
const rowDiv = document.createElement("div");
|
|
55
|
+
rowDiv.className = "row";
|
|
56
|
+
css(rowDiv, STYLES.row);
|
|
57
|
+
const fragment = document.createDocumentFragment();
|
|
58
|
+
const removeListenersArray = [];
|
|
59
|
+
for (let col = 0; col < GRID_SIZE.COLS; col++) {
|
|
60
|
+
const { cellDiv, removeListeners: removeListeners2 } = createCell(rowIndex, col, handleMouseOver, handleClick);
|
|
61
|
+
fragment.appendChild(cellDiv);
|
|
62
|
+
removeListenersArray.push(removeListeners2);
|
|
63
|
+
}
|
|
64
|
+
rowDiv.appendChild(fragment);
|
|
65
|
+
const removeListeners = () => {
|
|
66
|
+
removeListenersArray.forEach((remove) => remove());
|
|
67
|
+
};
|
|
68
|
+
return { rowDiv, removeListeners };
|
|
69
|
+
}
|
|
70
|
+
class TableSelector {
|
|
71
|
+
constructor({ onSelect }) {
|
|
72
|
+
this.rows = 0;
|
|
73
|
+
this.cols = 0;
|
|
74
|
+
this.removeListenersArray = [];
|
|
75
|
+
this.onSelect = onSelect;
|
|
76
|
+
this.initContainer();
|
|
77
|
+
this.initGrid();
|
|
78
|
+
this.initLabel();
|
|
79
|
+
}
|
|
80
|
+
// init table-selector container
|
|
81
|
+
initContainer() {
|
|
82
|
+
this.container = document.createElement("div");
|
|
83
|
+
this.container.className = "table-selector";
|
|
84
|
+
css(this.container, STYLES.container);
|
|
85
|
+
}
|
|
86
|
+
// init grid
|
|
87
|
+
initGrid() {
|
|
88
|
+
this.grid = document.createElement("div");
|
|
89
|
+
this.grid.className = "grid";
|
|
90
|
+
css(this.grid, STYLES.grid);
|
|
91
|
+
const fragment = document.createDocumentFragment();
|
|
92
|
+
for (let row = 0; row < GRID_SIZE.ROWS; row++) {
|
|
93
|
+
const { rowDiv, removeListeners } = createRow(
|
|
94
|
+
row,
|
|
95
|
+
this.handleMouseOver.bind(this),
|
|
96
|
+
this.handleClick.bind(this)
|
|
97
|
+
);
|
|
98
|
+
fragment.appendChild(rowDiv);
|
|
99
|
+
this.removeListenersArray.push(removeListeners);
|
|
100
|
+
}
|
|
101
|
+
this.grid.appendChild(fragment);
|
|
102
|
+
this.container.appendChild(this.grid);
|
|
103
|
+
}
|
|
104
|
+
// init label
|
|
105
|
+
initLabel() {
|
|
106
|
+
this.label = document.createElement("div");
|
|
107
|
+
this.label.className = "label";
|
|
108
|
+
css(this.label, STYLES.label);
|
|
109
|
+
this.container.appendChild(this.label);
|
|
110
|
+
}
|
|
111
|
+
handleMouseOver(row, col) {
|
|
112
|
+
this.rows = row;
|
|
113
|
+
this.cols = col;
|
|
114
|
+
this.updateGrid();
|
|
115
|
+
}
|
|
116
|
+
handleClick() {
|
|
117
|
+
this.onSelect(this.rows, this.cols);
|
|
118
|
+
this.hide();
|
|
119
|
+
}
|
|
120
|
+
updateGrid() {
|
|
121
|
+
const cells = this.grid.getElementsByClassName("cell");
|
|
122
|
+
for (let i = 0; i < cells.length; i++) {
|
|
123
|
+
const cell = cells[i];
|
|
124
|
+
const row = Math.floor(i / GRID_SIZE.COLS);
|
|
125
|
+
const col = i % GRID_SIZE.COLS;
|
|
126
|
+
css(cell, {
|
|
127
|
+
"background-color": row < this.rows && col < this.cols ? "#e6f3ff" : "#fff"
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
this.label.textContent = `${this.rows} x ${this.cols}`;
|
|
131
|
+
}
|
|
132
|
+
show(x, y) {
|
|
133
|
+
css(this.container, {
|
|
134
|
+
"left": `${x}px`,
|
|
135
|
+
"top": `${y}px`,
|
|
136
|
+
"display": "block",
|
|
137
|
+
"margin-top": "1px"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
hide() {
|
|
141
|
+
css(this.container, { display: "none" });
|
|
142
|
+
}
|
|
143
|
+
destroy() {
|
|
144
|
+
this.removeListenersArray.forEach((remove) => remove());
|
|
145
|
+
this.removeListenersArray = [];
|
|
146
|
+
this.hide();
|
|
147
|
+
if (this.container.parentNode) {
|
|
148
|
+
this.container.parentNode.removeChild(this.container);
|
|
149
|
+
}
|
|
150
|
+
this.rows = 0;
|
|
151
|
+
this.cols = 0;
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
TableSelector as default
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=table-selector.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-selector.es.js","sources":["../../../../src/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,SAAS,GAAG,UAAU,SAAS;AAAA,IAC/B,UAAU,GAAG,UAAU,SAAS;AAAA,IAChC,UAAU;AAAA,IACV,oBAAoB;AAAA,IACpB,cAAc;AAAA,EAChB;AAAA,EACA,OAAO;AAAA,IACL,cAAc;AAAA,IACd,cAAc;AAAA,IACd,aAAa;AAAA,IACb,SAAS;AA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,cAAc,GAAG,KAAK,IAAI,MAAM,KAAK,IAAI;AAAA,EACtD;AAAA,EAEA,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,EACH;AAAA,EAEA,OAAO;AACL,QAAI,KAAK,WAAW,EAAE,SAAS,OAAQ,CAAA;AAAA,EACzC;AAAA,EAEA,UAAU;AACR,SAAK,qBAAqB,QAAQ,CAAU,WAAA,OAAQ,CAAA;AACpD,SAAK,uBAAuB;AAE5B,SAAK,KAAK;AACN,QAAA,KAAK,UAAU,YAAY;AAC7B,WAAK,UAAU,WAAW,YAAY,KAAK,SAAS;AAAA,IACtD;AACA,SAAK,OAAO;AACZ,SAAK,OAAO;AACL,WAAA;AAAA,EACT;AACF;"}
|
package/lib/fluent-editor.cjs.js
CHANGED
|
@@ -135,7 +135,10 @@ const registerModules = function() {
|
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
[index$1.FormatPainter.toolName]: index$1.FormatPainter,
|
|
138
|
-
[index$2.Screenshot.toolName]: index$2.Screenshot
|
|
138
|
+
[index$2.Screenshot.toolName]: index$2.Screenshot,
|
|
139
|
+
"lineheight": function(value) {
|
|
140
|
+
this.quill.format("line-height", value);
|
|
141
|
+
}
|
|
139
142
|
}
|
|
140
143
|
},
|
|
141
144
|
"better-table": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluent-editor.cjs.js","sources":["../../src/fluent-editor.ts"],"sourcesContent":["import type { ExpandedQuillOptions, Module, Parchment as TypeParchment } from 'quill'\r\nimport type { IEditorConfig } from './config/types'\r\nimport Quill from 'quill'\r\nimport { FontStyle, LineHeightStyle, SizeStyle, TextIndentStyle } from './attributors'\r\nimport { CHANGE_LANGUAGE_EVENT, defaultLanguage, getListValue, ICONS_CONFIG, inputFile, LANG_CONF } from './config'\r\nimport Counter from './counter' // 字符统计\r\nimport CustomClipboard from './custom-clipboard' // 粘贴板\r\nimport CustomImage from './custom-image/BlotFormatter' // 图片\r\nimport { CustomImageSpec } from './custom-image/specs/CustomImageSpec' // 图片拉伸模块\r\nimport CustomUploader from './custom-uploader' // 上传\r\nimport Emoji from './emoji' // 表情\r\nimport FileModule from './file' // 文件\r\nimport { FormatPainter } from './format-painter'\r\nimport { fullscreenHandler } from './fullscreen/handler'\r\nimport Link from './link' // 超链接\r\nimport MathliveModule from './mathlive' // latex公式\r\nimport MathliveBlot from './mathlive/formats'\r\nimport Mention from './mention/Mention' // @提醒\r\nimport { Screenshot } from './screenshot'// 截图\r\nimport SoftBreak from './soft-break' // 软回车\r\nimport Strike from './strike' // 删除线\r\nimport CustomSyntax from './syntax' // 代码块高亮\r\nimport BetterTable from './table/better-table' // 表格\r\nimport Toolbar, { ToolbarTip } from './toolbar' // 工具栏\r\nimport { isUndefined } from './utils/is'\r\nimport Video from './video' // 视频\r\n// import GlobalLink from './global-link' // 全局链接\r\n// import QuickMenu from './quick-menu' // 快捷菜单\r\nexport interface I18NOptions {\r\n lang: string\r\n langText: Record<string, string>\r\n}\r\nfunction resolveLanguageOption(options: Partial<I18NOptions>): I18NOptions {\r\n if (isUndefined(options.lang)) {\r\n options.lang = defaultLanguage\r\n }\r\n if (!(options.lang in LANG_CONF)) {\r\n console.warn(`The language ${options.lang} is not supported. Use the default language: ${defaultLanguage}`)\r\n options.lang = defaultLanguage\r\n }\r\n return {\r\n lang: options.lang,\r\n langText: Object.assign({}, LANG_CONF[options.lang], options.langText || {}),\r\n }\r\n}\r\nexport class FluentEditor extends Quill {\r\n isFullscreen: boolean = false\r\n options: IEditorConfig & ExpandedQuillOptions\r\n constructor(container: HTMLElement | string, options: IEditorConfig = {}) {\r\n options = Object.assign(options, resolveLanguageOption(options || {}))\r\n super(container, options)\r\n }\r\n\r\n changeLanguage(options: Partial<I18NOptions>) {\r\n const langOps = resolveLanguageOption(options)\r\n if (langOps.lang === this.options.lang) return\r\n this.options.lang = langOps.lang\r\n this.options.langText = langOps.langText\r\n this.emitter.emit(CHANGE_LANGUAGE_EVENT, this.options.lang, this.options.langText)\r\n }\r\n}\r\n\r\nconst registerModules = function () {\r\n const Icons = Quill.import('ui/icons')\r\n Object.entries(ICONS_CONFIG).forEach(([key, icon]) => {\r\n Icons[key] = icon\r\n })\r\n\r\n const SnowTheme = Quill.imports['themes/snow'] as typeof Module\r\n SnowTheme.DEFAULTS = {\r\n modules: {\r\n 'keyboard': {\r\n bindings: {\r\n ...BetterTable.keyboardBindings,\r\n },\r\n },\r\n 'toolbar': {\r\n handlers: {\r\n ...(SnowTheme.DEFAULTS as Record<string, any>).modules.toolbar.handlers,\r\n 'formula': function () {\r\n if (!this.quill.isEnabled()) return\r\n const mathlive = this.quill.getModule('mathlive')\r\n if (!mathlive) {\r\n this.quill.theme.tooltip.edit('formula')\r\n }\r\n else {\r\n mathlive.createDialog()\r\n }\r\n },\r\n 'undo': function () {\r\n this.quill.history.undo()\r\n },\r\n 'redo': function () {\r\n this.quill.history.redo()\r\n },\r\n 'better-table': function () {\r\n this.quill.getModule('better-table').insertTable(3, 3)\r\n },\r\n 'file': function () {\r\n const accept = this.quill.options?.uploadOption?.fileAccept\r\n inputFile.call(this, 'file', accept)\r\n },\r\n 'image': function () {\r\n const accept = this.quill.options?.uploadOption?.imageAccept\r\n inputFile.call(this, 'image', accept)\r\n },\r\n 'emoji': function () {},\r\n 'fullscreen': fullscreenHandler,\r\n 'list': function (value) {\r\n const range = this.quill.getSelection()\r\n const formats = this.quill.getFormat(range)\r\n const preListValue = Array.isArray(formats.list) ? formats.list[0]?.value : formats.list?.value\r\n const curListValue = getListValue(value, preListValue)\r\n // 如果设置list的选区中有表格,判断第一个table-col位置,将表格前的内容设置为list格式\r\n const lines = this.quill.getLines(range.index, range.length)\r\n const tableCols = lines.filter(line => line.statics.blotName === 'table-col' && !line.prev)\r\n if (tableCols.length) {\r\n let start = range.index\r\n // 遍历table-col群组,以之获取表格,将表格前选区设置为对应list格式\r\n tableCols.forEach((item, index) => {\r\n const table = item.domNode.closest('table.quill-better-table')\r\n const tableBlot = Quill.find(table) as TypeParchment.Blot\r\n const tableLength = tableBlot.length()\r\n const tableStart = this.quill.getIndex(item)\r\n const tableEnd = tableStart + tableLength\r\n const beforeTableRangeLength = tableStart - start\r\n // 在表格前设置列表\r\n this.quill.setSelection(start, beforeTableRangeLength, Quill.sources.SILENT)\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n // 当前表格末尾为下一个选取的开始\r\n start = tableEnd\r\n if (index === tableCols.length - 1) {\r\n // 将最后一个表格之后所有选区内容设置list格式\r\n this.quill.setSelection(tableEnd, range.index + range.length - tableEnd)\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n }\r\n })\r\n }\r\n else {\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n }\r\n },\r\n [FormatPainter.toolName]: FormatPainter,\r\n [Screenshot.toolName]: Screenshot,\r\n },\r\n },\r\n 'better-table': {\r\n operationMenu: {\r\n color: true,\r\n },\r\n },\r\n 'image': {\r\n specs: [CustomImageSpec],\r\n overlay: {\r\n style: {\r\n border: '1px dashed rgb(68, 68, 68)',\r\n },\r\n },\r\n align: {\r\n icons: {\r\n left: '<i class=\"icon-text-align-left\"></i>',\r\n center: '<i class=\"icon-text-align-center\"></i>',\r\n right: '<i class=\"icon-text-align-right\"></i>',\r\n },\r\n },\r\n },\r\n [ToolbarTip.moduleName]: true,\r\n },\r\n }\r\n\r\n FluentEditor.register(\r\n {\r\n 'modules/toolbar': Toolbar,\r\n 'modules/mention': Mention,\r\n 'modules/better-table': BetterTable,\r\n 'modules/clipboard': CustomClipboard,\r\n 'modules/uploader': CustomUploader, // 三者关联性最强\r\n 'modules/image': CustomImage, // 三者关联性最强\r\n 'modules/file': FileModule, // 三者关联性最强\r\n 'modules/counter': Counter,\r\n 'modules/emoji-toolbar': Emoji.ToolbarEmoji,\r\n 'modules/emoji-shortname': Emoji.ShortNameEmoji,\r\n // 'modules/global-link': GlobalLink,//暂未开发\r\n 'modules/link': Link, // 报错\r\n // 'modules/quickmenu': QuickMenu,//暂未开发\r\n 'modules/syntax': CustomSyntax,\r\n 'modules/mathlive': MathliveModule,\r\n [`modules/${ToolbarTip.moduleName}`]: ToolbarTip,\r\n\r\n 'formats/strike': Strike,\r\n 'formats/softBreak': SoftBreak,\r\n 'formats/video': Video,\r\n 'formats/emoji': Emoji.EmojiBlot,\r\n 'formats/font': FontStyle,\r\n 'formats/size': SizeStyle,\r\n 'formats/line-height': LineHeightStyle,\r\n 'formats/text-indent': TextIndentStyle,\r\n [`formats/${MathliveBlot.blotName}`]: MathliveBlot,\r\n },\r\n true, // 覆盖内部模块\r\n )\r\n\r\n return FluentEditor\r\n}\r\n\r\nexport default registerModules()\r\n"],"names":["isUndefined","defaultLanguage","LANG_CONF","CHANGE_LANGUAGE_EVENT","ICONS_CONFIG","BetterTable","inputFile","fullscreenHandler","formats","getListValue","index","FormatPainter","Screenshot","CustomImageSpec","ToolbarTip","Toolbar","Mention","CustomClipboard","CustomUploader","CustomImage","FileModule","Counter","Emoji","Link","CustomSyntax","MathliveModule","Strike","SoftBreak","Video","FontStyle","SizeStyle","LineHeightStyle","TextIndentStyle","MathliveBlot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,sBAAsB,SAA4C;AACrE,MAAAA,GAAA,YAAY,QAAQ,IAAI,GAAG;AAC7B,YAAQ,OAAOC;EACjB;AACI,MAAA,EAAE,QAAQ,QAAQC,cAAAA,YAAY;AAChC,YAAQ,KAAK,gBAAgB,QAAQ,IAAI,gDAAgDD,6BAAe,EAAE;AAC1G,YAAQ,OAAOA;EACjB;AACO,SAAA;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,UAAU,OAAO,OAAO,CAAA,GAAIC,cAAA,UAAU,QAAQ,IAAI,GAAG,QAAQ,Y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AyBC,QAAM,QAAA;AAAA,MAC/B,2BAA2BA,QAAM,QAAA;AAAA;AAAA,MAEjC,gBAAgBC,QAAA;AAAA;AAAA;AAAA,MAEhB,kBAAkBC,QAAA;AAAA,MAClB,oBAAoBC,QAAA;AAAA,MACpB,CAAC,WAAWX,WAAAA,WAAW,UAAU,EAAE,GAAGA,WAAA;AAAA,MAEtC,kBAAkBY,QAAA;AAAA,MAClB,qBAAqBC,QAAA;AAAA,MACrB,iBAAiBC,QAAA;AAAA,MACjB,iBAAiBN,QAAM,QAAA;AAAA,MACvB,gBAAgBO,UAAA;AAAA,MAChB,gBAAgBC,SAAA;AAAA,MAChB,uBAAuBC,WAAA;AAAA,MACvB,uBAAuBC,WAAA;AAAA,MACvB,CAAC,WAAWC,QAAAA,QAAa,QAAQ,EAAE,GAAGA,QAAA;AAAA,IACxC;AAAA,IACA;AAAA;AAAA,EAAA;AAGK,SAAA;AACT;AAEA,MAAA,iBAAe,gBAAgB;;;"}
|
|
1
|
+
{"version":3,"file":"fluent-editor.cjs.js","sources":["../../src/fluent-editor.ts"],"sourcesContent":["import type { ExpandedQuillOptions, Module, Parchment as TypeParchment } from 'quill'\r\nimport type { IEditorConfig } from './config/types'\r\nimport Quill from 'quill'\r\nimport { FontStyle, LineHeightStyle, SizeStyle, TextIndentStyle } from './attributors'\r\nimport { CHANGE_LANGUAGE_EVENT, defaultLanguage, getListValue, ICONS_CONFIG, inputFile, LANG_CONF } from './config'\r\nimport Counter from './counter' // 字符统计\r\nimport CustomClipboard from './custom-clipboard' // 粘贴板\r\nimport CustomImage from './custom-image/BlotFormatter' // 图片\r\nimport { CustomImageSpec } from './custom-image/specs/CustomImageSpec' // 图片拉伸模块\r\nimport CustomUploader from './custom-uploader' // 上传\r\nimport Emoji from './emoji' // 表情\r\nimport FileModule from './file' // 文件\r\nimport { FormatPainter } from './format-painter'\r\nimport { fullscreenHandler } from './fullscreen/handler'\r\nimport Link from './link' // 超链接\r\nimport MathliveModule from './mathlive' // latex公式\r\nimport MathliveBlot from './mathlive/formats'\r\nimport Mention from './mention/Mention' // @提醒\r\nimport { Screenshot } from './screenshot'// 截图\r\nimport SoftBreak from './soft-break' // 软回车\r\nimport Strike from './strike' // 删除线\r\nimport CustomSyntax from './syntax' // 代码块高亮\r\nimport BetterTable from './table/better-table' // 表格\r\nimport Toolbar, { ToolbarTip } from './toolbar' // 工具栏\r\nimport { isUndefined } from './utils/is'\r\nimport Video from './video' // 视频\r\n// import GlobalLink from './global-link' // 全局链接\r\n// import QuickMenu from './quick-menu' // 快捷菜单\r\nexport interface I18NOptions {\r\n lang: string\r\n langText: Record<string, string>\r\n}\r\nfunction resolveLanguageOption(options: Partial<I18NOptions>): I18NOptions {\r\n if (isUndefined(options.lang)) {\r\n options.lang = defaultLanguage\r\n }\r\n if (!(options.lang in LANG_CONF)) {\r\n console.warn(`The language ${options.lang} is not supported. Use the default language: ${defaultLanguage}`)\r\n options.lang = defaultLanguage\r\n }\r\n return {\r\n lang: options.lang,\r\n langText: Object.assign({}, LANG_CONF[options.lang], options.langText || {}),\r\n }\r\n}\r\nexport class FluentEditor extends Quill {\r\n isFullscreen: boolean = false\r\n options: IEditorConfig & ExpandedQuillOptions\r\n constructor(container: HTMLElement | string, options: IEditorConfig = {}) {\r\n options = Object.assign(options, resolveLanguageOption(options || {}))\r\n super(container, options)\r\n }\r\n\r\n changeLanguage(options: Partial<I18NOptions>) {\r\n const langOps = resolveLanguageOption(options)\r\n if (langOps.lang === this.options.lang) return\r\n this.options.lang = langOps.lang\r\n this.options.langText = langOps.langText\r\n this.emitter.emit(CHANGE_LANGUAGE_EVENT, this.options.lang, this.options.langText)\r\n }\r\n}\r\n\r\nconst registerModules = function () {\r\n const Icons = Quill.import('ui/icons')\r\n Object.entries(ICONS_CONFIG).forEach(([key, icon]) => {\r\n Icons[key] = icon\r\n })\r\n\r\n const SnowTheme = Quill.imports['themes/snow'] as typeof Module\r\n SnowTheme.DEFAULTS = {\r\n modules: {\r\n 'keyboard': {\r\n bindings: {\r\n ...BetterTable.keyboardBindings,\r\n },\r\n },\r\n 'toolbar': {\r\n handlers: {\r\n ...(SnowTheme.DEFAULTS as Record<string, any>).modules.toolbar.handlers,\r\n 'formula': function () {\r\n if (!this.quill.isEnabled()) return\r\n const mathlive = this.quill.getModule('mathlive')\r\n if (!mathlive) {\r\n this.quill.theme.tooltip.edit('formula')\r\n }\r\n else {\r\n mathlive.createDialog()\r\n }\r\n },\r\n 'undo': function () {\r\n this.quill.history.undo()\r\n },\r\n 'redo': function () {\r\n this.quill.history.redo()\r\n },\r\n 'better-table': function () {\r\n this.quill.getModule('better-table').insertTable(3, 3)\r\n },\r\n 'file': function () {\r\n const accept = this.quill.options?.uploadOption?.fileAccept\r\n inputFile.call(this, 'file', accept)\r\n },\r\n 'image': function () {\r\n const accept = this.quill.options?.uploadOption?.imageAccept\r\n inputFile.call(this, 'image', accept)\r\n },\r\n 'emoji': function () {},\r\n 'fullscreen': fullscreenHandler,\r\n 'list': function (value) {\r\n const range = this.quill.getSelection()\r\n const formats = this.quill.getFormat(range)\r\n const preListValue = Array.isArray(formats.list) ? formats.list[0]?.value : formats.list?.value\r\n const curListValue = getListValue(value, preListValue)\r\n // 如果设置list的选区中有表格,判断第一个table-col位置,将表格前的内容设置为list格式\r\n const lines = this.quill.getLines(range.index, range.length)\r\n const tableCols = lines.filter(line => line.statics.blotName === 'table-col' && !line.prev)\r\n if (tableCols.length) {\r\n let start = range.index\r\n // 遍历table-col群组,以之获取表格,将表格前选区设置为对应list格式\r\n tableCols.forEach((item, index) => {\r\n const table = item.domNode.closest('table.quill-better-table')\r\n const tableBlot = Quill.find(table) as TypeParchment.Blot\r\n const tableLength = tableBlot.length()\r\n const tableStart = this.quill.getIndex(item)\r\n const tableEnd = tableStart + tableLength\r\n const beforeTableRangeLength = tableStart - start\r\n // 在表格前设置列表\r\n this.quill.setSelection(start, beforeTableRangeLength, Quill.sources.SILENT)\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n // 当前表格末尾为下一个选取的开始\r\n start = tableEnd\r\n if (index === tableCols.length - 1) {\r\n // 将最后一个表格之后所有选区内容设置list格式\r\n this.quill.setSelection(tableEnd, range.index + range.length - tableEnd)\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n }\r\n })\r\n }\r\n else {\r\n this.quill.format('list', curListValue, Quill.sources.USER)\r\n }\r\n },\r\n [FormatPainter.toolName]: FormatPainter,\r\n [Screenshot.toolName]: Screenshot,\r\n 'lineheight': function (value) {\r\n this.quill.format('line-height', value)\r\n },\r\n },\r\n },\r\n 'better-table': {\r\n operationMenu: {\r\n color: true,\r\n },\r\n },\r\n 'image': {\r\n specs: [CustomImageSpec],\r\n overlay: {\r\n style: {\r\n border: '1px dashed rgb(68, 68, 68)',\r\n },\r\n },\r\n align: {\r\n icons: {\r\n left: '<i class=\"icon-text-align-left\"></i>',\r\n center: '<i class=\"icon-text-align-center\"></i>',\r\n right: '<i class=\"icon-text-align-right\"></i>',\r\n },\r\n },\r\n },\r\n [ToolbarTip.moduleName]: true,\r\n },\r\n }\r\n\r\n FluentEditor.register(\r\n {\r\n 'modules/toolbar': Toolbar,\r\n 'modules/mention': Mention,\r\n 'modules/better-table': BetterTable,\r\n 'modules/clipboard': CustomClipboard,\r\n 'modules/uploader': CustomUploader, // 三者关联性最强\r\n 'modules/image': CustomImage, // 三者关联性最强\r\n 'modules/file': FileModule, // 三者关联性最强\r\n 'modules/counter': Counter,\r\n 'modules/emoji-toolbar': Emoji.ToolbarEmoji,\r\n 'modules/emoji-shortname': Emoji.ShortNameEmoji,\r\n // 'modules/global-link': GlobalLink,//暂未开发\r\n 'modules/link': Link, // 报错\r\n // 'modules/quickmenu': QuickMenu,//暂未开发\r\n 'modules/syntax': CustomSyntax,\r\n 'modules/mathlive': MathliveModule,\r\n [`modules/${ToolbarTip.moduleName}`]: ToolbarTip,\r\n\r\n 'formats/strike': Strike,\r\n 'formats/softBreak': SoftBreak,\r\n 'formats/video': Video,\r\n 'formats/emoji': Emoji.EmojiBlot,\r\n 'formats/font': FontStyle,\r\n 'formats/size': SizeStyle,\r\n 'formats/line-height': LineHeightStyle,\r\n 'formats/text-indent': TextIndentStyle,\r\n [`formats/${MathliveBlot.blotName}`]: MathliveBlot,\r\n },\r\n true, // 覆盖内部模块\r\n )\r\n\r\n return FluentEditor\r\n}\r\n\r\nexport default registerModules()\r\n"],"names":["isUndefined","defaultLanguage","LANG_CONF","CHANGE_LANGUAGE_EVENT","ICONS_CONFIG","BetterTable","inputFile","fullscreenHandler","formats","getListValue","index","FormatPainter","Screenshot","CustomImageSpec","ToolbarTip","Toolbar","Mention","CustomClipboard","CustomUploader","CustomImage","FileModule","Counter","Emoji","Link","CustomSyntax","MathliveModule","Strike","SoftBreak","Video","FontStyle","SizeStyle","LineHeightStyle","TextIndentStyle","MathliveBlot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,sBAAsB,SAA4C;AACrE,MAAAA,GAAA,YAAY,QAAQ,IAAI,GAAG;AAC7B,YAAQ,OAAOC;EACjB;AACI,MAAA,EAAE,QAAQ,QAAQC,cAAAA,YAAY;AAChC,YAAQ,KAAK,gBAAgB,QAAQ,IAAI,gDAAgDD,6BAAe,EAAE;AAC1G,YAAQ,OAAOA;EACjB;AACO,SAAA;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,UAAU,OAAO,OAAO,CAAA,GAAIC,cAAA,UAAU,QAAQ,IAAI,GAAG,QAAQ,YAAY,EAAE;AAAA,EAAA;AAE/E;AACO,MAAM,qBAAqB,MAAM;AAAA,EAGtC,YAAY,WAAiC,UAAyB,IAAI;AACxE,cAAU,OAAO,OAAO,SAAS,sBAAsB,WAAW,CAAE,CAAA,CAAC;AACrE,UAAM,WAAW,OAAO;AAJF,SAAA,eAAA;AAAA,EAKxB;AAAA,EAEA,eAAe,SAA+B;AACtC,UAAA,UAAU,sBAAsB,OAAO;AAC7C,QAAI,QAAQ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A,WAAA;AAAA,MAEtC,kBAAkBY,QAAA;AAAA,MAClB,qBAAqBC,QAAA;AAAA,MACrB,iBAAiBC,QAAA;AAAA,MACjB,iBAAiBN,QAAM,QAAA;AAAA,MACvB,gBAAgBO,UAAA;AAAA,MAChB,gBAAgBC,SAAA;AAAA,MAChB,uBAAuBC,WAAA;AAAA,MACvB,uBAAuBC,WAAA;AAAA,MACvB,CAAC,WAAWC,QAAAA,QAAa,QAAQ,EAAE,GAAGA,QAAA;AAAA,IACxC;AAAA,IACA;AAAA;AAAA,EAAA;AAGK,SAAA;AACT;AAEA,MAAA,iBAAe,gBAAgB;;;"}
|
|
@@ -9,6 +9,8 @@ const tableColumnTool = require("./modules/table-column-tool.cjs.js");
|
|
|
9
9
|
const tableOperationMenu = require("./modules/table-operation-menu.cjs.js");
|
|
10
10
|
const tableScrollBar = require("./modules/table-scroll-bar.cjs.js");
|
|
11
11
|
const tableSelection = require("./modules/table-selection.cjs.js");
|
|
12
|
+
const tableSelector = require("./modules/table-selector.cjs.js");
|
|
13
|
+
const index = require("./utils/index.cjs.js");
|
|
12
14
|
const nodeMatchers = require("./utils/node-matchers.cjs.js");
|
|
13
15
|
const Block = Quill.imports["blots/block"];
|
|
14
16
|
const Delta = Quill.imports.delta;
|
|
@@ -29,6 +31,7 @@ class BetterTable extends Module {
|
|
|
29
31
|
constructor(quill, options) {
|
|
30
32
|
super(quill, options);
|
|
31
33
|
this.isComposition = false;
|
|
34
|
+
this.isTableSelectorVisible = false;
|
|
32
35
|
this.quill.root.addEventListener("mousedown", (event) => this.handleMouseDown(event, quill), false);
|
|
33
36
|
this.quill.root.addEventListener("compositionend", () => this.handleCompositionend(quill), false);
|
|
34
37
|
this.quill.root.addEventListener("compositionstart", () => this.handleCompositionstart(quill), false);
|
|
@@ -110,7 +113,7 @@ class BetterTable extends Module {
|
|
|
110
113
|
return matcher[0] !== "tr";
|
|
111
114
|
});
|
|
112
115
|
quill.clipboard.addMatcher("tr", nodeMatchers.matchTableRow);
|
|
113
|
-
this.quill.on(
|
|
116
|
+
this.quill.on(Quill.events.EDITOR_CHANGE, () => {
|
|
114
117
|
const tableContainer = Quill.find(this.table);
|
|
115
118
|
if (!tableContainer) {
|
|
116
119
|
this.hideTableTools();
|
|
@@ -139,6 +142,32 @@ class BetterTable extends Module {
|
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
});
|
|
145
|
+
this.initTableSelector();
|
|
146
|
+
}
|
|
147
|
+
initTableSelector() {
|
|
148
|
+
const toolbar = this.quill.getModule("toolbar");
|
|
149
|
+
if (!toolbar) return;
|
|
150
|
+
const tableButton = toolbar.container.querySelector(".ql-better-table");
|
|
151
|
+
if (!tableButton) return;
|
|
152
|
+
const tableSelectorWrapper = this.tableSelectorWrapperCreator();
|
|
153
|
+
tableButton.parentNode.insertBefore(tableSelectorWrapper, tableButton);
|
|
154
|
+
tableSelectorWrapper.appendChild(tableButton);
|
|
155
|
+
this.tableSelectorWrapper = tableSelectorWrapper;
|
|
156
|
+
tableSelectorWrapper.addEventListener("mouseenter", this.handleTableSelectorHover.bind(this), false);
|
|
157
|
+
tableSelectorWrapper.addEventListener("mouseleave", this.handleTableSelectorMouseOut.bind(this), false);
|
|
158
|
+
}
|
|
159
|
+
tableSelectorWrapperCreator() {
|
|
160
|
+
const wrapper = document.createElement("div");
|
|
161
|
+
wrapper.className = "ql-better-table-wrapper";
|
|
162
|
+
const cssContent = {
|
|
163
|
+
position: "relative",
|
|
164
|
+
display: "flex",
|
|
165
|
+
alignItems: "center",
|
|
166
|
+
justifyContent: "center",
|
|
167
|
+
boxSizing: "border-box"
|
|
168
|
+
};
|
|
169
|
+
index.css(wrapper, cssContent);
|
|
170
|
+
return wrapper;
|
|
142
171
|
}
|
|
143
172
|
handleMouseDown(evt, quill) {
|
|
144
173
|
const path = editor_utils.getEventComposedPath(evt);
|
|
@@ -207,6 +236,29 @@ class BetterTable extends Module {
|
|
|
207
236
|
}
|
|
208
237
|
this.isComposition = false;
|
|
209
238
|
}
|
|
239
|
+
// 触发table selector
|
|
240
|
+
handleTableSelectorHover() {
|
|
241
|
+
if (this.isTableSelectorVisible) return;
|
|
242
|
+
if (!this.tableSelectorWrapper) return;
|
|
243
|
+
this.isTableSelectorVisible = true;
|
|
244
|
+
this.tableSelector = new tableSelector.default({
|
|
245
|
+
onSelect: (rows, cols) => this.insertTable(rows, cols)
|
|
246
|
+
});
|
|
247
|
+
this.tableSelectorWrapper.appendChild(this.tableSelector.container);
|
|
248
|
+
const buttonRect = this.tableSelectorWrapper.getBoundingClientRect();
|
|
249
|
+
this.tableSelector.show(
|
|
250
|
+
0,
|
|
251
|
+
buttonRect.height
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
// table selector 鼠标离开
|
|
255
|
+
handleTableSelectorMouseOut() {
|
|
256
|
+
if (this.tableSelector) {
|
|
257
|
+
this.tableSelector.destroy();
|
|
258
|
+
}
|
|
259
|
+
this.tableSelector = null;
|
|
260
|
+
this.isTableSelectorVisible = false;
|
|
261
|
+
}
|
|
210
262
|
getTable(range = this.quill.getSelection()) {
|
|
211
263
|
if (editor_utils.isNullOrUndefined(range)) return [null, null, null, -1];
|
|
212
264
|
const [cellLine, offset] = this.quill.getLine(range.index);
|
|
@@ -387,9 +439,9 @@ BetterTable.keyboardBindings = {
|
|
|
387
439
|
format: ["table-cell-line"],
|
|
388
440
|
handler(range, _context) {
|
|
389
441
|
const [line] = this.quill.getLine(range.index);
|
|
390
|
-
const
|
|
442
|
+
const index2 = this.quill.getIndex(line);
|
|
391
443
|
const length = line.length();
|
|
392
|
-
if (!line.next && (!line.prev && length === 1 || range.index !==
|
|
444
|
+
if (!line.next && (!line.prev && length === 1 || range.index !== index2 && range.index + 1 >= index2 + length)) {
|
|
393
445
|
return false;
|
|
394
446
|
}
|
|
395
447
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"better-table.cjs.js","sources":["../../../src/table/better-table.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport {\r\n getEventComposedPath,\r\n insideTable,\r\n isNullOrUndefined,\r\n isPureIE,\r\n} from '../config/editor.utils'\r\nimport Header from './formats/header'\r\nimport List from './formats/list'\r\nimport {\r\n cellId,\r\n rowId,\r\n TableBody,\r\n TableCell,\r\n TableCellLine,\r\n TableCol,\r\n TableColGroup,\r\n TableContainer,\r\n TableRow,\r\n TableViewWrapper,\r\n} from './formats/table'\r\nimport TableColumnTool from './modules/table-column-tool'\r\nimport TableOperationMenu from './modules/table-operation-menu'\r\nimport TableScrollBar from './modules/table-scroll-bar'\r\nimport TableSelection from './modules/table-selection'\r\n// import table node matchers\r\nimport {\r\n matchHeader,\r\n matchInline,\r\n matchList,\r\n matchMentionLink,\r\n matchTable,\r\n matchTableCell,\r\n matchTableHeader,\r\n matchTableRow,\r\n matchWordShapeImage,\r\n} from './utils/node-matchers'\r\n\r\nconst Block = Quill.imports['blots/block']\r\nconst Delta = Quill.imports.delta\r\nconst Module = Quill.imports['core/module']\r\n\r\n// @dynamic\r\nclass BetterTable extends Module {\r\n static keyboardBindings: any\r\n isComposition: boolean\r\n quill: any\r\n table: any\r\n modulesContainer: any\r\n tableSelection: any\r\n subscriber: any\r\n tableOperationMenu: any\r\n columnTool: TableColumnTool\r\n tableScrollBar: TableScrollBar\r\n\r\n static register() {\r\n Quill.register(TableCol, true)\r\n Quill.register(TableColGroup, true)\r\n Quill.register(TableCellLine, true)\r\n Quill.register(TableCell, true)\r\n Quill.register(TableRow, true)\r\n Quill.register(TableBody, true)\r\n Quill.register(TableContainer, true)\r\n Quill.register(TableViewWrapper, true)\r\n // register customized Header, overwriting quill built-in Header\r\n Quill.register('formats/header', Header, true)\r\n // register customized List, overwriting quill built-in Header\r\n Quill.register('formats/list', List, true)\r\n }\r\n\r\n constructor(quill, options) {\r\n super(quill, options)\r\n\r\n // handle click on quill-better-table\r\n this.isComposition = false\r\n this.quill.root.addEventListener('mousedown', event => this.handleMouseDown(event, quill), false)\r\n this.quill.root.addEventListener('compositionend', () => this.handleCompositionend(quill), false)\r\n this.quill.root.addEventListener('compositionstart', () => this.handleCompositionstart(quill), false)\r\n this.quill.root.addEventListener('keypress', event => this.handleKeyDown(event, quill), false)\r\n\r\n // handle right click on quill-better-table\r\n this.quill.root.addEventListener(\r\n 'contextmenu',\r\n (evt) => {\r\n if (!this.table) return true\r\n evt.preventDefault()\r\n\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n\r\n const tableNode = path.filter((node) => {\r\n return (\r\n node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n )\r\n })[0]\r\n\r\n const rowNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const cellNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const isTargetCellSelected = this.tableSelection.selectedTds\r\n .map(tableCell => tableCell.domNode)\r\n .includes(cellNode)\r\n\r\n if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) {\r\n this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect())\r\n }\r\n\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu = this.tableOperationMenu.destroy()\r\n }\r\n\r\n if (tableNode) {\r\n this.tableOperationMenu = new TableOperationMenu(\r\n {\r\n table: tableNode,\r\n row: rowNode,\r\n cell: cellNode,\r\n left: evt.x + 15,\r\n top: evt.y,\r\n },\r\n quill,\r\n options.operationMenu,\r\n )\r\n }\r\n },\r\n false,\r\n )\r\n\r\n // add keyboard binding:Backspace\r\n // prevent user hits backspace to delete table cell\r\n quill.keyboard.addBinding({ key: 'Backspace' }, {}, (range, context) => {\r\n if (range.index === 0 || this.quill.getLength() <= 1) return true\r\n if (context.offset === 0 && range.length === 0) {\r\n const [prev] = this.quill.getLine(range.index - 1)\r\n const [line] = this.quill.getLine(range.index)\r\n if (!isNullOrUndefined(prev)) {\r\n if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = prev.parent.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n return false\r\n }\r\n }\r\n }\r\n return true\r\n })\r\n // since only one matched bindings callback will execute.\r\n // expected my binding callback execute first\r\n // I changed the order of binding callbacks\r\n const thisBinding = quill.keyboard.bindings.Backspace.pop()\r\n quill.keyboard.bindings.Backspace.splice(1, 0, thisBinding)\r\n\r\n // add Matchers to match and render quill-better-table for initialization\r\n // or pasting\r\n quill.clipboard.addMatcher('td', matchTableCell)\r\n quill.clipboard.addMatcher('th', matchTableHeader)\r\n quill.clipboard.addMatcher('table', matchTable)\r\n quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader)\r\n quill.clipboard.addMatcher('ol, ul', matchList)\r\n quill.clipboard.addMatcher('span', matchMentionLink)\r\n quill.clipboard.addMatcher('v:imageData', matchWordShapeImage)\r\n quill.clipboard.addMatcher(Node.ELEMENT_NODE, matchInline)\r\n\r\n // remove matcher for tr tag\r\n quill.clipboard.matchers = quill.clipboard.matchers.filter((matcher) => {\r\n return matcher[0] !== 'tr'\r\n })\r\n\r\n // fix: 处理空<tr>标签被忽略的情况\r\n quill.clipboard.addMatcher('tr', matchTableRow)\r\n\r\n this.quill.on('editor-change', () => {\r\n const tableContainer = Quill.find(this.table)\r\n if (!tableContainer) {\r\n this.hideTableTools()\r\n }\r\n })\r\n\r\n this.quill.on(Quill.events.SELECTION_CHANGE, (range, _oldRange, source) => {\r\n if (!range) return\r\n const selectionStart = range.index\r\n const selectionEnd = range.index + range.length\r\n if (source === Quill.sources.USER) {\r\n const tables = this.quill.root.getElementsByTagName('table')\r\n if (tables && tables.length) {\r\n [].forEach.call(tables, (table) => {\r\n const tableContainer = Quill.find(table)\r\n if (tableContainer) {\r\n const tableStart = tableContainer.offset(this.quill.scroll)\r\n const tableEnd = tableStart + tableContainer.length()\r\n // @ts-ignore\r\n const classes = Array.from(table.parentNode.classList)\r\n\r\n if (selectionStart <= tableStart && tableEnd <= selectionEnd) {\r\n // @ts-ignore\r\n table.parentNode.classList.add('quill-better-table-selected')\r\n }\r\n else if (classes.includes('quill-better-table-selected')) {\r\n // @ts-ignore\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n }\r\n }\r\n })\r\n }\r\n }\r\n })\r\n }\r\n\r\n handleMouseDown(evt, quill) {\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n const tableNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n })[0]\r\n if (tableNode) {\r\n tableNode.parentNode.classList.remove('quill-better-table-selected')\r\n // current table clicked\r\n if (this.table === tableNode) return\r\n // other table clicked\r\n if (this.table) {\r\n this.hideTableTools()\r\n }\r\n if (!quill.options.readOnly) { // not show table tool in readonly mode\r\n this.showTableTools(tableNode, quill)\r\n }\r\n }\r\n else if (this.table) {\r\n // other clicked\r\n this.hideTableTools()\r\n }\r\n }\r\n\r\n handleKeyDown(evt, quill) {\r\n const key = evt.key\r\n const range = quill.getSelection()\r\n if (this.isComposition || !range) return\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (key && key !== 'Delete' && col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.insertText(range.index, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionstart(quill) {\r\n this.isComposition = true\r\n const range = quill.getSelection()\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n\\t', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionend(quill) {\r\n // fix: 解决在空行行首用中文输入法输入字符,然后按退格导致插入多余空行的问题\r\n const range = quill.getSelection()\r\n const [line] = quill.getLine(range.index)\r\n const domNode = line.domNode\r\n const isInParagraph = domNode.nodeName === 'P'\r\n const isInTableCell = line.statics.blotName === 'table-cell-line'\r\n if ((isInParagraph || isInTableCell)\r\n && domNode.childNodes.length > 1\r\n && domNode.childNodes[0].nodeName === 'BR') {\r\n domNode.childNodes[0].remove()\r\n }\r\n\r\n if (isPureIE && line instanceof Block) {\r\n // 设置光标位置防止跳入下一行\r\n quill.setSelection(range.index, 0, Quill.sources.SILENT)\r\n }\r\n\r\n this.isComposition = false\r\n }\r\n\r\n getTable(range = this.quill.getSelection()) {\r\n if (isNullOrUndefined(range)) return [null, null, null, -1]\r\n const [cellLine, offset] = this.quill.getLine(range.index)\r\n if (isNullOrUndefined(cellLine) || cellLine.statics.blotName !== TableCellLine.blotName) {\r\n return [null, null, null, -1]\r\n }\r\n const cell = cellLine.tableCell()\r\n const row = cell.row()\r\n const table = row.table()\r\n return [table, row, cell, offset]\r\n }\r\n\r\n insertTable(rows, columns) {\r\n const range = this.quill.getSelection(true)\r\n const isInsideTable = insideTable(range, this.quill)\r\n if (isNullOrUndefined(range) || isInsideTable) return\r\n // let currentBlot = this.quill.getLeaf(range.index)[0]\r\n // let nextBlot = this.quill.getLeaf(range.index + 1)[0]\r\n let delta = new Delta().retain(range.index)\r\n\r\n delta.insert('\\n')\r\n // insert table column\r\n delta = new Array(columns).fill('\\n').reduce((memo, text) => {\r\n memo.insert(text, { 'table-col': true })\r\n return memo\r\n }, delta)\r\n // insert table cell line with empty line\r\n delta = new Array(rows).fill(0).reduce((memo) => {\r\n const tableRowId = rowId()\r\n return new Array(columns).fill('\\n').reduce((op, text) => {\r\n op.insert(text, { 'table-cell-line': { row: tableRowId, cell: cellId() } })\r\n return op\r\n }, memo)\r\n }, delta)\r\n\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n delta.insert('\\n')\r\n }\r\n\r\n this.quill.updateContents(delta, Quill.sources.USER)\r\n\r\n // feature: 新增表格后首格自动激活编辑状态,initEvent兼容IE\r\n const [cellLine] = this.quill.getLine(range.index + columns + 1)\r\n if (cellLine) {\r\n const cell = cellLine.tableCell()\r\n const td = cell.domNode\r\n const mousedownEvent = document.createEvent('MouseEvent')\r\n const mouseupEvent = document.createEvent('MouseEvent')\r\n const keyEvent = document.createEvent('Event')\r\n mousedownEvent.initEvent('mousedown', true, false)\r\n mouseupEvent.initEvent('mouseup', true, false)\r\n keyEvent.initEvent('keypress', true, false)\r\n td.dispatchEvent(mousedownEvent)\r\n td.dispatchEvent(mouseupEvent)\r\n td.dispatchEvent(keyEvent)\r\n this.tableSelection.endTd = td\r\n }\r\n }\r\n\r\n showTableTools(table, quill) {\r\n this.table = table\r\n this.modulesContainer = document.createElement('div')\r\n this.modulesContainer.classList.add('qlbt-modules-container')\r\n // fix:表格容器插入时获取ql-tooltip容器,用insertBefore插入到它前面,避免遮挡链接浮窗\r\n const linkContainer = this.quill.root.parentNode.querySelector('.ql-tooltip ')\r\n this.quill.root.parentNode.insertBefore(this.modulesContainer, linkContainer)\r\n this.tableSelection = new TableSelection(table, quill, this.modulesContainer)\r\n this.columnTool = new TableColumnTool(table, quill, this.modulesContainer)\r\n this.tableScrollBar = new TableScrollBar(table, quill, this.modulesContainer)\r\n let timeoutID\r\n this.subscriber = () => {\r\n clearTimeout(timeoutID)\r\n timeoutID = setTimeout(this.hideTableTools, 300)\r\n }\r\n window.addEventListener('resize', this.subscriber, false)\r\n }\r\n\r\n hideTableTools() {\r\n if (this.columnTool) {\r\n this.columnTool.destroy()\r\n }\r\n if (this.tableSelection) {\r\n this.tableSelection.destroy()\r\n }\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu.destroy()\r\n }\r\n if (this.tableScrollBar) {\r\n this.tableScrollBar.destroy()\r\n }\r\n if (this.modulesContainer) {\r\n this.modulesContainer.remove()\r\n }\r\n this.columnTool = null\r\n this.tableSelection = null\r\n this.tableOperationMenu = null\r\n this.tableScrollBar = null\r\n this.modulesContainer = null\r\n this.table = null\r\n if (this.subscriber) {\r\n window.removeEventListener('resize', this.subscriber)\r\n }\r\n }\r\n}\r\n\r\nBetterTable.keyboardBindings = {\r\n 'line delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: { 'table-col': false, 'table-cell-line': false },\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n // fix: 当光标在编辑器最前且之后为表格时按delete不执行操作\r\n if (range.index === 0 && context.line.next && context.line.next.statics.blotName === 'table-view') {\r\n const [p] = this.quill.getLine(range.index - 1)\r\n const [col] = this.quill.getLine(range.index + 1)\r\n if (p && p.statics.blotName === 'block' && col && col.statics.blotName === 'table-col') {\r\n return false\r\n }\r\n }\r\n return true\r\n },\r\n },\r\n 'table-col enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n this.quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n this.quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n },\r\n },\r\n 'table-col delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = col.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n }\r\n }\r\n },\r\n },\r\n 'table-col backspace': {\r\n key: 'Backspace',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler() { },\r\n },\r\n 'table-cell-line backspace': {\r\n key: 'Backspace',\r\n format: ['table-cell-line'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range) {\r\n const [line] = this.quill.getLine(range.index)\r\n // 移除原有对非table-cell-line的阻止条件,使table-cell-line前的list等内容可以被删除\r\n if (!line.prev) {\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line delete': {\r\n key: 'Delete',\r\n format: ['table-cell-line'],\r\n handler(range, _context) {\r\n // 获取table-cell-line的索引和长度\r\n const [line] = this.quill.getLine(range.index)\r\n const index = this.quill.getIndex(line)\r\n const length = line.length()\r\n if (!line.next // 当无下一个元素且满足以下情况阻止删除操作\r\n && ((!line.prev && length === 1) // 单元格内只有一个table-cell-line且无内容\r\n || (range.index !== index && range.index + 1 >= index + length))) { // 光标在有内容的table-cell-line最后\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-cell-line'],\r\n handler(range, context) {\r\n // fix:通过window的光标选区当前指向判断,如果为HTMLElement且为表格容器则定位至下一行\r\n const node = window.getSelection().anchorNode\r\n if (node instanceof HTMLDivElement && node.classList.contains('quill-better-table-wrapper')) {\r\n this.quill.setSelection(range.index + 1, 0, Quill.sources.USER)\r\n this.quill.focus()\r\n return\r\n }\r\n // bugfix: a unexpected new line inserted when user compositionend with hitting Enter\r\n if (this.quill.selection && this.quill.selection.composing) return\r\n const Scope = Quill.imports.parchment.Scope\r\n if (range.length > 0) {\r\n this.quill.scroll.deleteAt(range.index, range.length) // So we do not trigger text-change\r\n }\r\n const lineFormats = Object.keys(context.format).reduce((formats, format) => {\r\n if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) {\r\n formats[format] = context.format[format]\r\n }\r\n return formats\r\n }, {})\r\n // insert new cellLine with lineFormats\r\n this.quill.insertText(range.index, '\\n', lineFormats['table-cell-line'], Quill.sources.USER)\r\n // Earlier scroll.deleteAt might have messed up our selection,\r\n // so insertText's built in selection preservation is not reliable\r\n this.quill.setSelection(range.index + 1, Quill.sources.SILENT)\r\n this.quill.focus()\r\n Object.keys(context.format).forEach((name) => {\r\n if (!isNullOrUndefined(lineFormats[name])) return\r\n if (Array.isArray(context.format[name])) return\r\n if (name === 'link') return\r\n this.quill.format(name, context.format[name], Quill.sources.USER)\r\n })\r\n },\r\n },\r\n}\r\n\r\nexport default BetterTable\r\n"],"names":["TableCol","TableColGroup","TableCellLine","TableCell","TableRow","TableBody","TableContainer","TableViewWrapper","Header","List","getEventComposedPath","TableOperationMenu","isNullOrUndefined","matchTableCell","matchTableHeader","matchTable","matchHeader","matchList","matchMentionLink","matchWordShapeImage","matchInline","matchTableRow","table","isPureIE","insideTable","rowId","cellId","TableSelection","TableColumnTool","TableScrollBar"],"mappings":";;;;;;;;;;;;AAsCA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AACz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,MAAM,QAAQ,OAAO,IAAI,GAAG,MAAM,QAAQ,IAAI;AAAA,MAAA,CACjE;AAAA,IACH;AAAA,EACF;AACF;;"}
|
|
1
|
+
{"version":3,"file":"better-table.cjs.js","sources":["../../../src/table/better-table.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport {\r\n getEventComposedPath,\r\n insideTable,\r\n isNullOrUndefined,\r\n isPureIE,\r\n} from '../config/editor.utils'\r\nimport Header from './formats/header'\r\nimport List from './formats/list'\r\nimport {\r\n cellId,\r\n rowId,\r\n TableBody,\r\n TableCell,\r\n TableCellLine,\r\n TableCol,\r\n TableColGroup,\r\n TableContainer,\r\n TableRow,\r\n TableViewWrapper,\r\n} from './formats/table'\r\nimport TableColumnTool from './modules/table-column-tool'\r\nimport TableOperationMenu from './modules/table-operation-menu'\r\nimport TableScrollBar from './modules/table-scroll-bar'\r\nimport TableSelection from './modules/table-selection'\r\nimport TableSelector from './modules/table-selector'\r\nimport { css } from './utils'\r\n// import table node matchers\r\nimport {\r\n matchHeader,\r\n matchInline,\r\n matchList,\r\n matchMentionLink,\r\n matchTable,\r\n matchTableCell,\r\n matchTableHeader,\r\n matchTableRow,\r\n matchWordShapeImage,\r\n} from './utils/node-matchers'\r\n\r\nconst Block = Quill.imports['blots/block']\r\nconst Delta = Quill.imports.delta\r\nconst Module = Quill.imports['core/module']\r\n\r\n// @dynamic\r\nclass BetterTable extends Module {\r\n static keyboardBindings: any\r\n isComposition: boolean\r\n quill: any\r\n table: any\r\n modulesContainer: any\r\n tableSelection: any\r\n subscriber: any\r\n tableOperationMenu: any\r\n columnTool: TableColumnTool\r\n tableScrollBar: TableScrollBar\r\n tableSelector: TableSelector\r\n isTableSelectorVisible: boolean\r\n tableSelectorWrapper: HTMLDivElement\r\n\r\n static register() {\r\n Quill.register(TableCol, true)\r\n Quill.register(TableColGroup, true)\r\n Quill.register(TableCellLine, true)\r\n Quill.register(TableCell, true)\r\n Quill.register(TableRow, true)\r\n Quill.register(TableBody, true)\r\n Quill.register(TableContainer, true)\r\n Quill.register(TableViewWrapper, true)\r\n // register customized Header, overwriting quill built-in Header\r\n Quill.register('formats/header', Header, true)\r\n // register customized List, overwriting quill built-in Header\r\n Quill.register('formats/list', List, true)\r\n }\r\n\r\n constructor(quill, options) {\r\n super(quill, options)\r\n\r\n // handle click on quill-better-table\r\n this.isComposition = false\r\n this.isTableSelectorVisible = false\r\n this.quill.root.addEventListener('mousedown', event => this.handleMouseDown(event, quill), false)\r\n this.quill.root.addEventListener('compositionend', () => this.handleCompositionend(quill), false)\r\n this.quill.root.addEventListener('compositionstart', () => this.handleCompositionstart(quill), false)\r\n this.quill.root.addEventListener('keypress', event => this.handleKeyDown(event, quill), false)\r\n\r\n // handle right click on quill-better-table\r\n this.quill.root.addEventListener(\r\n 'contextmenu',\r\n (evt) => {\r\n if (!this.table) return true\r\n evt.preventDefault()\r\n\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n\r\n const tableNode = path.filter((node) => {\r\n return (\r\n node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n )\r\n })[0]\r\n\r\n const rowNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const cellNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const isTargetCellSelected = this.tableSelection.selectedTds\r\n .map(tableCell => tableCell.domNode)\r\n .includes(cellNode)\r\n\r\n if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) {\r\n this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect())\r\n }\r\n\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu = this.tableOperationMenu.destroy()\r\n }\r\n\r\n if (tableNode) {\r\n this.tableOperationMenu = new TableOperationMenu(\r\n {\r\n table: tableNode,\r\n row: rowNode,\r\n cell: cellNode,\r\n left: evt.x + 15,\r\n top: evt.y,\r\n },\r\n quill,\r\n options.operationMenu,\r\n )\r\n }\r\n },\r\n false,\r\n )\r\n\r\n // add keyboard binding:Backspace\r\n // prevent user hits backspace to delete table cell\r\n quill.keyboard.addBinding({ key: 'Backspace' }, {}, (range, context) => {\r\n if (range.index === 0 || this.quill.getLength() <= 1) return true\r\n if (context.offset === 0 && range.length === 0) {\r\n const [prev] = this.quill.getLine(range.index - 1)\r\n const [line] = this.quill.getLine(range.index)\r\n if (!isNullOrUndefined(prev)) {\r\n if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = prev.parent.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n return false\r\n }\r\n }\r\n }\r\n return true\r\n })\r\n // since only one matched bindings callback will execute.\r\n // expected my binding callback execute first\r\n // I changed the order of binding callbacks\r\n const thisBinding = quill.keyboard.bindings.Backspace.pop()\r\n quill.keyboard.bindings.Backspace.splice(1, 0, thisBinding)\r\n\r\n // add Matchers to match and render quill-better-table for initialization\r\n // or pasting\r\n quill.clipboard.addMatcher('td', matchTableCell)\r\n quill.clipboard.addMatcher('th', matchTableHeader)\r\n quill.clipboard.addMatcher('table', matchTable)\r\n quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader)\r\n quill.clipboard.addMatcher('ol, ul', matchList)\r\n quill.clipboard.addMatcher('span', matchMentionLink)\r\n quill.clipboard.addMatcher('v:imageData', matchWordShapeImage)\r\n quill.clipboard.addMatcher(Node.ELEMENT_NODE, matchInline)\r\n\r\n // remove matcher for tr tag\r\n quill.clipboard.matchers = quill.clipboard.matchers.filter((matcher) => {\r\n return matcher[0] !== 'tr'\r\n })\r\n\r\n // fix: 处理空<tr>标签被忽略的情况\r\n quill.clipboard.addMatcher('tr', matchTableRow)\r\n\r\n this.quill.on(Quill.events.EDITOR_CHANGE, () => {\r\n const tableContainer = Quill.find(this.table)\r\n if (!tableContainer) {\r\n this.hideTableTools()\r\n }\r\n })\r\n\r\n this.quill.on(Quill.events.SELECTION_CHANGE, (range, _oldRange, source) => {\r\n if (!range) return\r\n const selectionStart = range.index\r\n const selectionEnd = range.index + range.length\r\n if (source === Quill.sources.USER) {\r\n const tables = this.quill.root.getElementsByTagName('table')\r\n if (tables && tables.length) {\r\n [].forEach.call(tables, (table) => {\r\n const tableContainer = Quill.find(table)\r\n if (tableContainer) {\r\n const tableStart = tableContainer.offset(this.quill.scroll)\r\n const tableEnd = tableStart + tableContainer.length()\r\n // @ts-ignore\r\n const classes = Array.from(table.parentNode.classList)\r\n\r\n if (selectionStart <= tableStart && tableEnd <= selectionEnd) {\r\n // @ts-ignore\r\n table.parentNode.classList.add('quill-better-table-selected')\r\n }\r\n else if (classes.includes('quill-better-table-selected')) {\r\n // @ts-ignore\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n }\r\n }\r\n })\r\n }\r\n }\r\n })\r\n this.initTableSelector()\r\n }\r\n\r\n initTableSelector() {\r\n // feat table selector ,在better-table按钮上套一层容器,往容器添加table selector\r\n const toolbar = this.quill.getModule('toolbar')\r\n if (!toolbar) return\r\n const tableButton = toolbar.container.querySelector('.ql-better-table')\r\n if (!tableButton) return\r\n const tableSelectorWrapper = this.tableSelectorWrapperCreator()\r\n tableButton.parentNode.insertBefore(tableSelectorWrapper, tableButton)\r\n tableSelectorWrapper.appendChild(tableButton)\r\n this.tableSelectorWrapper = tableSelectorWrapper\r\n tableSelectorWrapper.addEventListener('mouseenter', this.handleTableSelectorHover.bind(this), false)\r\n tableSelectorWrapper.addEventListener('mouseleave', this.handleTableSelectorMouseOut.bind(this), false)\r\n }\r\n\r\n tableSelectorWrapperCreator() {\r\n const wrapper = document.createElement('div')\r\n wrapper.className = 'ql-better-table-wrapper'\r\n const cssContent = {\r\n position: 'relative',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n boxSizing: 'border-box',\r\n }\r\n css(wrapper, cssContent)\r\n return wrapper\r\n }\r\n\r\n handleMouseDown(evt, quill) {\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n const tableNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n })[0]\r\n if (tableNode) {\r\n tableNode.parentNode.classList.remove('quill-better-table-selected')\r\n // current table clicked\r\n if (this.table === tableNode) return\r\n // other table clicked\r\n if (this.table) {\r\n this.hideTableTools()\r\n }\r\n if (!quill.options.readOnly) { // not show table tool in readonly mode\r\n this.showTableTools(tableNode, quill)\r\n }\r\n }\r\n else if (this.table) {\r\n // other clicked\r\n this.hideTableTools()\r\n }\r\n }\r\n\r\n handleKeyDown(evt, quill) {\r\n const key = evt.key\r\n const range = quill.getSelection()\r\n if (this.isComposition || !range) return\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (key && key !== 'Delete' && col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.insertText(range.index, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionstart(quill) {\r\n this.isComposition = true\r\n const range = quill.getSelection()\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n\\t', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionend(quill) {\r\n // fix: 解决在空行行首用中文输入法输入字符,然后按退格导致插入多余空行的问题\r\n const range = quill.getSelection()\r\n const [line] = quill.getLine(range.index)\r\n const domNode = line.domNode\r\n const isInParagraph = domNode.nodeName === 'P'\r\n const isInTableCell = line.statics.blotName === 'table-cell-line'\r\n if ((isInParagraph || isInTableCell)\r\n && domNode.childNodes.length > 1\r\n && domNode.childNodes[0].nodeName === 'BR') {\r\n domNode.childNodes[0].remove()\r\n }\r\n\r\n if (isPureIE && line instanceof Block) {\r\n // 设置光标位置防止跳入下一行\r\n quill.setSelection(range.index, 0, Quill.sources.SILENT)\r\n }\r\n\r\n this.isComposition = false\r\n }\r\n\r\n // 触发table selector\r\n handleTableSelectorHover() {\r\n if (this.isTableSelectorVisible) return\r\n if (!this.tableSelectorWrapper) return\r\n this.isTableSelectorVisible = true\r\n this.tableSelector = new TableSelector({\r\n onSelect: (rows, cols) => this.insertTable(rows, cols),\r\n })\r\n this.tableSelectorWrapper.appendChild(this.tableSelector.container)\r\n const buttonRect = this.tableSelectorWrapper.getBoundingClientRect()\r\n this.tableSelector.show(\r\n 0,\r\n buttonRect.height,\r\n )\r\n }\r\n\r\n // table selector 鼠标离开\r\n handleTableSelectorMouseOut() {\r\n if (this.tableSelector) {\r\n this.tableSelector.destroy()\r\n }\r\n this.tableSelector = null\r\n this.isTableSelectorVisible = false\r\n }\r\n\r\n getTable(range = this.quill.getSelection()) {\r\n if (isNullOrUndefined(range)) return [null, null, null, -1]\r\n const [cellLine, offset] = this.quill.getLine(range.index)\r\n if (isNullOrUndefined(cellLine) || cellLine.statics.blotName !== TableCellLine.blotName) {\r\n return [null, null, null, -1]\r\n }\r\n const cell = cellLine.tableCell()\r\n const row = cell.row()\r\n const table = row.table()\r\n return [table, row, cell, offset]\r\n }\r\n\r\n insertTable(rows, columns) {\r\n const range = this.quill.getSelection(true)\r\n const isInsideTable = insideTable(range, this.quill)\r\n if (isNullOrUndefined(range) || isInsideTable) return\r\n // let currentBlot = this.quill.getLeaf(range.index)[0]\r\n // let nextBlot = this.quill.getLeaf(range.index + 1)[0]\r\n let delta = new Delta().retain(range.index)\r\n\r\n delta.insert('\\n')\r\n // insert table column\r\n delta = new Array(columns).fill('\\n').reduce((memo, text) => {\r\n memo.insert(text, { 'table-col': true })\r\n return memo\r\n }, delta)\r\n // insert table cell line with empty line\r\n delta = new Array(rows).fill(0).reduce((memo) => {\r\n const tableRowId = rowId()\r\n return new Array(columns).fill('\\n').reduce((op, text) => {\r\n op.insert(text, { 'table-cell-line': { row: tableRowId, cell: cellId() } })\r\n return op\r\n }, memo)\r\n }, delta)\r\n\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n delta.insert('\\n')\r\n }\r\n\r\n this.quill.updateContents(delta, Quill.sources.USER)\r\n\r\n // feature: 新增表格后首格自动激活编辑状态,initEvent兼容IE\r\n const [cellLine] = this.quill.getLine(range.index + columns + 1)\r\n if (cellLine) {\r\n const cell = cellLine.tableCell()\r\n const td = cell.domNode\r\n const mousedownEvent = document.createEvent('MouseEvent')\r\n const mouseupEvent = document.createEvent('MouseEvent')\r\n const keyEvent = document.createEvent('Event')\r\n mousedownEvent.initEvent('mousedown', true, false)\r\n mouseupEvent.initEvent('mouseup', true, false)\r\n keyEvent.initEvent('keypress', true, false)\r\n td.dispatchEvent(mousedownEvent)\r\n td.dispatchEvent(mouseupEvent)\r\n td.dispatchEvent(keyEvent)\r\n this.tableSelection.endTd = td\r\n }\r\n }\r\n\r\n showTableTools(table, quill) {\r\n this.table = table\r\n this.modulesContainer = document.createElement('div')\r\n this.modulesContainer.classList.add('qlbt-modules-container')\r\n // fix:表格容器插入时获取ql-tooltip容器,用insertBefore插入到它前面,避免遮挡链接浮窗\r\n const linkContainer = this.quill.root.parentNode.querySelector('.ql-tooltip ')\r\n this.quill.root.parentNode.insertBefore(this.modulesContainer, linkContainer)\r\n this.tableSelection = new TableSelection(table, quill, this.modulesContainer)\r\n this.columnTool = new TableColumnTool(table, quill, this.modulesContainer)\r\n this.tableScrollBar = new TableScrollBar(table, quill, this.modulesContainer)\r\n let timeoutID\r\n this.subscriber = () => {\r\n clearTimeout(timeoutID)\r\n timeoutID = setTimeout(this.hideTableTools, 300)\r\n }\r\n window.addEventListener('resize', this.subscriber, false)\r\n }\r\n\r\n hideTableTools() {\r\n if (this.columnTool) {\r\n this.columnTool.destroy()\r\n }\r\n if (this.tableSelection) {\r\n this.tableSelection.destroy()\r\n }\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu.destroy()\r\n }\r\n if (this.tableScrollBar) {\r\n this.tableScrollBar.destroy()\r\n }\r\n if (this.modulesContainer) {\r\n this.modulesContainer.remove()\r\n }\r\n this.columnTool = null\r\n this.tableSelection = null\r\n this.tableOperationMenu = null\r\n this.tableScrollBar = null\r\n this.modulesContainer = null\r\n this.table = null\r\n if (this.subscriber) {\r\n window.removeEventListener('resize', this.subscriber)\r\n }\r\n }\r\n}\r\n\r\nBetterTable.keyboardBindings = {\r\n 'line delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: { 'table-col': false, 'table-cell-line': false },\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n // fix: 当光标在编辑器最前且之后为表格时按delete不执行操作\r\n if (range.index === 0 && context.line.next && context.line.next.statics.blotName === 'table-view') {\r\n const [p] = this.quill.getLine(range.index - 1)\r\n const [col] = this.quill.getLine(range.index + 1)\r\n if (p && p.statics.blotName === 'block' && col && col.statics.blotName === 'table-col') {\r\n return false\r\n }\r\n }\r\n return true\r\n },\r\n },\r\n 'table-col enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n this.quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n this.quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n },\r\n },\r\n 'table-col delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = col.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n }\r\n }\r\n },\r\n },\r\n 'table-col backspace': {\r\n key: 'Backspace',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler() { },\r\n },\r\n 'table-cell-line backspace': {\r\n key: 'Backspace',\r\n format: ['table-cell-line'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range) {\r\n const [line] = this.quill.getLine(range.index)\r\n // 移除原有对非table-cell-line的阻止条件,使table-cell-line前的list等内容可以被删除\r\n if (!line.prev) {\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line delete': {\r\n key: 'Delete',\r\n format: ['table-cell-line'],\r\n handler(range, _context) {\r\n // 获取table-cell-line的索引和长度\r\n const [line] = this.quill.getLine(range.index)\r\n const index = this.quill.getIndex(line)\r\n const length = line.length()\r\n if (!line.next // 当无下一个元素且满足以下情况阻止删除操作\r\n && ((!line.prev && length === 1) // 单元格内只有一个table-cell-line且无内容\r\n || (range.index !== index && range.index + 1 >= index + length))) { // 光标在有内容的table-cell-line最后\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-cell-line'],\r\n handler(range, context) {\r\n // fix:通过window的光标选区当前指向判断,如果为HTMLElement且为表格容器则定位至下一行\r\n const node = window.getSelection().anchorNode\r\n if (node instanceof HTMLDivElement && node.classList.contains('quill-better-table-wrapper')) {\r\n this.quill.setSelection(range.index + 1, 0, Quill.sources.USER)\r\n this.quill.focus()\r\n return\r\n }\r\n // bugfix: a unexpected new line inserted when user compositionend with hitting Enter\r\n if (this.quill.selection && this.quill.selection.composing) return\r\n const Scope = Quill.imports.parchment.Scope\r\n if (range.length > 0) {\r\n this.quill.scroll.deleteAt(range.index, range.length) // So we do not trigger text-change\r\n }\r\n const lineFormats = Object.keys(context.format).reduce((formats, format) => {\r\n if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) {\r\n formats[format] = context.format[format]\r\n }\r\n return formats\r\n }, {})\r\n // insert new cellLine with lineFormats\r\n this.quill.insertText(range.index, '\\n', lineFormats['table-cell-line'], Quill.sources.USER)\r\n // Earlier scroll.deleteAt might have messed up our selection,\r\n // so insertText's built in selection preservation is not reliable\r\n this.quill.setSelection(range.index + 1, Quill.sources.SILENT)\r\n this.quill.focus()\r\n Object.keys(context.format).forEach((name) => {\r\n if (!isNullOrUndefined(lineFormats[name])) return\r\n if (Array.isArray(context.format[name])) return\r\n if (name === 'link') return\r\n this.quill.format(name, context.format[name], Quill.sources.USER)\r\n })\r\n },\r\n },\r\n}\r\n\r\nexport default BetterTable\r\n"],"names":["TableCol","TableColGroup","TableCellLine","TableCell","TableRow","TableBody","TableContainer","TableViewWrapper","Header","List","getEventComposedPath","TableOperationMenu","isNullOrUndefined","matchTableCell","matchTableHeader","matchTable","matchHeader","matchList","matchMentionLink","matchWordShapeImage","matchInline","matchTableRow","table","css","isPureIE","TableSelector","insideTable","rowId","cellId","TableSelection","TableColumnTool","TableScrollBar","index"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,MAAM,QAAQ,MAAM,QAAQ;AAC5B,MAAM,SAAS,MAAM,QAAQ,aAAa;AAG1C,MAAM,oBAAoB,OAAO;AAAA,EAe/B,OAAO,WAAW;AACV,UAAA,SAASA,gBAAU,IAAI;AACvB,UAAA,SAASC,qBAAe,IAAI;AAC5B,UAAA,SAASC,qBAAe,IAAI;AAC5B,UAAA,SAASC,iBAAW,IAAI;AACxB,UAAA,SAASC,gBAAU,IAAI;AACvB,UAAA,SAASC,iBAAW,IAAI;AACxB,UAAA,SAASC,sBAAgB,IAAI;AAC7B,UAAA,SAASC,wBAAkB,IAAI;AAE/B,UAAA,SAAS,kBAAkBC,OAAA,SAAQ,IAAI;AAEvC,UAAA,SAAS,gBAAgBC,KAAA,SAAM,IAAI;AAAA,EAC3C;AAAA,EAEA,YAAY,OAAO,SAAS;AAC1B,UAAM,OAAO,OAAO;AAGpB,SAAK,gBAAgB;AACrB,SAAK,yBAAyB;AACzB,SAAA,MAAM,KAAK,iBAAiB,aAAa,CAAA,UAAS,KAAK,gBAAgB,OAAO,KAAK,GAAG,KAAK;AAC3F,SAAA,MAAM,KAAK,iBAAiB,kBAAkB,MAAM,KAAK,qBAAqB,KAAK,GAAG,KAAK;AAC3F,SAAA,MAAM,KAAK,iBAAiB,oBAAoB,MAAM,KAAK,uBAAuB,KAAK,GAAG,KAAK;AAC/F,SAAA,MAAM,KAAK,iBAAiB,YAAY,CAAA,UAAS,KAAK,cAAc,OAAO,KAAK,GAAG,KAAK;AAG7F,SAAK,MAAM,KAAK;AAAA,MACd;AAAA,MACA,CAAC,QAAQ;AACH,YAAA,CAAC,KAAK,MAAc,QAAA;AACxB,YAAI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AAM,EAAE,QAAQ,CAAC,SAAS;AAC5C,YAAI,CAACpB,aAAAA,kBAAkB,YAAY,IAAI,CAAC,EAAG;AAC3C,YAAI,MAAM,QAAQ,QAAQ,OAAO,IAAI,CAAC,EAAG;AACzC,YAAI,SAAS,OAAQ;AAChB,aAAA,MAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,GAAG,MAAM,QAAQ,IAAI;AAAA,MAAA,CACjE;AAAA,IACH;AAAA,EACF;AACF;;"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const index = require("../utils/index.cjs.js");
|
|
4
|
+
const GRID_SIZE = {
|
|
5
|
+
ROWS: 10,
|
|
6
|
+
COLS: 10,
|
|
7
|
+
CELL_SIZE: 15
|
|
8
|
+
};
|
|
9
|
+
const STYLES = {
|
|
10
|
+
container: {
|
|
11
|
+
"position": "absolute",
|
|
12
|
+
"z-index": "1000",
|
|
13
|
+
"background": "white",
|
|
14
|
+
"border": "1px solid #ccc",
|
|
15
|
+
"padding": "5px",
|
|
16
|
+
"box-shadow": "0 2px 8px rgba(0,0,0,0.1)"
|
|
17
|
+
},
|
|
18
|
+
grid: {
|
|
19
|
+
"display": "grid",
|
|
20
|
+
"grid-template-columns": `repeat(${GRID_SIZE.COLS}, ${GRID_SIZE.CELL_SIZE - 1}px)`,
|
|
21
|
+
"grid-template-rows": `repeat(${GRID_SIZE.ROWS}, ${GRID_SIZE.CELL_SIZE - 1}px)`,
|
|
22
|
+
"gap": "0px"
|
|
23
|
+
},
|
|
24
|
+
row: {
|
|
25
|
+
display: "contents"
|
|
26
|
+
},
|
|
27
|
+
cell: {
|
|
28
|
+
"width": `${GRID_SIZE.CELL_SIZE}px`,
|
|
29
|
+
"height": `${GRID_SIZE.CELL_SIZE}px`,
|
|
30
|
+
"border": "1px solid #ddd",
|
|
31
|
+
"background-color": "#fff",
|
|
32
|
+
"box-sizing": "border-box"
|
|
33
|
+
},
|
|
34
|
+
label: {
|
|
35
|
+
"text-align": "center",
|
|
36
|
+
"margin-top": "5px",
|
|
37
|
+
"font-size": "12px",
|
|
38
|
+
"color": "#666"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function createCell(row, col, handleMouseOver, handleClick) {
|
|
42
|
+
const cellDiv = document.createElement("div");
|
|
43
|
+
cellDiv.className = "cell";
|
|
44
|
+
index.css(cellDiv, STYLES.cell);
|
|
45
|
+
const mouseOverListener = () => handleMouseOver(row + 1, col + 1);
|
|
46
|
+
const clickListener = () => handleClick();
|
|
47
|
+
cellDiv.addEventListener("mouseover", mouseOverListener);
|
|
48
|
+
cellDiv.addEventListener("click", clickListener);
|
|
49
|
+
const removeListeners = () => {
|
|
50
|
+
cellDiv.removeEventListener("mouseover", mouseOverListener);
|
|
51
|
+
cellDiv.removeEventListener("click", clickListener);
|
|
52
|
+
};
|
|
53
|
+
return { cellDiv, removeListeners };
|
|
54
|
+
}
|
|
55
|
+
function createRow(rowIndex, handleMouseOver, handleClick) {
|
|
56
|
+
const rowDiv = document.createElement("div");
|
|
57
|
+
rowDiv.className = "row";
|
|
58
|
+
index.css(rowDiv, STYLES.row);
|
|
59
|
+
const fragment = document.createDocumentFragment();
|
|
60
|
+
const removeListenersArray = [];
|
|
61
|
+
for (let col = 0; col < GRID_SIZE.COLS; col++) {
|
|
62
|
+
const { cellDiv, removeListeners: removeListeners2 } = createCell(rowIndex, col, handleMouseOver, handleClick);
|
|
63
|
+
fragment.appendChild(cellDiv);
|
|
64
|
+
removeListenersArray.push(removeListeners2);
|
|
65
|
+
}
|
|
66
|
+
rowDiv.appendChild(fragment);
|
|
67
|
+
const removeListeners = () => {
|
|
68
|
+
removeListenersArray.forEach((remove) => remove());
|
|
69
|
+
};
|
|
70
|
+
return { rowDiv, removeListeners };
|
|
71
|
+
}
|
|
72
|
+
class TableSelector {
|
|
73
|
+
constructor({ onSelect }) {
|
|
74
|
+
this.rows = 0;
|
|
75
|
+
this.cols = 0;
|
|
76
|
+
this.removeListenersArray = [];
|
|
77
|
+
this.onSelect = onSelect;
|
|
78
|
+
this.initContainer();
|
|
79
|
+
this.initGrid();
|
|
80
|
+
this.initLabel();
|
|
81
|
+
}
|
|
82
|
+
// init table-selector container
|
|
83
|
+
initContainer() {
|
|
84
|
+
this.container = document.createElement("div");
|
|
85
|
+
this.container.className = "table-selector";
|
|
86
|
+
index.css(this.container, STYLES.container);
|
|
87
|
+
}
|
|
88
|
+
// init grid
|
|
89
|
+
initGrid() {
|
|
90
|
+
this.grid = document.createElement("div");
|
|
91
|
+
this.grid.className = "grid";
|
|
92
|
+
index.css(this.grid, STYLES.grid);
|
|
93
|
+
const fragment = document.createDocumentFragment();
|
|
94
|
+
for (let row = 0; row < GRID_SIZE.ROWS; row++) {
|
|
95
|
+
const { rowDiv, removeListeners } = createRow(
|
|
96
|
+
row,
|
|
97
|
+
this.handleMouseOver.bind(this),
|
|
98
|
+
this.handleClick.bind(this)
|
|
99
|
+
);
|
|
100
|
+
fragment.appendChild(rowDiv);
|
|
101
|
+
this.removeListenersArray.push(removeListeners);
|
|
102
|
+
}
|
|
103
|
+
this.grid.appendChild(fragment);
|
|
104
|
+
this.container.appendChild(this.grid);
|
|
105
|
+
}
|
|
106
|
+
// init label
|
|
107
|
+
initLabel() {
|
|
108
|
+
this.label = document.createElement("div");
|
|
109
|
+
this.label.className = "label";
|
|
110
|
+
index.css(this.label, STYLES.label);
|
|
111
|
+
this.container.appendChild(this.label);
|
|
112
|
+
}
|
|
113
|
+
handleMouseOver(row, col) {
|
|
114
|
+
this.rows = row;
|
|
115
|
+
this.cols = col;
|
|
116
|
+
this.updateGrid();
|
|
117
|
+
}
|
|
118
|
+
handleClick() {
|
|
119
|
+
this.onSelect(this.rows, this.cols);
|
|
120
|
+
this.hide();
|
|
121
|
+
}
|
|
122
|
+
updateGrid() {
|
|
123
|
+
const cells = this.grid.getElementsByClassName("cell");
|
|
124
|
+
for (let i = 0; i < cells.length; i++) {
|
|
125
|
+
const cell = cells[i];
|
|
126
|
+
const row = Math.floor(i / GRID_SIZE.COLS);
|
|
127
|
+
const col = i % GRID_SIZE.COLS;
|
|
128
|
+
index.css(cell, {
|
|
129
|
+
"background-color": row < this.rows && col < this.cols ? "#e6f3ff" : "#fff"
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
this.label.textContent = `${this.rows} x ${this.cols}`;
|
|
133
|
+
}
|
|
134
|
+
show(x, y) {
|
|
135
|
+
index.css(this.container, {
|
|
136
|
+
"left": `${x}px`,
|
|
137
|
+
"top": `${y}px`,
|
|
138
|
+
"display": "block",
|
|
139
|
+
"margin-top": "1px"
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
hide() {
|
|
143
|
+
index.css(this.container, { display: "none" });
|
|
144
|
+
}
|
|
145
|
+
destroy() {
|
|
146
|
+
this.removeListenersArray.forEach((remove) => remove());
|
|
147
|
+
this.removeListenersArray = [];
|
|
148
|
+
this.hide();
|
|
149
|
+
if (this.container.parentNode) {
|
|
150
|
+
this.container.parentNode.removeChild(this.container);
|
|
151
|
+
}
|
|
152
|
+
this.rows = 0;
|
|
153
|
+
this.cols = 0;
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.default = TableSelector;
|
|
158
|
+
//# sourceMappingURL=table-selector.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-selector.cjs.js","sources":["../../../../src/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":["css","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,SAAS,GAAG,UAAU,SAAS;AAAA,IAC/B,UAAU,GAAG,UAAU,SAAS;AAAA,IAChC,UAAU;AAAA,IACV,oBAAoB;AAAA,IACpB,cAAc;AAAA,EAChB;AAAA,EACA,OAAO;AAAA,IACL,cAAc;AAAA,IACd,cAAc;AAA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,KAAK,QAAQ,MAAM,KAAK,OAAO,YAAY;AAAA,MAAA,CACtE;AAAA,IACH;AACA,SAAK,MAAM,cAAc,GAAG,KAAK,IAAI,MAAM,KAAK,IAAI;AAAA,EACtD;AAAA,EAEA,KAAK,GAAW,GAAW;AACzBA,UAAA,IAAI,KAAK,WAAW;AAAA,MAClB,QAAQ,GAAG,CAAC;AAAA,MACZ,OAAO,GAAG,CAAC;AAAA,MACX,WAAW;AAAA,MACX,cAAc;AAAA,IAAA,CACf;AAAA,EACH;AAAA,EAEA,OAAO;AACLA,UAAA,IAAI,KAAK,WAAW,EAAE,SAAS,OAAQ,CAAA;AAAA,EACzC;AAAA,EAEA,UAAU;AACR,SAAK,qBAAqB,QAAQ,CAAU,WAAA,OAAQ,CAAA;AACpD,SAAK,uBAAuB;AAE5B,SAAK,KAAK;AACN,QAAA,KAAK,UAAU,YAAY;AAC7B,WAAK,UAAU,WAAW,YAAY,KAAK,SAAS;AAAA,IACtD;AACA,SAAK,OAAO;AACZ,SAAK,OAAO;AACL,WAAA;AAAA,EACT;AACF;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/fluent-editor",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0",
|
|
4
4
|
"description": "A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.",
|
|
5
5
|
"author": "OpenTiny Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,4 +54,4 @@
|
|
|
54
54
|
"vite": "^5.0.0",
|
|
55
55
|
"vite-plugin-dts": "^4.3.0"
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|
package/style.css
CHANGED
|
@@ -1022,7 +1022,7 @@
|
|
|
1022
1022
|
position: absolute;
|
|
1023
1023
|
top: 0;
|
|
1024
1024
|
width: 40px;
|
|
1025
|
-
background:
|
|
1025
|
+
background: Canvas;
|
|
1026
1026
|
display: none;
|
|
1027
1027
|
}
|
|
1028
1028
|
.qlbt-modules-container .qlbt-table-control-panel .qlbt-left-mask {
|
|
@@ -2175,7 +2175,7 @@
|
|
|
2175
2175
|
position: absolute;
|
|
2176
2176
|
top: 0;
|
|
2177
2177
|
width: 40px;
|
|
2178
|
-
background:
|
|
2178
|
+
background: Canvas;
|
|
2179
2179
|
display: none;
|
|
2180
2180
|
}
|
|
2181
2181
|
.ql-editor .qlbt-modules-container .qlbt-table-control-panel .qlbt-left-mask {
|
|
@@ -3052,7 +3052,7 @@ li.unchecked > .ql-ui {
|
|
|
3052
3052
|
position: absolute;
|
|
3053
3053
|
top: 0;
|
|
3054
3054
|
width: 40px;
|
|
3055
|
-
background:
|
|
3055
|
+
background: Canvas;
|
|
3056
3056
|
display: none;
|
|
3057
3057
|
}
|
|
3058
3058
|
.qlbt-modules-container .qlbt-table-control-panel .qlbt-left-mask {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as TableColumnTool } from './modules/table-column-tool';
|
|
2
2
|
import { default as TableScrollBar } from './modules/table-scroll-bar';
|
|
3
|
+
import { default as TableSelector } from './modules/table-selector';
|
|
3
4
|
|
|
4
5
|
declare const Module: unknown;
|
|
5
6
|
declare class BetterTable extends Module {
|
|
@@ -13,12 +14,19 @@ declare class BetterTable extends Module {
|
|
|
13
14
|
tableOperationMenu: any;
|
|
14
15
|
columnTool: TableColumnTool;
|
|
15
16
|
tableScrollBar: TableScrollBar;
|
|
17
|
+
tableSelector: TableSelector;
|
|
18
|
+
isTableSelectorVisible: boolean;
|
|
19
|
+
tableSelectorWrapper: HTMLDivElement;
|
|
16
20
|
static register(): void;
|
|
17
21
|
constructor(quill: any, options: any);
|
|
22
|
+
initTableSelector(): void;
|
|
23
|
+
tableSelectorWrapperCreator(): HTMLDivElement;
|
|
18
24
|
handleMouseDown(evt: any, quill: any): void;
|
|
19
25
|
handleKeyDown(evt: any, quill: any): void;
|
|
20
26
|
handleCompositionstart(quill: any): void;
|
|
21
27
|
handleCompositionend(quill: any): void;
|
|
28
|
+
handleTableSelectorHover(): void;
|
|
29
|
+
handleTableSelectorMouseOut(): void;
|
|
22
30
|
getTable(range?: any): any[];
|
|
23
31
|
insertTable(rows: any, columns: any): void;
|
|
24
32
|
showTableTools(table: any, quill: any): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare class TableSelector {
|
|
2
|
+
private onSelect;
|
|
3
|
+
container: HTMLDivElement;
|
|
4
|
+
private grid;
|
|
5
|
+
private label;
|
|
6
|
+
private rows;
|
|
7
|
+
private cols;
|
|
8
|
+
private removeListenersArray;
|
|
9
|
+
constructor({ onSelect }: {
|
|
10
|
+
onSelect: (rows: number, cols: number) => void;
|
|
11
|
+
});
|
|
12
|
+
private initContainer;
|
|
13
|
+
private initGrid;
|
|
14
|
+
private initLabel;
|
|
15
|
+
private handleMouseOver;
|
|
16
|
+
private handleClick;
|
|
17
|
+
updateGrid(): void;
|
|
18
|
+
show(x: number, y: number): void;
|
|
19
|
+
hide(): void;
|
|
20
|
+
destroy(): any;
|
|
21
|
+
}
|
|
22
|
+
export default TableSelector;
|