@univerjs/docs-ui 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +32 -36
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +32 -36
- package/lib/facade.js +1 -1
- package/lib/index.js +32 -36
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/clipboard/copy-content-cache.d.ts +0 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +9 -9
- package/package.json +10 -10
- /package/lib/types/services/{doc-print-interceptor-service.d.ts → doc-print-interceptor.service.d.ts} +0 -0
package/lib/cjs/facade.js
CHANGED
|
@@ -154,7 +154,7 @@ var FUniverDocsUIMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
154
154
|
return this._injector.createInstance(FDocument, document);
|
|
155
155
|
}
|
|
156
156
|
getActiveDocument() {
|
|
157
|
-
const document = this._univerInstanceService.
|
|
157
|
+
const document = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
158
158
|
if (!document) return null;
|
|
159
159
|
return this._injector.createInstance(FDocument, document);
|
|
160
160
|
}
|
package/lib/cjs/index.js
CHANGED
|
@@ -109,7 +109,7 @@ function addCustomDecorationBySelectionFactory(accessor, param) {
|
|
|
109
109
|
const { segmentId, id, type, unitId: propUnitId } = param;
|
|
110
110
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
111
111
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
112
|
-
const documentDataModel = propUnitId ? univerInstanceService.getUnit(propUnitId, _univerjs_core.UniverInstanceType.UNIVER_DOC) : univerInstanceService.
|
|
112
|
+
const documentDataModel = propUnitId ? univerInstanceService.getUnit(propUnitId, _univerjs_core.UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
113
113
|
if (!documentDataModel) return false;
|
|
114
114
|
const unitId = documentDataModel.getUnitId();
|
|
115
115
|
const selections = docSelectionManagerService.getTextRanges({
|
|
@@ -317,7 +317,7 @@ let DocAutoFormatService = class DocAutoFormatService extends _univerjs_core.Dis
|
|
|
317
317
|
onAutoFormat(id, params) {
|
|
318
318
|
var _this$_matches$get, _docRanges$find;
|
|
319
319
|
const autoFormats = (_this$_matches$get = this._matches.get(id)) !== null && _this$_matches$get !== void 0 ? _this$_matches$get : [];
|
|
320
|
-
const unit = this._univerInstanceService.
|
|
320
|
+
const unit = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
321
321
|
const docRanges = this._textSelectionManagerService.getDocRanges();
|
|
322
322
|
const selection = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
323
323
|
if (unit && selection) {
|
|
@@ -402,7 +402,7 @@ let DocMenuStyleService = class DocMenuStyleService extends _univerjs_core.Dispo
|
|
|
402
402
|
}
|
|
403
403
|
getDefaultStyle() {
|
|
404
404
|
var _this$_renderManagerS;
|
|
405
|
-
const docDataModel = this._univerInstanceService.
|
|
405
|
+
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
406
406
|
if (docDataModel == null) return { ...DEFAULT_TEXT_STYLE };
|
|
407
407
|
const unitId = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId();
|
|
408
408
|
const docSkeletonManagerService = (_this$_renderManagerS = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs.DocSkeletonManagerService);
|
|
@@ -502,7 +502,7 @@ const BreakLineCommand = {
|
|
|
502
502
|
}
|
|
503
503
|
const { horizontalLine } = params !== null && params !== void 0 ? params : {};
|
|
504
504
|
const { segmentId } = activeTextRange;
|
|
505
|
-
const docDataModel = univerInstanceService.
|
|
505
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
506
506
|
const originBody = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId !== null && segmentId !== void 0 ? segmentId : "").getBody();
|
|
507
507
|
if (docDataModel == null || originBody == null) return false;
|
|
508
508
|
const unitId = docDataModel.getUnitId();
|
|
@@ -1617,7 +1617,7 @@ const MergeTwoParagraphCommand = {
|
|
|
1617
1617
|
const ranges = docSelectionManagerService.getTextRanges();
|
|
1618
1618
|
if (activeRange == null || ranges == null) return false;
|
|
1619
1619
|
const { segmentId, style } = activeRange;
|
|
1620
|
-
const docDataModel = univerInstanceService.
|
|
1620
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1621
1621
|
const originBody = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
1622
1622
|
if (docDataModel == null || originBody == null) return false;
|
|
1623
1623
|
const dataStream = originBody.dataStream;
|
|
@@ -1697,7 +1697,7 @@ const RemoveHorizontalLineCommand = {
|
|
|
1697
1697
|
const ranges = docSelectionManagerService.getTextRanges();
|
|
1698
1698
|
if (activeRange == null || ranges == null) return false;
|
|
1699
1699
|
const { segmentId, style } = activeRange;
|
|
1700
|
-
const docDataModel = univerInstanceService.
|
|
1700
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1701
1701
|
const originBody = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
1702
1702
|
if (docDataModel == null || originBody == null) return false;
|
|
1703
1703
|
const actualRange = activeRange;
|
|
@@ -2070,10 +2070,6 @@ const DeleteCurrentParagraphCommand = {
|
|
|
2070
2070
|
//#endregion
|
|
2071
2071
|
//#region src/services/clipboard/copy-content-cache.ts
|
|
2072
2072
|
const COPY_CONTENT_CACHE_LIMIT = 10;
|
|
2073
|
-
const ID_LENGTH$2 = 6;
|
|
2074
|
-
function genId() {
|
|
2075
|
-
return (0, _univerjs_core.generateRandomId)(ID_LENGTH$2);
|
|
2076
|
-
}
|
|
2077
2073
|
function extractId(html) {
|
|
2078
2074
|
const match = html.match(/data-copy-id="([^\s]+)"/);
|
|
2079
2075
|
if (match && match[1]) return match[1];
|
|
@@ -2786,7 +2782,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
2786
2782
|
}
|
|
2787
2783
|
async legacyPaste(options) {
|
|
2788
2784
|
let { html, text, files } = options;
|
|
2789
|
-
const currentDocInstance = this._univerInstanceService.
|
|
2785
|
+
const currentDocInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
2790
2786
|
const docUnitId = (currentDocInstance === null || currentDocInstance === void 0 ? void 0 : currentDocInstance.getUnitId()) || "";
|
|
2791
2787
|
if (!html && !text && files.length) html = await this._createImagePasteHtml(files);
|
|
2792
2788
|
if (!html && !text) {
|
|
@@ -2840,7 +2836,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
2840
2836
|
const { body: _body } = docData;
|
|
2841
2837
|
if (_body == null) return false;
|
|
2842
2838
|
let body = (0, _univerjs_core.normalizeBody)(_body);
|
|
2843
|
-
if (!((_this$_univerInstance = this._univerInstanceService.
|
|
2839
|
+
if (!((_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId())) return false;
|
|
2844
2840
|
this._clipboardHooks.forEach((hook) => {
|
|
2845
2841
|
if (hook.onBeforePaste) body = hook.onBeforePaste(body);
|
|
2846
2842
|
});
|
|
@@ -2880,7 +2876,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
2880
2876
|
}
|
|
2881
2877
|
async _setClipboardData(documentList, needCache = true) {
|
|
2882
2878
|
var _documentList$0$body;
|
|
2883
|
-
const copyId =
|
|
2879
|
+
const copyId = (0, _univerjs_core.generateRandomId)(6);
|
|
2884
2880
|
const text = (documentList.length > 1 ? documentList.map((doc) => {
|
|
2885
2881
|
var _doc$body;
|
|
2886
2882
|
return ((_doc$body = doc.body) === null || _doc$body === void 0 ? void 0 : _doc$body.dataStream) || "";
|
|
@@ -2997,7 +2993,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
2997
2993
|
if (copyCache) return copyCache;
|
|
2998
2994
|
}
|
|
2999
2995
|
if (!_unitId) {
|
|
3000
|
-
const currentDocInstance = this._univerInstanceService.
|
|
2996
|
+
const currentDocInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
3001
2997
|
_unitId = (currentDocInstance === null || currentDocInstance === void 0 ? void 0 : currentDocInstance.getUnitId()) || "";
|
|
3002
2998
|
}
|
|
3003
2999
|
const doc = this._htmlToUDM.convert(html, { unitId: _unitId });
|
|
@@ -3210,7 +3206,7 @@ const DocSelectAllCommand = {
|
|
|
3210
3206
|
var _docRanges$find;
|
|
3211
3207
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
3212
3208
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
3213
|
-
const docDataModel = univerInstanceService.
|
|
3209
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
3214
3210
|
const docRanges = docSelectionManagerService.getDocRanges();
|
|
3215
3211
|
const activeRange = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
3216
3212
|
if (docDataModel == null || activeRange == null) return false;
|
|
@@ -3527,7 +3523,7 @@ const SetInlineFormatCommand = {
|
|
|
3527
3523
|
const activeRange = (_docRanges$find = docRanges.find((r) => r.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
3528
3524
|
if (docRanges.length === 0) return false;
|
|
3529
3525
|
const { segmentId } = docRanges[0];
|
|
3530
|
-
const docDataModel = univerInstanceService.
|
|
3526
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
3531
3527
|
if (docDataModel == null) return false;
|
|
3532
3528
|
const body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
3533
3529
|
if (body == null) return false;
|
|
@@ -3960,7 +3956,7 @@ const ListOperationCommand = {
|
|
|
3960
3956
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
3961
3957
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
3962
3958
|
const listType = params.listType;
|
|
3963
|
-
const docDataModel = univerInstanceService.
|
|
3959
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
3964
3960
|
const docRanges = (_ref = (_params$docRange = params.docRange) !== null && _params$docRange !== void 0 ? _params$docRange : docSelectionManagerService.getDocRanges()) !== null && _ref !== void 0 ? _ref : [];
|
|
3965
3961
|
if (docDataModel == null || docRanges.length === 0) return false;
|
|
3966
3962
|
const segmentId = docRanges[0].segmentId;
|
|
@@ -4002,7 +3998,7 @@ const ChangeListTypeCommand = {
|
|
|
4002
3998
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4003
3999
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4004
4000
|
const { listType } = params;
|
|
4005
|
-
const docDataModel = univerInstanceService.
|
|
4001
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4006
4002
|
const activeRanges = (_params$docRange2 = params.docRange) !== null && _params$docRange2 !== void 0 ? _params$docRange2 : docSelectionManagerService.getDocRanges();
|
|
4007
4003
|
if (docDataModel == null || activeRanges == null || !activeRanges.length) return false;
|
|
4008
4004
|
const { segmentId } = activeRanges[0];
|
|
@@ -4050,7 +4046,7 @@ const ChangeListNestingLevelCommand = {
|
|
|
4050
4046
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
4051
4047
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4052
4048
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4053
|
-
const docDataModel = univerInstanceService.
|
|
4049
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4054
4050
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4055
4051
|
if (docDataModel == null || activeRange == null) return false;
|
|
4056
4052
|
const { segmentId } = activeRange;
|
|
@@ -4122,7 +4118,7 @@ const ToggleCheckListCommand = {
|
|
|
4122
4118
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4123
4119
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4124
4120
|
const { index, segmentId, textRanges } = params;
|
|
4125
|
-
const docDataModel = univerInstanceService.
|
|
4121
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4126
4122
|
if (docDataModel == null) return false;
|
|
4127
4123
|
if (((_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.paragraphs) == null) return false;
|
|
4128
4124
|
const unitId = docDataModel.getUnitId();
|
|
@@ -4167,7 +4163,7 @@ const QuickListCommand = {
|
|
|
4167
4163
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
4168
4164
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4169
4165
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4170
|
-
const docDataModel = univerInstanceService.
|
|
4166
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4171
4167
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4172
4168
|
if (docDataModel == null || activeRange == null) return false;
|
|
4173
4169
|
const { segmentId, startOffset } = activeRange;
|
|
@@ -4524,7 +4520,7 @@ const QuickHeadingCommand = {
|
|
|
4524
4520
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
4525
4521
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4526
4522
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4527
|
-
const docDataModel = univerInstanceService.
|
|
4523
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4528
4524
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4529
4525
|
if (docDataModel == null || activeRange == null || !activeRange.collapsed) return false;
|
|
4530
4526
|
const { segmentId, startOffset } = activeRange;
|
|
@@ -6992,7 +6988,7 @@ const DocTableInsertRowCommand = {
|
|
|
6992
6988
|
const rangeInfo = getRangeInfoFromRanges(docSelectionManagerService.getActiveTextRange(), activeRectRanges);
|
|
6993
6989
|
if (rangeInfo == null) return false;
|
|
6994
6990
|
const { segmentId } = rangeInfo;
|
|
6995
|
-
const docDataModel = univerInstanceService.
|
|
6991
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
6996
6992
|
const body = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
6997
6993
|
if (docDataModel == null || body == null) return false;
|
|
6998
6994
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
@@ -7369,7 +7365,7 @@ var Editor = class extends _univerjs_core.Disposable {
|
|
|
7369
7365
|
* @deprecated use `IEditorService.focus` as instead. this is for internal usage.
|
|
7370
7366
|
*/
|
|
7371
7367
|
focus() {
|
|
7372
|
-
const curDoc = this._univerInstanceService.
|
|
7368
|
+
const curDoc = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
7373
7369
|
const editorUnitId = this.getEditorId();
|
|
7374
7370
|
if (curDoc == null || curDoc.getUnitId() !== editorUnitId) this._univerInstanceService.setCurrentUnitForType(editorUnitId);
|
|
7375
7371
|
this._param.render.with(DocSelectionRenderService).focus();
|
|
@@ -9517,11 +9513,11 @@ function DocSwitchModeMenuItemFactory(accessor) {
|
|
|
9517
9513
|
const subscription = commandService.onCommandExecuted((c) => {
|
|
9518
9514
|
if (c.id === _univerjs_docs.RichTextEditingMutation.id) {
|
|
9519
9515
|
var _instance$getSnapshot;
|
|
9520
|
-
const instance = univerInstanceService.
|
|
9516
|
+
const instance = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
9521
9517
|
subscriber.next((instance === null || instance === void 0 || (_instance$getSnapshot = instance.getSnapshot()) === null || _instance$getSnapshot === void 0 ? void 0 : _instance$getSnapshot.documentStyle.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN);
|
|
9522
9518
|
}
|
|
9523
9519
|
});
|
|
9524
|
-
const instance = univerInstanceService.
|
|
9520
|
+
const instance = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
9525
9521
|
subscriber.next((instance === null || instance === void 0 || (_instance$getSnapshot2 = instance.getSnapshot()) === null || _instance$getSnapshot2 === void 0 ? void 0 : _instance$getSnapshot2.documentStyle.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN);
|
|
9526
9522
|
return () => subscription.dispose();
|
|
9527
9523
|
})
|
|
@@ -9588,7 +9584,7 @@ function getFontStyleAtCursor(accessor) {
|
|
|
9588
9584
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
9589
9585
|
const textSelectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
9590
9586
|
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
9591
|
-
const docDataModel = univerInstanceService.
|
|
9587
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
9592
9588
|
const docRanges = textSelectionService.getDocRanges();
|
|
9593
9589
|
const activeRange = (_docRanges$find2 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find2 !== void 0 ? _docRanges$find2 : docRanges[0];
|
|
9594
9590
|
const defaultTextStyle = docMenuStyleService.getDefaultStyle();
|
|
@@ -10868,7 +10864,7 @@ const DocParagraphSettingCommand = {
|
|
|
10868
10864
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
10869
10865
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
10870
10866
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
10871
|
-
const docDataModel = univerInstanceService.
|
|
10867
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
10872
10868
|
const docRanges = docSelectionManagerService.getDocRanges();
|
|
10873
10869
|
if (!docDataModel || docRanges.length === 0 || !config) return false;
|
|
10874
10870
|
const segmentId = docRanges[0].segmentId;
|
|
@@ -10933,7 +10929,7 @@ const useDocRanges = () => {
|
|
|
10933
10929
|
};
|
|
10934
10930
|
const useCurrentParagraph = () => {
|
|
10935
10931
|
var _segment$getBody$para, _segment$getBody, _segment$getBody$data, _segment$getBody2, _BuildTextUtils$range;
|
|
10936
|
-
const docDataModel = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService).
|
|
10932
|
+
const docDataModel = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
10937
10933
|
const docRanges = useDocRanges();
|
|
10938
10934
|
if (!docDataModel || docRanges.length === 0) return [];
|
|
10939
10935
|
const segmentId = docRanges[0].segmentId;
|
|
@@ -11046,7 +11042,7 @@ const useFirstParagraphLineSpacing = (paragraph) => {
|
|
|
11046
11042
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
11047
11043
|
const skeleton = (0, react.useMemo)(() => {
|
|
11048
11044
|
var _renderManagerService;
|
|
11049
|
-
const docDataModel = univerInstanceService.
|
|
11045
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11050
11046
|
if (!docDataModel) return;
|
|
11051
11047
|
return (_renderManagerService = renderManagerService.getRenderById(docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId())) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
11052
11048
|
}, []);
|
|
@@ -12483,7 +12479,7 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
12483
12479
|
});
|
|
12484
12480
|
scene.attachControl();
|
|
12485
12481
|
scene.onMouseWheel$.subscribeEvent((evt, state) => {
|
|
12486
|
-
const currentDocUnit = this._univerInstanceService.
|
|
12482
|
+
const currentDocUnit = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
12487
12483
|
if ((currentDocUnit === null || currentDocUnit === void 0 ? void 0 : currentDocUnit.getUnitId()) !== this._context.unitId) return;
|
|
12488
12484
|
const e = evt;
|
|
12489
12485
|
if (e.ctrlKey) {
|
|
@@ -12618,7 +12614,7 @@ function getPageSizeInModernMode(page) {
|
|
|
12618
12614
|
//#endregion
|
|
12619
12615
|
//#region package.json
|
|
12620
12616
|
var name = "@univerjs/docs-ui";
|
|
12621
|
-
var version = "0.
|
|
12617
|
+
var version = "0.24.0";
|
|
12622
12618
|
|
|
12623
12619
|
//#endregion
|
|
12624
12620
|
//#region src/controllers/doc-auto-format.controller.ts
|
|
@@ -13842,7 +13838,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
13842
13838
|
}));
|
|
13843
13839
|
this.disposeWithMe(document.onPointerDown$.subscribeEvent((evt, state) => {
|
|
13844
13840
|
if (this._isEditorReadOnly(unitId)) return;
|
|
13845
|
-
const docDataModel = this._instanceSrv.
|
|
13841
|
+
const docDataModel = this._instanceSrv.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
13846
13842
|
if ((docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId()) !== unitId) this._instanceSrv.setCurrentUnitForType(unitId);
|
|
13847
13843
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
13848
13844
|
const { offsetX, offsetY } = evt;
|
|
@@ -14061,7 +14057,7 @@ DocZoomRenderController = __decorate([
|
|
|
14061
14057
|
], DocZoomRenderController);
|
|
14062
14058
|
|
|
14063
14059
|
//#endregion
|
|
14064
|
-
//#region src/services/doc-print-interceptor
|
|
14060
|
+
//#region src/services/doc-print-interceptor.service.ts
|
|
14065
14061
|
const PRINTING_COMPONENT_COLLECT = (0, _univerjs_core.createInterceptorKey)("PRINTING_COMPONENT_COLLECT");
|
|
14066
14062
|
const PRINTING_DOM_COLLECT = (0, _univerjs_core.createInterceptorKey)("PRINTING_DOM_COLLECT");
|
|
14067
14063
|
var DocPrintInterceptorService = class extends _univerjs_core.Disposable {
|
|
@@ -14263,7 +14259,7 @@ let DocsRenderService = class DocsRenderService extends _univerjs_core.RxDisposa
|
|
|
14263
14259
|
_createRenderer(doc) {
|
|
14264
14260
|
var _this$_instanceSrv$ge;
|
|
14265
14261
|
const unitId = doc.getUnitId();
|
|
14266
|
-
const workbookId = (_this$_instanceSrv$ge = this._instanceSrv.
|
|
14262
|
+
const workbookId = (_this$_instanceSrv$ge = this._instanceSrv.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _this$_instanceSrv$ge === void 0 ? void 0 : _this$_instanceSrv$ge.getUnitId();
|
|
14267
14263
|
this._renderManagerService.created$.subscribe((renderer) => {
|
|
14268
14264
|
if (renderer.unitId === workbookId) {
|
|
14269
14265
|
renderer.engine.getCanvas().setId(DOC_MAIN_CANVAS_ID);
|
|
@@ -14528,7 +14524,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
14528
14524
|
const currentService = this._injector.get(_univerjs_core.IUniverInstanceService);
|
|
14529
14525
|
const editorService = this._injector.get(IEditorService);
|
|
14530
14526
|
try {
|
|
14531
|
-
const doc = currentService.
|
|
14527
|
+
const doc = currentService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
14532
14528
|
if (!doc) return;
|
|
14533
14529
|
const id = doc.getUnitId();
|
|
14534
14530
|
if (!editorService.isEditor(id)) currentService.focusUnit(doc.getUnitId());
|
package/lib/es/facade.js
CHANGED
|
@@ -153,7 +153,7 @@ var FUniverDocsUIMixin = class extends FUniver {
|
|
|
153
153
|
return this._injector.createInstance(FDocument, document);
|
|
154
154
|
}
|
|
155
155
|
getActiveDocument() {
|
|
156
|
-
const document = this._univerInstanceService.
|
|
156
|
+
const document = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
157
157
|
if (!document) return null;
|
|
158
158
|
return this._injector.createInstance(FDocument, document);
|
|
159
159
|
}
|
package/lib/es/index.js
CHANGED
|
@@ -108,7 +108,7 @@ function addCustomDecorationBySelectionFactory(accessor, param) {
|
|
|
108
108
|
const { segmentId, id, type, unitId: propUnitId } = param;
|
|
109
109
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
110
110
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
111
|
-
const documentDataModel = propUnitId ? univerInstanceService.getUnit(propUnitId, UniverInstanceType.UNIVER_DOC) : univerInstanceService.
|
|
111
|
+
const documentDataModel = propUnitId ? univerInstanceService.getUnit(propUnitId, UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
112
112
|
if (!documentDataModel) return false;
|
|
113
113
|
const unitId = documentDataModel.getUnitId();
|
|
114
114
|
const selections = docSelectionManagerService.getTextRanges({
|
|
@@ -316,7 +316,7 @@ let DocAutoFormatService = class DocAutoFormatService extends Disposable {
|
|
|
316
316
|
onAutoFormat(id, params) {
|
|
317
317
|
var _this$_matches$get, _docRanges$find;
|
|
318
318
|
const autoFormats = (_this$_matches$get = this._matches.get(id)) !== null && _this$_matches$get !== void 0 ? _this$_matches$get : [];
|
|
319
|
-
const unit = this._univerInstanceService.
|
|
319
|
+
const unit = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
320
320
|
const docRanges = this._textSelectionManagerService.getDocRanges();
|
|
321
321
|
const selection = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
322
322
|
if (unit && selection) {
|
|
@@ -401,7 +401,7 @@ let DocMenuStyleService = class DocMenuStyleService extends Disposable {
|
|
|
401
401
|
}
|
|
402
402
|
getDefaultStyle() {
|
|
403
403
|
var _this$_renderManagerS;
|
|
404
|
-
const docDataModel = this._univerInstanceService.
|
|
404
|
+
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
405
405
|
if (docDataModel == null) return { ...DEFAULT_TEXT_STYLE };
|
|
406
406
|
const unitId = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId();
|
|
407
407
|
const docSkeletonManagerService = (_this$_renderManagerS = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocSkeletonManagerService);
|
|
@@ -501,7 +501,7 @@ const BreakLineCommand = {
|
|
|
501
501
|
}
|
|
502
502
|
const { horizontalLine } = params !== null && params !== void 0 ? params : {};
|
|
503
503
|
const { segmentId } = activeTextRange;
|
|
504
|
-
const docDataModel = univerInstanceService.
|
|
504
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
505
505
|
const originBody = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId !== null && segmentId !== void 0 ? segmentId : "").getBody();
|
|
506
506
|
if (docDataModel == null || originBody == null) return false;
|
|
507
507
|
const unitId = docDataModel.getUnitId();
|
|
@@ -1616,7 +1616,7 @@ const MergeTwoParagraphCommand = {
|
|
|
1616
1616
|
const ranges = docSelectionManagerService.getTextRanges();
|
|
1617
1617
|
if (activeRange == null || ranges == null) return false;
|
|
1618
1618
|
const { segmentId, style } = activeRange;
|
|
1619
|
-
const docDataModel = univerInstanceService.
|
|
1619
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
1620
1620
|
const originBody = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
1621
1621
|
if (docDataModel == null || originBody == null) return false;
|
|
1622
1622
|
const dataStream = originBody.dataStream;
|
|
@@ -1696,7 +1696,7 @@ const RemoveHorizontalLineCommand = {
|
|
|
1696
1696
|
const ranges = docSelectionManagerService.getTextRanges();
|
|
1697
1697
|
if (activeRange == null || ranges == null) return false;
|
|
1698
1698
|
const { segmentId, style } = activeRange;
|
|
1699
|
-
const docDataModel = univerInstanceService.
|
|
1699
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
1700
1700
|
const originBody = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
1701
1701
|
if (docDataModel == null || originBody == null) return false;
|
|
1702
1702
|
const actualRange = activeRange;
|
|
@@ -2069,10 +2069,6 @@ const DeleteCurrentParagraphCommand = {
|
|
|
2069
2069
|
//#endregion
|
|
2070
2070
|
//#region src/services/clipboard/copy-content-cache.ts
|
|
2071
2071
|
const COPY_CONTENT_CACHE_LIMIT = 10;
|
|
2072
|
-
const ID_LENGTH$2 = 6;
|
|
2073
|
-
function genId() {
|
|
2074
|
-
return generateRandomId(ID_LENGTH$2);
|
|
2075
|
-
}
|
|
2076
2072
|
function extractId(html) {
|
|
2077
2073
|
const match = html.match(/data-copy-id="([^\s]+)"/);
|
|
2078
2074
|
if (match && match[1]) return match[1];
|
|
@@ -2785,7 +2781,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
2785
2781
|
}
|
|
2786
2782
|
async legacyPaste(options) {
|
|
2787
2783
|
let { html, text, files } = options;
|
|
2788
|
-
const currentDocInstance = this._univerInstanceService.
|
|
2784
|
+
const currentDocInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
2789
2785
|
const docUnitId = (currentDocInstance === null || currentDocInstance === void 0 ? void 0 : currentDocInstance.getUnitId()) || "";
|
|
2790
2786
|
if (!html && !text && files.length) html = await this._createImagePasteHtml(files);
|
|
2791
2787
|
if (!html && !text) {
|
|
@@ -2839,7 +2835,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
2839
2835
|
const { body: _body } = docData;
|
|
2840
2836
|
if (_body == null) return false;
|
|
2841
2837
|
let body = normalizeBody(_body);
|
|
2842
|
-
if (!((_this$_univerInstance = this._univerInstanceService.
|
|
2838
|
+
if (!((_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId())) return false;
|
|
2843
2839
|
this._clipboardHooks.forEach((hook) => {
|
|
2844
2840
|
if (hook.onBeforePaste) body = hook.onBeforePaste(body);
|
|
2845
2841
|
});
|
|
@@ -2879,7 +2875,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
2879
2875
|
}
|
|
2880
2876
|
async _setClipboardData(documentList, needCache = true) {
|
|
2881
2877
|
var _documentList$0$body;
|
|
2882
|
-
const copyId =
|
|
2878
|
+
const copyId = generateRandomId(6);
|
|
2883
2879
|
const text = (documentList.length > 1 ? documentList.map((doc) => {
|
|
2884
2880
|
var _doc$body;
|
|
2885
2881
|
return ((_doc$body = doc.body) === null || _doc$body === void 0 ? void 0 : _doc$body.dataStream) || "";
|
|
@@ -2996,7 +2992,7 @@ let DocClipboardService = class DocClipboardService extends Disposable {
|
|
|
2996
2992
|
if (copyCache) return copyCache;
|
|
2997
2993
|
}
|
|
2998
2994
|
if (!_unitId) {
|
|
2999
|
-
const currentDocInstance = this._univerInstanceService.
|
|
2995
|
+
const currentDocInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
3000
2996
|
_unitId = (currentDocInstance === null || currentDocInstance === void 0 ? void 0 : currentDocInstance.getUnitId()) || "";
|
|
3001
2997
|
}
|
|
3002
2998
|
const doc = this._htmlToUDM.convert(html, { unitId: _unitId });
|
|
@@ -3209,7 +3205,7 @@ const DocSelectAllCommand = {
|
|
|
3209
3205
|
var _docRanges$find;
|
|
3210
3206
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3211
3207
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
3212
|
-
const docDataModel = univerInstanceService.
|
|
3208
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
3213
3209
|
const docRanges = docSelectionManagerService.getDocRanges();
|
|
3214
3210
|
const activeRange = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
3215
3211
|
if (docDataModel == null || activeRange == null) return false;
|
|
@@ -3526,7 +3522,7 @@ const SetInlineFormatCommand = {
|
|
|
3526
3522
|
const activeRange = (_docRanges$find = docRanges.find((r) => r.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
3527
3523
|
if (docRanges.length === 0) return false;
|
|
3528
3524
|
const { segmentId } = docRanges[0];
|
|
3529
|
-
const docDataModel = univerInstanceService.
|
|
3525
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
3530
3526
|
if (docDataModel == null) return false;
|
|
3531
3527
|
const body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
3532
3528
|
if (body == null) return false;
|
|
@@ -3959,7 +3955,7 @@ const ListOperationCommand = {
|
|
|
3959
3955
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3960
3956
|
const commandService = accessor.get(ICommandService);
|
|
3961
3957
|
const listType = params.listType;
|
|
3962
|
-
const docDataModel = univerInstanceService.
|
|
3958
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
3963
3959
|
const docRanges = (_ref = (_params$docRange = params.docRange) !== null && _params$docRange !== void 0 ? _params$docRange : docSelectionManagerService.getDocRanges()) !== null && _ref !== void 0 ? _ref : [];
|
|
3964
3960
|
if (docDataModel == null || docRanges.length === 0) return false;
|
|
3965
3961
|
const segmentId = docRanges[0].segmentId;
|
|
@@ -4001,7 +3997,7 @@ const ChangeListTypeCommand = {
|
|
|
4001
3997
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
4002
3998
|
const commandService = accessor.get(ICommandService);
|
|
4003
3999
|
const { listType } = params;
|
|
4004
|
-
const docDataModel = univerInstanceService.
|
|
4000
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
4005
4001
|
const activeRanges = (_params$docRange2 = params.docRange) !== null && _params$docRange2 !== void 0 ? _params$docRange2 : docSelectionManagerService.getDocRanges();
|
|
4006
4002
|
if (docDataModel == null || activeRanges == null || !activeRanges.length) return false;
|
|
4007
4003
|
const { segmentId } = activeRanges[0];
|
|
@@ -4049,7 +4045,7 @@ const ChangeListNestingLevelCommand = {
|
|
|
4049
4045
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
4050
4046
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
4051
4047
|
const commandService = accessor.get(ICommandService);
|
|
4052
|
-
const docDataModel = univerInstanceService.
|
|
4048
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
4053
4049
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4054
4050
|
if (docDataModel == null || activeRange == null) return false;
|
|
4055
4051
|
const { segmentId } = activeRange;
|
|
@@ -4121,7 +4117,7 @@ const ToggleCheckListCommand = {
|
|
|
4121
4117
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
4122
4118
|
const commandService = accessor.get(ICommandService);
|
|
4123
4119
|
const { index, segmentId, textRanges } = params;
|
|
4124
|
-
const docDataModel = univerInstanceService.
|
|
4120
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
4125
4121
|
if (docDataModel == null) return false;
|
|
4126
4122
|
if (((_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.paragraphs) == null) return false;
|
|
4127
4123
|
const unitId = docDataModel.getUnitId();
|
|
@@ -4166,7 +4162,7 @@ const QuickListCommand = {
|
|
|
4166
4162
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
4167
4163
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
4168
4164
|
const commandService = accessor.get(ICommandService);
|
|
4169
|
-
const docDataModel = univerInstanceService.
|
|
4165
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
4170
4166
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4171
4167
|
if (docDataModel == null || activeRange == null) return false;
|
|
4172
4168
|
const { segmentId, startOffset } = activeRange;
|
|
@@ -4523,7 +4519,7 @@ const QuickHeadingCommand = {
|
|
|
4523
4519
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
4524
4520
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
4525
4521
|
const commandService = accessor.get(ICommandService);
|
|
4526
|
-
const docDataModel = univerInstanceService.
|
|
4522
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
4527
4523
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4528
4524
|
if (docDataModel == null || activeRange == null || !activeRange.collapsed) return false;
|
|
4529
4525
|
const { segmentId, startOffset } = activeRange;
|
|
@@ -6991,7 +6987,7 @@ const DocTableInsertRowCommand = {
|
|
|
6991
6987
|
const rangeInfo = getRangeInfoFromRanges(docSelectionManagerService.getActiveTextRange(), activeRectRanges);
|
|
6992
6988
|
if (rangeInfo == null) return false;
|
|
6993
6989
|
const { segmentId } = rangeInfo;
|
|
6994
|
-
const docDataModel = univerInstanceService.
|
|
6990
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
6995
6991
|
const body = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
6996
6992
|
if (docDataModel == null || body == null) return false;
|
|
6997
6993
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
@@ -7368,7 +7364,7 @@ var Editor = class extends Disposable {
|
|
|
7368
7364
|
* @deprecated use `IEditorService.focus` as instead. this is for internal usage.
|
|
7369
7365
|
*/
|
|
7370
7366
|
focus() {
|
|
7371
|
-
const curDoc = this._univerInstanceService.
|
|
7367
|
+
const curDoc = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
7372
7368
|
const editorUnitId = this.getEditorId();
|
|
7373
7369
|
if (curDoc == null || curDoc.getUnitId() !== editorUnitId) this._univerInstanceService.setCurrentUnitForType(editorUnitId);
|
|
7374
7370
|
this._param.render.with(DocSelectionRenderService).focus();
|
|
@@ -9516,11 +9512,11 @@ function DocSwitchModeMenuItemFactory(accessor) {
|
|
|
9516
9512
|
const subscription = commandService.onCommandExecuted((c) => {
|
|
9517
9513
|
if (c.id === RichTextEditingMutation.id) {
|
|
9518
9514
|
var _instance$getSnapshot;
|
|
9519
|
-
const instance = univerInstanceService.
|
|
9515
|
+
const instance = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
9520
9516
|
subscriber.next((instance === null || instance === void 0 || (_instance$getSnapshot = instance.getSnapshot()) === null || _instance$getSnapshot === void 0 ? void 0 : _instance$getSnapshot.documentStyle.documentFlavor) === DocumentFlavor.MODERN);
|
|
9521
9517
|
}
|
|
9522
9518
|
});
|
|
9523
|
-
const instance = univerInstanceService.
|
|
9519
|
+
const instance = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
9524
9520
|
subscriber.next((instance === null || instance === void 0 || (_instance$getSnapshot2 = instance.getSnapshot()) === null || _instance$getSnapshot2 === void 0 ? void 0 : _instance$getSnapshot2.documentStyle.documentFlavor) === DocumentFlavor.MODERN);
|
|
9525
9521
|
return () => subscription.dispose();
|
|
9526
9522
|
})
|
|
@@ -9587,7 +9583,7 @@ function getFontStyleAtCursor(accessor) {
|
|
|
9587
9583
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
9588
9584
|
const textSelectionService = accessor.get(DocSelectionManagerService);
|
|
9589
9585
|
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
9590
|
-
const docDataModel = univerInstanceService.
|
|
9586
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
9591
9587
|
const docRanges = textSelectionService.getDocRanges();
|
|
9592
9588
|
const activeRange = (_docRanges$find2 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find2 !== void 0 ? _docRanges$find2 : docRanges[0];
|
|
9593
9589
|
const defaultTextStyle = docMenuStyleService.getDefaultStyle();
|
|
@@ -10867,7 +10863,7 @@ const DocParagraphSettingCommand = {
|
|
|
10867
10863
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
10868
10864
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
10869
10865
|
const commandService = accessor.get(ICommandService);
|
|
10870
|
-
const docDataModel = univerInstanceService.
|
|
10866
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
10871
10867
|
const docRanges = docSelectionManagerService.getDocRanges();
|
|
10872
10868
|
if (!docDataModel || docRanges.length === 0 || !config) return false;
|
|
10873
10869
|
const segmentId = docRanges[0].segmentId;
|
|
@@ -10932,7 +10928,7 @@ const useDocRanges = () => {
|
|
|
10932
10928
|
};
|
|
10933
10929
|
const useCurrentParagraph = () => {
|
|
10934
10930
|
var _segment$getBody$para, _segment$getBody, _segment$getBody$data, _segment$getBody2, _BuildTextUtils$range;
|
|
10935
|
-
const docDataModel = useDependency(IUniverInstanceService).
|
|
10931
|
+
const docDataModel = useDependency(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
10936
10932
|
const docRanges = useDocRanges();
|
|
10937
10933
|
if (!docDataModel || docRanges.length === 0) return [];
|
|
10938
10934
|
const segmentId = docRanges[0].segmentId;
|
|
@@ -11045,7 +11041,7 @@ const useFirstParagraphLineSpacing = (paragraph) => {
|
|
|
11045
11041
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
11046
11042
|
const skeleton = useMemo(() => {
|
|
11047
11043
|
var _renderManagerService;
|
|
11048
|
-
const docDataModel = univerInstanceService.
|
|
11044
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
11049
11045
|
if (!docDataModel) return;
|
|
11050
11046
|
return (_renderManagerService = renderManagerService.getRenderById(docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId())) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSkeletonManagerService).getSkeleton();
|
|
11051
11047
|
}, []);
|
|
@@ -12482,7 +12478,7 @@ let DocRenderController = class DocRenderController extends RxDisposable {
|
|
|
12482
12478
|
});
|
|
12483
12479
|
scene.attachControl();
|
|
12484
12480
|
scene.onMouseWheel$.subscribeEvent((evt, state) => {
|
|
12485
|
-
const currentDocUnit = this._univerInstanceService.
|
|
12481
|
+
const currentDocUnit = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
12486
12482
|
if ((currentDocUnit === null || currentDocUnit === void 0 ? void 0 : currentDocUnit.getUnitId()) !== this._context.unitId) return;
|
|
12487
12483
|
const e = evt;
|
|
12488
12484
|
if (e.ctrlKey) {
|
|
@@ -12617,7 +12613,7 @@ function getPageSizeInModernMode(page) {
|
|
|
12617
12613
|
//#endregion
|
|
12618
12614
|
//#region package.json
|
|
12619
12615
|
var name = "@univerjs/docs-ui";
|
|
12620
|
-
var version = "0.
|
|
12616
|
+
var version = "0.24.0";
|
|
12621
12617
|
|
|
12622
12618
|
//#endregion
|
|
12623
12619
|
//#region src/controllers/doc-auto-format.controller.ts
|
|
@@ -13841,7 +13837,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends Di
|
|
|
13841
13837
|
}));
|
|
13842
13838
|
this.disposeWithMe(document.onPointerDown$.subscribeEvent((evt, state) => {
|
|
13843
13839
|
if (this._isEditorReadOnly(unitId)) return;
|
|
13844
|
-
const docDataModel = this._instanceSrv.
|
|
13840
|
+
const docDataModel = this._instanceSrv.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
13845
13841
|
if ((docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId()) !== unitId) this._instanceSrv.setCurrentUnitForType(unitId);
|
|
13846
13842
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
13847
13843
|
const { offsetX, offsetY } = evt;
|
|
@@ -14060,7 +14056,7 @@ DocZoomRenderController = __decorate([
|
|
|
14060
14056
|
], DocZoomRenderController);
|
|
14061
14057
|
|
|
14062
14058
|
//#endregion
|
|
14063
|
-
//#region src/services/doc-print-interceptor
|
|
14059
|
+
//#region src/services/doc-print-interceptor.service.ts
|
|
14064
14060
|
const PRINTING_COMPONENT_COLLECT = createInterceptorKey("PRINTING_COMPONENT_COLLECT");
|
|
14065
14061
|
const PRINTING_DOM_COLLECT = createInterceptorKey("PRINTING_DOM_COLLECT");
|
|
14066
14062
|
var DocPrintInterceptorService = class extends Disposable {
|
|
@@ -14262,7 +14258,7 @@ let DocsRenderService = class DocsRenderService extends RxDisposable {
|
|
|
14262
14258
|
_createRenderer(doc) {
|
|
14263
14259
|
var _this$_instanceSrv$ge;
|
|
14264
14260
|
const unitId = doc.getUnitId();
|
|
14265
|
-
const workbookId = (_this$_instanceSrv$ge = this._instanceSrv.
|
|
14261
|
+
const workbookId = (_this$_instanceSrv$ge = this._instanceSrv.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)) === null || _this$_instanceSrv$ge === void 0 ? void 0 : _this$_instanceSrv$ge.getUnitId();
|
|
14266
14262
|
this._renderManagerService.created$.subscribe((renderer) => {
|
|
14267
14263
|
if (renderer.unitId === workbookId) {
|
|
14268
14264
|
renderer.engine.getCanvas().setId(DOC_MAIN_CANVAS_ID);
|
|
@@ -14527,7 +14523,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
|
|
|
14527
14523
|
const currentService = this._injector.get(IUniverInstanceService);
|
|
14528
14524
|
const editorService = this._injector.get(IEditorService);
|
|
14529
14525
|
try {
|
|
14530
|
-
const doc = currentService.
|
|
14526
|
+
const doc = currentService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
14531
14527
|
if (!doc) return;
|
|
14532
14528
|
const id = doc.getUnitId();
|
|
14533
14529
|
if (!editorService.isEditor(id)) currentService.focusUnit(doc.getUnitId());
|
package/lib/facade.js
CHANGED
|
@@ -153,7 +153,7 @@ var FUniverDocsUIMixin = class extends FUniver {
|
|
|
153
153
|
return this._injector.createInstance(FDocument, document);
|
|
154
154
|
}
|
|
155
155
|
getActiveDocument() {
|
|
156
|
-
const document = this._univerInstanceService.
|
|
156
|
+
const document = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
157
157
|
if (!document) return null;
|
|
158
158
|
return this._injector.createInstance(FDocument, document);
|
|
159
159
|
}
|