office-viewer 0.3.5 → 0.3.7
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/esm/common/autoParse.js +7 -1
- package/esm/excel/edit/ui/CellEditor.d.ts +1 -0
- package/esm/excel/edit/ui/CellEditor.js +18 -5
- package/esm/excel/io/excel/util/Range.d.ts +1 -1
- package/esm/excel/render/autoFilter/AutoFilterIconUI.d.ts +2 -0
- package/esm/excel/render/autoFilter/AutoFilterIconUI.js +5 -1
- package/esm/excel/render/autoFilter/filterColumn/CustomFiltersUI.js +9 -3
- package/esm/excel/render/cell/drawCells.js +1 -1
- package/esm/excel/render/cell/frozen/drawFrozen.d.ts +1 -1
- package/esm/excel/render/cell/frozen/getFrozenLeftViewPointRange.d.ts +1 -1
- package/esm/excel/render/cell/frozen/getFrozenTopLeftViewPointRange.d.ts +1 -1
- package/esm/excel/render/cell/frozen/getFrozenTopViewPointRange.d.ts +1 -1
- package/esm/excel/render/dnd/DragState.d.ts +1 -1
- package/esm/excel/render/drawing/drawDrawing.d.ts +1 -1
- package/esm/excel/render/drawing/findPositionInViewRange.d.ts +1 -1
- package/esm/excel/render/drawing/getRectFromAnchorPoint.d.ts +1 -1
- package/esm/excel/render/formulaBar/FormulaBar.js +7 -3
- package/esm/excel/render/grid/drawGridLines.d.ts +1 -1
- package/esm/excel/render/header/drawRowColHeaders.d.ts +1 -1
- package/esm/excel/render/header/drawRowColHeaders.js +3 -0
- package/esm/excel/render/selection/SheetSelection.d.ts +1 -1
- package/esm/excel/render/selection/binarySearchSize.d.ts +1 -1
- package/esm/excel/render/selection/findCell.d.ts +1 -1
- package/esm/excel/render/selection/findInViewRange.d.ts +1 -1
- package/esm/excel/render/selection/findInViewRangeX.d.ts +1 -1
- package/esm/excel/render/selection/findInViewRangeY.d.ts +1 -1
- package/esm/excel/render/selection/getCellPosition.d.ts +1 -1
- package/esm/excel/render/selection/getRangePosition.d.ts +1 -1
- package/esm/excel/render/selection/hitTest.d.ts +1 -1
- package/esm/excel/render/selection/hitTestInRange.d.ts +1 -1
- package/esm/excel/render/sparkline/drawSparkline.d.ts +1 -1
- package/esm/excel/render/ui/CheckBoxList.js +6 -2
- package/esm/excel/render/ui/Input.d.ts +9 -1
- package/esm/excel/render/ui/Input.js +15 -11
- package/esm/excel/types/X14Sparkline/X14SparklineGroup.d.ts +1 -1
- package/esm/excel/types/X14Sparkline/X14SparklineGroup.js +1 -1
- package/esm/excel/types/worksheet/CellData.js +10 -0
- package/esm/util/__tests__/replaceVar.test.d.ts +1 -1
- package/esm/util/__tests__/xmlToNode.test.d.ts +1 -0
- package/esm/util/onClickOutside.d.ts +2 -2
- package/esm/util/onClickOutside.js +4 -1
- package/esm/util/onClickOutsideOnce.d.ts +4 -0
- package/esm/util/onClickOutsideOnce.js +14 -0
- package/esm/util/xmlToNode.d.ts +5 -0
- package/lib/common/autoParse.js +7 -1
- package/lib/excel/edit/ui/CellEditor.d.ts +1 -0
- package/lib/excel/edit/ui/CellEditor.js +18 -5
- package/lib/excel/io/excel/util/Range.d.ts +1 -1
- package/lib/excel/lang/lang.d.ts +1 -1
- package/lib/excel/render/autoFilter/AutoFilterIconUI.d.ts +2 -0
- package/lib/excel/render/autoFilter/AutoFilterIconUI.js +5 -1
- package/lib/excel/render/autoFilter/filterColumn/CustomFiltersUI.js +9 -3
- package/lib/excel/render/autoFilter/sortState/getColumnSortOrder.d.ts +1 -1
- package/lib/excel/render/cell/drawCells.js +1 -1
- package/lib/excel/render/cell/frozen/drawFrozen.d.ts +1 -1
- package/lib/excel/render/cell/frozen/getFrozenLeftViewPointRange.d.ts +1 -1
- package/lib/excel/render/cell/frozen/getFrozenTopLeftViewPointRange.d.ts +1 -1
- package/lib/excel/render/cell/frozen/getFrozenTopViewPointRange.d.ts +1 -1
- package/lib/excel/render/dnd/DragState.d.ts +1 -1
- package/lib/excel/render/dnd/mousedownColHeader.d.ts +1 -1
- package/lib/excel/render/dnd/mousedownRowHeader.d.ts +1 -1
- package/lib/excel/render/drawing/drawDrawing.d.ts +1 -1
- package/lib/excel/render/drawing/findPositionInViewRange.d.ts +1 -1
- package/lib/excel/render/drawing/getRectFromAnchorPoint.d.ts +1 -1
- package/lib/excel/render/formulaBar/FormulaBar.js +7 -3
- package/lib/excel/render/grid/drawGridLines.d.ts +1 -1
- package/lib/excel/render/header/drawRowColHeaders.d.ts +1 -1
- package/lib/excel/render/header/drawRowColHeaders.js +3 -0
- package/lib/excel/render/selection/SheetSelection.d.ts +1 -1
- package/lib/excel/render/selection/binarySearchSize.d.ts +1 -1
- package/lib/excel/render/selection/findCell.d.ts +1 -1
- package/lib/excel/render/selection/findInViewRange.d.ts +1 -1
- package/lib/excel/render/selection/findInViewRangeX.d.ts +1 -1
- package/lib/excel/render/selection/findInViewRangeY.d.ts +1 -1
- package/lib/excel/render/selection/getCellPosition.d.ts +1 -1
- package/lib/excel/render/selection/getRangePosition.d.ts +1 -1
- package/lib/excel/render/selection/hitTest.d.ts +1 -1
- package/lib/excel/render/selection/hitTestInRange.d.ts +1 -1
- package/lib/excel/render/sparkline/drawSparkline.d.ts +1 -1
- package/lib/excel/render/ui/CheckBoxList.js +6 -2
- package/lib/excel/render/ui/Input.d.ts +9 -1
- package/lib/excel/render/ui/Input.js +15 -11
- package/lib/excel/types/X14Sparkline/X14SparklineGroup.d.ts +1 -1
- package/lib/excel/types/X14Sparkline/X14SparklineGroup.js +2 -2
- package/lib/excel/types/worksheet/CellData.js +10 -0
- package/lib/package/XMLPackageParser.d.ts +1 -1
- package/lib/package/ZipPackageParser.d.ts +1 -1
- package/lib/util/__tests__/replaceVar.test.d.ts +1 -1
- package/lib/util/__tests__/xmlToNode.test.d.ts +1 -0
- package/lib/util/onClickOutside.d.ts +2 -2
- package/lib/util/onClickOutside.js +4 -1
- package/lib/util/onClickOutsideOnce.d.ts +4 -0
- package/lib/util/onClickOutsideOnce.js +18 -0
- package/lib/util/xmlToNode.d.ts +5 -0
- package/package.json +5 -3
- package/esm/util/runWorker.d.ts +0 -6
- package/lib/util/runWorker.d.ts +0 -6
- /package/esm/excel/types/X14Sparkline/{x14:sparklines.d.ts → x14Sparklines.d.ts} +0 -0
- /package/esm/excel/types/X14Sparkline/{x14_sparklines.js → x14Sparklines.js} +0 -0
- /package/lib/excel/types/X14Sparkline/{x14:sparklines.d.ts → x14Sparklines.d.ts} +0 -0
- /package/lib/excel/types/X14Sparkline/{x14_sparklines.js → x14Sparklines.js} +0 -0
package/esm/common/autoParse.js
CHANGED
|
@@ -2,11 +2,17 @@ import { __values } from 'tslib';
|
|
|
2
2
|
import { ANY_KEY } from '../openxml/Attributes.js';
|
|
3
3
|
import { normalizeBoolean } from '../OpenXML.js';
|
|
4
4
|
|
|
5
|
+
var replaceCache = new Map();
|
|
5
6
|
/**
|
|
6
7
|
* 目前不支持这两种 name space
|
|
7
8
|
*/
|
|
8
9
|
function removeNamespace(tag) {
|
|
9
|
-
|
|
10
|
+
if (replaceCache.has(tag)) {
|
|
11
|
+
return replaceCache.get(tag);
|
|
12
|
+
}
|
|
13
|
+
var result = tag.replace('a:', '').replace('xdr:', '').replace('c:', '');
|
|
14
|
+
replaceCache.set(tag, result);
|
|
15
|
+
return result;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
18
|
* 通用属性解析
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { onClickOutsideOnce } from '../../../util/onClickOutsideOnce.js';
|
|
2
2
|
import { Input } from '../../render/ui/Input.js';
|
|
3
3
|
import { updateValue } from '../../types/worksheet/CellData.js';
|
|
4
4
|
|
|
5
|
+
var lastCellEditor;
|
|
5
6
|
/**
|
|
6
7
|
* 单元格编辑
|
|
7
8
|
*/
|
|
@@ -9,6 +10,9 @@ var CellEditor = /** @class */ (function () {
|
|
|
9
10
|
function CellEditor(dataContainer, workbook, hitTest) {
|
|
10
11
|
var _this = this;
|
|
11
12
|
var _a, _b;
|
|
13
|
+
if (lastCellEditor) {
|
|
14
|
+
lastCellEditor.close();
|
|
15
|
+
}
|
|
12
16
|
this.workbook = workbook;
|
|
13
17
|
this.editorContainer = document.createElement('div');
|
|
14
18
|
this.editorContainer.className = 'excel-cell-editor';
|
|
@@ -29,17 +33,26 @@ var CellEditor = /** @class */ (function () {
|
|
|
29
33
|
height = height - padding * 2;
|
|
30
34
|
this.initValue = cellInfo.value;
|
|
31
35
|
this.value = cellInfo.value;
|
|
32
|
-
var input = new Input(
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
var input = new Input({
|
|
37
|
+
container: this.editorContainer,
|
|
38
|
+
value: cellInfo.value,
|
|
39
|
+
onChange: function (value) {
|
|
40
|
+
_this.handleInput(value);
|
|
41
|
+
},
|
|
42
|
+
onEnter: function (value) {
|
|
43
|
+
_this.close();
|
|
44
|
+
},
|
|
45
|
+
style: 'borderLess'
|
|
46
|
+
});
|
|
35
47
|
input.force();
|
|
36
48
|
this.editorContainer.style.left = "".concat(x, "px");
|
|
37
49
|
this.editorContainer.style.top = "".concat(y, "px");
|
|
38
50
|
this.editorContainer.style.width = "".concat(width, "px");
|
|
39
51
|
this.editorContainer.style.height = "".concat(height, "px");
|
|
40
|
-
|
|
52
|
+
onClickOutsideOnce(this.editorContainer, function () {
|
|
41
53
|
_this.close();
|
|
42
54
|
});
|
|
55
|
+
lastCellEditor = this;
|
|
43
56
|
}
|
|
44
57
|
CellEditor.prototype.handleInput = function (value) {
|
|
45
58
|
this.value = value;
|
|
@@ -19,6 +19,7 @@ export declare class AutoFilterIconUI {
|
|
|
19
19
|
rangeRef: RangeRef;
|
|
20
20
|
colIndex: number;
|
|
21
21
|
autoFilter: CT_AutoFilter;
|
|
22
|
+
removeClickOutsideEvent: () => void;
|
|
22
23
|
constructor(sheet: Sheet, dataContainer: HTMLElement, autoFilter: CT_AutoFilter, rangeRef: RangeRef, colIndex: number, fid: string, headerRowCount?: number);
|
|
23
24
|
/**
|
|
24
25
|
* 更新过滤图标
|
|
@@ -30,4 +31,5 @@ export declare class AutoFilterIconUI {
|
|
|
30
31
|
showMenu(): void;
|
|
31
32
|
hideMenu(): void;
|
|
32
33
|
hide(): void;
|
|
34
|
+
destroy(): void;
|
|
33
35
|
}
|
|
@@ -29,7 +29,7 @@ var AutoFilterIconUI = /** @class */ (function () {
|
|
|
29
29
|
this.filterIcon = filterIcon;
|
|
30
30
|
this.filterMenu = new AutoFilterMenuUI(this, filterIconContainer, sheet, autoFilter, rangeRef, colIndex, headerRowCount);
|
|
31
31
|
filterIcon.addEventListener('click', this.handleClick.bind(this));
|
|
32
|
-
onClickOutside(filterIconContainer, function () {
|
|
32
|
+
this.removeClickOutsideEvent = onClickOutside(filterIconContainer, function () {
|
|
33
33
|
_this.hideMenu();
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -79,6 +79,10 @@ var AutoFilterIconUI = /** @class */ (function () {
|
|
|
79
79
|
AutoFilterIconUI.prototype.hide = function () {
|
|
80
80
|
this.filterIconContainer.style.display = 'none';
|
|
81
81
|
};
|
|
82
|
+
AutoFilterIconUI.prototype.destroy = function () {
|
|
83
|
+
this.filterIconContainer.remove();
|
|
84
|
+
this.removeClickOutsideEvent();
|
|
85
|
+
};
|
|
82
86
|
return AutoFilterIconUI;
|
|
83
87
|
}());
|
|
84
88
|
|
|
@@ -116,9 +116,15 @@ var CustomFiltersUI = /** @class */ (function () {
|
|
|
116
116
|
var select = new Select(customFilterItemInput, this.operatorOptions, toOperatorUI(operator, value), function () {
|
|
117
117
|
_this.syncCustomFilters();
|
|
118
118
|
});
|
|
119
|
-
var input = new Input(
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
var input = new Input({
|
|
120
|
+
container: customFilterItemInput,
|
|
121
|
+
value: value,
|
|
122
|
+
onChange: function () {
|
|
123
|
+
_this.syncCustomFilters();
|
|
124
|
+
},
|
|
125
|
+
style: 'normal',
|
|
126
|
+
options: this.texts
|
|
127
|
+
});
|
|
122
128
|
this.customFilterItems.push({ input: input, select: select });
|
|
123
129
|
};
|
|
124
130
|
/**
|
|
@@ -16,7 +16,7 @@ function drawCells(excelRender, currentSheet, excelRenderOptions, canvas, displa
|
|
|
16
16
|
}
|
|
17
17
|
var cellInfo = currentSheet.getCellInfo(row, col);
|
|
18
18
|
if (cellInfo) {
|
|
19
|
-
cellInfoMap.set("".concat(row, ",").concat(col), __assign(__assign({}, cellInfo), { width: width, height: height }));
|
|
19
|
+
cellInfoMap.set("".concat(row, ",").concat(col), __assign(__assign({}, JSON.parse(JSON.stringify(cellInfo))), { width: width, height: height }));
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ExcelRenderOptions } from '../../../sheet/ExcelRenderOptions';
|
|
2
2
|
import { Sheet } from '../../../sheet/Sheet';
|
|
3
3
|
import { SheetCanvas } from '../../SheetCanvas';
|
|
4
|
-
import { ViewRange } from 'src/excel/sheet/ViewRange';
|
|
5
4
|
import { IDataProvider } from '../../../types/IDataProvider';
|
|
6
5
|
import { LinkPosition } from '../LinkPosition';
|
|
7
6
|
import { ExcelRender } from '../../ExcelRender';
|
|
7
|
+
import { ViewRange } from '../../../sheet/ViewRange';
|
|
8
8
|
export type FrozenViewRange = {
|
|
9
9
|
topViewRange: ViewRange | null;
|
|
10
10
|
leftViewRange: ViewRange | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Workbook } from '../../Workbook';
|
|
2
|
-
import { Region } from '
|
|
2
|
+
import { Region } from '../../sheet/ViewRange';
|
|
3
3
|
import { SheetSelection } from '../selection/SheetSelection';
|
|
4
4
|
import { HitTestResult } from '../selection/hitTest';
|
|
5
5
|
export interface DragState {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Sheet } from '../../sheet/Sheet';
|
|
2
2
|
import { SheetCanvas } from '../SheetCanvas';
|
|
3
|
-
import { ViewRange } from 'src/excel/sheet/ViewRange';
|
|
4
3
|
import { ExcelRender } from '../ExcelRender';
|
|
4
|
+
import { ViewRange } from '../../sheet/ViewRange';
|
|
5
5
|
/**
|
|
6
6
|
* 绘制 sheet 里的图片及文本框
|
|
7
7
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CT_Marker } from '../../../openxml/ExcelTypes';
|
|
2
2
|
import { Sheet } from '../../sheet/Sheet';
|
|
3
|
-
import { ViewRange } from '
|
|
3
|
+
import { ViewRange } from '../../sheet/ViewRange';
|
|
4
4
|
export declare function getRectFromOneAnchorPoint(currentSheet: Sheet, cell: CT_Marker, viewRange: ViewRange): {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
@@ -35,9 +35,13 @@ var FormulaBar = /** @class */ (function () {
|
|
|
35
35
|
parent: this.dom
|
|
36
36
|
});
|
|
37
37
|
this.textBox = textBox;
|
|
38
|
-
var textInput = new Input(
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
var textInput = new Input({
|
|
39
|
+
container: textBox,
|
|
40
|
+
onChange: function (value) {
|
|
41
|
+
_this.changeCellValue(value);
|
|
42
|
+
},
|
|
43
|
+
style: 'borderLess'
|
|
44
|
+
});
|
|
41
45
|
this.textInput = textInput;
|
|
42
46
|
};
|
|
43
47
|
FormulaBar.prototype.getActiveCell = function () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridLineOptions } from '../../sheet/ExcelRenderOptions';
|
|
2
2
|
import { Sheet } from '../../sheet/Sheet';
|
|
3
|
-
import { ViewRange } from '
|
|
3
|
+
import { ViewRange } from '../../sheet/ViewRange';
|
|
4
4
|
import { SheetCanvas, Line } from '../SheetCanvas';
|
|
5
5
|
/**
|
|
6
6
|
* 生成网格线
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExcelRenderOptions } from '../../sheet/ExcelRenderOptions';
|
|
2
2
|
import { Sheet } from '../../sheet/Sheet';
|
|
3
|
-
import { ViewRange } from '
|
|
3
|
+
import { ViewRange } from '../../sheet/ViewRange';
|
|
4
4
|
import { FontSize } from '../../types/FontSize';
|
|
5
5
|
import { FontStyle } from '../../types/FontStyle';
|
|
6
6
|
import { SheetCanvas } from '../SheetCanvas';
|
|
@@ -7,6 +7,9 @@ import { genFontStr } from '../cell/genFontStr.js';
|
|
|
7
7
|
*/
|
|
8
8
|
function drawRowColHeaders(currentSheet, viewRange, sheetCanvas, renderOptions, defaultFontSize, defaultFontStyle) {
|
|
9
9
|
var e_1, _a, e_2, _b;
|
|
10
|
+
if (currentSheet.showRowColHeaders() === false) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
10
13
|
var rows = viewRange.rows, startRowOffset = viewRange.startRowOffset, height = viewRange.height, width = viewRange.width, cols = viewRange.cols, startColOffset = viewRange.startColOffset;
|
|
11
14
|
var _c = currentSheet.getRowColSize(), rowHeaderWidth = _c.rowHeaderWidth, colHeaderHeight = _c.colHeaderHeight;
|
|
12
15
|
var gridLineColor = renderOptions.gridLineColor, rowColHeadersBgColor = renderOptions.rowColHeadersBackgroundColor, hiddenRowColHeadersLineColor = renderOptions.hiddenRowColHeadersLineColor;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Region, ViewRange } from 'src/excel/sheet/ViewRange';
|
|
2
1
|
import { RangeRef } from '../../types/RangeRef';
|
|
3
2
|
import { FrozenViewRange } from '../cell/frozen/drawFrozen';
|
|
4
3
|
import { Position } from './Position';
|
|
5
4
|
import { IAbsoluteAnchor, IOneCellAnchor, ITwoCellAnchor } from '../../types/IDrawing';
|
|
5
|
+
import { Region, ViewRange } from '../../sheet/ViewRange';
|
|
6
6
|
export type HitTestCommon = Position & RangeRef;
|
|
7
7
|
/**
|
|
8
8
|
* 点击到表头的最左上角
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* 绘制 sparkline
|
|
3
3
|
*/
|
|
4
4
|
import { Sheet } from '../../sheet/Sheet';
|
|
5
|
-
import { ViewRange } from 'src/excel/sheet/ViewRange';
|
|
6
5
|
import { SheetCanvas } from '../SheetCanvas';
|
|
6
|
+
import { ViewRange } from '../../sheet/ViewRange';
|
|
7
7
|
export declare function drawSparkline(currentSheet: Sheet, viewRange: ViewRange, canvas: SheetCanvas): void;
|
|
@@ -17,8 +17,12 @@ var CheckBoxList = /** @class */ (function () {
|
|
|
17
17
|
className: 'excel-checkbox-list-wrapper',
|
|
18
18
|
parent: container
|
|
19
19
|
});
|
|
20
|
-
var searchInput = new Input(
|
|
21
|
-
|
|
20
|
+
var searchInput = new Input({
|
|
21
|
+
container: wrapper,
|
|
22
|
+
placeholder: searchPlaceholder,
|
|
23
|
+
onChange: function (text) {
|
|
24
|
+
_this.handleSearch(text);
|
|
25
|
+
}
|
|
22
26
|
});
|
|
23
27
|
this.searchInput = searchInput;
|
|
24
28
|
var listContainer = H('div', {
|
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare class Input {
|
|
5
5
|
input: HTMLInputElement;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(args: {
|
|
7
|
+
container: HTMLElement;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
onChange: (value: string) => void;
|
|
11
|
+
onEnter?: (value: string) => void;
|
|
12
|
+
style?: 'normal' | 'borderLess';
|
|
13
|
+
options?: string[];
|
|
14
|
+
});
|
|
7
15
|
getElement(): HTMLInputElement;
|
|
8
16
|
getValue(): string;
|
|
9
17
|
setValue(text: string): void;
|
|
@@ -3,26 +3,30 @@
|
|
|
3
3
|
*/
|
|
4
4
|
var inputId = 0;
|
|
5
5
|
var Input = /** @class */ (function () {
|
|
6
|
-
function Input(
|
|
7
|
-
if (style === void 0) { style = 'normal'; }
|
|
8
|
-
if (options === void 0) { options = []; }
|
|
6
|
+
function Input(args) {
|
|
9
7
|
var _this = this;
|
|
10
8
|
this.input = document.createElement('input');
|
|
11
|
-
this.input.value = value;
|
|
12
|
-
this.input.placeholder = placeholder;
|
|
13
|
-
container.appendChild(this.input);
|
|
9
|
+
this.input.value = args.value || '';
|
|
10
|
+
this.input.placeholder = args.placeholder || '';
|
|
11
|
+
args.container.appendChild(this.input);
|
|
14
12
|
this.input.className = 'excel-input';
|
|
15
|
-
if (style === 'borderLess') {
|
|
13
|
+
if (args.style === 'borderLess') {
|
|
16
14
|
this.input.classList.add('excel-input-border-less');
|
|
17
15
|
}
|
|
18
16
|
this.input.oninput = function () {
|
|
19
|
-
onChange(_this.input.value);
|
|
17
|
+
args.onChange(_this.input.value);
|
|
20
18
|
};
|
|
21
|
-
|
|
19
|
+
this.input.onkeydown = function (e) {
|
|
20
|
+
var _a;
|
|
21
|
+
if (e.key === 'Enter') {
|
|
22
|
+
(_a = args.onEnter) === null || _a === void 0 ? void 0 : _a.call(args, _this.input.value);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
if (args.options && args.options.length) {
|
|
22
26
|
var datalist_1 = document.createElement('datalist');
|
|
23
27
|
datalist_1.id = "".concat(inputId++, "-list");
|
|
24
|
-
container.appendChild(datalist_1);
|
|
25
|
-
options.forEach(function (option) {
|
|
28
|
+
args.container.appendChild(datalist_1);
|
|
29
|
+
args.options.forEach(function (option) {
|
|
26
30
|
var optionElement = document.createElement('option');
|
|
27
31
|
optionElement.value = option;
|
|
28
32
|
datalist_1.appendChild(optionElement);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Attributes } from '../../../openxml/Attributes';
|
|
5
5
|
import { CT_Color } from '../CT_Color';
|
|
6
|
-
import { X14Sparklines } from './
|
|
6
|
+
import { X14Sparklines } from './x14Sparklines';
|
|
7
7
|
export type ST_SparklineAxisMinMax = 'individual' | 'groupMax' | 'group';
|
|
8
8
|
export type X14SparklineGroup = {
|
|
9
9
|
'displayEmptyCellsAs'?: 'gap' | 'zero' | 'span';
|
|
@@ -29,6 +29,16 @@ function updateValue(value, cellData) {
|
|
|
29
29
|
if (typeof cellData === 'string') {
|
|
30
30
|
return value;
|
|
31
31
|
}
|
|
32
|
+
if ('type' in cellData && cellData.type === 'blank') {
|
|
33
|
+
if (cellData.s !== undefined) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'style',
|
|
36
|
+
value: value,
|
|
37
|
+
s: cellData.s
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
32
42
|
if ('value' in cellData) {
|
|
33
43
|
return __assign(__assign({}, cellData), { value: value });
|
|
34
44
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Word from '../../
|
|
1
|
+
import { Word } from '../../index';
|
|
2
2
|
export declare function createWord(fileName: string, data: any): Word;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 点击元素外部时触发回调,用于一直存在的对象,需要手动调用删除监听器
|
|
3
3
|
*/
|
|
4
4
|
function onClickOutside(element, onClickOutside) {
|
|
5
5
|
var outsideClickListener = function (event) {
|
|
@@ -8,6 +8,9 @@ function onClickOutside(element, onClickOutside) {
|
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
10
|
document.addEventListener('mousedown', outsideClickListener);
|
|
11
|
+
return function () {
|
|
12
|
+
document.removeEventListener('mousedown', outsideClickListener);
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export { onClickOutside };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 点击元素外部时触发回调,只触发一次,用于临时对象
|
|
3
|
+
*/
|
|
4
|
+
function onClickOutsideOnce(element, onClickOutside) {
|
|
5
|
+
var outsideClickListener = function (event) {
|
|
6
|
+
if (event.target instanceof Node && !element.contains(event.target)) {
|
|
7
|
+
onClickOutside();
|
|
8
|
+
document.removeEventListener('mousedown', outsideClickListener);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
document.addEventListener('mousedown', outsideClickListener);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { onClickOutsideOnce };
|
package/lib/common/autoParse.js
CHANGED
|
@@ -6,11 +6,17 @@ var tslib = require('tslib');
|
|
|
6
6
|
var Attributes = require('../openxml/Attributes.js');
|
|
7
7
|
var OpenXML = require('../OpenXML.js');
|
|
8
8
|
|
|
9
|
+
var replaceCache = new Map();
|
|
9
10
|
/**
|
|
10
11
|
* 目前不支持这两种 name space
|
|
11
12
|
*/
|
|
12
13
|
function removeNamespace(tag) {
|
|
13
|
-
|
|
14
|
+
if (replaceCache.has(tag)) {
|
|
15
|
+
return replaceCache.get(tag);
|
|
16
|
+
}
|
|
17
|
+
var result = tag.replace('a:', '').replace('xdr:', '').replace('c:', '');
|
|
18
|
+
replaceCache.set(tag, result);
|
|
19
|
+
return result;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* 通用属性解析
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var onClickOutsideOnce = require('../../../util/onClickOutsideOnce.js');
|
|
6
6
|
var Input = require('../../render/ui/Input.js');
|
|
7
7
|
var CellData = require('../../types/worksheet/CellData.js');
|
|
8
8
|
|
|
9
|
+
var lastCellEditor;
|
|
9
10
|
/**
|
|
10
11
|
* 单元格编辑
|
|
11
12
|
*/
|
|
@@ -13,6 +14,9 @@ var CellEditor = /** @class */ (function () {
|
|
|
13
14
|
function CellEditor(dataContainer, workbook, hitTest) {
|
|
14
15
|
var _this = this;
|
|
15
16
|
var _a, _b;
|
|
17
|
+
if (lastCellEditor) {
|
|
18
|
+
lastCellEditor.close();
|
|
19
|
+
}
|
|
16
20
|
this.workbook = workbook;
|
|
17
21
|
this.editorContainer = document.createElement('div');
|
|
18
22
|
this.editorContainer.className = 'excel-cell-editor';
|
|
@@ -33,17 +37,26 @@ var CellEditor = /** @class */ (function () {
|
|
|
33
37
|
height = height - padding * 2;
|
|
34
38
|
this.initValue = cellInfo.value;
|
|
35
39
|
this.value = cellInfo.value;
|
|
36
|
-
var input = new Input.Input(
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
var input = new Input.Input({
|
|
41
|
+
container: this.editorContainer,
|
|
42
|
+
value: cellInfo.value,
|
|
43
|
+
onChange: function (value) {
|
|
44
|
+
_this.handleInput(value);
|
|
45
|
+
},
|
|
46
|
+
onEnter: function (value) {
|
|
47
|
+
_this.close();
|
|
48
|
+
},
|
|
49
|
+
style: 'borderLess'
|
|
50
|
+
});
|
|
39
51
|
input.force();
|
|
40
52
|
this.editorContainer.style.left = "".concat(x, "px");
|
|
41
53
|
this.editorContainer.style.top = "".concat(y, "px");
|
|
42
54
|
this.editorContainer.style.width = "".concat(width, "px");
|
|
43
55
|
this.editorContainer.style.height = "".concat(height, "px");
|
|
44
|
-
|
|
56
|
+
onClickOutsideOnce.onClickOutsideOnce(this.editorContainer, function () {
|
|
45
57
|
_this.close();
|
|
46
58
|
});
|
|
59
|
+
lastCellEditor = this;
|
|
47
60
|
}
|
|
48
61
|
CellEditor.prototype.handleInput = function (value) {
|
|
49
62
|
this.value = value;
|