@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.
Files changed (44) hide show
  1. package/lib/cjs/facade.js +160 -1
  2. package/lib/cjs/index.js +526 -1
  3. package/lib/cjs/locale/ca-ES.js +12 -1
  4. package/lib/cjs/locale/en-US.js +27 -1
  5. package/lib/cjs/locale/es-ES.js +12 -1
  6. package/lib/cjs/locale/fa-IR.js +12 -1
  7. package/lib/cjs/locale/fr-FR.js +12 -1
  8. package/lib/cjs/locale/ja-JP.js +12 -1
  9. package/lib/cjs/locale/ko-KR.js +12 -1
  10. package/lib/cjs/locale/ru-RU.js +12 -1
  11. package/lib/cjs/locale/sk-SK.js +12 -1
  12. package/lib/cjs/locale/vi-VN.js +12 -1
  13. package/lib/cjs/locale/zh-CN.js +12 -1
  14. package/lib/cjs/locale/zh-TW.js +12 -1
  15. package/lib/es/facade.js +161 -1
  16. package/lib/es/index.js +517 -1
  17. package/lib/es/locale/ca-ES.js +11 -1
  18. package/lib/es/locale/en-US.js +26 -1
  19. package/lib/es/locale/es-ES.js +11 -1
  20. package/lib/es/locale/fa-IR.js +11 -1
  21. package/lib/es/locale/fr-FR.js +11 -1
  22. package/lib/es/locale/ja-JP.js +11 -1
  23. package/lib/es/locale/ko-KR.js +11 -1
  24. package/lib/es/locale/ru-RU.js +11 -1
  25. package/lib/es/locale/sk-SK.js +11 -1
  26. package/lib/es/locale/vi-VN.js +11 -1
  27. package/lib/es/locale/zh-CN.js +11 -1
  28. package/lib/es/locale/zh-TW.js +11 -1
  29. package/lib/facade.js +161 -1
  30. package/lib/index.js +517 -1
  31. package/lib/locale/ca-ES.js +11 -1
  32. package/lib/locale/en-US.js +26 -1
  33. package/lib/locale/es-ES.js +11 -1
  34. package/lib/locale/fa-IR.js +11 -1
  35. package/lib/locale/fr-FR.js +11 -1
  36. package/lib/locale/ja-JP.js +11 -1
  37. package/lib/locale/ko-KR.js +11 -1
  38. package/lib/locale/ru-RU.js +11 -1
  39. package/lib/locale/sk-SK.js +11 -1
  40. package/lib/locale/vi-VN.js +11 -1
  41. package/lib/locale/zh-CN.js +11 -1
  42. package/lib/locale/zh-TW.js +11 -1
  43. package/lib/umd/index.js +1 -1
  44. package/package.json +12 -12
@@ -1 +1,12 @@
1
- const e={rightClick:{zenEditor:`Editor na celú obrazovku`},shortcut:{sheet:{"zen-edit-cancel":`Zrušiť zen úpravu`,"zen-edit-confirm":`Potvrdiť zen úpravu`}}};module.exports=e;
1
+
2
+ //#region src/locale/sk-SK.ts
3
+ const locale = {
4
+ rightClick: { zenEditor: "Editor na celú obrazovku" },
5
+ shortcut: { sheet: {
6
+ "zen-edit-cancel": "Zrušiť zen úpravu",
7
+ "zen-edit-confirm": "Potvrdiť zen úpravu"
8
+ } }
9
+ };
10
+
11
+ //#endregion
12
+ module.exports = locale;
@@ -1 +1,12 @@
1
- const e={rightClick:{zenEditor:`Chế độ chỉnh sửa Zen`},shortcut:{sheet:{"zen-edit-cancel":`Hủy chỉnh sửa (trạng thái Zen mode)`,"zen-edit-confirm":`Bỏ chỉnh sửa (trạng thái Zen mode)`}}};module.exports=e;
1
+
2
+ //#region src/locale/vi-VN.ts
3
+ const locale = {
4
+ rightClick: { zenEditor: "Chế độ chỉnh sửa Zen" },
5
+ shortcut: { sheet: {
6
+ "zen-edit-cancel": "Hủy chỉnh sửa (trạng thái Zen mode)",
7
+ "zen-edit-confirm": "Bỏ chỉnh sửa (trạng thái Zen mode)"
8
+ } }
9
+ };
10
+
11
+ //#endregion
12
+ module.exports = locale;
@@ -1 +1,12 @@
1
- const e={rightClick:{zenEditor:`禅模式编辑`},shortcut:{sheet:{"zen-edit-cancel":`取消编辑(禅模式状态)`,"zen-edit-confirm":`放弃编辑(禅模式状态)`}}};module.exports=e;
1
+
2
+ //#region src/locale/zh-CN.ts
3
+ const locale = {
4
+ rightClick: { zenEditor: "禅模式编辑" },
5
+ shortcut: { sheet: {
6
+ "zen-edit-cancel": "取消编辑(禅模式状态)",
7
+ "zen-edit-confirm": "放弃编辑(禅模式状态)"
8
+ } }
9
+ };
10
+
11
+ //#endregion
12
+ module.exports = locale;
@@ -1 +1,12 @@
1
- const e={rightClick:{zenEditor:`禪模式編輯`},shortcut:{sheet:{"zen-edit-cancel":`取消編輯(禪模式狀態)`,"zen-edit-confirm":`放棄編輯(禪模式狀態)`}}};module.exports=e;
1
+
2
+ //#region src/locale/zh-TW.ts
3
+ const locale = {
4
+ rightClick: { zenEditor: "禪模式編輯" },
5
+ shortcut: { sheet: {
6
+ "zen-edit-cancel": "取消編輯(禪模式狀態)",
7
+ "zen-edit-confirm": "放棄編輯(禪模式狀態)"
8
+ } }
9
+ };
10
+
11
+ //#endregion
12
+ module.exports = locale;
package/lib/es/facade.js CHANGED
@@ -1 +1,161 @@
1
- import{CanceledError as e,DOCS_ZEN_EDITOR_UNIT_ID_KEY as t,ICommandService as n,IUniverInstanceService as r,RichTextValue as i}from"@univerjs/core";import{FUniver as a}from"@univerjs/core/facade";import{RichTextEditingMutation as o}from"@univerjs/docs";import{IEditorBridgeService as s}from"@univerjs/sheets-ui";import{CancelZenEditCommand as c,ConfirmZenEditCommand as l,OpenZenEditorCommand as u}from"@univerjs/sheets-zen-editor";import{FWorkbook as d}from"@univerjs/sheets/facade";var f=class extends a{_initSheetZenEditorEvent(a){let d=a.get(n);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditStart,()=>d.beforeCommandExecuted(t=>{if(t.id===u.id){let n=this.getCommandSheetTarget(t);if(!n)return;let{workbook:r,worksheet:i}=n,o=a.get(s),{keycode:c,eventType:l}=t.params,u=o.getEditLocation(),d={row:u.row,column:u.column,eventType:l,keycode:c,workbook:r,worksheet:i,isZenEditor:!0};if(this.fireEvent(this.Event.BeforeSheetEditStart,d),d.cancel)throw new e}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditEnd,()=>d.beforeCommandExecuted(n=>{if(n.id===c.id||n.id===l.id){let o=this.getCommandSheetTarget(n);if(!o)return;let{workbook:c,worksheet:u}=o,d=a.get(s),f=a.get(r),{keycode:p,eventType:m}=n.params,h=d.getEditLocation(),g={row:h.row,column:h.column,eventType:m,keycode:p,workbook:c,worksheet:u,isZenEditor:!0,value:i.create(f.getUnit(t).getSnapshot()),isConfirm:n.id===l.id};if(this.fireEvent(this.Event.BeforeSheetEditEnd,g),g.cancel)throw new e}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditStarted,()=>d.onCommandExecuted(e=>{if(e.id===u.id){let t=this.getCommandSheetTarget(e);if(!t)return;let{workbook:n,worksheet:r}=t,i=a.get(s),{keycode:o,eventType:c}=e.params,l=i.getEditLocation(),u={row:l.row,column:l.column,eventType:c,keycode:o,workbook:n,worksheet:r,isZenEditor:!0};this.fireEvent(this.Event.SheetEditStarted,u)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditEnded,()=>d.onCommandExecuted(e=>{if(e.id===c.id||e.id===l.id){let t=this.getCommandSheetTarget(e);if(!t)return;let{workbook:n,worksheet:r}=t,i=a.get(s),{keycode:o,eventType:c}=e.params,u=i.getEditLocation(),d={row:u.row,column:u.column,eventType:c,keycode:o,workbook:n,worksheet:r,isZenEditor:!0,isConfirm:e.id===l.id};this.fireEvent(this.Event.SheetEditEnded,d)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditChanging,()=>d.onCommandExecuted(e=>{if(e.id===o.id){let n=this.getActiveSheet();if(!n)return;let{workbook:o,worksheet:c}=n,l=a.get(s),u=a.get(r),d=e.params;if(!l.isVisible().visible)return;let{unitId:f}=d;if(f===t){let{row:e,column:n}=l.getEditLocation(),r={workbook:o,worksheet:c,row:e,column:n,value:i.create(u.getUnit(t).getSnapshot()),isZenEditor:!0};this.fireEvent(this.Event.SheetEditChanging,r)}}})))}_initialize(e){this._initSheetZenEditorEvent(e)}};a.extend(f);var p=class extends d{startZenEditingAsync(){return this._injector.get(n).executeCommand(u.id)}endZenEditingAsync(e=!0){let t=this._injector.get(n);return e?t.executeCommand(l.id):t.executeCommand(c.id)}};d.extend(p);export{};
1
+ import { CanceledError, DOCS_ZEN_EDITOR_UNIT_ID_KEY, ICommandService, IUniverInstanceService, RichTextValue } from "@univerjs/core";
2
+ import { FUniver } from "@univerjs/core/facade";
3
+ import { RichTextEditingMutation } from "@univerjs/docs";
4
+ import { IEditorBridgeService } from "@univerjs/sheets-ui";
5
+ import { CancelZenEditCommand, ConfirmZenEditCommand, OpenZenEditorCommand } from "@univerjs/sheets-zen-editor";
6
+ import { FWorkbook } from "@univerjs/sheets/facade";
7
+
8
+ //#region src/facade/f-univer.ts
9
+ var FUniverSheetsZenEditorMixin = class extends FUniver {
10
+ _initSheetZenEditorEvent(injector) {
11
+ const commandService = injector.get(ICommandService);
12
+ this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditStart, () => commandService.beforeCommandExecuted((commandInfo) => {
13
+ if (commandInfo.id === OpenZenEditorCommand.id) {
14
+ const target = this.getCommandSheetTarget(commandInfo);
15
+ if (!target) return;
16
+ const { workbook, worksheet } = target;
17
+ const editorBridgeService = injector.get(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 CanceledError();
31
+ }
32
+ })));
33
+ this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditEnd, () => commandService.beforeCommandExecuted((commandInfo) => {
34
+ if (commandInfo.id === CancelZenEditCommand.id || commandInfo.id === ConfirmZenEditCommand.id) {
35
+ const target = this.getCommandSheetTarget(commandInfo);
36
+ if (!target) return;
37
+ const { workbook, worksheet } = target;
38
+ const editorBridgeService = injector.get(IEditorBridgeService);
39
+ const univerInstanceService = injector.get(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: RichTextValue.create(univerInstanceService.getUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY).getSnapshot()),
51
+ isConfirm: commandInfo.id === ConfirmZenEditCommand.id
52
+ };
53
+ this.fireEvent(this.Event.BeforeSheetEditEnd, eventParams);
54
+ if (eventParams.cancel) throw new CanceledError();
55
+ }
56
+ })));
57
+ this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditStarted, () => commandService.onCommandExecuted((commandInfo) => {
58
+ if (commandInfo.id === OpenZenEditorCommand.id) {
59
+ const target = this.getCommandSheetTarget(commandInfo);
60
+ if (!target) return;
61
+ const { workbook, worksheet } = target;
62
+ const editorBridgeService = injector.get(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 === CancelZenEditCommand.id || commandInfo.id === ConfirmZenEditCommand.id) {
79
+ const target = this.getCommandSheetTarget(commandInfo);
80
+ if (!target) return;
81
+ const { workbook, worksheet } = target;
82
+ const editorBridgeService = injector.get(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 === 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 === RichTextEditingMutation.id) {
100
+ const target = this.getActiveSheet();
101
+ if (!target) return;
102
+ const { workbook, worksheet } = target;
103
+ const editorBridgeService = injector.get(IEditorBridgeService);
104
+ const univerInstanceService = injector.get(IUniverInstanceService);
105
+ const params = commandInfo.params;
106
+ if (!editorBridgeService.isVisible().visible) return;
107
+ const { unitId } = params;
108
+ if (unitId === 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: RichTextValue.create(univerInstanceService.getUnit(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
+ 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 FWorkbook {
150
+ startZenEditingAsync() {
151
+ return this._injector.get(ICommandService).executeCommand(OpenZenEditorCommand.id);
152
+ }
153
+ endZenEditingAsync(save = true) {
154
+ const commandService = this._injector.get(ICommandService);
155
+ return save ? commandService.executeCommand(ConfirmZenEditCommand.id) : commandService.executeCommand(CancelZenEditCommand.id);
156
+ }
157
+ };
158
+ FWorkbook.extend(FWorkbookSheetsZenEditorMixin);
159
+
160
+ //#endregion
161
+ export { };