@univerjs/sheets-note-ui 1.0.0-alpha.7 → 1.0.0-alpha.8
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 +15 -13
- package/lib/es/index.js +19 -17
- package/lib/index.js +19 -17
- package/lib/umd/index.js +1 -1
- package/package.json +12 -10
package/lib/cjs/index.js
CHANGED
|
@@ -12,7 +12,7 @@ let _univerjs_design = require("@univerjs/design");
|
|
|
12
12
|
let react = require("react");
|
|
13
13
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
14
|
|
|
15
|
-
//#region \0@oxc-project+runtime@0.
|
|
15
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
16
16
|
function __decorateParam(paramIndex, decorator) {
|
|
17
17
|
return function(target, key) {
|
|
18
18
|
decorator(target, key, paramIndex);
|
|
@@ -20,7 +20,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region \0@oxc-project+runtime@0.
|
|
23
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
24
24
|
function __decorate(decorators, target, key, desc) {
|
|
25
25
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
26
26
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -70,7 +70,7 @@ let SheetsCellContentController = class SheetsCellContentController extends _uni
|
|
|
70
70
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
71
71
|
if (!workbook) return;
|
|
72
72
|
const unitId = workbook.getUnitId();
|
|
73
|
-
const currentRender = this._renderManagerService.
|
|
73
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
74
74
|
currentRender === null || currentRender === void 0 || (_currentRender$mainCo = currentRender.mainComponent) === null || _currentRender$mainCo === void 0 || _currentRender$mainCo.makeForceDirty();
|
|
75
75
|
};
|
|
76
76
|
this.disposeWithMe(this._sheetsNoteModel.change$.pipe((0, rxjs.debounceTime)(16)).subscribe(() => {
|
|
@@ -105,7 +105,7 @@ SheetsCellContentController = __decorate([
|
|
|
105
105
|
const SHEET_NOTE_COMPONENT = "SHEET_NOTE_COMPONENT";
|
|
106
106
|
|
|
107
107
|
//#endregion
|
|
108
|
-
//#region \0@oxc-project+runtime@0.
|
|
108
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
109
109
|
function _typeof(o) {
|
|
110
110
|
"@babel/helpers - typeof";
|
|
111
111
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -116,7 +116,7 @@ function _typeof(o) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
//#endregion
|
|
119
|
-
//#region \0@oxc-project+runtime@0.
|
|
119
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
120
120
|
function toPrimitive(t, r) {
|
|
121
121
|
if ("object" != _typeof(t) || !t) return t;
|
|
122
122
|
var e = t[Symbol.toPrimitive];
|
|
@@ -129,14 +129,14 @@ function toPrimitive(t, r) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
//#endregion
|
|
132
|
-
//#region \0@oxc-project+runtime@0.
|
|
132
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
133
133
|
function toPropertyKey(t) {
|
|
134
134
|
var i = toPrimitive(t, "string");
|
|
135
135
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
//#endregion
|
|
139
|
-
//#region \0@oxc-project+runtime@0.
|
|
139
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
140
140
|
function _defineProperty(e, r, t) {
|
|
141
141
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
142
142
|
value: t,
|
|
@@ -239,7 +239,7 @@ let SheetsNotePopupController = class SheetsNotePopupController extends _univerj
|
|
|
239
239
|
_handleSelectionChange(selections, unitId, subUnitId) {
|
|
240
240
|
var _selections$, _render$with$getSkele, _range$rangeType;
|
|
241
241
|
const range = (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.range;
|
|
242
|
-
const render = this._renderManagerService.
|
|
242
|
+
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
243
243
|
const skeleton = render === null || render === void 0 || (_render$with$getSkele = render.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele === void 0 ? void 0 : _render$with$getSkele.skeleton;
|
|
244
244
|
if (!skeleton) return;
|
|
245
245
|
if (!range) return;
|
|
@@ -282,7 +282,7 @@ let SheetsNotePopupController = class SheetsNotePopupController extends _univerj
|
|
|
282
282
|
var _render$with$getSkele2;
|
|
283
283
|
if (!(cell === null || cell === void 0 ? void 0 : cell.location)) return;
|
|
284
284
|
const { unitId, subUnitId, row, col } = cell.location;
|
|
285
|
-
const render = this._renderManagerService.
|
|
285
|
+
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
286
286
|
const skeleton = render === null || render === void 0 || (_render$with$getSkele2 = render.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele2 === void 0 ? void 0 : _render$with$getSkele2.skeleton;
|
|
287
287
|
let targetRow = row;
|
|
288
288
|
let targetCol = col;
|
|
@@ -437,7 +437,7 @@ const menuSchema = { [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_
|
|
|
437
437
|
//#endregion
|
|
438
438
|
//#region package.json
|
|
439
439
|
var name = "@univerjs/sheets-note-ui";
|
|
440
|
-
var version = "1.0.0-alpha.
|
|
440
|
+
var version = "1.0.0-alpha.8";
|
|
441
441
|
|
|
442
442
|
//#endregion
|
|
443
443
|
//#region src/config/config.ts
|
|
@@ -464,7 +464,7 @@ function SheetsNoteContent({ activePopup }) {
|
|
|
464
464
|
const config = (0, _univerjs_ui.useConfigValue)(SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY);
|
|
465
465
|
const textareaRef = (0, react.useRef)(null);
|
|
466
466
|
const initialWidthRef = (0, react.useRef)(null);
|
|
467
|
-
const currentRender = renderManagerService.
|
|
467
|
+
const currentRender = renderManagerService.getRenderUnitById(activePopup.unitId);
|
|
468
468
|
const [note, setNote] = (0, react.useState)(null);
|
|
469
469
|
const applyResizeOffset = (0, react.useCallback)((width) => {
|
|
470
470
|
const textarea = textareaRef.current;
|
|
@@ -684,7 +684,9 @@ let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extend
|
|
|
684
684
|
}
|
|
685
685
|
case "update": {
|
|
686
686
|
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
687
|
-
|
|
687
|
+
const row = newNote ? newNote.row : oldNote.row;
|
|
688
|
+
const col = newNote ? newNote.col : oldNote.col;
|
|
689
|
+
handleNote(unitId, subUnitId, row, col, newNote);
|
|
688
690
|
break;
|
|
689
691
|
}
|
|
690
692
|
default: break;
|
|
@@ -788,7 +790,7 @@ _defineProperty(UniverSheetsNoteUIPlugin, "packageName", name);
|
|
|
788
790
|
_defineProperty(UniverSheetsNoteUIPlugin, "version", version);
|
|
789
791
|
_defineProperty(UniverSheetsNoteUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
790
792
|
UniverSheetsNoteUIPlugin = __decorate([
|
|
791
|
-
(0, _univerjs_core.DependentOn)(_univerjs_sheets_note.UniverSheetsNotePlugin),
|
|
793
|
+
(0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_ui.UniverUIPlugin, _univerjs_sheets_note.UniverSheetsNotePlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
|
|
792
794
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
793
795
|
__decorateParam(2, _univerjs_core.IConfigService)
|
|
794
796
|
], UniverSheetsNoteUIPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, RANGE_TYPE, Rectangle, UniverInstanceType, generateRandomId, merge, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
3
|
-
import { INTERCEPTOR_POINT, SheetInterceptorService, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, getSheetCommandTarget } from "@univerjs/sheets";
|
|
2
|
+
import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
3
|
+
import { INTERCEPTOR_POINT, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorksheetEditPermission, getSheetCommandTarget } from "@univerjs/sheets";
|
|
4
4
|
import { SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, UniverSheetsNotePlugin } from "@univerjs/sheets-note";
|
|
5
5
|
import { BehaviorSubject, combineLatest, debounceTime, map, of, switchMap } from "rxjs";
|
|
6
|
-
import { CellPopupManagerService, HoverManagerService, IEditorBridgeService, SheetSkeletonManagerService, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
6
|
+
import { CellPopupManagerService, HoverManagerService, IEditorBridgeService, SheetSkeletonManagerService, UniverSheetsUIPlugin, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
7
7
|
import { debounceTime as debounceTime$1 } from "rxjs/operators";
|
|
8
|
-
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IconManager, MenuItemType, getMenuHiddenObservable, useConfigValue, useDebounceFn, useDependency } from "@univerjs/ui";
|
|
8
|
+
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IconManager, MenuItemType, UniverUIPlugin, getMenuHiddenObservable, useConfigValue, useDebounceFn, useDependency } from "@univerjs/ui";
|
|
9
9
|
import { AddNoteIcon, DeleteNoteIcon, HideNoteIcon } from "@univerjs/icons";
|
|
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.140.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.140.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);
|
|
@@ -69,7 +69,7 @@ let SheetsCellContentController = class SheetsCellContentController extends Disp
|
|
|
69
69
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
70
70
|
if (!workbook) return;
|
|
71
71
|
const unitId = workbook.getUnitId();
|
|
72
|
-
const currentRender = this._renderManagerService.
|
|
72
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
73
73
|
currentRender === null || currentRender === void 0 || (_currentRender$mainCo = currentRender.mainComponent) === null || _currentRender$mainCo === void 0 || _currentRender$mainCo.makeForceDirty();
|
|
74
74
|
};
|
|
75
75
|
this.disposeWithMe(this._sheetsNoteModel.change$.pipe(debounceTime(16)).subscribe(() => {
|
|
@@ -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.140.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.140.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.140.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.140.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,
|
|
@@ -238,7 +238,7 @@ let SheetsNotePopupController = class SheetsNotePopupController extends Disposab
|
|
|
238
238
|
_handleSelectionChange(selections, unitId, subUnitId) {
|
|
239
239
|
var _selections$, _render$with$getSkele, _range$rangeType;
|
|
240
240
|
const range = (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.range;
|
|
241
|
-
const render = this._renderManagerService.
|
|
241
|
+
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
242
242
|
const skeleton = render === null || render === void 0 || (_render$with$getSkele = render.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele === void 0 ? void 0 : _render$with$getSkele.skeleton;
|
|
243
243
|
if (!skeleton) return;
|
|
244
244
|
if (!range) return;
|
|
@@ -281,7 +281,7 @@ let SheetsNotePopupController = class SheetsNotePopupController extends Disposab
|
|
|
281
281
|
var _render$with$getSkele2;
|
|
282
282
|
if (!(cell === null || cell === void 0 ? void 0 : cell.location)) return;
|
|
283
283
|
const { unitId, subUnitId, row, col } = cell.location;
|
|
284
|
-
const render = this._renderManagerService.
|
|
284
|
+
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
285
285
|
const skeleton = render === null || render === void 0 || (_render$with$getSkele2 = render.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele2 === void 0 ? void 0 : _render$with$getSkele2.skeleton;
|
|
286
286
|
let targetRow = row;
|
|
287
287
|
let targetCol = col;
|
|
@@ -436,7 +436,7 @@ const menuSchema = { [ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS
|
|
|
436
436
|
//#endregion
|
|
437
437
|
//#region package.json
|
|
438
438
|
var name = "@univerjs/sheets-note-ui";
|
|
439
|
-
var version = "1.0.0-alpha.
|
|
439
|
+
var version = "1.0.0-alpha.8";
|
|
440
440
|
|
|
441
441
|
//#endregion
|
|
442
442
|
//#region src/config/config.ts
|
|
@@ -463,7 +463,7 @@ function SheetsNoteContent({ activePopup }) {
|
|
|
463
463
|
const config = useConfigValue(SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY);
|
|
464
464
|
const textareaRef = useRef(null);
|
|
465
465
|
const initialWidthRef = useRef(null);
|
|
466
|
-
const currentRender = renderManagerService.
|
|
466
|
+
const currentRender = renderManagerService.getRenderUnitById(activePopup.unitId);
|
|
467
467
|
const [note, setNote] = useState(null);
|
|
468
468
|
const applyResizeOffset = useCallback((width) => {
|
|
469
469
|
const textarea = textareaRef.current;
|
|
@@ -683,7 +683,9 @@ let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extend
|
|
|
683
683
|
}
|
|
684
684
|
case "update": {
|
|
685
685
|
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
686
|
-
|
|
686
|
+
const row = newNote ? newNote.row : oldNote.row;
|
|
687
|
+
const col = newNote ? newNote.col : oldNote.col;
|
|
688
|
+
handleNote(unitId, subUnitId, row, col, newNote);
|
|
687
689
|
break;
|
|
688
690
|
}
|
|
689
691
|
default: break;
|
|
@@ -787,7 +789,7 @@ _defineProperty(UniverSheetsNoteUIPlugin, "packageName", name);
|
|
|
787
789
|
_defineProperty(UniverSheetsNoteUIPlugin, "version", version);
|
|
788
790
|
_defineProperty(UniverSheetsNoteUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
789
791
|
UniverSheetsNoteUIPlugin = __decorate([
|
|
790
|
-
DependentOn(UniverSheetsNotePlugin),
|
|
792
|
+
DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsNotePlugin, UniverSheetsUIPlugin),
|
|
791
793
|
__decorateParam(1, Inject(Injector)),
|
|
792
794
|
__decorateParam(2, IConfigService)
|
|
793
795
|
], UniverSheetsNoteUIPlugin);
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, RANGE_TYPE, Rectangle, UniverInstanceType, generateRandomId, merge, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
3
|
-
import { INTERCEPTOR_POINT, SheetInterceptorService, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, getSheetCommandTarget } from "@univerjs/sheets";
|
|
2
|
+
import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
3
|
+
import { INTERCEPTOR_POINT, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorksheetEditPermission, getSheetCommandTarget } from "@univerjs/sheets";
|
|
4
4
|
import { SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, UniverSheetsNotePlugin } from "@univerjs/sheets-note";
|
|
5
5
|
import { BehaviorSubject, combineLatest, debounceTime, map, of, switchMap } from "rxjs";
|
|
6
|
-
import { CellPopupManagerService, HoverManagerService, IEditorBridgeService, SheetSkeletonManagerService, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
6
|
+
import { CellPopupManagerService, HoverManagerService, IEditorBridgeService, SheetSkeletonManagerService, UniverSheetsUIPlugin, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
7
7
|
import { debounceTime as debounceTime$1 } from "rxjs/operators";
|
|
8
|
-
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IconManager, MenuItemType, getMenuHiddenObservable, useConfigValue, useDebounceFn, useDependency } from "@univerjs/ui";
|
|
8
|
+
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IconManager, MenuItemType, UniverUIPlugin, getMenuHiddenObservable, useConfigValue, useDebounceFn, useDependency } from "@univerjs/ui";
|
|
9
9
|
import { AddNoteIcon, DeleteNoteIcon, HideNoteIcon } from "@univerjs/icons";
|
|
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.140.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.140.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);
|
|
@@ -69,7 +69,7 @@ let SheetsCellContentController = class SheetsCellContentController extends Disp
|
|
|
69
69
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
70
70
|
if (!workbook) return;
|
|
71
71
|
const unitId = workbook.getUnitId();
|
|
72
|
-
const currentRender = this._renderManagerService.
|
|
72
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
73
73
|
currentRender === null || currentRender === void 0 || (_currentRender$mainCo = currentRender.mainComponent) === null || _currentRender$mainCo === void 0 || _currentRender$mainCo.makeForceDirty();
|
|
74
74
|
};
|
|
75
75
|
this.disposeWithMe(this._sheetsNoteModel.change$.pipe(debounceTime(16)).subscribe(() => {
|
|
@@ -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.140.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.140.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.140.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.140.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,
|
|
@@ -238,7 +238,7 @@ let SheetsNotePopupController = class SheetsNotePopupController extends Disposab
|
|
|
238
238
|
_handleSelectionChange(selections, unitId, subUnitId) {
|
|
239
239
|
var _selections$, _render$with$getSkele, _range$rangeType;
|
|
240
240
|
const range = (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.range;
|
|
241
|
-
const render = this._renderManagerService.
|
|
241
|
+
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
242
242
|
const skeleton = render === null || render === void 0 || (_render$with$getSkele = render.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele === void 0 ? void 0 : _render$with$getSkele.skeleton;
|
|
243
243
|
if (!skeleton) return;
|
|
244
244
|
if (!range) return;
|
|
@@ -281,7 +281,7 @@ let SheetsNotePopupController = class SheetsNotePopupController extends Disposab
|
|
|
281
281
|
var _render$with$getSkele2;
|
|
282
282
|
if (!(cell === null || cell === void 0 ? void 0 : cell.location)) return;
|
|
283
283
|
const { unitId, subUnitId, row, col } = cell.location;
|
|
284
|
-
const render = this._renderManagerService.
|
|
284
|
+
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
285
285
|
const skeleton = render === null || render === void 0 || (_render$with$getSkele2 = render.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele2 === void 0 ? void 0 : _render$with$getSkele2.skeleton;
|
|
286
286
|
let targetRow = row;
|
|
287
287
|
let targetCol = col;
|
|
@@ -436,7 +436,7 @@ const menuSchema = { [ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS
|
|
|
436
436
|
//#endregion
|
|
437
437
|
//#region package.json
|
|
438
438
|
var name = "@univerjs/sheets-note-ui";
|
|
439
|
-
var version = "1.0.0-alpha.
|
|
439
|
+
var version = "1.0.0-alpha.8";
|
|
440
440
|
|
|
441
441
|
//#endregion
|
|
442
442
|
//#region src/config/config.ts
|
|
@@ -463,7 +463,7 @@ function SheetsNoteContent({ activePopup }) {
|
|
|
463
463
|
const config = useConfigValue(SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY);
|
|
464
464
|
const textareaRef = useRef(null);
|
|
465
465
|
const initialWidthRef = useRef(null);
|
|
466
|
-
const currentRender = renderManagerService.
|
|
466
|
+
const currentRender = renderManagerService.getRenderUnitById(activePopup.unitId);
|
|
467
467
|
const [note, setNote] = useState(null);
|
|
468
468
|
const applyResizeOffset = useCallback((width) => {
|
|
469
469
|
const textarea = textareaRef.current;
|
|
@@ -683,7 +683,9 @@ let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extend
|
|
|
683
683
|
}
|
|
684
684
|
case "update": {
|
|
685
685
|
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
686
|
-
|
|
686
|
+
const row = newNote ? newNote.row : oldNote.row;
|
|
687
|
+
const col = newNote ? newNote.col : oldNote.col;
|
|
688
|
+
handleNote(unitId, subUnitId, row, col, newNote);
|
|
687
689
|
break;
|
|
688
690
|
}
|
|
689
691
|
default: break;
|
|
@@ -787,7 +789,7 @@ _defineProperty(UniverSheetsNoteUIPlugin, "packageName", name);
|
|
|
787
789
|
_defineProperty(UniverSheetsNoteUIPlugin, "version", version);
|
|
788
790
|
_defineProperty(UniverSheetsNoteUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
789
791
|
UniverSheetsNoteUIPlugin = __decorate([
|
|
790
|
-
DependentOn(UniverSheetsNotePlugin),
|
|
792
|
+
DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsNotePlugin, UniverSheetsUIPlugin),
|
|
791
793
|
__decorateParam(1, Inject(Injector)),
|
|
792
794
|
__decorateParam(2, IConfigService)
|
|
793
795
|
], UniverSheetsNoteUIPlugin);
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-note"),require("rxjs"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/ui"),require("react"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-note`,`rxjs`,`@univerjs/sheets-ui`,`rxjs/operators`,`@univerjs/ui`,`react`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNoteUi={},e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsNote,e.rxjs,e.UniverSheetsUi,e.rxjs.operators,e.UniverUi,e.React,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function f(e,t){return function(n,r){t(n,r,e)}}function p(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let m=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=t,this._renderManagerService=n,this._univerInstanceService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t;return this._sheetsNoteModel.getNote(a,o,{row:r,col:i})?((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:`#FFBD37`,size:6}},n(e)):n(e)},priority:100}))}_initSkeletonChange(){let e=()=>{var e;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=n.getUnitId(),i=this._renderManagerService.getRenderById(r);i==null||(e=i.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe((0,a.debounceTime)(16)).subscribe(()=>{e()}))}};m=p([f(0,(0,t.Inject)(r.SheetInterceptorService)),f(1,(0,t.Inject)(i.SheetsNoteModel)),f(2,n.IRenderManagerService),f(3,t.IUniverInstanceService)],m);let h=`SHEET_NOTE_COMPONENT`;function g(e){"@babel/helpers - typeof";return g=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let b=class extends t.Disposable{get activePopup(){return this._activePopup}constructor(e){super(),this._cellPopupManagerService=e,y(this,`_lastPopup`,null),y(this,`_activePopup`,void 0),y(this,`_activePopup$`,new a.BehaviorSubject(null)),y(this,`activePopup$`,this._activePopup$.asObservable()),this.disposeWithMe(()=>{this._activePopup$.complete()})}dispose(){super.dispose(),this.hidePopup()}showPopup(e,n){var r;let{row:i,col:a,unitId:o,subUnitId:s}=e;if(this._activePopup&&i===this._activePopup.row&&a===this._activePopup.col&&o===this._activePopup.unitId&&s===((r=this.activePopup)==null?void 0:r.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}this._lastPopup&&this._lastPopup.dispose(),this._activePopup=e,this._activePopup$.next(e);let c=this._cellPopupManagerService.showPopup({unitId:o,subUnitId:s,row:i,col:a},{componentKey:h,onClickOutside:()=>{this.hidePopup()},direction:`horizontal`,extraProps:{location:e},priority:3});if(!c)throw Error(`[SheetsNotePopupService]: cannot show popup!`);let l=new t.DisposableCollection;l.add(c),l.add({dispose:()=>{n==null||n()}}),this._lastPopup=l}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};b=p([f(0,(0,t.Inject)(o.CellPopupManagerService))],b);let x=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetsNotePopupService=e,this._sheetsNoteModel=t,this._sheetSelectionService=n,this._editorBridgeService=r,this._renderManagerService=i,this._hoverManagerService=a,y(this,`_isSwitchingSheet`,!1),this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,n,r){var i,a,s;let c=(i=e[0])==null?void 0:i.range,l=this._renderManagerService.getRenderById(n),u=l==null||(a=l.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:a.skeleton;if(!u||!c)return;let d=u.getCellWithCoordByIndex(c.startRow,c.startColumn);if((((s=c.rangeType)==null?t.RANGE_TYPE.NORMAL:s)!==t.RANGE_TYPE.NORMAL||c.endColumn-c.startColumn>0||c.endRow-c.startRow>0)&&!((d.isMerged||d.isMergedMainCell)&&t.Rectangle.equals(d.mergeInfo,c))){this._sheetsNotePopupService.hidePopup();return}let f=d.actualRow,p=d.actualColumn,m=this._sheetsNoteModel.getNote(n,r,{row:f,col:p});m!=null&&m.show||(m?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:m.id,row:f,col:p}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;let t=this._sheetSelectionService.currentSelectionParam;t&&this._handleSelectionChange(e,t.unitId,t.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{var t;if(!(e!=null&&e.location))return;let{unitId:n,subUnitId:r,row:i,col:a}=e.location,s=this._renderManagerService.getRenderById(n),c=s==null||(t=s.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:t.skeleton,l=i,u=a,d=this._sheetsNoteModel.getNote(n,r,{row:l,col:u});if(!d&&c){let{startRow:e,endRow:t,startColumn:o,endColumn:s}=c.getCellWithCoordByIndex(i,a).mergeInfo;if(e!==t||o!==s){let i=this._sheetsNoteModel.getSheetNotes(n,r);if(i){for(let[n,r]of i)if(r.row>=e&&r.row<=t&&r.col>=o&&r.col<=s){d=r,l=r.row,u=r.col;break}}}}d!=null&&d.show||(d?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:d.id,row:l,col:u,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;let{unitId:t,subUnitId:n,noteId:r,row:i,col:a}=this._sheetsNotePopupService.activePopup,{oldNote:o,newNote:s}=e;s===null&&e.unitId===t&&e.subUnitId===n&&(o!=null&&o.id&&o.id===r||(o==null?void 0:o.row)===i&&o.col===a)&&this._sheetsNotePopupService.hidePopup(!0)}))}};x=p([f(0,(0,t.Inject)(b)),f(1,(0,t.Inject)(i.SheetsNoteModel)),f(2,(0,t.Inject)(r.SheetsSelectionsService)),f(3,o.IEditorBridgeService),f(4,n.IRenderManagerService),f(5,(0,t.Inject)(o.HoverManagerService))],x);let S={id:`sheet.operation.add-note-popup`,type:t.CommandType.OPERATION,handler:async(e,n)=>{var i;let a=e.get(r.SheetsSelectionsService),o=e.get(b),s=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;let c=s.getActiveSheet(),l=a.getCurrentLastSelection();if(!(l!=null&&l.primary))return!1;let{primary:u}=l;return o.showPopup({unitId:s.getUnitId(),subUnitId:c.getSheetId(),row:u.actualRow,col:u.actualColumn,temp:!1,trigger:(i=n==null?void 0:n.trigger)==null?`add-note`:i}),!0}};function C(e){let n=e.get(r.SheetsSelectionsService),o=e.get(t.IUniverInstanceService);return n.selectionMoveEnd$.pipe((0,a.map)(()=>{let t=n.getCurrentLastSelection();if(!(t!=null&&t.primary))return!1;let a=(0,r.getSheetCommandTarget)(o);if(!a)return!1;let{actualColumn:s,actualRow:c}=t.primary;return!!e.get(i.SheetsNoteModel).getNote(a.unitId,a.subUnitId,{row:c,col:s})}))}function w(e){return{id:S.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.addNote`,icon:`AddNoteIcon`,hidden$:(0,a.combineLatest)([(0,c.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),C(e)]).pipe((0,a.map)(([e,t])=>e||t)),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetEditPermission]}),commandId:S.id}}function T(e){return{id:i.SheetDeleteNoteCommand.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.deleteNote`,icon:`DeleteNoteIcon`,hidden$:C(e).pipe((0,a.map)(e=>!e)),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetEditPermission]})}}function E(e){return{id:i.SheetToggleNotePopupCommand.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.toggleNote`,icon:`HideNoteIcon`,hidden$:C(e).pipe((0,a.map)(e=>!e))}}let D={[c.ContextMenuPosition.MAIN_AREA]:{[c.ContextMenuGroup.OTHERS]:{order:0,[S.id]:{order:0,menuItemFactory:w},[i.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:T},[i.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:E}}}};var O=`@univerjs/sheets-note-ui`,k=`1.0.0-alpha.7`;let A=`sheets-note-ui.config`,j={};function M({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,l.useRef)(`_${I()}`);return N(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function N(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...P(e,n,i),...r},(F(e,n).children||[]).map((r,a)=>N(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function P(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function F(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function I(){return Math.random().toString(36).substring(2,8)}M.displayName=`UniverIcon`;let L={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z`}}]},R=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`add-note-icon`,ref:t,icon:L}))});R.displayName=`AddNoteIcon`;let z={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z`}}]},B=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`delete-note-icon`,ref:t,icon:z}))});B.displayName=`DeleteNoteIcon`;let V={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z`}}]},H=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`hide-note-icon`,ref:t,icon:V}))});H.displayName=`HideNoteIcon`;let U=e=>{var t;let n=(t=e.popup.extraProps)==null?void 0:t.location;return n?(0,d.jsx)(W,{activePopup:n}):(console.error(`Popup extraProps or location is undefined.`),null)};function W({activePopup:e}){let r=(0,c.useDependency)(i.SheetsNoteModel),a=(0,c.useDependency)(t.LocaleService),o=(0,c.useDependency)(n.IRenderManagerService),s=(0,c.useDependency)(b),f=(0,c.useConfigValue)(A),p=(0,l.useRef)(null),m=(0,l.useRef)(null),h=o.getRenderById(e.unitId),[g,_]=(0,l.useState)(null),v=(0,l.useCallback)(e=>{let t=p.current;if(t)if(a.getDirection()===`rtl`&&m.current!=null){let n=m.current-e;t.style.transform=n?`translateX(${n}px)`:``}else t.style.transform=``},[a]);(0,l.useEffect)(()=>{var n,i,a,o,s,c;let{unitId:l,subUnitId:u,row:d,col:h}=e,g=r.getNote(l,u,{row:d,col:h}),v=(n=(i=g==null?void 0:g.width)==null?f==null||(a=f.defaultNoteSize)==null?void 0:a.width:i)==null?160:n,y=(o=(s=g==null?void 0:g.height)==null?f==null||(c=f.defaultNoteSize)==null?void 0:c.height:s)==null?72:o;if(g)_(g);else{let e={id:(0,t.generateRandomId)(6),width:v,height:y,note:``};_(e),x(e)}p.current&&(m.current=v,p.current.style.width=`${v}px`,p.current.style.height=`${y}px`,p.current.style.transform=``)},[e,p]),(0,l.useEffect)(()=>{if(!e||e.temp||!e.trigger||!p.current)return;let t=requestAnimationFrame(()=>{var e;(e=p.current)==null||e.focus()});return()=>cancelAnimationFrame(t)},[e]);let y=(0,c.useDependency)(t.ICommandService),x=(0,c.useDebounceFn)(t=>{if(!e)return;let{unitId:n,subUnitId:a,row:o,col:c}=e;if(!y.syncExecuteCommand(i.SheetUpdateNoteCommand.id,{unitId:n,sheetId:a,row:o,col:c,note:t})){let e=r.getNote(n,a,{noteId:t.id,row:o,col:c});e?_(e):s.hidePopup(!0)}}),S=(0,l.useCallback)(e=>{if(!g||e===g.note)return;let t={...g,note:e};_(t),x(t)},[g]),C=(0,l.useCallback)((e,t)=>{if(!g||(v(e),e===g.width&&t===g.height))return;let n={...g,width:e,height:t};_(n),x(n)},[v,g]);return(0,d.jsx)(u.Textarea,{ref:p,"data-u-comp":`note-textarea`,className:(0,u.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`),value:g==null?void 0:g.note,placeholder:a.t(`sheets-note-ui.note.placeholder`),onResize:C,onValueChange:S,onWheel:e=>{document.activeElement!==p.current&&h.engine.getCanvasElement().dispatchEvent(new WheelEvent(e.type,e.nativeEvent))}})}let G=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[h,U]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddNoteIcon:R,DeleteNoteIcon:B,HideNoteIcon:H}))}};G=p([f(0,(0,t.Inject)(c.ComponentManager)),f(1,(0,t.Inject)(c.IconManager))],G);let K=class extends t.Disposable{constructor(e,n,r,i){super(),this._sheetsNoteModel=e,this._univerInstanceService=n,this._cellPopupManagerService=r,this._sheetsNotePopupService=i,y(this,`_noteMatrix`,new t.ObjectMatrix),this._initNoteChangeListener()}_showPopup(e,t,n,r){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:t,row:n,col:r},{componentKey:h,direction:`horizontal`,extraProps:{location:{unitId:e,subUnitId:t,row:n,col:r}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((e,t,n)=>{n.dispose()})}_initSheet(e,n){var r;this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new t.ObjectMatrix;let i=(e,t,n,r,i)=>{let a=this._noteMatrix,o=a.getValue(n,r);if(i!=null&&i.show){if(!o){let i=this._showPopup(e,t,n,r);i&&a.setValue(n,r,i)}}else o&&(o.dispose(),a.realDeleteValue(n,r))};return(r=this._sheetsNoteModel.getSheetNotes(e,n))==null||r.forEach(t=>{i(e,n,t.row,t.col,t)}),this._sheetsNoteModel.change$.subscribe(t=>{if(!(t.unitId!==e||t.subUnitId!==n))switch(t.type){case`ref`:{let{unitId:e,subUnitId:n,oldNote:r,newNote:i}=t;if(!i.show)return;let a=this._noteMatrix,{row:o,col:s}=r,{row:c,col:l}=i,u=a.getValue(o,s);u&&(u.dispose(),a.realDeleteValue(o,s));let d=this._showPopup(e,n,c,l);d&&a.setValue(c,l,d);break}case`update`:{let{unitId:e,subUnitId:n,oldNote:r,newNote:a}=t;i(e,n,a?a.row:r.row,a?a.col:r.col,a);break}default:break}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,a.switchMap)(e=>{var t;return(t=e==null?void 0:e.activeSheet$)==null?(0,a.of)(null):t})).subscribe(e=>{if(e){let t=this._initSheet(e.getUnitId(),e.getSheetId());return()=>{t.unsubscribe()}}else this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new t.ObjectMatrix}))}};K=p([f(0,(0,t.Inject)(i.SheetsNoteModel)),f(1,(0,t.Inject)(t.IUniverInstanceService)),f(2,(0,t.Inject)(o.CellPopupManagerService)),f(3,(0,t.Inject)(b))],K);let q=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._commandService=t,this._initMenu(),this._initCommands()}_initMenu(){this._menuManagerService.mergeMenu(D)}_initCommands(){this._commandService.registerCommand(S)}};q=p([f(0,(0,t.Inject)(c.IMenuManagerService)),f(1,t.ICommandService)],q);let J=class extends t.Plugin{constructor(e=j,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},j,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(A,a)}onStarting(){this._injector.add([G]),this._injector.get(G),[[b],[m],[x],[q],[K]].forEach(e=>{this._injector.add(e)})}onReady(){(0,t.touchDependencies)(this._injector,[[q],[m]])}onRendered(){(0,t.touchDependencies)(this._injector,[[x],[K]])}};y(J,`pluginName`,`SHEET_NOTE_UI_PLUGIN`),y(J,`packageName`,O),y(J,`version`,k),y(J,`type`,t.UniverInstanceType.UNIVER_SHEET),J=p([(0,t.DependentOn)(i.UniverSheetsNotePlugin),f(1,(0,t.Inject)(t.Injector)),f(2,t.IConfigService)],J),Object.defineProperty(e,"SheetsCellContentController",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SheetsNotePopupController",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"SheetsNotePopupService",{enumerable:!0,get:function(){return b}}),e.SheetsNoteUIMenuSchema=D,Object.defineProperty(e,"UniverSheetsNoteUIPlugin",{enumerable:!0,get:function(){return J}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-note"),require("rxjs"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/ui"),require("react"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-note`,`rxjs`,`@univerjs/sheets-ui`,`rxjs/operators`,`@univerjs/ui`,`react`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNoteUi={},e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsNote,e.rxjs,e.UniverSheetsUi,e.rxjs.operators,e.UniverUi,e.React,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function f(e,t){return function(n,r){t(n,r,e)}}function p(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let m=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=t,this._renderManagerService=n,this._univerInstanceService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t;return this._sheetsNoteModel.getNote(a,o,{row:r,col:i})?((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:`#FFBD37`,size:6}},n(e)):n(e)},priority:100}))}_initSkeletonChange(){let e=()=>{var e;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=n.getUnitId(),i=this._renderManagerService.getRenderUnitById(r);i==null||(e=i.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe((0,a.debounceTime)(16)).subscribe(()=>{e()}))}};m=p([f(0,(0,t.Inject)(r.SheetInterceptorService)),f(1,(0,t.Inject)(i.SheetsNoteModel)),f(2,n.IRenderManagerService),f(3,t.IUniverInstanceService)],m);let h=`SHEET_NOTE_COMPONENT`;function g(e){"@babel/helpers - typeof";return g=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let b=class extends t.Disposable{get activePopup(){return this._activePopup}constructor(e){super(),this._cellPopupManagerService=e,y(this,`_lastPopup`,null),y(this,`_activePopup`,void 0),y(this,`_activePopup$`,new a.BehaviorSubject(null)),y(this,`activePopup$`,this._activePopup$.asObservable()),this.disposeWithMe(()=>{this._activePopup$.complete()})}dispose(){super.dispose(),this.hidePopup()}showPopup(e,n){var r;let{row:i,col:a,unitId:o,subUnitId:s}=e;if(this._activePopup&&i===this._activePopup.row&&a===this._activePopup.col&&o===this._activePopup.unitId&&s===((r=this.activePopup)==null?void 0:r.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}this._lastPopup&&this._lastPopup.dispose(),this._activePopup=e,this._activePopup$.next(e);let c=this._cellPopupManagerService.showPopup({unitId:o,subUnitId:s,row:i,col:a},{componentKey:h,onClickOutside:()=>{this.hidePopup()},direction:`horizontal`,extraProps:{location:e},priority:3});if(!c)throw Error(`[SheetsNotePopupService]: cannot show popup!`);let l=new t.DisposableCollection;l.add(c),l.add({dispose:()=>{n==null||n()}}),this._lastPopup=l}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};b=p([f(0,(0,t.Inject)(o.CellPopupManagerService))],b);let x=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetsNotePopupService=e,this._sheetsNoteModel=t,this._sheetSelectionService=n,this._editorBridgeService=r,this._renderManagerService=i,this._hoverManagerService=a,y(this,`_isSwitchingSheet`,!1),this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,n,r){var i,a,s;let c=(i=e[0])==null?void 0:i.range,l=this._renderManagerService.getRenderUnitById(n),u=l==null||(a=l.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:a.skeleton;if(!u||!c)return;let d=u.getCellWithCoordByIndex(c.startRow,c.startColumn);if((((s=c.rangeType)==null?t.RANGE_TYPE.NORMAL:s)!==t.RANGE_TYPE.NORMAL||c.endColumn-c.startColumn>0||c.endRow-c.startRow>0)&&!((d.isMerged||d.isMergedMainCell)&&t.Rectangle.equals(d.mergeInfo,c))){this._sheetsNotePopupService.hidePopup();return}let f=d.actualRow,p=d.actualColumn,m=this._sheetsNoteModel.getNote(n,r,{row:f,col:p});m!=null&&m.show||(m?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:m.id,row:f,col:p}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;let t=this._sheetSelectionService.currentSelectionParam;t&&this._handleSelectionChange(e,t.unitId,t.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{var t;if(!(e!=null&&e.location))return;let{unitId:n,subUnitId:r,row:i,col:a}=e.location,s=this._renderManagerService.getRenderUnitById(n),c=s==null||(t=s.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:t.skeleton,l=i,u=a,d=this._sheetsNoteModel.getNote(n,r,{row:l,col:u});if(!d&&c){let{startRow:e,endRow:t,startColumn:o,endColumn:s}=c.getCellWithCoordByIndex(i,a).mergeInfo;if(e!==t||o!==s){let i=this._sheetsNoteModel.getSheetNotes(n,r);if(i){for(let[n,r]of i)if(r.row>=e&&r.row<=t&&r.col>=o&&r.col<=s){d=r,l=r.row,u=r.col;break}}}}d!=null&&d.show||(d?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:d.id,row:l,col:u,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;let{unitId:t,subUnitId:n,noteId:r,row:i,col:a}=this._sheetsNotePopupService.activePopup,{oldNote:o,newNote:s}=e;s===null&&e.unitId===t&&e.subUnitId===n&&(o!=null&&o.id&&o.id===r||(o==null?void 0:o.row)===i&&o.col===a)&&this._sheetsNotePopupService.hidePopup(!0)}))}};x=p([f(0,(0,t.Inject)(b)),f(1,(0,t.Inject)(i.SheetsNoteModel)),f(2,(0,t.Inject)(r.SheetsSelectionsService)),f(3,o.IEditorBridgeService),f(4,n.IRenderManagerService),f(5,(0,t.Inject)(o.HoverManagerService))],x);let S={id:`sheet.operation.add-note-popup`,type:t.CommandType.OPERATION,handler:async(e,n)=>{var i;let a=e.get(r.SheetsSelectionsService),o=e.get(b),s=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;let c=s.getActiveSheet(),l=a.getCurrentLastSelection();if(!(l!=null&&l.primary))return!1;let{primary:u}=l;return o.showPopup({unitId:s.getUnitId(),subUnitId:c.getSheetId(),row:u.actualRow,col:u.actualColumn,temp:!1,trigger:(i=n==null?void 0:n.trigger)==null?`add-note`:i}),!0}};function C(e){let n=e.get(r.SheetsSelectionsService),o=e.get(t.IUniverInstanceService);return n.selectionMoveEnd$.pipe((0,a.map)(()=>{let t=n.getCurrentLastSelection();if(!(t!=null&&t.primary))return!1;let a=(0,r.getSheetCommandTarget)(o);if(!a)return!1;let{actualColumn:s,actualRow:c}=t.primary;return!!e.get(i.SheetsNoteModel).getNote(a.unitId,a.subUnitId,{row:c,col:s})}))}function w(e){return{id:S.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.addNote`,icon:`AddNoteIcon`,hidden$:(0,a.combineLatest)([(0,c.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),C(e)]).pipe((0,a.map)(([e,t])=>e||t)),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetEditPermission]}),commandId:S.id}}function T(e){return{id:i.SheetDeleteNoteCommand.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.deleteNote`,icon:`DeleteNoteIcon`,hidden$:C(e).pipe((0,a.map)(e=>!e)),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetEditPermission]})}}function E(e){return{id:i.SheetToggleNotePopupCommand.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.toggleNote`,icon:`HideNoteIcon`,hidden$:C(e).pipe((0,a.map)(e=>!e))}}let D={[c.ContextMenuPosition.MAIN_AREA]:{[c.ContextMenuGroup.OTHERS]:{order:0,[S.id]:{order:0,menuItemFactory:w},[i.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:T},[i.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:E}}}};var O=`@univerjs/sheets-note-ui`,k=`1.0.0-alpha.8`;let A=`sheets-note-ui.config`,j={};function M({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,l.useRef)(`_${I()}`);return N(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function N(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...P(e,n,i),...r},(F(e,n).children||[]).map((r,a)=>N(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function P(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function F(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function I(){return Math.random().toString(36).substring(2,8)}M.displayName=`UniverIcon`;let L={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z`}}]},R=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`add-note-icon`,ref:t,icon:L}))});R.displayName=`AddNoteIcon`;let z={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z`}}]},B=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`delete-note-icon`,ref:t,icon:z}))});B.displayName=`DeleteNoteIcon`;let V={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z`}}]},H=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`hide-note-icon`,ref:t,icon:V}))});H.displayName=`HideNoteIcon`;let U=e=>{var t;let n=(t=e.popup.extraProps)==null?void 0:t.location;return n?(0,d.jsx)(W,{activePopup:n}):(console.error(`Popup extraProps or location is undefined.`),null)};function W({activePopup:e}){let r=(0,c.useDependency)(i.SheetsNoteModel),a=(0,c.useDependency)(t.LocaleService),o=(0,c.useDependency)(n.IRenderManagerService),s=(0,c.useDependency)(b),f=(0,c.useConfigValue)(A),p=(0,l.useRef)(null),m=(0,l.useRef)(null),h=o.getRenderUnitById(e.unitId),[g,_]=(0,l.useState)(null),v=(0,l.useCallback)(e=>{let t=p.current;if(t)if(a.getDirection()===`rtl`&&m.current!=null){let n=m.current-e;t.style.transform=n?`translateX(${n}px)`:``}else t.style.transform=``},[a]);(0,l.useEffect)(()=>{var n,i,a,o,s,c;let{unitId:l,subUnitId:u,row:d,col:h}=e,g=r.getNote(l,u,{row:d,col:h}),v=(n=(i=g==null?void 0:g.width)==null?f==null||(a=f.defaultNoteSize)==null?void 0:a.width:i)==null?160:n,y=(o=(s=g==null?void 0:g.height)==null?f==null||(c=f.defaultNoteSize)==null?void 0:c.height:s)==null?72:o;if(g)_(g);else{let e={id:(0,t.generateRandomId)(6),width:v,height:y,note:``};_(e),x(e)}p.current&&(m.current=v,p.current.style.width=`${v}px`,p.current.style.height=`${y}px`,p.current.style.transform=``)},[e,p]),(0,l.useEffect)(()=>{if(!e||e.temp||!e.trigger||!p.current)return;let t=requestAnimationFrame(()=>{var e;(e=p.current)==null||e.focus()});return()=>cancelAnimationFrame(t)},[e]);let y=(0,c.useDependency)(t.ICommandService),x=(0,c.useDebounceFn)(t=>{if(!e)return;let{unitId:n,subUnitId:a,row:o,col:c}=e;if(!y.syncExecuteCommand(i.SheetUpdateNoteCommand.id,{unitId:n,sheetId:a,row:o,col:c,note:t})){let e=r.getNote(n,a,{noteId:t.id,row:o,col:c});e?_(e):s.hidePopup(!0)}}),S=(0,l.useCallback)(e=>{if(!g||e===g.note)return;let t={...g,note:e};_(t),x(t)},[g]),C=(0,l.useCallback)((e,t)=>{if(!g||(v(e),e===g.width&&t===g.height))return;let n={...g,width:e,height:t};_(n),x(n)},[v,g]);return(0,d.jsx)(u.Textarea,{ref:p,"data-u-comp":`note-textarea`,className:(0,u.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`),value:g==null?void 0:g.note,placeholder:a.t(`sheets-note-ui.note.placeholder`),onResize:C,onValueChange:S,onWheel:e=>{document.activeElement!==p.current&&h.engine.getCanvasElement().dispatchEvent(new WheelEvent(e.type,e.nativeEvent))}})}let G=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[h,U]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddNoteIcon:R,DeleteNoteIcon:B,HideNoteIcon:H}))}};G=p([f(0,(0,t.Inject)(c.ComponentManager)),f(1,(0,t.Inject)(c.IconManager))],G);let K=class extends t.Disposable{constructor(e,n,r,i){super(),this._sheetsNoteModel=e,this._univerInstanceService=n,this._cellPopupManagerService=r,this._sheetsNotePopupService=i,y(this,`_noteMatrix`,new t.ObjectMatrix),this._initNoteChangeListener()}_showPopup(e,t,n,r){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:t,row:n,col:r},{componentKey:h,direction:`horizontal`,extraProps:{location:{unitId:e,subUnitId:t,row:n,col:r}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((e,t,n)=>{n.dispose()})}_initSheet(e,n){var r;this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new t.ObjectMatrix;let i=(e,t,n,r,i)=>{let a=this._noteMatrix,o=a.getValue(n,r);if(i!=null&&i.show){if(!o){let i=this._showPopup(e,t,n,r);i&&a.setValue(n,r,i)}}else o&&(o.dispose(),a.realDeleteValue(n,r))};return(r=this._sheetsNoteModel.getSheetNotes(e,n))==null||r.forEach(t=>{i(e,n,t.row,t.col,t)}),this._sheetsNoteModel.change$.subscribe(t=>{if(t.unitId===e&&t.subUnitId===n)switch(t.type){case`ref`:{let{unitId:e,subUnitId:n,oldNote:r,newNote:i}=t;if(!i.show)return;let a=this._noteMatrix,{row:o,col:s}=r,{row:c,col:l}=i,u=a.getValue(o,s);u&&(u.dispose(),a.realDeleteValue(o,s));let d=this._showPopup(e,n,c,l);d&&a.setValue(c,l,d);break}case`update`:{let{unitId:e,subUnitId:n,oldNote:r,newNote:a}=t,o=a?a.row:r.row,s=a?a.col:r.col;i(e,n,o,s,a);break}default:break}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,a.switchMap)(e=>{var t;return(t=e==null?void 0:e.activeSheet$)==null?(0,a.of)(null):t})).subscribe(e=>{if(e){let t=this._initSheet(e.getUnitId(),e.getSheetId());return()=>{t.unsubscribe()}}else this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new t.ObjectMatrix}))}};K=p([f(0,(0,t.Inject)(i.SheetsNoteModel)),f(1,(0,t.Inject)(t.IUniverInstanceService)),f(2,(0,t.Inject)(o.CellPopupManagerService)),f(3,(0,t.Inject)(b))],K);let q=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._commandService=t,this._initMenu(),this._initCommands()}_initMenu(){this._menuManagerService.mergeMenu(D)}_initCommands(){this._commandService.registerCommand(S)}};q=p([f(0,(0,t.Inject)(c.IMenuManagerService)),f(1,t.ICommandService)],q);let J=class extends t.Plugin{constructor(e=j,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},j,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(A,a)}onStarting(){this._injector.add([G]),this._injector.get(G),[[b],[m],[x],[q],[K]].forEach(e=>{this._injector.add(e)})}onReady(){(0,t.touchDependencies)(this._injector,[[q],[m]])}onRendered(){(0,t.touchDependencies)(this._injector,[[x],[K]])}};y(J,`pluginName`,`SHEET_NOTE_UI_PLUGIN`),y(J,`packageName`,O),y(J,`version`,k),y(J,`type`,t.UniverInstanceType.UNIVER_SHEET),J=p([(0,t.DependentOn)(n.UniverRenderEnginePlugin,r.UniverSheetsPlugin,c.UniverUIPlugin,i.UniverSheetsNotePlugin,o.UniverSheetsUIPlugin),f(1,(0,t.Inject)(t.Injector)),f(2,t.IConfigService)],J),Object.defineProperty(e,"SheetsCellContentController",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SheetsNotePopupController",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"SheetsNotePopupService",{enumerable:!0,get:function(){return b}}),e.SheetsNoteUIMenuSchema=D,Object.defineProperty(e,"UniverSheetsNoteUIPlugin",{enumerable:!0,get:function(){return J}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-note-ui",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Cell note UI for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -57,26 +57,28 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@univerjs/icons": "1.34.0",
|
|
60
|
-
"@univerjs/core": "1.0.0-alpha.
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/sheets
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/ui": "1.0.0-alpha.
|
|
60
|
+
"@univerjs/core": "1.0.0-alpha.8",
|
|
61
|
+
"@univerjs/design": "1.0.0-alpha.8",
|
|
62
|
+
"@univerjs/engine-render": "1.0.0-alpha.8",
|
|
63
|
+
"@univerjs/sheets": "1.0.0-alpha.8",
|
|
64
|
+
"@univerjs/sheets-note": "1.0.0-alpha.8",
|
|
65
|
+
"@univerjs/ui": "1.0.0-alpha.8",
|
|
66
|
+
"@univerjs/sheets-ui": "1.0.0-alpha.8"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"postcss": "^8.5.
|
|
69
|
+
"postcss": "^8.5.23",
|
|
70
70
|
"react": "18.3.1",
|
|
71
71
|
"rxjs": "^7.8.2",
|
|
72
72
|
"tailwindcss": "3.4.18",
|
|
73
73
|
"typescript": "^6.0.3",
|
|
74
74
|
"vitest": "^4.1.10",
|
|
75
|
-
"@univerjs-infra/shared": "1.0.0-alpha.
|
|
75
|
+
"@univerjs-infra/shared": "1.0.0-alpha.8"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"test": "vitest run",
|
|
79
79
|
"test:watch": "vitest",
|
|
80
|
+
"coverage": "vitest run --coverage",
|
|
81
|
+
"typecheck": "tsc --noEmit",
|
|
80
82
|
"build:bundle": "univer-cli build",
|
|
81
83
|
"build:types": "tsc -p tsconfig.node.json",
|
|
82
84
|
"build": "pnpm run build:bundle && pnpm run build:types"
|