@visactor/vtable-sheet 1.22.10 → 1.22.11-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/formula/formula-editor.d.ts +0 -1
- package/cjs/formula/formula-editor.js +1 -1
- package/cjs/formula/formula-editor.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/vtable-sheet.js +116 -30
- package/dist/vtable-sheet.min.js +1 -1
- package/es/formula/formula-editor.d.ts +0 -1
- package/es/formula/formula-editor.js +1 -1
- package/es/formula/formula-editor.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -4,7 +4,6 @@ import type { EditContext } from '@visactor/vtable-editors';
|
|
|
4
4
|
export declare class FormulaInputEditor extends VTable_editors.InputEditor {
|
|
5
5
|
private formulaAutocomplete;
|
|
6
6
|
private sheet;
|
|
7
|
-
private eventHandlers;
|
|
8
7
|
setSheet(sheet: VTableSheet): void;
|
|
9
8
|
getInputElement(): HTMLInputElement;
|
|
10
9
|
targetIsOnEditor(target: HTMLElement): boolean;
|
|
@@ -33,7 +33,7 @@ const VTable_editors = __importStar(require("@visactor/vtable-editors")), formul
|
|
|
33
33
|
|
|
34
34
|
class FormulaInputEditor extends VTable_editors.InputEditor {
|
|
35
35
|
constructor() {
|
|
36
|
-
super(...arguments), this.formulaAutocomplete = null, this.sheet = null
|
|
36
|
+
super(...arguments), this.formulaAutocomplete = null, this.sheet = null;
|
|
37
37
|
}
|
|
38
38
|
setSheet(sheet) {
|
|
39
39
|
this.sheet = sheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/formula/formula-editor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAA2D;AAC3D,iEAA6D;AAG7D,qDAAmE;AAEnE,MAAa,kBAAmB,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AEF,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;QAGjC,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,MAAM,EAAE;YAC9C,OAAO,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAC;SACjC;QAGD,OAAO,GAAG,QAAQ,GAAG,QAAQ,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;IACrD,CAAC;CACF;AAjUD,gDAiUC;AAEY,QAAA,aAAa,GAAG,IAAI,kBAAkB,EAAE,CAAC","file":"formula-editor.js","sourcesContent":["import * as VTable_editors from '@visactor/vtable-editors';\nimport { FormulaAutocomplete } from './formula-autocomplete';\nimport type VTableSheet from '../components/vtable-sheet';\nimport type { EditContext } from '@visactor/vtable-editors';\nimport { detectFunctionParameterPosition } from './formula-helper';\n\nexport class FormulaInputEditor extends VTable_editors.InputEditor {\n private formulaAutocomplete: FormulaAutocomplete | null = null;\n private sheet: VTableSheet | null = null;\n // 定义存储事件处理函数的数组\n private eventHandlers: Array<{ type: string; handler: EventListener }> = [];\n /**\n * 设置 Sheet 实例\n */\n setSheet(sheet: VTableSheet): void {\n this.sheet = sheet;\n }\n getInputElement(): HTMLInputElement {\n return this.element;\n }\n targetIsOnEditor(target: HTMLElement): boolean {\n return target === this.element || target === this.sheet.formulaUIManager.formulaInput;\n }\n /**\n * 创建编辑器元素\n * 重写父类方法以添加自动补全功能\n */\n createElement(): void {\n super.createElement();\n\n if (this.element && this.sheet) {\n const events = ['click', 'mouseup', 'keyup', 'select', 'input', 'focus'];\n events.forEach(eventType => {\n const handler = (e: Event) => {\n const cursorPos = this.element.selectionStart;\n if (cursorPos !== null && cursorPos !== undefined) {\n this.sheet.formulaManager.lastKnownCursorPosInFormulaInput = cursorPos;\n this.sheet.formulaManager.inputingElement = this.element;\n }\n };\n\n this.element.addEventListener(eventType, handler);\n this.eventHandlers.push({ type: eventType, handler });\n });\n\n // 添加输入事件监听\n const inputHandler = (e: Event) => {\n this.handleFormulaInput(e);\n };\n this.element.addEventListener('input', inputHandler);\n this.eventHandlers.push({ type: 'input', handler: inputHandler });\n\n // 延迟初始化自动补全\n setTimeout(() => {\n this.initAutocomplete();\n }, 50);\n }\n }\n\n /**\n * 处理公式输入\n */\n private handleFormulaInput(event: Event): void {\n if (!this.sheet || !this.element) {\n return;\n }\n\n const value = this.element.value;\n // 同步内容到顶部输入栏\n this.sheet.formulaUIManager.formulaInput.value = value;\n // const inputEvent = new Event('input', { bubbles: true });\n // Object.defineProperty(inputEvent, 'isFormulaInsertion', { value: true });\n // this.sheet.formulaUIManager.formulaInput.dispatchEvent(inputEvent);\n // 获取高亮管理器\n const highlightManager = this.sheet.formulaManager.cellHighlightManager;\n\n if (highlightManager) {\n if (value.startsWith('=')) {\n highlightManager.highlightFormulaCells(value);\n } else {\n highlightManager.clearHighlights();\n }\n }\n }\n\n /**\n * 初始化自动补全\n */\n private initAutocomplete(): void {\n if (!this.sheet || !this.element) {\n return;\n }\n\n // 清理之前的实例\n if (this.formulaAutocomplete) {\n this.formulaAutocomplete.release();\n this.formulaAutocomplete = null;\n }\n\n const tableContainer = this.sheet.getContentElement();\n\n this.formulaAutocomplete = new FormulaAutocomplete(tableContainer, this.sheet);\n\n // 自定义定位逻辑\n const customPositioning = () => {\n if (!this.formulaAutocomplete || !this.element) {\n return;\n }\n\n // 获取编辑器元素和容器的位置信息\n const inputRect = this.element.getBoundingClientRect();\n const containerRect = tableContainer.getBoundingClientRect();\n const windowHeight = window.innerHeight;\n\n // 计算相对于表格容器的位置\n const relativeLeft = inputRect.left - containerRect.left;\n\n // 计算下拉框的最大高度和理想宽度\n const maxDropdownHeight = 250; // 最大高度限制\n const idealWidth = Math.max(300, inputRect.width); // 理想宽度\n\n // 计算下拉框在下方显示时的顶部位置\n let relativeTop = inputRect.bottom - containerRect.top + 2;\n\n // 检查是否有足够空间在下方显示下拉框\n const spaceBelow = windowHeight - inputRect.bottom;\n const spaceAbove = inputRect.top;\n\n // 判断应该将下拉框放在输入框的上方还是下方\n if (spaceBelow < maxDropdownHeight && spaceAbove > spaceBelow) {\n // 空间不足且上方空间更大,则放在上方\n relativeTop = inputRect.top - containerRect.top - maxDropdownHeight - 2;\n }\n\n // 确保下拉框不会超出容器底部\n const bottomOverflow = relativeTop + maxDropdownHeight - containerRect.height;\n if (bottomOverflow > 0) {\n relativeTop = Math.max(0, relativeTop - bottomOverflow);\n }\n\n // 确保下拉框不会超出容器顶部\n if (relativeTop < 0) {\n relativeTop = 0;\n }\n\n // 设置下拉框位置和样式\n const dropdown = (this.formulaAutocomplete as any).dropdown;\n if (dropdown) {\n dropdown.style.position = 'absolute';\n dropdown.style.left = `${Math.max(0, relativeLeft)}px`;\n dropdown.style.top = `${relativeTop}px`;\n dropdown.style.width = `${idealWidth}px`;\n dropdown.style.maxHeight = `${maxDropdownHeight}px`;\n dropdown.style.overflowY = 'auto';\n dropdown.style.zIndex = '10000';\n dropdown.style.boxShadow = '0 2px 8px rgba(0, 0, 0, 0.15)';\n }\n };\n\n // 附加自动补全到输入框\n this.formulaAutocomplete.attachTo(\n this.element,\n item => {\n // 当选择项目时的回调函数\n this.handleAutocompleteSelect(item);\n },\n customPositioning\n );\n }\n\n /**\n * 处理自动补全选择\n */\n private handleAutocompleteSelect(item: any): void {\n if (!this.element || !this.sheet) {\n return;\n }\n this.element.value = '=' + item.value;\n // 同步内容到顶部输入栏\n this.sheet.formulaUIManager.formulaInput.value = this.element.value;\n\n // 触发高亮更新\n const highlightManager = this.sheet.formulaManager.cellHighlightManager;\n if (highlightManager && this.element.value.startsWith('=')) {\n highlightManager.highlightFormulaCells(this.element.value);\n }\n }\n\n /**\n * 开始编辑\n * 重写父类方法\n */\n onStart(context: EditContext<string>): void {\n // 获取公式\n const formula = this.sheet.formulaManager.getCellFormula({\n sheet: this.sheet.getActiveSheet()?.getKey() || '',\n row: context.row,\n col: context.col\n });\n if (formula) {\n context.value = formula;\n }\n super.onStart(context);\n this.sheet.formulaManager.inputingElement = this.element;\n // 如果是公式,显示公式而不是计算结果\n if (this.sheet && typeof context.value === 'string') {\n const formula = this.sheet.formulaManager.getCellFormula({\n sheet: this.sheet.getActiveSheet()?.getKey() || '',\n row: context.row,\n col: context.col\n });\n\n if (formula) {\n this.setValue(formula);\n // 触发高亮\n const highlightManager = this.sheet.formulaManager.cellHighlightManager;\n if (highlightManager) {\n highlightManager.highlightFormulaCells(formula);\n }\n }\n }\n }\n beforeEnd(): void {\n this.sheet.formulaManager.formulaWorkingOnCell = null;\n }\n /**\n * 结束编辑\n * 重写父类方法以清理自动补全\n */\n onEnd(): void {\n if (this.formulaAutocomplete) {\n this.formulaAutocomplete.release();\n this.formulaAutocomplete = null;\n }\n if (this.sheet) {\n const highlightManager = this.sheet.formulaManager.cellHighlightManager;\n if (highlightManager) {\n highlightManager.clearHighlights();\n }\n }\n //解绑所有事件\n // 解绑事件(在需要解绑的地方)\n this.element &&\n this.eventHandlers.forEach(({ type, handler }) => {\n this.element.removeEventListener(type, handler);\n });\n super.onEnd();\n }\n\n /**\n * 获取编辑器的值\n */\n getValue(): string {\n return this.element?.value || '';\n }\n\n validateValue(\n newValue?: any,\n oldValue?: any,\n position?: VTable_editors.CellAddress,\n table?: any,\n isClickOnTable?: boolean\n ): boolean | VTable_editors.ValidateEnum {\n // 判断点击到表格其他单元格,且输入了公式,则检查公式是否完整\n if (isClickOnTable && newValue && newValue.startsWith('=')) {\n // 如果有sheet实例,使用FormulaManager检查公式完整性\n if (this.sheet) {\n const formulaInput = this.element;\n this.sheet.formulaManager.inputIsParamMode = detectFunctionParameterPosition(\n formulaInput.value,\n this.sheet.formulaManager.lastKnownCursorPosInFormulaInput\n );\n if (this.sheet.formulaManager.inputIsParamMode.inParamMode) {\n // // 如果公式不完整,不退出编辑状态 TODO 这里不应该只判断完整性,如这种情况下按住ctrl连续点选 =SUM(H5) 这种情况应该允许继续编辑输入点选单元格范围\n // if (!formulaManager.isFormulaComplete(newValue)) {\n\n this.sheet.formulaManager.formulaWorkingOnCell = this.sheet.getActiveSheet()?.editingCell;\n\n return VTable_editors.ValidateEnum.validateNotExit;\n }\n return VTable_editors.ValidateEnum.validateExit;\n }\n // 如果没有sheet实例,使用简单的括号匹配检查\n const openParenCount = (newValue.match(/\\(/g) || []).length;\n const closeParenCount = (newValue.match(/\\)/g) || []).length;\n if (openParenCount !== closeParenCount) {\n return VTable_editors.ValidateEnum.validateNotExit;\n }\n }\n return true;\n }\n\n /**\n * 将选中的单元格范围转换为公式引用字符串\n * 例如:A1:B3\n */\n private getCellRangeString(range: {\n start: { col: number; row: number };\n end: { col: number; row: number };\n }): string {\n if (!range || !range.start || !range.end) {\n return '';\n }\n\n // 将列索引转换为字母表示(0->A, 1->B, 等)\n const colToLetter = (col: number): string => {\n let letter = '';\n while (col >= 0) {\n letter = String.fromCharCode(65 + (col % 26)) + letter;\n col = Math.floor(col / 26) - 1;\n }\n return letter;\n };\n\n const startCol = colToLetter(range.start.col);\n const startRow = range.start.row + 1; // 行索引从1开始\n const endCol = colToLetter(range.end.col);\n const endRow = range.end.row + 1;\n\n // 如果是单个单元格\n if (startCol === endCol && startRow === endRow) {\n return `${startCol}${startRow}`;\n }\n\n // 如果是范围\n return `${startCol}${startRow}:${endCol}${endRow}`;\n }\n}\n\nexport const formulaEditor = new FormulaInputEditor();\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/formula/formula-editor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAA2D;AAC3D,iEAA6D;AAG7D,qDAAmE;AAEnE,MAAa,kBAAmB,SAAQ,cAAc,CAAC,WAAW;I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GAAG,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;QAGjC,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,MAAM,EAAE;YAC9C,OAAO,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAC;SACjC;QAGD,OAAO,GAAG,QAAQ,GAAG,QAAQ,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;IACrD,CAAC;CACF;AA/TD,gDA+TC;AAEY,QAAA,aAAa,GAAG,IAAI,kBAAkB,EAAE,CAAC","file":"formula-editor.js","sourcesContent":["import * as VTable_editors from '@visactor/vtable-editors';\nimport { FormulaAutocomplete } from './formula-autocomplete';\nimport type VTableSheet from '../components/vtable-sheet';\nimport type { EditContext } from '@visactor/vtable-editors';\nimport { detectFunctionParameterPosition } from './formula-helper';\n\nexport class FormulaInputEditor extends VTable_editors.InputEditor {\n private formulaAutocomplete: FormulaAutocomplete | null = null;\n private sheet: VTableSheet | null = null;\n /**\n * 设置 Sheet 实例\n */\n setSheet(sheet: VTableSheet): void {\n this.sheet = sheet;\n }\n getInputElement(): HTMLInputElement {\n return this.element;\n }\n targetIsOnEditor(target: HTMLElement): boolean {\n return target === this.element || target === this.sheet.formulaUIManager.formulaInput;\n }\n /**\n * 创建编辑器元素\n * 重写父类方法以添加自动补全功能\n */\n createElement(): void {\n super.createElement();\n\n if (this.element && this.sheet) {\n const events = ['click', 'mouseup', 'keyup', 'select', 'input', 'focus'];\n events.forEach(eventType => {\n const handler = (e: Event) => {\n const cursorPos = this.element.selectionStart;\n if (cursorPos !== null && cursorPos !== undefined) {\n this.sheet.formulaManager.lastKnownCursorPosInFormulaInput = cursorPos;\n this.sheet.formulaManager.inputingElement = this.element;\n }\n };\n\n this.element.addEventListener(eventType, handler);\n this.eventHandlers.push({ type: eventType, handler });\n });\n\n // 添加输入事件监听\n const inputHandler = (e: Event) => {\n this.handleFormulaInput(e);\n };\n this.element.addEventListener('input', inputHandler);\n this.eventHandlers.push({ type: 'input', handler: inputHandler });\n\n // 延迟初始化自动补全\n setTimeout(() => {\n this.initAutocomplete();\n }, 50);\n }\n }\n\n /**\n * 处理公式输入\n */\n private handleFormulaInput(event: Event): void {\n if (!this.sheet || !this.element) {\n return;\n }\n\n const value = this.element.value;\n // 同步内容到顶部输入栏\n this.sheet.formulaUIManager.formulaInput.value = value;\n // const inputEvent = new Event('input', { bubbles: true });\n // Object.defineProperty(inputEvent, 'isFormulaInsertion', { value: true });\n // this.sheet.formulaUIManager.formulaInput.dispatchEvent(inputEvent);\n // 获取高亮管理器\n const highlightManager = this.sheet.formulaManager.cellHighlightManager;\n\n if (highlightManager) {\n if (value.startsWith('=')) {\n highlightManager.highlightFormulaCells(value);\n } else {\n highlightManager.clearHighlights();\n }\n }\n }\n\n /**\n * 初始化自动补全\n */\n private initAutocomplete(): void {\n if (!this.sheet || !this.element) {\n return;\n }\n\n // 清理之前的实例\n if (this.formulaAutocomplete) {\n this.formulaAutocomplete.release();\n this.formulaAutocomplete = null;\n }\n\n const tableContainer = this.sheet.getContentElement();\n\n this.formulaAutocomplete = new FormulaAutocomplete(tableContainer, this.sheet);\n\n // 自定义定位逻辑\n const customPositioning = () => {\n if (!this.formulaAutocomplete || !this.element) {\n return;\n }\n\n // 获取编辑器元素和容器的位置信息\n const inputRect = this.element.getBoundingClientRect();\n const containerRect = tableContainer.getBoundingClientRect();\n const windowHeight = window.innerHeight;\n\n // 计算相对于表格容器的位置\n const relativeLeft = inputRect.left - containerRect.left;\n\n // 计算下拉框的最大高度和理想宽度\n const maxDropdownHeight = 250; // 最大高度限制\n const idealWidth = Math.max(300, inputRect.width); // 理想宽度\n\n // 计算下拉框在下方显示时的顶部位置\n let relativeTop = inputRect.bottom - containerRect.top + 2;\n\n // 检查是否有足够空间在下方显示下拉框\n const spaceBelow = windowHeight - inputRect.bottom;\n const spaceAbove = inputRect.top;\n\n // 判断应该将下拉框放在输入框的上方还是下方\n if (spaceBelow < maxDropdownHeight && spaceAbove > spaceBelow) {\n // 空间不足且上方空间更大,则放在上方\n relativeTop = inputRect.top - containerRect.top - maxDropdownHeight - 2;\n }\n\n // 确保下拉框不会超出容器底部\n const bottomOverflow = relativeTop + maxDropdownHeight - containerRect.height;\n if (bottomOverflow > 0) {\n relativeTop = Math.max(0, relativeTop - bottomOverflow);\n }\n\n // 确保下拉框不会超出容器顶部\n if (relativeTop < 0) {\n relativeTop = 0;\n }\n\n // 设置下拉框位置和样式\n const dropdown = (this.formulaAutocomplete as any).dropdown;\n if (dropdown) {\n dropdown.style.position = 'absolute';\n dropdown.style.left = `${Math.max(0, relativeLeft)}px`;\n dropdown.style.top = `${relativeTop}px`;\n dropdown.style.width = `${idealWidth}px`;\n dropdown.style.maxHeight = `${maxDropdownHeight}px`;\n dropdown.style.overflowY = 'auto';\n dropdown.style.zIndex = '10000';\n dropdown.style.boxShadow = '0 2px 8px rgba(0, 0, 0, 0.15)';\n }\n };\n\n // 附加自动补全到输入框\n this.formulaAutocomplete.attachTo(\n this.element,\n item => {\n // 当选择项目时的回调函数\n this.handleAutocompleteSelect(item);\n },\n customPositioning\n );\n }\n\n /**\n * 处理自动补全选择\n */\n private handleAutocompleteSelect(item: any): void {\n if (!this.element || !this.sheet) {\n return;\n }\n this.element.value = '=' + item.value;\n // 同步内容到顶部输入栏\n this.sheet.formulaUIManager.formulaInput.value = this.element.value;\n\n // 触发高亮更新\n const highlightManager = this.sheet.formulaManager.cellHighlightManager;\n if (highlightManager && this.element.value.startsWith('=')) {\n highlightManager.highlightFormulaCells(this.element.value);\n }\n }\n\n /**\n * 开始编辑\n * 重写父类方法\n */\n onStart(context: EditContext<string>): void {\n // 获取公式\n const formula = this.sheet.formulaManager.getCellFormula({\n sheet: this.sheet.getActiveSheet()?.getKey() || '',\n row: context.row,\n col: context.col\n });\n if (formula) {\n context.value = formula;\n }\n super.onStart(context);\n this.sheet.formulaManager.inputingElement = this.element;\n // 如果是公式,显示公式而不是计算结果\n if (this.sheet && typeof context.value === 'string') {\n const formula = this.sheet.formulaManager.getCellFormula({\n sheet: this.sheet.getActiveSheet()?.getKey() || '',\n row: context.row,\n col: context.col\n });\n\n if (formula) {\n this.setValue(formula);\n // 触发高亮\n const highlightManager = this.sheet.formulaManager.cellHighlightManager;\n if (highlightManager) {\n highlightManager.highlightFormulaCells(formula);\n }\n }\n }\n }\n beforeEnd(): void {\n this.sheet.formulaManager.formulaWorkingOnCell = null;\n }\n /**\n * 结束编辑\n * 重写父类方法以清理自动补全\n */\n onEnd(): void {\n if (this.formulaAutocomplete) {\n this.formulaAutocomplete.release();\n this.formulaAutocomplete = null;\n }\n if (this.sheet) {\n const highlightManager = this.sheet.formulaManager.cellHighlightManager;\n if (highlightManager) {\n highlightManager.clearHighlights();\n }\n }\n //解绑所有事件\n // 解绑事件(在需要解绑的地方)\n this.element &&\n this.eventHandlers.forEach(({ type, handler }) => {\n this.element.removeEventListener(type, handler);\n });\n super.onEnd();\n }\n\n /**\n * 获取编辑器的值\n */\n getValue(): string {\n return this.element?.value || '';\n }\n\n validateValue(\n newValue?: any,\n oldValue?: any,\n position?: VTable_editors.CellAddress,\n table?: any,\n isClickOnTable?: boolean\n ): boolean | VTable_editors.ValidateEnum {\n // 判断点击到表格其他单元格,且输入了公式,则检查公式是否完整\n if (isClickOnTable && newValue && newValue.startsWith('=')) {\n // 如果有sheet实例,使用FormulaManager检查公式完整性\n if (this.sheet) {\n const formulaInput = this.element;\n this.sheet.formulaManager.inputIsParamMode = detectFunctionParameterPosition(\n formulaInput.value,\n this.sheet.formulaManager.lastKnownCursorPosInFormulaInput\n );\n if (this.sheet.formulaManager.inputIsParamMode.inParamMode) {\n // // 如果公式不完整,不退出编辑状态 TODO 这里不应该只判断完整性,如这种情况下按住ctrl连续点选 =SUM(H5) 这种情况应该允许继续编辑输入点选单元格范围\n // if (!formulaManager.isFormulaComplete(newValue)) {\n\n this.sheet.formulaManager.formulaWorkingOnCell = this.sheet.getActiveSheet()?.editingCell;\n\n return VTable_editors.ValidateEnum.validateNotExit;\n }\n return VTable_editors.ValidateEnum.validateExit;\n }\n // 如果没有sheet实例,使用简单的括号匹配检查\n const openParenCount = (newValue.match(/\\(/g) || []).length;\n const closeParenCount = (newValue.match(/\\)/g) || []).length;\n if (openParenCount !== closeParenCount) {\n return VTable_editors.ValidateEnum.validateNotExit;\n }\n }\n return true;\n }\n\n /**\n * 将选中的单元格范围转换为公式引用字符串\n * 例如:A1:B3\n */\n private getCellRangeString(range: {\n start: { col: number; row: number };\n end: { col: number; row: number };\n }): string {\n if (!range || !range.start || !range.end) {\n return '';\n }\n\n // 将列索引转换为字母表示(0->A, 1->B, 等)\n const colToLetter = (col: number): string => {\n let letter = '';\n while (col >= 0) {\n letter = String.fromCharCode(65 + (col % 26)) + letter;\n col = Math.floor(col / 26) - 1;\n }\n return letter;\n };\n\n const startCol = colToLetter(range.start.col);\n const startRow = range.start.row + 1; // 行索引从1开始\n const endCol = colToLetter(range.end.col);\n const endRow = range.end.row + 1;\n\n // 如果是单个单元格\n if (startCol === endCol && startRow === endRow) {\n return `${startCol}${startRow}`;\n }\n\n // 如果是范围\n return `${startCol}${startRow}:${endCol}${endRow}`;\n }\n}\n\nexport const formulaEditor = new FormulaInputEditor();\n"]}
|
package/cjs/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import VTableSheet from './components/vtable-sheet';
|
|
|
2
2
|
import type { ISheetDefine, IVTableSheetOptions } from './ts-types';
|
|
3
3
|
import * as TYPES from './ts-types';
|
|
4
4
|
import * as VTable from './vtable';
|
|
5
|
-
export declare const version = "1.22.
|
|
5
|
+
export declare const version = "1.22.11-alpha.1";
|
|
6
6
|
export { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };
|
package/cjs/index.js
CHANGED
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,IAAA,4BAAY,GAAE,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.22.11-alpha.1\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
|
package/dist/vtable-sheet.js
CHANGED
|
@@ -38828,6 +38828,7 @@
|
|
|
38828
38828
|
AFTER_UPDATE_CELL_CONTENT_WIDTH: "after_update_cell_content_width",
|
|
38829
38829
|
AFTER_UPDATE_SELECT_BORDER_HEIGHT: "after_update_select_border_height",
|
|
38830
38830
|
CHANGE_CELL_VALUE: "change_cell_value",
|
|
38831
|
+
CHANGE_CELL_VALUES: "change_cell_values",
|
|
38831
38832
|
DRAG_FILL_HANDLE_END: "drag_fill_handle_end",
|
|
38832
38833
|
MOUSEDOWN_FILL_HANDLE: "mousedown_fill_handle",
|
|
38833
38834
|
DBLCLICK_FILL_HANDLE: "dblclick_fill_handle",
|
|
@@ -57774,7 +57775,13 @@
|
|
|
57774
57775
|
try {
|
|
57775
57776
|
const selectCells = this.cutCellRange;
|
|
57776
57777
|
if (!selectCells || 0 === selectCells.length) return;
|
|
57777
|
-
|
|
57778
|
+
const changeValues = [];
|
|
57779
|
+
for (let i = 0; i < selectCells.length; i++) for (let j = 0; j < selectCells[i].length; j++) selectCells[i][j] && changeValues.push({
|
|
57780
|
+
col: selectCells[i][j].col,
|
|
57781
|
+
row: selectCells[i][j].row,
|
|
57782
|
+
value: void 0
|
|
57783
|
+
});
|
|
57784
|
+
table.changeCellValuesByIds(changeValues);
|
|
57778
57785
|
} catch (error) {}
|
|
57779
57786
|
}
|
|
57780
57787
|
checkClipboardChanged() {
|
|
@@ -60017,7 +60024,7 @@
|
|
|
60017
60024
|
}
|
|
60018
60025
|
constructor(container, options = {}) {
|
|
60019
60026
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
60020
|
-
if (super(), this.showFrozenIcon = !0, this.version = "1.22.
|
|
60027
|
+
if (super(), this.showFrozenIcon = !0, this.version = "1.22.11-alpha.1", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env$1.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
|
|
60021
60028
|
this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
|
|
60022
60029
|
options: options,
|
|
60023
60030
|
container: container
|
|
@@ -63828,15 +63835,16 @@
|
|
|
63828
63835
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
63829
63836
|
});
|
|
63830
63837
|
};
|
|
63831
|
-
function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table) {
|
|
63838
|
+
function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, silentChangeCellValuesEvent) {
|
|
63832
63839
|
if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
|
|
63833
|
-
const
|
|
63840
|
+
const recordShowIndex = table.getRecordShowIndexByCell(col, row),
|
|
63841
|
+
recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
|
|
63834
63842
|
{
|
|
63835
63843
|
field: field
|
|
63836
63844
|
} = table.internalProps.layoutMap.getBody(col, row),
|
|
63837
63845
|
beforeChangeValue = table.getCellRawValue(col, row),
|
|
63838
63846
|
oldValue = table.getCellOriginValue(col, row);
|
|
63839
|
-
table.isHeader(col, row) ? table.internalProps.layoutMap.updateColumnTitle(col, row, value) : table.dataSource.changeFieldValue(value,
|
|
63847
|
+
table.isHeader(col, row) ? table.internalProps.layoutMap.updateColumnTitle(col, row, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, col, row, table);
|
|
63840
63848
|
const range = table.getCellRange(col, row),
|
|
63841
63849
|
aggregators = table.internalProps.layoutMap.getAggregatorsByCell(col, row);
|
|
63842
63850
|
if (aggregators) {
|
|
@@ -63859,16 +63867,24 @@
|
|
|
63859
63867
|
table.scenegraph.updateRowHeight(row, newHeight - oldHeight);
|
|
63860
63868
|
}
|
|
63861
63869
|
const changedValue = table.getCellOriginValue(col, row);
|
|
63862
|
-
oldValue !== changedValue && triggerEvent
|
|
63863
|
-
|
|
63864
|
-
|
|
63865
|
-
|
|
63866
|
-
|
|
63867
|
-
|
|
63868
|
-
|
|
63870
|
+
if (oldValue !== changedValue && triggerEvent) {
|
|
63871
|
+
const changeValue = {
|
|
63872
|
+
col: col,
|
|
63873
|
+
row: row,
|
|
63874
|
+
recordIndex: recordIndex,
|
|
63875
|
+
field: field,
|
|
63876
|
+
rawValue: beforeChangeValue,
|
|
63877
|
+
currentValue: oldValue,
|
|
63878
|
+
changedValue: changedValue
|
|
63879
|
+
};
|
|
63880
|
+
table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue), silentChangeCellValuesEvent || table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
|
|
63881
|
+
values: [changeValue]
|
|
63882
|
+
});
|
|
63883
|
+
}
|
|
63884
|
+
table.scenegraph.updateNextFrame();
|
|
63869
63885
|
}
|
|
63870
63886
|
}
|
|
63871
|
-
function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table) {
|
|
63887
|
+
function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, silentChangeCellValuesEvent) {
|
|
63872
63888
|
var _a, _b;
|
|
63873
63889
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63874
63890
|
const changedCellResults = [];
|
|
@@ -63890,6 +63906,7 @@
|
|
|
63890
63906
|
oldRowValues.push(oldValue);
|
|
63891
63907
|
}
|
|
63892
63908
|
}
|
|
63909
|
+
const resultChangeValues = [];
|
|
63893
63910
|
for (let i = 0; i < values.length && !(startRow + i > table.rowCount - 1); i++) {
|
|
63894
63911
|
changedCellResults[i] = [], pasteRowEnd = startRow + i;
|
|
63895
63912
|
const rowValues = values[i];
|
|
@@ -63913,25 +63930,34 @@
|
|
|
63913
63930
|
if (isCanChange) {
|
|
63914
63931
|
changedCellResults[i][j] = !0;
|
|
63915
63932
|
const value = rowValues[j],
|
|
63916
|
-
|
|
63933
|
+
recordShowIndex = table.getRecordShowIndexByCell(startCol + j, startRow + i),
|
|
63934
|
+
recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
|
|
63917
63935
|
{
|
|
63918
63936
|
field: field
|
|
63919
63937
|
} = table.internalProps.layoutMap.getBody(startCol + j, startRow + i),
|
|
63920
63938
|
beforeChangeValue = beforeChangeValues[i][j],
|
|
63921
63939
|
oldValue = oldValues[i][j];
|
|
63922
|
-
table.isHeader(startCol + j, startRow + i) ? table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value) : table.dataSource.changeFieldValue(value,
|
|
63940
|
+
table.isHeader(startCol + j, startRow + i) ? table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
|
|
63923
63941
|
const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
|
|
63924
|
-
oldValue !== changedValue && triggerEvent
|
|
63925
|
-
|
|
63926
|
-
|
|
63927
|
-
|
|
63928
|
-
|
|
63929
|
-
|
|
63930
|
-
|
|
63942
|
+
if (oldValue !== changedValue && triggerEvent) {
|
|
63943
|
+
const changeValue = {
|
|
63944
|
+
col: startCol + j,
|
|
63945
|
+
row: startRow + i,
|
|
63946
|
+
recordIndex: recordIndex,
|
|
63947
|
+
field: field,
|
|
63948
|
+
rawValue: beforeChangeValue,
|
|
63949
|
+
currentValue: oldValue,
|
|
63950
|
+
changedValue: changedValue
|
|
63951
|
+
};
|
|
63952
|
+
table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue), resultChangeValues.push(changeValue);
|
|
63953
|
+
}
|
|
63931
63954
|
} else changedCellResults[i][j] = !1;
|
|
63932
63955
|
}
|
|
63933
63956
|
pasteColEnd = Math.max(pasteColEnd, thisRowPasteColEnd);
|
|
63934
63957
|
}
|
|
63958
|
+
silentChangeCellValuesEvent || table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
|
|
63959
|
+
values: resultChangeValues
|
|
63960
|
+
});
|
|
63935
63961
|
const startRange = table.getCellRange(startCol, startRow),
|
|
63936
63962
|
range = table.getCellRange(pasteColEnd, pasteRowEnd),
|
|
63937
63963
|
aggregators = table.internalProps.layoutMap.getAggregatorsByCellRange(startRange.start.col, startRange.start.row, range.end.col, range.end.row);
|
|
@@ -63965,6 +63991,36 @@
|
|
|
63965
63991
|
return table.scenegraph.updateNextFrame(), changedCellResults;
|
|
63966
63992
|
});
|
|
63967
63993
|
}
|
|
63994
|
+
function listTableChangeCellValuesByIds(changeValues, triggerEvent, table, silentChangeCellValuesEvent) {
|
|
63995
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63996
|
+
const resultChangeValues = [];
|
|
63997
|
+
for (let i = 0; i < changeValues.length; i++) {
|
|
63998
|
+
const {
|
|
63999
|
+
col: col,
|
|
64000
|
+
row: row,
|
|
64001
|
+
value: value
|
|
64002
|
+
} = changeValues[i],
|
|
64003
|
+
recordShowIndex = table.getRecordShowIndexByCell(col, row),
|
|
64004
|
+
recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
|
|
64005
|
+
{
|
|
64006
|
+
field: field
|
|
64007
|
+
} = table.internalProps.layoutMap.getBody(col, row),
|
|
64008
|
+
oldValue = table.getCellOriginValue(col, row);
|
|
64009
|
+
listTableChangeCellValue(col, row, value, !1, triggerEvent, table, !0), oldValue !== value && triggerEvent && resultChangeValues.push({
|
|
64010
|
+
col: col,
|
|
64011
|
+
row: row,
|
|
64012
|
+
recordIndex: recordIndex,
|
|
64013
|
+
field: field,
|
|
64014
|
+
rawValue: oldValue,
|
|
64015
|
+
currentValue: oldValue,
|
|
64016
|
+
changedValue: value
|
|
64017
|
+
});
|
|
64018
|
+
}
|
|
64019
|
+
silentChangeCellValuesEvent || table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
|
|
64020
|
+
values: resultChangeValues
|
|
64021
|
+
});
|
|
64022
|
+
});
|
|
64023
|
+
}
|
|
63968
64024
|
function getCellUpdateType(col, row, table, oldCellUpdateType) {
|
|
63969
64025
|
if ("group" === oldCellUpdateType) return oldCellUpdateType;
|
|
63970
64026
|
if ("sort" === oldCellUpdateType && !table.internalProps.groupBy) return oldCellUpdateType;
|
|
@@ -65128,11 +65184,37 @@
|
|
|
65128
65184
|
}
|
|
65129
65185
|
return isValid$2(editorDefine);
|
|
65130
65186
|
}
|
|
65131
|
-
changeCellValue(col, row, value, workOnEditableCell = !1, triggerEvent = !0) {
|
|
65132
|
-
return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this);
|
|
65133
|
-
}
|
|
65134
|
-
changeCellValues(startCol, startRow, values, workOnEditableCell = !1, triggerEvent = !0) {
|
|
65135
|
-
return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this);
|
|
65187
|
+
changeCellValue(col, row, value, workOnEditableCell = !1, triggerEvent = !0, silentChangeCellValuesEvent) {
|
|
65188
|
+
return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this, silentChangeCellValuesEvent);
|
|
65189
|
+
}
|
|
65190
|
+
changeCellValues(startCol, startRow, values, workOnEditableCell = !1, triggerEvent = !0, silentChangeCellValuesEvent) {
|
|
65191
|
+
return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this, silentChangeCellValuesEvent);
|
|
65192
|
+
}
|
|
65193
|
+
changeCellValuesByIds(changeValues, triggerEvent = !0, silentChangeCellValuesEvent) {
|
|
65194
|
+
return listTableChangeCellValuesByIds(changeValues, triggerEvent, this, silentChangeCellValuesEvent);
|
|
65195
|
+
}
|
|
65196
|
+
changeSourceCellValue(recordIndex, field, value) {
|
|
65197
|
+
const tableIndex = this.getTableIndexByRecordIndex(recordIndex),
|
|
65198
|
+
cellAddr = this.getCellAddrByFieldRecord(field, recordIndex);
|
|
65199
|
+
if (tableIndex < 0 || cellAddr.col < 0 || cellAddr.row < 0) return;
|
|
65200
|
+
this.dataSource.changeFieldValue(value, tableIndex, field, cellAddr.col, cellAddr.row, this);
|
|
65201
|
+
const beforeChangeValue = this.getCellRawValue(cellAddr.col, cellAddr.row),
|
|
65202
|
+
oldValue = this.getCellOriginValue(cellAddr.col, cellAddr.row),
|
|
65203
|
+
changedValue = this.getCellOriginValue(cellAddr.col, cellAddr.row);
|
|
65204
|
+
if (oldValue !== changedValue) {
|
|
65205
|
+
const changeValue = {
|
|
65206
|
+
col: cellAddr.col,
|
|
65207
|
+
row: cellAddr.row,
|
|
65208
|
+
recordIndex: recordIndex,
|
|
65209
|
+
field: field,
|
|
65210
|
+
rawValue: beforeChangeValue,
|
|
65211
|
+
currentValue: oldValue,
|
|
65212
|
+
changedValue: changedValue
|
|
65213
|
+
};
|
|
65214
|
+
this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue), this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
|
|
65215
|
+
values: [changeValue]
|
|
65216
|
+
});
|
|
65217
|
+
}
|
|
65136
65218
|
}
|
|
65137
65219
|
addRecord(record, recordIndex) {
|
|
65138
65220
|
var _a;
|
|
@@ -65154,11 +65236,16 @@
|
|
|
65154
65236
|
}
|
|
65155
65237
|
deleteRecords(recordIndexs) {
|
|
65156
65238
|
var _a;
|
|
65157
|
-
|
|
65239
|
+
const deletedRecords = [];
|
|
65240
|
+
(null == recordIndexs ? void 0 : recordIndexs.length) > 0 && recordIndexs.forEach(index => {
|
|
65241
|
+
let record = null;
|
|
65242
|
+
record = "number" == typeof index ? this.dataSource.get(index) : [], deletedRecords.push(record);
|
|
65243
|
+
}), listTableDeleteRecords(recordIndexs, this), adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible();
|
|
65158
65244
|
const rowIndexs = [];
|
|
65159
65245
|
for (let i = 0; i < recordIndexs.length; i++) rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
|
|
65160
65246
|
this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
|
|
65161
65247
|
recordIndexs: recordIndexs,
|
|
65248
|
+
records: deletedRecords,
|
|
65162
65249
|
rowIndexs: rowIndexs,
|
|
65163
65250
|
deletedCount: (Array.isArray(recordIndexs[0]), recordIndexs.length)
|
|
65164
65251
|
});
|
|
@@ -84316,7 +84403,6 @@
|
|
|
84316
84403
|
class FormulaInputEditor extends InputEditor {
|
|
84317
84404
|
formulaAutocomplete = null;
|
|
84318
84405
|
sheet = null;
|
|
84319
|
-
eventHandlers = [];
|
|
84320
84406
|
setSheet(sheet) {
|
|
84321
84407
|
this.sheet = sheet;
|
|
84322
84408
|
}
|
|
@@ -91003,7 +91089,7 @@
|
|
|
91003
91089
|
importStyle();
|
|
91004
91090
|
}
|
|
91005
91091
|
|
|
91006
|
-
const version = "1.22.
|
|
91092
|
+
const version = "1.22.11-alpha.1";
|
|
91007
91093
|
importStyles();
|
|
91008
91094
|
|
|
91009
91095
|
exports.TYPES = index;
|