@univerjs/docs-ui 0.4.1 → 0.4.2
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 +10 -10
- package/lib/es/index.js +808 -656
- package/lib/locale/en-US.json +1 -0
- package/lib/locale/fa-IR.json +1 -0
- package/lib/locale/ru-RU.json +2 -1
- package/lib/locale/vi-VN.json +2 -1
- package/lib/locale/zh-CN.json +1 -0
- package/lib/locale/zh-TW.json +2 -1
- package/lib/types/basics/paragraph.d.ts +85 -1
- package/lib/types/commands/commands/doc-header-footer.command.d.ts +4 -0
- package/lib/types/commands/commands/paragraph-align.command.d.ts +1 -1
- package/lib/types/commands/commands/switch-doc-mode.command.d.ts +4 -0
- package/lib/types/controllers/doc-header-footer.controller.d.ts +2 -0
- package/lib/types/controllers/menu/menu.d.ts +1 -0
- package/lib/types/controllers/render-controllers/doc-ime-input.controller.d.ts +5 -5
- package/lib/types/controllers/render-controllers/doc-input.controller.d.ts +5 -3
- package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +2 -3
- package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +2 -2
- package/lib/types/index.d.ts +2 -2
- package/lib/types/locale/zh-CN.d.ts +1 -0
- package/lib/types/services/doc-auto-format.service.d.ts +2 -2
- package/lib/types/services/doc-event-manager.service.d.ts +2 -2
- package/lib/types/services/doc-ime-input-manager.service.d.ts +1 -1
- package/lib/types/services/doc-menu-style.service.d.ts +12 -0
- package/lib/types/services/doc-state-change-manager.service.d.ts +10 -0
- package/lib/types/services/selection/text-range.d.ts +2 -2
- package/lib/types/views/doc-container/DocContainer.d.ts +1 -1
- package/lib/umd/index.js +9 -9
- package/package.json +9 -9
- /package/lib/types/commands/commands/{delete.command.d.ts → doc-delete.command.d.ts} +0 -0
package/lib/es/index.js
CHANGED
|
@@ -2,30 +2,30 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { Inject, Disposable, toDisposable, UniverInstanceType, BuildTextUtils, IUniverInstanceService, TextX, JSONX, TextXActionType, getBodySlice, Tools, UpdateDocsAttributeType, ObjectRelativeFromH, ObjectRelativeFromV, CommandType, ICommandService, IUndoRedoService, DOC_RANGE_TYPE, RANGE_DIRECTION, COLORS, BooleanNumber, Rectangle, RxDisposable, DataStreamTreeTokenType, ILogService, DEFAULT_STYLES, createIdentifier, EDITOR_ACTIVATED, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, FOCUSING_EDITOR_INPUT_FORMULA, DEFAULT_EMPTY_DOCUMENT_VALUE, VerticalAlign, HorizontalAlign, IContextService, DocumentFlavor, useDependency, LocaleService, isInternalEditorID, debounce, PresetListType, sequenceExecuteAsync, FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_COMMON_DRAWINGS, MemoryCursor, BaselineOffset, PRESET_LIST_TYPE, GridType, sortRulesFactory, useObservable, TableCellHeightRule, TableSizeType, generateRandomId, TableAlignmentType, TableTextWrapType, PositionedObjectLayoutType,
|
|
5
|
+
import { Inject, Disposable, toDisposable, UniverInstanceType, BuildTextUtils, IUniverInstanceService, TextX, JSONX, TextXActionType, getBodySlice, Tools, UpdateDocsAttributeType, ObjectRelativeFromH, ObjectRelativeFromV, CommandType, ICommandService, IUndoRedoService, DOC_RANGE_TYPE, RANGE_DIRECTION, COLORS, BooleanNumber, Rectangle, RxDisposable, DataStreamTreeTokenType, ILogService, DEFAULT_STYLES, createIdentifier, EDITOR_ACTIVATED, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, FOCUSING_EDITOR_INPUT_FORMULA, DEFAULT_EMPTY_DOCUMENT_VALUE, VerticalAlign, HorizontalAlign, IContextService, DocumentFlavor, useDependency, LocaleService, isInternalEditorID, debounce, PresetListType, sequenceExecuteAsync, FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_COMMON_DRAWINGS, MemoryCursor, BaselineOffset, PRESET_LIST_TYPE, GridType, sortRulesFactory, useObservable, TableCellHeightRule, TableSizeType, generateRandomId, TableAlignmentType, TableTextWrapType, PositionedObjectLayoutType, LRUMap, ColorKit, skipParseTagNames, CustomRangeType, DataStreamTreeNodeType, SliceBodyType, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, normalizeBody, SpacingRule, ThemeService, DOCS_ZEN_EDITOR_UNIT_ID_KEY, Injector, connectInjector, IConfigService, QuickListTypeMap, Direction, DisposableCollection, fromEventSubject, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, checkForSubstrings, UndoCommandId, RedoCommandId, DependentOn, Plugin, touchDependencies, mergeOverrideWithDependencies } from "@univerjs/core";
|
|
6
6
|
import { DocSelectionManagerService, RichTextEditingMutation, DocSkeletonManagerService, SetTextSelectionsOperation, DocStateEmitService, DocInterceptorService } from "@univerjs/docs";
|
|
7
7
|
import { IRenderManagerService, Liquid, GlyphType, DocumentSkeletonPageType, getPageFromPath, getTableIdAndSliceIndex, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, getColor, RegularPolygon, Rect, getOffsetRectForDom, ScrollTimer, CURSOR_TYPE, getSystemHighlightColor, Vector2, PageLayoutType, DocumentEditArea, Shape, Path, getCharSpaceApply, getNumberUnitValue, hasListGlyph, isIndentByGlyph, isFirstGlyph, getParagraphByGlyph, pixelToPt, ptToPixel, parseDataStreamToTree, Viewport, ScrollBar, Layer, Documents, DocBackground, lineIterator, getLastLine, pxToNum, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
8
8
|
import * as require$$0 from "react";
|
|
9
9
|
import require$$0__default, { useState, useRef, useEffect, forwardRef, createElement, useMemo, useCallback } from "react";
|
|
10
10
|
import { LexerTreeBuilder, operatorToken, isReferenceStrings, serializeRange, serializeRangeWithSheet, serializeRangeWithSpreadsheet, isReferenceStringWithEffectiveColumn, getRangeWithRefsString } from "@univerjs/engine-formula";
|
|
11
|
-
import { Subject, BehaviorSubject, takeUntil, fromEvent, merge, combineLatest, Observable, map as map$1, distinctUntilChanged, filter as filter$1, throttleTime,
|
|
11
|
+
import { Subject, BehaviorSubject, takeUntil, fromEvent, merge, combineLatest, Observable, map as map$1, distinctUntilChanged, filter as filter$1, throttleTime, switchMap, take, animationFrameScheduler } from "rxjs";
|
|
12
12
|
import { ILayoutService, KeyCode, useEvent, ComponentManager, ISidebarService, MetaKeys, IClipboardInterfaceService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, CopyCommand, CutCommand, PasteCommand, IConfirmService, MenuItemType, getMenuHiddenObservable, FONT_FAMILY_LIST, FONT_SIZE_LIST, getHeaderFooterMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, FontFamily, FontFamilyItem, FontSize, BuiltInUIPart, IMenuManagerService, IUIPartsService, IShortcutService, ICanvasPopupService, IContextMenuService, SetEditorResizeOperation } from "@univerjs/ui";
|
|
13
13
|
import { filter, bufferTime, map } from "rxjs/operators";
|
|
14
14
|
import { Tooltip, Dialog, Button, Input, Checkbox, InputNumber, Slider, Select, ColorPicker } from "@univerjs/design";
|
|
15
|
-
var __defProp$
|
|
16
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
15
|
+
var __defProp$s = Object.defineProperty, __getOwnPropDesc$s = Object.getOwnPropertyDescriptor, __decorateClass$s = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
16
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$s(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
17
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
18
|
-
return kind && result && __defProp$
|
|
19
|
-
}, "__decorateClass$
|
|
18
|
+
return kind && result && __defProp$s(target, key, result), result;
|
|
19
|
+
}, "__decorateClass$s"), __decorateParam$s = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$s");
|
|
20
20
|
function getParagraphsInRange$1(activeRange, paragraphs) {
|
|
21
|
-
var
|
|
21
|
+
var _a29, _b2;
|
|
22
22
|
const { startOffset, endOffset } = activeRange, results = [];
|
|
23
23
|
let start = -1;
|
|
24
24
|
for (let i = 0; i < paragraphs.length; i++) {
|
|
25
25
|
const paragraph = paragraphs[i], prevParagraph = paragraphs[i - 1], { startIndex } = paragraph;
|
|
26
26
|
startOffset > start && startOffset <= startIndex || endOffset > start && endOffset <= startIndex ? results.push({
|
|
27
27
|
...paragraph,
|
|
28
|
-
paragraphStart: ((
|
|
28
|
+
paragraphStart: ((_a29 = prevParagraph == null ? void 0 : prevParagraph.startIndex) != null ? _a29 : -1) + 1,
|
|
29
29
|
paragraphEnd: paragraph.startIndex
|
|
30
30
|
}) : startIndex >= startOffset && startIndex <= endOffset && results.push({
|
|
31
31
|
...paragraph,
|
|
@@ -46,8 +46,8 @@ let DocAutoFormatService = (_a = class extends Disposable {
|
|
|
46
46
|
registerAutoFormat(match) {
|
|
47
47
|
const matchList = this._matches.get(match.id);
|
|
48
48
|
return matchList ? (matchList.push(match), matchList.sort((a, b) => {
|
|
49
|
-
var
|
|
50
|
-
return ((
|
|
49
|
+
var _a29, _b2;
|
|
50
|
+
return ((_a29 = b.priority) != null ? _a29 : 0) - ((_b2 = a.priority) != null ? _b2 : 0);
|
|
51
51
|
})) : this._matches.set(match.id, [match]), toDisposable(() => {
|
|
52
52
|
const matchList2 = this._matches.get(match.id);
|
|
53
53
|
if (matchList2) {
|
|
@@ -57,15 +57,15 @@ let DocAutoFormatService = (_a = class extends Disposable {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
onAutoFormat(id, params) {
|
|
60
|
-
var
|
|
61
|
-
const autoFormats = (
|
|
60
|
+
var _a29, _b2, _c, _d, _e, _f;
|
|
61
|
+
const autoFormats = (_a29 = this._matches.get(id)) != null ? _a29 : [], unit = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), selection = this._textSelectionManagerService.getActiveTextRange();
|
|
62
62
|
if (unit && selection) {
|
|
63
63
|
const doc = unit.getSelfOrHeaderFooterModel(selection.segmentId), context = {
|
|
64
64
|
unit: doc,
|
|
65
65
|
selection,
|
|
66
66
|
isBody: !selection.segmentId,
|
|
67
67
|
paragraphs: getParagraphsInRange$1(selection, (_c = (_b2 = doc.getBody()) == null ? void 0 : _b2.paragraphs) != null ? _c : []),
|
|
68
|
-
customRanges: BuildTextUtils.customRange.
|
|
68
|
+
customRanges: BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_e = (_d = doc.getBody()) == null ? void 0 : _d.customRanges) != null ? _e : []),
|
|
69
69
|
commandId: id,
|
|
70
70
|
commandParams: params
|
|
71
71
|
}, matched = autoFormats.find((i) => i.match(context));
|
|
@@ -74,9 +74,9 @@ let DocAutoFormatService = (_a = class extends Disposable {
|
|
|
74
74
|
return [];
|
|
75
75
|
}
|
|
76
76
|
}, __name(_a, "DocAutoFormatService"), _a);
|
|
77
|
-
DocAutoFormatService = __decorateClass$
|
|
78
|
-
__decorateParam$
|
|
79
|
-
__decorateParam$
|
|
77
|
+
DocAutoFormatService = __decorateClass$s([
|
|
78
|
+
__decorateParam$s(0, IUniverInstanceService),
|
|
79
|
+
__decorateParam$s(1, Inject(DocSelectionManagerService))
|
|
80
80
|
], DocAutoFormatService);
|
|
81
81
|
const DefaultToolbarConfig = {
|
|
82
82
|
undo: !0,
|
|
@@ -175,8 +175,7 @@ function addCustomDecorationFactory(param) {
|
|
|
175
175
|
const range = ranges[i], { startOffset: start, endOffset: end } = range;
|
|
176
176
|
start > 0 && textX.push({
|
|
177
177
|
t: TextXActionType.RETAIN,
|
|
178
|
-
len: start - cursor
|
|
179
|
-
segmentId
|
|
178
|
+
len: start - cursor
|
|
180
179
|
}), textX.push({
|
|
181
180
|
t: TextXActionType.RETAIN,
|
|
182
181
|
body: {
|
|
@@ -188,8 +187,7 @@ function addCustomDecorationFactory(param) {
|
|
|
188
187
|
endIndex: end - start - 1
|
|
189
188
|
}]
|
|
190
189
|
},
|
|
191
|
-
len: end - start
|
|
192
|
-
segmentId
|
|
190
|
+
len: end - start
|
|
193
191
|
}), cursor = end;
|
|
194
192
|
}
|
|
195
193
|
return doMutation.params.actions = jsonX.editOp(textX.serialize()), doMutation;
|
|
@@ -212,17 +210,17 @@ function addCustomDecorationBySelectionFactory(accessor, param) {
|
|
|
212
210
|
}
|
|
213
211
|
__name(addCustomDecorationBySelectionFactory, "addCustomDecorationBySelectionFactory");
|
|
214
212
|
function deleteCustomDecorationFactory(accessor, params) {
|
|
215
|
-
var
|
|
213
|
+
var _a29, _b2;
|
|
216
214
|
const { unitId, id, segmentId } = params, documentDataModel = accessor.get(IUniverInstanceService).getUnit(unitId), body = documentDataModel == null ? void 0 : documentDataModel.getBody();
|
|
217
215
|
if (!documentDataModel || !body)
|
|
218
216
|
return !1;
|
|
219
|
-
const decorations = (_b2 = (
|
|
217
|
+
const decorations = (_b2 = (_a29 = documentDataModel.getBody()) == null ? void 0 : _a29.customDecorations) == null ? void 0 : _b2.filter((d) => d.id === id);
|
|
220
218
|
if (!(decorations != null && decorations.length))
|
|
221
219
|
return !1;
|
|
222
220
|
const oldBodySlices = decorations.map((i) => getBodySlice(body, i.startIndex, i.endIndex + 1)), bodySlices = oldBodySlices.map((bodySlice) => {
|
|
223
|
-
var
|
|
221
|
+
var _a30;
|
|
224
222
|
const copy = Tools.deepClone(bodySlice);
|
|
225
|
-
return copy.customDecorations = (
|
|
223
|
+
return copy.customDecorations = (_a30 = copy.customDecorations) == null ? void 0 : _a30.filter((decoration) => decoration.id !== id), copy;
|
|
226
224
|
}), doMutation = {
|
|
227
225
|
id: RichTextEditingMutation.id,
|
|
228
226
|
params: {
|
|
@@ -236,12 +234,10 @@ function deleteCustomDecorationFactory(accessor, params) {
|
|
|
236
234
|
const bodySlice = bodySlices[i], oldBody = oldBodySlices[i];
|
|
237
235
|
decoration.startIndex !== cursor && textX.push({
|
|
238
236
|
t: TextXActionType.RETAIN,
|
|
239
|
-
len: decoration.startIndex - cursor
|
|
240
|
-
segmentId
|
|
237
|
+
len: decoration.startIndex - cursor
|
|
241
238
|
}), cursor = decoration.startIndex, textX.push({
|
|
242
239
|
t: TextXActionType.RETAIN,
|
|
243
240
|
len: decoration.endIndex - decoration.startIndex + 1,
|
|
244
|
-
segmentId,
|
|
245
241
|
body: bodySlice,
|
|
246
242
|
oldBody,
|
|
247
243
|
coverType: UpdateDocsAttributeType.REPLACE
|
|
@@ -250,8 +246,8 @@ function deleteCustomDecorationFactory(accessor, params) {
|
|
|
250
246
|
}
|
|
251
247
|
__name(deleteCustomDecorationFactory, "deleteCustomDecorationFactory");
|
|
252
248
|
function getCommandSkeleton(accessor, unitId) {
|
|
253
|
-
var
|
|
254
|
-
return (
|
|
249
|
+
var _a29;
|
|
250
|
+
return (_a29 = accessor.get(IRenderManagerService).getRenderById(unitId)) == null ? void 0 : _a29.with(DocSkeletonManagerService);
|
|
255
251
|
}
|
|
256
252
|
__name(getCommandSkeleton, "getCommandSkeleton");
|
|
257
253
|
function getRichTextEditPath(docDataModel, segmentId = "") {
|
|
@@ -286,8 +282,8 @@ function addCustomRangeFactory(accessor, param, body) {
|
|
|
286
282
|
}
|
|
287
283
|
__name(addCustomRangeFactory, "addCustomRangeFactory");
|
|
288
284
|
function addCustomRangeBySelectionFactory(accessor, param) {
|
|
289
|
-
var
|
|
290
|
-
const { rangeId, rangeType, wholeEntity, properties, unitId, selection: propSelection } = param, docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), selection = propSelection != null ? propSelection : (
|
|
285
|
+
var _a29;
|
|
286
|
+
const { rangeId, rangeType, wholeEntity, properties, unitId, selection: propSelection } = param, docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), selection = propSelection != null ? propSelection : (_a29 = docSelectionManagerService.getTextRanges({ unitId, subUnitId: unitId })) == null ? void 0 : _a29[0], segmentId = selection == null ? void 0 : selection.segmentId;
|
|
291
287
|
if (!selection)
|
|
292
288
|
return !1;
|
|
293
289
|
const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
@@ -320,8 +316,8 @@ function addCustomRangeBySelectionFactory(accessor, param) {
|
|
|
320
316
|
}
|
|
321
317
|
__name(addCustomRangeBySelectionFactory, "addCustomRangeBySelectionFactory");
|
|
322
318
|
function deleteCustomRangeFactory(accessor, params) {
|
|
323
|
-
var
|
|
324
|
-
const { unitId, segmentId, insert } = params, univerInstanceService = accessor.get(IUniverInstanceService), selection = (
|
|
319
|
+
var _a29;
|
|
320
|
+
const { unitId, segmentId, insert } = params, univerInstanceService = accessor.get(IUniverInstanceService), selection = (_a29 = accessor.get(DocSelectionManagerService).getTextRanges({ unitId, subUnitId: unitId })) == null ? void 0 : _a29[0], documentDataModel = univerInstanceService.getUnit(unitId);
|
|
325
321
|
if (!documentDataModel)
|
|
326
322
|
return !1;
|
|
327
323
|
const textRange = selection != null && selection.collapsed ? { index: selection.startOffset } : void 0, doMutation = {
|
|
@@ -349,13 +345,28 @@ function hasParagraphInTable(paragraph, tables) {
|
|
|
349
345
|
return tables.some((table) => paragraph.startIndex > table.startIndex && paragraph.startIndex < table.endIndex);
|
|
350
346
|
}
|
|
351
347
|
__name(hasParagraphInTable, "hasParagraphInTable");
|
|
348
|
+
function getTextRunAtPosition(textRuns, position, cacheStyle) {
|
|
349
|
+
for (let i = textRuns.length - 1; i >= 0; i--) {
|
|
350
|
+
const textRun = textRuns[i], { st, ed } = textRun;
|
|
351
|
+
if (position > st && position <= ed)
|
|
352
|
+
return {
|
|
353
|
+
...textRun,
|
|
354
|
+
ts: {
|
|
355
|
+
...textRun.ts,
|
|
356
|
+
...cacheStyle
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return cacheStyle ? { ts: cacheStyle } : null;
|
|
361
|
+
}
|
|
362
|
+
__name(getTextRunAtPosition, "getTextRunAtPosition");
|
|
352
363
|
function replaceSelectionFactory(accessor, params) {
|
|
353
|
-
var
|
|
364
|
+
var _a29, _b2, _c, _d;
|
|
354
365
|
const { unitId, body: insertBody, doc } = params;
|
|
355
366
|
let docDataModel = doc;
|
|
356
367
|
if (docDataModel || (docDataModel = accessor.get(IUniverInstanceService).getUnit(unitId)), !docDataModel)
|
|
357
368
|
return !1;
|
|
358
|
-
const segmentId = (
|
|
369
|
+
const segmentId = (_a29 = params.selection) == null ? void 0 : _a29.segmentId, body = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _b2.getBody();
|
|
359
370
|
if (!body) return !1;
|
|
360
371
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), selection = (_c = params.selection) != null ? _c : docSelectionManagerService.getActiveTextRange();
|
|
361
372
|
if (!selection || !body)
|
|
@@ -541,15 +552,11 @@ function getMutationActions(segmentId, docDatModel, prevBody, body) {
|
|
|
541
552
|
const textX = new TextX(), jsonX = JSONX.getInstance(), deleteLen = (prevBody == null ? void 0 : prevBody.dataStream.length) - 2;
|
|
542
553
|
deleteLen > 0 && textX.push({
|
|
543
554
|
t: TextXActionType.DELETE,
|
|
544
|
-
len: deleteLen
|
|
545
|
-
line: 0,
|
|
546
|
-
segmentId
|
|
555
|
+
len: deleteLen
|
|
547
556
|
}), body.dataStream.length > 0 && textX.push({
|
|
548
557
|
t: TextXActionType.INSERT,
|
|
549
558
|
body,
|
|
550
|
-
len: body.dataStream.length
|
|
551
|
-
line: 0,
|
|
552
|
-
segmentId
|
|
559
|
+
len: body.dataStream.length
|
|
553
560
|
});
|
|
554
561
|
const path = getRichTextEditPath(docDatModel, segmentId);
|
|
555
562
|
return jsonX.editOp(textX.serialize(), path);
|
|
@@ -775,7 +782,7 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
|
|
|
775
782
|
}
|
|
776
783
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
777
784
|
_selectionIterator(startPosition, endPosition, func) {
|
|
778
|
-
var
|
|
785
|
+
var _a29, _b2;
|
|
779
786
|
const skeleton = this._docSkeleton;
|
|
780
787
|
if (!skeleton)
|
|
781
788
|
return [];
|
|
@@ -796,7 +803,7 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
|
|
|
796
803
|
for (let p2 = skipPageIndex; p2 <= endIndex; p2++) {
|
|
797
804
|
const page = pages[p2], { headerId, footerId, pageWidth } = page;
|
|
798
805
|
let segmentPage2 = page;
|
|
799
|
-
if (pageType === DocumentSkeletonPageType.HEADER ? segmentPage2 = (
|
|
806
|
+
if (pageType === DocumentSkeletonPageType.HEADER ? segmentPage2 = (_a29 = skeHeaders.get(headerId)) == null ? void 0 : _a29.get(pageWidth) : pageType === DocumentSkeletonPageType.FOOTER ? segmentPage2 = (_b2 = skeFooters.get(footerId)) == null ? void 0 : _b2.get(pageWidth) : pageType === DocumentSkeletonPageType.CELL && (segmentPage2 = getPageFromPath(skeletonData, path)), segmentPage2 == null) {
|
|
800
807
|
this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
801
808
|
continue;
|
|
802
809
|
}
|
|
@@ -1100,8 +1107,8 @@ const _TextRange = class _TextRange {
|
|
|
1100
1107
|
}
|
|
1101
1108
|
// The start position of the range
|
|
1102
1109
|
get startOffset() {
|
|
1103
|
-
var
|
|
1104
|
-
const { startOffset } = (
|
|
1110
|
+
var _a29;
|
|
1111
|
+
const { startOffset } = (_a29 = getOneTextSelectionRange(this._cursorList)) != null ? _a29 : {}, body = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId).getBody();
|
|
1105
1112
|
if (startOffset == null || body == null)
|
|
1106
1113
|
return startOffset;
|
|
1107
1114
|
const maxLength = body.dataStream.length - 2;
|
|
@@ -1109,8 +1116,8 @@ const _TextRange = class _TextRange {
|
|
|
1109
1116
|
}
|
|
1110
1117
|
// The end position of the range
|
|
1111
1118
|
get endOffset() {
|
|
1112
|
-
var
|
|
1113
|
-
const { endOffset } = (
|
|
1119
|
+
var _a29;
|
|
1120
|
+
const { endOffset } = (_a29 = getOneTextSelectionRange(this._cursorList)) != null ? _a29 : {}, body = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId).getBody();
|
|
1114
1121
|
if (endOffset == null || body == null)
|
|
1115
1122
|
return endOffset;
|
|
1116
1123
|
const maxLength = body.dataStream.length - 2;
|
|
@@ -1176,15 +1183,15 @@ const _TextRange = class _TextRange {
|
|
|
1176
1183
|
return this._anchorShape;
|
|
1177
1184
|
}
|
|
1178
1185
|
activeStatic() {
|
|
1179
|
-
var
|
|
1186
|
+
var _a29, _b2;
|
|
1180
1187
|
(_b2 = this._anchorShape) == null || _b2.setProps({
|
|
1181
|
-
stroke: ((
|
|
1188
|
+
stroke: ((_a29 = this.style) == null ? void 0 : _a29.strokeActive) || getColor(COLORS.black, 1)
|
|
1182
1189
|
});
|
|
1183
1190
|
}
|
|
1184
1191
|
deactivateStatic() {
|
|
1185
|
-
var
|
|
1192
|
+
var _a29, _b2;
|
|
1186
1193
|
(_b2 = this._anchorShape) == null || _b2.setProps({
|
|
1187
|
-
stroke: ((
|
|
1194
|
+
stroke: ((_a29 = this.style) == null ? void 0 : _a29.stroke) || getColor(COLORS.black, 0)
|
|
1188
1195
|
});
|
|
1189
1196
|
}
|
|
1190
1197
|
isActive() {
|
|
@@ -1197,8 +1204,8 @@ const _TextRange = class _TextRange {
|
|
|
1197
1204
|
this._current = !1;
|
|
1198
1205
|
}
|
|
1199
1206
|
dispose() {
|
|
1200
|
-
var
|
|
1201
|
-
(
|
|
1207
|
+
var _a29, _b2;
|
|
1208
|
+
(_a29 = this._rangeShape) == null || _a29.dispose(), this._rangeShape = null, (_b2 = this._anchorShape) == null || _b2.dispose(), this._anchorShape = null, this._anchorBlinkTimer && (clearInterval(this._anchorBlinkTimer), this._anchorBlinkTimer = null);
|
|
1202
1209
|
}
|
|
1203
1210
|
isIntersection(compareRange) {
|
|
1204
1211
|
const { startOffset: activeStart, endOffset: activeEnd } = this, { startOffset: compareStart, endOffset: compareEnd } = compareRange;
|
|
@@ -1206,9 +1213,9 @@ const _TextRange = class _TextRange {
|
|
|
1206
1213
|
}
|
|
1207
1214
|
// render cursor and selection.
|
|
1208
1215
|
refresh() {
|
|
1209
|
-
var
|
|
1216
|
+
var _a29, _b2;
|
|
1210
1217
|
const { _document, _docSkeleton } = this, anchor = this.anchorNodePosition, focus = this.focusNodePosition;
|
|
1211
|
-
if ((
|
|
1218
|
+
if ((_a29 = this._anchorShape) == null || _a29.hide(), (_b2 = this._rangeShape) == null || _b2.hide(), this._isEmpty())
|
|
1212
1219
|
return;
|
|
1213
1220
|
const documentOffsetConfig = _document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, convertor = new NodePositionConvertToCursor(documentOffsetConfig, _docSkeleton);
|
|
1214
1221
|
if (this._isCollapsed()) {
|
|
@@ -1240,14 +1247,14 @@ const _TextRange = class _TextRange {
|
|
|
1240
1247
|
return anchor.isBack === focus.isBack;
|
|
1241
1248
|
}
|
|
1242
1249
|
_createOrUpdateRange(pointsGroup, left, top) {
|
|
1243
|
-
var
|
|
1250
|
+
var _a29;
|
|
1244
1251
|
if (this._rangeShape) {
|
|
1245
1252
|
this._rangeShape.translate(left, top), this._rangeShape.updatePointGroup(pointsGroup), this._rangeShape.show();
|
|
1246
1253
|
return;
|
|
1247
1254
|
}
|
|
1248
1255
|
const OPACITY = 0.3, polygon = new RegularPolygon(TEXT_RANGE_KEY_PREFIX + Tools.generateRandomId(ID_LENGTH$2), {
|
|
1249
1256
|
pointsGroup,
|
|
1250
|
-
fill: ((
|
|
1257
|
+
fill: ((_a29 = this.style) == null ? void 0 : _a29.fill) || getColor(COLORS.black, OPACITY),
|
|
1251
1258
|
left,
|
|
1252
1259
|
top,
|
|
1253
1260
|
evented: !1,
|
|
@@ -1256,14 +1263,14 @@ const _TextRange = class _TextRange {
|
|
|
1256
1263
|
this._rangeShape = polygon, this._scene.addObject(polygon, TEXT_RANGE_LAYER_INDEX);
|
|
1257
1264
|
}
|
|
1258
1265
|
_createOrUpdateAnchor(pointsGroup, docsLeft, docsTop, glyph) {
|
|
1259
|
-
var
|
|
1266
|
+
var _a29, _b2, _c;
|
|
1260
1267
|
const bounding = getAnchorBounding(pointsGroup), { left: boundingLeft } = bounding;
|
|
1261
1268
|
let { top: boundingTop, height } = bounding;
|
|
1262
1269
|
const MIN_CURSOR_HEIGHT = 14;
|
|
1263
1270
|
height < MIN_CURSOR_HEIGHT && (boundingTop -= MIN_CURSOR_HEIGHT - height, height = MIN_CURSOR_HEIGHT);
|
|
1264
1271
|
const ITALIC_DEGREE = 12;
|
|
1265
1272
|
let left = boundingLeft + docsLeft;
|
|
1266
|
-
const top = boundingTop + docsTop, isItalic = ((
|
|
1273
|
+
const top = boundingTop + docsTop, isItalic = ((_a29 = glyph == null ? void 0 : glyph.ts) == null ? void 0 : _a29.it) === BooleanNumber.TRUE;
|
|
1267
1274
|
if (isItalic && (left += height * Math.tan(ITALIC_DEGREE * Math.PI / 180) / 2), this._anchorShape) {
|
|
1268
1275
|
this._anchorShape.transformByState({ left, top, height }), this._anchorShape.show(), isItalic ? this._anchorShape.skew(-ITALIC_DEGREE, 0) : this._anchorShape.skew(0, 0);
|
|
1269
1276
|
return;
|
|
@@ -1351,16 +1358,16 @@ const _RectRange = class _RectRange {
|
|
|
1351
1358
|
return this._segmentPage;
|
|
1352
1359
|
}
|
|
1353
1360
|
get spanEntireRow() {
|
|
1354
|
-
var
|
|
1355
|
-
const table = (
|
|
1361
|
+
var _a29;
|
|
1362
|
+
const table = (_a29 = this._docSkeleton.getViewModel().getSnapshot().tableSource) == null ? void 0 : _a29[this._tableId], { _startCol, _endCol } = this;
|
|
1356
1363
|
if (table == null)
|
|
1357
1364
|
throw new Error("Table is not found.");
|
|
1358
1365
|
const { tableColumns } = table;
|
|
1359
1366
|
return _startCol === 0 && _endCol === tableColumns.length - 1;
|
|
1360
1367
|
}
|
|
1361
1368
|
get spanEntireColumn() {
|
|
1362
|
-
var
|
|
1363
|
-
const table = (
|
|
1369
|
+
var _a29;
|
|
1370
|
+
const table = (_a29 = this._docSkeleton.getViewModel().getSnapshot().tableSource) == null ? void 0 : _a29[this._tableId], { _startRow, _endRow } = this;
|
|
1364
1371
|
if (table == null)
|
|
1365
1372
|
throw new Error("Table is not found.");
|
|
1366
1373
|
const { tableRows } = table;
|
|
@@ -1391,8 +1398,8 @@ const _RectRange = class _RectRange {
|
|
|
1391
1398
|
this._current = !1;
|
|
1392
1399
|
}
|
|
1393
1400
|
dispose() {
|
|
1394
|
-
var
|
|
1395
|
-
(
|
|
1401
|
+
var _a29;
|
|
1402
|
+
(_a29 = this._rangeShape) == null || _a29.dispose(), this._rangeShape = null;
|
|
1396
1403
|
}
|
|
1397
1404
|
isIntersection(compareRange) {
|
|
1398
1405
|
const { startRow, startColumn, endRow, endColumn } = this, { startRow: cStartRow, startColumn: cStartColumn, endRow: cEndRow, endColumn: cEndColumn } = compareRange, rect1 = {
|
|
@@ -1409,8 +1416,8 @@ const _RectRange = class _RectRange {
|
|
|
1409
1416
|
return Rectangle.hasIntersectionBetweenTwoRect(rect1, rect2);
|
|
1410
1417
|
}
|
|
1411
1418
|
refresh() {
|
|
1412
|
-
var
|
|
1413
|
-
(
|
|
1419
|
+
var _a29;
|
|
1420
|
+
(_a29 = this._rangeShape) == null || _a29.hide();
|
|
1414
1421
|
const { startNodePosition, endNodePosition, _document, _docSkeleton } = this, documentOffsetConfig = _document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, rectInfo = new NodePositionConvertToRectRange(documentOffsetConfig, _docSkeleton).getRangePointData(startNodePosition, endNodePosition);
|
|
1415
1422
|
if (rectInfo == null)
|
|
1416
1423
|
return;
|
|
@@ -1421,14 +1428,14 @@ const _RectRange = class _RectRange {
|
|
|
1421
1428
|
this._startRow = startRow, this._endRow = endRow, this._startCol = startCol, this._endCol = endCol, this._tableId = tableId;
|
|
1422
1429
|
}
|
|
1423
1430
|
_createOrUpdateRange(pointsGroup, left, top) {
|
|
1424
|
-
var
|
|
1431
|
+
var _a29;
|
|
1425
1432
|
if (this._rangeShape) {
|
|
1426
1433
|
this._rangeShape.translate(left, top), this._rangeShape.updatePointGroup(pointsGroup), this._rangeShape.show();
|
|
1427
1434
|
return;
|
|
1428
1435
|
}
|
|
1429
1436
|
const OPACITY = 0.3, polygon = new RegularPolygon(RECT_RANGE_KEY_PREFIX + Tools.generateRandomId(ID_LENGTH$1), {
|
|
1430
1437
|
pointsGroup,
|
|
1431
|
-
fill: ((
|
|
1438
|
+
fill: ((_a29 = this.style) == null ? void 0 : _a29.fill) || getColor(COLORS.black, OPACITY),
|
|
1432
1439
|
left,
|
|
1433
1440
|
top,
|
|
1434
1441
|
evented: !1,
|
|
@@ -1548,8 +1555,8 @@ function getCanvasOffsetByEngine(engine) {
|
|
|
1548
1555
|
}
|
|
1549
1556
|
__name(getCanvasOffsetByEngine, "getCanvasOffsetByEngine");
|
|
1550
1557
|
function getParagraphInfoByGlyph(node) {
|
|
1551
|
-
var
|
|
1552
|
-
const line = (
|
|
1558
|
+
var _a29;
|
|
1559
|
+
const line = (_a29 = node.parent) == null ? void 0 : _a29.parent, column = line == null ? void 0 : line.parent;
|
|
1553
1560
|
if (line == null || column == null)
|
|
1554
1561
|
return;
|
|
1555
1562
|
const { paragraphIndex } = line, lines = column.lines.filter((line2) => line2.paragraphIndex === paragraphIndex);
|
|
@@ -1606,11 +1613,11 @@ function serializeRectRange(rectRange) {
|
|
|
1606
1613
|
};
|
|
1607
1614
|
}
|
|
1608
1615
|
__name(serializeRectRange, "serializeRectRange");
|
|
1609
|
-
var __defProp$
|
|
1610
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1616
|
+
var __defProp$r = Object.defineProperty, __getOwnPropDesc$r = Object.getOwnPropertyDescriptor, __decorateClass$r = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1617
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1611
1618
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1612
|
-
return kind && result && __defProp$
|
|
1613
|
-
}, "__decorateClass$
|
|
1619
|
+
return kind && result && __defProp$r(target, key, result), result;
|
|
1620
|
+
}, "__decorateClass$r"), __decorateParam$r = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$r"), _a2;
|
|
1614
1621
|
let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
1615
1622
|
constructor(_context, _layoutService, _logService, _univerInstanceService, _docSkeletonManagerService) {
|
|
1616
1623
|
super();
|
|
@@ -1878,7 +1885,7 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1878
1885
|
// Handle pointer down.
|
|
1879
1886
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1880
1887
|
__onPointDown(evt) {
|
|
1881
|
-
var
|
|
1888
|
+
var _a29, _b2;
|
|
1882
1889
|
this._editorFocusing = !0;
|
|
1883
1890
|
const { scene, mainComponent } = this._context, skeleton = this._docSkeletonManagerService.getSkeleton(), { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this._findNodeByCoord(evtOffsetX, evtOffsetY, {
|
|
1884
1891
|
strict: !1,
|
|
@@ -1899,7 +1906,7 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1899
1906
|
const { segmentId, segmentPage } = startNode;
|
|
1900
1907
|
segmentId && this._currentSegmentId && segmentId !== this._currentSegmentId && this.setSegment(segmentId), segmentId && segmentPage !== this._currentSegmentPage && this.setSegmentPage(segmentPage), this._anchorNodePosition = position, evt.shiftKey && this._getActiveRangeInstance() ? this._updateActiveRangePosition(position) : evt.ctrlKey ? this._removeAllCollapsedTextRanges() : this._isEmpty() || this._removeAllRanges(), scene.disableObjectsEvent();
|
|
1901
1908
|
const scrollTimer = ScrollTimer.create(scene);
|
|
1902
|
-
this._scrollTimers.push(scrollTimer), scrollTimer.startScroll(evtOffsetX, evtOffsetY), this._onSelectionStart$.next((
|
|
1909
|
+
this._scrollTimers.push(scrollTimer), scrollTimer.startScroll(evtOffsetX, evtOffsetY), this._onSelectionStart$.next((_a29 = this._getActiveRangeInstance()) == null ? void 0 : _a29.startNodePosition), (_b2 = scene.getTransformer()) == null || _b2.clearSelectedObjects();
|
|
1903
1910
|
let preMoveOffsetX = evtOffsetX, preMoveOffsetY = evtOffsetY;
|
|
1904
1911
|
this._scenePointerMoveSubs.push(scene.onPointerMove$.subscribeEvent((moveEvt) => {
|
|
1905
1912
|
const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;
|
|
@@ -2125,8 +2132,8 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
2125
2132
|
return this._rangeList.length === 0 && this._rectRangeList.length === 0;
|
|
2126
2133
|
}
|
|
2127
2134
|
_getCanvasOffset() {
|
|
2128
|
-
var
|
|
2129
|
-
const engine = (
|
|
2135
|
+
var _a29;
|
|
2136
|
+
const engine = (_a29 = this._context.scene) == null ? void 0 : _a29.getEngine();
|
|
2130
2137
|
return getCanvasOffsetByEngine(engine);
|
|
2131
2138
|
}
|
|
2132
2139
|
_updateInputPosition(forceFocus = !1) {
|
|
@@ -2140,7 +2147,7 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
2140
2147
|
canvasLeft += x, canvasTop += y, this.activate(canvasLeft, canvasTop, forceFocus);
|
|
2141
2148
|
}
|
|
2142
2149
|
_moving(moveOffsetX, moveOffsetY) {
|
|
2143
|
-
var
|
|
2150
|
+
var _a29, _b2;
|
|
2144
2151
|
const focusNode = this._findNodeByCoord(moveOffsetX, moveOffsetY, {
|
|
2145
2152
|
strict: !0,
|
|
2146
2153
|
segmentId: this._currentSegmentId,
|
|
@@ -2166,7 +2173,7 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
2166
2173
|
if (ranges == null)
|
|
2167
2174
|
return;
|
|
2168
2175
|
const { textRanges, rectRanges } = ranges;
|
|
2169
|
-
this._rangeList.length > 0 && textRanges.length > 0 && this._interactTextRanges(textRanges), this._rectRangeList.length > 0 && rectRanges.length > 0 && this._interactRectRanges(rectRanges), this._addTextRangesToCache(textRanges), this._addRectRangesToCache(rectRanges), this.deactivate(), (_b2 = (
|
|
2176
|
+
this._rangeList.length > 0 && textRanges.length > 0 && this._interactTextRanges(textRanges), this._rectRangeList.length > 0 && rectRanges.length > 0 && this._interactRectRanges(rectRanges), this._addTextRangesToCache(textRanges), this._addRectRangesToCache(rectRanges), this.deactivate(), (_b2 = (_a29 = this._context.scene) == null ? void 0 : _a29.getEngine()) == null || _b2.setRemainCapture();
|
|
2170
2177
|
}
|
|
2171
2178
|
__attachScrollEvent() {
|
|
2172
2179
|
const viewport = this.activeViewPort;
|
|
@@ -2300,11 +2307,11 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
2300
2307
|
this._onInputBefore$.complete(), this._onKeydown$.complete(), this._onInput$.complete(), this._onCompositionstart$.complete(), this._onCompositionupdate$.complete(), this._onCompositionend$.complete(), this._onSelectionStart$.complete(), this._textSelectionInner$.complete(), this._onPaste$.complete(), this._onFocus$.complete(), this._onBlur$.complete(), this._onPointerDown$.complete();
|
|
2301
2308
|
}
|
|
2302
2309
|
}, __name(_a2, "DocSelectionRenderService"), _a2);
|
|
2303
|
-
DocSelectionRenderService = __decorateClass$
|
|
2304
|
-
__decorateParam$
|
|
2305
|
-
__decorateParam$
|
|
2306
|
-
__decorateParam$
|
|
2307
|
-
__decorateParam$
|
|
2310
|
+
DocSelectionRenderService = __decorateClass$r([
|
|
2311
|
+
__decorateParam$r(1, ILayoutService),
|
|
2312
|
+
__decorateParam$r(2, ILogService),
|
|
2313
|
+
__decorateParam$r(3, IUniverInstanceService),
|
|
2314
|
+
__decorateParam$r(4, Inject(DocSkeletonManagerService))
|
|
2308
2315
|
], DocSelectionRenderService);
|
|
2309
2316
|
const _Editor = class _Editor extends Disposable {
|
|
2310
2317
|
constructor(_param, _univerInstanceService, _docSelectionManagerService, _commandService, _undoRedoService) {
|
|
@@ -2466,8 +2473,8 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2466
2473
|
return this._param.render;
|
|
2467
2474
|
}
|
|
2468
2475
|
isSingleChoice() {
|
|
2469
|
-
var
|
|
2470
|
-
return (
|
|
2476
|
+
var _a29;
|
|
2477
|
+
return (_a29 = this._param.isSingleChoice) != null ? _a29 : !1;
|
|
2471
2478
|
}
|
|
2472
2479
|
/** @deprecated */
|
|
2473
2480
|
setOpenForSheetUnitId(unitId) {
|
|
@@ -2537,8 +2544,8 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2537
2544
|
* @deprecated use getDocumentData.
|
|
2538
2545
|
*/
|
|
2539
2546
|
getValue() {
|
|
2540
|
-
var
|
|
2541
|
-
return (((
|
|
2547
|
+
var _a29;
|
|
2548
|
+
return (((_a29 = this._getDocDataModel().getBody()) == null ? void 0 : _a29.dataStream) || "").replace(/\r\n/g, "").replace(/\n/g, "").replace(/\n/g, "");
|
|
2542
2549
|
}
|
|
2543
2550
|
/**
|
|
2544
2551
|
* @deprecated use getDocumentData.
|
|
@@ -2559,7 +2566,7 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2559
2566
|
* @deprecated.
|
|
2560
2567
|
*/
|
|
2561
2568
|
verticalAlign() {
|
|
2562
|
-
var
|
|
2569
|
+
var _a29;
|
|
2563
2570
|
const docDataModel = this._getDocDataModel();
|
|
2564
2571
|
if (docDataModel == null)
|
|
2565
2572
|
return;
|
|
@@ -2571,7 +2578,7 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2571
2578
|
return;
|
|
2572
2579
|
}
|
|
2573
2580
|
let fontSize = DEFAULT_STYLES.fs;
|
|
2574
|
-
(
|
|
2581
|
+
(_a29 = this._param.canvasStyle) != null && _a29.fontSize && (fontSize = this._param.canvasStyle.fontSize);
|
|
2575
2582
|
const top = (height - fontSize * 4 / 3) / 2 - 2;
|
|
2576
2583
|
docDataModel.updateDocumentDataMargin({
|
|
2577
2584
|
t: top < 0 ? 0 : top
|
|
@@ -2581,29 +2588,29 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2581
2588
|
* @deprecated.
|
|
2582
2589
|
*/
|
|
2583
2590
|
updateCanvasStyle() {
|
|
2584
|
-
var
|
|
2591
|
+
var _a29;
|
|
2585
2592
|
const docDataModel = this._getDocDataModel();
|
|
2586
2593
|
if (docDataModel == null)
|
|
2587
2594
|
return;
|
|
2588
2595
|
const documentStyle = {};
|
|
2589
|
-
(
|
|
2596
|
+
(_a29 = this._param.canvasStyle) != null && _a29.fontSize && (documentStyle.textStyle == null && (documentStyle.textStyle = {}), documentStyle.textStyle.fs = this._param.canvasStyle.fontSize), docDataModel.updateDocumentStyle(documentStyle);
|
|
2590
2597
|
}
|
|
2591
2598
|
_getDocDataModel() {
|
|
2592
2599
|
const editorUnitId = this._getEditorId();
|
|
2593
2600
|
return this._univerInstanceService.getUnit(editorUnitId, UniverInstanceType.UNIVER_DOC);
|
|
2594
2601
|
}
|
|
2595
2602
|
_getEditorId() {
|
|
2596
|
-
var
|
|
2597
|
-
return ((
|
|
2603
|
+
var _a29;
|
|
2604
|
+
return ((_a29 = this._param.initialSnapshot) == null ? void 0 : _a29.id) || this._param.editorUnitId || "";
|
|
2598
2605
|
}
|
|
2599
2606
|
};
|
|
2600
2607
|
__name(_Editor, "Editor");
|
|
2601
2608
|
let Editor = _Editor;
|
|
2602
|
-
var __defProp$
|
|
2603
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
2609
|
+
var __defProp$q = Object.defineProperty, __getOwnPropDesc$q = Object.getOwnPropertyDescriptor, __decorateClass$q = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2610
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2604
2611
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2605
|
-
return kind && result && __defProp$
|
|
2606
|
-
}, "__decorateClass$
|
|
2612
|
+
return kind && result && __defProp$q(target, key, result), result;
|
|
2613
|
+
}, "__decorateClass$q"), __decorateParam$q = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$q");
|
|
2607
2614
|
const editorFocusInElements = [
|
|
2608
2615
|
"univer-editor",
|
|
2609
2616
|
"univer-range-selector",
|
|
@@ -2722,7 +2729,7 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2722
2729
|
}), this._focusStyle$.next(), this._blur$.next(null);
|
|
2723
2730
|
}
|
|
2724
2731
|
/** @deprecated */
|
|
2725
|
-
focus(editorUnitId = ((
|
|
2732
|
+
focus(editorUnitId = ((_a29) => (_a29 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a29.getUnitId())()) {
|
|
2726
2733
|
if (editorUnitId == null)
|
|
2727
2734
|
return;
|
|
2728
2735
|
const editor = this.getEditor(editorUnitId);
|
|
@@ -2789,8 +2796,8 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2789
2796
|
}
|
|
2790
2797
|
/** @deprecated */
|
|
2791
2798
|
isVisible(id) {
|
|
2792
|
-
var
|
|
2793
|
-
return (
|
|
2799
|
+
var _a29;
|
|
2800
|
+
return (_a29 = this.getEditor(id)) == null ? void 0 : _a29.isVisible();
|
|
2794
2801
|
}
|
|
2795
2802
|
/** @deprecated */
|
|
2796
2803
|
setOperationSheetUnitId(unitId) {
|
|
@@ -2809,7 +2816,7 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2809
2816
|
return this._currentSheetSubUnitId;
|
|
2810
2817
|
}
|
|
2811
2818
|
register(config, container) {
|
|
2812
|
-
var
|
|
2819
|
+
var _a29, _b2, _c, _d;
|
|
2813
2820
|
const { initialSnapshot, canvasStyle = {} } = config, editorUnitId = initialSnapshot.id;
|
|
2814
2821
|
this._univerInstanceService.getUnit(editorUnitId, UniverInstanceType.UNIVER_DOC) == null && this._univerInstanceService.createUnit(
|
|
2815
2822
|
UniverInstanceType.UNIVER_DOC,
|
|
@@ -2826,7 +2833,7 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2826
2833
|
this._commandService,
|
|
2827
2834
|
this._undoRedoService
|
|
2828
2835
|
);
|
|
2829
|
-
this._editors.set(editorUnitId, editor), config.scrollBar || (_d = (_c = (_b2 = (
|
|
2836
|
+
this._editors.set(editorUnitId, editor), config.scrollBar || (_d = (_c = (_b2 = (_a29 = render2.mainComponent) == null ? void 0 : _a29.getScene()) == null ? void 0 : _b2.getViewports()) == null ? void 0 : _c[0].getScrollBar()) == null || _d.dispose(), !editor.isSheetEditor() && !config.noNeedVerticalAlign && (editor.verticalAlign(), editor.updateCanvasStyle());
|
|
2830
2837
|
}
|
|
2831
2838
|
return toDisposable(() => {
|
|
2832
2839
|
this._unRegister(editorUnitId);
|
|
@@ -2896,14 +2903,14 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2896
2903
|
};
|
|
2897
2904
|
}
|
|
2898
2905
|
}, __name(_b, "EditorService"), _b);
|
|
2899
|
-
EditorService = __decorateClass$
|
|
2900
|
-
__decorateParam$
|
|
2901
|
-
__decorateParam$
|
|
2902
|
-
__decorateParam$
|
|
2903
|
-
__decorateParam$
|
|
2904
|
-
__decorateParam$
|
|
2905
|
-
__decorateParam$
|
|
2906
|
-
__decorateParam$
|
|
2906
|
+
EditorService = __decorateClass$q([
|
|
2907
|
+
__decorateParam$q(0, IUniverInstanceService),
|
|
2908
|
+
__decorateParam$q(1, IRenderManagerService),
|
|
2909
|
+
__decorateParam$q(2, Inject(LexerTreeBuilder)),
|
|
2910
|
+
__decorateParam$q(3, Inject(DocSelectionManagerService)),
|
|
2911
|
+
__decorateParam$q(4, IContextService),
|
|
2912
|
+
__decorateParam$q(5, ICommandService),
|
|
2913
|
+
__decorateParam$q(6, IUndoRedoService)
|
|
2907
2914
|
], EditorService);
|
|
2908
2915
|
const IEditorService = createIdentifier("univer.editor.service"), textEditorContainer = "univer-text-editor-container", textEditorContainerActive = "univer-text-editor-container-active", textEditorContainerError = "univer-text-editor-container-error", textEditorContainerDisabled = "univer-text-editor-container-disabled", textEditorContainerPlaceholder = "univer-text-editor-container-placeholder", textEditorValidationError = "univer-text-editor-validation-error", styles$7 = {
|
|
2909
2916
|
textEditorContainer,
|
|
@@ -2933,7 +2940,7 @@ function genSnapShotByValue(id = "", value = "") {
|
|
|
2933
2940
|
},
|
|
2934
2941
|
tableSource: {},
|
|
2935
2942
|
documentStyle: {
|
|
2936
|
-
documentFlavor: DocumentFlavor.
|
|
2943
|
+
documentFlavor: DocumentFlavor.UNSPECIFIED
|
|
2937
2944
|
}
|
|
2938
2945
|
};
|
|
2939
2946
|
}
|
|
@@ -3105,15 +3112,15 @@ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
|
3105
3112
|
var attrs = __assign({}, node.attrs);
|
|
3106
3113
|
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
3107
3114
|
var defIds = runtimeProps.defIds;
|
|
3108
|
-
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(
|
|
3109
|
-
var key =
|
|
3115
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a29) {
|
|
3116
|
+
var key = _a29[0], value = _a29[1];
|
|
3110
3117
|
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
3111
3118
|
})), attrs;
|
|
3112
3119
|
}
|
|
3113
3120
|
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
3114
3121
|
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
3115
|
-
var
|
|
3116
|
-
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((
|
|
3122
|
+
var _a29, defIds = runtimeProps.defIds;
|
|
3123
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a29 = node.children) === null || _a29 === void 0) && _a29.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
3117
3124
|
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
3118
3125
|
}) }) : node;
|
|
3119
3126
|
}
|
|
@@ -3352,8 +3359,8 @@ function RangeSelector(props) {
|
|
|
3352
3359
|
}
|
|
3353
3360
|
__name(handleAddRange, "handleAddRange");
|
|
3354
3361
|
function getSheetIdByName(name) {
|
|
3355
|
-
var
|
|
3356
|
-
return ((_b2 = (
|
|
3362
|
+
var _a29, _b2;
|
|
3363
|
+
return ((_b2 = (_a29 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a29.getSheetBySheetName(name)) == null ? void 0 : _b2.getSheetId()) || "";
|
|
3357
3364
|
}
|
|
3358
3365
|
__name(getSheetIdByName, "getSheetIdByName");
|
|
3359
3366
|
function handleTextValueChange(value2) {
|
|
@@ -3436,13 +3443,13 @@ function getSegmentId(documentStyle, editArea, pageIndex) {
|
|
|
3436
3443
|
}
|
|
3437
3444
|
__name(getSegmentId, "getSegmentId");
|
|
3438
3445
|
const DocHeaderFooterOptions = /* @__PURE__ */ __name((props) => {
|
|
3439
|
-
const localeService = useDependency(LocaleService), univerInstanceService = useDependency(IUniverInstanceService), renderManagerService = useDependency(IRenderManagerService), commandService = useDependency(ICommandService),
|
|
3440
|
-
var
|
|
3446
|
+
const localeService = useDependency(LocaleService), univerInstanceService = useDependency(IUniverInstanceService), renderManagerService = useDependency(IRenderManagerService), commandService = useDependency(ICommandService), layoutService = useDependency(ILayoutService), { unitId } = props, docSelectionRenderService = renderManagerService.getRenderById(unitId).with(DocSelectionRenderService), [options, setOptions] = useState({}), handleCheckboxChange = /* @__PURE__ */ __name((val, type) => {
|
|
3447
|
+
var _a29;
|
|
3441
3448
|
setOptions((prev) => ({
|
|
3442
3449
|
...prev,
|
|
3443
3450
|
[type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
|
|
3444
3451
|
}));
|
|
3445
|
-
const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle, docSkeletonManagerService = (
|
|
3452
|
+
const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle, docSkeletonManagerService = (_a29 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a29.with(DocSkeletonManagerService), viewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
|
|
3446
3453
|
if (documentStyle == null || viewModel == null)
|
|
3447
3454
|
return;
|
|
3448
3455
|
const editArea = viewModel.getEditArea();
|
|
@@ -3486,12 +3493,9 @@ const DocHeaderFooterOptions = /* @__PURE__ */ __name((props) => {
|
|
|
3486
3493
|
}
|
|
3487
3494
|
}), docSelectionRenderService.removeAllRanges(), docSelectionRenderService.blur();
|
|
3488
3495
|
}, "handleMarginChange"), closeHeaderFooter = /* @__PURE__ */ __name(() => {
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
return;
|
|
3493
|
-
const { scene } = renderObject, transformer = scene.getTransformerByCreate(), docSkeletonManagerService = renderObject.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton(), viewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel(), render2 = renderManagerService.getRenderById(unitId);
|
|
3494
|
-
render2 == null || viewModel == null || skeleton == null || (docSelectionManagerService.replaceTextRanges([]), transformer.clearSelectedObjects(), docSelectionRenderService.setSegment(""), docSelectionRenderService.setSegmentPage(-1), viewModel.setEditArea(DocumentEditArea.BODY), skeleton.calculate(), (_a28 = render2.mainComponent) == null || _a28.makeDirty(!0));
|
|
3496
|
+
commandService.executeCommand(CloseHeaderFooterCommand.id, {
|
|
3497
|
+
unitId
|
|
3498
|
+
});
|
|
3495
3499
|
}, "closeHeaderFooter");
|
|
3496
3500
|
return useEffect(() => {
|
|
3497
3501
|
const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle;
|
|
@@ -3569,8 +3573,8 @@ const DocHeaderFooterOptions = /* @__PURE__ */ __name((props) => {
|
|
|
3569
3573
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.optionsSection, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: closeHeaderFooter, children: localeService.t("headerFooter.closeHeaderFooter") }) })
|
|
3570
3574
|
] });
|
|
3571
3575
|
}, "DocHeaderFooterOptions"), DocHeaderFooterPanel = /* @__PURE__ */ __name(() => {
|
|
3572
|
-
var
|
|
3573
|
-
const localeService = useDependency(LocaleService), renderManagerService = useDependency(IRenderManagerService), unitId = useDependency(IUniverInstanceService).getCurrentUniverDocInstance().getUnitId(), viewModel = ((
|
|
3576
|
+
var _a29;
|
|
3577
|
+
const localeService = useDependency(LocaleService), renderManagerService = useDependency(IRenderManagerService), unitId = useDependency(IUniverInstanceService).getCurrentUniverDocInstance().getUnitId(), viewModel = ((_a29 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a29.with(DocSkeletonManagerService)).getViewModel(), [isEditHeaderFooter, setIsEditHeaderFooter] = useState(!0);
|
|
3574
3578
|
return useEffect(() => {
|
|
3575
3579
|
const editArea = viewModel.getEditArea();
|
|
3576
3580
|
setIsEditHeaderFooter(editArea !== DocumentEditArea.BODY);
|
|
@@ -3633,11 +3637,11 @@ const _TextBubbleShape = class _TextBubbleShape extends Shape {
|
|
|
3633
3637
|
};
|
|
3634
3638
|
__name(_TextBubbleShape, "TextBubbleShape");
|
|
3635
3639
|
let TextBubbleShape = _TextBubbleShape;
|
|
3636
|
-
var __defProp$
|
|
3637
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
3640
|
+
var __defProp$p = Object.defineProperty, __getOwnPropDesc$p = Object.getOwnPropertyDescriptor, __decorateClass$p = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
3641
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
3638
3642
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
3639
|
-
return kind && result && __defProp$
|
|
3640
|
-
}, "__decorateClass$
|
|
3643
|
+
return kind && result && __defProp$p(target, key, result), result;
|
|
3644
|
+
}, "__decorateClass$p"), __decorateParam$p = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$p");
|
|
3641
3645
|
const HEADER_FOOTER_STROKE_COLOR = "rgba(58, 96, 247, 1)", HEADER_FOOTER_FILL_COLOR = "rgba(58, 96, 247, 0.08)";
|
|
3642
3646
|
var HeaderFooterType = /* @__PURE__ */ ((HeaderFooterType2) => (HeaderFooterType2[HeaderFooterType2.FIRST_PAGE_HEADER = 0] = "FIRST_PAGE_HEADER", HeaderFooterType2[HeaderFooterType2.FIRST_PAGE_FOOTER = 1] = "FIRST_PAGE_FOOTER", HeaderFooterType2[HeaderFooterType2.DEFAULT_HEADER = 2] = "DEFAULT_HEADER", HeaderFooterType2[HeaderFooterType2.DEFAULT_FOOTER = 3] = "DEFAULT_FOOTER", HeaderFooterType2[HeaderFooterType2.EVEN_PAGE_HEADER = 4] = "EVEN_PAGE_HEADER", HeaderFooterType2[HeaderFooterType2.EVEN_PAGE_FOOTER = 5] = "EVEN_PAGE_FOOTER", HeaderFooterType2))(HeaderFooterType || {});
|
|
3643
3647
|
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
|
|
@@ -3698,7 +3702,20 @@ let DocHeaderFooterController = (_a3 = class extends Disposable {
|
|
|
3698
3702
|
this._context = _context, this._commandService = _commandService, this._editorService = _editorService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._docSkeletonManagerService = _docSkeletonManagerService, this._docSelectionRenderService = _docSelectionRenderService, this._localeService = _localeService, this._componentManager = _componentManager, this._initialize();
|
|
3699
3703
|
}
|
|
3700
3704
|
_initialize() {
|
|
3701
|
-
this.
|
|
3705
|
+
this._init(), this._drawHeaderFooterLabel(), this._initCustomComponents(), this._listenSwitchMode();
|
|
3706
|
+
}
|
|
3707
|
+
// Close header footer panel when switch mode.
|
|
3708
|
+
_listenSwitchMode() {
|
|
3709
|
+
this.disposeWithMe(
|
|
3710
|
+
this._commandService.onCommandExecuted((command) => {
|
|
3711
|
+
if (RichTextEditingMutation.id === command.id) {
|
|
3712
|
+
const docDataModel = this._context.unit, editArea = this._docSkeletonManagerService.getViewModel().getEditArea(), documentFlavor = docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
3713
|
+
editArea !== DocumentEditArea.BODY && documentFlavor === DocumentFlavor.MODERN && this._commandService.executeCommand(CloseHeaderFooterCommand.id, {
|
|
3714
|
+
unitId: this._context.unitId
|
|
3715
|
+
});
|
|
3716
|
+
}
|
|
3717
|
+
})
|
|
3718
|
+
);
|
|
3702
3719
|
}
|
|
3703
3720
|
_initCustomComponents() {
|
|
3704
3721
|
const componentManager = this._componentManager;
|
|
@@ -3711,7 +3728,7 @@ let DocHeaderFooterController = (_a3 = class extends Disposable {
|
|
|
3711
3728
|
_initialMain(unitId) {
|
|
3712
3729
|
const docObject = neoGetDocObject(this._context), { document: document2 } = docObject;
|
|
3713
3730
|
this.disposeWithMe(document2.onDblclick$.subscribeEvent(async (evt) => {
|
|
3714
|
-
if (this._isEditorReadOnly(unitId))
|
|
3731
|
+
if (this._isEditorReadOnly(unitId) || !this._isTraditionalMode())
|
|
3715
3732
|
return;
|
|
3716
3733
|
const { offsetX, offsetY } = evt, {
|
|
3717
3734
|
pageLayoutType = PageLayoutType.VERTICAL,
|
|
@@ -3756,7 +3773,7 @@ let DocHeaderFooterController = (_a3 = class extends Disposable {
|
|
|
3756
3773
|
if (unitId == null)
|
|
3757
3774
|
return;
|
|
3758
3775
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
3759
|
-
if (this._editorService.isEditor(unitId) || this._instanceSrv.getUniverDocInstance(unitId) == null || currentRender == null)
|
|
3776
|
+
if (this._editorService.isEditor(unitId) || this._instanceSrv.getUniverDocInstance(unitId) == null || !this._isTraditionalMode() || currentRender == null)
|
|
3760
3777
|
return;
|
|
3761
3778
|
const { mainComponent } = currentRender, docsComponent = mainComponent;
|
|
3762
3779
|
this.disposeWithMe(
|
|
@@ -3824,19 +3841,22 @@ let DocHeaderFooterController = (_a3 = class extends Disposable {
|
|
|
3824
3841
|
const editor = this._editorService.getEditor(unitId);
|
|
3825
3842
|
return editor ? editor.isReadOnly() : !1;
|
|
3826
3843
|
}
|
|
3844
|
+
_isTraditionalMode() {
|
|
3845
|
+
return this._context.unit.getSnapshot().documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL;
|
|
3846
|
+
}
|
|
3827
3847
|
_getDocDataModel() {
|
|
3828
3848
|
return this._context.unit;
|
|
3829
3849
|
}
|
|
3830
3850
|
}, __name(_a3, "DocHeaderFooterController"), _a3);
|
|
3831
|
-
DocHeaderFooterController = __decorateClass$
|
|
3832
|
-
__decorateParam$
|
|
3833
|
-
__decorateParam$
|
|
3834
|
-
__decorateParam$
|
|
3835
|
-
__decorateParam$
|
|
3836
|
-
__decorateParam$
|
|
3837
|
-
__decorateParam$
|
|
3838
|
-
__decorateParam$
|
|
3839
|
-
__decorateParam$
|
|
3851
|
+
DocHeaderFooterController = __decorateClass$p([
|
|
3852
|
+
__decorateParam$p(1, ICommandService),
|
|
3853
|
+
__decorateParam$p(2, IEditorService),
|
|
3854
|
+
__decorateParam$p(3, IUniverInstanceService),
|
|
3855
|
+
__decorateParam$p(4, IRenderManagerService),
|
|
3856
|
+
__decorateParam$p(5, Inject(DocSkeletonManagerService)),
|
|
3857
|
+
__decorateParam$p(6, Inject(DocSelectionRenderService)),
|
|
3858
|
+
__decorateParam$p(7, Inject(LocaleService)),
|
|
3859
|
+
__decorateParam$p(8, Inject(ComponentManager))
|
|
3840
3860
|
], DocHeaderFooterController);
|
|
3841
3861
|
const SidebarDocHeaderFooterPanelOperation = {
|
|
3842
3862
|
id: "sidebar.operation.doc-header-footer-panel",
|
|
@@ -3942,8 +3962,8 @@ const CoreHeaderFooterCommandId = "doc.command.core-header-footer", CoreHeaderFo
|
|
|
3942
3962
|
type: CommandType.COMMAND,
|
|
3943
3963
|
// eslint-disable-next-line max-lines-per-function
|
|
3944
3964
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
3945
|
-
var
|
|
3946
|
-
const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderManagerService = accessor.get(IRenderManagerService), { unitId, segmentId, createType, headerFooterProps } = params, docSkeletonManagerService = (
|
|
3965
|
+
var _a29;
|
|
3966
|
+
const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderManagerService = accessor.get(IRenderManagerService), { unitId, segmentId, createType, headerFooterProps } = params, docSkeletonManagerService = (_a29 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a29.with(DocSkeletonManagerService), docDataModel = univerInstanceService.getUniverDocInstance(unitId), docViewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
|
|
3947
3967
|
if (docDataModel == null || docViewModel == null)
|
|
3948
3968
|
return !1;
|
|
3949
3969
|
const editArea = docViewModel.getEditArea(), { documentStyle } = docDataModel.getSnapshot(), isUpdateMargin = (headerFooterProps == null ? void 0 : headerFooterProps.marginFooter) != null || (headerFooterProps == null ? void 0 : headerFooterProps.marginHeader) != null, textRanges = [{
|
|
@@ -3979,6 +3999,17 @@ const CoreHeaderFooterCommandId = "doc.command.core-header-footer", CoreHeaderFo
|
|
|
3979
3999
|
id: "doc.command.open-header-footer-panel",
|
|
3980
4000
|
type: CommandType.COMMAND,
|
|
3981
4001
|
handler: /* @__PURE__ */ __name(async (accessor, _params) => accessor.get(ICommandService).executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" }), "handler")
|
|
4002
|
+
}, CloseHeaderFooterCommand = {
|
|
4003
|
+
id: "doc.command.close-header-footer",
|
|
4004
|
+
type: CommandType.COMMAND,
|
|
4005
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4006
|
+
var _a29;
|
|
4007
|
+
const commandService = accessor.get(ICommandService), renderManagerService = accessor.get(IRenderManagerService), docSelectionManagerService = accessor.get(DocSelectionManagerService), { unitId } = params, renderObject = renderManagerService.getRenderById(unitId);
|
|
4008
|
+
if (renderObject == null)
|
|
4009
|
+
return !1;
|
|
4010
|
+
const { scene } = renderObject, transformer = scene.getTransformerByCreate(), docSkeletonManagerService = renderObject.with(DocSkeletonManagerService), docSelectionRenderService = renderObject.with(DocSelectionRenderService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton(), viewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
|
|
4011
|
+
return viewModel == null || skeleton == null ? !1 : (docSelectionManagerService.replaceDocRanges([]), transformer.clearSelectedObjects(), docSelectionRenderService.setSegment(""), docSelectionRenderService.setSegmentPage(-1), viewModel.setEditArea(DocumentEditArea.BODY), skeleton.calculate(), (_a29 = renderObject.mainComponent) == null || _a29.makeDirty(!0), commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" }), !0);
|
|
4012
|
+
}, "handler")
|
|
3982
4013
|
}, COMPONENT_PREFIX = "UI_PLUGIN_DOCS", COLOR_PICKER_COMPONENT = `${COMPONENT_PREFIX}_COLOR_PICKER_COMPONENT`, FONT_FAMILY_COMPONENT = `${COMPONENT_PREFIX}_FONT_FAMILY_COMPONENT`, FONT_FAMILY_ITEM_COMPONENT = `${COMPONENT_PREFIX}_FONT_FAMILY_ITEM_COMPONENT`, FONT_SIZE_COMPONENT = `${COMPONENT_PREFIX}_FONT_SIZE_COMPONENT`, docListTypePicker = "univer-doc-list-type-picker", docListTypePickerItem = "univer-doc-list-type-picker-item", docListTypePickerItemActive = "univer-doc-list-type-picker-item-active", styles$4 = {
|
|
3983
4014
|
docListTypePicker,
|
|
3984
4015
|
docListTypePickerItem,
|
|
@@ -4100,6 +4131,43 @@ const TabShortCut = {
|
|
|
4100
4131
|
shift: !0
|
|
4101
4132
|
}
|
|
4102
4133
|
};
|
|
4134
|
+
var __defProp$o = Object.defineProperty, __getOwnPropDesc$o = Object.getOwnPropertyDescriptor, __decorateClass$o = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
4135
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4136
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4137
|
+
return kind && result && __defProp$o(target, key, result), result;
|
|
4138
|
+
}, "__decorateClass$o"), __decorateParam$o = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$o"), _a4;
|
|
4139
|
+
let DocMenuStyleService = (_a4 = class extends Disposable {
|
|
4140
|
+
constructor(_textSelectionManagerService) {
|
|
4141
|
+
super();
|
|
4142
|
+
__publicField(this, "_cacheStyle", null);
|
|
4143
|
+
this._textSelectionManagerService = _textSelectionManagerService, this._init();
|
|
4144
|
+
}
|
|
4145
|
+
_init() {
|
|
4146
|
+
this._listenDocRangeChange();
|
|
4147
|
+
}
|
|
4148
|
+
_listenDocRangeChange() {
|
|
4149
|
+
this.disposeWithMe(
|
|
4150
|
+
this._textSelectionManagerService.textSelection$.subscribe(() => {
|
|
4151
|
+
this._clearStyleCache();
|
|
4152
|
+
})
|
|
4153
|
+
);
|
|
4154
|
+
}
|
|
4155
|
+
getStyleCache() {
|
|
4156
|
+
return this._cacheStyle;
|
|
4157
|
+
}
|
|
4158
|
+
setStyleCache(style) {
|
|
4159
|
+
this._cacheStyle = {
|
|
4160
|
+
...this._cacheStyle,
|
|
4161
|
+
...style
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
_clearStyleCache() {
|
|
4165
|
+
this._cacheStyle = null;
|
|
4166
|
+
}
|
|
4167
|
+
}, __name(_a4, "DocMenuStyleService"), _a4);
|
|
4168
|
+
DocMenuStyleService = __decorateClass$o([
|
|
4169
|
+
__decorateParam$o(0, Inject(DocSelectionManagerService))
|
|
4170
|
+
], DocMenuStyleService);
|
|
4103
4171
|
function handleInlineFormat(preCommandId, params, commandService) {
|
|
4104
4172
|
return commandService.executeCommand(SetInlineFormatCommand.id, {
|
|
4105
4173
|
preCommandId,
|
|
@@ -4245,10 +4313,10 @@ const SetInlineFormatBoldCommandId = "doc.command.set-inline-format-bold", SetIn
|
|
|
4245
4313
|
type: CommandType.COMMAND,
|
|
4246
4314
|
// eslint-disable-next-line max-lines-per-function
|
|
4247
4315
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4248
|
-
const { value, preCommandId } = params, commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), docRanges = docSelectionManagerService.getDocRanges();
|
|
4316
|
+
const { value, preCommandId } = params, commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), docMenuStyleService = accessor.get(DocMenuStyleService), docRanges = docSelectionManagerService.getDocRanges();
|
|
4249
4317
|
if (docRanges.length === 0)
|
|
4250
4318
|
return !1;
|
|
4251
|
-
const segmentId = docRanges[0].segmentId, docDataModel = univerInstanceService.
|
|
4319
|
+
const segmentId = docRanges[0].segmentId, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
4252
4320
|
if (docDataModel == null)
|
|
4253
4321
|
return !1;
|
|
4254
4322
|
const unitId = docDataModel.getUnitId();
|
|
@@ -4301,6 +4369,14 @@ const SetInlineFormatBoldCommandId = "doc.command.set-inline-format-bold", SetIn
|
|
|
4301
4369
|
const { startOffset, endOffset } = range;
|
|
4302
4370
|
if (startOffset == null || endOffset == null)
|
|
4303
4371
|
continue;
|
|
4372
|
+
if (startOffset === endOffset) {
|
|
4373
|
+
docMenuStyleService.setStyleCache(
|
|
4374
|
+
{
|
|
4375
|
+
[COMMAND_ID_TO_FORMAT_KEY_MAP[preCommandId]]: formatValue
|
|
4376
|
+
}
|
|
4377
|
+
);
|
|
4378
|
+
continue;
|
|
4379
|
+
}
|
|
4304
4380
|
const body = {
|
|
4305
4381
|
dataStream: "",
|
|
4306
4382
|
textRuns: [
|
|
@@ -4315,13 +4391,11 @@ const SetInlineFormatBoldCommandId = "doc.command.set-inline-format-bold", SetIn
|
|
|
4315
4391
|
}, len = startOffset - memoryCursor.cursor;
|
|
4316
4392
|
len !== 0 && textX.push({
|
|
4317
4393
|
t: TextXActionType.RETAIN,
|
|
4318
|
-
len
|
|
4319
|
-
segmentId
|
|
4394
|
+
len
|
|
4320
4395
|
}), textX.push({
|
|
4321
4396
|
t: TextXActionType.RETAIN,
|
|
4322
4397
|
body,
|
|
4323
|
-
len: endOffset - startOffset
|
|
4324
|
-
segmentId
|
|
4398
|
+
len: endOffset - startOffset
|
|
4325
4399
|
}), memoryCursor.reset(), memoryCursor.moveCursor(endOffset);
|
|
4326
4400
|
}
|
|
4327
4401
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -4364,8 +4438,8 @@ const ListOperationCommand = {
|
|
|
4364
4438
|
id: "doc.command.list-operation",
|
|
4365
4439
|
type: CommandType.COMMAND,
|
|
4366
4440
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4367
|
-
var
|
|
4368
|
-
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), listType = params.listType, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docRanges = (
|
|
4441
|
+
var _a29, _b2;
|
|
4442
|
+
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), listType = params.listType, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docRanges = (_a29 = docSelectionManagerService.getDocRanges()) != null ? _a29 : [];
|
|
4369
4443
|
if (docDataModel == null || docRanges.length === 0)
|
|
4370
4444
|
return !1;
|
|
4371
4445
|
const segmentId = docRanges[0].segmentId, paragraphs = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b2.paragraphs;
|
|
@@ -4393,11 +4467,11 @@ const ListOperationCommand = {
|
|
|
4393
4467
|
id: "doc.command.change-list-type",
|
|
4394
4468
|
type: CommandType.COMMAND,
|
|
4395
4469
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4396
|
-
var
|
|
4470
|
+
var _a29, _b2;
|
|
4397
4471
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { listType } = params, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), activeRanges = docSelectionManagerService.getDocRanges();
|
|
4398
4472
|
if (docDataModel == null || activeRanges == null || !activeRanges.length)
|
|
4399
4473
|
return !1;
|
|
4400
|
-
const { segmentId } = activeRanges[0], selections = (
|
|
4474
|
+
const { segmentId } = activeRanges[0], selections = (_a29 = docSelectionManagerService.getDocRanges()) != null ? _a29 : [], paragraphs = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b2.paragraphs;
|
|
4401
4475
|
if (paragraphs == null)
|
|
4402
4476
|
return !1;
|
|
4403
4477
|
const currentParagraphs = getParagraphsInRanges(selections, paragraphs), unitId = docDataModel.getUnitId(), textX = BuildTextUtils.paragraph.bullet.set({
|
|
@@ -4425,13 +4499,13 @@ const ChangeListNestingLevelCommand = {
|
|
|
4425
4499
|
id: "doc.command.change-list-nesting-level",
|
|
4426
4500
|
type: CommandType.COMMAND,
|
|
4427
4501
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4428
|
-
var
|
|
4502
|
+
var _a29, _b2;
|
|
4429
4503
|
if (!params)
|
|
4430
4504
|
return !1;
|
|
4431
4505
|
const { type } = params, docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4432
4506
|
if (docDataModel == null || activeRange == null)
|
|
4433
4507
|
return !1;
|
|
4434
|
-
const { segmentId } = activeRange, selections = (
|
|
4508
|
+
const { segmentId } = activeRange, selections = (_a29 = docSelectionManagerService.getDocRanges()) != null ? _a29 : [], paragraphs = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b2.paragraphs;
|
|
4435
4509
|
if (paragraphs == null)
|
|
4436
4510
|
return !1;
|
|
4437
4511
|
const currentParagraphs = getParagraphsInRange(activeRange, paragraphs), unitId = docDataModel.getUnitId(), jsonX = JSONX.getInstance(), textX = BuildTextUtils.paragraph.bullet.changeNestLevel({
|
|
@@ -4476,11 +4550,11 @@ const ChangeListNestingLevelCommand = {
|
|
|
4476
4550
|
id: "doc.command.toggle-check-list",
|
|
4477
4551
|
type: CommandType.COMMAND,
|
|
4478
4552
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4479
|
-
var
|
|
4553
|
+
var _a29;
|
|
4480
4554
|
if (!params)
|
|
4481
4555
|
return !1;
|
|
4482
4556
|
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { index, segmentId, textRanges } = params, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
4483
|
-
if (docDataModel == null || ((
|
|
4557
|
+
if (docDataModel == null || ((_a29 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a29.paragraphs) == null)
|
|
4484
4558
|
return !1;
|
|
4485
4559
|
const unitId = docDataModel.getUnitId(), doMutation = {
|
|
4486
4560
|
id: RichTextEditingMutation.id,
|
|
@@ -4517,13 +4591,13 @@ const ChangeListNestingLevelCommand = {
|
|
|
4517
4591
|
type: CommandType.COMMAND,
|
|
4518
4592
|
// eslint-disable-next-line max-lines-per-function
|
|
4519
4593
|
handler(accessor, params) {
|
|
4520
|
-
var
|
|
4594
|
+
var _a29, _b2, _c, _d, _e;
|
|
4521
4595
|
if (!params)
|
|
4522
4596
|
return !1;
|
|
4523
4597
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4524
4598
|
if (docDataModel == null || activeRange == null)
|
|
4525
4599
|
return !1;
|
|
4526
|
-
const { segmentId } = activeRange, { listType, paragraph } = params, { paragraphStart, paragraphEnd } = paragraph, textX = new TextX(), jsonX = JSONX.getInstance(), { defaultTabStop = 36 } = docDataModel.getSnapshot().documentStyle, sectionBreaks = (_b2 = (
|
|
4600
|
+
const { segmentId } = activeRange, { listType, paragraph } = params, { paragraphStart, paragraphEnd } = paragraph, textX = new TextX(), jsonX = JSONX.getInstance(), { defaultTabStop = 36 } = docDataModel.getSnapshot().documentStyle, sectionBreaks = (_b2 = (_a29 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a29.sectionBreaks) != null ? _b2 : [], { startIndex, paragraphStyle = {} } = paragraph, { indentFirstLine, snapToGrid, indentStart } = paragraphStyle, paragraphProperties = PRESET_LIST_TYPE[listType].nestingLevel[0].paragraphProperties || {}, { hanging: listHanging, indentStart: listIndentStart } = paragraphProperties, bulletParagraphTextStyle = paragraphProperties.textStyle, { charSpace, gridType } = findNearestSectionBreak(startIndex, sectionBreaks) || { charSpace: 0, gridType: GridType.LINES }, charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
|
|
4527
4601
|
let listId = Tools.generateRandomId(6);
|
|
4528
4602
|
const paragraphs = (_d = (_c = docDataModel.getBody()) == null ? void 0 : _c.paragraphs) != null ? _d : [], curIndex = paragraphs.findIndex((i) => i.startIndex === paragraph.startIndex), prevParagraph = paragraphs[curIndex - 1], nextParagraph = paragraphs[curIndex + 1];
|
|
4529
4603
|
prevParagraph && prevParagraph.bullet && prevParagraph.bullet.listType.indexOf(listType) === 0 ? listId = prevParagraph.bullet.listId : nextParagraph && nextParagraph.bullet && nextParagraph.bullet.listType.indexOf(listType) === 0 && (listId = nextParagraph.bullet.listId);
|
|
@@ -4545,8 +4619,7 @@ const ChangeListNestingLevelCommand = {
|
|
|
4545
4619
|
len: paragraphStart
|
|
4546
4620
|
}), textX.push({
|
|
4547
4621
|
t: TextXActionType.DELETE,
|
|
4548
|
-
len: paragraphEnd - paragraphStart
|
|
4549
|
-
line: 1
|
|
4622
|
+
len: paragraphEnd - paragraphStart
|
|
4550
4623
|
}), textX.push({
|
|
4551
4624
|
t: TextXActionType.RETAIN,
|
|
4552
4625
|
len: 1,
|
|
@@ -4616,19 +4689,19 @@ const AlignOperationCommand = {
|
|
|
4616
4689
|
type: CommandType.COMMAND,
|
|
4617
4690
|
// eslint-disable-next-line max-lines-per-function
|
|
4618
4691
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4619
|
-
var
|
|
4692
|
+
var _a29;
|
|
4620
4693
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { alignType } = params, docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
4621
4694
|
if (docDataModel == null)
|
|
4622
4695
|
return !1;
|
|
4623
4696
|
const allRanges = docSelectionManagerService.getDocRanges();
|
|
4624
4697
|
if (allRanges.length === 0)
|
|
4625
4698
|
return !1;
|
|
4626
|
-
const segmentId = allRanges[0].segmentId, paragraphs = (
|
|
4699
|
+
const segmentId = allRanges[0].segmentId, paragraphs = (_a29 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a29.paragraphs;
|
|
4627
4700
|
if (paragraphs == null)
|
|
4628
4701
|
return !1;
|
|
4629
4702
|
const currentParagraphs = getParagraphsInRanges(allRanges, paragraphs), unitId = docDataModel.getUnitId(), isAlreadyAligned = currentParagraphs.every((paragraph) => {
|
|
4630
|
-
var
|
|
4631
|
-
return ((
|
|
4703
|
+
var _a30;
|
|
4704
|
+
return ((_a30 = paragraph.paragraphStyle) == null ? void 0 : _a30.horizontalAlign) === alignType;
|
|
4632
4705
|
}), doMutation = {
|
|
4633
4706
|
id: RichTextEditingMutation.id,
|
|
4634
4707
|
params: {
|
|
@@ -4643,8 +4716,7 @@ const AlignOperationCommand = {
|
|
|
4643
4716
|
const { startIndex } = paragraph;
|
|
4644
4717
|
textX.push({
|
|
4645
4718
|
t: TextXActionType.RETAIN,
|
|
4646
|
-
len: startIndex - memoryCursor.cursor
|
|
4647
|
-
segmentId
|
|
4719
|
+
len: startIndex - memoryCursor.cursor
|
|
4648
4720
|
});
|
|
4649
4721
|
const paragraphStyle = {
|
|
4650
4722
|
...paragraph.paragraphStyle,
|
|
@@ -4663,7 +4735,6 @@ const AlignOperationCommand = {
|
|
|
4663
4735
|
}
|
|
4664
4736
|
]
|
|
4665
4737
|
},
|
|
4666
|
-
segmentId,
|
|
4667
4738
|
coverType: UpdateDocsAttributeType.REPLACE
|
|
4668
4739
|
}), memoryCursor.moveCursorTo(startIndex + 1);
|
|
4669
4740
|
}
|
|
@@ -4765,9 +4836,9 @@ const AlignOperationCommand = {
|
|
|
4765
4836
|
}, ZOOM_MAP = [50, 80, 100, 130, 150, 170, 200, 400], DOC_ZOOM_RANGE = [10, 400];
|
|
4766
4837
|
function ZoomSlider() {
|
|
4767
4838
|
const commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), currentDoc$ = useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), []), documentDataModel = useObservable(currentDoc$), getCurrentZoom = useCallback(() => {
|
|
4768
|
-
var
|
|
4839
|
+
var _a29, _b2;
|
|
4769
4840
|
if (!documentDataModel) return 100;
|
|
4770
|
-
const currentZoom = ((_b2 = (
|
|
4841
|
+
const currentZoom = ((_b2 = (_a29 = documentDataModel.getSettings()) == null ? void 0 : _a29.zoomRatio) != null ? _b2 : 1) * 100;
|
|
4771
4842
|
return Math.round(currentZoom);
|
|
4772
4843
|
}, [documentDataModel]), [zoom, setZoom] = useState(() => getCurrentZoom());
|
|
4773
4844
|
useEffect(() => (setZoom(getCurrentZoom()), commandService.onCommandExecuted((commandInfo) => {
|
|
@@ -4997,10 +5068,10 @@ ${DataStreamTreeTokenType.TABLE_CELL_END}`, paragraphs = [], sectionBreaks = [];
|
|
|
4997
5068
|
}
|
|
4998
5069
|
__name(getInsertColumnBody, "getInsertColumnBody");
|
|
4999
5070
|
function getInsertRowActionsParams(rangeInfo, position, viewModel) {
|
|
5000
|
-
var
|
|
5071
|
+
var _a29, _b2, _c;
|
|
5001
5072
|
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), index = position === 0 ? startOffset : endOffset;
|
|
5002
5073
|
let tableRow = null;
|
|
5003
|
-
const tableId = (_c = (_b2 = (
|
|
5074
|
+
const tableId = (_c = (_b2 = (_a29 = viewModel.getBody()) == null ? void 0 : _a29.tables) == null ? void 0 : _b2.find((t) => index >= t.startIndex && index <= t.endIndex)) == null ? void 0 : _c.tableId;
|
|
5004
5075
|
let rowIndex = 0;
|
|
5005
5076
|
for (const section of vm.children) {
|
|
5006
5077
|
for (const paragraph of section.children) {
|
|
@@ -5027,8 +5098,8 @@ function getInsertRowActionsParams(rangeInfo, position, viewModel) {
|
|
|
5027
5098
|
}
|
|
5028
5099
|
__name(getInsertRowActionsParams, "getInsertRowActionsParams");
|
|
5029
5100
|
function getInsertColumnActionsParams(rangeInfo, position, viewModel) {
|
|
5030
|
-
var
|
|
5031
|
-
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), index = position === 0 ? startOffset : endOffset, tableId = (_c = (_b2 = (
|
|
5101
|
+
var _a29, _b2, _c;
|
|
5102
|
+
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), index = position === 0 ? startOffset : endOffset, tableId = (_c = (_b2 = (_a29 = viewModel.getBody()) == null ? void 0 : _a29.tables) == null ? void 0 : _b2.find((t) => index >= t.startIndex && index <= t.endIndex)) == null ? void 0 : _c.tableId, offsets = [];
|
|
5032
5103
|
let table = null, columnIndex = -1;
|
|
5033
5104
|
for (const section of vm.children) {
|
|
5034
5105
|
for (const paragraph of section.children) {
|
|
@@ -5085,8 +5156,8 @@ function getColumnWidths(pageWidth, tableColumns, insertColumnIndex) {
|
|
|
5085
5156
|
}
|
|
5086
5157
|
__name(getColumnWidths, "getColumnWidths");
|
|
5087
5158
|
function getDeleteRowsActionsParams(rangeInfo, viewModel) {
|
|
5088
|
-
var
|
|
5089
|
-
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), tableId = (_c = (_b2 = (
|
|
5159
|
+
var _a29, _b2, _c;
|
|
5160
|
+
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), tableId = (_c = (_b2 = (_a29 = viewModel.getBody()) == null ? void 0 : _a29.tables) == null ? void 0 : _b2.find((t) => startOffset >= t.startIndex && endOffset <= t.endIndex)) == null ? void 0 : _c.tableId, rowIndexes = [];
|
|
5090
5161
|
let offset = -1, len = 0, cursor = -1, selectWholeTable = !1;
|
|
5091
5162
|
for (const section of vm.children) {
|
|
5092
5163
|
for (const paragraph of section.children) {
|
|
@@ -5117,8 +5188,8 @@ function getDeleteRowsActionsParams(rangeInfo, viewModel) {
|
|
|
5117
5188
|
}
|
|
5118
5189
|
__name(getDeleteRowsActionsParams, "getDeleteRowsActionsParams");
|
|
5119
5190
|
function getDeleteColumnsActionParams(rangeInfo, viewModel) {
|
|
5120
|
-
var
|
|
5121
|
-
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), tableId = (_c = (_b2 = (
|
|
5191
|
+
var _a29, _b2, _c;
|
|
5192
|
+
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), tableId = (_c = (_b2 = (_a29 = viewModel.getBody()) == null ? void 0 : _a29.tables) == null ? void 0 : _b2.find((t) => startOffset >= t.startIndex && endOffset <= t.endIndex)) == null ? void 0 : _c.tableId, offsets = [];
|
|
5122
5193
|
let table = null;
|
|
5123
5194
|
const columnIndexes = [];
|
|
5124
5195
|
let cursor = -1, startColumnIndex = -1, endColumnIndex = -1;
|
|
@@ -5164,8 +5235,8 @@ function getDeleteColumnsActionParams(rangeInfo, viewModel) {
|
|
|
5164
5235
|
}
|
|
5165
5236
|
__name(getDeleteColumnsActionParams, "getDeleteColumnsActionParams");
|
|
5166
5237
|
function getDeleteTableActionParams(rangeInfo, viewModel) {
|
|
5167
|
-
var
|
|
5168
|
-
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), tableId = (_c = (_b2 = (
|
|
5238
|
+
var _a29, _b2, _c;
|
|
5239
|
+
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), tableId = (_c = (_b2 = (_a29 = viewModel.getBody()) == null ? void 0 : _a29.tables) == null ? void 0 : _b2.find((t) => startOffset >= t.startIndex && endOffset <= t.endIndex)) == null ? void 0 : _c.tableId;
|
|
5169
5240
|
let offset = -1, len = 0, cursor = -1;
|
|
5170
5241
|
for (const section of vm.children) {
|
|
5171
5242
|
for (const paragraph of section.children) {
|
|
@@ -5190,8 +5261,8 @@ function getDeleteTableActionParams(rangeInfo, viewModel) {
|
|
|
5190
5261
|
}
|
|
5191
5262
|
__name(getDeleteTableActionParams, "getDeleteTableActionParams");
|
|
5192
5263
|
function getDeleteRowContentActionParams(rangeInfo, viewModel) {
|
|
5193
|
-
var
|
|
5194
|
-
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), tableId = (_c = (_b2 = (
|
|
5264
|
+
var _a29, _b2, _c;
|
|
5265
|
+
const { startOffset, endOffset, segmentId } = rangeInfo, vm = viewModel.getSelfOrHeaderFooterViewModel(segmentId), tableId = (_c = (_b2 = (_a29 = viewModel.getBody()) == null ? void 0 : _a29.tables) == null ? void 0 : _b2.find((t) => startOffset >= t.startIndex && endOffset <= t.endIndex)) == null ? void 0 : _c.tableId, offsets = [];
|
|
5195
5266
|
let table = null, cursor = -1, rowIndex = -1, startColumnIndex = -1, endColumnIndex = -1;
|
|
5196
5267
|
for (const section of vm.children) {
|
|
5197
5268
|
for (const paragraph of section.children) {
|
|
@@ -5305,7 +5376,7 @@ const InnerPasteCommand = {
|
|
|
5305
5376
|
type: CommandType.COMMAND,
|
|
5306
5377
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
5307
5378
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5308
|
-
var
|
|
5379
|
+
var _a29, _b2, _c, _d;
|
|
5309
5380
|
const { segmentId, textRanges, doc } = params, commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), originSelections = docSelectionManagerService.getTextRanges(), rectRanges = docSelectionManagerService.getRectRanges(), { body, tableSource, drawings } = doc;
|
|
5310
5381
|
if (!Array.isArray(originSelections) || originSelections.length === 0 || body == null)
|
|
5311
5382
|
return !1;
|
|
@@ -5322,7 +5393,7 @@ const InnerPasteCommand = {
|
|
|
5322
5393
|
}
|
|
5323
5394
|
}, memoryCursor = new MemoryCursor();
|
|
5324
5395
|
memoryCursor.reset();
|
|
5325
|
-
const textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [], hasTable = !!((
|
|
5396
|
+
const textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [], hasTable = !!((_a29 = body.tables) != null && _a29.length), hasCustomBlock = !!((_b2 = body.customBlocks) != null && _b2.length);
|
|
5326
5397
|
if (hasTable && segmentId || hasTable && hasRangeInTable(selections) || selections.length && (rectRanges != null && rectRanges.length))
|
|
5327
5398
|
return !1;
|
|
5328
5399
|
for (const selection of selections) {
|
|
@@ -5350,8 +5421,7 @@ const InnerPasteCommand = {
|
|
|
5350
5421
|
if (collapsed)
|
|
5351
5422
|
textX.push({
|
|
5352
5423
|
t: TextXActionType.RETAIN,
|
|
5353
|
-
len
|
|
5354
|
-
segmentId
|
|
5424
|
+
len
|
|
5355
5425
|
});
|
|
5356
5426
|
else {
|
|
5357
5427
|
const { dos } = BuildTextUtils.selection.getDeleteActions(selection, segmentId, memoryCursor.cursor, originBody);
|
|
@@ -5360,9 +5430,7 @@ const InnerPasteCommand = {
|
|
|
5360
5430
|
textX.push({
|
|
5361
5431
|
t: TextXActionType.INSERT,
|
|
5362
5432
|
body: cloneBody,
|
|
5363
|
-
len: body.dataStream.length
|
|
5364
|
-
line: 0,
|
|
5365
|
-
segmentId
|
|
5433
|
+
len: body.dataStream.length
|
|
5366
5434
|
}), memoryCursor.reset(), memoryCursor.moveCursor(endOffset);
|
|
5367
5435
|
}
|
|
5368
5436
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -5370,7 +5438,7 @@ const InnerPasteCommand = {
|
|
|
5370
5438
|
}, "handler")
|
|
5371
5439
|
};
|
|
5372
5440
|
function getCutActionsFromTextRanges(selections, docDataModel, segmentId) {
|
|
5373
|
-
var
|
|
5441
|
+
var _a29, _b2;
|
|
5374
5442
|
const originBody = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody(), textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [];
|
|
5375
5443
|
if (originBody == null)
|
|
5376
5444
|
return rawActions;
|
|
@@ -5383,13 +5451,12 @@ function getCutActionsFromTextRanges(selections, docDataModel, segmentId) {
|
|
|
5383
5451
|
const len = startOffset - memoryCursor.cursor;
|
|
5384
5452
|
collapsed ? textX.push({
|
|
5385
5453
|
t: TextXActionType.RETAIN,
|
|
5386
|
-
len
|
|
5387
|
-
|
|
5388
|
-
}) : textX.push(...BuildTextUtils.selection.getDeleteExculdeLastLineBreakActions(selection, originBody, segmentId, memoryCursor.cursor, !1)), memoryCursor.reset(), memoryCursor.moveCursor(endOffset);
|
|
5454
|
+
len
|
|
5455
|
+
}) : textX.push(...BuildTextUtils.selection.getDeleteExcludeLastLineBreakActions(selection, originBody, segmentId, memoryCursor.cursor, !1)), memoryCursor.reset(), memoryCursor.moveCursor(endOffset);
|
|
5389
5456
|
}
|
|
5390
5457
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
5391
5458
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
5392
|
-
const removedCustomBlockIds = getCustomBlockIdsInSelections(originBody, selections), drawings = (
|
|
5459
|
+
const removedCustomBlockIds = getCustomBlockIdsInSelections(originBody, selections), drawings = (_a29 = docDataModel.getDrawings()) != null ? _a29 : {}, drawingOrder = (_b2 = docDataModel.getDrawingsOrder()) != null ? _b2 : [], sortedRemovedCustomBlockIds = removedCustomBlockIds.sort((a, b) => drawingOrder.indexOf(a) > drawingOrder.indexOf(b) ? -1 : drawingOrder.indexOf(a) < drawingOrder.indexOf(b) ? 1 : 0);
|
|
5393
5460
|
if (sortedRemovedCustomBlockIds.length > 0)
|
|
5394
5461
|
for (const blockId of sortedRemovedCustomBlockIds) {
|
|
5395
5462
|
const drawing = drawings[blockId], drawingIndex = drawingOrder.indexOf(blockId);
|
|
@@ -5417,13 +5484,10 @@ function getCutActionsFromRectRanges(ranges, docDataModel, viewModel, segmentId)
|
|
|
5417
5484
|
const { offset, len, tableId } = actionParams;
|
|
5418
5485
|
offset - memoryCursor.cursor > 0 && textX.push({
|
|
5419
5486
|
t: TextXActionType.RETAIN,
|
|
5420
|
-
len: offset - memoryCursor.cursor
|
|
5421
|
-
segmentId
|
|
5487
|
+
len: offset - memoryCursor.cursor
|
|
5422
5488
|
}), textX.push({
|
|
5423
5489
|
t: TextXActionType.DELETE,
|
|
5424
|
-
len
|
|
5425
|
-
line: 0,
|
|
5426
|
-
segmentId
|
|
5490
|
+
len
|
|
5427
5491
|
});
|
|
5428
5492
|
const action = jsonX.removeOp(["tableSource", tableId]);
|
|
5429
5493
|
rawActions.push(action), memoryCursor.moveCursorTo(offset + len);
|
|
@@ -5434,13 +5498,10 @@ function getCutActionsFromRectRanges(ranges, docDataModel, viewModel, segmentId)
|
|
|
5434
5498
|
const { offset, rowIndexes, len, tableId } = actionParams;
|
|
5435
5499
|
offset - memoryCursor.cursor > 0 && textX.push({
|
|
5436
5500
|
t: TextXActionType.RETAIN,
|
|
5437
|
-
len: offset - memoryCursor.cursor
|
|
5438
|
-
segmentId
|
|
5501
|
+
len: offset - memoryCursor.cursor
|
|
5439
5502
|
}), textX.push({
|
|
5440
5503
|
t: TextXActionType.DELETE,
|
|
5441
|
-
len
|
|
5442
|
-
line: 0,
|
|
5443
|
-
segmentId
|
|
5504
|
+
len
|
|
5444
5505
|
});
|
|
5445
5506
|
for (const index of rowIndexes.reverse()) {
|
|
5446
5507
|
const action = jsonX.removeOp(["tableSource", tableId, "tableRows", index]);
|
|
@@ -5456,13 +5517,10 @@ function getCutActionsFromRectRanges(ranges, docDataModel, viewModel, segmentId)
|
|
|
5456
5517
|
const { retain, delete: delLen } = offset;
|
|
5457
5518
|
retain - memoryCursor.cursor > 0 && textX.push({
|
|
5458
5519
|
t: TextXActionType.RETAIN,
|
|
5459
|
-
len: retain - memoryCursor.cursor
|
|
5460
|
-
segmentId
|
|
5520
|
+
len: retain - memoryCursor.cursor
|
|
5461
5521
|
}), textX.push({
|
|
5462
5522
|
t: TextXActionType.DELETE,
|
|
5463
|
-
len: delLen
|
|
5464
|
-
line: 0,
|
|
5465
|
-
segmentId
|
|
5523
|
+
len: delLen
|
|
5466
5524
|
}), memoryCursor.moveCursorTo(retain + delLen);
|
|
5467
5525
|
}
|
|
5468
5526
|
}
|
|
@@ -5487,8 +5545,8 @@ const INNER_CUT_COMMAND_ID = "doc.command.inner-cut", CutContentCommand = {
|
|
|
5487
5545
|
id: INNER_CUT_COMMAND_ID,
|
|
5488
5546
|
type: CommandType.COMMAND,
|
|
5489
5547
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5490
|
-
var
|
|
5491
|
-
const { segmentId, textRanges } = params, commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), selections = (
|
|
5548
|
+
var _a29, _b2;
|
|
5549
|
+
const { segmentId, textRanges } = params, commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), selections = (_a29 = params.selections) != null ? _a29 : docSelectionManagerService.getTextRanges(), rectRanges = docSelectionManagerService.getRectRanges();
|
|
5492
5550
|
if ((!Array.isArray(selections) || selections.length === 0) && (!Array.isArray(rectRanges) || rectRanges.length === 0))
|
|
5493
5551
|
return !1;
|
|
5494
5552
|
const unitId = (_b2 = univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _b2.getUnitId();
|
|
@@ -5515,14 +5573,13 @@ var DeleteDirection = /* @__PURE__ */ ((DeleteDirection2) => (DeleteDirection2[D
|
|
|
5515
5573
|
const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
5516
5574
|
id: EditorInsertTextCommandId,
|
|
5517
5575
|
type: CommandType.COMMAND,
|
|
5518
|
-
// eslint-disable-next-line max-lines-per-function
|
|
5519
5576
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5520
|
-
var
|
|
5577
|
+
var _a29;
|
|
5521
5578
|
const commandService = accessor.get(ICommandService), { range, segmentId, body, unitId, cursorOffset, extendLastRange } = params, docSelectionManagerService = accessor.get(DocSelectionManagerService), docDataModel = accessor.get(IUniverInstanceService).getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
5522
5579
|
if (docDataModel == null)
|
|
5523
5580
|
return !1;
|
|
5524
|
-
const activeRange = docSelectionManagerService.getActiveTextRange(), originBody = docDataModel.getSelfOrHeaderFooterModel((
|
|
5525
|
-
if (
|
|
5581
|
+
const activeRange = docSelectionManagerService.getActiveTextRange(), originBody = docDataModel.getSelfOrHeaderFooterModel((_a29 = activeRange == null ? void 0 : activeRange.segmentId) != null ? _a29 : "").getBody();
|
|
5582
|
+
if (originBody == null)
|
|
5526
5583
|
return !1;
|
|
5527
5584
|
const actualRange = extendLastRange ? BuildTextUtils.selection.getDeleteSelection(range, originBody) : BuildTextUtils.selection.getInsertSelection(range, originBody), { startOffset, collapsed } = actualRange, cursorMove = cursorOffset != null ? cursorOffset : body.dataStream.length, textRanges = [
|
|
5528
5585
|
{
|
|
@@ -5543,8 +5600,7 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5543
5600
|
if (collapsed)
|
|
5544
5601
|
startOffset > 0 && textX.push({
|
|
5545
5602
|
t: TextXActionType.RETAIN,
|
|
5546
|
-
len: startOffset
|
|
5547
|
-
segmentId
|
|
5603
|
+
len: startOffset
|
|
5548
5604
|
});
|
|
5549
5605
|
else {
|
|
5550
5606
|
const { dos, retain } = BuildTextUtils.selection.getDeleteActions(actualRange, segmentId, 0, originBody);
|
|
@@ -5557,9 +5613,7 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5557
5613
|
textX.push({
|
|
5558
5614
|
t: TextXActionType.INSERT,
|
|
5559
5615
|
body,
|
|
5560
|
-
len: body.dataStream.length
|
|
5561
|
-
line: 0,
|
|
5562
|
-
segmentId
|
|
5616
|
+
len: body.dataStream.length
|
|
5563
5617
|
});
|
|
5564
5618
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
5565
5619
|
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
@@ -5568,11 +5622,11 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5568
5622
|
id: "doc.command.delete-text",
|
|
5569
5623
|
type: CommandType.COMMAND,
|
|
5570
5624
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5571
|
-
var
|
|
5625
|
+
var _a29;
|
|
5572
5626
|
const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), { range, segmentId, unitId, direction, len = 1 } = params, docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), body = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
5573
5627
|
if (docDataModel == null || body == null)
|
|
5574
5628
|
return !1;
|
|
5575
|
-
const { startOffset } = range, dataStream = body.dataStream, start = direction === DeleteDirection.LEFT ? startOffset - len : startOffset, end = start + len - 1, relativeCustomRanges = (
|
|
5629
|
+
const { startOffset } = range, dataStream = body.dataStream, start = direction === DeleteDirection.LEFT ? startOffset - len : startOffset, end = start + len - 1, relativeCustomRanges = (_a29 = body.customRanges) == null ? void 0 : _a29.filter((customRange) => BuildTextUtils.customRange.isIntersecting(customRange.startIndex, customRange.endIndex, start, end)), toDeleteRanges = relativeCustomRanges == null ? void 0 : relativeCustomRanges.filter((customRange) => BuildTextUtils.customRange.shouldDeleteCustomRange(start, len, customRange, dataStream)), deleteIndexes = [];
|
|
5576
5630
|
for (let i = 0; i < len; i++)
|
|
5577
5631
|
deleteIndexes.push(start + i);
|
|
5578
5632
|
toDeleteRanges == null || toDeleteRanges.forEach((range2) => {
|
|
@@ -5596,13 +5650,10 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5596
5650
|
const deleteIndex = deleteIndexes[i];
|
|
5597
5651
|
deleteIndex - cursor > 0 && textX.push({
|
|
5598
5652
|
t: TextXActionType.RETAIN,
|
|
5599
|
-
len: deleteIndex - cursor
|
|
5600
|
-
segmentId
|
|
5653
|
+
len: deleteIndex - cursor
|
|
5601
5654
|
}), textX.push({
|
|
5602
5655
|
t: TextXActionType.DELETE,
|
|
5603
|
-
len: 1
|
|
5604
|
-
segmentId,
|
|
5605
|
-
line: 0
|
|
5656
|
+
len: 1
|
|
5606
5657
|
}), cursor = deleteIndex + 1;
|
|
5607
5658
|
}
|
|
5608
5659
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -5625,13 +5676,11 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5625
5676
|
}, textX = new TextX(), jsonX = JSONX.getInstance(), { startOffset, endOffset } = range;
|
|
5626
5677
|
textX.push({
|
|
5627
5678
|
t: TextXActionType.RETAIN,
|
|
5628
|
-
len: startOffset
|
|
5629
|
-
segmentId
|
|
5679
|
+
len: startOffset
|
|
5630
5680
|
}), textX.push({
|
|
5631
5681
|
t: TextXActionType.RETAIN,
|
|
5632
5682
|
body: updateBody,
|
|
5633
5683
|
len: endOffset - startOffset,
|
|
5634
|
-
segmentId,
|
|
5635
5684
|
coverType
|
|
5636
5685
|
});
|
|
5637
5686
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -5641,7 +5690,7 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5641
5690
|
id: "doc.command.delete-custom-block",
|
|
5642
5691
|
type: CommandType.COMMAND,
|
|
5643
5692
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5644
|
-
var
|
|
5693
|
+
var _a29;
|
|
5645
5694
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), activeRange = docSelectionManagerService.getActiveTextRange(), documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
5646
5695
|
if (activeRange == null || documentDataModel == null)
|
|
5647
5696
|
return !1;
|
|
@@ -5662,17 +5711,14 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5662
5711
|
}, textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [];
|
|
5663
5712
|
startOffset > 0 && textX.push({
|
|
5664
5713
|
t: TextXActionType.RETAIN,
|
|
5665
|
-
len: direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset
|
|
5666
|
-
segmentId
|
|
5714
|
+
len: direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset
|
|
5667
5715
|
}), textX.push({
|
|
5668
5716
|
t: TextXActionType.DELETE,
|
|
5669
|
-
len: 1
|
|
5670
|
-
line: 0,
|
|
5671
|
-
segmentId
|
|
5717
|
+
len: 1
|
|
5672
5718
|
});
|
|
5673
5719
|
const path = getRichTextEditPath(documentDataModel, segmentId);
|
|
5674
5720
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
5675
|
-
const drawing = ((
|
|
5721
|
+
const drawing = ((_a29 = documentDataModel.getDrawings()) != null ? _a29 : {})[drawingId], drawingIndex = documentDataModel.getDrawingsOrder().indexOf(drawingId), removeDrawingAction = jsonX.removeOp(["drawings", drawingId], drawing), removeDrawingOrderAction = jsonX.removeOp(["drawingsOrder", drawingIndex], drawingId);
|
|
5676
5722
|
return rawActions.push(removeDrawingAction), rawActions.push(removeDrawingOrderAction), doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
5677
5723
|
}, "handler")
|
|
5678
5724
|
}, MergeTwoParagraphCommand = {
|
|
@@ -5683,13 +5729,24 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5683
5729
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { direction, range } = params, activeRange = docSelectionManagerService.getActiveTextRange(), ranges = docSelectionManagerService.getTextRanges();
|
|
5684
5730
|
if (activeRange == null || ranges == null)
|
|
5685
5731
|
return !1;
|
|
5686
|
-
const { segmentId, style } = activeRange, docDataModel = univerInstanceService.
|
|
5687
|
-
if (
|
|
5732
|
+
const { segmentId, style } = activeRange, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), originBody = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
5733
|
+
if (docDataModel == null || originBody == null)
|
|
5688
5734
|
return !1;
|
|
5689
5735
|
const actualRange = getDeleteSelection(activeRange, originBody), unitId = docDataModel.getUnitId(), { startOffset, collapsed } = actualRange;
|
|
5690
5736
|
if (!collapsed)
|
|
5691
5737
|
return !1;
|
|
5692
|
-
const startIndex = direction === DeleteDirection.LEFT ? startOffset : startOffset + 1
|
|
5738
|
+
const startIndex = direction === DeleteDirection.LEFT ? startOffset : startOffset + 1;
|
|
5739
|
+
let curParagraph, nextParagraph;
|
|
5740
|
+
for (const paragraph of originBody.paragraphs) {
|
|
5741
|
+
if (paragraph.startIndex >= startIndex) {
|
|
5742
|
+
nextParagraph = paragraph;
|
|
5743
|
+
break;
|
|
5744
|
+
}
|
|
5745
|
+
curParagraph = paragraph;
|
|
5746
|
+
}
|
|
5747
|
+
if (curParagraph == null || nextParagraph == null)
|
|
5748
|
+
return !1;
|
|
5749
|
+
const cursor = direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset, textRanges = [
|
|
5693
5750
|
{
|
|
5694
5751
|
startOffset: cursor,
|
|
5695
5752
|
endOffset: cursor,
|
|
@@ -5704,25 +5761,28 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5704
5761
|
prevTextRanges: [range]
|
|
5705
5762
|
}
|
|
5706
5763
|
}, textX = new TextX(), jsonX = JSONX.getInstance();
|
|
5707
|
-
textX.push({
|
|
5764
|
+
curParagraph.startIndex > 0 && textX.push({
|
|
5708
5765
|
t: TextXActionType.RETAIN,
|
|
5709
|
-
len:
|
|
5710
|
-
segmentId
|
|
5711
|
-
}), body.dataStream.length && textX.push({
|
|
5712
|
-
t: TextXActionType.INSERT,
|
|
5713
|
-
body,
|
|
5714
|
-
len: body.dataStream.length,
|
|
5715
|
-
line: 0,
|
|
5716
|
-
segmentId
|
|
5766
|
+
len: curParagraph.startIndex
|
|
5717
5767
|
}), textX.push({
|
|
5768
|
+
t: TextXActionType.DELETE,
|
|
5769
|
+
len: 1
|
|
5770
|
+
}), nextParagraph.startIndex > curParagraph.startIndex + 1 && textX.push({
|
|
5718
5771
|
t: TextXActionType.RETAIN,
|
|
5719
|
-
len: 1
|
|
5720
|
-
segmentId
|
|
5772
|
+
len: nextParagraph.startIndex - curParagraph.startIndex - 1
|
|
5721
5773
|
}), textX.push({
|
|
5722
|
-
t: TextXActionType.
|
|
5723
|
-
len:
|
|
5724
|
-
|
|
5725
|
-
|
|
5774
|
+
t: TextXActionType.RETAIN,
|
|
5775
|
+
len: 1,
|
|
5776
|
+
coverType: UpdateDocsAttributeType.REPLACE,
|
|
5777
|
+
body: {
|
|
5778
|
+
dataStream: "",
|
|
5779
|
+
paragraphs: [
|
|
5780
|
+
{
|
|
5781
|
+
...Tools.deepClone(curParagraph),
|
|
5782
|
+
startIndex: 0
|
|
5783
|
+
}
|
|
5784
|
+
]
|
|
5785
|
+
}
|
|
5726
5786
|
});
|
|
5727
5787
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
5728
5788
|
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
@@ -5754,11 +5814,11 @@ const DeleteLeftCommand = {
|
|
|
5754
5814
|
type: CommandType.COMMAND,
|
|
5755
5815
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
5756
5816
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
5757
|
-
var
|
|
5817
|
+
var _a29, _b2;
|
|
5758
5818
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
|
|
5759
5819
|
let result = !0;
|
|
5760
5820
|
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
5761
|
-
if (
|
|
5821
|
+
if (docDataModel == null)
|
|
5762
5822
|
return !1;
|
|
5763
5823
|
const unitId = docDataModel.getUnitId(), docSkeletonManagerService = getCommandSkeleton(accessor, unitId), activeRange = docSelectionManagerService.getActiveTextRange(), rectRanges = docSelectionManagerService.getRectRanges(), ranges = docSelectionManagerService.getTextRanges(), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
5764
5824
|
if (skeleton == null)
|
|
@@ -5829,7 +5889,7 @@ const DeleteLeftCommand = {
|
|
|
5829
5889
|
range: actualRange
|
|
5830
5890
|
});
|
|
5831
5891
|
else if (preGlyph.streamType === "\b") {
|
|
5832
|
-
const drawing = (_b2 = docDataModel.getSnapshot().drawings) == null ? void 0 : _b2[(
|
|
5892
|
+
const drawing = (_b2 = docDataModel.getSnapshot().drawings) == null ? void 0 : _b2[(_a29 = preGlyph.drawingId) != null ? _a29 : ""];
|
|
5833
5893
|
if (drawing == null)
|
|
5834
5894
|
return !0;
|
|
5835
5895
|
if (drawing.layoutType === PositionedObjectLayoutType.INLINE) {
|
|
@@ -5888,7 +5948,7 @@ const DeleteLeftCommand = {
|
|
|
5888
5948
|
type: CommandType.COMMAND,
|
|
5889
5949
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
5890
5950
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
5891
|
-
var
|
|
5951
|
+
var _a29, _b2;
|
|
5892
5952
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), docDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
|
|
5893
5953
|
if (!docDataModel)
|
|
5894
5954
|
return !1;
|
|
@@ -5924,7 +5984,7 @@ const DeleteLeftCommand = {
|
|
|
5924
5984
|
range: activeRange
|
|
5925
5985
|
});
|
|
5926
5986
|
else if (needDeleteGlyph.streamType === "\b") {
|
|
5927
|
-
const drawing = (_b2 = docDataModel.getSnapshot().drawings) == null ? void 0 : _b2[(
|
|
5987
|
+
const drawing = (_b2 = docDataModel.getSnapshot().drawings) == null ? void 0 : _b2[(_a29 = needDeleteGlyph.drawingId) != null ? _a29 : ""];
|
|
5928
5988
|
if (drawing == null)
|
|
5929
5989
|
return !0;
|
|
5930
5990
|
if (drawing.layoutType === PositionedObjectLayoutType.INLINE) {
|
|
@@ -5986,43 +6046,6 @@ const DeleteLeftCommand = {
|
|
|
5986
6046
|
return result;
|
|
5987
6047
|
}, "handler")
|
|
5988
6048
|
};
|
|
5989
|
-
function getParagraphBody(accessor, unitId, body, start, end) {
|
|
5990
|
-
const { textRuns: originTextRuns = [], customBlocks: originCustomBlocks = [] } = body, bodySlice = {
|
|
5991
|
-
dataStream: body.dataStream.substring(start, end),
|
|
5992
|
-
customRanges: getCustomRangeSlice(body, start, end).customRanges.map((range) => ({
|
|
5993
|
-
...Tools.deepClone(range),
|
|
5994
|
-
rangeId: generateRandomId()
|
|
5995
|
-
})),
|
|
5996
|
-
customDecorations: getCustomDecorationSlice(body, start, end)
|
|
5997
|
-
}, textRuns = [];
|
|
5998
|
-
for (const textRun of originTextRuns) {
|
|
5999
|
-
const { st, ed } = textRun;
|
|
6000
|
-
ed <= start || st >= end || (st < start ? textRuns.push({
|
|
6001
|
-
...textRun,
|
|
6002
|
-
st: 0,
|
|
6003
|
-
ed: ed - start
|
|
6004
|
-
}) : ed > end ? textRuns.push({
|
|
6005
|
-
...textRun,
|
|
6006
|
-
st: st - start,
|
|
6007
|
-
ed: end - start
|
|
6008
|
-
}) : textRuns.push({
|
|
6009
|
-
...textRun,
|
|
6010
|
-
st: st - start,
|
|
6011
|
-
ed: ed - start
|
|
6012
|
-
}));
|
|
6013
|
-
}
|
|
6014
|
-
textRuns.length > 0 && (bodySlice.textRuns = textRuns);
|
|
6015
|
-
const customBlocks = [];
|
|
6016
|
-
for (const block of originCustomBlocks) {
|
|
6017
|
-
const { startIndex } = block;
|
|
6018
|
-
startIndex >= start && startIndex <= end && customBlocks.push({
|
|
6019
|
-
...block,
|
|
6020
|
-
startIndex: startIndex - start
|
|
6021
|
-
});
|
|
6022
|
-
}
|
|
6023
|
-
return customBlocks.length > 0 && (bodySlice.customBlocks = customBlocks), bodySlice;
|
|
6024
|
-
}
|
|
6025
|
-
__name(getParagraphBody, "getParagraphBody");
|
|
6026
6049
|
function getTextRangesWhenDelete(activeRange, ranges) {
|
|
6027
6050
|
let cursor = activeRange.endOffset;
|
|
6028
6051
|
for (const range of ranges) {
|
|
@@ -6184,11 +6207,11 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
|
|
|
6184
6207
|
return pastePlugin && (this._styleRules = [...pastePlugin.stylesRules], this._afterProcessRules = [...pastePlugin.afterProcessRules]), this._tableCache = [], this._styleCache.clear(), this._process(null, dom.childNodes, docData), this._styleCache.clear(), this._styleRules = [], this._afterProcessRules = [], docData;
|
|
6185
6208
|
}
|
|
6186
6209
|
_process(parent, nodes, doc) {
|
|
6187
|
-
var
|
|
6210
|
+
var _a29, _b2;
|
|
6188
6211
|
const body = doc.body;
|
|
6189
6212
|
for (const node of nodes)
|
|
6190
6213
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
6191
|
-
if (((
|
|
6214
|
+
if (((_a29 = node.nodeValue) == null ? void 0 : _a29.trim()) === "")
|
|
6192
6215
|
continue;
|
|
6193
6216
|
const text = (_b2 = node.nodeValue) == null ? void 0 : _b2.replace(/[\r\n]/g, "");
|
|
6194
6217
|
let style;
|
|
@@ -6213,11 +6236,11 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
|
|
|
6213
6236
|
}
|
|
6214
6237
|
}
|
|
6215
6238
|
_processBeforeTable(node, doc) {
|
|
6216
|
-
var
|
|
6239
|
+
var _a29;
|
|
6217
6240
|
const tagName = node.tagName.toUpperCase(), body = doc.body;
|
|
6218
6241
|
switch (tagName) {
|
|
6219
6242
|
case "TABLE": {
|
|
6220
|
-
body.dataStream[body.dataStream.length - 1] !== "\r" && (body.dataStream += "\r", body.paragraphs == null && (body.paragraphs = []), (
|
|
6243
|
+
body.dataStream[body.dataStream.length - 1] !== "\r" && (body.dataStream += "\r", body.paragraphs == null && (body.paragraphs = []), (_a29 = body.paragraphs) == null || _a29.push({
|
|
6221
6244
|
startIndex: body.dataStream.length - 1
|
|
6222
6245
|
}));
|
|
6223
6246
|
const table = genTableSource(0, 0, DEFAULT_TABLE_WIDTH);
|
|
@@ -6240,7 +6263,7 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
|
|
|
6240
6263
|
}
|
|
6241
6264
|
}
|
|
6242
6265
|
_processAfterTable(node, doc) {
|
|
6243
|
-
var
|
|
6266
|
+
var _a29, _b2;
|
|
6244
6267
|
const tagName = node.tagName.toUpperCase(), body = doc.body;
|
|
6245
6268
|
doc.tableSource == null && (doc.tableSource = {}), body.tables == null && (body.tables = []), body.sectionBreaks == null && (body.sectionBreaks = []);
|
|
6246
6269
|
const { tableSource } = doc;
|
|
@@ -6259,7 +6282,7 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
|
|
|
6259
6282
|
break;
|
|
6260
6283
|
}
|
|
6261
6284
|
case "TD": {
|
|
6262
|
-
body.dataStream[body.dataStream.length - 1] !== "\r" && ((
|
|
6285
|
+
body.dataStream[body.dataStream.length - 1] !== "\r" && ((_a29 = body.paragraphs) == null || _a29.push({
|
|
6263
6286
|
startIndex: body.dataStream.length
|
|
6264
6287
|
}), body.dataStream += "\r"), (_b2 = body.sectionBreaks) == null || _b2.push({
|
|
6265
6288
|
startIndex: body.dataStream.length
|
|
@@ -6274,9 +6297,9 @@ ${DataStreamTreeTokenType.TABLE_CELL_END}`;
|
|
|
6274
6297
|
return element2.tagName.toUpperCase() === "A" && (body.dataStream += DataStreamTreeTokenType.CUSTOM_RANGE_START), start;
|
|
6275
6298
|
}
|
|
6276
6299
|
_processAfterLink(node, doc, start) {
|
|
6277
|
-
var
|
|
6300
|
+
var _a29, _b2;
|
|
6278
6301
|
const body = doc.body, element2 = node;
|
|
6279
|
-
element2.tagName.toUpperCase() === "A" && (body.dataStream += DataStreamTreeTokenType.CUSTOM_RANGE_END, body.customRanges = (
|
|
6302
|
+
element2.tagName.toUpperCase() === "A" && (body.dataStream += DataStreamTreeTokenType.CUSTOM_RANGE_END, body.customRanges = (_a29 = body.customRanges) != null ? _a29 : [], body.customRanges.push({
|
|
6280
6303
|
startIndex: start,
|
|
6281
6304
|
endIndex: body.dataStream.length - 1,
|
|
6282
6305
|
rangeId: (_b2 = element2.dataset.rangeid) != null ? _b2 : generateRandomId(),
|
|
@@ -6426,13 +6449,13 @@ function getBodySliceHtml(body, startIndex, endIndex) {
|
|
|
6426
6449
|
const { customRanges = [] } = body, customRangesInRange = customRanges.filter((range) => range.startIndex >= startIndex && range.endIndex <= endIndex);
|
|
6427
6450
|
let cursorIndex = startIndex, html = "";
|
|
6428
6451
|
customRangesInRange.forEach((range) => {
|
|
6429
|
-
var
|
|
6452
|
+
var _a29, _b2;
|
|
6430
6453
|
const { startIndex: startIndex2, endIndex: endIndex2, rangeType, rangeId } = range, preHtml = getBodyInlineSlice(body, cursorIndex, startIndex2);
|
|
6431
6454
|
html += preHtml;
|
|
6432
6455
|
const sliceHtml = getBodyInlineSlice(body, startIndex2 + 1, endIndex2);
|
|
6433
6456
|
switch (rangeType) {
|
|
6434
6457
|
case CustomRangeType.HYPERLINK: {
|
|
6435
|
-
html += `<a data-rangeid="${rangeId}" href="${(_b2 = (
|
|
6458
|
+
html += `<a data-rangeid="${rangeId}" href="${(_b2 = (_a29 = range.properties) == null ? void 0 : _a29.url) != null ? _b2 : ""}">${sliceHtml}</a>`;
|
|
6436
6459
|
break;
|
|
6437
6460
|
}
|
|
6438
6461
|
default: {
|
|
@@ -6463,7 +6486,7 @@ function convertBodyToHtml(body) {
|
|
|
6463
6486
|
}
|
|
6464
6487
|
__name(convertBodyToHtml, "convertBodyToHtml");
|
|
6465
6488
|
function processNode(node, body, result) {
|
|
6466
|
-
var
|
|
6489
|
+
var _a29;
|
|
6467
6490
|
switch (node.nodeType) {
|
|
6468
6491
|
case DataStreamTreeNodeType.SECTION_BREAK: {
|
|
6469
6492
|
for (const n2 of node.children)
|
|
@@ -6471,7 +6494,7 @@ function processNode(node, body, result) {
|
|
|
6471
6494
|
break;
|
|
6472
6495
|
}
|
|
6473
6496
|
case DataStreamTreeNodeType.PARAGRAPH: {
|
|
6474
|
-
const { children, startIndex, endIndex } = node, paragraph = (
|
|
6497
|
+
const { children, startIndex, endIndex } = node, paragraph = (_a29 = body.paragraphs.find((p2) => p2.startIndex === endIndex)) != null ? _a29 : {}, { paragraphStyle = {} } = paragraph, { spaceAbove, spaceBelow, lineSpacing } = paragraphStyle, style = [];
|
|
6475
6498
|
if (spaceAbove != null && (typeof spaceAbove == "number" ? style.push(`margin-top: ${spaceAbove}px`) : style.push(`margin-top: ${spaceAbove.v}px`)), spaceBelow != null && (typeof spaceBelow == "number" ? style.push(`margin-bottom: ${spaceBelow}px`) : style.push(`margin-bottom: ${spaceBelow.v}px`)), lineSpacing != null && style.push(`line-height: ${lineSpacing}`), result.html += `<p class="UniverNormal" ${style.length ? `style="${style.join("; ")};"` : ""}>`, children.length)
|
|
6476
6499
|
for (const table of children)
|
|
6477
6500
|
processNode(table, body, result);
|
|
@@ -6528,9 +6551,9 @@ HtmlToUDMService.use(wordPastePlugin);
|
|
|
6528
6551
|
HtmlToUDMService.use(wordPastePlugin$1);
|
|
6529
6552
|
HtmlToUDMService.use(univerPastePlugin);
|
|
6530
6553
|
function getTableSlice(body, start, end) {
|
|
6531
|
-
var
|
|
6554
|
+
var _a29, _b2, _c;
|
|
6532
6555
|
const bodySlice = getBodySlice(body, start, end + 2), dataStream = DataStreamTreeTokenType.TABLE_START + DataStreamTreeTokenType.TABLE_ROW_START + DataStreamTreeTokenType.TABLE_CELL_START + bodySlice.dataStream + DataStreamTreeTokenType.TABLE_CELL_END + DataStreamTreeTokenType.TABLE_ROW_END + DataStreamTreeTokenType.TABLE_END;
|
|
6533
|
-
return bodySlice.dataStream = dataStream, (
|
|
6556
|
+
return bodySlice.dataStream = dataStream, (_a29 = bodySlice.textRuns) == null || _a29.forEach((textRun) => {
|
|
6534
6557
|
const { st, ed } = textRun;
|
|
6535
6558
|
textRun.st = st + 3, textRun.ed = ed + 3;
|
|
6536
6559
|
}), (_b2 = bodySlice.tables) == null || _b2.forEach((table) => {
|
|
@@ -6543,8 +6566,8 @@ function getTableSlice(body, start, end) {
|
|
|
6543
6566
|
}
|
|
6544
6567
|
__name(getTableSlice, "getTableSlice");
|
|
6545
6568
|
const IDocClipboardService = createIdentifier("doc.clipboard-service");
|
|
6546
|
-
var
|
|
6547
|
-
let DocClipboardService = (
|
|
6569
|
+
var _a5;
|
|
6570
|
+
let DocClipboardService = (_a5 = class extends Disposable {
|
|
6548
6571
|
constructor(_univerInstanceService, _logService, _commandService, _clipboardInterfaceService, _docSelectionManagerService) {
|
|
6549
6572
|
super();
|
|
6550
6573
|
__publicField(this, "_clipboardHooks", []);
|
|
@@ -6553,8 +6576,8 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6553
6576
|
this._univerInstanceService = _univerInstanceService, this._logService = _logService, this._commandService = _commandService, this._clipboardInterfaceService = _clipboardInterfaceService, this._docSelectionManagerService = _docSelectionManagerService;
|
|
6554
6577
|
}
|
|
6555
6578
|
async copy(sliceType = SliceBodyType.copy) {
|
|
6556
|
-
var
|
|
6557
|
-
const { bodyList = [], needCache = !1, snapshot } = (
|
|
6579
|
+
var _a29;
|
|
6580
|
+
const { bodyList = [], needCache = !1, snapshot } = (_a29 = this._getDocumentBodyInRanges(sliceType)) != null ? _a29 : {};
|
|
6558
6581
|
if (bodyList.length === 0 || snapshot == null)
|
|
6559
6582
|
return !1;
|
|
6560
6583
|
try {
|
|
@@ -6573,9 +6596,9 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6573
6596
|
return this._paste(partDocData);
|
|
6574
6597
|
}
|
|
6575
6598
|
async legacyPaste(html, text) {
|
|
6576
|
-
var
|
|
6599
|
+
var _a29;
|
|
6577
6600
|
const partDocData = this._genDocDataFromHtmlAndText(html, text);
|
|
6578
|
-
if (((
|
|
6601
|
+
if (((_a29 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a29.getUnitId()) === DOCS_NORMAL_EDITOR_UNIT_ID_KEY)
|
|
6579
6602
|
if (text) {
|
|
6580
6603
|
const textDocData = BuildTextUtils.transform.fromPlainText(text);
|
|
6581
6604
|
return this._paste({ body: textDocData });
|
|
@@ -6584,12 +6607,12 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6584
6607
|
return this._paste(partDocData);
|
|
6585
6608
|
}
|
|
6586
6609
|
async _cut() {
|
|
6587
|
-
var
|
|
6610
|
+
var _a29, _b2, _c;
|
|
6588
6611
|
const {
|
|
6589
6612
|
segmentId,
|
|
6590
6613
|
endOffset: activeEndOffset,
|
|
6591
6614
|
style
|
|
6592
|
-
} = (
|
|
6615
|
+
} = (_a29 = this._docSelectionManagerService.getActiveTextRange()) != null ? _a29 : {}, textRanges = (_b2 = this._docSelectionManagerService.getTextRanges()) != null ? _b2 : [], rectRanges = (_c = this._docSelectionManagerService.getRectRanges()) != null ? _c : [];
|
|
6593
6616
|
if (segmentId == null && this._logService.error("[DocClipboardController] segmentId is not existed"), textRanges.length === 0 && rectRanges.length === 0)
|
|
6594
6617
|
return !1;
|
|
6595
6618
|
this.copy(SliceBodyType.cut);
|
|
@@ -6617,12 +6640,12 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6617
6640
|
}
|
|
6618
6641
|
}
|
|
6619
6642
|
async _paste(docData) {
|
|
6620
|
-
var
|
|
6643
|
+
var _a29, _b2;
|
|
6621
6644
|
const { body: _body } = docData;
|
|
6622
6645
|
if (_body == null)
|
|
6623
6646
|
return !1;
|
|
6624
6647
|
let body = normalizeBody(_body);
|
|
6625
|
-
if (!((
|
|
6648
|
+
if (!((_a29 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a29.getUnitId()))
|
|
6626
6649
|
return !1;
|
|
6627
6650
|
this._clipboardHooks.forEach((hook) => {
|
|
6628
6651
|
hook.onBeforePaste && (body = hook.onBeforePaste(body));
|
|
@@ -6656,7 +6679,7 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6656
6679
|
}
|
|
6657
6680
|
}
|
|
6658
6681
|
async _setClipboardData(documentBodyList, snapshot, needCache = !0) {
|
|
6659
|
-
var
|
|
6682
|
+
var _a29, _b2;
|
|
6660
6683
|
const copyId = genId(), text = (documentBodyList.length > 1 ? documentBodyList.map((body) => body.dataStream).join(`
|
|
6661
6684
|
`) : documentBodyList[0].dataStream).replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, "").replaceAll(DataStreamTreeTokenType.TABLE_START, "").replaceAll(DataStreamTreeTokenType.TABLE_END, "").replaceAll(DataStreamTreeTokenType.TABLE_ROW_START, "").replaceAll(DataStreamTreeTokenType.TABLE_ROW_END, "").replaceAll(DataStreamTreeTokenType.TABLE_CELL_START, "").replaceAll(DataStreamTreeTokenType.TABLE_CELL_END, "").replaceAll(`\r
|
|
6662
6685
|
`, " ");
|
|
@@ -6664,7 +6687,7 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6664
6687
|
if (documentBodyList.length === 1 && needCache) {
|
|
6665
6688
|
html = html.replace(/(<[a-z]+)/, (_p0, p1) => `${p1} data-copy-id="${copyId}"`);
|
|
6666
6689
|
const body = documentBodyList[0], cache = { body };
|
|
6667
|
-
if ((
|
|
6690
|
+
if ((_a29 = body.customBlocks) != null && _a29.length) {
|
|
6668
6691
|
cache.drawings = {};
|
|
6669
6692
|
for (const block of body.customBlocks) {
|
|
6670
6693
|
const { blockId } = block, drawing = (_b2 = snapshot.drawings) == null ? void 0 : _b2[blockId];
|
|
@@ -6688,12 +6711,12 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6688
6711
|
});
|
|
6689
6712
|
}
|
|
6690
6713
|
_getDocumentBodyInRanges(sliceType) {
|
|
6691
|
-
var
|
|
6714
|
+
var _a29;
|
|
6692
6715
|
const docDataModel = this._univerInstanceService.getCurrentUniverDocInstance(), allRanges = this._docSelectionManagerService.getDocRanges(), results = [];
|
|
6693
6716
|
let needCache = !0;
|
|
6694
6717
|
if (docDataModel == null || allRanges.length === 0)
|
|
6695
6718
|
return;
|
|
6696
|
-
const segmentId = allRanges[0].segmentId, body = (
|
|
6719
|
+
const segmentId = allRanges[0].segmentId, body = (_a29 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a29.getBody(), snapshot = docDataModel.getSnapshot();
|
|
6697
6720
|
if (body != null) {
|
|
6698
6721
|
for (const range of allRanges) {
|
|
6699
6722
|
const { startOffset, endOffset, collapsed, rangeType } = range;
|
|
@@ -6741,7 +6764,7 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6741
6764
|
}
|
|
6742
6765
|
return this._htmlToUDM.convert(html);
|
|
6743
6766
|
}
|
|
6744
|
-
}, __name(
|
|
6767
|
+
}, __name(_a5, "DocClipboardService"), _a5);
|
|
6745
6768
|
DocClipboardService = __decorateClass$n([
|
|
6746
6769
|
__decorateParam$n(0, IUniverInstanceService),
|
|
6747
6770
|
__decorateParam$n(1, ILogService),
|
|
@@ -6780,6 +6803,55 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6780
6803
|
const docClipboardService = accessor.get(IDocClipboardService), clipboardItems = await accessor.get(IClipboardInterfaceService).read();
|
|
6781
6804
|
return clipboardItems.length === 0 ? !1 : docClipboardService.paste(clipboardItems);
|
|
6782
6805
|
}, "handler")
|
|
6806
|
+
}, SwitchDocModeCommand = {
|
|
6807
|
+
id: "doc.command.switch-mode",
|
|
6808
|
+
type: CommandType.COMMAND,
|
|
6809
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
6810
|
+
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
6811
|
+
var _a29, _b2, _c, _d, _e;
|
|
6812
|
+
const commandService = accessor.get(ICommandService), renderManagerService = accessor.get(IRenderManagerService), docSelectionManagerService = accessor.get(DocSelectionManagerService), docDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
|
|
6813
|
+
if (docDataModel == null)
|
|
6814
|
+
return !1;
|
|
6815
|
+
const unitId = docDataModel.getUnitId(), skeleton = (_a29 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a29.with(DocSkeletonManagerService).getSkeleton(), docSelectionRenderService = (_b2 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _b2.with(DocSelectionRenderService);
|
|
6816
|
+
if (skeleton == null || docSelectionRenderService == null)
|
|
6817
|
+
return !1;
|
|
6818
|
+
const segmentId = docSelectionRenderService == null ? void 0 : docSelectionRenderService.getSegment(), segmentPage = docSelectionRenderService == null ? void 0 : docSelectionRenderService.getSegmentPage(), oldDocumentFlavor = docDataModel.getSnapshot().documentStyle.documentFlavor, docRanges = docSelectionManagerService.getDocRanges(), doMutation = {
|
|
6819
|
+
id: RichTextEditingMutation.id,
|
|
6820
|
+
params: {
|
|
6821
|
+
unitId,
|
|
6822
|
+
actions: [],
|
|
6823
|
+
textRanges: oldDocumentFlavor === DocumentFlavor.TRADITIONAL && segmentId ? [] : docRanges
|
|
6824
|
+
}
|
|
6825
|
+
}, jsonX = JSONX.getInstance(), rawActions = [];
|
|
6826
|
+
let action;
|
|
6827
|
+
if (oldDocumentFlavor === void 0 ? action = jsonX.insertOp(["documentStyle", "documentFlavor"], DocumentFlavor.MODERN) : oldDocumentFlavor === DocumentFlavor.MODERN ? action = jsonX.replaceOp(["documentStyle", "documentFlavor"], oldDocumentFlavor, DocumentFlavor.TRADITIONAL) : action = jsonX.replaceOp(["documentStyle", "documentFlavor"], oldDocumentFlavor, DocumentFlavor.MODERN), action)
|
|
6828
|
+
rawActions.push(action);
|
|
6829
|
+
else
|
|
6830
|
+
return !1;
|
|
6831
|
+
if (oldDocumentFlavor !== DocumentFlavor.MODERN) {
|
|
6832
|
+
const snapshot = docDataModel.getSnapshot(), { drawings = {}, body } = snapshot, customBlocks = (_c = body == null ? void 0 : body.customBlocks) != null ? _c : [];
|
|
6833
|
+
for (const drawingId in drawings) {
|
|
6834
|
+
const drawing = drawings[drawingId], customBlock = customBlocks.find((block) => block.blockId === drawingId);
|
|
6835
|
+
if (customBlock == null)
|
|
6836
|
+
continue;
|
|
6837
|
+
const drawingPositionV = drawing.docTransform.positionV, { relativeFrom: prevRelativeFrom, posOffset: prevPosOffset } = drawingPositionV;
|
|
6838
|
+
if (prevRelativeFrom === ObjectRelativeFromV.PARAGRAPH)
|
|
6839
|
+
continue;
|
|
6840
|
+
const { startIndex } = customBlock, glyph = skeleton.findNodeByCharIndex(startIndex, segmentId, segmentPage), line = (_d = glyph == null ? void 0 : glyph.parent) == null ? void 0 : _d.parent, column = line == null ? void 0 : line.parent, paragraphStartLine = column == null ? void 0 : column.lines.find((l2) => l2.paragraphIndex === (line == null ? void 0 : line.paragraphIndex) && l2.paragraphStart), page = (_e = column == null ? void 0 : column.parent) == null ? void 0 : _e.parent;
|
|
6841
|
+
if (glyph == null || line == null || paragraphStartLine == null || column == null || page == null)
|
|
6842
|
+
continue;
|
|
6843
|
+
let delta = 0;
|
|
6844
|
+
prevRelativeFrom === ObjectRelativeFromV.LINE ? delta -= line.top : prevRelativeFrom === ObjectRelativeFromV.PAGE && (delta += page.marginTop), delta += paragraphStartLine.top;
|
|
6845
|
+
const newPositionV = {
|
|
6846
|
+
...drawingPositionV,
|
|
6847
|
+
relativeFrom: ObjectRelativeFromV.PARAGRAPH,
|
|
6848
|
+
posOffset: (prevPosOffset != null ? prevPosOffset : 0) - delta
|
|
6849
|
+
}, updateDrawingAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionV"], drawingPositionV, newPositionV);
|
|
6850
|
+
updateDrawingAction && rawActions.push(updateDrawingAction);
|
|
6851
|
+
}
|
|
6852
|
+
}
|
|
6853
|
+
return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
6854
|
+
}, "handler")
|
|
6783
6855
|
}, DocTableDeleteRowsCommand = {
|
|
6784
6856
|
id: "doc.table.delete-rows",
|
|
6785
6857
|
type: CommandType.COMMAND,
|
|
@@ -6814,13 +6886,10 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6814
6886
|
};
|
|
6815
6887
|
offset > 0 && textX.push({
|
|
6816
6888
|
t: TextXActionType.RETAIN,
|
|
6817
|
-
len: offset
|
|
6818
|
-
segmentId
|
|
6889
|
+
len: offset
|
|
6819
6890
|
}), textX.push({
|
|
6820
6891
|
t: TextXActionType.DELETE,
|
|
6821
|
-
len
|
|
6822
|
-
line: 0,
|
|
6823
|
-
segmentId
|
|
6892
|
+
len
|
|
6824
6893
|
});
|
|
6825
6894
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
6826
6895
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -6866,13 +6935,10 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6866
6935
|
const { retain, delete: deleteLen } = offset;
|
|
6867
6936
|
retain > 0 && textX.push({
|
|
6868
6937
|
t: TextXActionType.RETAIN,
|
|
6869
|
-
len: retain
|
|
6870
|
-
segmentId
|
|
6938
|
+
len: retain
|
|
6871
6939
|
}), textX.push({
|
|
6872
6940
|
t: TextXActionType.DELETE,
|
|
6873
|
-
len: deleteLen
|
|
6874
|
-
line: 0,
|
|
6875
|
-
segmentId
|
|
6941
|
+
len: deleteLen
|
|
6876
6942
|
});
|
|
6877
6943
|
}
|
|
6878
6944
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -6919,13 +6985,10 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6919
6985
|
};
|
|
6920
6986
|
offset > 0 && textX.push({
|
|
6921
6987
|
t: TextXActionType.RETAIN,
|
|
6922
|
-
len: offset
|
|
6923
|
-
segmentId
|
|
6988
|
+
len: offset
|
|
6924
6989
|
}), textX.push({
|
|
6925
6990
|
t: TextXActionType.DELETE,
|
|
6926
|
-
len
|
|
6927
|
-
line: 0,
|
|
6928
|
-
segmentId
|
|
6991
|
+
len
|
|
6929
6992
|
});
|
|
6930
6993
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
6931
6994
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -6979,16 +7042,13 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6979
7042
|
};
|
|
6980
7043
|
offset > 0 && textX.push({
|
|
6981
7044
|
t: TextXActionType.RETAIN,
|
|
6982
|
-
len: offset
|
|
6983
|
-
segmentId
|
|
7045
|
+
len: offset
|
|
6984
7046
|
});
|
|
6985
7047
|
const insertBody = getInsertRowBody(colCount);
|
|
6986
7048
|
textX.push({
|
|
6987
7049
|
t: TextXActionType.INSERT,
|
|
6988
7050
|
body: insertBody,
|
|
6989
|
-
len: insertBody.dataStream.length
|
|
6990
|
-
line: 0,
|
|
6991
|
-
segmentId
|
|
7051
|
+
len: insertBody.dataStream.length
|
|
6992
7052
|
});
|
|
6993
7053
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
6994
7054
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -7000,7 +7060,7 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
7000
7060
|
type: CommandType.COMMAND,
|
|
7001
7061
|
// eslint-disable-next-line max-lines-per-function
|
|
7002
7062
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
7003
|
-
var
|
|
7063
|
+
var _a29, _b2, _c;
|
|
7004
7064
|
const { position } = params, docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), activeRectRanges = docSelectionManagerService.getRectRanges(), activeTextRange = docSelectionManagerService.getActiveTextRange(), rangeInfo = getRangeInfoFromRanges(activeTextRange, activeRectRanges);
|
|
7005
7065
|
if (rangeInfo == null)
|
|
7006
7066
|
return !1;
|
|
@@ -7028,16 +7088,13 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
7028
7088
|
for (const offset of offsets) {
|
|
7029
7089
|
textX.push({
|
|
7030
7090
|
t: TextXActionType.RETAIN,
|
|
7031
|
-
len: offset
|
|
7032
|
-
segmentId
|
|
7091
|
+
len: offset
|
|
7033
7092
|
});
|
|
7034
7093
|
const insertBody = getInsertColumnBody();
|
|
7035
7094
|
textX.push({
|
|
7036
7095
|
t: TextXActionType.INSERT,
|
|
7037
7096
|
body: insertBody,
|
|
7038
|
-
len: insertBody.dataStream.length
|
|
7039
|
-
line: 0,
|
|
7040
|
-
segmentId
|
|
7097
|
+
len: insertBody.dataStream.length
|
|
7041
7098
|
});
|
|
7042
7099
|
}
|
|
7043
7100
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -7046,7 +7103,7 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
7046
7103
|
const insertCell = getEmptyTableCell(), insertTableSource = jsonX.insertOp(["tableSource", tableId, "tableRows", i, "tableCells", columnIndex], insertCell);
|
|
7047
7104
|
rawActions.push(insertTableSource);
|
|
7048
7105
|
}
|
|
7049
|
-
const snapshot = docDataModel.getSnapshot(), documentStyle = snapshot.documentStyle, { marginLeft = 0, marginRight = 0 } = documentStyle, pageWidth = ((_b2 = (
|
|
7106
|
+
const snapshot = docDataModel.getSnapshot(), documentStyle = snapshot.documentStyle, { marginLeft = 0, marginRight = 0 } = documentStyle, pageWidth = ((_b2 = (_a29 = documentStyle.pageSize) == null ? void 0 : _a29.width) != null ? _b2 : 800) - marginLeft - marginRight, tableColumns = (_c = snapshot == null ? void 0 : snapshot.tableSource) == null ? void 0 : _c[tableId].tableColumns, { newColWidth, widths } = getColumnWidths(pageWidth, tableColumns, columnIndex);
|
|
7050
7107
|
for (let i = 0; i < widths.length; i++) {
|
|
7051
7108
|
const action = jsonX.replaceOp(["tableSource", tableId, "tableColumns", i, "size", "width", "v"], tableColumns[i].size.width.v, widths[i]);
|
|
7052
7109
|
rawActions.push(action);
|
|
@@ -7071,52 +7128,54 @@ const BreakLineCommand = {
|
|
|
7071
7128
|
id: "doc.command.break-line",
|
|
7072
7129
|
type: CommandType.COMMAND,
|
|
7073
7130
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
7074
|
-
var
|
|
7131
|
+
var _a29, _b2;
|
|
7075
7132
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), activeTextRange = docSelectionManagerService.getActiveTextRange(), rectRanges = docSelectionManagerService.getRectRanges();
|
|
7076
7133
|
if (activeTextRange == null)
|
|
7077
7134
|
return !1;
|
|
7078
7135
|
if (rectRanges && rectRanges.length) {
|
|
7079
7136
|
const { startOffset: startOffset2 } = activeTextRange;
|
|
7080
|
-
return docSelectionManagerService.
|
|
7137
|
+
return docSelectionManagerService.replaceDocRanges([{
|
|
7081
7138
|
startOffset: startOffset2,
|
|
7082
7139
|
endOffset: startOffset2
|
|
7083
7140
|
}]), !0;
|
|
7084
7141
|
}
|
|
7085
|
-
const { segmentId } = activeTextRange, docDataModel = univerInstanceService.
|
|
7086
|
-
if (
|
|
7142
|
+
const { segmentId } = activeTextRange, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), body = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId != null ? segmentId : "").getBody();
|
|
7143
|
+
if (docDataModel == null || body == null)
|
|
7087
7144
|
return !1;
|
|
7088
|
-
const unitId = docDataModel.getUnitId(), { startOffset, endOffset } = BuildTextUtils.selection.getInsertSelection(activeTextRange, body), prevParagraph = ((
|
|
7145
|
+
const unitId = docDataModel.getUnitId(), { startOffset, endOffset } = BuildTextUtils.selection.getInsertSelection(activeTextRange, body), prevParagraph = ((_a29 = body.paragraphs) != null ? _a29 : []).find((p2) => p2.startIndex >= startOffset);
|
|
7089
7146
|
if (!prevParagraph)
|
|
7090
7147
|
return !1;
|
|
7091
|
-
const
|
|
7092
|
-
|
|
7093
|
-
|
|
7148
|
+
const prevParagraphIndex = prevParagraph.startIndex, insertBody = {
|
|
7149
|
+
dataStream: DataStreamTreeTokenType.PARAGRAPH,
|
|
7150
|
+
paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
7151
|
+
}, deleteRange = {
|
|
7094
7152
|
startOffset,
|
|
7095
|
-
endOffset
|
|
7096
|
-
|
|
7097
|
-
};
|
|
7098
|
-
return ((_d = (_c = bodyAfter.paragraphs) == null ? void 0 : _c[0].bullet) == null ? void 0 : _d.listType) === PresetListType.CHECK_LIST_CHECKED && (bodyAfter.paragraphs[0].bullet.listType = PresetListType.CHECK_LIST), updateAttributeByInsert(
|
|
7099
|
-
bodyAfter,
|
|
7100
|
-
{
|
|
7101
|
-
dataStream: DataStreamTreeTokenType.PARAGRAPH,
|
|
7102
|
-
paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
7103
|
-
},
|
|
7104
|
-
1,
|
|
7105
|
-
0
|
|
7106
|
-
), await commandService.executeCommand(InsertCommand.id, {
|
|
7153
|
+
endOffset
|
|
7154
|
+
}, result = await commandService.executeCommand(InsertCommand.id, {
|
|
7107
7155
|
unitId,
|
|
7108
|
-
body:
|
|
7156
|
+
body: insertBody,
|
|
7109
7157
|
range: deleteRange,
|
|
7110
|
-
segmentId
|
|
7111
|
-
cursorOffset: 1
|
|
7158
|
+
segmentId
|
|
7112
7159
|
});
|
|
7160
|
+
if (((_b2 = prevParagraph.bullet) == null ? void 0 : _b2.listType) === PresetListType.CHECK_LIST_CHECKED) {
|
|
7161
|
+
const params = {
|
|
7162
|
+
index: prevParagraphIndex + 1 - (endOffset - startOffset),
|
|
7163
|
+
segmentId,
|
|
7164
|
+
textRanges: [{
|
|
7165
|
+
startOffset: startOffset + 1,
|
|
7166
|
+
endOffset: startOffset + 1
|
|
7167
|
+
}]
|
|
7168
|
+
};
|
|
7169
|
+
return !!await commandService.executeCommand(ToggleCheckListCommand.id, params) && result;
|
|
7170
|
+
}
|
|
7171
|
+
return result;
|
|
7113
7172
|
}, "handler")
|
|
7114
7173
|
}, CreateDocTableCommandId = "doc.command.create-table", CreateDocTableCommand = {
|
|
7115
7174
|
id: CreateDocTableCommandId,
|
|
7116
7175
|
type: CommandType.COMMAND,
|
|
7117
7176
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
7118
7177
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
7119
|
-
var
|
|
7178
|
+
var _a29, _b2, _c, _d, _e, _f;
|
|
7120
7179
|
const { rowCount, colCount } = params, docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), activeRange = docSelectionManagerService.getActiveTextRange();
|
|
7121
7180
|
if (activeRange == null)
|
|
7122
7181
|
return !1;
|
|
@@ -7126,7 +7185,7 @@ const BreakLineCommand = {
|
|
|
7126
7185
|
const unitId = docDataModel.getUnitId(), docSkeletonManagerService = getCommandSkeleton(accessor, unitId), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
7127
7186
|
if (skeleton == null)
|
|
7128
7187
|
return !1;
|
|
7129
|
-
const { startOffset } = BuildTextUtils.selection.getInsertSelection(activeRange, body), prevParagraph = ((
|
|
7188
|
+
const { startOffset } = BuildTextUtils.selection.getInsertSelection(activeRange, body), prevParagraph = ((_a29 = body.paragraphs) != null ? _a29 : []).find((p2) => p2.startIndex >= startOffset), curGlyph = skeleton.findNodeByCharIndex(startOffset, segmentId, segmentPage), line = (_b2 = curGlyph == null ? void 0 : curGlyph.parent) == null ? void 0 : _b2.parent, preGlyph = skeleton.findNodeByCharIndex(startOffset - 1, segmentId, segmentPage), isInParagraph = preGlyph && preGlyph.content !== "\r";
|
|
7130
7189
|
if (curGlyph == null || line == null)
|
|
7131
7190
|
return !1;
|
|
7132
7191
|
const needCreateParagraph = isInParagraph || line.isBehindTable, textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [], cursor = startOffset + (needCreateParagraph ? 4 : 3), textRanges = [{
|
|
@@ -7143,17 +7202,14 @@ const BreakLineCommand = {
|
|
|
7143
7202
|
};
|
|
7144
7203
|
startOffset > 0 && textX.push({
|
|
7145
7204
|
t: TextXActionType.RETAIN,
|
|
7146
|
-
len: startOffset
|
|
7147
|
-
segmentId
|
|
7205
|
+
len: startOffset
|
|
7148
7206
|
}), needCreateParagraph && textX.push({
|
|
7149
7207
|
t: TextXActionType.INSERT,
|
|
7150
7208
|
body: {
|
|
7151
7209
|
dataStream: DataStreamTreeTokenType.PARAGRAPH,
|
|
7152
7210
|
paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
7153
7211
|
},
|
|
7154
|
-
len: 1
|
|
7155
|
-
line: 0,
|
|
7156
|
-
segmentId
|
|
7212
|
+
len: 1
|
|
7157
7213
|
});
|
|
7158
7214
|
const { dataStream: tableDataStream, paragraphs: tableParagraphs, sectionBreaks } = genEmptyTable(rowCount, colCount), page = (_f = (_e = (_d = (_c = curGlyph.parent) == null ? void 0 : _c.parent) == null ? void 0 : _d.parent) == null ? void 0 : _e.parent) == null ? void 0 : _f.parent;
|
|
7159
7215
|
if (page == null)
|
|
@@ -7173,9 +7229,7 @@ const BreakLineCommand = {
|
|
|
7173
7229
|
}
|
|
7174
7230
|
]
|
|
7175
7231
|
},
|
|
7176
|
-
len: tableDataStream.length
|
|
7177
|
-
line: 0,
|
|
7178
|
-
segmentId
|
|
7232
|
+
len: tableDataStream.length
|
|
7179
7233
|
});
|
|
7180
7234
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
7181
7235
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -7217,11 +7271,11 @@ const BreakLineCommand = {
|
|
|
7217
7271
|
id: "doc-paragraph-setting.command",
|
|
7218
7272
|
type: CommandType.COMMAND,
|
|
7219
7273
|
handler: /* @__PURE__ */ __name(async (accessor, config) => {
|
|
7220
|
-
var
|
|
7274
|
+
var _a29, _b2, _c;
|
|
7221
7275
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docRanges = docSelectionManagerService.getDocRanges();
|
|
7222
7276
|
if (!docDataModel || docRanges.length === 0 || !config)
|
|
7223
7277
|
return !1;
|
|
7224
|
-
const segmentId = docRanges[0].segmentId, unitId = docDataModel.getUnitId(), allParagraphs = (_b2 = (
|
|
7278
|
+
const segmentId = docRanges[0].segmentId, unitId = docDataModel.getUnitId(), allParagraphs = (_b2 = (_a29 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a29.paragraphs) != null ? _b2 : [], paragraphs = (_c = getParagraphsInRanges(docRanges, allParagraphs)) != null ? _c : [], doMutation = {
|
|
7225
7279
|
id: RichTextEditingMutation.id,
|
|
7226
7280
|
params: {
|
|
7227
7281
|
unitId,
|
|
@@ -7235,8 +7289,7 @@ const BreakLineCommand = {
|
|
|
7235
7289
|
const { startIndex } = paragraph;
|
|
7236
7290
|
textX.push({
|
|
7237
7291
|
t: TextXActionType.RETAIN,
|
|
7238
|
-
len: startIndex - memoryCursor.cursor
|
|
7239
|
-
segmentId
|
|
7292
|
+
len: startIndex - memoryCursor.cursor
|
|
7240
7293
|
});
|
|
7241
7294
|
const paragraphStyle = {
|
|
7242
7295
|
...paragraph.paragraphStyle,
|
|
@@ -7255,7 +7308,6 @@ const BreakLineCommand = {
|
|
|
7255
7308
|
}
|
|
7256
7309
|
]
|
|
7257
7310
|
},
|
|
7258
|
-
segmentId,
|
|
7259
7311
|
coverType: UpdateDocsAttributeType.REPLACE
|
|
7260
7312
|
}), memoryCursor.moveCursorTo(startIndex + 1);
|
|
7261
7313
|
}
|
|
@@ -7268,89 +7320,89 @@ const BreakLineCommand = {
|
|
|
7268
7320
|
docRanges.length || docParagraphSettingController.closePanel();
|
|
7269
7321
|
}, [docRanges]), docRanges;
|
|
7270
7322
|
}, "useDocRanges"), useCurrentParagraph = /* @__PURE__ */ __name(() => {
|
|
7271
|
-
var
|
|
7323
|
+
var _a29, _b2, _c;
|
|
7272
7324
|
const docDataModel = useDependency(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docRanges = useDocRanges();
|
|
7273
7325
|
if (!docDataModel || docRanges.length === 0)
|
|
7274
7326
|
return [];
|
|
7275
|
-
const segmentId = docRanges[0].segmentId, paragraphs = (_b2 = (
|
|
7327
|
+
const segmentId = docRanges[0].segmentId, paragraphs = (_b2 = (_a29 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a29.paragraphs) != null ? _b2 : [];
|
|
7276
7328
|
return (_c = getParagraphsInRanges(docRanges, paragraphs)) != null ? _c : [];
|
|
7277
7329
|
}, "useCurrentParagraph"), useFirstParagraphHorizontalAlign = /* @__PURE__ */ __name((paragraph, defaultValue) => {
|
|
7278
7330
|
const commandService = useDependency(ICommandService), [horizontalAlign, _horizontalAlignSet] = useState(() => {
|
|
7279
|
-
var
|
|
7331
|
+
var _a29, _b2;
|
|
7280
7332
|
const firstParagraph = paragraph[0];
|
|
7281
|
-
return firstParagraph ? String((_b2 = (
|
|
7333
|
+
return firstParagraph ? String((_b2 = (_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.horizontalAlign) != null ? _b2 : defaultValue) : defaultValue;
|
|
7282
7334
|
});
|
|
7283
7335
|
return [horizontalAlign, /* @__PURE__ */ __name((v) => (_horizontalAlignSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
|
|
7284
7336
|
paragraph: { horizontalAlign: Number(v) }
|
|
7285
7337
|
})), "horizontalAlignSet")];
|
|
7286
7338
|
}, "useFirstParagraphHorizontalAlign"), useFirstParagraphIndentStart = /* @__PURE__ */ __name((paragraph) => {
|
|
7287
7339
|
const commandService = useDependency(ICommandService), [indentStart, _indentStartSet] = useState(() => {
|
|
7288
|
-
var
|
|
7340
|
+
var _a29;
|
|
7289
7341
|
const firstParagraph = paragraph[0];
|
|
7290
|
-
return firstParagraph ? getNumberUnitValue((
|
|
7342
|
+
return firstParagraph ? getNumberUnitValue((_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.indentStart, 0) : 0;
|
|
7291
7343
|
});
|
|
7292
7344
|
return [indentStart, /* @__PURE__ */ __name((v) => (_indentStartSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
|
|
7293
7345
|
paragraph: { indentStart: { v } }
|
|
7294
7346
|
})), "indentStartSet")];
|
|
7295
7347
|
}, "useFirstParagraphIndentStart"), useFirstParagraphIndentEnd = /* @__PURE__ */ __name((paragraph) => {
|
|
7296
7348
|
const commandService = useDependency(ICommandService), [indentEnd, _indentEndSet] = useState(() => {
|
|
7297
|
-
var
|
|
7349
|
+
var _a29;
|
|
7298
7350
|
const firstParagraph = paragraph[0];
|
|
7299
|
-
return firstParagraph ? getNumberUnitValue((
|
|
7351
|
+
return firstParagraph ? getNumberUnitValue((_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.indentEnd, 0) : 0;
|
|
7300
7352
|
});
|
|
7301
7353
|
return [indentEnd, /* @__PURE__ */ __name((v) => (_indentEndSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
|
|
7302
7354
|
paragraph: { indentEnd: { v } }
|
|
7303
7355
|
})), "indentEndSet")];
|
|
7304
7356
|
}, "useFirstParagraphIndentEnd"), useFirstParagraphIndentFirstLine = /* @__PURE__ */ __name((paragraph) => {
|
|
7305
7357
|
const commandService = useDependency(ICommandService), [indentFirstLine, _indentFirstLineSet] = useState(() => {
|
|
7306
|
-
var
|
|
7358
|
+
var _a29;
|
|
7307
7359
|
const firstParagraph = paragraph[0];
|
|
7308
|
-
return firstParagraph ? getNumberUnitValue((
|
|
7360
|
+
return firstParagraph ? getNumberUnitValue((_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.indentFirstLine, 0) : 0;
|
|
7309
7361
|
});
|
|
7310
7362
|
return [indentFirstLine, /* @__PURE__ */ __name((v) => (_indentFirstLineSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
|
|
7311
7363
|
paragraph: { indentFirstLine: { v } }
|
|
7312
7364
|
})), "indentFirstLineSet")];
|
|
7313
7365
|
}, "useFirstParagraphIndentFirstLine"), useFirstParagraphIndentHanging = /* @__PURE__ */ __name((paragraph) => {
|
|
7314
7366
|
const commandService = useDependency(ICommandService), [hanging, _hangingSet] = useState(() => {
|
|
7315
|
-
var
|
|
7367
|
+
var _a29;
|
|
7316
7368
|
const firstParagraph = paragraph[0];
|
|
7317
|
-
return firstParagraph ? getNumberUnitValue((
|
|
7369
|
+
return firstParagraph ? getNumberUnitValue((_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.hanging, 0) : 0;
|
|
7318
7370
|
});
|
|
7319
7371
|
return [hanging, /* @__PURE__ */ __name((v) => (_hangingSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
|
|
7320
7372
|
paragraph: { hanging: { v } }
|
|
7321
7373
|
})), "hangingSet")];
|
|
7322
7374
|
}, "useFirstParagraphIndentHanging"), useFirstParagraphIndentSpaceAbove = /* @__PURE__ */ __name((paragraph) => {
|
|
7323
7375
|
const commandService = useDependency(ICommandService), [spaceAbove, _spaceAboveSet] = useState(() => {
|
|
7324
|
-
var
|
|
7376
|
+
var _a29;
|
|
7325
7377
|
const firstParagraph = paragraph[0];
|
|
7326
|
-
return firstParagraph ? getNumberUnitValue((
|
|
7378
|
+
return firstParagraph ? getNumberUnitValue((_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.spaceAbove, 0) : 0;
|
|
7327
7379
|
});
|
|
7328
7380
|
return [spaceAbove, /* @__PURE__ */ __name((v) => (_spaceAboveSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
|
|
7329
7381
|
paragraph: { spaceAbove: { v } }
|
|
7330
7382
|
})), "spaceAboveSet")];
|
|
7331
7383
|
}, "useFirstParagraphIndentSpaceAbove"), useFirstParagraphSpaceBelow = /* @__PURE__ */ __name((paragraph) => {
|
|
7332
7384
|
const commandService = useDependency(ICommandService), [spaceBelow, _spaceBelowSet] = useState(() => {
|
|
7333
|
-
var
|
|
7385
|
+
var _a29;
|
|
7334
7386
|
const firstParagraph = paragraph[0];
|
|
7335
|
-
return firstParagraph ? getNumberUnitValue((
|
|
7387
|
+
return firstParagraph ? getNumberUnitValue((_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.spaceBelow, 0) : 0;
|
|
7336
7388
|
});
|
|
7337
7389
|
return [spaceBelow, /* @__PURE__ */ __name((v) => (_spaceBelowSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
|
|
7338
7390
|
paragraph: { spaceBelow: { v } }
|
|
7339
7391
|
})), "spaceBelowSet")];
|
|
7340
7392
|
}, "useFirstParagraphSpaceBelow"), useFirstParagraphLineSpacing = /* @__PURE__ */ __name((paragraph) => {
|
|
7341
7393
|
const commandService = useDependency(ICommandService), renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), skeleton = useMemo(() => {
|
|
7342
|
-
var
|
|
7394
|
+
var _a29;
|
|
7343
7395
|
const docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
7344
7396
|
if (docDataModel)
|
|
7345
|
-
return (
|
|
7397
|
+
return (_a29 = renderManagerService.getRenderById(docDataModel == null ? void 0 : docDataModel.getUnitId())) == null ? void 0 : _a29.with(DocSkeletonManagerService).getSkeleton();
|
|
7346
7398
|
}, []), stateChange$ = useMemo(() => new BehaviorSubject({}), []), [lineSpacing, _lineSpacingSet] = useState(() => {
|
|
7347
|
-
var
|
|
7399
|
+
var _a29, _b2;
|
|
7348
7400
|
const firstParagraph = paragraph[0];
|
|
7349
|
-
return firstParagraph && (_b2 = (
|
|
7401
|
+
return firstParagraph && (_b2 = (_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.lineSpacing) != null ? _b2 : 1;
|
|
7350
7402
|
}), lineSpacingCache = useRef(lineSpacing), [spacingRule, _spacingRuleSet] = useState(() => {
|
|
7351
|
-
var
|
|
7403
|
+
var _a29, _b2;
|
|
7352
7404
|
const firstParagraph = paragraph[0];
|
|
7353
|
-
return firstParagraph ? (_b2 = (
|
|
7405
|
+
return firstParagraph ? (_b2 = (_a29 = firstParagraph.paragraphStyle) == null ? void 0 : _a29.spacingRule) != null ? _b2 : SpacingRule.AUTO : SpacingRule.AUTO;
|
|
7354
7406
|
}), lineSpacingSet = /* @__PURE__ */ __name(async (v) => {
|
|
7355
7407
|
_lineSpacingSet(v), stateChange$.next({ lineSpacing: v, spacingRule });
|
|
7356
7408
|
}, "lineSpacingSet"), spacingRuleSet = /* @__PURE__ */ __name(async (v) => {
|
|
@@ -7402,8 +7454,8 @@ const BreakLineCommand = {
|
|
|
7402
7454
|
onChange: /* @__PURE__ */ __name((v) => {
|
|
7403
7455
|
onChange(v != null ? v : 0).finally(() => {
|
|
7404
7456
|
setTimeout(() => {
|
|
7405
|
-
var
|
|
7406
|
-
(
|
|
7457
|
+
var _a29;
|
|
7458
|
+
(_a29 = ref.current) == null || _a29.focus();
|
|
7407
7459
|
}, 30);
|
|
7408
7460
|
});
|
|
7409
7461
|
}, "onChange"),
|
|
@@ -7517,13 +7569,13 @@ function ParagraphSettingIndex() {
|
|
|
7517
7569
|
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), currentLocale = useObservable(localeService.currentLocale$), [key, keySet] = useState(""), rangeRef = useRef([]);
|
|
7518
7570
|
return useEffect(() => {
|
|
7519
7571
|
const dispose = commandService.onCommandExecuted((info) => {
|
|
7520
|
-
var
|
|
7572
|
+
var _a29;
|
|
7521
7573
|
if (SetTextSelectionsOperation.id === info.id) {
|
|
7522
7574
|
const ranges = info.params.ranges;
|
|
7523
7575
|
isRangesEqual(ranges, rangeRef.current) || keySet(generateRandomId(4)), rangeRef.current = ranges;
|
|
7524
7576
|
}
|
|
7525
7577
|
if (RichTextEditingMutation.id === info.id) {
|
|
7526
|
-
const params = info.params, ranges = (
|
|
7578
|
+
const params = info.params, ranges = (_a29 = params.textRanges) != null ? _a29 : [];
|
|
7527
7579
|
params.trigger !== DocParagraphSettingCommand.id && isRangesIntersection(ranges, rangeRef.current) && keySet(generateRandomId(4));
|
|
7528
7580
|
}
|
|
7529
7581
|
});
|
|
@@ -7539,8 +7591,8 @@ var __defProp$m = Object.defineProperty, __getOwnPropDesc$m = Object.getOwnPrope
|
|
|
7539
7591
|
return kind && result && __defProp$m(target, key, result), result;
|
|
7540
7592
|
}, "__decorateClass$m"), __decorateParam$m = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$m");
|
|
7541
7593
|
const paragraphSettingIndexKey = "doc_ui_paragraph-setting-panel";
|
|
7542
|
-
var
|
|
7543
|
-
let DocParagraphSettingController = (
|
|
7594
|
+
var _a6;
|
|
7595
|
+
let DocParagraphSettingController = (_a6 = class extends Disposable {
|
|
7544
7596
|
constructor(_commandService, _componentManager, _sidebarService) {
|
|
7545
7597
|
super();
|
|
7546
7598
|
__publicField(this, "_id");
|
|
@@ -7563,7 +7615,7 @@ let DocParagraphSettingController = (_a5 = class extends Disposable {
|
|
|
7563
7615
|
closePanel() {
|
|
7564
7616
|
this._sidebarService.close(this._id);
|
|
7565
7617
|
}
|
|
7566
|
-
}, __name(
|
|
7618
|
+
}, __name(_a6, "DocParagraphSettingController"), _a6);
|
|
7567
7619
|
DocParagraphSettingController = __decorateClass$m([
|
|
7568
7620
|
__decorateParam$m(0, ICommandService),
|
|
7569
7621
|
__decorateParam$m(1, Inject(ComponentManager)),
|
|
@@ -7594,14 +7646,14 @@ const getDisableWhenSelectionNotInTableObservable = /* @__PURE__ */ __name((acce
|
|
|
7594
7646
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService);
|
|
7595
7647
|
return new Observable((subscriber) => {
|
|
7596
7648
|
const observable = docSelectionManagerService.textSelection$.subscribe(() => {
|
|
7597
|
-
var
|
|
7649
|
+
var _a29;
|
|
7598
7650
|
const rectRanges = docSelectionManagerService.getRectRanges(), activeRange = docSelectionManagerService.getActiveTextRange();
|
|
7599
7651
|
if (rectRanges && rectRanges.length && inSameTable(rectRanges)) {
|
|
7600
7652
|
subscriber.next(!1);
|
|
7601
7653
|
return;
|
|
7602
7654
|
}
|
|
7603
7655
|
if (activeRange && (rectRanges == null || rectRanges.length === 0)) {
|
|
7604
|
-
const { segmentId, startOffset, endOffset } = activeRange, docDataModel = univerInstanceService.getCurrentUniverDocInstance(), tables = (
|
|
7656
|
+
const { segmentId, startOffset, endOffset } = activeRange, docDataModel = univerInstanceService.getCurrentUniverDocInstance(), tables = (_a29 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a29.tables;
|
|
7605
7657
|
if (tables && tables.length && tables.some((table) => {
|
|
7606
7658
|
const { startIndex, endIndex } = table;
|
|
7607
7659
|
return startOffset > startIndex && startOffset < endIndex || endOffset > startIndex && endOffset < endIndex;
|
|
@@ -7767,6 +7819,38 @@ function getInsertTableHiddenObservable(accessor) {
|
|
|
7767
7819
|
});
|
|
7768
7820
|
}
|
|
7769
7821
|
__name(getInsertTableHiddenObservable, "getInsertTableHiddenObservable");
|
|
7822
|
+
function getHeaderFooterDisabledObservable(accessor) {
|
|
7823
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
|
|
7824
|
+
return new Observable((subscriber) => {
|
|
7825
|
+
const subscription0 = commandService.onCommandExecuted((command) => {
|
|
7826
|
+
if (command.id === SwitchDocModeCommand.id) {
|
|
7827
|
+
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
7828
|
+
if (docDataModel == null) {
|
|
7829
|
+
subscriber.next(!0);
|
|
7830
|
+
return;
|
|
7831
|
+
}
|
|
7832
|
+
const documentStyle = docDataModel.getSnapshot().documentStyle;
|
|
7833
|
+
subscriber.next((documentStyle == null ? void 0 : documentStyle.documentFlavor) !== DocumentFlavor.TRADITIONAL);
|
|
7834
|
+
}
|
|
7835
|
+
}), subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
7836
|
+
var _a29;
|
|
7837
|
+
if (unitId == null) {
|
|
7838
|
+
subscriber.next(!0);
|
|
7839
|
+
return;
|
|
7840
|
+
}
|
|
7841
|
+
const docDataModel = univerInstanceService.getUnit(unitId);
|
|
7842
|
+
if (docDataModel == null) {
|
|
7843
|
+
subscriber.next(!0);
|
|
7844
|
+
return;
|
|
7845
|
+
}
|
|
7846
|
+
return subscriber.next(((_a29 = docDataModel.getSnapshot().documentStyle) == null ? void 0 : _a29.documentFlavor) !== DocumentFlavor.TRADITIONAL);
|
|
7847
|
+
});
|
|
7848
|
+
return () => {
|
|
7849
|
+
subscription.unsubscribe(), subscription0.dispose();
|
|
7850
|
+
};
|
|
7851
|
+
});
|
|
7852
|
+
}
|
|
7853
|
+
__name(getHeaderFooterDisabledObservable, "getHeaderFooterDisabledObservable");
|
|
7770
7854
|
function getTableDisabledObservable(accessor) {
|
|
7771
7855
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService);
|
|
7772
7856
|
return new Observable((subscriber) => {
|
|
@@ -7841,7 +7925,7 @@ function BoldMenuItemFactory(accessor) {
|
|
|
7841
7925
|
tooltip: "toolbar.bold",
|
|
7842
7926
|
activated$: new Observable((subscriber) => {
|
|
7843
7927
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
7844
|
-
var
|
|
7928
|
+
var _a29;
|
|
7845
7929
|
const id = c.id;
|
|
7846
7930
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
7847
7931
|
const textRun = getFontStyleAtCursor(accessor);
|
|
@@ -7849,7 +7933,7 @@ function BoldMenuItemFactory(accessor) {
|
|
|
7849
7933
|
subscriber.next(!1);
|
|
7850
7934
|
return;
|
|
7851
7935
|
}
|
|
7852
|
-
const bl = (
|
|
7936
|
+
const bl = (_a29 = textRun.ts) == null ? void 0 : _a29.bl;
|
|
7853
7937
|
subscriber.next(bl === BooleanNumber.TRUE);
|
|
7854
7938
|
}
|
|
7855
7939
|
});
|
|
@@ -7870,7 +7954,7 @@ function ItalicMenuItemFactory(accessor) {
|
|
|
7870
7954
|
tooltip: "toolbar.italic",
|
|
7871
7955
|
activated$: new Observable((subscriber) => {
|
|
7872
7956
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
7873
|
-
var
|
|
7957
|
+
var _a29;
|
|
7874
7958
|
const id = c.id;
|
|
7875
7959
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
7876
7960
|
const textRun = getFontStyleAtCursor(accessor);
|
|
@@ -7878,7 +7962,7 @@ function ItalicMenuItemFactory(accessor) {
|
|
|
7878
7962
|
subscriber.next(!1);
|
|
7879
7963
|
return;
|
|
7880
7964
|
}
|
|
7881
|
-
const it = (
|
|
7965
|
+
const it = (_a29 = textRun.ts) == null ? void 0 : _a29.it;
|
|
7882
7966
|
subscriber.next(it === BooleanNumber.TRUE);
|
|
7883
7967
|
}
|
|
7884
7968
|
});
|
|
@@ -7899,7 +7983,7 @@ function UnderlineMenuItemFactory(accessor) {
|
|
|
7899
7983
|
tooltip: "toolbar.underline",
|
|
7900
7984
|
activated$: new Observable((subscriber) => {
|
|
7901
7985
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
7902
|
-
var
|
|
7986
|
+
var _a29;
|
|
7903
7987
|
const id = c.id;
|
|
7904
7988
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
7905
7989
|
const textRun = getFontStyleAtCursor(accessor);
|
|
@@ -7907,7 +7991,7 @@ function UnderlineMenuItemFactory(accessor) {
|
|
|
7907
7991
|
subscriber.next(!1);
|
|
7908
7992
|
return;
|
|
7909
7993
|
}
|
|
7910
|
-
const ul = (
|
|
7994
|
+
const ul = (_a29 = textRun.ts) == null ? void 0 : _a29.ul;
|
|
7911
7995
|
subscriber.next((ul == null ? void 0 : ul.s) === BooleanNumber.TRUE);
|
|
7912
7996
|
}
|
|
7913
7997
|
});
|
|
@@ -7928,7 +8012,7 @@ function StrikeThroughMenuItemFactory(accessor) {
|
|
|
7928
8012
|
tooltip: "toolbar.strikethrough",
|
|
7929
8013
|
activated$: new Observable((subscriber) => {
|
|
7930
8014
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
7931
|
-
var
|
|
8015
|
+
var _a29;
|
|
7932
8016
|
const id = c.id;
|
|
7933
8017
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
7934
8018
|
const textRun = getFontStyleAtCursor(accessor);
|
|
@@ -7936,7 +8020,7 @@ function StrikeThroughMenuItemFactory(accessor) {
|
|
|
7936
8020
|
subscriber.next(!1);
|
|
7937
8021
|
return;
|
|
7938
8022
|
}
|
|
7939
|
-
const st = (
|
|
8023
|
+
const st = (_a29 = textRun.ts) == null ? void 0 : _a29.st;
|
|
7940
8024
|
subscriber.next((st == null ? void 0 : st.s) === BooleanNumber.TRUE);
|
|
7941
8025
|
}
|
|
7942
8026
|
});
|
|
@@ -7956,7 +8040,7 @@ function SubscriptMenuItemFactory(accessor) {
|
|
|
7956
8040
|
tooltip: "toolbar.subscript",
|
|
7957
8041
|
activated$: new Observable((subscriber) => {
|
|
7958
8042
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
7959
|
-
var
|
|
8043
|
+
var _a29;
|
|
7960
8044
|
const id = c.id;
|
|
7961
8045
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
7962
8046
|
const textRun = getFontStyleAtCursor(accessor);
|
|
@@ -7964,7 +8048,7 @@ function SubscriptMenuItemFactory(accessor) {
|
|
|
7964
8048
|
subscriber.next(!1);
|
|
7965
8049
|
return;
|
|
7966
8050
|
}
|
|
7967
|
-
const va = (
|
|
8051
|
+
const va = (_a29 = textRun.ts) == null ? void 0 : _a29.va;
|
|
7968
8052
|
subscriber.next(va === BaselineOffset.SUBSCRIPT);
|
|
7969
8053
|
}
|
|
7970
8054
|
});
|
|
@@ -7984,7 +8068,7 @@ function SuperscriptMenuItemFactory(accessor) {
|
|
|
7984
8068
|
tooltip: "toolbar.superscript",
|
|
7985
8069
|
activated$: new Observable((subscriber) => {
|
|
7986
8070
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
7987
|
-
var
|
|
8071
|
+
var _a29;
|
|
7988
8072
|
const id = c.id;
|
|
7989
8073
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
7990
8074
|
const textRun = getFontStyleAtCursor(accessor);
|
|
@@ -7992,7 +8076,7 @@ function SuperscriptMenuItemFactory(accessor) {
|
|
|
7992
8076
|
subscriber.next(!1);
|
|
7993
8077
|
return;
|
|
7994
8078
|
}
|
|
7995
|
-
const va = (
|
|
8079
|
+
const va = (_a29 = textRun.ts) == null ? void 0 : _a29.va;
|
|
7996
8080
|
subscriber.next(va === BaselineOffset.SUPERSCRIPT);
|
|
7997
8081
|
}
|
|
7998
8082
|
});
|
|
@@ -8020,7 +8104,7 @@ function FontFamilySelectorMenuItemFactory(accessor) {
|
|
|
8020
8104
|
// disabled$: getCurrentSheetDisabled$(accessor),
|
|
8021
8105
|
value$: new Observable((subscriber) => {
|
|
8022
8106
|
const defaultValue = FONT_FAMILY_LIST[0].value, disposable = commandService.onCommandExecuted((c) => {
|
|
8023
|
-
var
|
|
8107
|
+
var _a29;
|
|
8024
8108
|
const id = c.id;
|
|
8025
8109
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatFontFamilyCommand.id) {
|
|
8026
8110
|
const textRun = getFontStyleAtCursor(accessor);
|
|
@@ -8028,7 +8112,7 @@ function FontFamilySelectorMenuItemFactory(accessor) {
|
|
|
8028
8112
|
subscriber.next(defaultValue);
|
|
8029
8113
|
return;
|
|
8030
8114
|
}
|
|
8031
|
-
const ff = (
|
|
8115
|
+
const ff = (_a29 = textRun.ts) == null ? void 0 : _a29.ff;
|
|
8032
8116
|
subscriber.next(ff != null ? ff : defaultValue);
|
|
8033
8117
|
}
|
|
8034
8118
|
});
|
|
@@ -8057,7 +8141,7 @@ function FontSizeSelectorMenuItemFactory(accessor) {
|
|
|
8057
8141
|
// disabled$,
|
|
8058
8142
|
value$: new Observable((subscriber) => {
|
|
8059
8143
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
8060
|
-
var
|
|
8144
|
+
var _a29;
|
|
8061
8145
|
const id = c.id;
|
|
8062
8146
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatFontSizeCommand.id) {
|
|
8063
8147
|
const textRun = getFontStyleAtCursor(accessor);
|
|
@@ -8065,7 +8149,7 @@ function FontSizeSelectorMenuItemFactory(accessor) {
|
|
|
8065
8149
|
subscriber.next(14);
|
|
8066
8150
|
return;
|
|
8067
8151
|
}
|
|
8068
|
-
const fs = (
|
|
8152
|
+
const fs = (_a29 = textRun.ts) == null ? void 0 : _a29.fs;
|
|
8069
8153
|
subscriber.next(fs != null ? fs : 14);
|
|
8070
8154
|
}
|
|
8071
8155
|
});
|
|
@@ -8112,6 +8196,7 @@ function HeaderFooterMenuItemFactory(accessor) {
|
|
|
8112
8196
|
type: MenuItemType.BUTTON,
|
|
8113
8197
|
icon: "HeaderFooterSingle",
|
|
8114
8198
|
tooltip: "toolbar.headerFooter",
|
|
8199
|
+
disabled$: getHeaderFooterDisabledObservable(accessor),
|
|
8115
8200
|
hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getHeaderFooterMenuHiddenObservable(accessor), (one, two) => one || two)
|
|
8116
8201
|
};
|
|
8117
8202
|
}
|
|
@@ -8148,13 +8233,13 @@ function AlignLeftMenuItemFactory(accessor) {
|
|
|
8148
8233
|
disabled$: disableMenuWhenNoDocRange(accessor),
|
|
8149
8234
|
activated$: new Observable((subscriber) => {
|
|
8150
8235
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
8151
|
-
var
|
|
8236
|
+
var _a29;
|
|
8152
8237
|
const id = c.id;
|
|
8153
8238
|
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
8154
8239
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
8155
8240
|
if (paragraph == null)
|
|
8156
8241
|
return;
|
|
8157
|
-
const alignType = (
|
|
8242
|
+
const alignType = (_a29 = paragraph.paragraphStyle) == null ? void 0 : _a29.horizontalAlign;
|
|
8158
8243
|
subscriber.next(alignType === HorizontalAlign.LEFT);
|
|
8159
8244
|
}
|
|
8160
8245
|
});
|
|
@@ -8173,13 +8258,13 @@ function AlignCenterMenuItemFactory(accessor) {
|
|
|
8173
8258
|
tooltip: "toolbar.alignCenter",
|
|
8174
8259
|
activated$: new Observable((subscriber) => {
|
|
8175
8260
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
8176
|
-
var
|
|
8261
|
+
var _a29;
|
|
8177
8262
|
const id = c.id;
|
|
8178
8263
|
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
8179
8264
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
8180
8265
|
if (paragraph == null)
|
|
8181
8266
|
return;
|
|
8182
|
-
const alignType = (
|
|
8267
|
+
const alignType = (_a29 = paragraph.paragraphStyle) == null ? void 0 : _a29.horizontalAlign;
|
|
8183
8268
|
subscriber.next(alignType === HorizontalAlign.CENTER);
|
|
8184
8269
|
}
|
|
8185
8270
|
});
|
|
@@ -8199,13 +8284,13 @@ function AlignRightMenuItemFactory(accessor) {
|
|
|
8199
8284
|
tooltip: "toolbar.alignRight",
|
|
8200
8285
|
activated$: new Observable((subscriber) => {
|
|
8201
8286
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
8202
|
-
var
|
|
8287
|
+
var _a29;
|
|
8203
8288
|
const id = c.id;
|
|
8204
8289
|
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
8205
8290
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
8206
8291
|
if (paragraph == null)
|
|
8207
8292
|
return;
|
|
8208
|
-
const alignType = (
|
|
8293
|
+
const alignType = (_a29 = paragraph.paragraphStyle) == null ? void 0 : _a29.horizontalAlign;
|
|
8209
8294
|
subscriber.next(alignType === HorizontalAlign.RIGHT);
|
|
8210
8295
|
}
|
|
8211
8296
|
});
|
|
@@ -8225,13 +8310,13 @@ function AlignJustifyMenuItemFactory(accessor) {
|
|
|
8225
8310
|
tooltip: "toolbar.alignJustify",
|
|
8226
8311
|
activated$: new Observable((subscriber) => {
|
|
8227
8312
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
8228
|
-
var
|
|
8313
|
+
var _a29;
|
|
8229
8314
|
const id = c.id;
|
|
8230
8315
|
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
8231
8316
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
8232
8317
|
if (paragraph == null)
|
|
8233
8318
|
return;
|
|
8234
|
-
const alignType = (
|
|
8319
|
+
const alignType = (_a29 = paragraph.paragraphStyle) == null ? void 0 : _a29.horizontalAlign;
|
|
8235
8320
|
subscriber.next(alignType === HorizontalAlign.JUSTIFIED);
|
|
8236
8321
|
}
|
|
8237
8322
|
});
|
|
@@ -8250,14 +8335,14 @@ const listValueFactory$ = /* @__PURE__ */ __name((accessor) => new Observable((s
|
|
|
8250
8335
|
return;
|
|
8251
8336
|
const docDataModel = univerInstanceService.getUniverDocInstance(unitId);
|
|
8252
8337
|
docDataModel != null && (textSubscription = docSelectionManagerService.textSelection$.subscribe(() => {
|
|
8253
|
-
var
|
|
8338
|
+
var _a29, _b2;
|
|
8254
8339
|
const range = docSelectionManagerService.getActiveTextRange();
|
|
8255
8340
|
if (range) {
|
|
8256
|
-
const doc = docDataModel.getSelfOrHeaderFooterModel(range == null ? void 0 : range.segmentId), paragraphs = getParagraphsInRange(range, (_b2 = (
|
|
8341
|
+
const doc = docDataModel.getSelfOrHeaderFooterModel(range == null ? void 0 : range.segmentId), paragraphs = getParagraphsInRange(range, (_b2 = (_a29 = doc.getBody()) == null ? void 0 : _a29.paragraphs) != null ? _b2 : []);
|
|
8257
8342
|
let listType;
|
|
8258
8343
|
if (paragraphs.every((p2) => {
|
|
8259
|
-
var
|
|
8260
|
-
return listType || (listType = (
|
|
8344
|
+
var _a30;
|
|
8345
|
+
return listType || (listType = (_a30 = p2.bullet) == null ? void 0 : _a30.listType), p2.bullet && p2.bullet.listType === listType;
|
|
8261
8346
|
})) {
|
|
8262
8347
|
subscriber.next(listType);
|
|
8263
8348
|
return;
|
|
@@ -8324,6 +8409,28 @@ function CheckListMenuItemFactory(accessor) {
|
|
|
8324
8409
|
};
|
|
8325
8410
|
}
|
|
8326
8411
|
__name(CheckListMenuItemFactory, "CheckListMenuItemFactory");
|
|
8412
|
+
function DocSwitchModeMenuItemFactory(accessor) {
|
|
8413
|
+
const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService);
|
|
8414
|
+
return {
|
|
8415
|
+
id: SwitchDocModeCommand.id,
|
|
8416
|
+
type: MenuItemType.BUTTON,
|
|
8417
|
+
icon: "KeyboardSingle",
|
|
8418
|
+
tooltip: "toolbar.documentFlavor",
|
|
8419
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, void 0, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
|
|
8420
|
+
activated$: new Observable((subscriber) => {
|
|
8421
|
+
var _a29;
|
|
8422
|
+
const subscription = commandService.onCommandExecuted((c) => {
|
|
8423
|
+
var _a30;
|
|
8424
|
+
if (c.id === SwitchDocModeCommand.id) {
|
|
8425
|
+
const instance2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
8426
|
+
subscriber.next(((_a30 = instance2 == null ? void 0 : instance2.getSnapshot()) == null ? void 0 : _a30.documentStyle.documentFlavor) === DocumentFlavor.MODERN);
|
|
8427
|
+
}
|
|
8428
|
+
}), instance = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
8429
|
+
return subscriber.next(((_a29 = instance == null ? void 0 : instance.getSnapshot()) == null ? void 0 : _a29.documentStyle.documentFlavor) === DocumentFlavor.MODERN), () => subscription.dispose();
|
|
8430
|
+
})
|
|
8431
|
+
};
|
|
8432
|
+
}
|
|
8433
|
+
__name(DocSwitchModeMenuItemFactory, "DocSwitchModeMenuItemFactory");
|
|
8327
8434
|
function ResetBackgroundColorMenuItemFactory(accessor) {
|
|
8328
8435
|
return {
|
|
8329
8436
|
id: ResetInlineFormatTextBackgroundColorCommand.id,
|
|
@@ -8363,13 +8470,17 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
8363
8470
|
}
|
|
8364
8471
|
__name(BackgroundColorSelectorMenuItemFactory, "BackgroundColorSelectorMenuItemFactory");
|
|
8365
8472
|
function getFontStyleAtCursor(accessor) {
|
|
8366
|
-
var
|
|
8367
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(DocSelectionManagerService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveTextRange();
|
|
8473
|
+
var _a29, _b2;
|
|
8474
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(DocSelectionManagerService), docMenuStyleService = accessor.get(DocMenuStyleService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveTextRange(), cacheStyle = (_a29 = docMenuStyleService.getStyleCache()) != null ? _a29 : {};
|
|
8368
8475
|
if (docDataModel == null || activeTextRange == null)
|
|
8369
|
-
return
|
|
8370
|
-
|
|
8476
|
+
return {
|
|
8477
|
+
ts: cacheStyle
|
|
8478
|
+
};
|
|
8479
|
+
const { startOffset, segmentId } = activeTextRange, textRuns = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b2.textRuns;
|
|
8371
8480
|
if (textRuns == null)
|
|
8372
|
-
return
|
|
8481
|
+
return {
|
|
8482
|
+
ts: cacheStyle
|
|
8483
|
+
};
|
|
8373
8484
|
let textRun;
|
|
8374
8485
|
for (let i = textRuns.length - 1; i >= 0; i--) {
|
|
8375
8486
|
const curTextRun = textRuns[i];
|
|
@@ -8378,15 +8489,21 @@ function getFontStyleAtCursor(accessor) {
|
|
|
8378
8489
|
break;
|
|
8379
8490
|
}
|
|
8380
8491
|
}
|
|
8381
|
-
return
|
|
8492
|
+
return {
|
|
8493
|
+
...textRun,
|
|
8494
|
+
ts: {
|
|
8495
|
+
...textRun == null ? void 0 : textRun.ts,
|
|
8496
|
+
...cacheStyle
|
|
8497
|
+
}
|
|
8498
|
+
};
|
|
8382
8499
|
}
|
|
8383
8500
|
__name(getFontStyleAtCursor, "getFontStyleAtCursor");
|
|
8384
8501
|
function getParagraphStyleAtCursor(accessor) {
|
|
8385
|
-
var
|
|
8502
|
+
var _a29;
|
|
8386
8503
|
const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(DocSelectionManagerService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveTextRange();
|
|
8387
8504
|
if (docDataModel == null || activeTextRange == null)
|
|
8388
8505
|
return;
|
|
8389
|
-
const { startOffset, segmentId } = activeTextRange, paragraphs = (
|
|
8506
|
+
const { startOffset, segmentId } = activeTextRange, paragraphs = (_a29 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a29.paragraphs;
|
|
8390
8507
|
if (paragraphs == null)
|
|
8391
8508
|
return;
|
|
8392
8509
|
let prevIndex = -1;
|
|
@@ -8486,6 +8603,10 @@ const menuSchema = {
|
|
|
8486
8603
|
[OpenHeaderFooterPanelCommand.id]: {
|
|
8487
8604
|
order: 9,
|
|
8488
8605
|
menuItemFactory: HeaderFooterMenuItemFactory
|
|
8606
|
+
},
|
|
8607
|
+
[SwitchDocModeCommand.id]: {
|
|
8608
|
+
order: 10,
|
|
8609
|
+
menuItemFactory: DocSwitchModeMenuItemFactory
|
|
8489
8610
|
}
|
|
8490
8611
|
},
|
|
8491
8612
|
[ContextMenuPosition.MAIN_AREA]: {
|
|
@@ -8555,8 +8676,8 @@ var __defProp$l = Object.defineProperty, __getOwnPropDesc$l = Object.getOwnPrope
|
|
|
8555
8676
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$l(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8556
8677
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
8557
8678
|
return kind && result && __defProp$l(target, key, result), result;
|
|
8558
|
-
}, "__decorateClass$l"), __decorateParam$l = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$l"),
|
|
8559
|
-
let DocUIController = (
|
|
8679
|
+
}, "__decorateClass$l"), __decorateParam$l = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$l"), _a7;
|
|
8680
|
+
let DocUIController = (_a7 = class extends Disposable {
|
|
8560
8681
|
constructor(_injector, _componentManager, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService) {
|
|
8561
8682
|
super(), this._injector = _injector, this._componentManager = _componentManager, this._commandService = _commandService, this._layoutService = _layoutService, this._menuManagerService = _menuManagerService, this._uiPartsService = _uiPartsService, this._univerInstanceService = _univerInstanceService, this._shortcutService = _shortcutService, this._configService = _configService, this._init();
|
|
8562
8683
|
}
|
|
@@ -8566,9 +8687,9 @@ let DocUIController = (_a6 = class extends Disposable {
|
|
|
8566
8687
|
}
|
|
8567
8688
|
// TODO: @zhangwei, why add workbook to docs-ui?
|
|
8568
8689
|
_initUiParts() {
|
|
8569
|
-
var
|
|
8690
|
+
var _a29, _b2;
|
|
8570
8691
|
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), config = this._configService.getConfig(PLUGIN_CONFIG_KEY);
|
|
8571
|
-
(_b2 = (
|
|
8692
|
+
(_b2 = (_a29 = config == null ? void 0 : config.layout) == null ? void 0 : _a29.docContainerConfig) != null && _b2.footer && !workbook && this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.FOOTER, () => connectInjector(DocFooter, this._injector)));
|
|
8572
8693
|
}
|
|
8573
8694
|
_initMenus() {
|
|
8574
8695
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
@@ -8609,7 +8730,7 @@ let DocUIController = (_a6 = class extends Disposable {
|
|
|
8609
8730
|
})
|
|
8610
8731
|
);
|
|
8611
8732
|
}
|
|
8612
|
-
}, __name(
|
|
8733
|
+
}, __name(_a7, "DocUIController"), _a7);
|
|
8613
8734
|
DocUIController = __decorateClass$l([
|
|
8614
8735
|
__decorateParam$l(0, Inject(Injector)),
|
|
8615
8736
|
__decorateParam$l(1, Inject(ComponentManager)),
|
|
@@ -8627,8 +8748,8 @@ var __defProp$k = Object.defineProperty, __getOwnPropDesc$k = Object.getOwnPrope
|
|
|
8627
8748
|
return kind && result && __defProp$k(target, key, result), result;
|
|
8628
8749
|
}, "__decorateClass$k"), __decorateParam$k = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$k");
|
|
8629
8750
|
const ANCHOR_WIDTH = 1.5;
|
|
8630
|
-
var
|
|
8631
|
-
let DocBackScrollRenderController = (
|
|
8751
|
+
var _a8;
|
|
8752
|
+
let DocBackScrollRenderController = (_a8 = class extends RxDisposable {
|
|
8632
8753
|
constructor(_context, _textSelectionManagerService, _editorService, _docSkeletonManagerService) {
|
|
8633
8754
|
super(), this._context = _context, this._textSelectionManagerService = _textSelectionManagerService, this._editorService = _editorService, this._docSkeletonManagerService = _docSkeletonManagerService, this._init();
|
|
8634
8755
|
}
|
|
@@ -8648,7 +8769,7 @@ let DocBackScrollRenderController = (_a7 = class extends RxDisposable {
|
|
|
8648
8769
|
anchorNodePosition && this.scrollToNode(anchorNodePosition);
|
|
8649
8770
|
}
|
|
8650
8771
|
scrollToNode(startNodePosition) {
|
|
8651
|
-
var
|
|
8772
|
+
var _a29;
|
|
8652
8773
|
const { unitId, scene, mainComponent } = this._context, skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
8653
8774
|
if (mainComponent == null || skeleton == null)
|
|
8654
8775
|
return;
|
|
@@ -8662,7 +8783,7 @@ let DocBackScrollRenderController = (_a7 = class extends RxDisposable {
|
|
|
8662
8783
|
bottom: boundBottom
|
|
8663
8784
|
} = viewportMain.getBounding().viewBound;
|
|
8664
8785
|
let offsetY = 0, offsetX = 0;
|
|
8665
|
-
const delta = editor ? (
|
|
8786
|
+
const delta = editor ? (_a29 = editor.params.backScrollOffset) != null ? _a29 : 0 : 100;
|
|
8666
8787
|
top < boundTop ? offsetY = top - boundTop - delta : top > boundBottom - height && (offsetY = top - boundBottom + height + delta), left < boundLeft ? offsetX = left - boundLeft : left > boundRight - ANCHOR_WIDTH && (offsetX = left - boundRight + ANCHOR_WIDTH);
|
|
8667
8788
|
const config = viewportMain.transViewportScroll2ScrollValue(offsetX, offsetY);
|
|
8668
8789
|
viewportMain.scrollByBarDeltaValue(config);
|
|
@@ -8675,7 +8796,7 @@ let DocBackScrollRenderController = (_a7 = class extends RxDisposable {
|
|
|
8675
8796
|
const { collapsed, startNodePosition } = activeTextRange;
|
|
8676
8797
|
collapsed && this.scrollToNode(startNodePosition);
|
|
8677
8798
|
}
|
|
8678
|
-
}, __name(
|
|
8799
|
+
}, __name(_a8, "DocBackScrollRenderController"), _a8);
|
|
8679
8800
|
DocBackScrollRenderController = __decorateClass$k([
|
|
8680
8801
|
__decorateParam$k(1, Inject(DocSelectionManagerService)),
|
|
8681
8802
|
__decorateParam$k(2, IEditorService),
|
|
@@ -8685,14 +8806,14 @@ var __defProp$j = Object.defineProperty, __getOwnPropDesc$j = Object.getOwnPrope
|
|
|
8685
8806
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8686
8807
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
8687
8808
|
return kind && result && __defProp$j(target, key, result), result;
|
|
8688
|
-
}, "__decorateClass$j"), __decorateParam$j = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$j"),
|
|
8689
|
-
let DocRenderController = (
|
|
8690
|
-
constructor(_context,
|
|
8691
|
-
super(), this._context = _context, this.
|
|
8809
|
+
}, "__decorateClass$j"), __decorateParam$j = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$j"), _a9;
|
|
8810
|
+
let DocRenderController = (_a9 = class extends RxDisposable {
|
|
8811
|
+
constructor(_context, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _editorService, _renderManagerService, _univerInstanceService) {
|
|
8812
|
+
super(), this._context = _context, this._commandService = _commandService, this._docSelectionRenderService = _docSelectionRenderService, this._docSkeletonManagerService = _docSkeletonManagerService, this._editorService = _editorService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._addNewRender(), this._initRenderRefresh(), this._initCommandListener();
|
|
8692
8813
|
}
|
|
8693
8814
|
reRender(unitId) {
|
|
8694
|
-
var
|
|
8695
|
-
const docSkeletonManagerService = (
|
|
8815
|
+
var _a29, _b2;
|
|
8816
|
+
const docSkeletonManagerService = (_a29 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a29.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
8696
8817
|
if (!skeleton || !!skeleton.getViewModel().getDataModel().getSnapshot().disabled)
|
|
8697
8818
|
return;
|
|
8698
8819
|
skeleton.calculate();
|
|
@@ -8709,8 +8830,6 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8709
8830
|
top: 0,
|
|
8710
8831
|
bottom: 0,
|
|
8711
8832
|
right: 0,
|
|
8712
|
-
explicitViewportWidthSet: !1,
|
|
8713
|
-
explicitViewportHeightSet: !1,
|
|
8714
8833
|
isWheelPreventDefaultX: !0
|
|
8715
8834
|
});
|
|
8716
8835
|
scene.attachControl(), scene.onMouseWheel$.subscribeEvent((evt, state) => {
|
|
@@ -8733,8 +8852,8 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8733
8852
|
}
|
|
8734
8853
|
_addComponent() {
|
|
8735
8854
|
const { scene, unit: documentModel, components } = this._context, config = {
|
|
8736
|
-
pageMarginLeft:
|
|
8737
|
-
pageMarginTop:
|
|
8855
|
+
pageMarginLeft: 20,
|
|
8856
|
+
pageMarginTop: 20
|
|
8738
8857
|
}, documents = new Documents(DOCS_VIEW_KEY.MAIN, void 0, config);
|
|
8739
8858
|
documents.zIndex = DOCS_COMPONENT_DEFAULT_Z_INDEX;
|
|
8740
8859
|
const docBackground = new DocBackground(DOCS_VIEW_KEY.BACKGROUND, void 0, config);
|
|
@@ -8761,28 +8880,29 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8761
8880
|
}));
|
|
8762
8881
|
}
|
|
8763
8882
|
_recalculateSizeBySkeleton(skeleton) {
|
|
8764
|
-
var
|
|
8765
|
-
const { mainComponent, scene, unitId, components } = this._context, docsComponent = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND), pages = (
|
|
8883
|
+
var _a29;
|
|
8884
|
+
const { mainComponent, scene, unitId, components } = this._context, docsComponent = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND), pages = (_a29 = skeleton.getSkeletonData()) == null ? void 0 : _a29.pages;
|
|
8766
8885
|
if (pages == null)
|
|
8767
8886
|
return;
|
|
8768
8887
|
let width = 0, height = 0;
|
|
8888
|
+
const documentFlavor = this._context.unit.getSnapshot().documentStyle.documentFlavor;
|
|
8769
8889
|
for (let i = 0, len = pages.length; i < len; i++) {
|
|
8770
|
-
const page = pages[i]
|
|
8771
|
-
|
|
8890
|
+
const page = pages[i];
|
|
8891
|
+
let { pageWidth, pageHeight, marginLeft, marginRight, marginTop, marginBottom } = page;
|
|
8892
|
+
documentFlavor === DocumentFlavor.MODERN && (pageWidth === Number.POSITIVE_INFINITY && (pageWidth = page.width + marginLeft + marginRight), pageHeight === Number.POSITIVE_INFINITY && (pageHeight = page.height + marginTop + marginBottom)), docsComponent.pageLayoutType === PageLayoutType.VERTICAL ? (height += pageHeight, height += docsComponent.pageMarginTop, i === len - 1 && (height += docsComponent.pageMarginTop), width = Math.max(width, pageWidth)) : docsComponent.pageLayoutType === PageLayoutType.HORIZONTAL && (width += pageWidth, i !== len - 1 && (width += docsComponent.pageMarginLeft), height = Math.max(height, pageHeight));
|
|
8772
8893
|
}
|
|
8773
8894
|
docsComponent.resize(width, height), docBackground.resize(width, height);
|
|
8774
8895
|
const editor = this._editorService.getEditor(unitId);
|
|
8775
8896
|
(!this._editorService.isEditor(unitId) || editor != null && editor.params.scrollBar) && scene.resize(width, height);
|
|
8776
8897
|
}
|
|
8777
|
-
}, __name(
|
|
8898
|
+
}, __name(_a9, "DocRenderController"), _a9);
|
|
8778
8899
|
DocRenderController = __decorateClass$j([
|
|
8779
|
-
__decorateParam$j(1,
|
|
8780
|
-
__decorateParam$j(2,
|
|
8781
|
-
__decorateParam$j(3, Inject(
|
|
8782
|
-
__decorateParam$j(4,
|
|
8783
|
-
__decorateParam$j(5,
|
|
8784
|
-
__decorateParam$j(6,
|
|
8785
|
-
__decorateParam$j(7, IUniverInstanceService)
|
|
8900
|
+
__decorateParam$j(1, ICommandService),
|
|
8901
|
+
__decorateParam$j(2, Inject(DocSelectionRenderService)),
|
|
8902
|
+
__decorateParam$j(3, Inject(DocSkeletonManagerService)),
|
|
8903
|
+
__decorateParam$j(4, IEditorService),
|
|
8904
|
+
__decorateParam$j(5, IRenderManagerService),
|
|
8905
|
+
__decorateParam$j(6, IUniverInstanceService)
|
|
8786
8906
|
], DocRenderController);
|
|
8787
8907
|
const _DocIMEInputManagerService = class _DocIMEInputManagerService extends RxDisposable {
|
|
8788
8908
|
constructor(_context) {
|
|
@@ -8840,8 +8960,8 @@ const IMEInputCommand = {
|
|
|
8840
8960
|
type: CommandType.COMMAND,
|
|
8841
8961
|
// eslint-disable-next-line max-lines-per-function
|
|
8842
8962
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
8843
|
-
var
|
|
8844
|
-
const { unitId, newText, oldTextLen, isCompositionEnd, isCompositionStart } = params, commandService = accessor.get(ICommandService),
|
|
8963
|
+
var _a29, _b2;
|
|
8964
|
+
const { unitId, newText, oldTextLen, isCompositionEnd, isCompositionStart } = params, commandService = accessor.get(ICommandService), renderManagerService = accessor.get(IRenderManagerService), univerInstanceService = accessor.get(IUniverInstanceService), docMenuStyleService = accessor.get(DocMenuStyleService), imeInputManagerService = (_a29 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a29.with(DocIMEInputManagerService), docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
8845
8965
|
if (docDataModel == null || imeInputManagerService == null)
|
|
8846
8966
|
return !1;
|
|
8847
8967
|
const previousActiveRange = imeInputManagerService.getActiveRange();
|
|
@@ -8866,9 +8986,9 @@ const IMEInputCommand = {
|
|
|
8866
8986
|
actions: [],
|
|
8867
8987
|
textRanges
|
|
8868
8988
|
}
|
|
8869
|
-
}, textX = new TextX(), jsonX = JSONX.getInstance();
|
|
8989
|
+
}, styleCache = docMenuStyleService.getStyleCache(), curTextRun = getTextRunAtPosition((_b2 = body.textRuns) != null ? _b2 : [], startOffset + oldTextLen, styleCache), textX = new TextX(), jsonX = JSONX.getInstance();
|
|
8870
8990
|
if (!previousActiveRange.collapsed && isCompositionStart) {
|
|
8871
|
-
const { dos, retain
|
|
8991
|
+
const { dos, retain } = BuildTextUtils.selection.getDeleteActions(previousActiveRange, segmentId, 0, body);
|
|
8872
8992
|
textX.push(...dos), doMutation.params.textRanges = [{
|
|
8873
8993
|
startOffset: startOffset + len + retain,
|
|
8874
8994
|
endOffset: startOffset + len + retain,
|
|
@@ -8877,22 +8997,22 @@ const IMEInputCommand = {
|
|
|
8877
8997
|
} else
|
|
8878
8998
|
textX.push({
|
|
8879
8999
|
t: TextXActionType.RETAIN,
|
|
8880
|
-
len: startOffset
|
|
8881
|
-
segmentId
|
|
9000
|
+
len: startOffset
|
|
8882
9001
|
});
|
|
8883
9002
|
oldTextLen > 0 && textX.push({
|
|
8884
9003
|
t: TextXActionType.DELETE,
|
|
8885
|
-
len: oldTextLen
|
|
8886
|
-
line: 0,
|
|
8887
|
-
segmentId
|
|
9004
|
+
len: oldTextLen
|
|
8888
9005
|
}), textX.push({
|
|
8889
9006
|
t: TextXActionType.INSERT,
|
|
8890
9007
|
body: {
|
|
8891
|
-
dataStream: newText
|
|
9008
|
+
dataStream: newText,
|
|
9009
|
+
textRuns: curTextRun ? [{
|
|
9010
|
+
...curTextRun,
|
|
9011
|
+
st: 0,
|
|
9012
|
+
ed: newText.length
|
|
9013
|
+
}] : []
|
|
8892
9014
|
},
|
|
8893
|
-
len: newText.length
|
|
8894
|
-
line: 0,
|
|
8895
|
-
segmentId
|
|
9015
|
+
len: newText.length
|
|
8896
9016
|
});
|
|
8897
9017
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
8898
9018
|
doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation.params.noHistory = !isCompositionEnd, doMutation.params.isCompositionEnd = isCompositionEnd;
|
|
@@ -8903,9 +9023,9 @@ const IMEInputCommand = {
|
|
|
8903
9023
|
type: CommandType.COMMAND,
|
|
8904
9024
|
id: "doc.command.set-zoom-ratio",
|
|
8905
9025
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
8906
|
-
var
|
|
9026
|
+
var _a29, _b2, _c;
|
|
8907
9027
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService);
|
|
8908
|
-
let documentId = (
|
|
9028
|
+
let documentId = (_a29 = univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a29.getUnitId();
|
|
8909
9029
|
if (!documentId) return !1;
|
|
8910
9030
|
let zoomRatio = 1;
|
|
8911
9031
|
if (params && (documentId = (_b2 = params.documentId) != null ? _b2 : documentId, zoomRatio = (_c = params.zoomRatio) != null ? _c : zoomRatio), !univerInstanceService.getUniverDocInstance(documentId)) return !1;
|
|
@@ -8972,8 +9092,8 @@ var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPrope
|
|
|
8972
9092
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8973
9093
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
8974
9094
|
return kind && result && __defProp$i(target, key, result), result;
|
|
8975
|
-
}, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"),
|
|
8976
|
-
let DocContainerUIController = (
|
|
9095
|
+
}, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"), _a10;
|
|
9096
|
+
let DocContainerUIController = (_a10 = class {
|
|
8977
9097
|
constructor(_localeService, _injector, _configService) {
|
|
8978
9098
|
__publicField(this, "_docContainer");
|
|
8979
9099
|
// 获取SheetContainer组件
|
|
@@ -9011,7 +9131,7 @@ let DocContainerUIController = (_a9 = class {
|
|
|
9011
9131
|
getDocContainer() {
|
|
9012
9132
|
return this._docContainer;
|
|
9013
9133
|
}
|
|
9014
|
-
}, __name(
|
|
9134
|
+
}, __name(_a10, "DocContainerUIController"), _a10);
|
|
9015
9135
|
DocContainerUIController = __decorateClass$i([
|
|
9016
9136
|
__decorateParam$i(0, Inject(LocaleService)),
|
|
9017
9137
|
__decorateParam$i(1, Inject(Injector)),
|
|
@@ -9021,14 +9141,14 @@ var __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPrope
|
|
|
9021
9141
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9022
9142
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
9023
9143
|
return kind && result && __defProp$h(target, key, result), result;
|
|
9024
|
-
}, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h"),
|
|
9025
|
-
let AppUIController = (
|
|
9144
|
+
}, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h"), _a11;
|
|
9145
|
+
let AppUIController = (_a11 = class extends RxDisposable {
|
|
9026
9146
|
constructor(_injector) {
|
|
9027
9147
|
super();
|
|
9028
9148
|
__publicField(this, "_docContainerController");
|
|
9029
9149
|
this._injector = _injector, this._docContainerController = this._injector.createInstance(DocContainerUIController);
|
|
9030
9150
|
}
|
|
9031
|
-
}, __name(
|
|
9151
|
+
}, __name(_a11, "AppUIController"), _a11);
|
|
9032
9152
|
AppUIController = __decorateClass$h([
|
|
9033
9153
|
__decorateParam$h(0, Inject(Injector))
|
|
9034
9154
|
], AppUIController);
|
|
@@ -9036,8 +9156,8 @@ var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPrope
|
|
|
9036
9156
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9037
9157
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
9038
9158
|
return kind && result && __defProp$g(target, key, result), result;
|
|
9039
|
-
}, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g"),
|
|
9040
|
-
let DocAutoFormatController = (
|
|
9159
|
+
}, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g"), _a12;
|
|
9160
|
+
let DocAutoFormatController = (_a12 = class extends Disposable {
|
|
9041
9161
|
constructor(_docAutoFormatService) {
|
|
9042
9162
|
super(), this._docAutoFormatService = _docAutoFormatService, this._initListTabAutoFormat(), this._initListSpaceAutoFormat(), this._initDefaultEnterFormat(), this._initExitListAutoFormat();
|
|
9043
9163
|
}
|
|
@@ -9046,12 +9166,12 @@ let DocAutoFormatController = (_a11 = class extends Disposable {
|
|
|
9046
9166
|
this._docAutoFormatService.registerAutoFormat({
|
|
9047
9167
|
id: TabCommand.id,
|
|
9048
9168
|
match: /* @__PURE__ */ __name((context) => {
|
|
9049
|
-
var
|
|
9169
|
+
var _a29;
|
|
9050
9170
|
const { selection, paragraphs, unit } = context;
|
|
9051
9171
|
if (paragraphs.length === 1 && selection.startOffset === paragraphs[0].paragraphStart && paragraphs[0].bullet) {
|
|
9052
|
-
const allParagraphs = (
|
|
9053
|
-
var
|
|
9054
|
-
return ((
|
|
9172
|
+
const allParagraphs = (_a29 = unit.getBody()) == null ? void 0 : _a29.paragraphs, bulletParagraphs = allParagraphs == null ? void 0 : allParagraphs.filter((p2) => {
|
|
9173
|
+
var _a30;
|
|
9174
|
+
return ((_a30 = p2.bullet) == null ? void 0 : _a30.listId) === paragraphs[0].bullet.listId;
|
|
9055
9175
|
});
|
|
9056
9176
|
return (bulletParagraphs == null ? void 0 : bulletParagraphs.findIndex((p2) => p2.startIndex === paragraphs[0].startIndex)) !== 0;
|
|
9057
9177
|
} else if (paragraphs.length > 1 && paragraphs.some((p2) => p2.bullet))
|
|
@@ -9095,16 +9215,16 @@ let DocAutoFormatController = (_a11 = class extends Disposable {
|
|
|
9095
9215
|
this._docAutoFormatService.registerAutoFormat({
|
|
9096
9216
|
id: AfterSpaceCommand.id,
|
|
9097
9217
|
match: /* @__PURE__ */ __name((context) => {
|
|
9098
|
-
var
|
|
9218
|
+
var _a29;
|
|
9099
9219
|
const { selection, paragraphs, unit } = context;
|
|
9100
9220
|
if (!selection.collapsed || paragraphs.length !== 1)
|
|
9101
9221
|
return !1;
|
|
9102
|
-
const text = (
|
|
9222
|
+
const text = (_a29 = unit.getBody()) == null ? void 0 : _a29.dataStream.slice(paragraphs[0].paragraphStart, paragraphs[0].paragraphEnd - 1);
|
|
9103
9223
|
return !!(text && Object.keys(QuickListTypeMap).includes(text));
|
|
9104
9224
|
}, "match"),
|
|
9105
9225
|
getMutations(context) {
|
|
9106
|
-
var
|
|
9107
|
-
const { paragraphs, unit } = context, text = (
|
|
9226
|
+
var _a29;
|
|
9227
|
+
const { paragraphs, unit } = context, text = (_a29 = unit.getBody()) == null ? void 0 : _a29.dataStream.slice(paragraphs[0].paragraphStart, paragraphs[0].paragraphEnd - 1);
|
|
9108
9228
|
if (text && Object.keys(QuickListTypeMap).includes(text)) {
|
|
9109
9229
|
const type = QuickListTypeMap[text];
|
|
9110
9230
|
return [{
|
|
@@ -9159,7 +9279,7 @@ let DocAutoFormatController = (_a11 = class extends Disposable {
|
|
|
9159
9279
|
})
|
|
9160
9280
|
);
|
|
9161
9281
|
}
|
|
9162
|
-
}, __name(
|
|
9282
|
+
}, __name(_a12, "DocAutoFormatController"), _a12);
|
|
9163
9283
|
DocAutoFormatController = __decorateClass$g([
|
|
9164
9284
|
__decorateParam$g(0, Inject(DocAutoFormatService))
|
|
9165
9285
|
], DocAutoFormatController);
|
|
@@ -9201,14 +9321,14 @@ function findLineBeforeAndAfterTable(table) {
|
|
|
9201
9321
|
}
|
|
9202
9322
|
__name(findLineBeforeAndAfterTable, "findLineBeforeAndAfterTable");
|
|
9203
9323
|
function findBellowCell(cell) {
|
|
9204
|
-
var
|
|
9324
|
+
var _a29, _b2;
|
|
9205
9325
|
const row = cell.parent, table = row == null ? void 0 : row.parent, tableId = table == null ? void 0 : table.tableId;
|
|
9206
9326
|
if (row == null || table == null)
|
|
9207
9327
|
return;
|
|
9208
9328
|
const col = row.cells.indexOf(cell), bellowRow = table.rows[table.rows.indexOf(row) + 1];
|
|
9209
9329
|
if (bellowRow == null) {
|
|
9210
9330
|
if (tableId.indexOf("#-#")) {
|
|
9211
|
-
const [id, index] = tableId.split("#-#"), pages = (_b2 = (
|
|
9331
|
+
const [id, index] = tableId.split("#-#"), pages = (_b2 = (_a29 = table.parent) == null ? void 0 : _a29.parent) == null ? void 0 : _b2.pages, nextTableId = `${id}#-#${Number.parseInt(index) + 1}`;
|
|
9212
9332
|
if (pages)
|
|
9213
9333
|
for (const page of pages) {
|
|
9214
9334
|
const { skeTables } = page;
|
|
@@ -9225,14 +9345,14 @@ function findBellowCell(cell) {
|
|
|
9225
9345
|
}
|
|
9226
9346
|
__name(findBellowCell, "findBellowCell");
|
|
9227
9347
|
function findAboveCell(cell) {
|
|
9228
|
-
var
|
|
9348
|
+
var _a29, _b2;
|
|
9229
9349
|
const row = cell.parent, table = row == null ? void 0 : row.parent;
|
|
9230
9350
|
if (row == null || table == null)
|
|
9231
9351
|
return;
|
|
9232
9352
|
const aboveRow = table.rows[table.rows.indexOf(row) - 1], col = row.cells.indexOf(cell);
|
|
9233
9353
|
if (aboveRow == null) {
|
|
9234
9354
|
if (table.tableId.indexOf("#-#")) {
|
|
9235
|
-
const [id, index] = table.tableId.split("#-#"), pages = (_b2 = (
|
|
9355
|
+
const [id, index] = table.tableId.split("#-#"), pages = (_b2 = (_a29 = table.parent) == null ? void 0 : _a29.parent) == null ? void 0 : _b2.pages, nextTableId = `${id}#-#${Number.parseInt(index) - 1}`;
|
|
9236
9356
|
if (pages)
|
|
9237
9357
|
for (const page of pages) {
|
|
9238
9358
|
const { skeTables } = page;
|
|
@@ -9271,16 +9391,16 @@ var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPrope
|
|
|
9271
9391
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9272
9392
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
9273
9393
|
return kind && result && __defProp$f(target, key, result), result;
|
|
9274
|
-
}, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"),
|
|
9275
|
-
let DocMoveCursorController = (
|
|
9394
|
+
}, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), _a13;
|
|
9395
|
+
let DocMoveCursorController = (_a13 = class extends Disposable {
|
|
9276
9396
|
constructor(_univerInstanceService, _renderManagerService, _textSelectionManagerService, _commandService) {
|
|
9277
9397
|
super();
|
|
9278
9398
|
__publicField(this, "_onInputSubscription");
|
|
9279
9399
|
this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, this._commandExecutedListener();
|
|
9280
9400
|
}
|
|
9281
9401
|
dispose() {
|
|
9282
|
-
var
|
|
9283
|
-
super.dispose(), (
|
|
9402
|
+
var _a29;
|
|
9403
|
+
super.dispose(), (_a29 = this._onInputSubscription) == null || _a29.unsubscribe();
|
|
9284
9404
|
}
|
|
9285
9405
|
_commandExecutedListener() {
|
|
9286
9406
|
const updateCommandList = [MoveCursorOperation.id, MoveSelectionOperation.id];
|
|
@@ -9302,11 +9422,11 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9302
9422
|
}
|
|
9303
9423
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
9304
9424
|
_handleShiftMoveSelection(direction) {
|
|
9305
|
-
var
|
|
9425
|
+
var _a29, _b2, _c;
|
|
9306
9426
|
const activeRange = this._textSelectionManagerService.getActiveTextRange(), allRanges = this._textSelectionManagerService.getTextRanges(), docDataModel = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
9307
9427
|
if (docDataModel == null)
|
|
9308
9428
|
return;
|
|
9309
|
-
const skeleton = (
|
|
9429
|
+
const skeleton = (_a29 = this._renderManagerService.getRenderById(docDataModel.getUnitId())) == null ? void 0 : _a29.with(DocSkeletonManagerService).getSkeleton(), docObject = this._getDocObject();
|
|
9310
9430
|
if (activeRange == null || skeleton == null || docObject == null)
|
|
9311
9431
|
return;
|
|
9312
9432
|
const {
|
|
@@ -9375,11 +9495,11 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9375
9495
|
}
|
|
9376
9496
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
9377
9497
|
_handleMoveCursor(direction) {
|
|
9378
|
-
var
|
|
9498
|
+
var _a29, _b2, _c, _d;
|
|
9379
9499
|
const activeRange = this._textSelectionManagerService.getActiveTextRange(), allRanges = this._textSelectionManagerService.getTextRanges(), docDataModel = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
9380
9500
|
if (docDataModel == null)
|
|
9381
9501
|
return !1;
|
|
9382
|
-
const skeleton = (
|
|
9502
|
+
const skeleton = (_a29 = this._renderManagerService.getRenderById(docDataModel.getUnitId())) == null ? void 0 : _a29.with(DocSkeletonManagerService).getSkeleton(), docObject = this._getDocObject();
|
|
9383
9503
|
if (activeRange == null || skeleton == null || docObject == null || allRanges == null)
|
|
9384
9504
|
return;
|
|
9385
9505
|
const { startOffset, endOffset, style, collapsed, segmentId, startNodePosition, endNodePosition, segmentPage } = activeRange, body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
@@ -9490,7 +9610,7 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9490
9610
|
}
|
|
9491
9611
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
9492
9612
|
_getNextOrPrevLine(glyph, direction, skipCellContent = !1) {
|
|
9493
|
-
var
|
|
9613
|
+
var _a29, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
9494
9614
|
const divide = glyph.parent, line = divide == null ? void 0 : divide.parent, column = line == null ? void 0 : line.parent, section = column == null ? void 0 : column.parent, page = section == null ? void 0 : section.parent;
|
|
9495
9615
|
if (divide == null || line == null || column == null || section == null || page == null)
|
|
9496
9616
|
return;
|
|
@@ -9524,7 +9644,7 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9524
9644
|
if (currentColumnIndex === -1)
|
|
9525
9645
|
return;
|
|
9526
9646
|
if (direction === !0)
|
|
9527
|
-
newLine = (
|
|
9647
|
+
newLine = (_a29 = section.columns[currentColumnIndex + 1]) == null ? void 0 : _a29.lines[0];
|
|
9528
9648
|
else {
|
|
9529
9649
|
const prevColumnLines = (_c = (_b2 = section.columns) == null ? void 0 : _b2[currentColumnIndex - 1]) == null ? void 0 : _c.lines;
|
|
9530
9650
|
newLine = prevColumnLines == null ? void 0 : prevColumnLines[prevColumnLines.length - 1];
|
|
@@ -9563,8 +9683,8 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9563
9683
|
}
|
|
9564
9684
|
}
|
|
9565
9685
|
_scrollToFocusNodePosition(unitId, offset) {
|
|
9566
|
-
var
|
|
9567
|
-
const backScrollController = (
|
|
9686
|
+
var _a29;
|
|
9687
|
+
const backScrollController = (_a29 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a29.with(DocBackScrollRenderController);
|
|
9568
9688
|
backScrollController != null && backScrollController.scrollToRange({
|
|
9569
9689
|
startOffset: offset,
|
|
9570
9690
|
endOffset: offset,
|
|
@@ -9574,7 +9694,7 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9574
9694
|
_getDocObject() {
|
|
9575
9695
|
return getDocObject(this._univerInstanceService, this._renderManagerService);
|
|
9576
9696
|
}
|
|
9577
|
-
}, __name(
|
|
9697
|
+
}, __name(_a13, "DocMoveCursorController"), _a13);
|
|
9578
9698
|
DocMoveCursorController = __decorateClass$f([
|
|
9579
9699
|
__decorateParam$f(0, IUniverInstanceService),
|
|
9580
9700
|
__decorateParam$f(1, IRenderManagerService),
|
|
@@ -9582,14 +9702,14 @@ DocMoveCursorController = __decorateClass$f([
|
|
|
9582
9702
|
__decorateParam$f(3, ICommandService)
|
|
9583
9703
|
], DocMoveCursorController);
|
|
9584
9704
|
function findAboveOrBellowCellLine(page, direction) {
|
|
9585
|
-
var
|
|
9705
|
+
var _a29, _b2;
|
|
9586
9706
|
let newLine = null;
|
|
9587
9707
|
if (direction === !0) {
|
|
9588
9708
|
const bellowCell = findBellowCell(page);
|
|
9589
9709
|
if (bellowCell)
|
|
9590
9710
|
newLine = firstLineInCell(bellowCell);
|
|
9591
9711
|
else {
|
|
9592
|
-
const table = (
|
|
9712
|
+
const table = (_a29 = page.parent) == null ? void 0 : _a29.parent, { lineAfterTable } = findLineBeforeAndAfterTable(table);
|
|
9593
9713
|
lineAfterTable && (newLine = lineAfterTable);
|
|
9594
9714
|
}
|
|
9595
9715
|
} else {
|
|
@@ -9658,8 +9778,8 @@ var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPrope
|
|
|
9658
9778
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9659
9779
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
9660
9780
|
return kind && result && __defProp$e(target, key, result), result;
|
|
9661
|
-
}, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"),
|
|
9662
|
-
let DocTableController = (
|
|
9781
|
+
}, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a14;
|
|
9782
|
+
let DocTableController = (_a14 = class extends Disposable {
|
|
9663
9783
|
constructor(_commandService, _componentManager) {
|
|
9664
9784
|
super(), this._commandService = _commandService, this._componentManager = _componentManager, this._initialize();
|
|
9665
9785
|
}
|
|
@@ -9677,7 +9797,7 @@ let DocTableController = (_a13 = class extends Disposable {
|
|
|
9677
9797
|
}
|
|
9678
9798
|
_init() {
|
|
9679
9799
|
}
|
|
9680
|
-
}, __name(
|
|
9800
|
+
}, __name(_a14, "DocTableController"), _a14);
|
|
9681
9801
|
DocTableController = __decorateClass$e([
|
|
9682
9802
|
__decorateParam$e(0, ICommandService),
|
|
9683
9803
|
__decorateParam$e(1, Inject(ComponentManager))
|
|
@@ -9738,8 +9858,8 @@ const calcDocRangePositions$1 = /* @__PURE__ */ __name((range, currentRender) =>
|
|
|
9738
9858
|
bottom: (i.bottom + docsTop * scaleY) * scaleAdjust + top
|
|
9739
9859
|
}));
|
|
9740
9860
|
}, "calcDocRangePositions$1");
|
|
9741
|
-
var
|
|
9742
|
-
let DocCanvasPopManagerService = (
|
|
9861
|
+
var _a15;
|
|
9862
|
+
let DocCanvasPopManagerService = (_a15 = class extends Disposable {
|
|
9743
9863
|
constructor(_globalPopupManagerService, _renderManagerService, _univerInstanceService, _commandService) {
|
|
9744
9864
|
super(), this._globalPopupManagerService = _globalPopupManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService;
|
|
9745
9865
|
}
|
|
@@ -9771,8 +9891,8 @@ let DocCanvasPopManagerService = (_a14 = class extends Disposable {
|
|
|
9771
9891
|
};
|
|
9772
9892
|
}
|
|
9773
9893
|
_createRangePositionObserver(range, currentRender) {
|
|
9774
|
-
var
|
|
9775
|
-
const positions = (
|
|
9894
|
+
var _a29;
|
|
9895
|
+
const positions = (_a29 = calcDocRangePositions$1(range, currentRender)) != null ? _a29 : [], positions$ = new BehaviorSubject(positions), disposable = new DisposableCollection();
|
|
9776
9896
|
disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
|
|
9777
9897
|
if (commandInfo.id === SetDocZoomRatioOperation.id) {
|
|
9778
9898
|
const position = calcDocRangePositions$1(range, currentRender);
|
|
@@ -9848,7 +9968,7 @@ let DocCanvasPopManagerService = (_a14 = class extends Disposable {
|
|
|
9848
9968
|
};
|
|
9849
9969
|
}
|
|
9850
9970
|
// #endregion
|
|
9851
|
-
}, __name(
|
|
9971
|
+
}, __name(_a15, "DocCanvasPopManagerService"), _a15);
|
|
9852
9972
|
DocCanvasPopManagerService = __decorateClass$d([
|
|
9853
9973
|
__decorateParam$d(0, Inject(ICanvasPopupService)),
|
|
9854
9974
|
__decorateParam$d(1, IRenderManagerService),
|
|
@@ -9861,11 +9981,11 @@ var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPrope
|
|
|
9861
9981
|
return kind && result && __defProp$c(target, key, result), result;
|
|
9862
9982
|
}, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c");
|
|
9863
9983
|
const calcDocRangePositions = /* @__PURE__ */ __name((range, documents, skeleton, pageIndex) => {
|
|
9864
|
-
var
|
|
9984
|
+
var _a29, _b2, _c, _d, _e;
|
|
9865
9985
|
const startPosition = skeleton.findNodePositionByCharIndex(range.startOffset, !1, range.segmentId, pageIndex), skeletonData = skeleton.getSkeletonData();
|
|
9866
9986
|
let end = range.endOffset;
|
|
9867
9987
|
if (range.segmentId) {
|
|
9868
|
-
const root = (_e = Array.from((_b2 = (
|
|
9988
|
+
const root = (_e = Array.from((_b2 = (_a29 = skeletonData == null ? void 0 : skeletonData.skeFooters.get(range.segmentId)) == null ? void 0 : _a29.values()) != null ? _b2 : [])[0]) != null ? _e : Array.from((_d = (_c = skeletonData == null ? void 0 : skeletonData.skeHeaders.get(range.segmentId)) == null ? void 0 : _c.values()) != null ? _d : [])[0];
|
|
9869
9989
|
root && (end = Math.min(root.ed, end));
|
|
9870
9990
|
}
|
|
9871
9991
|
const endPosition = skeleton.findNodePositionByCharIndex(end, !1, range.segmentId, pageIndex);
|
|
@@ -9890,8 +10010,8 @@ const calcDocRangePositions = /* @__PURE__ */ __name((range, documents, skeleton
|
|
|
9890
10010
|
right: rect.left + documentOffsetConfig.docsLeft + glyph.width
|
|
9891
10011
|
};
|
|
9892
10012
|
}, "calcDocGlyphPosition");
|
|
9893
|
-
var
|
|
9894
|
-
let DocEventManagerService = (
|
|
10013
|
+
var _a16;
|
|
10014
|
+
let DocEventManagerService = (_a16 = class extends Disposable {
|
|
9895
10015
|
constructor(_context, _docSkeletonManagerService) {
|
|
9896
10016
|
super();
|
|
9897
10017
|
__publicField(this, "_hoverCustomRanges$", new BehaviorSubject([]));
|
|
@@ -9954,7 +10074,7 @@ let DocEventManagerService = (_a15 = class extends Disposable {
|
|
|
9954
10074
|
}));
|
|
9955
10075
|
const onPointerDown$ = fromEventSubject(this._context.mainComponent.onPointerDown$), onPointerUp$ = fromEventSubject(this._context.scene.onPointerUp$);
|
|
9956
10076
|
this.disposeWithMe(onPointerDown$.pipe(
|
|
9957
|
-
|
|
10077
|
+
switchMap((down) => onPointerUp$.pipe(take(1), map$1((up) => ({ down, up })))),
|
|
9958
10078
|
filter$1(({ down, up }) => down.target === up.target && up.timeStamp - down.timeStamp < 300)
|
|
9959
10079
|
// filter(({ down, up }) => down.offsetX === up.offsetX && down.offsetY === up.offsetY)
|
|
9960
10080
|
).subscribe(({ down }) => {
|
|
@@ -9967,8 +10087,8 @@ let DocEventManagerService = (_a15 = class extends Disposable {
|
|
|
9967
10087
|
}));
|
|
9968
10088
|
}
|
|
9969
10089
|
_buildCustomRangeBoundsBySegment(segmentId, segmentPage = -1) {
|
|
9970
|
-
var
|
|
9971
|
-
const customRanges = (_c = (_b2 = (
|
|
10090
|
+
var _a29, _b2, _c;
|
|
10091
|
+
const customRanges = (_c = (_b2 = (_a29 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a29.getBody()) == null ? void 0 : _b2.customRanges) != null ? _c : [], layouts = [];
|
|
9972
10092
|
return customRanges.forEach((range) => {
|
|
9973
10093
|
const textRange = {
|
|
9974
10094
|
startOffset: range.startIndex,
|
|
@@ -9987,12 +10107,12 @@ let DocEventManagerService = (_a15 = class extends Disposable {
|
|
|
9987
10107
|
}), layouts;
|
|
9988
10108
|
}
|
|
9989
10109
|
_buildCustomRangeBounds() {
|
|
9990
|
-
var
|
|
10110
|
+
var _a29;
|
|
9991
10111
|
if (!this._customRangeDirty)
|
|
9992
10112
|
return;
|
|
9993
10113
|
this._customRangeDirty = !1;
|
|
9994
10114
|
const customRangeBounds = [];
|
|
9995
|
-
customRangeBounds.push(...this._buildCustomRangeBoundsBySegment()), (
|
|
10115
|
+
customRangeBounds.push(...this._buildCustomRangeBoundsBySegment()), (_a29 = this._skeleton.getSkeletonData()) == null || _a29.pages.forEach((page, pageIndex) => {
|
|
9996
10116
|
page.headerId && customRangeBounds.push(...this._buildCustomRangeBoundsBySegment(page.headerId, pageIndex)), page.footerId && customRangeBounds.push(...this._buildCustomRangeBoundsBySegment(page.footerId, pageIndex));
|
|
9997
10117
|
}), this._customRangeBounds = customRangeBounds;
|
|
9998
10118
|
}
|
|
@@ -10012,12 +10132,12 @@ let DocEventManagerService = (_a15 = class extends Disposable {
|
|
|
10012
10132
|
);
|
|
10013
10133
|
}
|
|
10014
10134
|
_buildBulletBoundsBySegment(segmentId, segmentPage = -1) {
|
|
10015
|
-
var
|
|
10016
|
-
const body = (
|
|
10135
|
+
var _a29, _b2, _c, _d, _e;
|
|
10136
|
+
const body = (_a29 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a29.getBody(), paragraphs = ((_b2 = body == null ? void 0 : body.paragraphs) != null ? _b2 : []).filter((p2) => p2.bullet && p2.bullet.listType.indexOf("CHECK_LIST") === 0), bounds = [], skeletonData = this._skeleton.getSkeletonData();
|
|
10017
10137
|
if (!skeletonData)
|
|
10018
10138
|
return bounds;
|
|
10019
10139
|
const calc = /* @__PURE__ */ __name((pages) => {
|
|
10020
|
-
var
|
|
10140
|
+
var _a30, _b3, _c2;
|
|
10021
10141
|
for (const page of pages) {
|
|
10022
10142
|
const sections = [...page.sections];
|
|
10023
10143
|
if (page.skeTables) {
|
|
@@ -10030,7 +10150,7 @@ let DocEventManagerService = (_a15 = class extends Disposable {
|
|
|
10030
10150
|
if (line.paragraphStart) {
|
|
10031
10151
|
const paragraph = paragraphs.find((p2) => p2.startIndex === line.paragraphIndex);
|
|
10032
10152
|
if (paragraph) {
|
|
10033
|
-
const targetLine = line, bulletNode = (_c2 = (_b3 = (
|
|
10153
|
+
const targetLine = line, bulletNode = (_c2 = (_b3 = (_a30 = targetLine == null ? void 0 : targetLine.divides) == null ? void 0 : _a30[0]) == null ? void 0 : _b3.glyphGroup) == null ? void 0 : _c2[0];
|
|
10034
10154
|
if (!bulletNode)
|
|
10035
10155
|
continue;
|
|
10036
10156
|
const rect = calcDocGlyphPosition(bulletNode, this._documents, this._skeleton, segmentPage);
|
|
@@ -10054,8 +10174,8 @@ let DocEventManagerService = (_a15 = class extends Disposable {
|
|
|
10054
10174
|
return calc(skeletonData.pages);
|
|
10055
10175
|
}
|
|
10056
10176
|
_buildBulletBounds() {
|
|
10057
|
-
var
|
|
10058
|
-
this._bulletDirty && (this._bulletDirty = !1, this._bulletBounds = [], this._bulletBounds.push(...this._buildBulletBoundsBySegment()), (
|
|
10177
|
+
var _a29;
|
|
10178
|
+
this._bulletDirty && (this._bulletDirty = !1, this._bulletBounds = [], this._bulletBounds.push(...this._buildBulletBoundsBySegment()), (_a29 = this._skeleton.getSkeletonData()) == null || _a29.pages.forEach((page, pageIndex) => {
|
|
10059
10179
|
page.headerId && this._bulletBounds.push(...this._buildBulletBoundsBySegment(page.headerId, pageIndex)), page.footerId && this._bulletBounds.push(...this._buildBulletBoundsBySegment(page.footerId, pageIndex));
|
|
10060
10180
|
}));
|
|
10061
10181
|
}
|
|
@@ -10067,7 +10187,7 @@ let DocEventManagerService = (_a15 = class extends Disposable {
|
|
|
10067
10187
|
return x >= left && x <= right && y >= top && y <= bottom;
|
|
10068
10188
|
});
|
|
10069
10189
|
}
|
|
10070
|
-
}, __name(
|
|
10190
|
+
}, __name(_a16, "DocEventManagerService"), _a16);
|
|
10071
10191
|
DocEventManagerService = __decorateClass$c([
|
|
10072
10192
|
__decorateParam$c(1, Inject(DocSkeletonManagerService))
|
|
10073
10193
|
], DocEventManagerService);
|
|
@@ -10075,8 +10195,8 @@ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPrope
|
|
|
10075
10195
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10076
10196
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10077
10197
|
return kind && result && __defProp$b(target, key, result), result;
|
|
10078
|
-
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"),
|
|
10079
|
-
let DocChecklistRenderController = (
|
|
10198
|
+
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a17;
|
|
10199
|
+
let DocChecklistRenderController = (_a17 = class extends Disposable {
|
|
10080
10200
|
constructor(_context, _docSkeletonManagerService, _commandService, _docEventManagerService, _textSelectionManagerService) {
|
|
10081
10201
|
super(), this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._docEventManagerService = _docEventManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._initPointerDownObserver(), this._initHoverCursor();
|
|
10082
10202
|
}
|
|
@@ -10102,7 +10222,7 @@ let DocChecklistRenderController = (_a16 = class extends Disposable {
|
|
|
10102
10222
|
if (originCoord)
|
|
10103
10223
|
return documentTransform.clone().invert().applyPoint(originCoord);
|
|
10104
10224
|
}
|
|
10105
|
-
}, __name(
|
|
10225
|
+
}, __name(_a17, "DocChecklistRenderController"), _a17);
|
|
10106
10226
|
DocChecklistRenderController = __decorateClass$b([
|
|
10107
10227
|
__decorateParam$b(1, Inject(DocSkeletonManagerService)),
|
|
10108
10228
|
__decorateParam$b(2, ICommandService),
|
|
@@ -10113,8 +10233,8 @@ var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPrope
|
|
|
10113
10233
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10114
10234
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10115
10235
|
return kind && result && __defProp$a(target, key, result), result;
|
|
10116
|
-
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"),
|
|
10117
|
-
let DocClipboardController = (
|
|
10236
|
+
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a18;
|
|
10237
|
+
let DocClipboardController = (_a18 = class extends RxDisposable {
|
|
10118
10238
|
constructor(_context, _commandService, _docClipboardService, _docSelectionRenderService, _contextService, _editorService) {
|
|
10119
10239
|
super(), this._context = _context, this._commandService = _commandService, this._docClipboardService = _docClipboardService, this._docSelectionRenderService = _docSelectionRenderService, this._contextService = _contextService, this._editorService = _editorService, this._init();
|
|
10120
10240
|
}
|
|
@@ -10122,19 +10242,19 @@ let DocClipboardController = (_a17 = class extends RxDisposable {
|
|
|
10122
10242
|
this._initLegacyPasteCommand();
|
|
10123
10243
|
}
|
|
10124
10244
|
_initLegacyPasteCommand() {
|
|
10125
|
-
var
|
|
10126
|
-
(
|
|
10127
|
-
var
|
|
10245
|
+
var _a29;
|
|
10246
|
+
(_a29 = this._docSelectionRenderService) == null || _a29.onPaste$.pipe(takeUntil(this.dispose$)).subscribe((config) => {
|
|
10247
|
+
var _a30, _b2;
|
|
10128
10248
|
if (!whenDocOrEditor(this._contextService))
|
|
10129
10249
|
return;
|
|
10130
10250
|
config.event.preventDefault();
|
|
10131
10251
|
const clipboardEvent = config.event;
|
|
10132
|
-
let htmlContent = (
|
|
10252
|
+
let htmlContent = (_a30 = clipboardEvent.clipboardData) == null ? void 0 : _a30.getData("text/html");
|
|
10133
10253
|
const textContent = (_b2 = clipboardEvent.clipboardData) == null ? void 0 : _b2.getData("text/plain");
|
|
10134
10254
|
this._editorService.getEditor(this._context.unitId) && (htmlContent != null ? htmlContent : "").indexOf("</table>") > -1 && (htmlContent = ""), this._docClipboardService.legacyPaste(htmlContent, textContent);
|
|
10135
10255
|
});
|
|
10136
10256
|
}
|
|
10137
|
-
}, __name(
|
|
10257
|
+
}, __name(_a18, "DocClipboardController"), _a18);
|
|
10138
10258
|
DocClipboardController = __decorateClass$a([
|
|
10139
10259
|
__decorateParam$a(1, ICommandService),
|
|
10140
10260
|
__decorateParam$a(2, IDocClipboardService),
|
|
@@ -10153,14 +10273,14 @@ const SKIP_UNIT_IDS = [
|
|
|
10153
10273
|
DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
|
|
10154
10274
|
DOCS_ZEN_EDITOR_UNIT_ID_KEY
|
|
10155
10275
|
];
|
|
10156
|
-
var
|
|
10157
|
-
let DocContextMenuRenderController = (
|
|
10276
|
+
var _a19;
|
|
10277
|
+
let DocContextMenuRenderController = (_a19 = class extends Disposable {
|
|
10158
10278
|
constructor(_context, _contextMenuService, _commandService) {
|
|
10159
10279
|
super(), this._context = _context, this._contextMenuService = _contextMenuService, this._commandService = _commandService, SKIP_UNIT_IDS.includes(this._context.unitId) || (this._initPointerDown(), this._initEditChange());
|
|
10160
10280
|
}
|
|
10161
10281
|
_initPointerDown() {
|
|
10162
|
-
var
|
|
10163
|
-
const documentsSubscription = ((_b2 = (
|
|
10282
|
+
var _a29, _b2;
|
|
10283
|
+
const documentsSubscription = ((_b2 = (_a29 = this._context) == null ? void 0 : _a29.mainComponent) == null ? void 0 : _b2.onPointerDown$).subscribeEvent((event) => {
|
|
10164
10284
|
event.button === 2 && this._contextMenuService.triggerContextMenu(event, ContextMenuPosition.MAIN_AREA);
|
|
10165
10285
|
});
|
|
10166
10286
|
this.disposeWithMe(documentsSubscription);
|
|
@@ -10172,7 +10292,7 @@ let DocContextMenuRenderController = (_a18 = class extends Disposable {
|
|
|
10172
10292
|
})
|
|
10173
10293
|
);
|
|
10174
10294
|
}
|
|
10175
|
-
}, __name(
|
|
10295
|
+
}, __name(_a19, "DocContextMenuRenderController"), _a19);
|
|
10176
10296
|
DocContextMenuRenderController = __decorateClass$9([
|
|
10177
10297
|
__decorateParam$9(1, IContextMenuService),
|
|
10178
10298
|
__decorateParam$9(2, ICommandService)
|
|
@@ -10181,8 +10301,8 @@ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPrope
|
|
|
10181
10301
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10182
10302
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10183
10303
|
return kind && result && __defProp$8(target, key, result), result;
|
|
10184
|
-
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"),
|
|
10185
|
-
let DocEditorBridgeController = (
|
|
10304
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a20;
|
|
10305
|
+
let DocEditorBridgeController = (_a20 = class extends Disposable {
|
|
10186
10306
|
constructor(_context, _univerInstanceService, _editorService, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _renderManagerService) {
|
|
10187
10307
|
super();
|
|
10188
10308
|
__publicField(this, "_initialEditors", /* @__PURE__ */ new Set());
|
|
@@ -10200,7 +10320,7 @@ let DocEditorBridgeController = (_a19 = class extends Disposable {
|
|
|
10200
10320
|
}
|
|
10201
10321
|
// eslint-disable-next-line complexity
|
|
10202
10322
|
_resize(unitId) {
|
|
10203
|
-
var
|
|
10323
|
+
var _a29, _b2;
|
|
10204
10324
|
if (unitId == null)
|
|
10205
10325
|
return;
|
|
10206
10326
|
const editor = this._editorService.getEditor(unitId);
|
|
@@ -10222,7 +10342,7 @@ let DocEditorBridgeController = (_a19 = class extends Disposable {
|
|
|
10222
10342
|
scene.transformByState({
|
|
10223
10343
|
width: contentWidth,
|
|
10224
10344
|
height: contentHeight
|
|
10225
|
-
}), mainComponent == null || mainComponent.resize(contentWidth, contentHeight), editor.isSingle() ? actualWidth > width ? scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { barSize: 8, enableVertical: !1 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll() : (scrollBar = null, viewportMain == null || viewportMain.scrollToBarPos({ x: 0, y: 0 }), (_b2 = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _b2.dispose()) : actualHeight > height ? scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { enableHorizontal: !1, barSize: 8 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll() : (scrollBar = null, viewportMain == null || viewportMain.scrollToBarPos({ x: 0, y: 0 }), (
|
|
10345
|
+
}), mainComponent == null || mainComponent.resize(contentWidth, contentHeight), editor.isSingle() ? actualWidth > width ? scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { barSize: 8, enableVertical: !1 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll() : (scrollBar = null, viewportMain == null || viewportMain.scrollToBarPos({ x: 0, y: 0 }), (_b2 = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _b2.dispose()) : actualHeight > height ? scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { enableHorizontal: !1, barSize: 8 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll() : (scrollBar = null, viewportMain == null || viewportMain.scrollToBarPos({ x: 0, y: 0 }), (_a29 = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _a29.dispose());
|
|
10226
10346
|
}
|
|
10227
10347
|
_initialSetValue() {
|
|
10228
10348
|
this.disposeWithMe(
|
|
@@ -10250,8 +10370,8 @@ let DocEditorBridgeController = (_a19 = class extends Disposable {
|
|
|
10250
10370
|
_initialFocus() {
|
|
10251
10371
|
this.disposeWithMe(
|
|
10252
10372
|
this._editorService.focus$.subscribe((textRange) => {
|
|
10253
|
-
var
|
|
10254
|
-
((
|
|
10373
|
+
var _a29;
|
|
10374
|
+
((_a29 = this._editorService.getFocusEditor()) == null ? void 0 : _a29.getEditorId()) === this._context.unitId && (this._docSelectionRenderService.removeAllRanges(), this._docSelectionRenderService.addDocRanges([textRange]));
|
|
10255
10375
|
})
|
|
10256
10376
|
);
|
|
10257
10377
|
const focusExcepts = [
|
|
@@ -10308,7 +10428,7 @@ let DocEditorBridgeController = (_a19 = class extends Disposable {
|
|
|
10308
10428
|
})
|
|
10309
10429
|
);
|
|
10310
10430
|
}
|
|
10311
|
-
}, __name(
|
|
10431
|
+
}, __name(_a20, "DocEditorBridgeController"), _a20);
|
|
10312
10432
|
DocEditorBridgeController = __decorateClass$8([
|
|
10313
10433
|
__decorateParam$8(1, IUniverInstanceService),
|
|
10314
10434
|
__decorateParam$8(2, IEditorService),
|
|
@@ -10321,20 +10441,20 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
|
|
|
10321
10441
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10322
10442
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10323
10443
|
return kind && result && __defProp$7(target, key, result), result;
|
|
10324
|
-
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"),
|
|
10325
|
-
let DocIMEInputController = (
|
|
10326
|
-
constructor(_context,
|
|
10444
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a21;
|
|
10445
|
+
let DocIMEInputController = (_a21 = class extends Disposable {
|
|
10446
|
+
constructor(_context, _docSelectionRenderService, _docImeInputManagerService, _docSkeletonManagerService, _commandService) {
|
|
10327
10447
|
super();
|
|
10328
10448
|
__publicField(this, "_previousIMEContent", "");
|
|
10329
10449
|
__publicField(this, "_isCompositionStart", !0);
|
|
10330
10450
|
__publicField(this, "_onStartSubscription");
|
|
10331
10451
|
__publicField(this, "_onUpdateSubscription");
|
|
10332
10452
|
__publicField(this, "_onEndSubscription");
|
|
10333
|
-
this._context = _context, this.
|
|
10453
|
+
this._context = _context, this._docSelectionRenderService = _docSelectionRenderService, this._docImeInputManagerService = _docImeInputManagerService, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._initialize();
|
|
10334
10454
|
}
|
|
10335
10455
|
dispose() {
|
|
10336
|
-
var
|
|
10337
|
-
(
|
|
10456
|
+
var _a29, _b2, _c;
|
|
10457
|
+
(_a29 = this._onStartSubscription) == null || _a29.unsubscribe(), (_b2 = this._onUpdateSubscription) == null || _b2.unsubscribe(), (_c = this._onEndSubscription) == null || _c.unsubscribe();
|
|
10338
10458
|
}
|
|
10339
10459
|
_initialize() {
|
|
10340
10460
|
this._initialOnCompositionstart(), this._initialOnCompositionUpdate(), this._initialOnCompositionend();
|
|
@@ -10359,18 +10479,14 @@ let DocIMEInputController = (_a20 = class extends Disposable {
|
|
|
10359
10479
|
});
|
|
10360
10480
|
}
|
|
10361
10481
|
async _updateContent(config, isUpdate) {
|
|
10362
|
-
var _a28;
|
|
10363
10482
|
if (config == null)
|
|
10364
10483
|
return;
|
|
10365
|
-
const
|
|
10366
|
-
if (!documentModel)
|
|
10367
|
-
return;
|
|
10368
|
-
const skeleton = (_a28 = this._renderManagerSrv.getRenderById(documentModel.getUnitId())) == null ? void 0 : _a28.with(DocSkeletonManagerService).getSkeleton(), { event, activeRange } = config;
|
|
10484
|
+
const unitId = this._context.unitId, skeleton = this._docSkeletonManagerService.getSkeleton(), { event, activeRange } = config;
|
|
10369
10485
|
if (skeleton == null || activeRange == null)
|
|
10370
10486
|
return;
|
|
10371
10487
|
const content = event.data;
|
|
10372
10488
|
content === this._previousIMEContent && isUpdate || (await this._commandService.executeCommand(IMEInputCommand.id, {
|
|
10373
|
-
unitId
|
|
10489
|
+
unitId,
|
|
10374
10490
|
newText: content,
|
|
10375
10491
|
oldTextLen: this._previousIMEContent.length,
|
|
10376
10492
|
isCompositionStart: this._isCompositionStart,
|
|
@@ -10380,44 +10496,51 @@ let DocIMEInputController = (_a20 = class extends Disposable {
|
|
|
10380
10496
|
_resetIME() {
|
|
10381
10497
|
this._previousIMEContent = "", this._isCompositionStart = !0, this._docImeInputManagerService.clearUndoRedoMutationParamsCache(), this._docImeInputManagerService.setActiveRange(null);
|
|
10382
10498
|
}
|
|
10383
|
-
}, __name(
|
|
10499
|
+
}, __name(_a21, "DocIMEInputController"), _a21);
|
|
10384
10500
|
DocIMEInputController = __decorateClass$7([
|
|
10385
|
-
__decorateParam$7(1,
|
|
10386
|
-
__decorateParam$7(2,
|
|
10387
|
-
__decorateParam$7(3, Inject(
|
|
10388
|
-
__decorateParam$7(4,
|
|
10389
|
-
__decorateParam$7(5, ICommandService)
|
|
10501
|
+
__decorateParam$7(1, Inject(DocSelectionRenderService)),
|
|
10502
|
+
__decorateParam$7(2, Inject(DocIMEInputManagerService)),
|
|
10503
|
+
__decorateParam$7(3, Inject(DocSkeletonManagerService)),
|
|
10504
|
+
__decorateParam$7(4, ICommandService)
|
|
10390
10505
|
], DocIMEInputController);
|
|
10391
10506
|
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
10392
10507
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10393
10508
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10394
10509
|
return kind && result && __defProp$6(target, key, result), result;
|
|
10395
|
-
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"),
|
|
10396
|
-
let DocInputController = (
|
|
10397
|
-
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService) {
|
|
10510
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a22;
|
|
10511
|
+
let DocInputController = (_a22 = class extends Disposable {
|
|
10512
|
+
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService, _docMenuStyleService) {
|
|
10398
10513
|
super();
|
|
10399
10514
|
__publicField(this, "_onInputSubscription");
|
|
10400
|
-
this._context = _context, this._docSelectionRenderService = _docSelectionRenderService, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._init();
|
|
10515
|
+
this._context = _context, this._docSelectionRenderService = _docSelectionRenderService, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._docMenuStyleService = _docMenuStyleService, this._init();
|
|
10401
10516
|
}
|
|
10402
10517
|
dispose() {
|
|
10403
|
-
var
|
|
10404
|
-
super.dispose(), (
|
|
10518
|
+
var _a29;
|
|
10519
|
+
super.dispose(), (_a29 = this._onInputSubscription) == null || _a29.unsubscribe();
|
|
10405
10520
|
}
|
|
10406
10521
|
_init() {
|
|
10407
10522
|
this._initialNormalInput();
|
|
10408
10523
|
}
|
|
10409
10524
|
_initialNormalInput() {
|
|
10410
10525
|
this._onInputSubscription = this._docSelectionRenderService.onInput$.subscribe(async (config) => {
|
|
10526
|
+
var _a29;
|
|
10411
10527
|
if (config == null)
|
|
10412
10528
|
return;
|
|
10413
|
-
const unitId = this._context
|
|
10414
|
-
if (e.data == null || skeleton == null ||
|
|
10529
|
+
const { unitId } = this._context, { event, content = "", activeRange } = config, e = event, skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
10530
|
+
if (e.data == null || skeleton == null || activeRange == null)
|
|
10415
10531
|
return;
|
|
10416
|
-
const { segmentId } = activeRange, UNITS = [DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];
|
|
10532
|
+
const { segmentId } = activeRange, UNITS = [DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY], originBody = this._context.unit.getSelfOrHeaderFooterModel(segmentId).getBody(), cacheStyle = this._docMenuStyleService.getStyleCache(), curTextRun = getTextRunAtPosition((_a29 = originBody == null ? void 0 : originBody.textRuns) != null ? _a29 : [], activeRange.endOffset, cacheStyle);
|
|
10417
10533
|
await this._commandService.executeCommand(InsertCommand.id, {
|
|
10418
10534
|
unitId,
|
|
10419
10535
|
body: {
|
|
10420
|
-
dataStream: content
|
|
10536
|
+
dataStream: content,
|
|
10537
|
+
textRuns: curTextRun ? [
|
|
10538
|
+
{
|
|
10539
|
+
...curTextRun,
|
|
10540
|
+
st: 0,
|
|
10541
|
+
ed: content.length
|
|
10542
|
+
}
|
|
10543
|
+
] : []
|
|
10421
10544
|
},
|
|
10422
10545
|
range: activeRange,
|
|
10423
10546
|
segmentId,
|
|
@@ -10425,24 +10548,25 @@ let DocInputController = (_a21 = class extends Disposable {
|
|
|
10425
10548
|
}), content === " " && await this._commandService.executeCommand(AfterSpaceCommand.id);
|
|
10426
10549
|
});
|
|
10427
10550
|
}
|
|
10428
|
-
}, __name(
|
|
10551
|
+
}, __name(_a22, "DocInputController"), _a22);
|
|
10429
10552
|
DocInputController = __decorateClass$6([
|
|
10430
10553
|
__decorateParam$6(1, Inject(DocSelectionRenderService)),
|
|
10431
10554
|
__decorateParam$6(2, Inject(DocSkeletonManagerService)),
|
|
10432
|
-
__decorateParam$6(3, ICommandService)
|
|
10555
|
+
__decorateParam$6(3, ICommandService),
|
|
10556
|
+
__decorateParam$6(4, Inject(DocMenuStyleService))
|
|
10433
10557
|
], DocInputController);
|
|
10434
10558
|
const _DocPageLayoutService = class _DocPageLayoutService extends Disposable {
|
|
10435
10559
|
constructor(_context) {
|
|
10436
10560
|
super(), this._context = _context;
|
|
10437
10561
|
}
|
|
10438
10562
|
calculatePagePosition() {
|
|
10439
|
-
var
|
|
10440
|
-
const docObject = neoGetDocObject(this._context), zoomRatio = (_b2 = (
|
|
10563
|
+
var _a29, _b2;
|
|
10564
|
+
const docObject = neoGetDocObject(this._context), zoomRatio = (_b2 = (_a29 = this._context.unit.getSettings()) == null ? void 0 : _a29.zoomRatio) != null ? _b2 : 1, { document: docsComponent, scene, docBackground } = docObject, parent = scene == null ? void 0 : scene.getParent(), { width: docsWidth, height: docsHeight, pageMarginLeft, pageMarginTop } = docsComponent;
|
|
10441
10565
|
if (parent == null || docsWidth === Number.POSITIVE_INFINITY || docsHeight === Number.POSITIVE_INFINITY)
|
|
10442
10566
|
return;
|
|
10443
10567
|
const { width: engineWidth, height: engineHeight } = parent;
|
|
10444
|
-
let docsLeft = 0, docsTop =
|
|
10445
|
-
engineWidth > (docsWidth + pageMarginLeft * 2) * zoomRatio ? (docsLeft = engineWidth / 2 - docsWidth * zoomRatio / 2, docsLeft /= zoomRatio, sceneWidth = (engineWidth - pageMarginLeft * 2) / zoomRatio, scrollToX = 0) : (docsLeft = pageMarginLeft, sceneWidth = docsWidth + pageMarginLeft * 2, scrollToX = (sceneWidth - engineWidth / zoomRatio) / 2), engineHeight > docsHeight ?
|
|
10568
|
+
let docsLeft = 0, docsTop = pageMarginTop, sceneWidth = 0, sceneHeight = 0, scrollToX = Number.POSITIVE_INFINITY;
|
|
10569
|
+
engineWidth > (docsWidth + pageMarginLeft * 2) * zoomRatio ? (docsLeft = engineWidth / 2 - docsWidth * zoomRatio / 2, docsLeft /= zoomRatio, sceneWidth = (engineWidth - pageMarginLeft * 2) / zoomRatio, scrollToX = 0) : (docsLeft = pageMarginLeft, sceneWidth = docsWidth + pageMarginLeft * 2, scrollToX = (sceneWidth - engineWidth / zoomRatio) / 2), engineHeight > docsHeight ? sceneHeight = (engineHeight - pageMarginTop * 2) / zoomRatio : sceneHeight = docsHeight + pageMarginTop * 2, scene.resize(sceneWidth, sceneHeight), engineWidth <= 1 && (docsLeft = -1e4, docsTop = -1e4), docsComponent.translate(docsLeft, docsTop), docBackground.translate(docsLeft, docsTop);
|
|
10446
10570
|
const viewport = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
10447
10571
|
return scrollToX !== Number.POSITIVE_INFINITY && viewport != null && viewport.scrollToViewportPos({
|
|
10448
10572
|
viewportScrollX: scrollToX
|
|
@@ -10455,8 +10579,8 @@ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPrope
|
|
|
10455
10579
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10456
10580
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10457
10581
|
return kind && result && __defProp$5(target, key, result), result;
|
|
10458
|
-
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"),
|
|
10459
|
-
let DocResizeRenderController = (
|
|
10582
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a23;
|
|
10583
|
+
let DocResizeRenderController = (_a23 = class extends Disposable {
|
|
10460
10584
|
constructor(_context, _docPageLayoutService, _textSelectionManagerService) {
|
|
10461
10585
|
super(), this._context = _context, this._docPageLayoutService = _docPageLayoutService, this._textSelectionManagerService = _textSelectionManagerService;
|
|
10462
10586
|
const unitId = this._context.unitId;
|
|
@@ -10473,7 +10597,7 @@ let DocResizeRenderController = (_a22 = class extends Disposable {
|
|
|
10473
10597
|
})
|
|
10474
10598
|
);
|
|
10475
10599
|
}
|
|
10476
|
-
}, __name(
|
|
10600
|
+
}, __name(_a23, "DocResizeRenderController"), _a23);
|
|
10477
10601
|
DocResizeRenderController = __decorateClass$5([
|
|
10478
10602
|
__decorateParam$5(1, Inject(DocPageLayoutService)),
|
|
10479
10603
|
__decorateParam$5(2, Inject(DocSelectionManagerService))
|
|
@@ -10482,8 +10606,8 @@ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPrope
|
|
|
10482
10606
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10483
10607
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10484
10608
|
return kind && result && __defProp$4(target, key, result), result;
|
|
10485
|
-
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"),
|
|
10486
|
-
let DocSelectionRenderController = (
|
|
10609
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a24;
|
|
10610
|
+
let DocSelectionRenderController = (_a24 = class extends Disposable {
|
|
10487
10611
|
constructor(_context, _commandService, _editorService, _instanceSrv, _docSelectionRenderService, _docSkeletonManagerService, _docSelectionManagerService) {
|
|
10488
10612
|
super();
|
|
10489
10613
|
__publicField(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
@@ -10502,7 +10626,7 @@ let DocSelectionRenderController = (_a23 = class extends Disposable {
|
|
|
10502
10626
|
if (params == null)
|
|
10503
10627
|
return;
|
|
10504
10628
|
const { unitId, docRanges, isEditing, options } = params;
|
|
10505
|
-
unitId === this._context.unitId && (this._docSelectionRenderService.removeAllRanges(),
|
|
10629
|
+
unitId === this._context.unitId && (this._docSelectionRenderService.removeAllRanges(), this._docSelectionRenderService.addDocRanges(docRanges, isEditing, options));
|
|
10506
10630
|
})
|
|
10507
10631
|
);
|
|
10508
10632
|
}
|
|
@@ -10571,9 +10695,9 @@ let DocSelectionRenderController = (_a23 = class extends Disposable {
|
|
|
10571
10695
|
const updateCommandList = [SetDocZoomRatioOperation.id];
|
|
10572
10696
|
this.disposeWithMe(
|
|
10573
10697
|
this._commandService.onCommandExecuted((command) => {
|
|
10574
|
-
var
|
|
10698
|
+
var _a29;
|
|
10575
10699
|
if (updateCommandList.includes(command.id)) {
|
|
10576
|
-
const params = command.params, { unitId: documentId } = params, unitId = (
|
|
10700
|
+
const params = command.params, { unitId: documentId } = params, unitId = (_a29 = this._docSelectionManagerService.__getCurrentSelection()) == null ? void 0 : _a29.unitId;
|
|
10577
10701
|
if (documentId !== unitId)
|
|
10578
10702
|
return;
|
|
10579
10703
|
this._docSelectionManagerService.refreshSelection();
|
|
@@ -10596,7 +10720,7 @@ let DocSelectionRenderController = (_a23 = class extends Disposable {
|
|
|
10596
10720
|
}, !1));
|
|
10597
10721
|
}));
|
|
10598
10722
|
}
|
|
10599
|
-
}, __name(
|
|
10723
|
+
}, __name(_a24, "DocSelectionRenderController"), _a24);
|
|
10600
10724
|
DocSelectionRenderController = __decorateClass$4([
|
|
10601
10725
|
__decorateParam$4(1, ICommandService),
|
|
10602
10726
|
__decorateParam$4(2, IEditorService),
|
|
@@ -10609,8 +10733,8 @@ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPrope
|
|
|
10609
10733
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10610
10734
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10611
10735
|
return kind && result && __defProp$3(target, key, result), result;
|
|
10612
|
-
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"),
|
|
10613
|
-
let DocZoomRenderController = (
|
|
10736
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a25;
|
|
10737
|
+
let DocZoomRenderController = (_a25 = class extends Disposable {
|
|
10614
10738
|
constructor(_context, _contextService, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService) {
|
|
10615
10739
|
super(), this._context = _context, this._contextService = _contextService, this._docSkeletonManagerService = _docSkeletonManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._textSelectionManagerService = _textSelectionManagerService, this._editorService = _editorService, this._docPageLayoutService = _docPageLayoutService, this._initSkeletonListener(), this._initCommandExecutedListener(), this._initRenderRefresher(), setTimeout(() => this.updateViewZoom(1, !0), 20);
|
|
10616
10740
|
}
|
|
@@ -10625,6 +10749,9 @@ let DocZoomRenderController = (_a24 = class extends Disposable {
|
|
|
10625
10749
|
const documentModel = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
10626
10750
|
if (!documentModel)
|
|
10627
10751
|
return;
|
|
10752
|
+
const { documentFlavor } = documentModel.getSnapshot().documentStyle;
|
|
10753
|
+
if (documentFlavor === DocumentFlavor.MODERN)
|
|
10754
|
+
return;
|
|
10628
10755
|
const deltaFactor = Math.abs(e.deltaX);
|
|
10629
10756
|
let ratioDelta = deltaFactor < 40 ? 0.2 : deltaFactor < 80 ? 0.4 : 0.2;
|
|
10630
10757
|
ratioDelta *= e.deltaY > 0 ? -1 : 1, scene.scaleX < 1 && (ratioDelta /= 2);
|
|
@@ -10654,14 +10781,21 @@ let DocZoomRenderController = (_a24 = class extends Disposable {
|
|
|
10654
10781
|
const zoomRatio = this._context.unit.zoomRatio || 1;
|
|
10655
10782
|
this.updateViewZoom(zoomRatio);
|
|
10656
10783
|
}
|
|
10657
|
-
}))
|
|
10784
|
+
})), this.disposeWithMe(
|
|
10785
|
+
this._commandService.beforeCommandExecuted((command) => {
|
|
10786
|
+
command.id === SwitchDocModeCommand.id && this._commandService.executeCommand(SetDocZoomRatioCommand.id, {
|
|
10787
|
+
zoomRatio: 1,
|
|
10788
|
+
unitId: this._context.unitId
|
|
10789
|
+
});
|
|
10790
|
+
})
|
|
10791
|
+
);
|
|
10658
10792
|
}
|
|
10659
10793
|
updateViewZoom(zoomRatio, needRefreshSelection = !0) {
|
|
10660
|
-
var
|
|
10794
|
+
var _a29;
|
|
10661
10795
|
const docObject = neoGetDocObject(this._context);
|
|
10662
|
-
docObject.scene.scale(zoomRatio, zoomRatio), this._docPageLayoutService.calculatePagePosition(), needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && this._textSelectionManagerService.refreshSelection(), (
|
|
10796
|
+
docObject.scene.scale(zoomRatio, zoomRatio), this._editorService.isEditor(this._context.unitId) || this._docPageLayoutService.calculatePagePosition(), needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && this._textSelectionManagerService.refreshSelection(), (_a29 = docObject.scene.getTransformer()) == null || _a29.clearSelectedObjects();
|
|
10663
10797
|
}
|
|
10664
|
-
}, __name(
|
|
10798
|
+
}, __name(_a25, "DocZoomRenderController"), _a25);
|
|
10665
10799
|
DocZoomRenderController = __decorateClass$3([
|
|
10666
10800
|
__decorateParam$3(1, IContextService),
|
|
10667
10801
|
__decorateParam$3(2, Inject(DocSkeletonManagerService)),
|
|
@@ -10677,8 +10811,8 @@ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPrope
|
|
|
10677
10811
|
return kind && result && __defProp$2(target, key, result), result;
|
|
10678
10812
|
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
|
|
10679
10813
|
const DEBOUNCE_DELAY = 300;
|
|
10680
|
-
var
|
|
10681
|
-
let DocStateChangeManagerService = (
|
|
10814
|
+
var _a26;
|
|
10815
|
+
let DocStateChangeManagerService = (_a26 = class extends RxDisposable {
|
|
10682
10816
|
constructor(_undoRedoService, _commandService, _univerInstanceService, _docStateEmitService, _renderManagerService) {
|
|
10683
10817
|
super();
|
|
10684
10818
|
__publicField(this, "_docStateChange$", new BehaviorSubject(null));
|
|
@@ -10691,6 +10825,16 @@ let DocStateChangeManagerService = (_a25 = class extends RxDisposable {
|
|
|
10691
10825
|
__publicField(this, "_changeStateCacheTimer", null);
|
|
10692
10826
|
this._undoRedoService = _undoRedoService, this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._docStateEmitService = _docStateEmitService, this._renderManagerService = _renderManagerService, this._initialize(), this._listenDocStateChange();
|
|
10693
10827
|
}
|
|
10828
|
+
getStateCache(unitId) {
|
|
10829
|
+
var _a29, _b2;
|
|
10830
|
+
return {
|
|
10831
|
+
history: (_a29 = this._historyStateCache.get(unitId)) != null ? _a29 : [],
|
|
10832
|
+
collaboration: (_b2 = this._changeStateCache.get(unitId)) != null ? _b2 : []
|
|
10833
|
+
};
|
|
10834
|
+
}
|
|
10835
|
+
setStateCache(unitId, cache) {
|
|
10836
|
+
this._historyStateCache.set(unitId, cache.history), this._changeStateCache.set(unitId, cache.collaboration);
|
|
10837
|
+
}
|
|
10694
10838
|
_setChangeState(changeState) {
|
|
10695
10839
|
this._cacheChangeState(changeState, "history"), this._cacheChangeState(changeState, "collaboration");
|
|
10696
10840
|
}
|
|
@@ -10709,10 +10853,10 @@ let DocStateChangeManagerService = (_a25 = class extends RxDisposable {
|
|
|
10709
10853
|
}
|
|
10710
10854
|
_listenDocStateChange() {
|
|
10711
10855
|
this._docStateEmitService.docStateChangeParams$.pipe(takeUntil(this.dispose$)).subscribe((changeStateInfo) => {
|
|
10712
|
-
var
|
|
10856
|
+
var _a29;
|
|
10713
10857
|
if (changeStateInfo == null)
|
|
10714
10858
|
return;
|
|
10715
|
-
const { isCompositionEnd, ...changeState } = changeStateInfo, imeInputManagerService = (
|
|
10859
|
+
const { isCompositionEnd, isSync, syncer, ...changeState } = changeStateInfo, imeInputManagerService = (_a29 = this._renderManagerService.getRenderById(isSync ? syncer : changeStateInfo.unitId)) == null ? void 0 : _a29.with(DocIMEInputManagerService);
|
|
10716
10860
|
if (imeInputManagerService != null) {
|
|
10717
10861
|
if (isCompositionEnd) {
|
|
10718
10862
|
const historyParams = imeInputManagerService.fetchComposedUndoRedoMutationParams();
|
|
@@ -10786,7 +10930,7 @@ let DocStateChangeManagerService = (_a25 = class extends RxDisposable {
|
|
|
10786
10930
|
};
|
|
10787
10931
|
cacheStates.length = 0, this._docStateChange$.next(changeState);
|
|
10788
10932
|
}
|
|
10789
|
-
}, __name(
|
|
10933
|
+
}, __name(_a26, "DocStateChangeManagerService"), _a26);
|
|
10790
10934
|
DocStateChangeManagerService = __decorateClass$2([
|
|
10791
10935
|
__decorateParam$2(0, Inject(IUndoRedoService)),
|
|
10792
10936
|
__decorateParam$2(1, ICommandService),
|
|
@@ -10798,8 +10942,10 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
|
|
|
10798
10942
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10799
10943
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10800
10944
|
return kind && result && __defProp$1(target, key, result), result;
|
|
10801
|
-
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1")
|
|
10802
|
-
|
|
10945
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
|
|
10946
|
+
const DOC_MAIN_CANVAS_ID = "univer-doc-main-canvas";
|
|
10947
|
+
var _a27;
|
|
10948
|
+
let DocsRenderService = (_a27 = class extends RxDisposable {
|
|
10803
10949
|
constructor(_instanceSrv, _renderManagerService) {
|
|
10804
10950
|
super(), this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._init();
|
|
10805
10951
|
}
|
|
@@ -10807,8 +10953,11 @@ let DocsRenderService = (_a26 = class extends RxDisposable {
|
|
|
10807
10953
|
this._renderManagerService.createRender$.pipe(takeUntil(this.dispose$)).subscribe((unitId) => this._createRenderWithId(unitId)), this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentModel) => this._createRenderer(documentModel)), this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((doc) => this._createRenderer(doc)), this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((doc) => this._disposeRenderer(doc));
|
|
10808
10954
|
}
|
|
10809
10955
|
_createRenderer(doc) {
|
|
10810
|
-
|
|
10811
|
-
|
|
10956
|
+
var _a29;
|
|
10957
|
+
const unitId = doc.getUnitId(), workbookId = (_a29 = this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a29.getUnitId();
|
|
10958
|
+
this._renderManagerService.created$.subscribe((renderer) => {
|
|
10959
|
+
renderer.unitId === workbookId && (renderer.engine.getCanvas().setId(DOC_MAIN_CANVAS_ID), renderer.engine.getCanvas().getContext().setId(DOC_MAIN_CANVAS_ID));
|
|
10960
|
+
}), this._renderManagerService.has(unitId) || (this._createRenderWithId(unitId), this._renderManagerService.setCurrent(unitId));
|
|
10812
10961
|
}
|
|
10813
10962
|
_createRenderWithId(unitId) {
|
|
10814
10963
|
this._renderManagerService.createRender(unitId);
|
|
@@ -10817,7 +10966,7 @@ let DocsRenderService = (_a26 = class extends RxDisposable {
|
|
|
10817
10966
|
const unitId = doc.getUnitId();
|
|
10818
10967
|
this._renderManagerService.removeRender(unitId);
|
|
10819
10968
|
}
|
|
10820
|
-
}, __name(
|
|
10969
|
+
}, __name(_a27, "DocsRenderService"), _a27);
|
|
10821
10970
|
DocsRenderService = __decorateClass$1([
|
|
10822
10971
|
__decorateParam$1(0, IUniverInstanceService),
|
|
10823
10972
|
__decorateParam$1(1, IRenderManagerService)
|
|
@@ -10899,8 +11048,8 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
|
|
|
10899
11048
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10900
11049
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10901
11050
|
return kind && result && __defProp2(target, key, result), result;
|
|
10902
|
-
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, key + "", value), "__publicField"),
|
|
10903
|
-
let UniverDocsUIPlugin = (
|
|
11051
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, key + "", value), "__publicField"), _a28;
|
|
11052
|
+
let UniverDocsUIPlugin = (_a28 = class extends Plugin {
|
|
10904
11053
|
// static override type = UniverInstanceType.UNIVER_DOC;
|
|
10905
11054
|
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _commandService, _logService, _configService) {
|
|
10906
11055
|
super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._commandService = _commandService, this._logService = _logService, this._configService = _configService;
|
|
@@ -10965,6 +11114,7 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
10965
11114
|
DocTableDeleteRowsCommand,
|
|
10966
11115
|
DocTableDeleteColumnsCommand,
|
|
10967
11116
|
DocTableDeleteTableCommand,
|
|
11117
|
+
CloseHeaderFooterCommand,
|
|
10968
11118
|
DocTableTabCommand,
|
|
10969
11119
|
TabCommand,
|
|
10970
11120
|
AfterSpaceCommand,
|
|
@@ -10975,6 +11125,7 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
10975
11125
|
ToggleCheckListCommand,
|
|
10976
11126
|
QuickListCommand,
|
|
10977
11127
|
IMEInputCommand,
|
|
11128
|
+
SwitchDocModeCommand,
|
|
10978
11129
|
DocParagraphSettingCommand,
|
|
10979
11130
|
InnerPasteCommand,
|
|
10980
11131
|
CutContentCommand,
|
|
@@ -11025,7 +11176,8 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
11025
11176
|
[DocCanvasPopManagerService],
|
|
11026
11177
|
[DocsRenderService],
|
|
11027
11178
|
[DocStateChangeManagerService],
|
|
11028
|
-
[DocAutoFormatService]
|
|
11179
|
+
[DocAutoFormatService],
|
|
11180
|
+
[DocMenuStyleService]
|
|
11029
11181
|
], this._config.override).forEach((d) => injector.add(d));
|
|
11030
11182
|
}
|
|
11031
11183
|
_markDocAsFocused() {
|
|
@@ -11072,7 +11224,7 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
11072
11224
|
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m2);
|
|
11073
11225
|
});
|
|
11074
11226
|
}
|
|
11075
|
-
}, __name(
|
|
11227
|
+
}, __name(_a28, "UniverDocsUIPlugin"), _a28);
|
|
11076
11228
|
__publicField2(UniverDocsUIPlugin, "pluginName", DOC_UI_PLUGIN_NAME);
|
|
11077
11229
|
UniverDocsUIPlugin = __decorateClass([
|
|
11078
11230
|
DependentOn(UniverRenderEnginePlugin),
|