@univerjs/ui 0.1.0-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.
Files changed (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -0
  3. package/lib/cjs/index.js +4671 -0
  4. package/lib/cjs/locale/en-US.js +46 -0
  5. package/lib/cjs/locale/zh-CN.js +35 -0
  6. package/lib/esm/index.js +4507 -0
  7. package/lib/esm/locale/en-US.js +25 -0
  8. package/lib/esm/locale/zh-CN.js +14 -0
  9. package/lib/index.css +474 -0
  10. package/lib/types/BaseComponent.d.ts +8 -0
  11. package/lib/types/BaseComponent.d.ts.map +1 -0
  12. package/lib/types/commands/operations/toggle-shortcut-panel.operation.d.ts +4 -0
  13. package/lib/types/commands/operations/toggle-shortcut-panel.operation.d.ts.map +1 -0
  14. package/lib/types/common/component-manager.d.ts +14 -0
  15. package/lib/types/common/component-manager.d.ts.map +1 -0
  16. package/lib/types/common/index.d.ts +3 -0
  17. package/lib/types/common/index.d.ts.map +1 -0
  18. package/lib/types/common/lifecycle.d.ts +4 -0
  19. package/lib/types/common/lifecycle.d.ts.map +1 -0
  20. package/lib/types/common/z-index-manager.d.ts +8 -0
  21. package/lib/types/common/z-index-manager.d.ts.map +1 -0
  22. package/lib/types/components/custom-label/CustomLabel.d.ts +14 -0
  23. package/lib/types/components/custom-label/CustomLabel.d.ts.map +1 -0
  24. package/lib/types/components/custom-label/index.d.ts +2 -0
  25. package/lib/types/components/custom-label/index.d.ts.map +1 -0
  26. package/lib/types/components/hooks/observable.d.ts +4 -0
  27. package/lib/types/components/hooks/observable.d.ts.map +1 -0
  28. package/lib/types/components/index.d.ts +3 -0
  29. package/lib/types/components/index.d.ts.map +1 -0
  30. package/lib/types/components/menu/Menu.d.ts +11 -0
  31. package/lib/types/components/menu/Menu.d.ts.map +1 -0
  32. package/lib/types/components/menu/index.d.ts +2 -0
  33. package/lib/types/components/menu/index.d.ts.map +1 -0
  34. package/lib/types/components/notification/Notification.d.ts +41 -0
  35. package/lib/types/components/notification/Notification.d.ts.map +1 -0
  36. package/lib/types/controllers/error/error.controller.d.ts +8 -0
  37. package/lib/types/controllers/error/error.controller.d.ts.map +1 -0
  38. package/lib/types/controllers/menus/menus.d.ts +5 -0
  39. package/lib/types/controllers/menus/menus.d.ts.map +1 -0
  40. package/lib/types/controllers/shared-shortcut.controller.d.ts +25 -0
  41. package/lib/types/controllers/shared-shortcut.controller.d.ts.map +1 -0
  42. package/lib/types/controllers/shortcut-display/menu.d.ts +3 -0
  43. package/lib/types/controllers/shortcut-display/menu.d.ts.map +1 -0
  44. package/lib/types/controllers/shortcut-display/shortcut-panel.controller.d.ts +10 -0
  45. package/lib/types/controllers/shortcut-display/shortcut-panel.controller.d.ts.map +1 -0
  46. package/lib/types/controllers/ui/ui-desktop.controller.d.ts +55 -0
  47. package/lib/types/controllers/ui/ui-desktop.controller.d.ts.map +1 -0
  48. package/lib/types/controllers/ui/ui.controller.d.ts +14 -0
  49. package/lib/types/controllers/ui/ui.controller.d.ts.map +1 -0
  50. package/lib/types/index.d.ts +30 -0
  51. package/lib/types/index.d.ts.map +1 -0
  52. package/lib/types/locale/en-US.d.ts +23 -0
  53. package/lib/types/locale/en-US.d.ts.map +1 -0
  54. package/lib/types/locale/index.d.ts +3 -0
  55. package/lib/types/locale/index.d.ts.map +1 -0
  56. package/lib/types/locale/zh-CN.d.ts +12 -0
  57. package/lib/types/locale/zh-CN.d.ts.map +1 -0
  58. package/lib/types/services/before-close/before-close.service.d.ts +21 -0
  59. package/lib/types/services/before-close/before-close.service.d.ts.map +1 -0
  60. package/lib/types/services/clipboard/clipboard-interface.service.d.ts +36 -0
  61. package/lib/types/services/clipboard/clipboard-interface.service.d.ts.map +1 -0
  62. package/lib/types/services/clipboard/clipboard.command.d.ts +5 -0
  63. package/lib/types/services/clipboard/clipboard.command.d.ts.map +1 -0
  64. package/lib/types/services/confirm/confirm.service.d.ts +10 -0
  65. package/lib/types/services/confirm/confirm.service.d.ts.map +1 -0
  66. package/lib/types/services/confirm/desktop-confirm.service.d.ts +12 -0
  67. package/lib/types/services/confirm/desktop-confirm.service.d.ts.map +1 -0
  68. package/lib/types/services/contextmenu/contextmenu.service.d.ts +18 -0
  69. package/lib/types/services/contextmenu/contextmenu.service.d.ts.map +1 -0
  70. package/lib/types/services/dialog/desktop-dialog.service.d.ts +12 -0
  71. package/lib/types/services/dialog/desktop-dialog.service.d.ts.map +1 -0
  72. package/lib/types/services/dialog/dialog.service.d.ts +10 -0
  73. package/lib/types/services/dialog/dialog.service.d.ts.map +1 -0
  74. package/lib/types/services/focus/focus.service.d.ts +22 -0
  75. package/lib/types/services/focus/focus.service.d.ts.map +1 -0
  76. package/lib/types/services/local-storage/local-storage.service.d.ts +11 -0
  77. package/lib/types/services/local-storage/local-storage.service.d.ts.map +1 -0
  78. package/lib/types/services/menu/menu.d.ts +103 -0
  79. package/lib/types/services/menu/menu.d.ts.map +1 -0
  80. package/lib/types/services/menu/menu.service.d.ts +28 -0
  81. package/lib/types/services/menu/menu.service.d.ts.map +1 -0
  82. package/lib/types/services/message/desktop-message.service.d.ts +11 -0
  83. package/lib/types/services/message/desktop-message.service.d.ts.map +1 -0
  84. package/lib/types/services/message/message.service.d.ts +8 -0
  85. package/lib/types/services/message/message.service.d.ts.map +1 -0
  86. package/lib/types/services/notification/desktop-notification.service.d.ts +7 -0
  87. package/lib/types/services/notification/desktop-notification.service.d.ts.map +1 -0
  88. package/lib/types/services/notification/notification.service.d.ts +7 -0
  89. package/lib/types/services/notification/notification.service.d.ts.map +1 -0
  90. package/lib/types/services/platform/platform.service.d.ts +15 -0
  91. package/lib/types/services/platform/platform.service.d.ts.map +1 -0
  92. package/lib/types/services/shortcut/keycode.d.ts +79 -0
  93. package/lib/types/services/shortcut/keycode.d.ts.map +1 -0
  94. package/lib/types/services/shortcut/shortcut-experience.service.d.ts +31 -0
  95. package/lib/types/services/shortcut/shortcut-experience.service.d.ts.map +1 -0
  96. package/lib/types/services/shortcut/shortcut-panel.service.d.ts +10 -0
  97. package/lib/types/services/shortcut/shortcut-panel.service.d.ts.map +1 -0
  98. package/lib/types/services/shortcut/shortcut.service.d.ts +55 -0
  99. package/lib/types/services/shortcut/shortcut.service.d.ts.map +1 -0
  100. package/lib/types/services/sidebar/desktop-sidebar.service.d.ts +12 -0
  101. package/lib/types/services/sidebar/desktop-sidebar.service.d.ts.map +1 -0
  102. package/lib/types/services/sidebar/sidebar.service.d.ts +10 -0
  103. package/lib/types/services/sidebar/sidebar.service.d.ts.map +1 -0
  104. package/lib/types/ui-plugin.d.ts +20 -0
  105. package/lib/types/ui-plugin.d.ts.map +1 -0
  106. package/lib/types/utils/cell.d.ts +34 -0
  107. package/lib/types/utils/cell.d.ts.map +1 -0
  108. package/lib/types/utils/index.d.ts +3 -0
  109. package/lib/types/utils/index.d.ts.map +1 -0
  110. package/lib/types/utils/util.d.ts +2 -0
  111. package/lib/types/utils/util.d.ts.map +1 -0
  112. package/lib/types/views/App.d.ts +13 -0
  113. package/lib/types/views/App.d.ts.map +1 -0
  114. package/lib/types/views/components/ComponentContainer.d.ts +6 -0
  115. package/lib/types/views/components/ComponentContainer.d.ts.map +1 -0
  116. package/lib/types/views/components/confirm-part/ConfirmPart.d.ts +3 -0
  117. package/lib/types/views/components/confirm-part/ConfirmPart.d.ts.map +1 -0
  118. package/lib/types/views/components/confirm-part/interface.d.ts +8 -0
  119. package/lib/types/views/components/confirm-part/interface.d.ts.map +1 -0
  120. package/lib/types/views/components/context-menu/ContextMenu.d.ts +5 -0
  121. package/lib/types/views/components/context-menu/ContextMenu.d.ts.map +1 -0
  122. package/lib/types/views/components/dialog-part/DialogPart.d.ts +3 -0
  123. package/lib/types/views/components/dialog-part/DialogPart.d.ts.map +1 -0
  124. package/lib/types/views/components/dialog-part/interface.d.ts +10 -0
  125. package/lib/types/views/components/dialog-part/interface.d.ts.map +1 -0
  126. package/lib/types/views/components/doc-bars/Button/ToolbarButton.d.ts +28 -0
  127. package/lib/types/views/components/doc-bars/Button/ToolbarButton.d.ts.map +1 -0
  128. package/lib/types/views/components/doc-bars/MenuBar.d.ts +7 -0
  129. package/lib/types/views/components/doc-bars/MenuBar.d.ts.map +1 -0
  130. package/lib/types/views/components/doc-bars/Toolbar.d.ts +3 -0
  131. package/lib/types/views/components/doc-bars/Toolbar.d.ts.map +1 -0
  132. package/lib/types/views/components/doc-bars/ToolbarItem.d.ts +4 -0
  133. package/lib/types/views/components/doc-bars/ToolbarItem.d.ts.map +1 -0
  134. package/lib/types/views/components/doc-bars/hooks/menu.d.ts +10 -0
  135. package/lib/types/views/components/doc-bars/hooks/menu.d.ts.map +1 -0
  136. package/lib/types/views/components/shortcut-panel/ShortcutPanel.d.ts +6 -0
  137. package/lib/types/views/components/shortcut-panel/ShortcutPanel.d.ts.map +1 -0
  138. package/lib/types/views/components/sidebar/Sidebar.d.ts +3 -0
  139. package/lib/types/views/components/sidebar/Sidebar.d.ts.map +1 -0
  140. package/lib/types/views/components/sidebar/interface.d.ts +11 -0
  141. package/lib/types/views/components/sidebar/interface.d.ts.map +1 -0
  142. package/lib/types/views/parts.d.ts +3 -0
  143. package/lib/types/views/parts.d.ts.map +1 -0
  144. package/package.json +77 -0
@@ -0,0 +1,4507 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
12
+ function _assert_this_initialized(self) {
13
+ if (self === void 0) {
14
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
15
+ }
16
+ return self;
17
+ }
18
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
19
+ try {
20
+ var info = gen[key](arg);
21
+ var value = info.value;
22
+ } catch (error) {
23
+ reject(error);
24
+ return;
25
+ }
26
+ if (info.done) {
27
+ resolve(value);
28
+ } else {
29
+ Promise.resolve(value).then(_next, _throw);
30
+ }
31
+ }
32
+ function _async_to_generator(fn) {
33
+ return function() {
34
+ var self = this, args = arguments;
35
+ return new Promise(function(resolve, reject) {
36
+ var gen = fn.apply(self, args);
37
+ function _next(value) {
38
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
39
+ }
40
+ function _throw(err) {
41
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
42
+ }
43
+ _next(undefined);
44
+ });
45
+ };
46
+ }
47
+ function _class_call_check(instance, Constructor) {
48
+ if (!(instance instanceof Constructor)) {
49
+ throw new TypeError("Cannot call a class as a function");
50
+ }
51
+ }
52
+ function _construct(Parent, args, Class) {
53
+ if (_is_native_reflect_construct()) {
54
+ _construct = Reflect.construct;
55
+ } else {
56
+ _construct = function construct(Parent, args, Class) {
57
+ var a = [
58
+ null
59
+ ];
60
+ a.push.apply(a, args);
61
+ var Constructor = Function.bind.apply(Parent, a);
62
+ var instance = new Constructor();
63
+ if (Class) _set_prototype_of(instance, Class.prototype);
64
+ return instance;
65
+ };
66
+ }
67
+ return _construct.apply(null, arguments);
68
+ }
69
+ function _defineProperties(target, props) {
70
+ for(var i = 0; i < props.length; i++){
71
+ var descriptor = props[i];
72
+ descriptor.enumerable = descriptor.enumerable || false;
73
+ descriptor.configurable = true;
74
+ if ("value" in descriptor) descriptor.writable = true;
75
+ Object.defineProperty(target, descriptor.key, descriptor);
76
+ }
77
+ }
78
+ function _create_class(Constructor, protoProps, staticProps) {
79
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
80
+ if (staticProps) _defineProperties(Constructor, staticProps);
81
+ return Constructor;
82
+ }
83
+ function _define_property(obj, key, value) {
84
+ if (key in obj) {
85
+ Object.defineProperty(obj, key, {
86
+ value: value,
87
+ enumerable: true,
88
+ configurable: true,
89
+ writable: true
90
+ });
91
+ } else {
92
+ obj[key] = value;
93
+ }
94
+ return obj;
95
+ }
96
+ function _get(target, property, receiver) {
97
+ if (typeof Reflect !== "undefined" && Reflect.get) {
98
+ _get = Reflect.get;
99
+ } else {
100
+ _get = function get(target, property, receiver) {
101
+ var base = _super_prop_base(target, property);
102
+ if (!base) return;
103
+ var desc = Object.getOwnPropertyDescriptor(base, property);
104
+ if (desc.get) {
105
+ return desc.get.call(receiver || target);
106
+ }
107
+ return desc.value;
108
+ };
109
+ }
110
+ return _get(target, property, receiver || target);
111
+ }
112
+ function _get_prototype_of(o) {
113
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
114
+ return o.__proto__ || Object.getPrototypeOf(o);
115
+ };
116
+ return _get_prototype_of(o);
117
+ }
118
+ function _inherits(subClass, superClass) {
119
+ if (typeof superClass !== "function" && superClass !== null) {
120
+ throw new TypeError("Super expression must either be null or a function");
121
+ }
122
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
123
+ constructor: {
124
+ value: subClass,
125
+ writable: true,
126
+ configurable: true
127
+ }
128
+ });
129
+ if (superClass) _set_prototype_of(subClass, superClass);
130
+ }
131
+ function _instanceof(left, right) {
132
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
133
+ return !!right[Symbol.hasInstance](left);
134
+ } else {
135
+ return left instanceof right;
136
+ }
137
+ }
138
+ function _is_native_function(fn) {
139
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
140
+ }
141
+ function _iterable_to_array(iter) {
142
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
143
+ }
144
+ function _iterable_to_array_limit(arr, i) {
145
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
146
+ if (_i == null) return;
147
+ var _arr = [];
148
+ var _n = true;
149
+ var _d = false;
150
+ var _s, _e;
151
+ try {
152
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
153
+ _arr.push(_s.value);
154
+ if (i && _arr.length === i) break;
155
+ }
156
+ } catch (err) {
157
+ _d = true;
158
+ _e = err;
159
+ } finally{
160
+ try {
161
+ if (!_n && _i["return"] != null) _i["return"]();
162
+ } finally{
163
+ if (_d) throw _e;
164
+ }
165
+ }
166
+ return _arr;
167
+ }
168
+ function _non_iterable_rest() {
169
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
170
+ }
171
+ function _non_iterable_spread() {
172
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
173
+ }
174
+ function _object_spread(target) {
175
+ for(var i = 1; i < arguments.length; i++){
176
+ var source = arguments[i] != null ? arguments[i] : {};
177
+ var ownKeys = Object.keys(source);
178
+ if (typeof Object.getOwnPropertySymbols === "function") {
179
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
180
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
181
+ }));
182
+ }
183
+ ownKeys.forEach(function(key) {
184
+ _define_property(target, key, source[key]);
185
+ });
186
+ }
187
+ return target;
188
+ }
189
+ function ownKeys(object, enumerableOnly) {
190
+ var keys = Object.keys(object);
191
+ if (Object.getOwnPropertySymbols) {
192
+ var symbols = Object.getOwnPropertySymbols(object);
193
+ if (enumerableOnly) {
194
+ symbols = symbols.filter(function(sym) {
195
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
196
+ });
197
+ }
198
+ keys.push.apply(keys, symbols);
199
+ }
200
+ return keys;
201
+ }
202
+ function _object_spread_props(target, source) {
203
+ source = source != null ? source : {};
204
+ if (Object.getOwnPropertyDescriptors) {
205
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
206
+ } else {
207
+ ownKeys(Object(source)).forEach(function(key) {
208
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
209
+ });
210
+ }
211
+ return target;
212
+ }
213
+ function _object_without_properties(source, excluded) {
214
+ if (source == null) return {};
215
+ var target = _object_without_properties_loose(source, excluded);
216
+ var key, i;
217
+ if (Object.getOwnPropertySymbols) {
218
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
219
+ for(i = 0; i < sourceSymbolKeys.length; i++){
220
+ key = sourceSymbolKeys[i];
221
+ if (excluded.indexOf(key) >= 0) continue;
222
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
223
+ target[key] = source[key];
224
+ }
225
+ }
226
+ return target;
227
+ }
228
+ function _object_without_properties_loose(source, excluded) {
229
+ if (source == null) return {};
230
+ var target = {};
231
+ var sourceKeys = Object.keys(source);
232
+ var key, i;
233
+ for(i = 0; i < sourceKeys.length; i++){
234
+ key = sourceKeys[i];
235
+ if (excluded.indexOf(key) >= 0) continue;
236
+ target[key] = source[key];
237
+ }
238
+ return target;
239
+ }
240
+ function _possible_constructor_return(self, call) {
241
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
242
+ return call;
243
+ }
244
+ return _assert_this_initialized(self);
245
+ }
246
+ function _set_prototype_of(o, p) {
247
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
248
+ o.__proto__ = p;
249
+ return o;
250
+ };
251
+ return _set_prototype_of(o, p);
252
+ }
253
+ function _sliced_to_array(arr, i) {
254
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
255
+ }
256
+ function _super_prop_base(object, property) {
257
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
258
+ object = _get_prototype_of(object);
259
+ if (object === null) break;
260
+ }
261
+ return object;
262
+ }
263
+ function _to_consumable_array(arr) {
264
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
265
+ }
266
+ function _type_of(obj) {
267
+ "@swc/helpers - typeof";
268
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
269
+ }
270
+ function _unsupported_iterable_to_array(o, minLen) {
271
+ if (!o) return;
272
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
273
+ var n = Object.prototype.toString.call(o).slice(8, -1);
274
+ if (n === "Object" && o.constructor) n = o.constructor.name;
275
+ if (n === "Map" || n === "Set") return Array.from(n);
276
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
277
+ }
278
+ function _wrap_native_super(Class) {
279
+ var _cache = typeof Map === "function" ? new Map() : undefined;
280
+ _wrap_native_super = function wrapNativeSuper(Class) {
281
+ if (Class === null || !_is_native_function(Class)) return Class;
282
+ if (typeof Class !== "function") {
283
+ throw new TypeError("Super expression must either be null or a function");
284
+ }
285
+ if (typeof _cache !== "undefined") {
286
+ if (_cache.has(Class)) return _cache.get(Class);
287
+ _cache.set(Class, Wrapper);
288
+ }
289
+ function Wrapper() {
290
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
291
+ }
292
+ Wrapper.prototype = Object.create(Class.prototype, {
293
+ constructor: {
294
+ value: Wrapper,
295
+ enumerable: false,
296
+ writable: true,
297
+ configurable: true
298
+ }
299
+ });
300
+ return _set_prototype_of(Wrapper, Class);
301
+ };
302
+ return _wrap_native_super(Class);
303
+ }
304
+ function _is_native_reflect_construct() {
305
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
306
+ if (Reflect.construct.sham) return false;
307
+ if (typeof Proxy === "function") return true;
308
+ try {
309
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
310
+ return true;
311
+ } catch (e) {
312
+ return false;
313
+ }
314
+ }
315
+ function _create_super(Derived) {
316
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
317
+ return function _createSuperInternal() {
318
+ var Super = _get_prototype_of(Derived), result;
319
+ if (hasNativeReflectConstruct) {
320
+ var NewTarget = _get_prototype_of(this).constructor;
321
+ result = Reflect.construct(Super, arguments, NewTarget);
322
+ } else {
323
+ result = Super.apply(this, arguments);
324
+ }
325
+ return _possible_constructor_return(this, result);
326
+ };
327
+ }
328
+ function _ts_generator(thisArg, body) {
329
+ var f, y, t, g, _ = {
330
+ label: 0,
331
+ sent: function() {
332
+ if (t[0] & 1) throw t[1];
333
+ return t[1];
334
+ },
335
+ trys: [],
336
+ ops: []
337
+ };
338
+ return g = {
339
+ next: verb(0),
340
+ "throw": verb(1),
341
+ "return": verb(2)
342
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
343
+ return this;
344
+ }), g;
345
+ function verb(n) {
346
+ return function(v) {
347
+ return step([
348
+ n,
349
+ v
350
+ ]);
351
+ };
352
+ }
353
+ function step(op) {
354
+ if (f) throw new TypeError("Generator is already executing.");
355
+ while(_)try {
356
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
357
+ if (y = 0, t) op = [
358
+ op[0] & 2,
359
+ t.value
360
+ ];
361
+ switch(op[0]){
362
+ case 0:
363
+ case 1:
364
+ t = op;
365
+ break;
366
+ case 4:
367
+ _.label++;
368
+ return {
369
+ value: op[1],
370
+ done: false
371
+ };
372
+ case 5:
373
+ _.label++;
374
+ y = op[1];
375
+ op = [
376
+ 0
377
+ ];
378
+ continue;
379
+ case 7:
380
+ op = _.ops.pop();
381
+ _.trys.pop();
382
+ continue;
383
+ default:
384
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
385
+ _ = 0;
386
+ continue;
387
+ }
388
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
389
+ _.label = op[1];
390
+ break;
391
+ }
392
+ if (op[0] === 6 && _.label < t[1]) {
393
+ _.label = t[1];
394
+ t = op;
395
+ break;
396
+ }
397
+ if (t && _.label < t[2]) {
398
+ _.label = t[2];
399
+ _.ops.push(op);
400
+ break;
401
+ }
402
+ if (t[2]) _.ops.pop();
403
+ _.trys.pop();
404
+ continue;
405
+ }
406
+ op = body.call(thisArg, _);
407
+ } catch (e) {
408
+ op = [
409
+ 6,
410
+ e
411
+ ];
412
+ y = 0;
413
+ } finally{
414
+ f = t = 0;
415
+ }
416
+ if (op[0] & 5) throw op[1];
417
+ return {
418
+ value: op[0] ? op[1] : void 0,
419
+ done: true
420
+ };
421
+ }
422
+ }
423
+ var _class;
424
+ var __defProp = Object.defineProperty;
425
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
426
+ var __decorateClass = function(decorators, target, key, kind) {
427
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
428
+ for(var i = decorators.length - 1, decorator; i >= 0; i--)if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
429
+ if (kind && result) __defProp(target, key, result);
430
+ return result;
431
+ };
432
+ var __decorateParam = function(index, decorator) {
433
+ return function(target, key) {
434
+ return decorator(target, key, index);
435
+ };
436
+ };
437
+ // src/common/component-manager.ts
438
+ import { toDisposable } from "@univerjs/core";
439
+ import { AdjustHeight, AdjustWidth, AlignBottomSingle, AlignTopSingle, AllBorderSingle, AutoHeight, AutowrapSingle, AvgSingle, BoldSingle, BrushSingle, CancelFreezeSingle, CancelMergeSingle, ClearFormat, CntSingle, CodeSingle, ContentSingle16, Copy, DeleteCellMoveDown, DeleteCellShiftLeft, DeleteCellShiftRight, DeleteCellShiftUp, DeleteColumn, DeleteRow, DownBorder, FontColor, FreezeColumnSingle, FreezeRowSingle, FreezeToSelectedSingle, FunctionSingle, Hide, HorizontallySingle, HorizontalMergeSingle, InnerBorder, Insert, InsertCellDown, InsertCellShiftRight, InsertRowAbove, InsertRowBelow, ItalicSingle, KeyboardSingle, LeftBorder, LeftInsertColumn, LeftJustifyingSingle, LeftRotationFortyFiveDegreesSingle, LeftRotationNinetyDegreesSingle, MaxSingle, MergeAllSingle, MinSingle, NoBorderSingle, NoColor, NoRotationSingle, OuterBorder, OverflowSingle, PaintBucket, PasteSpecial, RedoSingle, Reduce, RightBorder, RightInsertColumn, RightJustifyingSingle, RightRotationFortyFiveDegreesSingle, RightRotationNinetyDegreesSingle, StrikethroughSingle, SumSingle, TruncationSingle, UnderlineSingle, UndoSingle, UpBorder, VerticalCenterSingle, VerticalIntegrationSingle, VerticalTextSingle } from "@univerjs/icons";
440
+ var ComponentManager = /*#__PURE__*/ function() {
441
+ "use strict";
442
+ function ComponentManager() {
443
+ _class_call_check(this, ComponentManager);
444
+ _define_property(this, "_components", /* @__PURE__ */ new Map());
445
+ var iconList = {
446
+ AlignBottomSingle: AlignBottomSingle,
447
+ AlignTopSingle: AlignTopSingle,
448
+ AllBorderSingle: AllBorderSingle,
449
+ AutowrapSingle: AutowrapSingle,
450
+ BoldSingle: BoldSingle,
451
+ BrushSingle: BrushSingle,
452
+ Copy: Copy,
453
+ ClearFormat: ClearFormat,
454
+ DownBorder: DownBorder,
455
+ FontColor: FontColor,
456
+ FunctionSingle: FunctionSingle,
457
+ HorizontallySingle: HorizontallySingle,
458
+ InnerBorder: InnerBorder,
459
+ ItalicSingle: ItalicSingle,
460
+ KeyboardSingle: KeyboardSingle,
461
+ ContentSingle16: ContentSingle16,
462
+ LeftBorder: LeftBorder,
463
+ LeftJustifyingSingle: LeftJustifyingSingle,
464
+ LeftRotationFortyFiveDegreesSingle: LeftRotationFortyFiveDegreesSingle,
465
+ LeftRotationNinetyDegreesSingle: LeftRotationNinetyDegreesSingle,
466
+ MergeAllSingle: MergeAllSingle,
467
+ HorizontalMergeSingle: HorizontalMergeSingle,
468
+ VerticalIntegrationSingle: VerticalIntegrationSingle,
469
+ CancelMergeSingle: CancelMergeSingle,
470
+ NoBorderSingle: NoBorderSingle,
471
+ NoColor: NoColor,
472
+ NoRotationSingle: NoRotationSingle,
473
+ OuterBorder: OuterBorder,
474
+ OverflowSingle: OverflowSingle,
475
+ PaintBucket: PaintBucket,
476
+ PasteSpecial: PasteSpecial,
477
+ RedoSingle: RedoSingle,
478
+ RightBorder: RightBorder,
479
+ RightJustifyingSingle: RightJustifyingSingle,
480
+ RightRotationFortyFiveDegreesSingle: RightRotationFortyFiveDegreesSingle,
481
+ RightRotationNinetyDegreesSingle: RightRotationNinetyDegreesSingle,
482
+ StrikethroughSingle: StrikethroughSingle,
483
+ TruncationSingle: TruncationSingle,
484
+ UnderlineSingle: UnderlineSingle,
485
+ UndoSingle: UndoSingle,
486
+ UpBorder: UpBorder,
487
+ VerticalCenterSingle: VerticalCenterSingle,
488
+ VerticalTextSingle: VerticalTextSingle,
489
+ Insert: Insert,
490
+ InsertCellDown: InsertCellDown,
491
+ InsertCellShiftRight: InsertCellShiftRight,
492
+ InsertRowAbove: InsertRowAbove,
493
+ InsertRowBelow: InsertRowBelow,
494
+ LeftInsertColumn: LeftInsertColumn,
495
+ RightInsertColumn: RightInsertColumn,
496
+ DeleteColumn: DeleteColumn,
497
+ DeleteRow: DeleteRow,
498
+ DeleteCellShiftUp: DeleteCellShiftUp,
499
+ DeleteCellShiftRight: DeleteCellShiftRight,
500
+ DeleteCellShiftLeft: DeleteCellShiftLeft,
501
+ DeleteCellMoveDown: DeleteCellMoveDown,
502
+ Reduce: Reduce,
503
+ Hide: Hide,
504
+ AutoHeight: AutoHeight,
505
+ AdjustHeight: AdjustHeight,
506
+ AdjustWidth: AdjustWidth,
507
+ AvgSingle: AvgSingle,
508
+ CntSingle: CntSingle,
509
+ MaxSingle: MaxSingle,
510
+ MinSingle: MinSingle,
511
+ SumSingle: SumSingle,
512
+ CancelFreezeSingle: CancelFreezeSingle,
513
+ FreezeColumnSingle: FreezeColumnSingle,
514
+ FreezeRowSingle: FreezeRowSingle,
515
+ FreezeToSelectedSingle: FreezeToSelectedSingle,
516
+ CodeSingle: CodeSingle
517
+ };
518
+ for(var k in iconList){
519
+ this.register(k, iconList[k]);
520
+ }
521
+ }
522
+ _create_class(ComponentManager, [
523
+ {
524
+ key: "register",
525
+ value: function register(name, component) {
526
+ var _this = this;
527
+ if (this._components.has(name)) {
528
+ console.warn("Component ".concat(name, " already exists."));
529
+ }
530
+ this._components.set(name, component);
531
+ return toDisposable(function() {
532
+ return _this._components.delete(name);
533
+ });
534
+ }
535
+ },
536
+ {
537
+ key: "get",
538
+ value: function get(name) {
539
+ return this._components.get(name);
540
+ }
541
+ },
542
+ {
543
+ key: "delete",
544
+ value: function _delete(name) {
545
+ this._components.delete(name);
546
+ }
547
+ }
548
+ ]);
549
+ return ComponentManager;
550
+ }();
551
+ // src/common/z-index-manager.ts
552
+ var ZIndexManager = /*#__PURE__*/ function() {
553
+ "use strict";
554
+ function ZIndexManager() {
555
+ _class_call_check(this, ZIndexManager);
556
+ _define_property(this, "_list", /* @__PURE__ */ new Map());
557
+ }
558
+ _create_class(ZIndexManager, [
559
+ {
560
+ key: "setIndex",
561
+ value: function setIndex(name, index) {
562
+ this._list.set(name, index);
563
+ }
564
+ },
565
+ {
566
+ key: "getIndex",
567
+ value: function getIndex(name) {
568
+ return this._list.get(name);
569
+ }
570
+ },
571
+ {
572
+ key: "removeIndex",
573
+ value: function removeIndex(name) {
574
+ this._list.delete(name);
575
+ }
576
+ },
577
+ {
578
+ key: "getMaxIndex",
579
+ value: function getMaxIndex() {
580
+ var max = -9999999;
581
+ this._list.forEach(function(item) {
582
+ if (+item > max) {
583
+ max = +item;
584
+ }
585
+ });
586
+ return max;
587
+ }
588
+ }
589
+ ]);
590
+ return ZIndexManager;
591
+ }();
592
+ // src/components/custom-label/CustomLabel.tsx
593
+ import { TinyColor } from "@ctrl/tinycolor";
594
+ import { LocaleService } from "@univerjs/core";
595
+ import { useDependency } from "@wendellhu/redi/react-bindings";
596
+ import React from "react";
597
+ import { isObservable } from "rxjs";
598
+ // src/components/hooks/observable.ts
599
+ import { useRef, useState } from "react";
600
+ function useObservable(observable, defaultValue, shouldHaveSyncValue) {
601
+ var observableRef = useRef(null);
602
+ var subscriptionRef = useRef(null);
603
+ var setValue;
604
+ var initialized = false;
605
+ var innerDefaultValue;
606
+ if (!observableRef.current || observableRef.current !== observable) {
607
+ var _subscriptionRef_current;
608
+ (_subscriptionRef_current = subscriptionRef.current) === null || _subscriptionRef_current === void 0 ? void 0 : _subscriptionRef_current.unsubscribe();
609
+ subscriptionRef.current = observable.subscribe(function(v) {
610
+ if (setValue) {
611
+ setValue(v);
612
+ } else {
613
+ innerDefaultValue = v;
614
+ initialized = true;
615
+ }
616
+ });
617
+ }
618
+ if (shouldHaveSyncValue && !initialized) {
619
+ throw new Error("[useObservable]: expect shouldHaveSyncValue but not getting a sync value!");
620
+ }
621
+ var s = useState(innerDefaultValue || defaultValue);
622
+ var value = s[0];
623
+ setValue = s[1];
624
+ return value;
625
+ }
626
+ // src/components/custom-label/CustomLabel.tsx
627
+ function CustomLabel(props) {
628
+ var title = props.title, icon = props.icon, label = props.label, value = props.value, value$ = props.value$;
629
+ var localeService = useDependency(LocaleService);
630
+ var componentManager = useDependency(ComponentManager);
631
+ var nodes = [];
632
+ var index = 0;
633
+ var realValue = value;
634
+ if (value$) {
635
+ realValue = useObservable(value$, void 0, true);
636
+ }
637
+ var realIcon;
638
+ if (isObservable(icon)) {
639
+ realIcon = useObservable(icon, void 0, true);
640
+ } else {
641
+ realIcon = icon;
642
+ }
643
+ var isValid = new TinyColor(realValue).isValid;
644
+ if (icon) {
645
+ var Icon = componentManager.get(realIcon !== null && realIcon !== void 0 ? realIcon : "");
646
+ Icon && nodes.push(/* @__PURE__ */ React.createElement(Icon, {
647
+ key: index++,
648
+ extend: {
649
+ colorChannel1: isValid ? realValue : "rgb(var(--primary-color))"
650
+ }
651
+ }));
652
+ }
653
+ if (label) {
654
+ var isStringLabel = typeof label === "string";
655
+ var customProps = isStringLabel ? _object_spread({}, props) : _object_spread({}, label === null || label === void 0 ? void 0 : label.props, props);
656
+ var labelName = isStringLabel ? label : label === null || label === void 0 ? void 0 : label.name;
657
+ var CustomComponent = componentManager.get(labelName);
658
+ if (CustomComponent) {
659
+ nodes.push(/* @__PURE__ */ React.createElement(CustomComponent, _object_spread_props(_object_spread({
660
+ key: index++
661
+ }, customProps), {
662
+ value: realValue
663
+ })));
664
+ } else {
665
+ nodes.push(/* @__PURE__ */ React.createElement("span", {
666
+ key: index++
667
+ }, localeService.t(labelName)));
668
+ }
669
+ }
670
+ if (title) {
671
+ nodes.push(/* @__PURE__ */ React.createElement("span", {
672
+ key: index++
673
+ }, localeService.t(title)));
674
+ }
675
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, nodes);
676
+ }
677
+ // src/components/menu/Menu.tsx
678
+ import { isRealNum } from "@univerjs/core";
679
+ import { Menu as DesignMenu, MenuItem as DesignMenuItem, MenuItemGroup as DesignMenuItemGroup, SubMenu as DesignSubMenu } from "@univerjs/design";
680
+ import { CheckMarkSingle, MoreSingle } from "@univerjs/icons";
681
+ import { useDependency as useDependency2 } from "@wendellhu/redi/react-bindings";
682
+ import clsx from "clsx";
683
+ import React2, { useState as useState2 } from "react";
684
+ import { isObservable as isObservable2, of } from "rxjs";
685
+ // src/services/menu/menu.ts
686
+ var MenuPosition = /* @__PURE__ */ function(MenuPosition2) {
687
+ MenuPosition2["VOID"] = "void";
688
+ MenuPosition2["TOOLBAR_START"] = "uiToolbar.start";
689
+ MenuPosition2["TOOLBAR_INSERT"] = "uiToolbar.insert";
690
+ MenuPosition2["TOOLBAR_FORMULAS"] = "uiToolbar.formulas";
691
+ MenuPosition2["TOOLBAR_DATA"] = "uiToolbar.data";
692
+ MenuPosition2["TOOLBAR_VIEW"] = "uiToolbar.view";
693
+ MenuPosition2["TOOLBAR_OTHERS"] = "uiToolbar.others";
694
+ MenuPosition2["CONTEXT_MENU"] = "contextMenu";
695
+ return MenuPosition2;
696
+ }(MenuPosition || {});
697
+ var MenuGroup = /* @__PURE__ */ function(MenuGroup2) {
698
+ MenuGroup2[MenuGroup2["TOOLBAR_HISTORY"] = 0] = "TOOLBAR_HISTORY";
699
+ MenuGroup2[MenuGroup2["TOOLBAR_FORMAT"] = 1] = "TOOLBAR_FORMAT";
700
+ MenuGroup2[MenuGroup2["TOOLBAR_LAYOUT"] = 2] = "TOOLBAR_LAYOUT";
701
+ MenuGroup2[MenuGroup2["TOOLBAR_FORMULAS_INSERT"] = 3] = "TOOLBAR_FORMULAS_INSERT";
702
+ MenuGroup2[MenuGroup2["TOOLBAR_FORMULAS_VIEW"] = 4] = "TOOLBAR_FORMULAS_VIEW";
703
+ MenuGroup2[MenuGroup2["TOOLBAR_FILE"] = 5] = "TOOLBAR_FILE";
704
+ MenuGroup2[MenuGroup2["TOOLBAR_OTHERS"] = 6] = "TOOLBAR_OTHERS";
705
+ MenuGroup2[MenuGroup2["CONTEXT_MENU_FORMAT"] = 7] = "CONTEXT_MENU_FORMAT";
706
+ MenuGroup2[MenuGroup2["CONTEXT_MENU_LAYOUT"] = 8] = "CONTEXT_MENU_LAYOUT";
707
+ MenuGroup2[MenuGroup2["CONTEXT_MENU_DATA"] = 9] = "CONTEXT_MENU_DATA";
708
+ MenuGroup2[MenuGroup2["CONTEXT_MENU_OTHERS"] = 10] = "CONTEXT_MENU_OTHERS";
709
+ return MenuGroup2;
710
+ }(MenuGroup || {});
711
+ var MenuItemType = /* @__PURE__ */ function(MenuItemType2) {
712
+ MenuItemType2[MenuItemType2["BUTTON"] = 0] = "BUTTON";
713
+ MenuItemType2[MenuItemType2["SELECTOR"] = 1] = "SELECTOR";
714
+ MenuItemType2[MenuItemType2["BUTTON_SELECTOR"] = 2] = "BUTTON_SELECTOR";
715
+ MenuItemType2[MenuItemType2["SUBITEMS"] = 3] = "SUBITEMS";
716
+ return MenuItemType2;
717
+ }(MenuItemType || {});
718
+ // src/services/menu/menu.service.ts
719
+ import { Disposable as Disposable2, toDisposable as toDisposable4 } from "@univerjs/core";
720
+ import { createIdentifier as createIdentifier3 } from "@wendellhu/redi";
721
+ import { BehaviorSubject } from "rxjs";
722
+ // src/services/shortcut/shortcut.service.ts
723
+ import { Disposable, ICommandService, IContextService, toDisposable as toDisposable3 } from "@univerjs/core";
724
+ import { createIdentifier as createIdentifier2 } from "@wendellhu/redi";
725
+ import { Subject } from "rxjs";
726
+ // src/common/lifecycle.ts
727
+ import { toDisposable as toDisposable2 } from "@univerjs/core";
728
+ function fromDocumentEvent(type, listener, options) {
729
+ document.addEventListener(type, listener, options);
730
+ return toDisposable2(function() {
731
+ return document.removeEventListener(type, listener, options);
732
+ });
733
+ }
734
+ // src/services/platform/platform.service.ts
735
+ import { createIdentifier } from "@wendellhu/redi";
736
+ var IPlatformService = createIdentifier("univer.platform-service");
737
+ var DesktopPlatformService = /*#__PURE__*/ function() {
738
+ "use strict";
739
+ function DesktopPlatformService() {
740
+ _class_call_check(this, DesktopPlatformService);
741
+ }
742
+ _create_class(DesktopPlatformService, [
743
+ {
744
+ key: "isMac",
745
+ get: function get() {
746
+ return /Mac/.test(navigator.appVersion);
747
+ }
748
+ },
749
+ {
750
+ key: "isWindows",
751
+ get: function get() {
752
+ return /Windows/.test(navigator.appVersion);
753
+ }
754
+ },
755
+ {
756
+ key: "isLinux",
757
+ get: function get() {
758
+ return /Linux/.test(navigator.appVersion);
759
+ }
760
+ }
761
+ ]);
762
+ return DesktopPlatformService;
763
+ }();
764
+ var _obj;
765
+ // src/services/shortcut/keycode.ts
766
+ var KeyCodeToChar = (_obj = {}, _define_property(_obj, 8 /* BACKSPACE */ , "Backspace"), _define_property(_obj, 9 /* TAB */ , "Tab"), _define_property(_obj, 13 /* ENTER */ , "Enter"), _define_property(_obj, 46 /* DELETE */ , "Del"), _define_property(_obj, 27 /* ESC */ , "Esc"), _define_property(_obj, 32 /* SPACE */ , "Space"), _define_property(_obj, 37 /* ARROW_LEFT */ , "←"), _define_property(_obj, 39 /* ARROW_RIGHT */ , "→"), _define_property(_obj, 38 /* ARROW_UP */ , "↑"), _define_property(_obj, 40 /* ARROW_DOWN */ , "↓"), _define_property(_obj, 48 /* Digit0 */ , "0"), _define_property(_obj, 49 /* Digit1 */ , "1"), _define_property(_obj, 50 /* Digit2 */ , "2"), _define_property(_obj, 51 /* Digit3 */ , "3"), _define_property(_obj, 52 /* Digit4 */ , "4"), _define_property(_obj, 53 /* Digit5 */ , "5"), _define_property(_obj, 54 /* Digit6 */ , "6"), _define_property(_obj, 55 /* Digit7 */ , "7"), _define_property(_obj, 56 /* Digit8 */ , "8"), _define_property(_obj, 57 /* Digit9 */ , "9"), _define_property(_obj, 65 /* A */ , "A"), _define_property(_obj, 66 /* B */ , "B"), _define_property(_obj, 67 /* C */ , "C"), _define_property(_obj, 68 /* D */ , "D"), _define_property(_obj, 69 /* E */ , "E"), _define_property(_obj, 70 /* F */ , "F"), _define_property(_obj, 71 /* G */ , "G"), _define_property(_obj, 72 /* H */ , "H"), _define_property(_obj, 73 /* I */ , "I"), _define_property(_obj, 74 /* J */ , "J"), _define_property(_obj, 75 /* K */ , "K"), _define_property(_obj, 76 /* L */ , "L"), _define_property(_obj, 77 /* M */ , "M"), _define_property(_obj, 78 /* N */ , "N"), _define_property(_obj, 79 /* O */ , "O"), _define_property(_obj, 80 /* P */ , "P"), _define_property(_obj, 81 /* Q */ , "Q"), _define_property(_obj, 82 /* R */ , "R"), _define_property(_obj, 83 /* S */ , "S"), _define_property(_obj, 84 /* T */ , "T"), _define_property(_obj, 85 /* U */ , "U"), _define_property(_obj, 86 /* V */ , "V"), _define_property(_obj, 87 /* W */ , "W"), _define_property(_obj, 88 /* X */ , "X"), _define_property(_obj, 89 /* Y */ , "Y"), _define_property(_obj, 90 /* Z */ , "Z"), _define_property(_obj, 189 /* MINUS */ , "-"), _define_property(_obj, 187 /* EQUAL */ , "="), _obj);
767
+ var KeyCode = /* @__PURE__ */ function(KeyCode2) {
768
+ KeyCode2[KeyCode2["UNKNOWN"] = 0] = "UNKNOWN";
769
+ KeyCode2[KeyCode2["BACKSPACE"] = 8] = "BACKSPACE";
770
+ KeyCode2[KeyCode2["TAB"] = 9] = "TAB";
771
+ KeyCode2[KeyCode2["ENTER"] = 13] = "ENTER";
772
+ KeyCode2[KeyCode2["ESC"] = 27] = "ESC";
773
+ KeyCode2[KeyCode2["SPACE"] = 32] = "SPACE";
774
+ KeyCode2[KeyCode2["ARROW_LEFT"] = 37] = "ARROW_LEFT";
775
+ KeyCode2[KeyCode2["ARROW_UP"] = 38] = "ARROW_UP";
776
+ KeyCode2[KeyCode2["ARROW_RIGHT"] = 39] = "ARROW_RIGHT";
777
+ KeyCode2[KeyCode2["ARROW_DOWN"] = 40] = "ARROW_DOWN";
778
+ KeyCode2[KeyCode2["INSERT"] = 45] = "INSERT";
779
+ KeyCode2[KeyCode2["DELETE"] = 46] = "DELETE";
780
+ KeyCode2[KeyCode2["Digit0"] = 48] = "Digit0";
781
+ KeyCode2[KeyCode2["Digit1"] = 49] = "Digit1";
782
+ KeyCode2[KeyCode2["Digit2"] = 50] = "Digit2";
783
+ KeyCode2[KeyCode2["Digit3"] = 51] = "Digit3";
784
+ KeyCode2[KeyCode2["Digit4"] = 52] = "Digit4";
785
+ KeyCode2[KeyCode2["Digit5"] = 53] = "Digit5";
786
+ KeyCode2[KeyCode2["Digit6"] = 54] = "Digit6";
787
+ KeyCode2[KeyCode2["Digit7"] = 55] = "Digit7";
788
+ KeyCode2[KeyCode2["Digit8"] = 56] = "Digit8";
789
+ KeyCode2[KeyCode2["Digit9"] = 57] = "Digit9";
790
+ KeyCode2[KeyCode2["A"] = 65] = "A";
791
+ KeyCode2[KeyCode2["B"] = 66] = "B";
792
+ KeyCode2[KeyCode2["C"] = 67] = "C";
793
+ KeyCode2[KeyCode2["D"] = 68] = "D";
794
+ KeyCode2[KeyCode2["E"] = 69] = "E";
795
+ KeyCode2[KeyCode2["F"] = 70] = "F";
796
+ KeyCode2[KeyCode2["G"] = 71] = "G";
797
+ KeyCode2[KeyCode2["H"] = 72] = "H";
798
+ KeyCode2[KeyCode2["I"] = 73] = "I";
799
+ KeyCode2[KeyCode2["J"] = 74] = "J";
800
+ KeyCode2[KeyCode2["K"] = 75] = "K";
801
+ KeyCode2[KeyCode2["L"] = 76] = "L";
802
+ KeyCode2[KeyCode2["M"] = 77] = "M";
803
+ KeyCode2[KeyCode2["N"] = 78] = "N";
804
+ KeyCode2[KeyCode2["O"] = 79] = "O";
805
+ KeyCode2[KeyCode2["P"] = 80] = "P";
806
+ KeyCode2[KeyCode2["Q"] = 81] = "Q";
807
+ KeyCode2[KeyCode2["R"] = 82] = "R";
808
+ KeyCode2[KeyCode2["S"] = 83] = "S";
809
+ KeyCode2[KeyCode2["T"] = 84] = "T";
810
+ KeyCode2[KeyCode2["U"] = 85] = "U";
811
+ KeyCode2[KeyCode2["V"] = 86] = "V";
812
+ KeyCode2[KeyCode2["W"] = 87] = "W";
813
+ KeyCode2[KeyCode2["X"] = 88] = "X";
814
+ KeyCode2[KeyCode2["Y"] = 89] = "Y";
815
+ KeyCode2[KeyCode2["Z"] = 90] = "Z";
816
+ KeyCode2[KeyCode2["F1"] = 112] = "F1";
817
+ KeyCode2[KeyCode2["F2"] = 113] = "F2";
818
+ KeyCode2[KeyCode2["F3"] = 114] = "F3";
819
+ KeyCode2[KeyCode2["F4"] = 115] = "F4";
820
+ KeyCode2[KeyCode2["F5"] = 116] = "F5";
821
+ KeyCode2[KeyCode2["F6"] = 117] = "F6";
822
+ KeyCode2[KeyCode2["F7"] = 118] = "F7";
823
+ KeyCode2[KeyCode2["F8"] = 119] = "F8";
824
+ KeyCode2[KeyCode2["F9"] = 120] = "F9";
825
+ KeyCode2[KeyCode2["F10"] = 121] = "F10";
826
+ KeyCode2[KeyCode2["F11"] = 122] = "F11";
827
+ KeyCode2[KeyCode2["F12"] = 123] = "F12";
828
+ KeyCode2[KeyCode2["NUM_LOCK"] = 144] = "NUM_LOCK";
829
+ KeyCode2[KeyCode2["SCROLL_LOCK"] = 145] = "SCROLL_LOCK";
830
+ KeyCode2[KeyCode2["MINUS"] = 189] = "MINUS";
831
+ KeyCode2[KeyCode2["EQUAL"] = 187] = "EQUAL";
832
+ return KeyCode2;
833
+ }(KeyCode || {});
834
+ var MetaKeys = /* @__PURE__ */ function(MetaKeys2) {
835
+ MetaKeys2[MetaKeys2["SHIFT"] = 1024] = "SHIFT";
836
+ MetaKeys2[MetaKeys2["ALT"] = 2048] = "ALT";
837
+ MetaKeys2[MetaKeys2["CTRL_COMMAND"] = 4096] = "CTRL_COMMAND";
838
+ MetaKeys2[MetaKeys2["MAC_CTRL"] = 8192] = "MAC_CTRL";
839
+ return MetaKeys2;
840
+ }(MetaKeys || {});
841
+ // src/services/shortcut/shortcut.service.ts
842
+ var IShortcutService = createIdentifier2("univer.shortcut");
843
+ var DesktopShortcutService = /*#__PURE__*/ function(Disposable) {
844
+ "use strict";
845
+ _inherits(DesktopShortcutService, Disposable);
846
+ var _super = _create_super(DesktopShortcutService);
847
+ function DesktopShortcutService(_commandService, _platformService, _contextService) {
848
+ _class_call_check(this, DesktopShortcutService);
849
+ var _this;
850
+ _this = _super.call(this);
851
+ _define_property(_assert_this_initialized(_this), "_shortCutMapping", /* @__PURE__ */ new Map());
852
+ _define_property(_assert_this_initialized(_this), "_commandIDMapping", /* @__PURE__ */ new Map());
853
+ _define_property(_assert_this_initialized(_this), "_shortcutChanged$", new Subject());
854
+ _define_property(_assert_this_initialized(_this), "shortcutChanged$", _this._shortcutChanged$.asObservable());
855
+ _define_property(_assert_this_initialized(_this), "_forceEscaped", false);
856
+ _this._commandService = _commandService;
857
+ _this._platformService = _platformService;
858
+ _this._contextService = _contextService;
859
+ _this.disposeWithMe(fromDocumentEvent("keydown", function(e) {
860
+ _this._resolveKeyboardEvent(e);
861
+ }));
862
+ return _this;
863
+ }
864
+ _create_class(DesktopShortcutService, [
865
+ {
866
+ key: "getAllShortcuts",
867
+ value: function getAllShortcuts() {
868
+ return Array.from(this._shortCutMapping.values()).map(function(v) {
869
+ return Array.from(v.values());
870
+ }).flat();
871
+ }
872
+ },
873
+ {
874
+ key: "registerShortcut",
875
+ value: function registerShortcut(shortcut) {
876
+ var _this = this;
877
+ var binding = this._getBindingFromItem(shortcut);
878
+ var bindingSet = this._shortCutMapping.get(binding);
879
+ if (bindingSet) {
880
+ bindingSet.add(shortcut);
881
+ } else {
882
+ this._shortCutMapping.set(binding, /* @__PURE__ */ new Set([
883
+ shortcut
884
+ ]));
885
+ }
886
+ var commandID = shortcut.id;
887
+ var commandIDSet = this._commandIDMapping.get(commandID);
888
+ if (commandIDSet) {
889
+ commandIDSet.add(shortcut);
890
+ } else {
891
+ this._commandIDMapping.set(commandID, /* @__PURE__ */ new Set([
892
+ shortcut
893
+ ]));
894
+ }
895
+ this._emitShortcutChanged();
896
+ return toDisposable3(function() {
897
+ var _this__shortCutMapping_get, _this__shortCutMapping_get1, _this__commandIDMapping_get, _this__commandIDMapping_get1;
898
+ (_this__shortCutMapping_get = _this._shortCutMapping.get(binding)) === null || _this__shortCutMapping_get === void 0 ? void 0 : _this__shortCutMapping_get.delete(shortcut);
899
+ if (((_this__shortCutMapping_get1 = _this._shortCutMapping.get(binding)) === null || _this__shortCutMapping_get1 === void 0 ? void 0 : _this__shortCutMapping_get1.size) === 0) {
900
+ _this._shortCutMapping.delete(binding);
901
+ }
902
+ (_this__commandIDMapping_get = _this._commandIDMapping.get(commandID)) === null || _this__commandIDMapping_get === void 0 ? void 0 : _this__commandIDMapping_get.delete(shortcut);
903
+ if (((_this__commandIDMapping_get1 = _this._commandIDMapping.get(commandID)) === null || _this__commandIDMapping_get1 === void 0 ? void 0 : _this__commandIDMapping_get1.size) === 0) {
904
+ _this._commandIDMapping.delete(commandID);
905
+ }
906
+ _this._emitShortcutChanged();
907
+ });
908
+ }
909
+ },
910
+ {
911
+ key: "getShortcutDisplayOfCommand",
912
+ value: function getShortcutDisplayOfCommand(id) {
913
+ var set = this._commandIDMapping.get(id);
914
+ if (!set) {
915
+ return null;
916
+ }
917
+ return this.getShortcutDisplay(set.values().next().value);
918
+ }
919
+ },
920
+ {
921
+ key: "getShortcutDisplay",
922
+ value: function getShortcutDisplay(shortcut) {
923
+ var binding = this._getBindingFromItem(shortcut);
924
+ var ctrlKey = binding & 4096 /* CTRL_COMMAND */ ;
925
+ var shiftKey = binding & 1024 /* SHIFT */ ;
926
+ var altKey = binding & 2048 /* ALT */ ;
927
+ var macCtrl = binding & 8192 /* MAC_CTRL */ ;
928
+ var _KeyCodeToChar_;
929
+ var body = (_KeyCodeToChar_ = KeyCodeToChar[binding & 255]) !== null && _KeyCodeToChar_ !== void 0 ? _KeyCodeToChar_ : "<->";
930
+ if (this._platformService.isMac) {
931
+ return "".concat(ctrlKey ? "⌘" : "").concat(shiftKey ? "⇧" : "").concat(altKey ? "⌥" : "").concat(macCtrl ? "⌃" : "").concat(body);
932
+ }
933
+ return "".concat(ctrlKey ? "Ctrl+" : "").concat(shiftKey ? "Shift+" : "").concat(altKey ? "Alt+" : "").concat(body);
934
+ }
935
+ },
936
+ {
937
+ key: "_emitShortcutChanged",
938
+ value: function _emitShortcutChanged() {
939
+ this._shortcutChanged$.next();
940
+ }
941
+ },
942
+ {
943
+ key: "forceEscape",
944
+ value: function forceEscape() {
945
+ var _this = this;
946
+ this._forceEscaped = true;
947
+ return toDisposable3(function() {
948
+ return _this._forceEscaped = false;
949
+ });
950
+ }
951
+ },
952
+ {
953
+ key: "_resolveKeyboardEvent",
954
+ value: function _resolveKeyboardEvent(e) {
955
+ if (this._forceEscaped) {
956
+ return;
957
+ }
958
+ var shouldPreventDefault = this._dispatch(e);
959
+ if (shouldPreventDefault) {
960
+ e.preventDefault();
961
+ }
962
+ }
963
+ },
964
+ {
965
+ key: "_dispatch",
966
+ value: function _dispatch(e) {
967
+ var _this = this;
968
+ var binding = this._deriveBindingFromEvent(e);
969
+ if (binding === null) {
970
+ return false;
971
+ }
972
+ var shortcuts = this._shortCutMapping.get(binding);
973
+ if (shortcuts === void 0) {
974
+ return false;
975
+ }
976
+ var shouldTrigger = Array.from(shortcuts).sort(function(s1, s2) {
977
+ var _s2_priority, _s1_priority;
978
+ return ((_s2_priority = s2.priority) !== null && _s2_priority !== void 0 ? _s2_priority : 0) - ((_s1_priority = s1.priority) !== null && _s1_priority !== void 0 ? _s1_priority : 0);
979
+ }).find(function(s) {
980
+ var _s_preconditions;
981
+ var _s_preconditions1;
982
+ return (_s_preconditions1 = (_s_preconditions = s.preconditions) === null || _s_preconditions === void 0 ? void 0 : _s_preconditions.call(s, _this._contextService)) !== null && _s_preconditions1 !== void 0 ? _s_preconditions1 : true;
983
+ });
984
+ if (shouldTrigger) {
985
+ this._commandService.executeCommand(shouldTrigger.id, shouldTrigger.staticParameters);
986
+ return true;
987
+ }
988
+ return false;
989
+ }
990
+ },
991
+ {
992
+ key: "_getBindingFromItem",
993
+ value: function _getBindingFromItem(item) {
994
+ if (this._platformService.isMac && item.mac) {
995
+ return item.mac;
996
+ }
997
+ if (this._platformService.isWindows && item.win) {
998
+ return item.win;
999
+ }
1000
+ if (this._platformService.isLinux && item.linux) {
1001
+ return item.linux;
1002
+ }
1003
+ return item.binding;
1004
+ }
1005
+ },
1006
+ {
1007
+ key: "_deriveBindingFromEvent",
1008
+ value: function _deriveBindingFromEvent(e) {
1009
+ var shiftKey = e.shiftKey, metaKey = e.metaKey, altKey = e.altKey, keyCode = e.keyCode;
1010
+ var binding = keyCode;
1011
+ if (shiftKey) {
1012
+ binding |= 1024 /* SHIFT */ ;
1013
+ }
1014
+ if (altKey) {
1015
+ binding |= 2048 /* ALT */ ;
1016
+ }
1017
+ var ctrlKey = this._platformService.isMac ? metaKey : e.ctrlKey;
1018
+ if (ctrlKey) {
1019
+ binding |= 4096 /* CTRL_COMMAND */ ;
1020
+ }
1021
+ if (this._platformService.isMac && e.ctrlKey) {
1022
+ binding |= 8192 /* MAC_CTRL */ ;
1023
+ }
1024
+ return binding;
1025
+ }
1026
+ }
1027
+ ]);
1028
+ return DesktopShortcutService;
1029
+ }(Disposable);
1030
+ DesktopShortcutService = __decorateClass([
1031
+ __decorateParam(0, ICommandService),
1032
+ __decorateParam(1, IPlatformService),
1033
+ __decorateParam(2, IContextService)
1034
+ ], DesktopShortcutService);
1035
+ // src/services/menu/menu.service.ts
1036
+ var IMenuService = createIdentifier3("univer.menu-service");
1037
+ var DesktopMenuService = /*#__PURE__*/ function(Disposable2) {
1038
+ "use strict";
1039
+ _inherits(DesktopMenuService, Disposable2);
1040
+ var _super = _create_super(DesktopMenuService);
1041
+ function DesktopMenuService(_shortcutService) {
1042
+ _class_call_check(this, DesktopMenuService);
1043
+ var _this;
1044
+ _this = _super.call(this);
1045
+ _define_property(_assert_this_initialized(_this), "_menuItemMap", /* @__PURE__ */ new Map());
1046
+ _define_property(_assert_this_initialized(_this), "_menuByPositions", /* @__PURE__ */ new Map());
1047
+ _define_property(_assert_this_initialized(_this), "_menuChanged$", new BehaviorSubject(void 0));
1048
+ _define_property(_assert_this_initialized(_this), "menuChanged$", _this._menuChanged$.asObservable());
1049
+ _this._shortcutService = _shortcutService;
1050
+ return _this;
1051
+ }
1052
+ _create_class(DesktopMenuService, [
1053
+ {
1054
+ key: "dispose",
1055
+ value: function dispose() {
1056
+ this._menuItemMap.clear();
1057
+ this._menuChanged$.complete();
1058
+ }
1059
+ },
1060
+ {
1061
+ key: "addMenuItem",
1062
+ value: function addMenuItem(item) {
1063
+ var _this = this;
1064
+ if (this._menuItemMap.has(item.id)) {
1065
+ throw new Error("Menu item with the same id ".concat(item.id, " has already been added!"));
1066
+ }
1067
+ this._menuItemMap.set(item.id, item);
1068
+ if (Array.isArray(item.positions)) {
1069
+ item.positions.forEach(function(menu) {
1070
+ return _this.appendMenuToPosition(item, menu);
1071
+ });
1072
+ } else {
1073
+ this.appendMenuToPosition(item, item.positions);
1074
+ }
1075
+ this._menuChanged$.next();
1076
+ return toDisposable4(function() {
1077
+ _this._menuItemMap.delete(item.id);
1078
+ if (Array.isArray(item.positions)) {
1079
+ item.positions.forEach(function(menu) {
1080
+ var menus = _this._menuByPositions.get(menu);
1081
+ if (!menus) {
1082
+ return;
1083
+ }
1084
+ var index = menus.findIndex(function(m) {
1085
+ return m[0] === item.id;
1086
+ });
1087
+ if (index > -1) {
1088
+ menus.splice(index, 1);
1089
+ }
1090
+ });
1091
+ } else {
1092
+ var menus = _this._menuByPositions.get(item.positions);
1093
+ if (!menus) {
1094
+ return;
1095
+ }
1096
+ var index = menus.findIndex(function(m) {
1097
+ return m[0] === item.id;
1098
+ });
1099
+ if (index > -1) {
1100
+ menus.splice(index, 1);
1101
+ }
1102
+ }
1103
+ _this._menuChanged$.next();
1104
+ });
1105
+ }
1106
+ },
1107
+ {
1108
+ key: "getMenuItems",
1109
+ value: function getMenuItems(positions2) {
1110
+ var _this = this;
1111
+ if (this._menuByPositions.has(positions2)) {
1112
+ var menuItems = this._menuByPositions.get(positions2);
1113
+ if (menuItems) {
1114
+ return _to_consumable_array(menuItems.values()).map(function(menu) {
1115
+ return _this.getDisplayMenuItems(menu[1]);
1116
+ });
1117
+ }
1118
+ }
1119
+ return [];
1120
+ }
1121
+ },
1122
+ {
1123
+ key: "getMenuItem",
1124
+ value: function getMenuItem(id) {
1125
+ if (this._menuItemMap.has(id)) {
1126
+ return this._menuItemMap.get(id);
1127
+ }
1128
+ return null;
1129
+ }
1130
+ },
1131
+ {
1132
+ key: "getDisplayMenuItems",
1133
+ value: function getDisplayMenuItems(menuItem) {
1134
+ var shortcut = this._shortcutService.getShortcutDisplayOfCommand(menuItem.id);
1135
+ if (!shortcut) {
1136
+ return menuItem;
1137
+ }
1138
+ return _object_spread_props(_object_spread({}, menuItem), {
1139
+ shortcut: shortcut
1140
+ });
1141
+ }
1142
+ },
1143
+ {
1144
+ key: "appendMenuToPosition",
1145
+ value: function appendMenuToPosition(menu, position) {
1146
+ if (!this._menuByPositions.has(position)) {
1147
+ this._menuByPositions.set(position, []);
1148
+ }
1149
+ var menuList = this._menuByPositions.get(position);
1150
+ if (menuList.findIndex(function(m) {
1151
+ return m[0] === menu.id;
1152
+ }) > -1) {
1153
+ throw new Error("Menu item with the same id ".concat(menu.id, " has already been added!"));
1154
+ }
1155
+ menuList.push([
1156
+ menu.id,
1157
+ menu
1158
+ ]);
1159
+ }
1160
+ }
1161
+ ]);
1162
+ return DesktopMenuService;
1163
+ }(Disposable2);
1164
+ DesktopMenuService = __decorateClass([
1165
+ __decorateParam(0, IShortcutService)
1166
+ ], DesktopMenuService);
1167
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/ui/src/components/menu/index.module.less
1168
+ var index_module_default = {
1169
+ "menuItemNoHover": "univer-menu-item-no-hover",
1170
+ "menuItemContent": "univer-menu-item-content",
1171
+ "menuItemSelectable": "univer-menu-item-selectable",
1172
+ "menuItemSelectableIcon": "univer-menu-item-selectable-icon",
1173
+ "menuItemMoreIcon": "univer-menu-item-more-icon"
1174
+ };
1175
+ // src/components/menu/Menu.tsx
1176
+ function MenuWrapper(props) {
1177
+ var menuType = props.menuType, onOptionSelect = props.onOptionSelect;
1178
+ var menuService = useDependency2(IMenuService);
1179
+ if (!menuType) return;
1180
+ if (Array.isArray(menuType)) {
1181
+ var menuTypes = menuType.map(function(type) {
1182
+ return menuService.getMenuItems(type);
1183
+ });
1184
+ var group = menuTypes.map(function(menuItems2) {
1185
+ return menuItems2.reduce(function(acc, item) {
1186
+ if (item.group) {
1187
+ var _acc_item_group;
1188
+ acc[item.group] = (_acc_item_group = acc[item.group]) !== null && _acc_item_group !== void 0 ? _acc_item_group : [];
1189
+ acc[item.group].push(item);
1190
+ } else {
1191
+ var _acc_;
1192
+ acc[10 /* CONTEXT_MENU_OTHERS */ ] = (_acc_ = acc[10 /* CONTEXT_MENU_OTHERS */ ]) !== null && _acc_ !== void 0 ? _acc_ : [];
1193
+ acc[10 /* CONTEXT_MENU_OTHERS */ ].push(item);
1194
+ }
1195
+ return acc;
1196
+ }, {});
1197
+ });
1198
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, group.map(function(groupItem) {
1199
+ return Object.keys(groupItem).map(function(groupKey) {
1200
+ return /* @__PURE__ */ React2.createElement(DesignMenuItemGroup, {
1201
+ key: groupKey,
1202
+ eventKey: groupKey
1203
+ }, groupItem[groupKey].map(function(item) {
1204
+ return /* @__PURE__ */ React2.createElement(MenuItem, {
1205
+ key: item.id,
1206
+ menuItem: item,
1207
+ onClick: function(object) {
1208
+ onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(_object_spread({
1209
+ value: "",
1210
+ label: item.id
1211
+ }, object));
1212
+ }
1213
+ });
1214
+ }));
1215
+ });
1216
+ }));
1217
+ }
1218
+ var menuItems = menuService.getMenuItems(menuType);
1219
+ return menuItems.map(function(item) {
1220
+ return /* @__PURE__ */ React2.createElement(MenuItem, {
1221
+ key: item.id,
1222
+ menuItem: item,
1223
+ onClick: function(object) {
1224
+ onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(_object_spread({
1225
+ value: "",
1226
+ label: item.id
1227
+ }, object));
1228
+ }
1229
+ });
1230
+ });
1231
+ }
1232
+ function MenuOptionsWrapper(props) {
1233
+ var options = props.options, value = props.value, onOptionSelect = props.onOptionSelect, parentKey = props.parentKey;
1234
+ var _options_map;
1235
+ return (_options_map = options === null || options === void 0 ? void 0 : options.map(function(option, index) {
1236
+ var _option_label, _option_label1;
1237
+ var _option_label2;
1238
+ var key = "".concat(parentKey, "-").concat((_option_label2 = option.label) !== null && _option_label2 !== void 0 ? _option_label2 : option.id, "-").concat(index);
1239
+ var onChange = function(v) {
1240
+ onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect({
1241
+ value: v,
1242
+ label: option === null || option === void 0 ? void 0 : option.label
1243
+ });
1244
+ };
1245
+ var handleClick = function() {
1246
+ if (typeof option.value === "undefined") return;
1247
+ onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(_object_spread({}, option));
1248
+ };
1249
+ var _className = clsx(_define_property({}, index_module_default.menuItemNoHover, typeof option.label !== "string" && !((_option_label = option.label) === null || _option_label === void 0 ? void 0 : _option_label.hoverable)));
1250
+ return /* @__PURE__ */ React2.createElement(DesignMenuItem, {
1251
+ key: key,
1252
+ eventKey: key,
1253
+ className: _className,
1254
+ onClick: handleClick
1255
+ }, /* @__PURE__ */ React2.createElement("span", {
1256
+ className: clsx(index_module_default.menuItemContent, _define_property({}, index_module_default.menuItemSelectable, !(typeof option.label !== "string" && !((_option_label1 = option.label) === null || _option_label1 === void 0 ? void 0 : _option_label1.hoverable))))
1257
+ }, typeof value !== "undefined" && String(value) === String(option.value) && /* @__PURE__ */ React2.createElement("span", {
1258
+ className: index_module_default.menuItemSelectableIcon
1259
+ }, /* @__PURE__ */ React2.createElement(CheckMarkSingle, {
1260
+ style: {
1261
+ color: "rgb(var(--success-color))"
1262
+ }
1263
+ })), /* @__PURE__ */ React2.createElement(CustomLabel, {
1264
+ value$: option.value$,
1265
+ value: option.value,
1266
+ label: option.label,
1267
+ icon: option.icon,
1268
+ onChange: onChange
1269
+ })));
1270
+ })) !== null && _options_map !== void 0 ? _options_map : /* @__PURE__ */ React2.createElement(React2.Fragment, null);
1271
+ }
1272
+ var Menu = function(props) {
1273
+ return /* @__PURE__ */ React2.createElement(DesignMenu, {
1274
+ selectable: false
1275
+ }, /* @__PURE__ */ React2.createElement(MenuOptionsWrapper, _object_spread({}, props)), /* @__PURE__ */ React2.createElement(MenuWrapper, _object_spread({}, props)));
1276
+ };
1277
+ function MenuItem(param) {
1278
+ var menuItem = param.menuItem, onClick = param.onClick;
1279
+ var menuService = useDependency2(IMenuService);
1280
+ var menuItems = menuItem.id ? menuService.getMenuItems(menuItem.id) : [];
1281
+ var disabled = useObservable(menuItem.disabled$ || of(false), false, true);
1282
+ var hidden = useObservable(menuItem.hidden$ || of(false), false, true);
1283
+ var value = useObservable(menuItem.value$ || of(void 0), void 0, true);
1284
+ var _useState2 = _sliced_to_array(useState2(value), 2), inputValue = _useState2[0], setInputValue = _useState2[1];
1285
+ var onChange = function(v) {
1286
+ var newValue = isRealNum(v) && typeof v === "string" ? parseInt(v) : v;
1287
+ setInputValue(newValue);
1288
+ };
1289
+ var renderButtonType = function() {
1290
+ var item = menuItem;
1291
+ var title = item.title, label = item.label;
1292
+ return /* @__PURE__ */ React2.createElement(DesignMenuItem, {
1293
+ key: item.id,
1294
+ eventKey: item.id,
1295
+ disabled: disabled,
1296
+ onClick: function() {
1297
+ onClick({
1298
+ value: inputValue,
1299
+ id: item.id
1300
+ });
1301
+ }
1302
+ }, /* @__PURE__ */ React2.createElement("span", {
1303
+ className: index_module_default.menuItemContent
1304
+ }, /* @__PURE__ */ React2.createElement(CustomLabel, {
1305
+ value: value,
1306
+ title: title,
1307
+ label: label,
1308
+ icon: item.icon,
1309
+ onChange: onChange
1310
+ })));
1311
+ };
1312
+ var renderSelectorType = function() {
1313
+ var item = menuItem;
1314
+ var selections;
1315
+ if (isObservable2(item.selections)) {
1316
+ selections = useObservable(item.selections || of([]), [], true);
1317
+ } else {
1318
+ selections = item.selections || [];
1319
+ }
1320
+ if (selections.length > 0) {
1321
+ return /* @__PURE__ */ React2.createElement(DesignSubMenu, {
1322
+ key: item.id,
1323
+ eventKey: item.id,
1324
+ popupOffset: [
1325
+ 18,
1326
+ 0
1327
+ ],
1328
+ title: /* @__PURE__ */ React2.createElement("span", {
1329
+ className: index_module_default.menuItemContent
1330
+ }, /* @__PURE__ */ React2.createElement(CustomLabel, {
1331
+ title: item.title,
1332
+ value: inputValue,
1333
+ onChange: onChange,
1334
+ icon: item.icon,
1335
+ label: item.label
1336
+ }), item.shortcut && " (".concat(item.shortcut, ")")),
1337
+ expandIcon: /* @__PURE__ */ React2.createElement(MoreSingle, {
1338
+ className: index_module_default.menuItemMoreIcon
1339
+ })
1340
+ }, selections.length > 0 && /* @__PURE__ */ React2.createElement(MenuOptionsWrapper, {
1341
+ parentKey: item.id,
1342
+ menuType: item.id,
1343
+ options: selections,
1344
+ onOptionSelect: function(v) {
1345
+ onClick({
1346
+ value: v.value,
1347
+ id: item.id
1348
+ });
1349
+ }
1350
+ }));
1351
+ }
1352
+ return /* @__PURE__ */ React2.createElement(DesignMenuItem, {
1353
+ key: item.id,
1354
+ eventKey: item.id
1355
+ }, /* @__PURE__ */ React2.createElement("span", {
1356
+ className: index_module_default.menuItemContent
1357
+ }, /* @__PURE__ */ React2.createElement(CustomLabel, {
1358
+ title: item.title,
1359
+ value: inputValue,
1360
+ icon: item.icon,
1361
+ label: item.label,
1362
+ onChange: onChange
1363
+ }), item.shortcut && " (".concat(item.shortcut, ")")));
1364
+ };
1365
+ var renderSubItemsType = function() {
1366
+ var item = menuItem;
1367
+ return /* @__PURE__ */ React2.createElement(DesignSubMenu, {
1368
+ key: item.id,
1369
+ eventKey: item.id,
1370
+ popupOffset: [
1371
+ 18,
1372
+ 0
1373
+ ],
1374
+ title: /* @__PURE__ */ React2.createElement("span", {
1375
+ className: index_module_default.menuItemContent
1376
+ }, /* @__PURE__ */ React2.createElement(CustomLabel, {
1377
+ title: item.title,
1378
+ icon: item.icon,
1379
+ label: item.label,
1380
+ onChange: onChange
1381
+ })),
1382
+ expandIcon: /* @__PURE__ */ React2.createElement(MoreSingle, {
1383
+ className: index_module_default.menuItemMoreIcon
1384
+ })
1385
+ }, menuItems.length && /* @__PURE__ */ React2.createElement(MenuWrapper, {
1386
+ menuType: item.id,
1387
+ parentKey: item.id,
1388
+ onOptionSelect: onClick
1389
+ }));
1390
+ };
1391
+ if (hidden) {
1392
+ return null;
1393
+ }
1394
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, menuItem.type === 1 /* SELECTOR */ && renderSelectorType(), menuItem.type === 3 /* SUBITEMS */ && renderSubItemsType(), menuItem.type === 0 /* BUTTON */ && renderButtonType());
1395
+ }
1396
+ // src/controllers/shared-shortcut.controller.ts
1397
+ import { Disposable as Disposable3, ICommandService as ICommandService2, LifecycleStages, OnLifecycle, RedoCommand as RedoCommand2, UndoCommand as UndoCommand2 } from "@univerjs/core";
1398
+ import { Inject, Injector } from "@wendellhu/redi";
1399
+ // src/services/clipboard/clipboard.command.ts
1400
+ import { CommandType } from "@univerjs/core";
1401
+ var CopyCommandName = "univer.command.copy";
1402
+ var CopyCommand = {
1403
+ id: CopyCommandName,
1404
+ name: CopyCommandName,
1405
+ multi: true,
1406
+ priority: 0,
1407
+ type: CommandType.COMMAND,
1408
+ preconditions: function() {
1409
+ return false;
1410
+ },
1411
+ handler: /*#__PURE__*/ _async_to_generator(function() {
1412
+ return _ts_generator(this, function(_state) {
1413
+ return [
1414
+ 2,
1415
+ true
1416
+ ];
1417
+ });
1418
+ })
1419
+ };
1420
+ var CutCommandName = "univer.command.cut";
1421
+ var CutCommand = {
1422
+ id: CutCommandName,
1423
+ name: CutCommandName,
1424
+ multi: true,
1425
+ priority: 0,
1426
+ type: CommandType.COMMAND,
1427
+ preconditions: function() {
1428
+ return false;
1429
+ },
1430
+ handler: /*#__PURE__*/ _async_to_generator(function() {
1431
+ return _ts_generator(this, function(_state) {
1432
+ return [
1433
+ 2,
1434
+ true
1435
+ ];
1436
+ });
1437
+ })
1438
+ };
1439
+ var PasteCommandName = "univer.command.paste";
1440
+ var PasteCommand = {
1441
+ id: PasteCommandName,
1442
+ name: PasteCommandName,
1443
+ multi: true,
1444
+ priority: 0,
1445
+ type: CommandType.COMMAND,
1446
+ preconditions: function() {
1447
+ return false;
1448
+ },
1449
+ handler: /*#__PURE__*/ _async_to_generator(function() {
1450
+ return _ts_generator(this, function(_state) {
1451
+ return [
1452
+ 2,
1453
+ true
1454
+ ];
1455
+ });
1456
+ })
1457
+ };
1458
+ // src/controllers/menus/menus.ts
1459
+ import { IUndoRedoService, RedoCommand, UndoCommand } from "@univerjs/core";
1460
+ import { map } from "rxjs/operators";
1461
+ function UndoMenuItemFactory(accessor) {
1462
+ var undoRedoService = accessor.get(IUndoRedoService);
1463
+ return {
1464
+ id: UndoCommand.id,
1465
+ group: 0 /* TOOLBAR_HISTORY */ ,
1466
+ type: 0 /* BUTTON */ ,
1467
+ icon: "UndoSingle",
1468
+ title: "Undo",
1469
+ tooltip: "toolbar.undo",
1470
+ positions: [
1471
+ "uiToolbar.start" /* TOOLBAR_START */
1472
+ ],
1473
+ disabled$: undoRedoService.undoRedoStatus$.pipe(map(function(v) {
1474
+ return v.undos <= 0;
1475
+ }))
1476
+ };
1477
+ }
1478
+ function RedoMenuItemFactory(accessor) {
1479
+ var undoRedoService = accessor.get(IUndoRedoService);
1480
+ return {
1481
+ id: RedoCommand.id,
1482
+ group: 0 /* TOOLBAR_HISTORY */ ,
1483
+ type: 0 /* BUTTON */ ,
1484
+ icon: "RedoSingle",
1485
+ title: "Redo",
1486
+ tooltip: "toolbar.redo",
1487
+ positions: [
1488
+ "uiToolbar.start" /* TOOLBAR_START */
1489
+ ],
1490
+ disabled$: undoRedoService.undoRedoStatus$.pipe(map(function(v) {
1491
+ return v.redos <= 0;
1492
+ }))
1493
+ };
1494
+ }
1495
+ // src/controllers/shared-shortcut.controller.ts
1496
+ var CopyShortcutItem = {
1497
+ id: CopyCommand.id,
1498
+ description: "shortcut.copy",
1499
+ group: "1_common-edit",
1500
+ binding: 67 /* C */ | 4096 /* CTRL_COMMAND */
1501
+ };
1502
+ var CutShortcutItem = {
1503
+ id: CutCommand.id,
1504
+ description: "shortcut.cut",
1505
+ group: "1_common-edit",
1506
+ binding: 88 /* X */ | 4096 /* CTRL_COMMAND */
1507
+ };
1508
+ var PasteShortcutItem = {
1509
+ id: PasteCommand.id,
1510
+ description: "shortcut.paste",
1511
+ group: "1_common-edit",
1512
+ binding: 86 /* V */ | 4096 /* CTRL_COMMAND */
1513
+ };
1514
+ var UndoShortcutItem = {
1515
+ id: UndoCommand2.id,
1516
+ description: "shortcut.undo",
1517
+ group: "1_common-edit",
1518
+ binding: 90 /* Z */ | 4096 /* CTRL_COMMAND */
1519
+ };
1520
+ var RedoShortcutItem = {
1521
+ id: RedoCommand2.id,
1522
+ description: "shortcut.redo",
1523
+ group: "1_common-edit",
1524
+ binding: 89 /* Y */ | 4096 /* CTRL_COMMAND */
1525
+ };
1526
+ var SharedController = /*#__PURE__*/ function(Disposable3) {
1527
+ "use strict";
1528
+ _inherits(SharedController, Disposable3);
1529
+ var _super = _create_super(SharedController);
1530
+ function SharedController(_injector, _menuService, _shortcutService, _commandService) {
1531
+ _class_call_check(this, SharedController);
1532
+ var _this;
1533
+ _this = _super.call(this);
1534
+ _this._injector = _injector;
1535
+ _this._menuService = _menuService;
1536
+ _this._shortcutService = _shortcutService;
1537
+ _this._commandService = _commandService;
1538
+ _this.initialize();
1539
+ return _this;
1540
+ }
1541
+ _create_class(SharedController, [
1542
+ {
1543
+ key: "initialize",
1544
+ value: function initialize() {
1545
+ this._registerCommands();
1546
+ this._registerShortcuts();
1547
+ this._registerMenus();
1548
+ }
1549
+ },
1550
+ {
1551
+ key: "_registerMenus",
1552
+ value: function _registerMenus() {
1553
+ var _this = this;
1554
+ [
1555
+ UndoMenuItemFactory,
1556
+ RedoMenuItemFactory
1557
+ ].forEach(function(factory) {
1558
+ _this.disposeWithMe(_this._menuService.addMenuItem(_this._injector.invoke(factory)));
1559
+ });
1560
+ }
1561
+ },
1562
+ {
1563
+ key: "_registerCommands",
1564
+ value: function _registerCommands() {
1565
+ var _this = this;
1566
+ [
1567
+ CutCommand,
1568
+ CopyCommand,
1569
+ PasteCommand
1570
+ ].forEach(function(command) {
1571
+ return _this.disposeWithMe(_this._commandService.registerAsMultipleCommand(command));
1572
+ });
1573
+ }
1574
+ },
1575
+ {
1576
+ key: "_registerShortcuts",
1577
+ value: function _registerShortcuts() {
1578
+ var _this = this;
1579
+ [
1580
+ UndoShortcutItem,
1581
+ RedoShortcutItem,
1582
+ CutShortcutItem,
1583
+ CopyShortcutItem,
1584
+ PasteShortcutItem
1585
+ ].forEach(function(shortcut) {
1586
+ return _this.disposeWithMe(_this._shortcutService.registerShortcut(shortcut));
1587
+ });
1588
+ }
1589
+ }
1590
+ ]);
1591
+ return SharedController;
1592
+ }(Disposable3);
1593
+ SharedController = __decorateClass([
1594
+ OnLifecycle(LifecycleStages.Ready, SharedController),
1595
+ __decorateParam(0, Inject(Injector)),
1596
+ __decorateParam(1, IMenuService),
1597
+ __decorateParam(2, IShortcutService),
1598
+ __decorateParam(3, ICommandService2)
1599
+ ], SharedController);
1600
+ // src/controllers/ui/ui.controller.ts
1601
+ import { createIdentifier as createIdentifier4 } from "@wendellhu/redi";
1602
+ var IUIController = createIdentifier4("univer.ui-controller");
1603
+ // src/controllers/ui/ui-desktop.controller.tsx
1604
+ import { Disposable as Disposable6, LifecycleService, LifecycleStages as LifecycleStages3, toDisposable as toDisposable7 } from "@univerjs/core";
1605
+ import { IRenderManagerService } from "@univerjs/engine-render";
1606
+ import { Inject as Inject2, Injector as Injector2 } from "@wendellhu/redi";
1607
+ import { connectInjector } from "@wendellhu/redi/react-bindings";
1608
+ import { render as createRoot, unmount } from "rc-util/lib/React/render";
1609
+ import React14 from "react";
1610
+ import { Subject as Subject3 } from "rxjs";
1611
+ // src/services/focus/focus.service.ts
1612
+ import { Disposable as Disposable4, IContextService as IContextService2, LifecycleStages as LifecycleStages2, OnLifecycle as OnLifecycle2, toDisposable as toDisposable5 } from "@univerjs/core";
1613
+ import { createIdentifier as createIdentifier5 } from "@wendellhu/redi";
1614
+ import { fromEvent } from "rxjs";
1615
+ var IFocusService = createIdentifier5("univer.focus-service");
1616
+ var FOCUSING_UNIVER = "FOCUSING_UNIVER";
1617
+ var DesktopFocusService = /*#__PURE__*/ function(Disposable4) {
1618
+ "use strict";
1619
+ _inherits(DesktopFocusService, Disposable4);
1620
+ var _super = _create_super(DesktopFocusService);
1621
+ function DesktopFocusService(_contextService) {
1622
+ _class_call_check(this, DesktopFocusService);
1623
+ var _this;
1624
+ _this = _super.call(this);
1625
+ _define_property(_assert_this_initialized(_this), "_containerElement", null);
1626
+ _define_property(_assert_this_initialized(_this), "_isUniverFocused", true);
1627
+ _this._contextService = _contextService;
1628
+ _this._initFocusListener();
1629
+ return _this;
1630
+ }
1631
+ _create_class(DesktopFocusService, [
1632
+ {
1633
+ key: "isFocused",
1634
+ get: function get() {
1635
+ return this._isUniverFocused;
1636
+ }
1637
+ },
1638
+ {
1639
+ key: "dispose",
1640
+ value: function dispose() {
1641
+ _get(_get_prototype_of(DesktopFocusService.prototype), "dispose", this).call(this);
1642
+ this._containerElement = null;
1643
+ }
1644
+ },
1645
+ {
1646
+ key: "setContainerElement",
1647
+ value: function setContainerElement(container) {
1648
+ this._containerElement = container;
1649
+ }
1650
+ },
1651
+ {
1652
+ key: "_initFocusListener",
1653
+ value: function _initFocusListener() {
1654
+ var _this = this;
1655
+ this.disposeWithMe(toDisposable5(fromEvent(window, "focusin").subscribe(function(event) {
1656
+ var _this__containerElement;
1657
+ if (event.target && ((_this__containerElement = _this._containerElement) === null || _this__containerElement === void 0 ? void 0 : _this__containerElement.contains(event.target))) {
1658
+ _this._isUniverFocused = true;
1659
+ } else {
1660
+ _this._isUniverFocused = false;
1661
+ }
1662
+ _this._contextService.setContextValue(FOCUSING_UNIVER, _this._isUniverFocused);
1663
+ })));
1664
+ }
1665
+ }
1666
+ ]);
1667
+ return DesktopFocusService;
1668
+ }(Disposable4);
1669
+ DesktopFocusService = __decorateClass([
1670
+ OnLifecycle2(LifecycleStages2.Ready, IFocusService),
1671
+ __decorateParam(0, IContextService2)
1672
+ ], DesktopFocusService);
1673
+ // src/views/App.tsx
1674
+ import { LocaleService as LocaleService4, ThemeService } from "@univerjs/core";
1675
+ import { ConfigProvider, defaultTheme, themeInstance } from "@univerjs/design";
1676
+ import { useDependency as useDependency10 } from "@wendellhu/redi/react-bindings";
1677
+ import React13, { useEffect as useEffect9, useMemo as useMemo2, useRef as useRef3, useState as useState10 } from "react";
1678
+ // src/services/message/message.service.ts
1679
+ import { createIdentifier as createIdentifier6 } from "@wendellhu/redi";
1680
+ var IMessageService = createIdentifier6("univer.message-service");
1681
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/ui/src/views/app.module.less
1682
+ var app_module_default = {
1683
+ "appLayout": "univer-app-layout",
1684
+ "appContainer": "univer-app-container",
1685
+ "appContainerHeader": "univer-app-container-header",
1686
+ "appContainerWrapper": "univer-app-container-wrapper",
1687
+ "appContainerContent": "univer-app-container-content",
1688
+ "appContainerCanvas": "univer-app-container-canvas",
1689
+ "appContainerSidebar": "univer-app-container-sidebar"
1690
+ };
1691
+ // src/views/components/ComponentContainer.tsx
1692
+ import React3 from "react";
1693
+ function ComponentContainer(props) {
1694
+ var components = props.components;
1695
+ if (!components) return null;
1696
+ return Array.from(components.values()).map(function(component, index) {
1697
+ return React3.createElement(component(), {
1698
+ key: "".concat(index)
1699
+ });
1700
+ });
1701
+ }
1702
+ // src/views/components/doc-bars/MenuBar.tsx
1703
+ import { LocaleService as LocaleService2 } from "@univerjs/core";
1704
+ import { useDependency as useDependency3 } from "@wendellhu/redi/react-bindings";
1705
+ import clsx2 from "clsx";
1706
+ import React4, { useEffect, useState as useState3 } from "react";
1707
+ // src/views/components/doc-bars/hooks/menu.ts
1708
+ import { BehaviorSubject as BehaviorSubject2 } from "rxjs";
1709
+ var positions = [
1710
+ "uiToolbar.start" /* TOOLBAR_START */ ,
1711
+ "uiToolbar.insert" /* TOOLBAR_INSERT */ ,
1712
+ "uiToolbar.formulas" /* TOOLBAR_FORMULAS */ ,
1713
+ "uiToolbar.data" /* TOOLBAR_DATA */ ,
1714
+ "uiToolbar.view" /* TOOLBAR_VIEW */ ,
1715
+ "uiToolbar.others" /* TOOLBAR_OTHERS */
1716
+ ];
1717
+ var positionSubject = new BehaviorSubject2("uiToolbar.start" /* TOOLBAR_START */ );
1718
+ var position$ = positionSubject.asObservable();
1719
+ function setPosition(position) {
1720
+ positionSubject.next(position);
1721
+ }
1722
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/ui/src/views/components/doc-bars/index.module.less
1723
+ var index_module_default2 = {
1724
+ "headerbar": "univer-headerbar",
1725
+ "headerMenu": "univer-header-menu",
1726
+ "menubar": "univer-menubar",
1727
+ "menubarItem": "univer-menubar-item",
1728
+ "menubarItemActive": "univer-menubar-item-active",
1729
+ "toolbar": "univer-toolbar",
1730
+ "toolbarContainer": "univer-toolbar-container",
1731
+ "toolbarGroup": "univer-toolbar-group",
1732
+ "toolbarItemSelectButton": "univer-toolbar-item-select-button",
1733
+ "toolbarItemSelectButtonLabel": "univer-toolbar-item-select-button-label",
1734
+ "toolbarItemSelectButtonArrow": "univer-toolbar-item-select-button-arrow",
1735
+ "toolbarItemSelect": "univer-toolbar-item-select",
1736
+ "toolbarItemSelectArrow": "univer-toolbar-item-select-arrow"
1737
+ };
1738
+ // src/views/components/doc-bars/MenuBar.tsx
1739
+ function MenuBar(props) {
1740
+ var headerMenuComponents = props.headerMenuComponents;
1741
+ var localeService = useDependency3(LocaleService2);
1742
+ var menuService = useDependency3(IMenuService);
1743
+ var _useState3 = _sliced_to_array(useState3([]), 2), group = _useState3[0], setGroup = _useState3[1];
1744
+ useEffect(function() {
1745
+ var listener = menuService.menuChanged$.subscribe(function() {
1746
+ var group2 = [];
1747
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1748
+ try {
1749
+ for(var _iterator = positions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1750
+ var position2 = _step.value;
1751
+ var menuItems = menuService.getMenuItems(position2);
1752
+ if (menuItems.length) {
1753
+ group2.push({
1754
+ name: position2,
1755
+ menuItems: menuItems
1756
+ });
1757
+ }
1758
+ }
1759
+ } catch (err) {
1760
+ _didIteratorError = true;
1761
+ _iteratorError = err;
1762
+ } finally{
1763
+ try {
1764
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1765
+ _iterator.return();
1766
+ }
1767
+ } finally{
1768
+ if (_didIteratorError) {
1769
+ throw _iteratorError;
1770
+ }
1771
+ }
1772
+ }
1773
+ setGroup(group2);
1774
+ });
1775
+ return function() {
1776
+ listener.unsubscribe();
1777
+ };
1778
+ }, []);
1779
+ var position = useObservable(position$, "uiToolbar.start" /* TOOLBAR_START */ , true);
1780
+ return /* @__PURE__ */ React4.createElement("header", {
1781
+ className: index_module_default2.headerbar
1782
+ }, /* @__PURE__ */ React4.createElement("div", {
1783
+ className: index_module_default2.menubar
1784
+ }, group.length > 1 && group.map(function(item, index) {
1785
+ return /* @__PURE__ */ React4.createElement("a", {
1786
+ key: index,
1787
+ className: clsx2(index_module_default2.menubarItem, _define_property({}, index_module_default2.menubarItemActive, item.name === position)),
1788
+ onClick: function() {
1789
+ return setPosition(item.name);
1790
+ }
1791
+ }, localeService.t(item.name));
1792
+ })), /* @__PURE__ */ React4.createElement("div", {
1793
+ className: index_module_default2.headerMenu
1794
+ }, /* @__PURE__ */ React4.createElement(ComponentContainer, {
1795
+ components: headerMenuComponents
1796
+ })));
1797
+ }
1798
+ // src/views/components/doc-bars/Toolbar.tsx
1799
+ import { useDependency as useDependency5 } from "@wendellhu/redi/react-bindings";
1800
+ import React7, { useEffect as useEffect3, useState as useState5 } from "react";
1801
+ // src/views/components/doc-bars/ToolbarItem.tsx
1802
+ import { ICommandService as ICommandService3, LocaleService as LocaleService3 } from "@univerjs/core";
1803
+ import { Dropdown, Tooltip } from "@univerjs/design";
1804
+ import { MoreDownSingle } from "@univerjs/icons";
1805
+ import { useDependency as useDependency4 } from "@wendellhu/redi/react-bindings";
1806
+ import React6, { useEffect as useEffect2, useState as useState4 } from "react";
1807
+ import { isObservable as isObservable3 } from "rxjs";
1808
+ // src/views/components/doc-bars/Button/ToolbarButton.tsx
1809
+ import clsx3 from "clsx";
1810
+ import React5 from "react";
1811
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/ui/src/views/components/doc-bars/Button/index.module.less
1812
+ var index_module_default3 = {
1813
+ "toolbarBtn": "univer-toolbar-btn",
1814
+ "toolbarBtnActive": "univer-toolbar-btn-active"
1815
+ };
1816
+ // src/views/components/doc-bars/Button/ToolbarButton.tsx
1817
+ function ToolbarButton(props) {
1818
+ var children = props.children, className = props.className, style = props.style, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, _props_active = props.active, active = _props_active === void 0 ? false : _props_active, onClick = props.onClick, onDoubleClick = props.onDoubleClick, restProps = _object_without_properties(props, [
1819
+ "children",
1820
+ "className",
1821
+ "style",
1822
+ "disabled",
1823
+ "active",
1824
+ "onClick",
1825
+ "onDoubleClick"
1826
+ ]);
1827
+ var handleClick = function(e) {
1828
+ if (disabled) {
1829
+ e.preventDefault();
1830
+ return;
1831
+ }
1832
+ onClick && onClick(e);
1833
+ };
1834
+ var handleDoubleClick = function(e) {
1835
+ if (disabled) {
1836
+ e.preventDefault();
1837
+ return;
1838
+ }
1839
+ onDoubleClick && onDoubleClick(e);
1840
+ };
1841
+ var _className = clsx3(index_module_default3.toolbarBtn, _define_property({}, "".concat(index_module_default3.toolbarBtn, "-active"), active), className);
1842
+ return /* @__PURE__ */ React5.createElement("button", _object_spread({
1843
+ className: _className,
1844
+ style: style,
1845
+ disabled: disabled,
1846
+ onClick: handleClick,
1847
+ onDoubleClick: handleDoubleClick
1848
+ }, restProps), children);
1849
+ }
1850
+ // src/views/components/doc-bars/ToolbarItem.tsx
1851
+ function ToolbarItem(props) {
1852
+ var localeService = useDependency4(LocaleService3);
1853
+ var commandService = useDependency4(ICommandService3);
1854
+ var _useState4 = _sliced_to_array(useState4(), 2), value = _useState4[0], setValue = _useState4[1];
1855
+ var _useState41 = _sliced_to_array(useState4(false), 2), disabled = _useState41[0], setDisabled = _useState41[1];
1856
+ var _useState42 = _sliced_to_array(useState4(false), 2), activated = _useState42[0], setActivated = _useState42[1];
1857
+ useEffect2(function() {
1858
+ var subscriptions = [];
1859
+ props.disabled$ && subscriptions.push(props.disabled$.subscribe(function(disabled2) {
1860
+ setDisabled(disabled2);
1861
+ }));
1862
+ if (props.type === 0 /* BUTTON */ ) {
1863
+ props.activated$ && subscriptions.push(props.activated$.subscribe(function(activated2) {
1864
+ setActivated(activated2);
1865
+ }));
1866
+ }
1867
+ props.value$ && subscriptions.push(props.value$.subscribe(function(value2) {
1868
+ setValue(value2);
1869
+ }));
1870
+ return function() {
1871
+ subscriptions.forEach(function(subscription) {
1872
+ subscription.unsubscribe();
1873
+ });
1874
+ };
1875
+ }, []);
1876
+ var tooltip = props.tooltip, shortcut = props.shortcut, icon = props.icon, title = props.title, label = props.label, id = props.id;
1877
+ var tooltipTitle = localeService.t(tooltip !== null && tooltip !== void 0 ? tooltip : "") + (shortcut ? " (".concat(shortcut, ")") : "");
1878
+ function renderSelectorType(menuType) {
1879
+ var selections = props.selections;
1880
+ var options = selections;
1881
+ var iconToDisplay = icon;
1882
+ if (isObservable3(icon)) {
1883
+ iconToDisplay = useObservable(icon, void 0, true);
1884
+ } else {
1885
+ var _options_find;
1886
+ var _options_find_icon;
1887
+ iconToDisplay = (_options_find_icon = options === null || options === void 0 ? void 0 : (_options_find = options.find(function(o) {
1888
+ return o.value === value;
1889
+ })) === null || _options_find === void 0 ? void 0 : _options_find.icon) !== null && _options_find_icon !== void 0 ? _options_find_icon : icon;
1890
+ }
1891
+ function handleSelect(option) {
1892
+ var commandId = id;
1893
+ var value2 = option;
1894
+ if (option.id) {
1895
+ commandId = option.id;
1896
+ }
1897
+ commandService.executeCommand(commandId, value2);
1898
+ }
1899
+ function handleChange(value2) {
1900
+ var commandId = id;
1901
+ commandService.executeCommand(commandId, {
1902
+ value: value2
1903
+ });
1904
+ }
1905
+ function handleClick() {
1906
+ if (menuType === 2 /* BUTTON_SELECTOR */ ) {
1907
+ var commandId = id;
1908
+ commandService.executeCommand(commandId, {
1909
+ value: value
1910
+ });
1911
+ }
1912
+ }
1913
+ return menuType === 2 /* BUTTON_SELECTOR */ ? /* @__PURE__ */ React6.createElement("div", {
1914
+ className: index_module_default2.toolbarItemSelectButton
1915
+ }, /* @__PURE__ */ React6.createElement("div", {
1916
+ className: index_module_default2.toolbarItemSelectButtonLabel,
1917
+ onClick: handleClick
1918
+ }, /* @__PURE__ */ React6.createElement(CustomLabel, {
1919
+ icon: iconToDisplay,
1920
+ title: title,
1921
+ value: value,
1922
+ label: label,
1923
+ onChange: handleChange
1924
+ })), /* @__PURE__ */ React6.createElement(Dropdown, {
1925
+ overlay: /* @__PURE__ */ React6.createElement(Menu, {
1926
+ menuType: id,
1927
+ options: options,
1928
+ onOptionSelect: handleSelect,
1929
+ value: value
1930
+ })
1931
+ }, /* @__PURE__ */ React6.createElement("div", {
1932
+ className: index_module_default2.toolbarItemSelectButtonArrow
1933
+ }, /* @__PURE__ */ React6.createElement(MoreDownSingle, null)))) : /* @__PURE__ */ React6.createElement(Dropdown, {
1934
+ overlay: /* @__PURE__ */ React6.createElement(Menu, {
1935
+ menuType: id,
1936
+ options: options,
1937
+ onOptionSelect: handleSelect,
1938
+ value: value
1939
+ })
1940
+ }, /* @__PURE__ */ React6.createElement("div", {
1941
+ className: index_module_default2.toolbarItemSelect
1942
+ }, /* @__PURE__ */ React6.createElement(CustomLabel, {
1943
+ icon: iconToDisplay,
1944
+ title: title,
1945
+ value: value,
1946
+ label: label,
1947
+ onChange: handleChange
1948
+ }), /* @__PURE__ */ React6.createElement("div", {
1949
+ className: index_module_default2.toolbarItemSelectArrow
1950
+ }, /* @__PURE__ */ React6.createElement(MoreDownSingle, null))));
1951
+ }
1952
+ function renderButtonType() {
1953
+ var componentManager = useDependency4(ComponentManager);
1954
+ var _label_name;
1955
+ var isCustomComponent = componentManager.get(typeof label === "string" ? label : (_label_name = label === null || label === void 0 ? void 0 : label.name) !== null && _label_name !== void 0 ? _label_name : "");
1956
+ return /* @__PURE__ */ React6.createElement(ToolbarButton, {
1957
+ className: index_module_default2.toolbarItemTextButton,
1958
+ active: activated,
1959
+ disabled: disabled,
1960
+ onClick: function() {
1961
+ return commandService.executeCommand(props.id);
1962
+ },
1963
+ onDoubleClick: function() {
1964
+ return props.subId && commandService.executeCommand(props.subId);
1965
+ }
1966
+ }, isCustomComponent ? /* @__PURE__ */ React6.createElement(CustomLabel, {
1967
+ title: title,
1968
+ value: value,
1969
+ label: label
1970
+ }) : /* @__PURE__ */ React6.createElement(CustomLabel, {
1971
+ icon: icon
1972
+ }));
1973
+ }
1974
+ function renderItem() {
1975
+ switch(props.type){
1976
+ case 2 /* BUTTON_SELECTOR */ :
1977
+ case 1 /* SELECTOR */ :
1978
+ case 3 /* SUBITEMS */ :
1979
+ return renderSelectorType(props.type);
1980
+ case 0 /* BUTTON */ :
1981
+ default:
1982
+ return renderButtonType();
1983
+ }
1984
+ }
1985
+ return /* @__PURE__ */ React6.createElement(Tooltip, {
1986
+ title: tooltipTitle,
1987
+ placement: "bottom"
1988
+ }, renderItem());
1989
+ }
1990
+ // src/views/components/doc-bars/Toolbar.tsx
1991
+ function Toolbar() {
1992
+ var menuService = useDependency5(IMenuService);
1993
+ var _useState5 = _sliced_to_array(useState5([]), 2), group = _useState5[0], setGroup = _useState5[1];
1994
+ var position = useObservable(position$, "uiToolbar.start" /* TOOLBAR_START */ , true);
1995
+ useEffect3(function() {
1996
+ var listener = menuService.menuChanged$.subscribe(function() {
1997
+ var group2 = [];
1998
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1999
+ try {
2000
+ for(var _iterator = positions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2001
+ var position2 = _step.value;
2002
+ var menuItems = menuService.getMenuItems(position2);
2003
+ if (menuItems.length) {
2004
+ group2.push({
2005
+ name: position2,
2006
+ menuItems: menuItems
2007
+ });
2008
+ }
2009
+ }
2010
+ } catch (err) {
2011
+ _didIteratorError = true;
2012
+ _iteratorError = err;
2013
+ } finally{
2014
+ try {
2015
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2016
+ _iterator.return();
2017
+ }
2018
+ } finally{
2019
+ if (_didIteratorError) {
2020
+ throw _iteratorError;
2021
+ }
2022
+ }
2023
+ }
2024
+ setGroup(group2);
2025
+ });
2026
+ return function() {
2027
+ listener.unsubscribe();
2028
+ };
2029
+ }, []);
2030
+ var activeMenuGroup = group.find(function(g) {
2031
+ return g.name === position;
2032
+ });
2033
+ var _activeMenuGroup_menuItems_reduce;
2034
+ var toolbarGroups = (_activeMenuGroup_menuItems_reduce = activeMenuGroup === null || activeMenuGroup === void 0 ? void 0 : activeMenuGroup.menuItems.reduce(function(acc, item) {
2035
+ var _item_group;
2036
+ var key = (_item_group = item.group) !== null && _item_group !== void 0 ? _item_group : 6 /* TOOLBAR_OTHERS */ ;
2037
+ if (!acc[key]) {
2038
+ acc[key] = [];
2039
+ }
2040
+ acc[key].push(item);
2041
+ return acc;
2042
+ }, {})) !== null && _activeMenuGroup_menuItems_reduce !== void 0 ? _activeMenuGroup_menuItems_reduce : {};
2043
+ return /* @__PURE__ */ React7.createElement("div", {
2044
+ className: index_module_default2.toolbar
2045
+ }, /* @__PURE__ */ React7.createElement("div", {
2046
+ className: index_module_default2.toolbarContainer
2047
+ }, Object.entries(toolbarGroups).map(function(param) {
2048
+ var _param = _sliced_to_array(param, 2), key = _param[0], item = _param[1];
2049
+ return /* @__PURE__ */ React7.createElement("div", {
2050
+ key: key,
2051
+ className: index_module_default2.toolbarGroup
2052
+ }, item.map(function(subItem) {
2053
+ return /* @__PURE__ */ React7.createElement(ToolbarItem, _object_spread({
2054
+ key: subItem.id
2055
+ }, subItem));
2056
+ }));
2057
+ })));
2058
+ }
2059
+ // src/views/components/sidebar/Sidebar.tsx
2060
+ import { CloseSingle } from "@univerjs/icons";
2061
+ import { useDependency as useDependency6 } from "@wendellhu/redi/react-bindings";
2062
+ import clsx4 from "clsx";
2063
+ import React8, { useEffect as useEffect4, useMemo, useState as useState6 } from "react";
2064
+ // src/services/sidebar/sidebar.service.ts
2065
+ import { createIdentifier as createIdentifier7 } from "@wendellhu/redi";
2066
+ var ISidebarService = createIdentifier7("univer.sidebar-service");
2067
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/ui/src/views/components/sidebar/index.module.less
2068
+ var index_module_default4 = {
2069
+ "sidebar": "univer-sidebar",
2070
+ "sidebarOpen": "univer-sidebar-open",
2071
+ "sidebarContainer": "univer-sidebar-container",
2072
+ "sidebarHeader": "univer-sidebar-header",
2073
+ "sidebarHeaderClose": "univer-sidebar-header-close",
2074
+ "sidebarBody": "univer-sidebar-body",
2075
+ "sidebarFooter": "univer-sidebar-footer"
2076
+ };
2077
+ // src/views/components/sidebar/Sidebar.tsx
2078
+ function Sidebar() {
2079
+ var sidebarService = useDependency6(ISidebarService);
2080
+ var _useState6 = _sliced_to_array(useState6({}), 2), sidebarOptions = _useState6[0], setSidebarOptions = _useState6[1];
2081
+ useEffect4(function() {
2082
+ var sidebar$ = sidebarService.getObservableSidebar();
2083
+ var subscribtion = sidebar$.subscribe(function(options2) {
2084
+ setSidebarOptions(options2);
2085
+ });
2086
+ return function() {
2087
+ subscribtion.unsubscribe();
2088
+ };
2089
+ }, []);
2090
+ var options = sidebarOptions;
2091
+ for(var _i = 0, _iter = [
2092
+ "children",
2093
+ "header",
2094
+ "footer"
2095
+ ]; _i < _iter.length; _i++){
2096
+ var key = _iter[_i];
2097
+ var k = key;
2098
+ if (sidebarOptions[k]) {
2099
+ var props = sidebarOptions[k];
2100
+ if (props) {
2101
+ options[k] = /* @__PURE__ */ React8.createElement(CustomLabel, _object_spread({}, props));
2102
+ }
2103
+ }
2104
+ }
2105
+ var _className = clsx4(index_module_default4.sidebar, _define_property({}, index_module_default4.sidebarOpen, options.visible));
2106
+ var width = useMemo(function() {
2107
+ if (!options.visible) return 0;
2108
+ if (typeof options.width === "number") {
2109
+ return "".concat(options.width, "px");
2110
+ }
2111
+ return options.width;
2112
+ }, [
2113
+ options
2114
+ ]);
2115
+ function handleClose() {
2116
+ var _options2_onClose;
2117
+ var options2 = _object_spread_props(_object_spread({}, sidebarOptions), {
2118
+ visible: false
2119
+ });
2120
+ setSidebarOptions(options2);
2121
+ var sidebar$ = sidebarService.getObservableSidebar();
2122
+ sidebar$.next(options2);
2123
+ options2 === null || options2 === void 0 ? void 0 : (_options2_onClose = options2.onClose) === null || _options2_onClose === void 0 ? void 0 : _options2_onClose.call(options2);
2124
+ }
2125
+ return /* @__PURE__ */ React8.createElement("section", {
2126
+ className: _className,
2127
+ style: {
2128
+ width: width
2129
+ }
2130
+ }, /* @__PURE__ */ React8.createElement("section", {
2131
+ className: index_module_default4.sidebarContainer
2132
+ }, /* @__PURE__ */ React8.createElement("header", {
2133
+ className: index_module_default4.sidebarHeader
2134
+ }, options === null || options === void 0 ? void 0 : options.header, /* @__PURE__ */ React8.createElement("a", {
2135
+ className: index_module_default4.sidebarHeaderClose,
2136
+ onClick: handleClose
2137
+ }, /* @__PURE__ */ React8.createElement(CloseSingle, null))), /* @__PURE__ */ React8.createElement("section", {
2138
+ className: index_module_default4.sidebarBody
2139
+ }, options === null || options === void 0 ? void 0 : options.children), (options === null || options === void 0 ? void 0 : options.footer) && /* @__PURE__ */ React8.createElement("footer", {
2140
+ className: index_module_default4.sidebarFooter
2141
+ }, options.footer)));
2142
+ }
2143
+ // src/components/notification/Notification.tsx
2144
+ import { ConfigContext } from "@univerjs/design";
2145
+ import { CloseSingle as CloseSingle2, ErrorSingle, SuccessSingle, WarningSingle } from "@univerjs/icons";
2146
+ import clsx5 from "clsx";
2147
+ import { useNotification } from "rc-notification";
2148
+ import React9, { useContext, useEffect as useEffect5, useRef as useRef2 } from "react";
2149
+ import { Subject as Subject2 } from "rxjs";
2150
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/ui/src/components/notification/index.module.less
2151
+ var index_module_default5 = {
2152
+ "notification": "univer-notification",
2153
+ "notificationNotice": "univer-notification-notice",
2154
+ "notificationNoticeWrapper": "univer-notification-notice-wrapper",
2155
+ "notificationNoticeContent": "univer-notification-notice-content",
2156
+ "notificationNoticeClose": "univer-notification-notice-close",
2157
+ "notificationIcon": "univer-notification-icon",
2158
+ "notificationIconSuccess": "univer-notification-icon-success",
2159
+ "notificationIconInfo": "univer-notification-icon-info",
2160
+ "notificationIconWarning": "univer-notification-icon-warning",
2161
+ "notificationIconError": "univer-notification-icon-error",
2162
+ "notificationContentContainer": "univer-notification-content-container",
2163
+ "notificationTitle": "univer-notification-title",
2164
+ "notificationContent": "univer-notification-content",
2165
+ "notificationContentEllipsis": "univer-notification-content-ellipsis",
2166
+ "notificationTop": "univer-notification-top",
2167
+ "notificationTopLeft": "univer-notification-topLeft",
2168
+ "notificationTopRight": "univer-notification-topRight",
2169
+ "notificationBottom": "univer-notification-bottom",
2170
+ "notificationBottomRight": "univer-notification-bottomRight",
2171
+ "notificationBottomLeft": "univer-notification-bottomLeft",
2172
+ "notificationFade": "univer-notification-fade",
2173
+ "notificationFadeAppearPrepare": "univer-notification-fade-appear-prepare",
2174
+ "notificationFadeAppearStart": "univer-notification-fade-appear-start",
2175
+ "notificationFadeAppearActive": "univer-notification-fade-appear-active",
2176
+ "notificationFadeAppear": "univer-notification-fade-appear",
2177
+ "notificationFadeEnter": "univer-notification-fade-enter",
2178
+ "notificationFadeLeave": "univer-notification-fade-leave",
2179
+ "notificationFadeEnterActive": "univer-notification-fade-enter-active",
2180
+ "notificationFadeIn": "univer-notification-fade-in",
2181
+ "notificationFadeLeaveActive": "univer-notification-fade-leave-active",
2182
+ "notificationFadeOut": "univer-notification-fade-out"
2183
+ };
2184
+ // src/components/notification/Notification.tsx
2185
+ var iconMap = {
2186
+ success: /* @__PURE__ */ React9.createElement(SuccessSingle, {
2187
+ className: index_module_default5.notificationIconSuccess
2188
+ }),
2189
+ info: /* @__PURE__ */ React9.createElement(WarningSingle, {
2190
+ className: index_module_default5.notificationIconInfo
2191
+ }),
2192
+ warning: /* @__PURE__ */ React9.createElement(WarningSingle, {
2193
+ className: index_module_default5.notificationIconWarning
2194
+ }),
2195
+ error: /* @__PURE__ */ React9.createElement(ErrorSingle, {
2196
+ className: index_module_default5.notificationIconError
2197
+ })
2198
+ };
2199
+ var notificationObserver = new Subject2();
2200
+ var PureContent = function(props) {
2201
+ var type = props.type, content = props.content, title = props.title, _props_lines = props.lines, lines = _props_lines === void 0 ? 0 : _props_lines;
2202
+ var contentClassName = clsx5(index_module_default5.notificationContent, _define_property({}, index_module_default5.notificationContentEllipsis, lines !== 0));
2203
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement("span", {
2204
+ className: index_module_default5.notificationIcon
2205
+ }, iconMap[type]), /* @__PURE__ */ React9.createElement("div", {
2206
+ className: index_module_default5.notificationContentContainer
2207
+ }, /* @__PURE__ */ React9.createElement("span", {
2208
+ className: index_module_default5.notificationTitle
2209
+ }, title), /* @__PURE__ */ React9.createElement("span", {
2210
+ className: contentClassName,
2211
+ style: {
2212
+ WebkitLineClamp: lines
2213
+ }
2214
+ }, content)));
2215
+ };
2216
+ function Notification() {
2217
+ var mountContainer = useContext(ConfigContext).mountContainer;
2218
+ var _useNotification = _sliced_to_array(useNotification({
2219
+ prefixCls: index_module_default5.notification,
2220
+ maxCount: 3,
2221
+ closeIcon: /* @__PURE__ */ React9.createElement(CloseSingle2, null),
2222
+ getContainer: function() {
2223
+ return mountContainer;
2224
+ },
2225
+ motion: {
2226
+ motionName: index_module_default5.notificationFade,
2227
+ motionAppear: true,
2228
+ motionEnter: true,
2229
+ motionLeave: true
2230
+ }
2231
+ }), 2), api = _useNotification[0], contextHolder = _useNotification[1];
2232
+ var observerRef = useRef2(notificationObserver);
2233
+ useEffect5(function() {
2234
+ var subscription = observerRef.current.subscribe(function(options) {
2235
+ var _options_placement, _options_duration, _options_closable;
2236
+ api.open({
2237
+ content: /* @__PURE__ */ React9.createElement(PureContent, {
2238
+ content: options.content,
2239
+ type: options.type,
2240
+ title: options.title,
2241
+ lines: options.lines
2242
+ }),
2243
+ placement: (_options_placement = options.placement) !== null && _options_placement !== void 0 ? _options_placement : "topRight",
2244
+ duration: (_options_duration = options.duration) !== null && _options_duration !== void 0 ? _options_duration : 4.5,
2245
+ closable: (_options_closable = options.closable) !== null && _options_closable !== void 0 ? _options_closable : true
2246
+ });
2247
+ });
2248
+ return function() {
2249
+ subscription.unsubscribe();
2250
+ };
2251
+ }, []);
2252
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, contextHolder);
2253
+ }
2254
+ var notification = {
2255
+ show: function(options) {
2256
+ notificationObserver.next(options);
2257
+ }
2258
+ };
2259
+ // src/views/components/confirm-part/ConfirmPart.tsx
2260
+ import { Confirm } from "@univerjs/design";
2261
+ import { useDependency as useDependency7 } from "@wendellhu/redi/react-bindings";
2262
+ import React10, { useEffect as useEffect6, useState as useState7 } from "react";
2263
+ // src/services/confirm/confirm.service.ts
2264
+ import { createIdentifier as createIdentifier8 } from "@wendellhu/redi";
2265
+ var IConfirmService = createIdentifier8("univer.confirm-service");
2266
+ // src/views/components/confirm-part/ConfirmPart.tsx
2267
+ function ConfirmPart() {
2268
+ var confirmService = useDependency7(IConfirmService);
2269
+ var _useState7 = _sliced_to_array(useState7([]), 2), confirmOptions = _useState7[0], setConfirmOptions = _useState7[1];
2270
+ useEffect6(function() {
2271
+ var confirm$ = confirmService.getObservableConfirm();
2272
+ var subscribtion = confirm$.subscribe(function(options) {
2273
+ setConfirmOptions(options);
2274
+ });
2275
+ return function() {
2276
+ subscribtion.unsubscribe();
2277
+ };
2278
+ }, []);
2279
+ var props = confirmOptions.map(function(options) {
2280
+ var children = options.children, title = options.title, restProps = _object_without_properties(options, [
2281
+ "children",
2282
+ "title"
2283
+ ]);
2284
+ var confirmProps = restProps;
2285
+ for(var _i = 0, _iter = [
2286
+ "children",
2287
+ "title"
2288
+ ]; _i < _iter.length; _i++){
2289
+ var key = _iter[_i];
2290
+ var k = key;
2291
+ var props2 = options[k];
2292
+ if (props2) {
2293
+ confirmProps[k] = /* @__PURE__ */ React10.createElement(CustomLabel, _object_spread({}, props2));
2294
+ }
2295
+ }
2296
+ return confirmProps;
2297
+ });
2298
+ return props === null || props === void 0 ? void 0 : props.map(function(options, index) {
2299
+ return /* @__PURE__ */ React10.createElement(Confirm, _object_spread({
2300
+ key: index
2301
+ }, options));
2302
+ });
2303
+ }
2304
+ // src/views/components/context-menu/ContextMenu.tsx
2305
+ import { ICommandService as ICommandService4 } from "@univerjs/core";
2306
+ import { Popup } from "@univerjs/design";
2307
+ import { useDependency as useDependency8 } from "@wendellhu/redi/react-bindings";
2308
+ import React11, { useEffect as useEffect7, useState as useState8 } from "react";
2309
+ // src/services/contextmenu/contextmenu.service.ts
2310
+ import { Disposable as Disposable5, toDisposable as toDisposable6 } from "@univerjs/core";
2311
+ import { createIdentifier as createIdentifier9 } from "@wendellhu/redi";
2312
+ var IContextMenuService = createIdentifier9("univer.context-menu-service");
2313
+ var DesktopContextMenuService = /*#__PURE__*/ function(Disposable5) {
2314
+ "use strict";
2315
+ _inherits(DesktopContextMenuService, Disposable5);
2316
+ var _super = _create_super(DesktopContextMenuService);
2317
+ function DesktopContextMenuService() {
2318
+ _class_call_check(this, DesktopContextMenuService);
2319
+ var _this;
2320
+ _this = _super.apply(this, arguments);
2321
+ _define_property(_assert_this_initialized(_this), "_currentHandler", null);
2322
+ return _this;
2323
+ }
2324
+ _create_class(DesktopContextMenuService, [
2325
+ {
2326
+ key: "triggerContextMenu",
2327
+ value: function triggerContextMenu(event, menuType) {
2328
+ var _this__currentHandler;
2329
+ event.stopPropagation();
2330
+ (_this__currentHandler = this._currentHandler) === null || _this__currentHandler === void 0 ? void 0 : _this__currentHandler.handleContextMenu(event, menuType);
2331
+ }
2332
+ },
2333
+ {
2334
+ key: "registerContextMenuHandler",
2335
+ value: function registerContextMenuHandler(handler) {
2336
+ var _this = this;
2337
+ if (this._currentHandler) {
2338
+ throw new Error("There is already a context menu handler!");
2339
+ }
2340
+ this._currentHandler = handler;
2341
+ return toDisposable6(function() {
2342
+ _this._currentHandler = null;
2343
+ });
2344
+ }
2345
+ }
2346
+ ]);
2347
+ return DesktopContextMenuService;
2348
+ }(Disposable5);
2349
+ // src/views/components/context-menu/ContextMenu.tsx
2350
+ function ContextMenu() {
2351
+ var _useState8 = _sliced_to_array(useState8(false), 2), visible = _useState8[0], setVisible = _useState8[1];
2352
+ var _useState81 = _sliced_to_array(useState8(""), 2), menuType = _useState81[0], setMenuType = _useState81[1];
2353
+ var _useState82 = _sliced_to_array(useState8([
2354
+ 0,
2355
+ 0
2356
+ ]), 2), offset = _useState82[0], setOffset = _useState82[1];
2357
+ var contextMenuService = useDependency8(IContextMenuService);
2358
+ var commandService = useDependency8(ICommandService4);
2359
+ useEffect7(function() {
2360
+ var disposables = contextMenuService.registerContextMenuHandler({
2361
+ handleContextMenu: handleContextMenu
2362
+ });
2363
+ document.addEventListener("pointerdown", handleClose);
2364
+ document.addEventListener("wheel", handleClose);
2365
+ return function() {
2366
+ document.removeEventListener("pointerdown", handleClose);
2367
+ document.removeEventListener("wheel", handleClose);
2368
+ disposables.dispose();
2369
+ };
2370
+ }, []);
2371
+ function handleContextMenu(event, menuType2) {
2372
+ setMenuType(menuType2);
2373
+ setOffset([
2374
+ event.clientX,
2375
+ event.clientY
2376
+ ]);
2377
+ setVisible(true);
2378
+ }
2379
+ function handleClose() {
2380
+ setVisible(false);
2381
+ }
2382
+ return /* @__PURE__ */ React11.createElement(Popup, {
2383
+ visible: visible,
2384
+ offset: offset
2385
+ }, /* @__PURE__ */ React11.createElement("section", {
2386
+ onPointerDown: function(e) {
2387
+ return e.stopPropagation();
2388
+ }
2389
+ }, /* @__PURE__ */ React11.createElement(Menu, {
2390
+ menuType: [
2391
+ menuType
2392
+ ],
2393
+ onOptionSelect: function(params) {
2394
+ var commandId = params.label, value = params.value;
2395
+ commandService && commandService.executeCommand(commandId, {
2396
+ value: value
2397
+ });
2398
+ setVisible(false);
2399
+ }
2400
+ })));
2401
+ }
2402
+ // src/views/components/dialog-part/DialogPart.tsx
2403
+ import { Dialog } from "@univerjs/design";
2404
+ import { useDependency as useDependency9 } from "@wendellhu/redi/react-bindings";
2405
+ import React12, { useEffect as useEffect8, useState as useState9 } from "react";
2406
+ // src/services/dialog/dialog.service.ts
2407
+ import { createIdentifier as createIdentifier10 } from "@wendellhu/redi";
2408
+ var IDialogService = createIdentifier10("univer.dialog-service");
2409
+ // src/views/components/dialog-part/DialogPart.tsx
2410
+ function DialogPart() {
2411
+ var dialogService = useDependency9(IDialogService);
2412
+ var _useState9 = _sliced_to_array(useState9([]), 2), dialogOptions = _useState9[0], setDialogOptions = _useState9[1];
2413
+ useEffect8(function() {
2414
+ var dialog$ = dialogService.getObservableDialog();
2415
+ var subscribtion = dialog$.subscribe(function(options) {
2416
+ setDialogOptions(options);
2417
+ });
2418
+ return function() {
2419
+ subscribtion.unsubscribe();
2420
+ };
2421
+ }, []);
2422
+ var props = dialogOptions.map(function(options) {
2423
+ var children = options.children, title = options.title, closeIcon = options.closeIcon, footer = options.footer, restProps = _object_without_properties(options, [
2424
+ "children",
2425
+ "title",
2426
+ "closeIcon",
2427
+ "footer"
2428
+ ]);
2429
+ var dialogProps = restProps;
2430
+ for(var _i = 0, _iter = [
2431
+ "children",
2432
+ "title",
2433
+ "closeIcon",
2434
+ "footer"
2435
+ ]; _i < _iter.length; _i++){
2436
+ var key = _iter[_i];
2437
+ var k = key;
2438
+ var props2 = options[k];
2439
+ if (props2) {
2440
+ dialogProps[k] = /* @__PURE__ */ React12.createElement(CustomLabel, _object_spread({}, props2));
2441
+ }
2442
+ }
2443
+ return dialogProps;
2444
+ });
2445
+ return /* @__PURE__ */ React12.createElement(React12.Fragment, null, props === null || props === void 0 ? void 0 : props.map(function(options) {
2446
+ return /* @__PURE__ */ React12.createElement(Dialog, _object_spread({
2447
+ key: options.id
2448
+ }, options));
2449
+ }));
2450
+ }
2451
+ // src/views/parts.ts
2452
+ var globalComponents = /* @__PURE__ */ new Set([
2453
+ function() {
2454
+ return DialogPart;
2455
+ },
2456
+ function() {
2457
+ return ConfirmPart;
2458
+ },
2459
+ function() {
2460
+ return Notification;
2461
+ },
2462
+ function() {
2463
+ return ContextMenu;
2464
+ }
2465
+ ]);
2466
+ // src/views/App.tsx
2467
+ function App(props) {
2468
+ var localeService = useDependency10(LocaleService4);
2469
+ var themeService = useDependency10(ThemeService);
2470
+ var messageService = useDependency10(IMessageService);
2471
+ var contentRef = useRef3(null);
2472
+ var mountContainer = props.mountContainer, headerComponents = props.headerComponents, headerMenuComponents = props.headerMenuComponents, contentComponents = props.contentComponents, footerComponents = props.footerComponents, // sidebarComponents,
2473
+ onRendered = props.onRendered;
2474
+ useEffect9(function() {
2475
+ if (!themeService.getCurrentTheme()) {
2476
+ themeService.setTheme(defaultTheme);
2477
+ }
2478
+ }, []);
2479
+ useEffect9(function() {
2480
+ if (contentRef.current) {
2481
+ onRendered === null || onRendered === void 0 ? void 0 : onRendered(contentRef.current);
2482
+ }
2483
+ }, [
2484
+ onRendered
2485
+ ]);
2486
+ var _useState10 = _sliced_to_array(useState10(localeService.getLocales()), 2), locale = _useState10[0], setLocale = _useState10[1];
2487
+ var portalContainer = useMemo2(function() {
2488
+ return document.createElement("div");
2489
+ }, []);
2490
+ useEffect9(function() {
2491
+ document.body.appendChild(portalContainer);
2492
+ messageService.setContainer(portalContainer);
2493
+ var subscriptions = [
2494
+ localeService.localeChanged$.subscribe(function() {
2495
+ setLocale(localeService.getLocales());
2496
+ }),
2497
+ themeService.currentTheme$.subscribe(function(theme) {
2498
+ themeInstance.setTheme(mountContainer, theme);
2499
+ portalContainer && themeInstance.setTheme(portalContainer, theme);
2500
+ })
2501
+ ];
2502
+ return function() {
2503
+ subscriptions.forEach(function(subscription) {
2504
+ return subscription.unsubscribe();
2505
+ });
2506
+ };
2507
+ }, [
2508
+ portalContainer
2509
+ ]);
2510
+ return /* @__PURE__ */ React13.createElement(ConfigProvider, {
2511
+ locale: locale,
2512
+ mountContainer: portalContainer
2513
+ }, /* @__PURE__ */ React13.createElement("section", {
2514
+ className: app_module_default.appLayout
2515
+ }, props.toolbar && /* @__PURE__ */ React13.createElement(MenuBar, {
2516
+ headerMenuComponents: headerMenuComponents
2517
+ }), /* @__PURE__ */ React13.createElement("section", {
2518
+ className: app_module_default.appContainer
2519
+ }, /* @__PURE__ */ React13.createElement("header", {
2520
+ className: app_module_default.appContainerHeader
2521
+ }, props.toolbar && /* @__PURE__ */ React13.createElement(Toolbar, null)), /* @__PURE__ */ React13.createElement("section", {
2522
+ className: app_module_default.appContainerWrapper
2523
+ }, /* @__PURE__ */ React13.createElement("section", {
2524
+ className: app_module_default.appContainerContent
2525
+ }, /* @__PURE__ */ React13.createElement("header", null, /* @__PURE__ */ React13.createElement(ComponentContainer, {
2526
+ components: headerComponents
2527
+ })), /* @__PURE__ */ React13.createElement("section", {
2528
+ className: app_module_default.appContainerCanvas,
2529
+ ref: contentRef,
2530
+ "data-range-selector": true,
2531
+ onContextMenu: function(e) {
2532
+ return e.preventDefault();
2533
+ }
2534
+ }, /* @__PURE__ */ React13.createElement(ComponentContainer, {
2535
+ components: contentComponents
2536
+ }))), /* @__PURE__ */ React13.createElement("aside", {
2537
+ className: app_module_default.appContainerSidebar
2538
+ }, /* @__PURE__ */ React13.createElement(Sidebar, null)))), /* @__PURE__ */ React13.createElement("footer", {
2539
+ className: app_module_default.appFooter
2540
+ }, /* @__PURE__ */ React13.createElement(ComponentContainer, {
2541
+ components: footerComponents
2542
+ }))), /* @__PURE__ */ React13.createElement(ComponentContainer, {
2543
+ components: globalComponents
2544
+ }));
2545
+ }
2546
+ // src/controllers/ui/ui-desktop.controller.tsx
2547
+ var DesktopUIPart = /* @__PURE__ */ function(DesktopUIPart2) {
2548
+ DesktopUIPart2["HEADER"] = "header";
2549
+ DesktopUIPart2["HEADER_MENU"] = "header-menu";
2550
+ DesktopUIPart2["CONTENT"] = "content";
2551
+ DesktopUIPart2["FOOTER"] = "footer";
2552
+ return DesktopUIPart2;
2553
+ }(DesktopUIPart || {});
2554
+ var STEADY_TIMEOUT = 3e3;
2555
+ var DesktopUIController = /*#__PURE__*/ function(Disposable6) {
2556
+ "use strict";
2557
+ _inherits(DesktopUIController, Disposable6);
2558
+ var _super = _create_super(DesktopUIController);
2559
+ function DesktopUIController(_injector, _lifecycleService, _renderManagerService, _focusService) {
2560
+ _class_call_check(this, DesktopUIController);
2561
+ var _this;
2562
+ _this = _super.call(this);
2563
+ _define_property(_assert_this_initialized(_this), "_headerComponents", /* @__PURE__ */ new Set());
2564
+ _define_property(_assert_this_initialized(_this), "_headerMenuComponents", /* @__PURE__ */ new Set());
2565
+ _define_property(_assert_this_initialized(_this), "_contentComponents", /* @__PURE__ */ new Set());
2566
+ _define_property(_assert_this_initialized(_this), "_footerComponents", /* @__PURE__ */ new Set());
2567
+ // private _sidebarComponents: Set<() => ComponentType> = new Set();
2568
+ _define_property(_assert_this_initialized(_this), "_componentRegistered$", new Subject3());
2569
+ _define_property(_assert_this_initialized(_this), "componentRegistered$", _this._componentRegistered$.asObservable());
2570
+ _this._injector = _injector;
2571
+ _this._lifecycleService = _lifecycleService;
2572
+ _this._renderManagerService = _renderManagerService;
2573
+ _this._focusService = _focusService;
2574
+ return _this;
2575
+ }
2576
+ _create_class(DesktopUIController, [
2577
+ {
2578
+ key: "bootstrapWorkbench",
2579
+ value: function bootstrapWorkbench(options) {
2580
+ var _this = this;
2581
+ this.disposeWithMe(bootStrap(this._injector, options, function(canvasElement, containerElement) {
2582
+ _this._initializeEngine(canvasElement);
2583
+ _this._lifecycleService.stage = LifecycleStages3.Rendered;
2584
+ _this._focusService.setContainerElement(containerElement);
2585
+ setTimeout(function() {
2586
+ return _this._lifecycleService.stage = LifecycleStages3.Steady;
2587
+ }, STEADY_TIMEOUT);
2588
+ }));
2589
+ }
2590
+ },
2591
+ {
2592
+ key: "_initializeEngine",
2593
+ value: function _initializeEngine(element) {
2594
+ var engine = this._renderManagerService.getCurrent().engine;
2595
+ engine.setContainer(element);
2596
+ }
2597
+ },
2598
+ {
2599
+ key: "registerComponent",
2600
+ value: function registerComponent(part, component) {
2601
+ switch(part){
2602
+ case "header" /* HEADER */ :
2603
+ return this.registerHeaderComponent(component);
2604
+ case "content" /* CONTENT */ :
2605
+ return this.registerContentComponent(component);
2606
+ case "footer" /* FOOTER */ :
2607
+ return this.registerFooterComponent(component);
2608
+ case "header-menu" /* HEADER_MENU */ :
2609
+ return this.registerHeaderMenuComponent(component);
2610
+ default:
2611
+ throw new Error("[DesktopUIController] Unknown part type: ".concat(part, "."));
2612
+ }
2613
+ }
2614
+ },
2615
+ {
2616
+ key: "registerHeaderMenuComponent",
2617
+ value: function registerHeaderMenuComponent(component) {
2618
+ var _this = this;
2619
+ this._headerMenuComponents.add(component);
2620
+ this._componentRegistered$.next();
2621
+ return toDisposable7(function() {
2622
+ return _this._headerMenuComponents.delete(component);
2623
+ });
2624
+ }
2625
+ },
2626
+ {
2627
+ key: "getHeaderMenuComponents",
2628
+ value: function getHeaderMenuComponents() {
2629
+ return /* @__PURE__ */ new Set(_to_consumable_array(this._headerMenuComponents));
2630
+ }
2631
+ },
2632
+ {
2633
+ key: "registerHeaderComponent",
2634
+ value: function registerHeaderComponent(component) {
2635
+ var _this = this;
2636
+ this._headerComponents.add(component);
2637
+ this._componentRegistered$.next();
2638
+ return toDisposable7(function() {
2639
+ return _this._headerComponents.delete(component);
2640
+ });
2641
+ }
2642
+ },
2643
+ {
2644
+ key: "getHeaderComponents",
2645
+ value: function getHeaderComponents() {
2646
+ return /* @__PURE__ */ new Set(_to_consumable_array(this._headerComponents));
2647
+ }
2648
+ },
2649
+ {
2650
+ key: "registerContentComponent",
2651
+ value: function registerContentComponent(component) {
2652
+ var _this = this;
2653
+ this._contentComponents.add(component);
2654
+ this._componentRegistered$.next();
2655
+ return toDisposable7(function() {
2656
+ return _this._contentComponents.delete(component);
2657
+ });
2658
+ }
2659
+ },
2660
+ {
2661
+ key: "getContentComponents",
2662
+ value: function getContentComponents() {
2663
+ return /* @__PURE__ */ new Set(_to_consumable_array(this._contentComponents));
2664
+ }
2665
+ },
2666
+ {
2667
+ key: "registerFooterComponent",
2668
+ value: function registerFooterComponent(component) {
2669
+ var _this = this;
2670
+ this._footerComponents.add(component);
2671
+ this._componentRegistered$.next();
2672
+ return toDisposable7(function() {
2673
+ return _this._footerComponents.delete(component);
2674
+ });
2675
+ }
2676
+ },
2677
+ {
2678
+ key: "getFooterComponents",
2679
+ value: function getFooterComponents() {
2680
+ return /* @__PURE__ */ new Set(_to_consumable_array(this._footerComponents));
2681
+ }
2682
+ }
2683
+ ]);
2684
+ return DesktopUIController;
2685
+ }(Disposable6);
2686
+ DesktopUIController = __decorateClass([
2687
+ __decorateParam(0, Inject2(Injector2)),
2688
+ __decorateParam(1, Inject2(LifecycleService)),
2689
+ __decorateParam(2, IRenderManagerService),
2690
+ __decorateParam(3, IFocusService)
2691
+ ], DesktopUIController);
2692
+ function bootStrap(injector, options, callback) {
2693
+ var mountContainer;
2694
+ var container = options.container;
2695
+ if (typeof container === "string") {
2696
+ var containerElement = document.getElementById(container);
2697
+ if (!containerElement) {
2698
+ mountContainer = createContainer(container);
2699
+ } else {
2700
+ mountContainer = containerElement;
2701
+ }
2702
+ } else if (_instanceof(container, HTMLElement)) {
2703
+ mountContainer = container;
2704
+ } else {
2705
+ mountContainer = createContainer("univer");
2706
+ }
2707
+ var ConnectedApp = connectInjector(App, injector);
2708
+ var desktopUIController = injector.get(IUIController);
2709
+ var onRendered = function(canvasElement) {
2710
+ return callback(canvasElement, mountContainer);
2711
+ };
2712
+ function render() {
2713
+ var headerComponents = desktopUIController.getHeaderComponents();
2714
+ var contentComponents = desktopUIController.getContentComponents();
2715
+ var footerComponents = desktopUIController.getFooterComponents();
2716
+ var headerMenuComponents = desktopUIController.getHeaderMenuComponents();
2717
+ createRoot(/* @__PURE__ */ React14.createElement(ConnectedApp, _object_spread_props(_object_spread({}, options), {
2718
+ mountContainer: mountContainer,
2719
+ headerComponents: headerComponents,
2720
+ headerMenuComponents: headerMenuComponents,
2721
+ contentComponents: contentComponents,
2722
+ onRendered: onRendered,
2723
+ footerComponents: footerComponents
2724
+ })), mountContainer);
2725
+ }
2726
+ var updateSubscription = desktopUIController.componentRegistered$.subscribe(render);
2727
+ render();
2728
+ return toDisposable7(function() {
2729
+ unmount(mountContainer);
2730
+ updateSubscription.unsubscribe();
2731
+ });
2732
+ }
2733
+ function createContainer(id) {
2734
+ var element = document.createElement("div");
2735
+ element.id = id;
2736
+ return element;
2737
+ }
2738
+ // src/services/before-close/before-close.service.ts
2739
+ import { createIdentifier as createIdentifier12 } from "@wendellhu/redi";
2740
+ // src/services/notification/notification.service.ts
2741
+ import { createIdentifier as createIdentifier11 } from "@wendellhu/redi";
2742
+ var INotificationService = createIdentifier11("univer.notification-service");
2743
+ // src/services/before-close/before-close.service.ts
2744
+ var IBeforeCloseService = createIdentifier12("univer.ui.before-close-service");
2745
+ var DesktopBeforeCloseService = /*#__PURE__*/ function() {
2746
+ "use strict";
2747
+ function DesktopBeforeCloseService(_notificationService) {
2748
+ _class_call_check(this, DesktopBeforeCloseService);
2749
+ _define_property(this, "_callbacks", []);
2750
+ this._notificationService = _notificationService;
2751
+ this._init();
2752
+ }
2753
+ _create_class(DesktopBeforeCloseService, [
2754
+ {
2755
+ key: "registerBeforeClose",
2756
+ value: function registerBeforeClose(callback) {
2757
+ var _this = this;
2758
+ this._callbacks.push(callback);
2759
+ return {
2760
+ dispose: function() {
2761
+ _this._callbacks = _this._callbacks.filter(function(cb) {
2762
+ return cb !== callback;
2763
+ });
2764
+ }
2765
+ };
2766
+ }
2767
+ },
2768
+ {
2769
+ key: "_init",
2770
+ value: function _init() {
2771
+ var _this = this;
2772
+ window.onbeforeunload = function(event) {
2773
+ var message = _this._callbacks.map(function(callback) {
2774
+ return callback();
2775
+ }).filter(function(m) {
2776
+ return !!m;
2777
+ }).join("\n");
2778
+ if (message) {
2779
+ _this._notificationService.show({
2780
+ type: "error",
2781
+ title: "Some changes are not saved",
2782
+ content: message
2783
+ });
2784
+ if (typeof event === "undefined") {
2785
+ event = window.event;
2786
+ }
2787
+ event.returnValue = message;
2788
+ return message;
2789
+ }
2790
+ };
2791
+ }
2792
+ }
2793
+ ]);
2794
+ return DesktopBeforeCloseService;
2795
+ }();
2796
+ DesktopBeforeCloseService = __decorateClass([
2797
+ __decorateParam(0, INotificationService)
2798
+ ], DesktopBeforeCloseService);
2799
+ // src/services/clipboard/clipboard-interface.service.ts
2800
+ import { Disposable as Disposable7 } from "@univerjs/core";
2801
+ import { createIdentifier as createIdentifier13 } from "@wendellhu/redi";
2802
+ var PLAIN_TEXT_CLIPBOARD_MIME_TYPE = "text/plain";
2803
+ var HTML_CLIPBOARD_MIME_TYPE = "text/html";
2804
+ var IClipboardInterfaceService = createIdentifier13("univer.clipboard-interface-service");
2805
+ var BrowserClipboardService = /*#__PURE__*/ function(Disposable7) {
2806
+ "use strict";
2807
+ _inherits(BrowserClipboardService, Disposable7);
2808
+ var _super = _create_super(BrowserClipboardService);
2809
+ function BrowserClipboardService() {
2810
+ _class_call_check(this, BrowserClipboardService);
2811
+ return _super.apply(this, arguments);
2812
+ }
2813
+ _create_class(BrowserClipboardService, [
2814
+ {
2815
+ key: "write",
2816
+ value: function write(text, html) {
2817
+ return _async_to_generator(function() {
2818
+ var _obj, error;
2819
+ return _ts_generator(this, function(_state) {
2820
+ switch(_state.label){
2821
+ case 0:
2822
+ _state.trys.push([
2823
+ 0,
2824
+ 2,
2825
+ ,
2826
+ 3
2827
+ ]);
2828
+ return [
2829
+ 4,
2830
+ navigator.clipboard.write([
2831
+ new ClipboardItem((_obj = {}, _define_property(_obj, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, new Blob([
2832
+ text
2833
+ ], {
2834
+ type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE
2835
+ })), _define_property(_obj, HTML_CLIPBOARD_MIME_TYPE, new Blob([
2836
+ html
2837
+ ], {
2838
+ type: HTML_CLIPBOARD_MIME_TYPE
2839
+ })), _obj))
2840
+ ])
2841
+ ];
2842
+ case 1:
2843
+ return [
2844
+ 2,
2845
+ _state.sent()
2846
+ ];
2847
+ case 2:
2848
+ error = _state.sent();
2849
+ console.error(error);
2850
+ return [
2851
+ 3,
2852
+ 3
2853
+ ];
2854
+ case 3:
2855
+ return [
2856
+ 2
2857
+ ];
2858
+ }
2859
+ });
2860
+ })();
2861
+ }
2862
+ },
2863
+ {
2864
+ key: "writeText",
2865
+ value: function writeText(text) {
2866
+ return _async_to_generator(function() {
2867
+ var error, activeElement, container;
2868
+ return _ts_generator(this, function(_state) {
2869
+ switch(_state.label){
2870
+ case 0:
2871
+ _state.trys.push([
2872
+ 0,
2873
+ 2,
2874
+ ,
2875
+ 3
2876
+ ]);
2877
+ return [
2878
+ 4,
2879
+ navigator.clipboard.writeText(text)
2880
+ ];
2881
+ case 1:
2882
+ return [
2883
+ 2,
2884
+ _state.sent()
2885
+ ];
2886
+ case 2:
2887
+ error = _state.sent();
2888
+ console.error(error);
2889
+ return [
2890
+ 3,
2891
+ 3
2892
+ ];
2893
+ case 3:
2894
+ activeElement = document.activeElement;
2895
+ container = createCopyPasteContainer();
2896
+ container.value = text;
2897
+ container.focus();
2898
+ container.select();
2899
+ document.body.appendChild(container);
2900
+ document.execCommand("copy");
2901
+ if (_instanceof(activeElement, HTMLElement)) {
2902
+ activeElement.focus();
2903
+ }
2904
+ document.removeChild(container);
2905
+ return [
2906
+ 2
2907
+ ];
2908
+ }
2909
+ });
2910
+ })();
2911
+ }
2912
+ },
2913
+ {
2914
+ key: "read",
2915
+ value: function read() {
2916
+ return _async_to_generator(function() {
2917
+ return _ts_generator(this, function(_state) {
2918
+ return [
2919
+ 2,
2920
+ navigator.clipboard.read()
2921
+ ];
2922
+ });
2923
+ })();
2924
+ }
2925
+ },
2926
+ {
2927
+ key: "readText",
2928
+ value: function readText() {
2929
+ return _async_to_generator(function() {
2930
+ var e;
2931
+ return _ts_generator(this, function(_state) {
2932
+ switch(_state.label){
2933
+ case 0:
2934
+ _state.trys.push([
2935
+ 0,
2936
+ 2,
2937
+ ,
2938
+ 3
2939
+ ]);
2940
+ return [
2941
+ 4,
2942
+ navigator.clipboard.readText()
2943
+ ];
2944
+ case 1:
2945
+ return [
2946
+ 2,
2947
+ _state.sent()
2948
+ ];
2949
+ case 2:
2950
+ e = _state.sent();
2951
+ console.error(e);
2952
+ return [
2953
+ 2,
2954
+ ""
2955
+ ];
2956
+ case 3:
2957
+ return [
2958
+ 2
2959
+ ];
2960
+ }
2961
+ });
2962
+ })();
2963
+ }
2964
+ }
2965
+ ]);
2966
+ return BrowserClipboardService;
2967
+ }(Disposable7);
2968
+ function createCopyPasteContainer() {
2969
+ var textArea = document.createElement("textarea");
2970
+ textArea.style.position = "absolute";
2971
+ textArea.style.height = "1px";
2972
+ textArea.style.width = "1px";
2973
+ return textArea;
2974
+ }
2975
+ // src/services/confirm/desktop-confirm.service.ts
2976
+ import { toDisposable as toDisposable8 } from "@univerjs/core";
2977
+ import { Subject as Subject4 } from "rxjs";
2978
+ var DesktopConfirmService = /*#__PURE__*/ function() {
2979
+ "use strict";
2980
+ function DesktopConfirmService() {
2981
+ _class_call_check(this, DesktopConfirmService);
2982
+ _define_property(this, "confirmOptions", []);
2983
+ _define_property(this, "confirmOptions$", new Subject4());
2984
+ }
2985
+ _create_class(DesktopConfirmService, [
2986
+ {
2987
+ key: "open",
2988
+ value: function open(option) {
2989
+ var _this = this;
2990
+ if (this.confirmOptions.find(function(item) {
2991
+ return item.id === option.id;
2992
+ })) {
2993
+ this.confirmOptions = this.confirmOptions.map(function(item) {
2994
+ return _object_spread_props(_object_spread({}, item.id === option.id ? option : item), {
2995
+ visible: true
2996
+ });
2997
+ });
2998
+ } else {
2999
+ this.confirmOptions.push(_object_spread_props(_object_spread({}, option), {
3000
+ visible: true
3001
+ }));
3002
+ }
3003
+ this.confirmOptions$.next(this.confirmOptions);
3004
+ return toDisposable8(function() {
3005
+ _this.confirmOptions = [];
3006
+ _this.confirmOptions$.next([]);
3007
+ });
3008
+ }
3009
+ },
3010
+ {
3011
+ key: "close",
3012
+ value: function close(id) {
3013
+ this.confirmOptions = this.confirmOptions.map(function(item) {
3014
+ return _object_spread_props(_object_spread({}, item), {
3015
+ visible: item.id === id ? false : item.visible
3016
+ });
3017
+ });
3018
+ this.confirmOptions$.next(_to_consumable_array(this.confirmOptions));
3019
+ }
3020
+ },
3021
+ {
3022
+ key: "getObservableConfirm",
3023
+ value: function getObservableConfirm() {
3024
+ return this.confirmOptions$;
3025
+ }
3026
+ }
3027
+ ]);
3028
+ return DesktopConfirmService;
3029
+ }();
3030
+ // src/services/dialog/desktop-dialog.service.ts
3031
+ import { toDisposable as toDisposable9 } from "@univerjs/core";
3032
+ import { Subject as Subject5 } from "rxjs";
3033
+ var DesktopDialogService = /*#__PURE__*/ function() {
3034
+ "use strict";
3035
+ function DesktopDialogService() {
3036
+ _class_call_check(this, DesktopDialogService);
3037
+ _define_property(this, "dialogOptions", []);
3038
+ _define_property(this, "dialogOptions$", new Subject5());
3039
+ }
3040
+ _create_class(DesktopDialogService, [
3041
+ {
3042
+ key: "open",
3043
+ value: function open(option) {
3044
+ var _this = this;
3045
+ if (this.dialogOptions.find(function(item) {
3046
+ return item.id === option.id;
3047
+ })) {
3048
+ this.dialogOptions = this.dialogOptions.map(function(item) {
3049
+ return _object_spread_props(_object_spread({}, item.id === option.id ? option : item), {
3050
+ visible: true
3051
+ });
3052
+ });
3053
+ } else {
3054
+ this.dialogOptions.push(_object_spread_props(_object_spread({}, option), {
3055
+ visible: true
3056
+ }));
3057
+ }
3058
+ this.dialogOptions$.next(this.dialogOptions);
3059
+ return toDisposable9(function() {
3060
+ _this.dialogOptions = [];
3061
+ _this.dialogOptions$.next([]);
3062
+ });
3063
+ }
3064
+ },
3065
+ {
3066
+ key: "close",
3067
+ value: function close(id) {
3068
+ this.dialogOptions = this.dialogOptions.map(function(item) {
3069
+ return _object_spread_props(_object_spread({}, item), {
3070
+ visible: item.id === id ? false : item.visible
3071
+ });
3072
+ });
3073
+ this.dialogOptions$.next(_to_consumable_array(this.dialogOptions));
3074
+ }
3075
+ },
3076
+ {
3077
+ key: "getObservableDialog",
3078
+ value: function getObservableDialog() {
3079
+ return this.dialogOptions$;
3080
+ }
3081
+ }
3082
+ ]);
3083
+ return DesktopDialogService;
3084
+ }();
3085
+ // src/services/message/desktop-message.service.ts
3086
+ import { toDisposable as toDisposable10 } from "@univerjs/core";
3087
+ import { Message } from "@univerjs/design";
3088
+ var DesktopMessageService = /*#__PURE__*/ function() {
3089
+ "use strict";
3090
+ function DesktopMessageService() {
3091
+ _class_call_check(this, DesktopMessageService);
3092
+ _define_property(this, "portalContainer", document.body);
3093
+ _define_property(this, "message", void 0);
3094
+ }
3095
+ _create_class(DesktopMessageService, [
3096
+ {
3097
+ key: "setContainer",
3098
+ value: function setContainer(container) {
3099
+ this.portalContainer = container;
3100
+ this.message = new Message(container);
3101
+ }
3102
+ },
3103
+ {
3104
+ key: "show",
3105
+ value: function show(options) {
3106
+ var type = options.type, rest = _object_without_properties(options, [
3107
+ "type"
3108
+ ]);
3109
+ this.message && this.message[type](rest);
3110
+ return toDisposable10(function() {});
3111
+ }
3112
+ }
3113
+ ]);
3114
+ return DesktopMessageService;
3115
+ }();
3116
+ // src/services/notification/desktop-notification.service.ts
3117
+ import { toDisposable as toDisposable11 } from "@univerjs/core";
3118
+ var DesktopNotificationService = /*#__PURE__*/ function() {
3119
+ "use strict";
3120
+ function DesktopNotificationService() {
3121
+ _class_call_check(this, DesktopNotificationService);
3122
+ }
3123
+ _create_class(DesktopNotificationService, [
3124
+ {
3125
+ key: "show",
3126
+ value: function show(params) {
3127
+ notification.show(params);
3128
+ return toDisposable11(function() {});
3129
+ }
3130
+ }
3131
+ ]);
3132
+ return DesktopNotificationService;
3133
+ }();
3134
+ // src/services/shortcut/shortcut-experience.service.ts
3135
+ import { IUniverInstanceService, LocaleService as LocaleService5 } from "@univerjs/core";
3136
+ import { Inject as Inject3 } from "@wendellhu/redi";
3137
+ var ShortcutExperienceService = /*#__PURE__*/ function() {
3138
+ "use strict";
3139
+ function ShortcutExperienceService(_currentUniverService, _localeService) {
3140
+ _class_call_check(this, ShortcutExperienceService);
3141
+ _define_property(this, "_current", null);
3142
+ _define_property(this, "_shortcutParam", []);
3143
+ this._currentUniverService = _currentUniverService;
3144
+ this._localeService = _localeService;
3145
+ }
3146
+ _create_class(ShortcutExperienceService, [
3147
+ {
3148
+ key: "dispose",
3149
+ value: function dispose() {
3150
+ this._shortcutParam = [];
3151
+ }
3152
+ },
3153
+ {
3154
+ key: "getCurrentBySearch",
3155
+ value: function getCurrentBySearch(searchParm) {
3156
+ return this._getCurrentBySearch(searchParm);
3157
+ }
3158
+ },
3159
+ {
3160
+ key: "getCurrent",
3161
+ value: function getCurrent() {
3162
+ return this._getCurrentBySearch(this._current);
3163
+ }
3164
+ },
3165
+ {
3166
+ key: "addOrUpdate",
3167
+ value: function addOrUpdate(insertParam) {
3168
+ var param = this._getCurrentBySearch({
3169
+ unitId: insertParam.unitId,
3170
+ sheetId: insertParam.sheetId,
3171
+ keycode: insertParam.keycode
3172
+ });
3173
+ if (param != null) {
3174
+ var index = this._shortcutParam.indexOf(param);
3175
+ this._shortcutParam.splice(index, 1);
3176
+ }
3177
+ this._shortcutParam.push(insertParam);
3178
+ return param;
3179
+ }
3180
+ },
3181
+ {
3182
+ key: "remove",
3183
+ value: function remove(searchParm) {
3184
+ if (searchParm == null) {
3185
+ return;
3186
+ }
3187
+ var param = this._getCurrentBySearch(searchParm);
3188
+ if (param == null) {
3189
+ return;
3190
+ }
3191
+ var index = this._shortcutParam.indexOf(param);
3192
+ return this._shortcutParam.splice(index, 1)[0];
3193
+ }
3194
+ },
3195
+ {
3196
+ key: "_getCurrentBySearch",
3197
+ value: function _getCurrentBySearch(searchParm) {
3198
+ if (searchParm == null) {
3199
+ return;
3200
+ }
3201
+ var item = this._shortcutParam.find(function(param) {
3202
+ return param.unitId === searchParm.unitId && param.sheetId === searchParm.sheetId && param.keycode === searchParm.keycode;
3203
+ });
3204
+ return item;
3205
+ }
3206
+ }
3207
+ ]);
3208
+ return ShortcutExperienceService;
3209
+ }();
3210
+ ShortcutExperienceService = __decorateClass([
3211
+ __decorateParam(0, IUniverInstanceService),
3212
+ __decorateParam(1, Inject3(LocaleService5))
3213
+ ], ShortcutExperienceService);
3214
+ // src/services/sidebar/desktop-sidebar.service.ts
3215
+ import { toDisposable as toDisposable12 } from "@univerjs/core";
3216
+ import { Subject as Subject6 } from "rxjs";
3217
+ var DesktopSidebarService = /*#__PURE__*/ function() {
3218
+ "use strict";
3219
+ function DesktopSidebarService() {
3220
+ _class_call_check(this, DesktopSidebarService);
3221
+ _define_property(this, "sidebarOptions", {});
3222
+ _define_property(this, "sidebarOptions$", new Subject6());
3223
+ }
3224
+ _create_class(DesktopSidebarService, [
3225
+ {
3226
+ key: "open",
3227
+ value: function open(option) {
3228
+ var _this = this;
3229
+ this.sidebarOptions = _object_spread_props(_object_spread({}, option), {
3230
+ visible: true
3231
+ });
3232
+ this.sidebarOptions$.next(this.sidebarOptions);
3233
+ return toDisposable12(function() {
3234
+ _this.sidebarOptions$.next({});
3235
+ });
3236
+ }
3237
+ },
3238
+ {
3239
+ key: "close",
3240
+ value: function close() {
3241
+ this.sidebarOptions = _object_spread_props(_object_spread({}, this.sidebarOptions), {
3242
+ visible: false
3243
+ });
3244
+ this.sidebarOptions$.next(this.sidebarOptions);
3245
+ this.sidebarOptions.onClose && this.sidebarOptions.onClose();
3246
+ }
3247
+ },
3248
+ {
3249
+ key: "getObservableSidebar",
3250
+ value: function getObservableSidebar() {
3251
+ return this.sidebarOptions$;
3252
+ }
3253
+ }
3254
+ ]);
3255
+ return DesktopSidebarService;
3256
+ }();
3257
+ // src/ui-plugin.ts
3258
+ import { ILocalStorageService, LocaleService as LocaleService7, Plugin, PluginType } from "@univerjs/core";
3259
+ import { Inject as Inject6, Injector as Injector3 } from "@wendellhu/redi";
3260
+ // src/controllers/error/error.controller.ts
3261
+ import { Disposable as Disposable8, ErrorService, LifecycleStages as LifecycleStages4, OnLifecycle as OnLifecycle3, toDisposable as toDisposable13 } from "@univerjs/core";
3262
+ import { MessageType } from "@univerjs/design";
3263
+ import { Inject as Inject4 } from "@wendellhu/redi";
3264
+ var ErrorController = /*#__PURE__*/ function(Disposable8) {
3265
+ "use strict";
3266
+ _inherits(ErrorController, Disposable8);
3267
+ var _super = _create_super(ErrorController);
3268
+ function ErrorController(_errorService, _messageService) {
3269
+ _class_call_check(this, ErrorController);
3270
+ var _this;
3271
+ _this = _super.call(this);
3272
+ _this._errorService = _errorService;
3273
+ _this._messageService = _messageService;
3274
+ _this.disposeWithMe(toDisposable13(_this._errorService.error$.subscribe(function(error) {
3275
+ _this._messageService.show({
3276
+ content: error.errorKey,
3277
+ type: MessageType.Error
3278
+ });
3279
+ })));
3280
+ return _this;
3281
+ }
3282
+ return ErrorController;
3283
+ }(Disposable8);
3284
+ ErrorController = __decorateClass([
3285
+ OnLifecycle3(LifecycleStages4.Starting, ErrorController),
3286
+ __decorateParam(0, Inject4(ErrorService)),
3287
+ __decorateParam(1, IMessageService)
3288
+ ], ErrorController);
3289
+ // src/controllers/shortcut-display/shortcut-panel.controller.ts
3290
+ import { Disposable as Disposable10, ICommandService as ICommandService5, LifecycleStages as LifecycleStages5, OnLifecycle as OnLifecycle4 } from "@univerjs/core";
3291
+ import { Inject as Inject5 } from "@wendellhu/redi";
3292
+ // src/commands/operations/toggle-shortcut-panel.operation.ts
3293
+ import { CommandType as CommandType2 } from "@univerjs/core";
3294
+ // src/services/shortcut/shortcut-panel.service.ts
3295
+ import { Disposable as Disposable9 } from "@univerjs/core";
3296
+ import { BehaviorSubject as BehaviorSubject3, distinctUntilChanged } from "rxjs";
3297
+ var ShortcutPanelService = /*#__PURE__*/ function(Disposable9) {
3298
+ "use strict";
3299
+ _inherits(ShortcutPanelService, Disposable9);
3300
+ var _super = _create_super(ShortcutPanelService);
3301
+ function ShortcutPanelService() {
3302
+ _class_call_check(this, ShortcutPanelService);
3303
+ var _this;
3304
+ _this = _super.apply(this, arguments);
3305
+ _define_property(_assert_this_initialized(_this), "_open$", new BehaviorSubject3(false));
3306
+ _define_property(_assert_this_initialized(_this), "open$", _this._open$.pipe(distinctUntilChanged()));
3307
+ return _this;
3308
+ }
3309
+ _create_class(ShortcutPanelService, [
3310
+ {
3311
+ key: "isOpen",
3312
+ get: function get() {
3313
+ return this._open$.getValue();
3314
+ }
3315
+ },
3316
+ {
3317
+ key: "dispose",
3318
+ value: function dispose() {
3319
+ this._open$.next(false);
3320
+ this._open$.complete();
3321
+ }
3322
+ },
3323
+ {
3324
+ key: "open",
3325
+ value: function open() {
3326
+ this._open$.next(true);
3327
+ }
3328
+ },
3329
+ {
3330
+ key: "close",
3331
+ value: function close() {
3332
+ this._open$.next(false);
3333
+ }
3334
+ }
3335
+ ]);
3336
+ return ShortcutPanelService;
3337
+ }(Disposable9);
3338
+ // src/commands/operations/toggle-shortcut-panel.operation.ts
3339
+ var ShortcutPanelComponentName = "ShortcutPanel";
3340
+ var ToggleShortcutPanelOperation = {
3341
+ id: "base-ui.operation.toggle-shortcut-panel",
3342
+ type: CommandType2.OPERATION,
3343
+ handler: function(accessor) {
3344
+ var shortcutPanelService = accessor.get(ShortcutPanelService);
3345
+ var sidebarService = accessor.get(ISidebarService);
3346
+ var isOpen = shortcutPanelService.isOpen;
3347
+ if (isOpen) {
3348
+ shortcutPanelService.close();
3349
+ sidebarService.close();
3350
+ } else {
3351
+ shortcutPanelService.open();
3352
+ sidebarService.open({
3353
+ header: {
3354
+ title: "shortcut-panel.title"
3355
+ },
3356
+ children: {
3357
+ label: ShortcutPanelComponentName
3358
+ }
3359
+ });
3360
+ }
3361
+ return true;
3362
+ }
3363
+ };
3364
+ // src/views/components/shortcut-panel/ShortcutPanel.tsx
3365
+ import { LocaleService as LocaleService6 } from "@univerjs/core";
3366
+ import { useDependency as useDependency11 } from "@wendellhu/redi/react-bindings";
3367
+ import React15, { useCallback, useEffect as useEffect10 } from "react";
3368
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/ui/src/views/components/shortcut-panel/index.module.less
3369
+ var index_module_default6 = {
3370
+ "shortcutPanelGroupTitle": "univer-shortcut-panel-group-title",
3371
+ "shortcutPanelItem": "univer-shortcut-panel-item",
3372
+ "shortcutPanelItemTitle": "univer-shortcut-panel-item-title",
3373
+ "shortcutPanelItemShortcut": "univer-shortcut-panel-item-shortcut"
3374
+ };
3375
+ // src/views/components/shortcut-panel/ShortcutPanel.tsx
3376
+ function ShortcutPanel() {
3377
+ var shortcutService = useDependency11(IShortcutService);
3378
+ var localeService = useDependency11(LocaleService6);
3379
+ var _React15_useState = _sliced_to_array(React15.useState([]), 2), shortcutItems = _React15_useState[0], setShortcutItems = _React15_useState[1];
3380
+ var updateShortcuts = useCallback(function() {
3381
+ var shortcutGroups = /* @__PURE__ */ new Map();
3382
+ var shortcuts = shortcutService.getAllShortcuts().filter(function(item) {
3383
+ return !!item.group;
3384
+ });
3385
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3386
+ try {
3387
+ for(var _iterator = shortcuts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3388
+ var shortcut = _step.value;
3389
+ var group = shortcut.group;
3390
+ var _shortcut_description;
3391
+ var shortcutItem = {
3392
+ title: localeService.t((_shortcut_description = shortcut.description) !== null && _shortcut_description !== void 0 ? _shortcut_description : shortcut.id),
3393
+ shortcut: shortcutService.getShortcutDisplay(shortcut)
3394
+ };
3395
+ if (!/\d+_[a-zA-Z0-9]/.test(group)) {
3396
+ throw new Error("[ShortcutPanel]: Invalid shortcut group: ".concat(group, "!"));
3397
+ }
3398
+ if (!shortcutGroups.has(group)) {
3399
+ shortcutGroups.set(group, []);
3400
+ }
3401
+ shortcutGroups.get(group).push(shortcutItem);
3402
+ }
3403
+ } catch (err) {
3404
+ _didIteratorError = true;
3405
+ _iteratorError = err;
3406
+ } finally{
3407
+ try {
3408
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3409
+ _iterator.return();
3410
+ }
3411
+ } finally{
3412
+ if (_didIteratorError) {
3413
+ throw _iteratorError;
3414
+ }
3415
+ }
3416
+ }
3417
+ var toRender = Array.from(shortcutGroups.entries()).map(function(param) {
3418
+ var _param = _sliced_to_array(param, 2), name = _param[0], items = _param[1];
3419
+ var groupSequence = name.split("_")[0];
3420
+ var groupName = name.slice(groupSequence.length + 1);
3421
+ return {
3422
+ sequence: +groupSequence,
3423
+ name: localeService.t(groupName),
3424
+ items: items
3425
+ };
3426
+ }).sort(function(a, b) {
3427
+ return a.sequence - b.sequence;
3428
+ });
3429
+ setShortcutItems(toRender);
3430
+ }, [
3431
+ shortcutService,
3432
+ localeService
3433
+ ]);
3434
+ useEffect10(function() {
3435
+ updateShortcuts();
3436
+ var subscription = shortcutService.shortcutChanged$.subscribe(function() {
3437
+ return updateShortcuts();
3438
+ });
3439
+ return function() {
3440
+ return subscription.unsubscribe();
3441
+ };
3442
+ }, [
3443
+ shortcutService
3444
+ ]);
3445
+ return /* @__PURE__ */ React15.createElement("div", {
3446
+ className: index_module_default6.shortcutPanel
3447
+ }, shortcutItems.map(function(group) {
3448
+ return /* @__PURE__ */ React15.createElement("div", {
3449
+ className: index_module_default6.shortcutPanelGroup,
3450
+ key: group.name
3451
+ }, /* @__PURE__ */ React15.createElement("div", {
3452
+ className: index_module_default6.shortcutPanelGroupTitle
3453
+ }, group.name), group.items.map(function(item, index) {
3454
+ return /* @__PURE__ */ React15.createElement("div", {
3455
+ className: index_module_default6.shortcutPanelItem,
3456
+ key: index
3457
+ }, /* @__PURE__ */ React15.createElement("span", {
3458
+ className: index_module_default6.shortcutPanelItemTitle
3459
+ }, item.title), /* @__PURE__ */ React15.createElement("span", {
3460
+ className: index_module_default6.shortcutPanelItemShortcut
3461
+ }, item.shortcut));
3462
+ }));
3463
+ }));
3464
+ }
3465
+ // src/controllers/shortcut-display/menu.ts
3466
+ function ShortcutPanelMenuItemFactory() {
3467
+ return {
3468
+ id: ToggleShortcutPanelOperation.id,
3469
+ title: "toggle-shortcut-panel",
3470
+ tooltip: "toggle-shortcut-panel",
3471
+ icon: "KeyboardSingle",
3472
+ type: 0 /* BUTTON */ ,
3473
+ positions: [
3474
+ "uiToolbar.others" /* TOOLBAR_OTHERS */
3475
+ ]
3476
+ };
3477
+ }
3478
+ // src/controllers/shortcut-display/shortcut-panel.controller.ts
3479
+ var ShortcutPanelController = /*#__PURE__*/ function(Disposable10) {
3480
+ "use strict";
3481
+ _inherits(ShortcutPanelController, Disposable10);
3482
+ var _super = _create_super(ShortcutPanelController);
3483
+ function ShortcutPanelController(menuService, commandService, componentManager) {
3484
+ _class_call_check(this, ShortcutPanelController);
3485
+ var _this;
3486
+ _this = _super.call(this);
3487
+ _this.disposeWithMe(menuService.addMenuItem(ShortcutPanelMenuItemFactory()));
3488
+ _this.disposeWithMe(componentManager.register(ShortcutPanelComponentName, ShortcutPanel));
3489
+ _this.disposeWithMe(commandService.registerCommand(ToggleShortcutPanelOperation));
3490
+ return _this;
3491
+ }
3492
+ return ShortcutPanelController;
3493
+ }(Disposable10);
3494
+ ShortcutPanelController = __decorateClass([
3495
+ OnLifecycle4(LifecycleStages5.Steady, ShortcutPanelController),
3496
+ __decorateParam(0, IMenuService),
3497
+ __decorateParam(1, ICommandService5),
3498
+ __decorateParam(2, Inject5(ComponentManager))
3499
+ ], ShortcutPanelController);
3500
+ // src/locale/en-US.ts
3501
+ var en_US_default = {
3502
+ uiToolbar: {
3503
+ start: "Start",
3504
+ insert: "Insert",
3505
+ formulas: "Formulas",
3506
+ data: "Data",
3507
+ view: "View",
3508
+ others: "Others"
3509
+ },
3510
+ "shortcut-panel": {
3511
+ title: "Shortcuts"
3512
+ },
3513
+ shortcut: {
3514
+ undo: "Undo",
3515
+ redo: "Redo",
3516
+ cut: "Cut",
3517
+ copy: "Copy",
3518
+ paste: "Paste"
3519
+ },
3520
+ "common-edit": "Common Editing Shortcuts"
3521
+ };
3522
+ // src/services/local-storage/local-storage.service.ts
3523
+ import localforage from "localforage";
3524
+ var DesktopLocalStorageService = /*#__PURE__*/ function() {
3525
+ "use strict";
3526
+ function DesktopLocalStorageService() {
3527
+ _class_call_check(this, DesktopLocalStorageService);
3528
+ }
3529
+ _create_class(DesktopLocalStorageService, [
3530
+ {
3531
+ key: "getItem",
3532
+ value: function getItem(key) {
3533
+ return localforage.getItem(key);
3534
+ }
3535
+ },
3536
+ {
3537
+ key: "setItem",
3538
+ value: function setItem(key, value) {
3539
+ return localforage.setItem(key, value);
3540
+ }
3541
+ },
3542
+ {
3543
+ key: "removeItem",
3544
+ value: function removeItem(key) {
3545
+ return localforage.removeItem(key);
3546
+ }
3547
+ },
3548
+ {
3549
+ key: "clear",
3550
+ value: function clear() {
3551
+ return localforage.clear();
3552
+ }
3553
+ },
3554
+ {
3555
+ key: "key",
3556
+ value: function key(index) {
3557
+ return localforage.key(index);
3558
+ }
3559
+ },
3560
+ {
3561
+ key: "keys",
3562
+ value: function keys() {
3563
+ return localforage.keys();
3564
+ }
3565
+ },
3566
+ {
3567
+ key: "iterate",
3568
+ value: function iterate(iteratee) {
3569
+ return localforage.iterate(iteratee);
3570
+ }
3571
+ }
3572
+ ]);
3573
+ return DesktopLocalStorageService;
3574
+ }();
3575
+ // src/ui-plugin.ts
3576
+ var PLUGIN_NAME = "ui";
3577
+ var DEFAULT_SLIDE_PLUGIN_DATA = {};
3578
+ var UIPlugin = (_class = /*#__PURE__*/ function(Plugin) {
3579
+ "use strict";
3580
+ _inherits(_class, Plugin);
3581
+ var _super = _create_super(_class);
3582
+ function _class() {
3583
+ var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _injector = arguments.length > 1 ? arguments[1] : void 0, _localeService = arguments.length > 2 ? arguments[2] : void 0;
3584
+ _class_call_check(this, _class);
3585
+ var _this;
3586
+ _this = _super.call(this, PLUGIN_NAME);
3587
+ _define_property(_assert_this_initialized(_this), "_config", void 0);
3588
+ _this._injector = _injector;
3589
+ _this._localeService = _localeService;
3590
+ _this._config = Object.assign(DEFAULT_SLIDE_PLUGIN_DATA, config);
3591
+ _this._localeService.load({
3592
+ enUS: en_US_default
3593
+ });
3594
+ return _this;
3595
+ }
3596
+ _create_class(_class, [
3597
+ {
3598
+ key: "onStarting",
3599
+ value: function onStarting(_injector) {
3600
+ this._initDependencies(_injector);
3601
+ }
3602
+ },
3603
+ {
3604
+ key: "onReady",
3605
+ value: function onReady() {
3606
+ this._initUI();
3607
+ }
3608
+ },
3609
+ {
3610
+ key: "_initDependencies",
3611
+ value: function _initDependencies(injector) {
3612
+ var dependencies = [
3613
+ // legacy managers - deprecated
3614
+ [
3615
+ ComponentManager
3616
+ ],
3617
+ [
3618
+ ZIndexManager
3619
+ ],
3620
+ // services
3621
+ [
3622
+ ShortcutExperienceService
3623
+ ],
3624
+ [
3625
+ ShortcutPanelService
3626
+ ],
3627
+ [
3628
+ IShortcutService,
3629
+ {
3630
+ useClass: DesktopShortcutService
3631
+ }
3632
+ ],
3633
+ [
3634
+ IPlatformService,
3635
+ {
3636
+ useClass: DesktopPlatformService
3637
+ }
3638
+ ],
3639
+ [
3640
+ IMenuService,
3641
+ {
3642
+ useClass: DesktopMenuService
3643
+ }
3644
+ ],
3645
+ [
3646
+ IContextMenuService,
3647
+ {
3648
+ useClass: DesktopContextMenuService
3649
+ }
3650
+ ],
3651
+ [
3652
+ IClipboardInterfaceService,
3653
+ {
3654
+ useClass: BrowserClipboardService,
3655
+ lazy: true
3656
+ }
3657
+ ],
3658
+ [
3659
+ INotificationService,
3660
+ {
3661
+ useClass: DesktopNotificationService,
3662
+ lazy: true
3663
+ }
3664
+ ],
3665
+ [
3666
+ IDialogService,
3667
+ {
3668
+ useClass: DesktopDialogService,
3669
+ lazy: true
3670
+ }
3671
+ ],
3672
+ [
3673
+ IConfirmService,
3674
+ {
3675
+ useClass: DesktopConfirmService,
3676
+ lazy: true
3677
+ }
3678
+ ],
3679
+ [
3680
+ ISidebarService,
3681
+ {
3682
+ useClass: DesktopSidebarService,
3683
+ lazy: true
3684
+ }
3685
+ ],
3686
+ [
3687
+ IMessageService,
3688
+ {
3689
+ useClass: DesktopMessageService,
3690
+ lazy: true
3691
+ }
3692
+ ],
3693
+ [
3694
+ ILocalStorageService,
3695
+ {
3696
+ useClass: DesktopLocalStorageService,
3697
+ lazy: true
3698
+ }
3699
+ ],
3700
+ [
3701
+ IBeforeCloseService,
3702
+ {
3703
+ useClass: DesktopBeforeCloseService
3704
+ }
3705
+ ],
3706
+ // controllers
3707
+ [
3708
+ IFocusService,
3709
+ {
3710
+ useClass: DesktopFocusService
3711
+ }
3712
+ ],
3713
+ [
3714
+ IUIController,
3715
+ {
3716
+ useClass: DesktopUIController
3717
+ }
3718
+ ],
3719
+ [
3720
+ SharedController
3721
+ ],
3722
+ [
3723
+ ErrorController
3724
+ ],
3725
+ [
3726
+ ShortcutPanelController
3727
+ ]
3728
+ ];
3729
+ dependencies.forEach(function(dependency) {
3730
+ return injector.add(dependency);
3731
+ });
3732
+ }
3733
+ },
3734
+ {
3735
+ key: "_initUI",
3736
+ value: function _initUI() {
3737
+ var _this = this;
3738
+ Promise.resolve().then(function() {
3739
+ return _this._injector.get(IUIController).bootstrapWorkbench(_this._config);
3740
+ });
3741
+ }
3742
+ }
3743
+ ]);
3744
+ return _class;
3745
+ }(_wrap_native_super(Plugin)), _define_property(_class, "type", PluginType.Univer), _class);
3746
+ UIPlugin = __decorateClass([
3747
+ __decorateParam(1, Inject6(Injector3)),
3748
+ __decorateParam(2, Inject6(LocaleService7))
3749
+ ], UIPlugin);
3750
+ // src/utils/cell.ts
3751
+ import { getBorderStyleType, Tools } from "@univerjs/core";
3752
+ import { ptToPx, pxToPt } from "@univerjs/engine-render";
3753
+ // src/utils/util.ts
3754
+ function textTrim(x) {
3755
+ if (x.length === 0) {
3756
+ return x;
3757
+ }
3758
+ return x.replace(/^\s+|\s+$/gm, "");
3759
+ }
3760
+ // src/utils/cell.ts
3761
+ function handleDomToJson($dom) {
3762
+ var _loop = function(i) {
3763
+ var span = nodeList["".concat(i)];
3764
+ var str = void 0;
3765
+ if (span.nodeName === "#text") {
3766
+ var _span_textContent;
3767
+ str = (_span_textContent = span.textContent) !== null && _span_textContent !== void 0 ? _span_textContent : "";
3768
+ span = span.parentElement;
3769
+ } else {
3770
+ str = span.innerText;
3771
+ }
3772
+ var textStyle = handleStringToStyle(span);
3773
+ var spanTexts = splitSpanText(str);
3774
+ spanTexts.forEach(function(item) {
3775
+ var length = item.length;
3776
+ ed += length;
3777
+ st = ed - length;
3778
+ var sId = Tools.generateRandomId(6);
3779
+ textRuns.push({
3780
+ sId: sId,
3781
+ st: st,
3782
+ ed: ed - 1,
3783
+ ts: textStyle
3784
+ });
3785
+ });
3786
+ };
3787
+ var nodeList = $dom.childNodes;
3788
+ if (nodeList.length === 0) {
3789
+ return $dom.textContent;
3790
+ }
3791
+ if (nodeList[0].nodeName === "DIV") {
3792
+ nodeList = nodeList[0].childNodes;
3793
+ }
3794
+ if (nodeList.length === 1 && nodeList[0].nodeName === "#text") {
3795
+ return nodeList[0].textContent;
3796
+ }
3797
+ var textRuns = [];
3798
+ var st = 0;
3799
+ var ed = 0;
3800
+ var dataStream = $dom.textContent || "";
3801
+ dataStream += "\r\n";
3802
+ for(var i = 0; i < nodeList.length; i++)_loop(i);
3803
+ var blockId = Tools.generateRandomId(6);
3804
+ var p = {
3805
+ id: Tools.generateRandomId(6),
3806
+ body: {
3807
+ dataStream: dataStream,
3808
+ textRuns: textRuns
3809
+ },
3810
+ documentStyle: {}
3811
+ };
3812
+ return p;
3813
+ }
3814
+ function handleStringToStyle($dom) {
3815
+ var cssStyle = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
3816
+ var _$dom_style;
3817
+ var _$dom_style_cssText;
3818
+ var cssText = (_$dom_style_cssText = $dom === null || $dom === void 0 ? void 0 : (_$dom_style = $dom.style) === null || _$dom_style === void 0 ? void 0 : _$dom_style.cssText) !== null && _$dom_style_cssText !== void 0 ? _$dom_style_cssText : "";
3819
+ cssText += cssStyle;
3820
+ if (cssText.length === 0) {
3821
+ return {};
3822
+ }
3823
+ var cssTextArray = cssText.split(";");
3824
+ var styleList = {};
3825
+ var borderInfo = {
3826
+ t: "",
3827
+ r: "",
3828
+ b: "",
3829
+ l: ""
3830
+ };
3831
+ cssTextArray.forEach(function(s) {
3832
+ s = s.toLowerCase();
3833
+ var key = textTrim(s.substr(0, s.indexOf(":")));
3834
+ var value = textTrim(s.substr(s.indexOf(":") + 1));
3835
+ if (key === "font-weight") {
3836
+ if (value === "bold") {
3837
+ styleList.bl = 1;
3838
+ } else {
3839
+ styleList.bl = 0;
3840
+ }
3841
+ } else if (key === "font-style") {
3842
+ if (value === "italic") {
3843
+ styleList.it = 1;
3844
+ } else {
3845
+ styleList.it = 0;
3846
+ }
3847
+ } else if (key === "font-family") {
3848
+ styleList.ff = value;
3849
+ } else if (key === "font-size") {
3850
+ var fs = parseInt(value);
3851
+ if (cssText.indexOf("vertical-align") > -1 && (cssText.indexOf("sub") > -1 || cssText.indexOf("sup") > -1)) {
3852
+ fs *= 2;
3853
+ }
3854
+ if (value.indexOf("px") !== -1) {
3855
+ fs = pxToPt(parseInt(value));
3856
+ }
3857
+ styleList.fs = fs;
3858
+ } else if (key === "color") {
3859
+ styleList.cl = {
3860
+ rgb: value
3861
+ };
3862
+ } else if (key === "background" || key === "background-color") {
3863
+ styleList.bg = {
3864
+ rgb: value
3865
+ };
3866
+ } else if (key === "text-decoration-line") {
3867
+ if (value === "underline") {
3868
+ if (!styleList.ul) {
3869
+ styleList.ul = {
3870
+ s: 1
3871
+ };
3872
+ }
3873
+ styleList.ul.s = 1;
3874
+ } else if (value === "line-through") {
3875
+ if (!styleList.st) {
3876
+ styleList.st = {
3877
+ s: 1
3878
+ };
3879
+ }
3880
+ styleList.st.s = 1;
3881
+ } else if (value === "overline") {
3882
+ if (!styleList.ol) {
3883
+ styleList.ol = {
3884
+ s: 1
3885
+ };
3886
+ }
3887
+ styleList.ol.s = 1;
3888
+ }
3889
+ } else if (key === "text-decoration-color") {
3890
+ if (styleList.hasOwnProperty("ul")) {
3891
+ if (!styleList.ul) {
3892
+ styleList.ul = {
3893
+ s: 1,
3894
+ cl: {
3895
+ rgb: value
3896
+ }
3897
+ };
3898
+ }
3899
+ styleList.ul.cl = {
3900
+ rgb: value
3901
+ };
3902
+ }
3903
+ if (styleList.hasOwnProperty("st")) {
3904
+ if (!styleList.st) {
3905
+ styleList.st = {
3906
+ s: 1,
3907
+ cl: {
3908
+ rgb: value
3909
+ }
3910
+ };
3911
+ }
3912
+ styleList.st.cl = {
3913
+ rgb: value
3914
+ };
3915
+ }
3916
+ if (styleList.hasOwnProperty("ol")) {
3917
+ if (!styleList.ol) {
3918
+ styleList.ol = {
3919
+ s: 1,
3920
+ cl: {
3921
+ rgb: value
3922
+ }
3923
+ };
3924
+ }
3925
+ styleList.ol.cl = {
3926
+ rgb: value
3927
+ };
3928
+ }
3929
+ } else if (key === "text-decoration-style") {
3930
+ if (styleList.hasOwnProperty("ul")) {
3931
+ if (!styleList.ul) {
3932
+ styleList.ul = {
3933
+ s: 1,
3934
+ t: Number(value)
3935
+ };
3936
+ }
3937
+ styleList.ul.t = Number(value);
3938
+ }
3939
+ if (styleList.hasOwnProperty("st")) {
3940
+ if (!styleList.st) {
3941
+ styleList.st = {
3942
+ s: 1,
3943
+ t: Number(value)
3944
+ };
3945
+ }
3946
+ styleList.st.t = Number(value);
3947
+ }
3948
+ if (styleList.hasOwnProperty("ol")) {
3949
+ if (!styleList.ol) {
3950
+ styleList.ol = {
3951
+ s: 1,
3952
+ t: Number(value)
3953
+ };
3954
+ }
3955
+ styleList.ol.t = Number(value);
3956
+ }
3957
+ } else if (key === "text-decoration" || key === "univer-strike") {
3958
+ styleList.st = {
3959
+ s: 1
3960
+ };
3961
+ }
3962
+ if (key === "univer-underline") {
3963
+ styleList.ul = {
3964
+ s: 1
3965
+ };
3966
+ }
3967
+ if (key === "vertical-align") {
3968
+ if (value === "sub") {
3969
+ styleList.va = 1;
3970
+ } else if (value === "super") {
3971
+ styleList.va = 2;
3972
+ } else if (value === "top") {
3973
+ styleList.vt = 1;
3974
+ } else if (value === "middle") {
3975
+ styleList.vt = 2;
3976
+ } else if (value === "bottom") {
3977
+ styleList.vt = 3;
3978
+ } else {
3979
+ styleList.va = 0;
3980
+ }
3981
+ }
3982
+ if (key === "transform") {
3983
+ var values = value.split(")");
3984
+ var index = values.findIndex(function(item) {
3985
+ return item.includes("rotate");
3986
+ });
3987
+ if (index > -1) {
3988
+ var match = values[index].match(/\d+/g);
3989
+ var angle = 0;
3990
+ var ver = 0;
3991
+ if (match === null || match === void 0 ? void 0 : match.length) {
3992
+ angle = +match[0];
3993
+ }
3994
+ if ($dom === null || $dom === void 0 ? void 0 : $dom.dataset.vertical) {
3995
+ ver = +$dom.dataset.vertical;
3996
+ }
3997
+ styleList.tr = {
3998
+ a: angle,
3999
+ v: ver
4000
+ };
4001
+ }
4002
+ }
4003
+ if (key === "text-align") {
4004
+ if (value === "left") {
4005
+ styleList.ht = 1;
4006
+ } else if (value === "center") {
4007
+ styleList.ht = 2;
4008
+ } else if (value === "right") {
4009
+ styleList.ht = 3;
4010
+ } else if (value === "justify") {
4011
+ styleList.ht = 4;
4012
+ } else {
4013
+ styleList.ht = 0;
4014
+ }
4015
+ }
4016
+ if (key === "overflow-wrap" || key === "word-wrap") {
4017
+ if (value === "break-word") {
4018
+ styleList.tb = 3;
4019
+ }
4020
+ } else if (key === "text-overflow") {
4021
+ if (value === "clip") {
4022
+ styleList.tb = 2;
4023
+ }
4024
+ } else if (key === "text-break") {
4025
+ if (value === "overflow") {
4026
+ styleList.tb = 1;
4027
+ }
4028
+ }
4029
+ if (key === "border-color") {
4030
+ var colors = handleBorder(value, ")");
4031
+ if (!styleList.bd) {
4032
+ styleList.bd = {
4033
+ b: {
4034
+ cl: {
4035
+ rgb: "#000"
4036
+ },
4037
+ s: 0
4038
+ },
4039
+ t: {
4040
+ cl: {
4041
+ rgb: "#000"
4042
+ },
4043
+ s: 0
4044
+ },
4045
+ l: {
4046
+ cl: {
4047
+ rgb: "#000"
4048
+ },
4049
+ s: 0
4050
+ },
4051
+ r: {
4052
+ cl: {
4053
+ rgb: "#000"
4054
+ },
4055
+ s: 0
4056
+ }
4057
+ };
4058
+ for(var k in colors){
4059
+ styleList.bd[k].cl.rgb = colors[k];
4060
+ }
4061
+ } else {
4062
+ for(var k1 in colors){
4063
+ styleList.bd[k1].cl.rgb = colors[k1];
4064
+ }
4065
+ }
4066
+ }
4067
+ if (key === "border-width" || key === "border-style") {
4068
+ var width = handleBorder(value, " ");
4069
+ for(var k2 in width){
4070
+ borderInfo[k2] += " ".concat(width[k2]);
4071
+ }
4072
+ if (!styleList.bd) {
4073
+ styleList.bd = {
4074
+ b: {
4075
+ cl: {
4076
+ rgb: "#000"
4077
+ },
4078
+ s: getBorderStyleType(borderInfo.b)
4079
+ },
4080
+ t: {
4081
+ cl: {
4082
+ rgb: "#000"
4083
+ },
4084
+ s: getBorderStyleType(borderInfo.t)
4085
+ },
4086
+ l: {
4087
+ cl: {
4088
+ rgb: "#000"
4089
+ },
4090
+ s: getBorderStyleType(borderInfo.l)
4091
+ },
4092
+ r: {
4093
+ cl: {
4094
+ rgb: "#000"
4095
+ },
4096
+ s: getBorderStyleType(borderInfo.r)
4097
+ }
4098
+ };
4099
+ } else {
4100
+ styleList.bd.b.s = getBorderStyleType(borderInfo.b);
4101
+ styleList.bd.t.s = getBorderStyleType(borderInfo.t);
4102
+ styleList.bd.l.s = getBorderStyleType(borderInfo.l);
4103
+ styleList.bd.r.s = getBorderStyleType(borderInfo.r);
4104
+ }
4105
+ }
4106
+ if (key === "border-bottom" || key === "border-top" || key === "border-left" || key === "border-right" || key === "border") {
4107
+ if (!styleList.bd) {
4108
+ styleList.bd = {};
4109
+ }
4110
+ var arr = value.split(" ");
4111
+ var type = "".concat(arr[0], " ").concat(arr[1]);
4112
+ arr.splice(0, 2);
4113
+ var color = arr.join("");
4114
+ var obj = {
4115
+ cl: {
4116
+ rgb: color
4117
+ },
4118
+ s: getBorderStyleType(type)
4119
+ };
4120
+ if (key === "border-bottom") {
4121
+ styleList.bd.b = value === "none" ? null : obj;
4122
+ } else if (key === "border-top") {
4123
+ styleList.bd.t = value === "none" ? null : obj;
4124
+ } else if (key === "border-left") {
4125
+ styleList.bd.l = value === "none" ? null : obj;
4126
+ } else if (key === "border-right") {
4127
+ styleList.bd.r = value === "none" ? null : obj;
4128
+ } else if (key === "border") {
4129
+ styleList.bd = {
4130
+ r: value === "none" ? null : obj,
4131
+ t: value === "none" ? null : obj,
4132
+ b: value === "none" ? null : obj,
4133
+ l: value === "none" ? null : obj
4134
+ };
4135
+ }
4136
+ }
4137
+ });
4138
+ return styleList;
4139
+ }
4140
+ function handleBorder(border, param) {
4141
+ var arr;
4142
+ if (param === " ") {
4143
+ arr = border.trim().split(param);
4144
+ } else {
4145
+ arr = border.trim().split(param).slice(0, -1);
4146
+ }
4147
+ arr.forEach(function(item) {
4148
+ return "".concat(item.trim(), ")");
4149
+ });
4150
+ var obj = {};
4151
+ if (arr.length === 1) {
4152
+ obj = {
4153
+ t: arr[0],
4154
+ r: arr[0],
4155
+ b: arr[0],
4156
+ l: arr[0]
4157
+ };
4158
+ } else if (arr.length === 2) {
4159
+ obj = {
4160
+ t: arr[0],
4161
+ r: arr[1],
4162
+ b: arr[0],
4163
+ l: arr[1]
4164
+ };
4165
+ } else if (arr.length === 3) {
4166
+ obj = {
4167
+ t: arr[0],
4168
+ r: arr[1],
4169
+ b: arr[2],
4170
+ l: arr[1]
4171
+ };
4172
+ } else if (arr.length === 4) {
4173
+ obj = {
4174
+ t: arr[0],
4175
+ r: arr[1],
4176
+ b: arr[2],
4177
+ l: arr[3]
4178
+ };
4179
+ }
4180
+ return obj;
4181
+ }
4182
+ function splitSpanText(text) {
4183
+ if (text === "") return [
4184
+ text
4185
+ ];
4186
+ var regex = /(?:(\n+.+)|(.+))/g;
4187
+ var arr = text.match(regex);
4188
+ var arr1 = arr.map(function(item) {
4189
+ return item.replace(/\n/g, "\r\n");
4190
+ });
4191
+ return arr1;
4192
+ }
4193
+ function handleTableColgroup(table) {
4194
+ var content = document.createElement("DIV");
4195
+ var data = [];
4196
+ content.innerHTML = table;
4197
+ var colgroup = content.querySelectorAll("table col");
4198
+ if (!colgroup.length) return [];
4199
+ for(var i = 0; i < colgroup.length; i++){
4200
+ var col = colgroup[i];
4201
+ var colSpan = col.getAttribute("span");
4202
+ if (colSpan && +colSpan > 1) {
4203
+ for(var j = 0; j < +colSpan; j++){
4204
+ var width = getTdHeight(col.getAttribute("width"), 72);
4205
+ data.push(width);
4206
+ }
4207
+ } else {
4208
+ var width1 = getTdHeight(col.getAttribute("width"), 72);
4209
+ data.push(width1);
4210
+ }
4211
+ }
4212
+ return data;
4213
+ }
4214
+ function getTdHeight(height, defaultHeight) {
4215
+ if (!height) return defaultHeight;
4216
+ var firstHeight;
4217
+ if (height.includes("pt")) {
4218
+ firstHeight = ptToPx(parseFloat(height));
4219
+ } else if (height.includes("px")) {
4220
+ firstHeight = parseFloat(height);
4221
+ } else {
4222
+ firstHeight = parseFloat(height) * 72 / 96;
4223
+ }
4224
+ return firstHeight;
4225
+ }
4226
+ function handleTableRowGroup(table) {
4227
+ var content = document.createElement("DIV");
4228
+ var data = [];
4229
+ content.innerHTML = table;
4230
+ var rowGroup = content.querySelectorAll("table tr");
4231
+ if (!rowGroup.length) return [];
4232
+ for(var i = 0; i < rowGroup.length; i++){
4233
+ var row = rowGroup[i];
4234
+ var tds = row.querySelectorAll("td");
4235
+ var firstHeight = getTdHeight(tds[0].style.height, 19);
4236
+ for(var k = 0; k < tds.length; k++){
4237
+ var rowSpan = tds[k].getAttribute("rowSpan");
4238
+ if (rowSpan && +rowSpan > 1) {
4239
+ continue;
4240
+ }
4241
+ firstHeight = getTdHeight(tds[k].style.height, 19);
4242
+ break;
4243
+ }
4244
+ data.push(firstHeight);
4245
+ }
4246
+ return data;
4247
+ }
4248
+ function handelTableToJson(table) {
4249
+ var data = [];
4250
+ var content = document.createElement("DIV");
4251
+ content.innerHTML = table;
4252
+ data = new Array(content.querySelectorAll("table tr").length);
4253
+ if (!data.length) return [];
4254
+ var colLen = 0;
4255
+ var trs = content.querySelectorAll("table tr");
4256
+ var firstTds = trs[0].querySelectorAll("td");
4257
+ firstTds.forEach(function(item) {
4258
+ var colSpan = 0;
4259
+ var attr = item.getAttribute("colSpan");
4260
+ if (attr !== null) {
4261
+ colSpan = +attr;
4262
+ } else {
4263
+ colSpan = 1;
4264
+ }
4265
+ colLen += colSpan;
4266
+ });
4267
+ for(var i = 0; i < data.length; i++){
4268
+ data[i] = new Array(colLen);
4269
+ }
4270
+ var r = 0;
4271
+ trs.forEach(function(item) {
4272
+ var c = 0;
4273
+ item.querySelectorAll("td").forEach(function(td) {
4274
+ var cell = {};
4275
+ if (td.querySelectorAll("span").length || td.querySelectorAll("font").length) {
4276
+ var spanStyle = handleDomToJson(td);
4277
+ if (typeof spanStyle !== "string") {
4278
+ cell.p = spanStyle;
4279
+ }
4280
+ }
4281
+ var txt = td.innerText;
4282
+ if (txt.trim().length === 0) {
4283
+ cell.v = "";
4284
+ cell.m = "";
4285
+ } else {
4286
+ cell.v = txt;
4287
+ cell.m = txt;
4288
+ }
4289
+ var style = handleStringToStyle(td);
4290
+ if (Tools.isPlainObject(style)) {
4291
+ cell.s = style;
4292
+ }
4293
+ while(c < colLen && data[r][c] != null){
4294
+ c++;
4295
+ }
4296
+ if (c === colLen) {
4297
+ return;
4298
+ }
4299
+ if (data[r][c] == null) {
4300
+ data[r][c] = cell;
4301
+ var _Number;
4302
+ var rowSpan = (_Number = Number(td.getAttribute("rowSpan"))) !== null && _Number !== void 0 ? _Number : 1;
4303
+ var _Number1;
4304
+ var colSpan = (_Number1 = Number(td.getAttribute("colSpan"))) !== null && _Number1 !== void 0 ? _Number1 : 1;
4305
+ if (rowSpan > 1 || colSpan > 1) {
4306
+ var first = {
4307
+ rs: +rowSpan - 1,
4308
+ cs: +colSpan - 1,
4309
+ r: r,
4310
+ c: c
4311
+ };
4312
+ data[r][c].mc = first;
4313
+ for(var rp = 0; rp < rowSpan; rp++){
4314
+ for(var cp = 0; cp < colSpan; cp++){
4315
+ if (rp === 0 && cp === 0) {
4316
+ continue;
4317
+ }
4318
+ data[r + rp][c + cp] = {
4319
+ mc: null
4320
+ };
4321
+ }
4322
+ }
4323
+ }
4324
+ }
4325
+ c++;
4326
+ });
4327
+ r++;
4328
+ });
4329
+ return data;
4330
+ }
4331
+ function handlePlainToJson(plain) {
4332
+ var data = [];
4333
+ var content = document.createElement("DIV");
4334
+ content.innerHTML = plain;
4335
+ var dataChe = plain.replace(/\r/g, "");
4336
+ var che = dataChe.split("\n");
4337
+ var colCheLen = che[0].split(" ").length;
4338
+ for(var i = 0; i < che.length; i++){
4339
+ if (che[i].split(" ").length < colCheLen) {
4340
+ continue;
4341
+ }
4342
+ data.push(che[i].split(" "));
4343
+ }
4344
+ for(var i1 = 0; i1 < data.length; i1++){
4345
+ for(var j = 0; j < data[i1].length; j++){
4346
+ if (data[i1][j].length) {
4347
+ data[i1][j] = {
4348
+ v: data[i1][j] || "",
4349
+ m: data[i1][j] || ""
4350
+ };
4351
+ } else {
4352
+ data[i1][j] = null;
4353
+ }
4354
+ }
4355
+ }
4356
+ return data;
4357
+ }
4358
+ function handleTableMergeData(data, selection) {
4359
+ var copyH = data.length;
4360
+ var copyC = data[0].length;
4361
+ var minH = 0;
4362
+ var maxH = minH + copyH - 1;
4363
+ var minC = 0;
4364
+ var maxC = minC + copyC - 1;
4365
+ if (selection) {
4366
+ minH = selection.startRow;
4367
+ maxH = minH + copyH - 1;
4368
+ minC = selection.startColumn;
4369
+ maxC = minC + copyC - 1;
4370
+ }
4371
+ var mergeData = [];
4372
+ for(var i = 0; i < data.length; i++){
4373
+ for(var j = 0; j < data[i].length; j++){
4374
+ if (data[i][j] && typeof data[i][j] === "object" && "mc" in data[i][j]) {
4375
+ if (data[i][j].mc) {
4376
+ var mc = data[i][j].mc;
4377
+ var startRow = mc.r + minH;
4378
+ var endRow = startRow + mc.rs;
4379
+ var startColumn = mc.c + minC;
4380
+ var endColumn = startColumn + mc.cs;
4381
+ mergeData.push({
4382
+ startRow: startRow,
4383
+ endRow: endRow,
4384
+ startColumn: startColumn,
4385
+ endColumn: endColumn
4386
+ });
4387
+ delete data[i][j].mc;
4388
+ } else {
4389
+ data[i][j] = null;
4390
+ }
4391
+ }
4392
+ }
4393
+ }
4394
+ return {
4395
+ data: data,
4396
+ mergeData: mergeData
4397
+ };
4398
+ }
4399
+ function handelExcelToJson(html) {
4400
+ var _content_querySelector;
4401
+ var data = [];
4402
+ var content = document.createElement("html");
4403
+ content.innerHTML = html;
4404
+ var styleText = (_content_querySelector = content.querySelector("style")) === null || _content_querySelector === void 0 ? void 0 : _content_querySelector.innerText;
4405
+ if (!styleText) return;
4406
+ var excelStyle = getStyles(styleText);
4407
+ data = new Array(content.querySelectorAll("table tr").length);
4408
+ if (!data.length) return [];
4409
+ var colLen = 0;
4410
+ var trs = content.querySelectorAll("table tr");
4411
+ var firstTds = trs[0].querySelectorAll("td");
4412
+ firstTds.forEach(function(item) {
4413
+ var colSpan = 0;
4414
+ var attr = item.getAttribute("colSpan");
4415
+ if (attr !== null) {
4416
+ colSpan = +attr;
4417
+ } else {
4418
+ colSpan = 1;
4419
+ }
4420
+ colLen += colSpan;
4421
+ });
4422
+ for(var i = 0; i < data.length; i++){
4423
+ data[i] = new Array(colLen);
4424
+ }
4425
+ var r = 0;
4426
+ trs.forEach(function(item) {
4427
+ var c = 0;
4428
+ item.querySelectorAll("td").forEach(function(td) {
4429
+ var cell = {};
4430
+ if (td.querySelectorAll("span").length || td.querySelectorAll("font").length) {
4431
+ var spanStyle = handleDomToJson(td);
4432
+ if (typeof spanStyle !== "string") {
4433
+ cell.p = spanStyle;
4434
+ }
4435
+ }
4436
+ var txt = td.innerText;
4437
+ if (txt.trim().length === 0) {
4438
+ cell.v = "";
4439
+ cell.m = "";
4440
+ } else {
4441
+ cell.v = txt;
4442
+ cell.m = txt;
4443
+ }
4444
+ var cssText = "";
4445
+ for(var attr in excelStyle){
4446
+ if (td.classList.contains(attr)) {
4447
+ cssText += excelStyle[attr];
4448
+ }
4449
+ }
4450
+ var style = handleStringToStyle(td, cssText);
4451
+ if (Tools.isPlainObject(style)) {
4452
+ cell.s = style;
4453
+ }
4454
+ while(c < colLen && data[r][c] != null){
4455
+ c++;
4456
+ }
4457
+ if (c === colLen) {
4458
+ return;
4459
+ }
4460
+ if (data[r][c] == null) {
4461
+ data[r][c] = cell;
4462
+ var _Number;
4463
+ var rowSpan = (_Number = Number(td.getAttribute("rowSpan"))) !== null && _Number !== void 0 ? _Number : 1;
4464
+ var _Number1;
4465
+ var colSpan = (_Number1 = Number(td.getAttribute("colSpan"))) !== null && _Number1 !== void 0 ? _Number1 : 1;
4466
+ if (rowSpan > 1 || colSpan > 1) {
4467
+ var first = {
4468
+ rs: +rowSpan - 1,
4469
+ cs: +colSpan - 1,
4470
+ r: r,
4471
+ c: c
4472
+ };
4473
+ data[r][c].mc = first;
4474
+ for(var rp = 0; rp < rowSpan; rp++){
4475
+ for(var cp = 0; cp < colSpan; cp++){
4476
+ if (rp === 0 && cp === 0) {
4477
+ continue;
4478
+ }
4479
+ data[r + rp][c + cp] = {
4480
+ mc: null
4481
+ };
4482
+ }
4483
+ }
4484
+ }
4485
+ }
4486
+ c++;
4487
+ });
4488
+ r++;
4489
+ });
4490
+ return data;
4491
+ }
4492
+ function getStyles(styleText) {
4493
+ var output = {};
4494
+ var string = styleText.replaceAll("<!--", "").replaceAll("-->", "").trim();
4495
+ var style = string === null || string === void 0 ? void 0 : string.replaceAll(" ", "").replaceAll("\n", "").split("}");
4496
+ for(var i = 0; i < style.length; i++){
4497
+ if (!style[i]) continue;
4498
+ var attr = style[i].split("{")[0].trim();
4499
+ if (attr.includes(".")) {
4500
+ attr = attr.slice(1);
4501
+ }
4502
+ var value = style[i].split("{")[1].trim();
4503
+ output[attr] = value;
4504
+ }
4505
+ return output;
4506
+ }
4507
+ export { BrowserClipboardService, ComponentManager, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DesktopBeforeCloseService, DesktopConfirmService, DesktopContextMenuService, DesktopDialogService, DesktopMenuService, DesktopMessageService, DesktopNotificationService, DesktopPlatformService, DesktopShortcutService, DesktopSidebarService, DesktopUIPart, HTML_CLIPBOARD_MIME_TYPE, IBeforeCloseService, IClipboardInterfaceService, IConfirmService, IContextMenuService, IDialogService, IMenuService, IMessageService, INotificationService, IPlatformService, IShortcutService, ISidebarService, IUIController, KeyCode, Menu, MenuGroup, MenuItemType, MenuPosition, MetaKeys, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PasteShortcutItem, RedoShortcutItem, SharedController, ShortcutExperienceService, UIPlugin, UndoShortcutItem, ZIndexManager, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, splitSpanText, textTrim, useObservable };