@univerjs/sheets-note-ui 0.25.0 → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +161 -144
- package/lib/es/index.js +162 -144
- package/lib/index.js +162 -144
- package/lib/types/controllers/components.controller.d.ts +24 -0
- package/lib/types/controllers/{sheets-note-ui.controller.d.ts → ui.controller.d.ts} +2 -4
- package/lib/types/index.d.ts +0 -1
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/menu/note.menu.d.ts +5 -4
- package/lib/types/services/sheets-note-popup.service.d.ts +1 -4
- package/lib/types/views/Note.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
package/lib/es/index.js
CHANGED
|
@@ -5,13 +5,13 @@ import { SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCom
|
|
|
5
5
|
import { BehaviorSubject, combineLatest, debounceTime, map, of, switchMap } from "rxjs";
|
|
6
6
|
import { CellPopupManagerService, HoverManagerService, IEditorBridgeService, SheetSkeletonManagerService, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
7
7
|
import { debounceTime as debounceTime$1 } from "rxjs/operators";
|
|
8
|
-
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IZenZoneService, MenuItemType, getMenuHiddenObservable, useConfigValue, useDebounceFn, useDependency } from "@univerjs/ui";
|
|
9
8
|
import { AddNoteIcon, DeleteNoteIcon, HideNoteIcon } from "@univerjs/icons";
|
|
9
|
+
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IconManager, MenuItemType, getMenuHiddenObservable, useConfigValue, useDebounceFn, useDependency } from "@univerjs/ui";
|
|
10
10
|
import { Textarea, clsx } from "@univerjs/design";
|
|
11
11
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
12
12
|
import { jsx } from "react/jsx-runtime";
|
|
13
13
|
|
|
14
|
-
//#region \0@oxc-project+runtime@0.
|
|
14
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
15
15
|
function __decorateParam(paramIndex, decorator) {
|
|
16
16
|
return function(target, key) {
|
|
17
17
|
decorator(target, key, paramIndex);
|
|
@@ -19,7 +19,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
//#endregion
|
|
22
|
-
//#region \0@oxc-project+runtime@0.
|
|
22
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
23
23
|
function __decorate(decorators, target, key, desc) {
|
|
24
24
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25
25
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -104,7 +104,7 @@ SheetsCellContentController = __decorate([
|
|
|
104
104
|
const SHEET_NOTE_COMPONENT = "SHEET_NOTE_COMPONENT";
|
|
105
105
|
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region \0@oxc-project+runtime@0.
|
|
107
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
108
108
|
function _typeof(o) {
|
|
109
109
|
"@babel/helpers - typeof";
|
|
110
110
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -115,7 +115,7 @@ function _typeof(o) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
//#endregion
|
|
118
|
-
//#region \0@oxc-project+runtime@0.
|
|
118
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
119
119
|
function toPrimitive(t, r) {
|
|
120
120
|
if ("object" != _typeof(t) || !t) return t;
|
|
121
121
|
var e = t[Symbol.toPrimitive];
|
|
@@ -128,14 +128,14 @@ function toPrimitive(t, r) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
//#endregion
|
|
131
|
-
//#region \0@oxc-project+runtime@0.
|
|
131
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
132
132
|
function toPropertyKey(t) {
|
|
133
133
|
var i = toPrimitive(t, "string");
|
|
134
134
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
//#endregion
|
|
138
|
-
//#region \0@oxc-project+runtime@0.
|
|
138
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
139
139
|
function _defineProperty(e, r, t) {
|
|
140
140
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
141
141
|
value: t,
|
|
@@ -151,24 +151,17 @@ let SheetsNotePopupService = class SheetsNotePopupService extends Disposable {
|
|
|
151
151
|
get activePopup() {
|
|
152
152
|
return this._activePopup;
|
|
153
153
|
}
|
|
154
|
-
constructor(
|
|
154
|
+
constructor(_cellPopupManagerService) {
|
|
155
155
|
super();
|
|
156
|
-
this._zenZoneService = _zenZoneService;
|
|
157
156
|
this._cellPopupManagerService = _cellPopupManagerService;
|
|
158
157
|
_defineProperty(this, "_lastPopup", null);
|
|
159
158
|
_defineProperty(this, "_activePopup", void 0);
|
|
160
159
|
_defineProperty(this, "_activePopup$", new BehaviorSubject(null));
|
|
161
160
|
_defineProperty(this, "activePopup$", this._activePopup$.asObservable());
|
|
162
|
-
this._initZenVisible();
|
|
163
161
|
this.disposeWithMe(() => {
|
|
164
162
|
this._activePopup$.complete();
|
|
165
163
|
});
|
|
166
164
|
}
|
|
167
|
-
_initZenVisible() {
|
|
168
|
-
this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
|
|
169
|
-
if (visible) this.hidePopup();
|
|
170
|
-
}));
|
|
171
|
-
}
|
|
172
165
|
dispose() {
|
|
173
166
|
super.dispose();
|
|
174
167
|
this.hidePopup();
|
|
@@ -182,7 +175,6 @@ let SheetsNotePopupService = class SheetsNotePopupService extends Disposable {
|
|
|
182
175
|
return;
|
|
183
176
|
}
|
|
184
177
|
if (this._lastPopup) this._lastPopup.dispose();
|
|
185
|
-
if (this._zenZoneService.visible) return;
|
|
186
178
|
this._activePopup = location;
|
|
187
179
|
this._activePopup$.next(location);
|
|
188
180
|
const popupDisposable = this._cellPopupManagerService.showPopup({
|
|
@@ -224,7 +216,7 @@ let SheetsNotePopupService = class SheetsNotePopupService extends Disposable {
|
|
|
224
216
|
this._activePopup$.next(this._activePopup);
|
|
225
217
|
}
|
|
226
218
|
};
|
|
227
|
-
SheetsNotePopupService = __decorate([__decorateParam(0,
|
|
219
|
+
SheetsNotePopupService = __decorate([__decorateParam(0, Inject(CellPopupManagerService))], SheetsNotePopupService);
|
|
228
220
|
|
|
229
221
|
//#endregion
|
|
230
222
|
//#region src/controllers/sheets-note-popup.controller.ts
|
|
@@ -344,7 +336,7 @@ SheetsNotePopupController = __decorate([
|
|
|
344
336
|
//#endregion
|
|
345
337
|
//#region package.json
|
|
346
338
|
var name = "@univerjs/sheets-note-ui";
|
|
347
|
-
var version = "0.
|
|
339
|
+
var version = "1.0.0-alpha.0";
|
|
348
340
|
|
|
349
341
|
//#endregion
|
|
350
342
|
//#region src/config/config.ts
|
|
@@ -352,6 +344,152 @@ const SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY = "sheets-note-ui.config";
|
|
|
352
344
|
const configSymbol = Symbol(SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY);
|
|
353
345
|
const defaultPluginConfig = {};
|
|
354
346
|
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/views/Note.tsx
|
|
349
|
+
const SheetsNote = (props) => {
|
|
350
|
+
var _popup$extraProps;
|
|
351
|
+
const { popup } = props;
|
|
352
|
+
const noteModel = useDependency(SheetsNoteModel);
|
|
353
|
+
const localeService = useDependency(LocaleService);
|
|
354
|
+
const renderManagerService = useDependency(IRenderManagerService);
|
|
355
|
+
const notePopupService = useDependency(SheetsNotePopupService);
|
|
356
|
+
const config = useConfigValue(SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY);
|
|
357
|
+
const activePopup = (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.location;
|
|
358
|
+
if (!activePopup) {
|
|
359
|
+
console.error("Popup extraProps or location is undefined.");
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
const textareaRef = useRef(null);
|
|
363
|
+
const currentRender = renderManagerService.getRenderById(activePopup.unitId);
|
|
364
|
+
const [note, setNote] = useState(null);
|
|
365
|
+
useEffect(() => {
|
|
366
|
+
var _ref, _note$width, _config$defaultNoteSi, _ref2, _note$height, _config$defaultNoteSi2;
|
|
367
|
+
const { unitId, subUnitId, row, col } = activePopup;
|
|
368
|
+
const note = noteModel.getNote(unitId, subUnitId, {
|
|
369
|
+
row,
|
|
370
|
+
col
|
|
371
|
+
});
|
|
372
|
+
const width = (_ref = (_note$width = note === null || note === void 0 ? void 0 : note.width) !== null && _note$width !== void 0 ? _note$width : config === null || config === void 0 || (_config$defaultNoteSi = config.defaultNoteSize) === null || _config$defaultNoteSi === void 0 ? void 0 : _config$defaultNoteSi.width) !== null && _ref !== void 0 ? _ref : 160;
|
|
373
|
+
const height = (_ref2 = (_note$height = note === null || note === void 0 ? void 0 : note.height) !== null && _note$height !== void 0 ? _note$height : config === null || config === void 0 || (_config$defaultNoteSi2 = config.defaultNoteSize) === null || _config$defaultNoteSi2 === void 0 ? void 0 : _config$defaultNoteSi2.height) !== null && _ref2 !== void 0 ? _ref2 : 72;
|
|
374
|
+
if (!note) {
|
|
375
|
+
const initNote = {
|
|
376
|
+
id: generateRandomId(6),
|
|
377
|
+
width,
|
|
378
|
+
height,
|
|
379
|
+
note: ""
|
|
380
|
+
};
|
|
381
|
+
setNote(initNote);
|
|
382
|
+
updateNote(initNote);
|
|
383
|
+
} else setNote(note);
|
|
384
|
+
if (textareaRef.current) {
|
|
385
|
+
textareaRef.current.style.width = `${width}px`;
|
|
386
|
+
textareaRef.current.style.height = `${height}px`;
|
|
387
|
+
}
|
|
388
|
+
}, [activePopup, textareaRef]);
|
|
389
|
+
useEffect(() => {
|
|
390
|
+
if (!activePopup || activePopup.temp || !activePopup.trigger) return;
|
|
391
|
+
if (!textareaRef.current) return;
|
|
392
|
+
const focusId = requestAnimationFrame(() => {
|
|
393
|
+
var _textareaRef$current;
|
|
394
|
+
(_textareaRef$current = textareaRef.current) === null || _textareaRef$current === void 0 || _textareaRef$current.focus();
|
|
395
|
+
});
|
|
396
|
+
return () => cancelAnimationFrame(focusId);
|
|
397
|
+
}, [activePopup]);
|
|
398
|
+
const commandService = useDependency(ICommandService);
|
|
399
|
+
const updateNote = useDebounceFn((newNote) => {
|
|
400
|
+
if (!activePopup) return;
|
|
401
|
+
const { unitId, subUnitId, row, col } = activePopup;
|
|
402
|
+
if (!commandService.syncExecuteCommand(SheetUpdateNoteCommand.id, {
|
|
403
|
+
unitId,
|
|
404
|
+
sheetId: subUnitId,
|
|
405
|
+
row,
|
|
406
|
+
col,
|
|
407
|
+
note: newNote
|
|
408
|
+
})) {
|
|
409
|
+
const oldNote = noteModel.getNote(unitId, subUnitId, {
|
|
410
|
+
noteId: newNote.id,
|
|
411
|
+
row,
|
|
412
|
+
col
|
|
413
|
+
});
|
|
414
|
+
if (oldNote) setNote(oldNote);
|
|
415
|
+
else notePopupService.hidePopup(true);
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
const handleNoteChange = useCallback((value) => {
|
|
419
|
+
if (!note) return;
|
|
420
|
+
if (value === note.note) return;
|
|
421
|
+
const newNote = {
|
|
422
|
+
...note,
|
|
423
|
+
note: value
|
|
424
|
+
};
|
|
425
|
+
setNote(newNote);
|
|
426
|
+
updateNote(newNote);
|
|
427
|
+
}, [note]);
|
|
428
|
+
const handleResize = useCallback((width, height) => {
|
|
429
|
+
if (!note) return;
|
|
430
|
+
if (width === note.width && height === note.height) return;
|
|
431
|
+
const newNote = {
|
|
432
|
+
...note,
|
|
433
|
+
width,
|
|
434
|
+
height
|
|
435
|
+
};
|
|
436
|
+
setNote(newNote);
|
|
437
|
+
updateNote(newNote);
|
|
438
|
+
}, [note]);
|
|
439
|
+
return /* @__PURE__ */ jsx(Textarea, {
|
|
440
|
+
ref: textareaRef,
|
|
441
|
+
"data-u-comp": "note-textarea",
|
|
442
|
+
className: clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),
|
|
443
|
+
value: note === null || note === void 0 ? void 0 : note.note,
|
|
444
|
+
placeholder: localeService.t("sheets-note-ui.note.placeholder"),
|
|
445
|
+
onResize: handleResize,
|
|
446
|
+
onValueChange: handleNoteChange,
|
|
447
|
+
onWheel: (e) => {
|
|
448
|
+
if (document.activeElement !== textareaRef.current) currentRender.engine.getCanvasElement().dispatchEvent(new WheelEvent(e.type, e.nativeEvent));
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/controllers/components.controller.ts
|
|
455
|
+
/**
|
|
456
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
457
|
+
*
|
|
458
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
459
|
+
* you may not use this file except in compliance with the License.
|
|
460
|
+
* You may obtain a copy of the License at
|
|
461
|
+
*
|
|
462
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
463
|
+
*
|
|
464
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
465
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
466
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
467
|
+
* See the License for the specific language governing permissions and
|
|
468
|
+
* limitations under the License.
|
|
469
|
+
*/
|
|
470
|
+
let ComponentsController = class ComponentsController extends Disposable {
|
|
471
|
+
constructor(_componentManager, _iconManager) {
|
|
472
|
+
super();
|
|
473
|
+
this._componentManager = _componentManager;
|
|
474
|
+
this._iconManager = _iconManager;
|
|
475
|
+
this._registerComponents();
|
|
476
|
+
this._registerIcons();
|
|
477
|
+
}
|
|
478
|
+
_registerComponents() {
|
|
479
|
+
[[SHEET_NOTE_COMPONENT, SheetsNote]].forEach(([key, comp]) => {
|
|
480
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
_registerIcons() {
|
|
484
|
+
this.disposeWithMe(this._iconManager.register({
|
|
485
|
+
AddNoteIcon,
|
|
486
|
+
DeleteNoteIcon,
|
|
487
|
+
HideNoteIcon
|
|
488
|
+
}));
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
492
|
+
|
|
355
493
|
//#endregion
|
|
356
494
|
//#region src/controllers/sheets-note-attachment.controller.ts
|
|
357
495
|
let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extends Disposable {
|
|
@@ -565,113 +703,7 @@ const menuSchema = { [ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS
|
|
|
565
703
|
} } };
|
|
566
704
|
|
|
567
705
|
//#endregion
|
|
568
|
-
//#region src/
|
|
569
|
-
const SheetsNote = (props) => {
|
|
570
|
-
var _popup$extraProps;
|
|
571
|
-
const { popup } = props;
|
|
572
|
-
const noteModel = useDependency(SheetsNoteModel);
|
|
573
|
-
const localeService = useDependency(LocaleService);
|
|
574
|
-
const renderManagerService = useDependency(IRenderManagerService);
|
|
575
|
-
const notePopupService = useDependency(SheetsNotePopupService);
|
|
576
|
-
const config = useConfigValue(SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY);
|
|
577
|
-
const activePopup = (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.location;
|
|
578
|
-
if (!activePopup) {
|
|
579
|
-
console.error("Popup extraProps or location is undefined.");
|
|
580
|
-
return null;
|
|
581
|
-
}
|
|
582
|
-
const textareaRef = useRef(null);
|
|
583
|
-
const currentRender = renderManagerService.getRenderById(activePopup.unitId);
|
|
584
|
-
const [note, setNote] = useState(null);
|
|
585
|
-
useEffect(() => {
|
|
586
|
-
var _ref, _note$width, _config$defaultNoteSi, _ref2, _note$height, _config$defaultNoteSi2;
|
|
587
|
-
const { unitId, subUnitId, row, col } = activePopup;
|
|
588
|
-
const note = noteModel.getNote(unitId, subUnitId, {
|
|
589
|
-
row,
|
|
590
|
-
col
|
|
591
|
-
});
|
|
592
|
-
const width = (_ref = (_note$width = note === null || note === void 0 ? void 0 : note.width) !== null && _note$width !== void 0 ? _note$width : config === null || config === void 0 || (_config$defaultNoteSi = config.defaultNoteSize) === null || _config$defaultNoteSi === void 0 ? void 0 : _config$defaultNoteSi.width) !== null && _ref !== void 0 ? _ref : 160;
|
|
593
|
-
const height = (_ref2 = (_note$height = note === null || note === void 0 ? void 0 : note.height) !== null && _note$height !== void 0 ? _note$height : config === null || config === void 0 || (_config$defaultNoteSi2 = config.defaultNoteSize) === null || _config$defaultNoteSi2 === void 0 ? void 0 : _config$defaultNoteSi2.height) !== null && _ref2 !== void 0 ? _ref2 : 72;
|
|
594
|
-
if (!note) {
|
|
595
|
-
const initNote = {
|
|
596
|
-
id: generateRandomId(6),
|
|
597
|
-
width,
|
|
598
|
-
height,
|
|
599
|
-
note: ""
|
|
600
|
-
};
|
|
601
|
-
setNote(initNote);
|
|
602
|
-
updateNote(initNote);
|
|
603
|
-
} else setNote(note);
|
|
604
|
-
if (textareaRef.current) {
|
|
605
|
-
textareaRef.current.style.width = `${width}px`;
|
|
606
|
-
textareaRef.current.style.height = `${height}px`;
|
|
607
|
-
}
|
|
608
|
-
}, [activePopup, textareaRef]);
|
|
609
|
-
useEffect(() => {
|
|
610
|
-
if (!activePopup || activePopup.temp || !activePopup.trigger) return;
|
|
611
|
-
if (!textareaRef.current) return;
|
|
612
|
-
const focusId = requestAnimationFrame(() => {
|
|
613
|
-
var _textareaRef$current;
|
|
614
|
-
(_textareaRef$current = textareaRef.current) === null || _textareaRef$current === void 0 || _textareaRef$current.focus();
|
|
615
|
-
});
|
|
616
|
-
return () => cancelAnimationFrame(focusId);
|
|
617
|
-
}, [activePopup]);
|
|
618
|
-
const commandService = useDependency(ICommandService);
|
|
619
|
-
const updateNote = useDebounceFn((newNote) => {
|
|
620
|
-
if (!activePopup) return;
|
|
621
|
-
const { unitId, subUnitId, row, col } = activePopup;
|
|
622
|
-
if (!commandService.syncExecuteCommand(SheetUpdateNoteCommand.id, {
|
|
623
|
-
unitId,
|
|
624
|
-
sheetId: subUnitId,
|
|
625
|
-
row,
|
|
626
|
-
col,
|
|
627
|
-
note: newNote
|
|
628
|
-
})) {
|
|
629
|
-
const oldNote = noteModel.getNote(unitId, subUnitId, {
|
|
630
|
-
noteId: newNote.id,
|
|
631
|
-
row,
|
|
632
|
-
col
|
|
633
|
-
});
|
|
634
|
-
if (oldNote) setNote(oldNote);
|
|
635
|
-
else notePopupService.hidePopup(true);
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
const handleNoteChange = useCallback((value) => {
|
|
639
|
-
if (!note) return;
|
|
640
|
-
if (value === note.note) return;
|
|
641
|
-
const newNote = {
|
|
642
|
-
...note,
|
|
643
|
-
note: value
|
|
644
|
-
};
|
|
645
|
-
setNote(newNote);
|
|
646
|
-
updateNote(newNote);
|
|
647
|
-
}, [note]);
|
|
648
|
-
const handleResize = useCallback((width, height) => {
|
|
649
|
-
if (!note) return;
|
|
650
|
-
if (width === note.width && height === note.height) return;
|
|
651
|
-
const newNote = {
|
|
652
|
-
...note,
|
|
653
|
-
width,
|
|
654
|
-
height
|
|
655
|
-
};
|
|
656
|
-
setNote(newNote);
|
|
657
|
-
updateNote(newNote);
|
|
658
|
-
}, [note]);
|
|
659
|
-
return /* @__PURE__ */ jsx(Textarea, {
|
|
660
|
-
ref: textareaRef,
|
|
661
|
-
"data-u-comp": "note-textarea",
|
|
662
|
-
className: clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),
|
|
663
|
-
value: note === null || note === void 0 ? void 0 : note.note,
|
|
664
|
-
placeholder: localeService.t("sheets-note-ui.note.placeholder"),
|
|
665
|
-
onResize: handleResize,
|
|
666
|
-
onValueChange: handleNoteChange,
|
|
667
|
-
onWheel: (e) => {
|
|
668
|
-
if (document.activeElement !== textareaRef.current) currentRender.engine.getCanvasElement().dispatchEvent(new WheelEvent(e.type, e.nativeEvent));
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
//#endregion
|
|
674
|
-
//#region src/controllers/sheets-note-ui.controller.ts
|
|
706
|
+
//#region src/controllers/ui.controller.ts
|
|
675
707
|
/**
|
|
676
708
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
677
709
|
*
|
|
@@ -688,25 +720,13 @@ const SheetsNote = (props) => {
|
|
|
688
720
|
* limitations under the License.
|
|
689
721
|
*/
|
|
690
722
|
let SheetsNoteUIController = class SheetsNoteUIController extends Disposable {
|
|
691
|
-
constructor(
|
|
723
|
+
constructor(_menuManagerService, _commandService) {
|
|
692
724
|
super();
|
|
693
|
-
this._componentManager = _componentManager;
|
|
694
725
|
this._menuManagerService = _menuManagerService;
|
|
695
726
|
this._commandService = _commandService;
|
|
696
|
-
this._initComponents();
|
|
697
727
|
this._initMenu();
|
|
698
728
|
this._initCommands();
|
|
699
729
|
}
|
|
700
|
-
_initComponents() {
|
|
701
|
-
[
|
|
702
|
-
[SHEET_NOTE_COMPONENT, SheetsNote],
|
|
703
|
-
["AddNoteIcon", AddNoteIcon],
|
|
704
|
-
["DeleteNoteIcon", DeleteNoteIcon],
|
|
705
|
-
["HideNoteIcon", HideNoteIcon]
|
|
706
|
-
].forEach(([key, comp]) => {
|
|
707
|
-
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
730
|
_initMenu() {
|
|
711
731
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
712
732
|
}
|
|
@@ -714,11 +734,7 @@ let SheetsNoteUIController = class SheetsNoteUIController extends Disposable {
|
|
|
714
734
|
this._commandService.registerCommand(AddNotePopupOperation);
|
|
715
735
|
}
|
|
716
736
|
};
|
|
717
|
-
SheetsNoteUIController = __decorate([
|
|
718
|
-
__decorateParam(0, Inject(ComponentManager)),
|
|
719
|
-
__decorateParam(1, Inject(IMenuManagerService)),
|
|
720
|
-
__decorateParam(2, ICommandService)
|
|
721
|
-
], SheetsNoteUIController);
|
|
737
|
+
SheetsNoteUIController = __decorate([__decorateParam(0, Inject(IMenuManagerService)), __decorateParam(1, ICommandService)], SheetsNoteUIController);
|
|
722
738
|
|
|
723
739
|
//#endregion
|
|
724
740
|
//#region src/plugin.ts
|
|
@@ -733,6 +749,8 @@ let UniverSheetsNoteUIPlugin = class UniverSheetsNoteUIPlugin extends Plugin {
|
|
|
733
749
|
this._configService.setConfig(SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY, rest);
|
|
734
750
|
}
|
|
735
751
|
onStarting() {
|
|
752
|
+
this._injector.add([ComponentsController]);
|
|
753
|
+
this._injector.get(ComponentsController);
|
|
736
754
|
[
|
|
737
755
|
[SheetsNotePopupService],
|
|
738
756
|
[SheetsCellContentController],
|
|
@@ -761,4 +779,4 @@ UniverSheetsNoteUIPlugin = __decorate([
|
|
|
761
779
|
], UniverSheetsNoteUIPlugin);
|
|
762
780
|
|
|
763
781
|
//#endregion
|
|
764
|
-
export { SheetsCellContentController,
|
|
782
|
+
export { SheetsCellContentController, SheetsNotePopupController, SheetsNotePopupService, UniverSheetsNoteUIPlugin };
|