@univerjs/sheets-zen-editor 0.20.1 → 0.21.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/lib/cjs/facade.js +160 -1
- package/lib/cjs/index.js +526 -1
- package/lib/cjs/locale/ca-ES.js +12 -1
- package/lib/cjs/locale/en-US.js +27 -1
- package/lib/cjs/locale/es-ES.js +12 -1
- package/lib/cjs/locale/fa-IR.js +12 -1
- package/lib/cjs/locale/fr-FR.js +12 -1
- package/lib/cjs/locale/ja-JP.js +12 -1
- package/lib/cjs/locale/ko-KR.js +12 -1
- package/lib/cjs/locale/ru-RU.js +12 -1
- package/lib/cjs/locale/sk-SK.js +12 -1
- package/lib/cjs/locale/vi-VN.js +12 -1
- package/lib/cjs/locale/zh-CN.js +12 -1
- package/lib/cjs/locale/zh-TW.js +12 -1
- package/lib/es/facade.js +161 -1
- package/lib/es/index.js +517 -1
- package/lib/es/locale/ca-ES.js +11 -1
- package/lib/es/locale/en-US.js +26 -1
- package/lib/es/locale/es-ES.js +11 -1
- package/lib/es/locale/fa-IR.js +11 -1
- package/lib/es/locale/fr-FR.js +11 -1
- package/lib/es/locale/ja-JP.js +11 -1
- package/lib/es/locale/ko-KR.js +11 -1
- package/lib/es/locale/ru-RU.js +11 -1
- package/lib/es/locale/sk-SK.js +11 -1
- package/lib/es/locale/vi-VN.js +11 -1
- package/lib/es/locale/zh-CN.js +11 -1
- package/lib/es/locale/zh-TW.js +11 -1
- package/lib/facade.js +161 -1
- package/lib/index.js +517 -1
- package/lib/locale/ca-ES.js +11 -1
- package/lib/locale/en-US.js +26 -1
- package/lib/locale/es-ES.js +11 -1
- package/lib/locale/fa-IR.js +11 -1
- package/lib/locale/fr-FR.js +11 -1
- package/lib/locale/ja-JP.js +11 -1
- package/lib/locale/ko-KR.js +11 -1
- package/lib/locale/ru-RU.js +11 -1
- package/lib/locale/sk-SK.js +11 -1
- package/lib/locale/vi-VN.js +11 -1
- package/lib/locale/zh-CN.js +11 -1
- package/lib/locale/zh-TW.js +11 -1
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1,160 @@
|
|
|
1
|
-
let
|
|
1
|
+
let _univerjs_core = require("@univerjs/core");
|
|
2
|
+
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
3
|
+
let _univerjs_docs = require("@univerjs/docs");
|
|
4
|
+
let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
5
|
+
let _univerjs_sheets_zen_editor = require("@univerjs/sheets-zen-editor");
|
|
6
|
+
let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
|
|
7
|
+
|
|
8
|
+
//#region src/facade/f-univer.ts
|
|
9
|
+
var FUniverSheetsZenEditorMixin = class extends _univerjs_core_facade.FUniver {
|
|
10
|
+
_initSheetZenEditorEvent(injector) {
|
|
11
|
+
const commandService = injector.get(_univerjs_core.ICommandService);
|
|
12
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditStart, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
13
|
+
if (commandInfo.id === _univerjs_sheets_zen_editor.OpenZenEditorCommand.id) {
|
|
14
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
15
|
+
if (!target) return;
|
|
16
|
+
const { workbook, worksheet } = target;
|
|
17
|
+
const editorBridgeService = injector.get(_univerjs_sheets_ui.IEditorBridgeService);
|
|
18
|
+
const { keycode, eventType } = commandInfo.params;
|
|
19
|
+
const loc = editorBridgeService.getEditLocation();
|
|
20
|
+
const eventParams = {
|
|
21
|
+
row: loc.row,
|
|
22
|
+
column: loc.column,
|
|
23
|
+
eventType,
|
|
24
|
+
keycode,
|
|
25
|
+
workbook,
|
|
26
|
+
worksheet,
|
|
27
|
+
isZenEditor: true
|
|
28
|
+
};
|
|
29
|
+
this.fireEvent(this.Event.BeforeSheetEditStart, eventParams);
|
|
30
|
+
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
31
|
+
}
|
|
32
|
+
})));
|
|
33
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditEnd, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
34
|
+
if (commandInfo.id === _univerjs_sheets_zen_editor.CancelZenEditCommand.id || commandInfo.id === _univerjs_sheets_zen_editor.ConfirmZenEditCommand.id) {
|
|
35
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
36
|
+
if (!target) return;
|
|
37
|
+
const { workbook, worksheet } = target;
|
|
38
|
+
const editorBridgeService = injector.get(_univerjs_sheets_ui.IEditorBridgeService);
|
|
39
|
+
const univerInstanceService = injector.get(_univerjs_core.IUniverInstanceService);
|
|
40
|
+
const { keycode, eventType } = commandInfo.params;
|
|
41
|
+
const loc = editorBridgeService.getEditLocation();
|
|
42
|
+
const eventParams = {
|
|
43
|
+
row: loc.row,
|
|
44
|
+
column: loc.column,
|
|
45
|
+
eventType,
|
|
46
|
+
keycode,
|
|
47
|
+
workbook,
|
|
48
|
+
worksheet,
|
|
49
|
+
isZenEditor: true,
|
|
50
|
+
value: _univerjs_core.RichTextValue.create(univerInstanceService.getUnit(_univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY).getSnapshot()),
|
|
51
|
+
isConfirm: commandInfo.id === _univerjs_sheets_zen_editor.ConfirmZenEditCommand.id
|
|
52
|
+
};
|
|
53
|
+
this.fireEvent(this.Event.BeforeSheetEditEnd, eventParams);
|
|
54
|
+
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
55
|
+
}
|
|
56
|
+
})));
|
|
57
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditStarted, () => commandService.onCommandExecuted((commandInfo) => {
|
|
58
|
+
if (commandInfo.id === _univerjs_sheets_zen_editor.OpenZenEditorCommand.id) {
|
|
59
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
60
|
+
if (!target) return;
|
|
61
|
+
const { workbook, worksheet } = target;
|
|
62
|
+
const editorBridgeService = injector.get(_univerjs_sheets_ui.IEditorBridgeService);
|
|
63
|
+
const { keycode, eventType } = commandInfo.params;
|
|
64
|
+
const loc = editorBridgeService.getEditLocation();
|
|
65
|
+
const eventParams = {
|
|
66
|
+
row: loc.row,
|
|
67
|
+
column: loc.column,
|
|
68
|
+
eventType,
|
|
69
|
+
keycode,
|
|
70
|
+
workbook,
|
|
71
|
+
worksheet,
|
|
72
|
+
isZenEditor: true
|
|
73
|
+
};
|
|
74
|
+
this.fireEvent(this.Event.SheetEditStarted, eventParams);
|
|
75
|
+
}
|
|
76
|
+
})));
|
|
77
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditEnded, () => commandService.onCommandExecuted((commandInfo) => {
|
|
78
|
+
if (commandInfo.id === _univerjs_sheets_zen_editor.CancelZenEditCommand.id || commandInfo.id === _univerjs_sheets_zen_editor.ConfirmZenEditCommand.id) {
|
|
79
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
80
|
+
if (!target) return;
|
|
81
|
+
const { workbook, worksheet } = target;
|
|
82
|
+
const editorBridgeService = injector.get(_univerjs_sheets_ui.IEditorBridgeService);
|
|
83
|
+
const { keycode, eventType } = commandInfo.params;
|
|
84
|
+
const loc = editorBridgeService.getEditLocation();
|
|
85
|
+
const eventParams = {
|
|
86
|
+
row: loc.row,
|
|
87
|
+
column: loc.column,
|
|
88
|
+
eventType,
|
|
89
|
+
keycode,
|
|
90
|
+
workbook,
|
|
91
|
+
worksheet,
|
|
92
|
+
isZenEditor: true,
|
|
93
|
+
isConfirm: commandInfo.id === _univerjs_sheets_zen_editor.ConfirmZenEditCommand.id
|
|
94
|
+
};
|
|
95
|
+
this.fireEvent(this.Event.SheetEditEnded, eventParams);
|
|
96
|
+
}
|
|
97
|
+
})));
|
|
98
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditChanging, () => commandService.onCommandExecuted((commandInfo) => {
|
|
99
|
+
if (commandInfo.id === _univerjs_docs.RichTextEditingMutation.id) {
|
|
100
|
+
const target = this.getActiveSheet();
|
|
101
|
+
if (!target) return;
|
|
102
|
+
const { workbook, worksheet } = target;
|
|
103
|
+
const editorBridgeService = injector.get(_univerjs_sheets_ui.IEditorBridgeService);
|
|
104
|
+
const univerInstanceService = injector.get(_univerjs_core.IUniverInstanceService);
|
|
105
|
+
const params = commandInfo.params;
|
|
106
|
+
if (!editorBridgeService.isVisible().visible) return;
|
|
107
|
+
const { unitId } = params;
|
|
108
|
+
if (unitId === _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY) {
|
|
109
|
+
const { row, column } = editorBridgeService.getEditLocation();
|
|
110
|
+
const eventParams = {
|
|
111
|
+
workbook,
|
|
112
|
+
worksheet,
|
|
113
|
+
row,
|
|
114
|
+
column,
|
|
115
|
+
value: _univerjs_core.RichTextValue.create(univerInstanceService.getUnit(_univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY).getSnapshot()),
|
|
116
|
+
isZenEditor: true
|
|
117
|
+
};
|
|
118
|
+
this.fireEvent(this.Event.SheetEditChanging, eventParams);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
})));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @ignore
|
|
125
|
+
*/
|
|
126
|
+
_initialize(injector) {
|
|
127
|
+
this._initSheetZenEditorEvent(injector);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
_univerjs_core_facade.FUniver.extend(FUniverSheetsZenEditorMixin);
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/facade/f-workbook.ts
|
|
134
|
+
/**
|
|
135
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
136
|
+
*
|
|
137
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
138
|
+
* you may not use this file except in compliance with the License.
|
|
139
|
+
* You may obtain a copy of the License at
|
|
140
|
+
*
|
|
141
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
142
|
+
*
|
|
143
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
144
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
145
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
146
|
+
* See the License for the specific language governing permissions and
|
|
147
|
+
* limitations under the License.
|
|
148
|
+
*/
|
|
149
|
+
var FWorkbookSheetsZenEditorMixin = class extends _univerjs_sheets_facade.FWorkbook {
|
|
150
|
+
startZenEditingAsync() {
|
|
151
|
+
return this._injector.get(_univerjs_core.ICommandService).executeCommand(_univerjs_sheets_zen_editor.OpenZenEditorCommand.id);
|
|
152
|
+
}
|
|
153
|
+
endZenEditingAsync(save = true) {
|
|
154
|
+
const commandService = this._injector.get(_univerjs_core.ICommandService);
|
|
155
|
+
return save ? commandService.executeCommand(_univerjs_sheets_zen_editor.ConfirmZenEditCommand.id) : commandService.executeCommand(_univerjs_sheets_zen_editor.CancelZenEditCommand.id);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
_univerjs_sheets_facade.FWorkbook.extend(FWorkbookSheetsZenEditorMixin);
|
|
159
|
+
|
|
160
|
+
//#endregion
|