@univerjs/docs-ui 0.4.1 → 0.4.2-nightly.202410301606
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/core-editing.command-DAmOCaTR.mjs +1905 -0
- package/lib/es/facade.js +109 -0
- package/lib/es/index.js +577 -2416
- package/lib/locale/en-US.js +85 -0
- package/lib/locale/fa-IR.js +85 -0
- package/lib/locale/ru-RU.js +85 -0
- package/lib/locale/vi-VN.js +85 -0
- package/lib/locale/zh-CN.js +85 -0
- package/lib/locale/zh-TW.js +85 -0
- 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/facade/f-document.d.ts +34 -0
- package/lib/types/facade/f-univer.d.ts +34 -0
- package/lib/types/facade/index.d.ts +1 -0
- package/lib/types/index.d.ts +2 -4
- 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/editor/editor-manager.service.d.ts +63 -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/facade.js +19 -0
- package/lib/umd/index.js +14 -14
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +23 -21
- package/LICENSE +0 -176
- package/lib/cjs/index.js +0 -37
- package/lib/locale/en-US.json +0 -81
- package/lib/locale/fa-IR.json +0 -81
- package/lib/locale/ru-RU.json +0 -81
- package/lib/locale/vi-VN.json +0 -81
- package/lib/locale/zh-CN.json +0 -81
- package/lib/locale/zh-TW.json +0 -81
- package/lib/types/basics/custom-range-factory.d.ts +0 -25
- package/lib/types/basics/replace.d.ts +0 -20
- /package/lib/types/commands/commands/{delete.command.d.ts → doc-delete.command.d.ts} +0 -0
package/lib/es/index.js
CHANGED
|
@@ -2,14 +2,16 @@ 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,
|
|
5
|
+
import { Inject, Disposable, toDisposable, UniverInstanceType, BuildTextUtils, IUniverInstanceService, TextX, JSONX, TextXActionType, getBodySlice, Tools, UpdateDocsAttributeType, ObjectRelativeFromH, ObjectRelativeFromV, CommandType, ICommandService, IUndoRedoService, DEFAULT_STYLES, createIdentifier, EDITOR_ACTIVATED, FOCUSING_EDITOR_STANDALONE, isInternalEditorID, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, FOCUSING_EDITOR_INPUT_FORMULA, DEFAULT_EMPTY_DOCUMENT_VALUE, VerticalAlign, HorizontalAlign, IContextService, DocumentFlavor, useDependency, LocaleService, debounce, BooleanNumber, PresetListType, sequenceExecuteAsync, FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_COMMON_DRAWINGS, MemoryCursor, BaselineOffset, PRESET_LIST_TYPE, GridType, sortRulesFactory, useObservable, DataStreamTreeTokenType, TableCellHeightRule, TableSizeType, generateRandomId, TableAlignmentType, TableTextWrapType, PositionedObjectLayoutType, LRUMap, ColorKit, skipParseTagNames, CustomRangeType, DataStreamTreeNodeType, ILogService, SliceBodyType, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, normalizeBody, DOC_RANGE_TYPE, SpacingRule, ThemeService, DOCS_ZEN_EDITOR_UNIT_ID_KEY, Injector, connectInjector, IConfigService, RxDisposable, QuickListTypeMap, Direction, RANGE_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
|
-
import {
|
|
7
|
+
import { g as getRichTextEditPath, D as DocSelectionRenderService, a as getCommandSkeleton, b as DeleteDirection, U as UpdateCommand, c as DeleteCommand, I as InsertCommand, d as getAnchorBounding, N as NodePositionConvertToCursor, i as isInSameTableCell, e as getLineBounding } from "../core-editing.command-DAmOCaTR.mjs";
|
|
8
|
+
import { E, h, R, T, m, k, l, j, f } from "../core-editing.command-DAmOCaTR.mjs";
|
|
8
9
|
import * as require$$0 from "react";
|
|
9
10
|
import require$$0__default, { useState, useRef, useEffect, forwardRef, createElement, useMemo, useCallback } from "react";
|
|
10
11
|
import { LexerTreeBuilder, operatorToken, isReferenceStrings, serializeRange, serializeRangeWithSheet, serializeRangeWithSpreadsheet, isReferenceStringWithEffectiveColumn, getRangeWithRefsString } from "@univerjs/engine-formula";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
12
|
+
import { IRenderManagerService, DocumentEditArea, Shape, PageLayoutType, Vector2, Rect, Path, getCharSpaceApply, getNumberUnitValue, hasListGlyph, isIndentByGlyph, isFirstGlyph, getParagraphByGlyph, pixelToPt, ptToPixel, parseDataStreamToTree, Viewport, ScrollBar, Layer, Documents, DocBackground, DocumentSkeletonPageType, lineIterator, getLastLine, pxToNum, CURSOR_TYPE, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
13
|
+
import { Subject, merge, fromEvent, BehaviorSubject, combineLatest, Observable, map as map$1, takeUntil, distinctUntilChanged, filter as filter$1, throttleTime, switchMap, take, animationFrameScheduler } from "rxjs";
|
|
14
|
+
import { KeyCode, useEvent, ILayoutService, 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
15
|
import { filter, bufferTime, map } from "rxjs/operators";
|
|
14
16
|
import { Tooltip, Dialog, Button, Input, Checkbox, InputNumber, Slider, Select, ColorPicker } from "@univerjs/design";
|
|
15
17
|
var __defProp$r = Object.defineProperty, __getOwnPropDesc$r = Object.getOwnPropertyDescriptor, __decorateClass$r = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
@@ -65,7 +67,7 @@ let DocAutoFormatService = (_a = class extends Disposable {
|
|
|
65
67
|
selection,
|
|
66
68
|
isBody: !selection.segmentId,
|
|
67
69
|
paragraphs: getParagraphsInRange$1(selection, (_c = (_b2 = doc.getBody()) == null ? void 0 : _b2.paragraphs) != null ? _c : []),
|
|
68
|
-
customRanges: BuildTextUtils.customRange.
|
|
70
|
+
customRanges: BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_e = (_d = doc.getBody()) == null ? void 0 : _d.customRanges) != null ? _e : []),
|
|
69
71
|
commandId: id,
|
|
70
72
|
commandParams: params
|
|
71
73
|
}, matched = autoFormats.find((i) => i.match(context));
|
|
@@ -123,9 +125,9 @@ const DefaultToolbarConfig = {
|
|
|
123
125
|
var DOCS_VIEW_KEY = /* @__PURE__ */ ((DOCS_VIEW_KEY2) => (DOCS_VIEW_KEY2.MAIN = "__Document_Render_Main__", DOCS_VIEW_KEY2.BACKGROUND = "__Document_Render_Background__", DOCS_VIEW_KEY2))(DOCS_VIEW_KEY || {}), VIEWPORT_KEY = /* @__PURE__ */ ((VIEWPORT_KEY2) => (VIEWPORT_KEY2.VIEW_MAIN = "viewMain", VIEWPORT_KEY2.VIEW_TOP = "viewTop", VIEWPORT_KEY2.VIEW_LEFT = "viewLeft", VIEWPORT_KEY2.VIEW_LEFT_TOP = "viewLeftTop", VIEWPORT_KEY2))(VIEWPORT_KEY || {});
|
|
124
126
|
const DOCS_COMPONENT_BACKGROUND_LAYER_INDEX = 0, DOCS_COMPONENT_MAIN_LAYER_INDEX = 2, DOCS_COMPONENT_HEADER_LAYER_INDEX = 4, DOCS_COMPONENT_DEFAULT_Z_INDEX = 10, NORMAL_TEXT_SELECTION_PLUGIN_NAME = "normalTextSelectionPluginName";
|
|
125
127
|
function neoGetDocObject(renderContext) {
|
|
126
|
-
const { mainComponent, scene, engine, components } = renderContext,
|
|
128
|
+
const { mainComponent, scene, engine, components } = renderContext, document = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND);
|
|
127
129
|
return {
|
|
128
|
-
document
|
|
130
|
+
document,
|
|
129
131
|
docBackground,
|
|
130
132
|
scene,
|
|
131
133
|
engine
|
|
@@ -139,9 +141,9 @@ function getDocObject(univerInstanceService, renderManagerService) {
|
|
|
139
141
|
const unitId = documentModel.getUnitId(), currentRender = renderManagerService.getRenderById(unitId);
|
|
140
142
|
if (currentRender == null)
|
|
141
143
|
return;
|
|
142
|
-
const { mainComponent, scene, engine, components } = currentRender,
|
|
144
|
+
const { mainComponent, scene, engine, components } = currentRender, document = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND);
|
|
143
145
|
return {
|
|
144
|
-
document
|
|
146
|
+
document,
|
|
145
147
|
docBackground,
|
|
146
148
|
scene,
|
|
147
149
|
engine
|
|
@@ -152,9 +154,9 @@ function getDocObjectById(unitId, renderManagerService) {
|
|
|
152
154
|
const currentRender = renderManagerService.getRenderById(unitId);
|
|
153
155
|
if (currentRender == null)
|
|
154
156
|
return;
|
|
155
|
-
const { mainComponent, scene, engine, components } = currentRender,
|
|
157
|
+
const { mainComponent, scene, engine, components } = currentRender, document = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND);
|
|
156
158
|
return {
|
|
157
|
-
document
|
|
159
|
+
document,
|
|
158
160
|
docBackground,
|
|
159
161
|
scene,
|
|
160
162
|
engine
|
|
@@ -175,8 +177,7 @@ function addCustomDecorationFactory(param) {
|
|
|
175
177
|
const range = ranges[i], { startOffset: start, endOffset: end } = range;
|
|
176
178
|
start > 0 && textX.push({
|
|
177
179
|
t: TextXActionType.RETAIN,
|
|
178
|
-
len: start - cursor
|
|
179
|
-
segmentId
|
|
180
|
+
len: start - cursor
|
|
180
181
|
}), textX.push({
|
|
181
182
|
t: TextXActionType.RETAIN,
|
|
182
183
|
body: {
|
|
@@ -188,8 +189,7 @@ function addCustomDecorationFactory(param) {
|
|
|
188
189
|
endIndex: end - start - 1
|
|
189
190
|
}]
|
|
190
191
|
},
|
|
191
|
-
len: end - start
|
|
192
|
-
segmentId
|
|
192
|
+
len: end - start
|
|
193
193
|
}), cursor = end;
|
|
194
194
|
}
|
|
195
195
|
return doMutation.params.actions = jsonX.editOp(textX.serialize()), doMutation;
|
|
@@ -236,12 +236,10 @@ function deleteCustomDecorationFactory(accessor, params) {
|
|
|
236
236
|
const bodySlice = bodySlices[i], oldBody = oldBodySlices[i];
|
|
237
237
|
decoration.startIndex !== cursor && textX.push({
|
|
238
238
|
t: TextXActionType.RETAIN,
|
|
239
|
-
len: decoration.startIndex - cursor
|
|
240
|
-
segmentId
|
|
239
|
+
len: decoration.startIndex - cursor
|
|
241
240
|
}), cursor = decoration.startIndex, textX.push({
|
|
242
241
|
t: TextXActionType.RETAIN,
|
|
243
242
|
len: decoration.endIndex - decoration.startIndex + 1,
|
|
244
|
-
segmentId,
|
|
245
243
|
body: bodySlice,
|
|
246
244
|
oldBody,
|
|
247
245
|
coverType: UpdateDocsAttributeType.REPLACE
|
|
@@ -249,143 +247,25 @@ function deleteCustomDecorationFactory(accessor, params) {
|
|
|
249
247
|
}), doMutation.params.actions = jsonX.editOp(textX.serialize()), doMutation;
|
|
250
248
|
}
|
|
251
249
|
__name(deleteCustomDecorationFactory, "deleteCustomDecorationFactory");
|
|
252
|
-
function getCommandSkeleton(accessor, unitId) {
|
|
253
|
-
var _a28;
|
|
254
|
-
return (_a28 = accessor.get(IRenderManagerService).getRenderById(unitId)) == null ? void 0 : _a28.with(DocSkeletonManagerService);
|
|
255
|
-
}
|
|
256
|
-
__name(getCommandSkeleton, "getCommandSkeleton");
|
|
257
|
-
function getRichTextEditPath(docDataModel, segmentId = "") {
|
|
258
|
-
if (!segmentId)
|
|
259
|
-
return ["body"];
|
|
260
|
-
const { headers, footers } = docDataModel.getSnapshot();
|
|
261
|
-
if (headers == null && footers == null)
|
|
262
|
-
throw new Error("Document data model must have headers or footers when update by segment id");
|
|
263
|
-
if ((headers == null ? void 0 : headers[segmentId]) != null)
|
|
264
|
-
return ["headers", segmentId, "body"];
|
|
265
|
-
if ((footers == null ? void 0 : footers[segmentId]) != null)
|
|
266
|
-
return ["footers", segmentId, "body"];
|
|
267
|
-
throw new Error("Segment id not found in headers or footers");
|
|
268
|
-
}
|
|
269
|
-
__name(getRichTextEditPath, "getRichTextEditPath");
|
|
270
|
-
function addCustomRangeFactory(accessor, param, body) {
|
|
271
|
-
const { unitId, segmentId } = param, documentDataModel = accessor.get(IUniverInstanceService).getUnit(unitId);
|
|
272
|
-
if (!documentDataModel)
|
|
273
|
-
return !1;
|
|
274
|
-
const doMutation = {
|
|
275
|
-
id: RichTextEditingMutation.id,
|
|
276
|
-
params: {
|
|
277
|
-
unitId: param.unitId,
|
|
278
|
-
actions: [],
|
|
279
|
-
textRanges: void 0
|
|
280
|
-
}
|
|
281
|
-
}, jsonX = JSONX.getInstance(), textX = BuildTextUtils.customRange.add({ ...param, body });
|
|
282
|
-
if (!textX)
|
|
283
|
-
return !1;
|
|
284
|
-
const path = getRichTextEditPath(documentDataModel, segmentId);
|
|
285
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation;
|
|
286
|
-
}
|
|
287
|
-
__name(addCustomRangeFactory, "addCustomRangeFactory");
|
|
288
|
-
function addCustomRangeBySelectionFactory(accessor, param) {
|
|
289
|
-
var _a28;
|
|
290
|
-
const { rangeId, rangeType, wholeEntity, properties, unitId, selection: propSelection } = param, docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), selection = propSelection != null ? propSelection : (_a28 = docSelectionManagerService.getTextRanges({ unitId, subUnitId: unitId })) == null ? void 0 : _a28[0], segmentId = selection == null ? void 0 : selection.segmentId;
|
|
291
|
-
if (!selection)
|
|
292
|
-
return !1;
|
|
293
|
-
const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
294
|
-
if (!documentDataModel)
|
|
295
|
-
return !1;
|
|
296
|
-
const body = documentDataModel.getSelfOrHeaderFooterModel(selection.segmentId).getBody();
|
|
297
|
-
if (!body)
|
|
298
|
-
return !1;
|
|
299
|
-
const { startOffset, endOffset } = BuildTextUtils.selection.normalizeSelection(selection), textX = BuildTextUtils.customRange.add({
|
|
300
|
-
range: { startOffset, endOffset, collapsed: startOffset === endOffset },
|
|
301
|
-
rangeId,
|
|
302
|
-
rangeType,
|
|
303
|
-
segmentId,
|
|
304
|
-
wholeEntity,
|
|
305
|
-
properties,
|
|
306
|
-
body
|
|
307
|
-
});
|
|
308
|
-
if (!textX)
|
|
309
|
-
return !1;
|
|
310
|
-
const jsonX = JSONX.getInstance(), doMutation = {
|
|
311
|
-
id: RichTextEditingMutation.id,
|
|
312
|
-
params: {
|
|
313
|
-
unitId,
|
|
314
|
-
actions: [],
|
|
315
|
-
textRanges: void 0
|
|
316
|
-
},
|
|
317
|
-
textX
|
|
318
|
-
}, path = getRichTextEditPath(documentDataModel, segmentId);
|
|
319
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation;
|
|
320
|
-
}
|
|
321
|
-
__name(addCustomRangeBySelectionFactory, "addCustomRangeBySelectionFactory");
|
|
322
|
-
function deleteCustomRangeFactory(accessor, params) {
|
|
323
|
-
var _a28;
|
|
324
|
-
const { unitId, segmentId, insert } = params, univerInstanceService = accessor.get(IUniverInstanceService), selection = (_a28 = accessor.get(DocSelectionManagerService).getTextRanges({ unitId, subUnitId: unitId })) == null ? void 0 : _a28[0], documentDataModel = univerInstanceService.getUnit(unitId);
|
|
325
|
-
if (!documentDataModel)
|
|
326
|
-
return !1;
|
|
327
|
-
const textRange = selection != null && selection.collapsed ? { index: selection.startOffset } : void 0, doMutation = {
|
|
328
|
-
id: RichTextEditingMutation.id,
|
|
329
|
-
params: {
|
|
330
|
-
unitId: params.unitId,
|
|
331
|
-
actions: [],
|
|
332
|
-
textRanges: void 0,
|
|
333
|
-
segmentId
|
|
334
|
-
}
|
|
335
|
-
}, jsonX = JSONX.getInstance(), textX = BuildTextUtils.customRange.delete(accessor, {
|
|
336
|
-
documentDataModel,
|
|
337
|
-
rangeId: params.rangeId,
|
|
338
|
-
insert,
|
|
339
|
-
segmentId,
|
|
340
|
-
textRange
|
|
341
|
-
});
|
|
342
|
-
if (!textX)
|
|
343
|
-
return !1;
|
|
344
|
-
const path = getRichTextEditPath(documentDataModel, segmentId);
|
|
345
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation.params.textRanges = textRange ? [{ startOffset: textRange.index, endOffset: textRange.index, collapsed: !0 }] : void 0, doMutation;
|
|
346
|
-
}
|
|
347
|
-
__name(deleteCustomRangeFactory, "deleteCustomRangeFactory");
|
|
348
250
|
function hasParagraphInTable(paragraph, tables) {
|
|
349
251
|
return tables.some((table) => paragraph.startIndex > table.startIndex && paragraph.startIndex < table.endIndex);
|
|
350
252
|
}
|
|
351
253
|
__name(hasParagraphInTable, "hasParagraphInTable");
|
|
352
|
-
function
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
endOffset: selection.startOffset + insertBody.dataStream.length,
|
|
366
|
-
collapsed: !0,
|
|
367
|
-
segmentId
|
|
368
|
-
}], textX = BuildTextUtils.selection.replace({
|
|
369
|
-
selection,
|
|
370
|
-
body: insertBody,
|
|
371
|
-
doc: docDataModel
|
|
372
|
-
});
|
|
373
|
-
if (!textX)
|
|
374
|
-
return !1;
|
|
375
|
-
const doMutation = {
|
|
376
|
-
id: RichTextEditingMutation.id,
|
|
377
|
-
params: {
|
|
378
|
-
unitId,
|
|
379
|
-
actions: [],
|
|
380
|
-
textRanges,
|
|
381
|
-
debounce: !0,
|
|
382
|
-
segmentId
|
|
383
|
-
},
|
|
384
|
-
textX
|
|
385
|
-
}, jsonX = JSONX.getInstance(), path = getRichTextEditPath(docDataModel, segmentId);
|
|
386
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation;
|
|
254
|
+
function getTextRunAtPosition(textRuns, position, cacheStyle) {
|
|
255
|
+
for (let i = textRuns.length - 1; i >= 0; i--) {
|
|
256
|
+
const textRun = textRuns[i], { st, ed } = textRun;
|
|
257
|
+
if (position > st && position <= ed)
|
|
258
|
+
return {
|
|
259
|
+
...textRun,
|
|
260
|
+
ts: {
|
|
261
|
+
...textRun.ts,
|
|
262
|
+
...cacheStyle
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
return cacheStyle ? { ts: cacheStyle } : null;
|
|
387
267
|
}
|
|
388
|
-
__name(
|
|
268
|
+
__name(getTextRunAtPosition, "getTextRunAtPosition");
|
|
389
269
|
function docDrawingPositionToTransform(position) {
|
|
390
270
|
return {
|
|
391
271
|
left: position.positionH.posOffset,
|
|
@@ -423,16 +303,16 @@ var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
|
423
303
|
* This source code is licensed under the MIT license found in the
|
|
424
304
|
* LICENSE file in the root directory of this source tree.
|
|
425
305
|
*/
|
|
426
|
-
var
|
|
306
|
+
var f2 = require$$0__default, k2 = Symbol.for("react.element"), l2 = Symbol.for("react.fragment"), m2 = Object.prototype.hasOwnProperty, n = f2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
427
307
|
function q(c, a, g) {
|
|
428
|
-
var b, d = {}, e = null,
|
|
429
|
-
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (
|
|
430
|
-
for (b in a)
|
|
308
|
+
var b, d = {}, e = null, h2 = null;
|
|
309
|
+
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h2 = a.ref);
|
|
310
|
+
for (b in a) m2.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
431
311
|
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
432
|
-
return { $$typeof:
|
|
312
|
+
return { $$typeof: k2, type: c, key: e, ref: h2, props: d, _owner: n.current };
|
|
433
313
|
}
|
|
434
314
|
__name(q, "q");
|
|
435
|
-
reactJsxRuntime_production_min.Fragment =
|
|
315
|
+
reactJsxRuntime_production_min.Fragment = l2;
|
|
436
316
|
reactJsxRuntime_production_min.jsx = q;
|
|
437
317
|
reactJsxRuntime_production_min.jsxs = q;
|
|
438
318
|
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
@@ -473,1839 +353,97 @@ const ReplaceSnapshotCommand = {
|
|
|
473
353
|
const doMutation = {
|
|
474
354
|
id: RichTextEditingMutation.id,
|
|
475
355
|
params: {
|
|
476
|
-
unitId,
|
|
477
|
-
actions: [],
|
|
478
|
-
textRanges
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
options && (doMutation.params.options = options);
|
|
482
|
-
const rawActions = [], jsonX = JSONX.getInstance();
|
|
483
|
-
if (!Tools.diffValue(body, prevBody)) {
|
|
484
|
-
const actions = jsonX.replaceOp(["body"], prevBody, body);
|
|
485
|
-
actions != null && rawActions.push(actions);
|
|
486
|
-
}
|
|
487
|
-
if (!Tools.diffValue(tableSource, prevTableSource)) {
|
|
488
|
-
const actions = jsonX.replaceOp(["tableSource"], prevTableSource, tableSource);
|
|
489
|
-
actions != null && rawActions.push(actions);
|
|
490
|
-
}
|
|
491
|
-
if (!Tools.diffValue(footers, prevFooters)) {
|
|
492
|
-
const actions = jsonX.replaceOp(["footers"], prevFooters, footers);
|
|
493
|
-
actions != null && rawActions.push(actions);
|
|
494
|
-
}
|
|
495
|
-
if (!Tools.diffValue(headers, prevHeaders)) {
|
|
496
|
-
const actions = jsonX.replaceOp(["headers"], prevHeaders, headers);
|
|
497
|
-
actions != null && rawActions.push(actions);
|
|
498
|
-
}
|
|
499
|
-
if (!Tools.diffValue(lists, prevLists)) {
|
|
500
|
-
const actions = jsonX.replaceOp(["lists"], prevLists, lists);
|
|
501
|
-
actions != null && rawActions.push(actions);
|
|
502
|
-
}
|
|
503
|
-
if (!Tools.diffValue(drawings, prevDrawings)) {
|
|
504
|
-
const actions = jsonX.replaceOp(["drawings"], prevDrawings, drawings);
|
|
505
|
-
actions != null && rawActions.push(actions);
|
|
506
|
-
}
|
|
507
|
-
if (!Tools.diffValue(drawingsOrder, prevDrawingsOrder)) {
|
|
508
|
-
const actions = jsonX.replaceOp(["drawingsOrder"], prevDrawingsOrder, drawingsOrder);
|
|
509
|
-
actions != null && rawActions.push(actions);
|
|
510
|
-
}
|
|
511
|
-
return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
512
|
-
}, "handler")
|
|
513
|
-
}, ReplaceContentCommand = {
|
|
514
|
-
id: "doc.command-replace-content",
|
|
515
|
-
type: CommandType.COMMAND,
|
|
516
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
517
|
-
const { unitId, body, textRanges, segmentId = "", options } = params, univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), prevBody = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getSnapshot().body;
|
|
518
|
-
if (docDataModel == null || prevBody == null)
|
|
519
|
-
return !1;
|
|
520
|
-
const doMutation = getMutationParams(unitId, segmentId, docDataModel, prevBody, body);
|
|
521
|
-
return doMutation.params.textRanges = textRanges, options && (doMutation.params.options = options), doMutation.params.actions == null && textRanges ? (docSelectionManagerService.replaceDocRanges(textRanges, {
|
|
522
|
-
unitId,
|
|
523
|
-
subUnitId: unitId
|
|
524
|
-
}, !1), !0) : !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
525
|
-
}, "handler")
|
|
526
|
-
}, CoverContentCommand = {
|
|
527
|
-
id: "doc.command-cover-content",
|
|
528
|
-
type: CommandType.COMMAND,
|
|
529
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
530
|
-
const { unitId, body, segmentId = "" } = params, univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), docDatModel = univerInstanceService.getUniverDocInstance(unitId), prevBody = docDatModel == null ? void 0 : docDatModel.getSnapshot().body;
|
|
531
|
-
if (docDatModel == null || prevBody == null)
|
|
532
|
-
return !1;
|
|
533
|
-
const doMutation = getMutationParams(unitId, segmentId, docDatModel, prevBody, body);
|
|
534
|
-
return doMutation.params.noNeedSetTextRange = !0, doMutation.params.noHistory = !0, commandService.syncExecuteCommand(
|
|
535
|
-
doMutation.id,
|
|
536
|
-
doMutation.params
|
|
537
|
-
), undoRedoService.clearUndoRedo(unitId), !0;
|
|
538
|
-
}, "handler")
|
|
539
|
-
};
|
|
540
|
-
function getMutationActions(segmentId, docDatModel, prevBody, body) {
|
|
541
|
-
const textX = new TextX(), jsonX = JSONX.getInstance(), deleteLen = (prevBody == null ? void 0 : prevBody.dataStream.length) - 2;
|
|
542
|
-
deleteLen > 0 && textX.push({
|
|
543
|
-
t: TextXActionType.DELETE,
|
|
544
|
-
len: deleteLen,
|
|
545
|
-
line: 0,
|
|
546
|
-
segmentId
|
|
547
|
-
}), body.dataStream.length > 0 && textX.push({
|
|
548
|
-
t: TextXActionType.INSERT,
|
|
549
|
-
body,
|
|
550
|
-
len: body.dataStream.length,
|
|
551
|
-
line: 0,
|
|
552
|
-
segmentId
|
|
553
|
-
});
|
|
554
|
-
const path = getRichTextEditPath(docDatModel, segmentId);
|
|
555
|
-
return jsonX.editOp(textX.serialize(), path);
|
|
556
|
-
}
|
|
557
|
-
__name(getMutationActions, "getMutationActions");
|
|
558
|
-
function getMutationParams(unitId, segmentId, docDatModel, prevBody, body) {
|
|
559
|
-
const doMutation = {
|
|
560
|
-
id: RichTextEditingMutation.id,
|
|
561
|
-
params: {
|
|
562
|
-
unitId,
|
|
563
|
-
actions: [],
|
|
564
|
-
textRanges: []
|
|
565
|
-
}
|
|
566
|
-
}, actions = getMutationActions(segmentId, docDatModel, prevBody, body);
|
|
567
|
-
return doMutation.params.actions = actions, doMutation;
|
|
568
|
-
}
|
|
569
|
-
__name(getMutationParams, "getMutationParams");
|
|
570
|
-
CommandType.COMMAND;
|
|
571
|
-
var NodePositionType = /* @__PURE__ */ ((NodePositionType2) => (NodePositionType2[NodePositionType2.page = 0] = "page", NodePositionType2[NodePositionType2.section = 1] = "section", NodePositionType2[NodePositionType2.column = 2] = "column", NodePositionType2[NodePositionType2.line = 3] = "line", NodePositionType2[NodePositionType2.divide = 4] = "divide", NodePositionType2[NodePositionType2.glyph = 5] = "glyph", NodePositionType2))(NodePositionType || {});
|
|
572
|
-
const NodePositionMap = {
|
|
573
|
-
page: 0,
|
|
574
|
-
section: 1,
|
|
575
|
-
column: 2,
|
|
576
|
-
line: 3,
|
|
577
|
-
divide: 4,
|
|
578
|
-
glyph: 5
|
|
579
|
-
};
|
|
580
|
-
function compareNodePositionLogic(pos1, pos2) {
|
|
581
|
-
return pos1.page > pos2.page ? !1 : pos1.page < pos2.page ? !0 : pos1.section > pos2.section ? !1 : pos1.section < pos2.section ? !0 : pos1.column > pos2.column ? !1 : pos1.column < pos2.column ? !0 : pos1.line > pos2.line ? !1 : pos1.line < pos2.line ? !0 : pos1.divide > pos2.divide ? !1 : pos1.divide < pos2.divide ? !0 : pos1.glyph > pos2.glyph ? !1 : (pos1.glyph < pos2.glyph, !0);
|
|
582
|
-
}
|
|
583
|
-
__name(compareNodePositionLogic, "compareNodePositionLogic");
|
|
584
|
-
function compareNodePosition(pos1, pos2) {
|
|
585
|
-
return compareNodePositionLogic(pos1, pos2) ? {
|
|
586
|
-
start: pos1,
|
|
587
|
-
end: pos2
|
|
588
|
-
} : {
|
|
589
|
-
start: pos2,
|
|
590
|
-
end: pos1
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
__name(compareNodePosition, "compareNodePosition");
|
|
594
|
-
function getOneTextSelectionRange(rangeList) {
|
|
595
|
-
const rangeCount = rangeList.length;
|
|
596
|
-
if (rangeCount === 0)
|
|
597
|
-
return;
|
|
598
|
-
const firstCursor = rangeList[0], lastCursor = rangeList[rangeCount - 1], collapsed = rangeList.length === 1 && firstCursor.collapsed;
|
|
599
|
-
return {
|
|
600
|
-
startOffset: firstCursor.startOffset,
|
|
601
|
-
endOffset: lastCursor.endOffset,
|
|
602
|
-
collapsed
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
__name(getOneTextSelectionRange, "getOneTextSelectionRange");
|
|
606
|
-
function getOffsetInDivide(glyphGroup, startGlyphIndex, endGlyphIndex, st) {
|
|
607
|
-
let startOffset = st, endOffset = st;
|
|
608
|
-
for (let i = 0; i < glyphGroup.length; i++) {
|
|
609
|
-
const contentLength = glyphGroup[i].count;
|
|
610
|
-
i < startGlyphIndex && (startOffset += contentLength), i < endGlyphIndex && (endOffset += contentLength);
|
|
611
|
-
}
|
|
612
|
-
return {
|
|
613
|
-
startOffset,
|
|
614
|
-
endOffset
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
__name(getOffsetInDivide, "getOffsetInDivide");
|
|
618
|
-
function pushToPoints(position) {
|
|
619
|
-
const { startX, startY, endX, endY } = position, points = [];
|
|
620
|
-
return points.push({
|
|
621
|
-
x: startX,
|
|
622
|
-
y: startY
|
|
623
|
-
}), points.push({
|
|
624
|
-
x: endX,
|
|
625
|
-
y: startY
|
|
626
|
-
}), points.push({
|
|
627
|
-
x: endX,
|
|
628
|
-
y: endY
|
|
629
|
-
}), points.push({
|
|
630
|
-
x: startX,
|
|
631
|
-
y: endY
|
|
632
|
-
}), points.push({
|
|
633
|
-
x: startX,
|
|
634
|
-
y: startY
|
|
635
|
-
}), points;
|
|
636
|
-
}
|
|
637
|
-
__name(pushToPoints, "pushToPoints");
|
|
638
|
-
const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
|
|
639
|
-
constructor(_documentOffsetConfig, _docSkeleton) {
|
|
640
|
-
__publicField(this, "_liquid", new Liquid());
|
|
641
|
-
__publicField(this, "_currentStartState", {
|
|
642
|
-
page: 0,
|
|
643
|
-
section: 0,
|
|
644
|
-
column: 0,
|
|
645
|
-
line: 0,
|
|
646
|
-
divide: 0,
|
|
647
|
-
glyph: 0
|
|
648
|
-
/* NORMAL */
|
|
649
|
-
});
|
|
650
|
-
__publicField(this, "_currentEndState", {
|
|
651
|
-
page: 0,
|
|
652
|
-
section: 0,
|
|
653
|
-
column: 0,
|
|
654
|
-
line: 0,
|
|
655
|
-
divide: 0,
|
|
656
|
-
glyph: 0
|
|
657
|
-
/* NORMAL */
|
|
658
|
-
});
|
|
659
|
-
this._documentOffsetConfig = _documentOffsetConfig, this._docSkeleton = _docSkeleton;
|
|
660
|
-
}
|
|
661
|
-
// eslint-disable-next-line max-lines-per-function
|
|
662
|
-
getRangePointData(startOrigin, endOrigin) {
|
|
663
|
-
const borderBoxPointGroup = [], contentBoxPointGroup = [], cursorList = [];
|
|
664
|
-
if (startOrigin == null || endOrigin == null)
|
|
665
|
-
return {
|
|
666
|
-
borderBoxPointGroup,
|
|
667
|
-
contentBoxPointGroup,
|
|
668
|
-
cursorList
|
|
669
|
-
};
|
|
670
|
-
if (!this._isValidPosition(startOrigin, endOrigin))
|
|
671
|
-
throw new Error(
|
|
672
|
-
`
|
|
673
|
-
Invalid positions in NodePositionConvertToCursor,
|
|
674
|
-
they are not in the same segment page when in header or footer.`
|
|
675
|
-
);
|
|
676
|
-
const { start, end } = compareNodePosition(startOrigin, endOrigin);
|
|
677
|
-
return this._selectionIterator(start, end, (start_sp, end_sp, isFirst, isLast, divide, line) => {
|
|
678
|
-
const { lineHeight, asc, paddingTop, marginTop, marginBottom } = line, { glyphGroup, st } = divide;
|
|
679
|
-
if (glyphGroup.length === 0)
|
|
680
|
-
return;
|
|
681
|
-
const { x: startX, y: startY } = this._liquid;
|
|
682
|
-
let borderBoxPosition, contentBoxPosition;
|
|
683
|
-
const firstGlyph = glyphGroup[start_sp], lastGlyph = glyphGroup[end_sp], preGlyph = glyphGroup[start_sp - 1], firstGlyphLeft = (firstGlyph == null ? void 0 : firstGlyph.left) || 0, firstGlyphWidth = (firstGlyph == null ? void 0 : firstGlyph.width) || 0, lastGlyphLeft = (lastGlyph == null ? void 0 : lastGlyph.left) || 0, lastGlyphWidth = (lastGlyph == null ? void 0 : lastGlyph.width) || 0, isCurrentList = (firstGlyph == null ? void 0 : firstGlyph.glyphType) === GlyphType.LIST, { startOffset, endOffset } = getOffsetInDivide(glyphGroup, start_sp, end_sp, st), isStartBack = start.glyph === start_sp && isFirst ? start.isBack : !0, isEndBack = end.glyph === end_sp && isLast ? end.isBack : !1, collapsed = start === end, anchorGlyph = isStartBack && preGlyph != null ? preGlyph : firstGlyph;
|
|
684
|
-
if (start_sp === 0 && end_sp === glyphGroup.length - 1)
|
|
685
|
-
borderBoxPosition = {
|
|
686
|
-
startX: startX + firstGlyphLeft + (isCurrentList ? firstGlyphWidth : 0),
|
|
687
|
-
startY,
|
|
688
|
-
endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
|
|
689
|
-
endY: startY + lineHeight - marginTop - marginBottom
|
|
690
|
-
}, contentBoxPosition = {
|
|
691
|
-
startX: startX + firstGlyphLeft + (isCurrentList ? firstGlyphWidth : 0),
|
|
692
|
-
startY: startY + paddingTop + asc - anchorGlyph.bBox.ba,
|
|
693
|
-
endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
|
|
694
|
-
endY: startY + paddingTop + asc + anchorGlyph.bBox.bd
|
|
695
|
-
};
|
|
696
|
-
else {
|
|
697
|
-
const isStartBackFin = isStartBack && !isCurrentList;
|
|
698
|
-
borderBoxPosition = {
|
|
699
|
-
startX: startX + firstGlyphLeft + (isStartBackFin ? 0 : firstGlyphWidth),
|
|
700
|
-
startY,
|
|
701
|
-
endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
|
|
702
|
-
endY: startY + lineHeight - marginTop - marginBottom
|
|
703
|
-
}, contentBoxPosition = {
|
|
704
|
-
startX: startX + firstGlyphLeft + (isStartBackFin ? 0 : firstGlyphWidth),
|
|
705
|
-
startY: startY + paddingTop + asc - anchorGlyph.bBox.ba,
|
|
706
|
-
endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
|
|
707
|
-
endY: startY + paddingTop + asc + anchorGlyph.bBox.bd
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
borderBoxPointGroup.push(pushToPoints(borderBoxPosition)), contentBoxPointGroup.push(pushToPoints(contentBoxPosition)), cursorList.push({
|
|
711
|
-
startOffset: isStartBack ? startOffset : startOffset + firstGlyph.count,
|
|
712
|
-
endOffset: isEndBack ? endOffset : endOffset + lastGlyph.count,
|
|
713
|
-
collapsed
|
|
714
|
-
});
|
|
715
|
-
}), {
|
|
716
|
-
borderBoxPointGroup,
|
|
717
|
-
contentBoxPointGroup,
|
|
718
|
-
cursorList
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
_isValidPosition(startOrigin, endOrigin) {
|
|
722
|
-
const { segmentPage: startPage, pageType: startPageType } = startOrigin, { segmentPage: endPage, pageType: endPageType } = endOrigin;
|
|
723
|
-
return startPageType !== endPageType ? !1 : startPageType === DocumentSkeletonPageType.HEADER || startPageType === DocumentSkeletonPageType.FOOTER ? startPage === endPage : !0;
|
|
724
|
-
}
|
|
725
|
-
_resetCurrentNodePositionState() {
|
|
726
|
-
this._currentStartState = {
|
|
727
|
-
page: 0,
|
|
728
|
-
section: 0,
|
|
729
|
-
column: 0,
|
|
730
|
-
line: 0,
|
|
731
|
-
divide: 0,
|
|
732
|
-
glyph: 0
|
|
733
|
-
/* NORMAL */
|
|
734
|
-
}, this._currentEndState = {
|
|
735
|
-
page: 0,
|
|
736
|
-
section: 0,
|
|
737
|
-
column: 0,
|
|
738
|
-
line: 0,
|
|
739
|
-
divide: 0,
|
|
740
|
-
glyph: 0
|
|
741
|
-
/* NORMAL */
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
_setNodePositionState(type = 0, start, end, current) {
|
|
745
|
-
current === start ? this._currentStartState[type] = 1 : this._currentStartState[type] = 0, current === end ? this._currentEndState[type] = 2 : this._currentEndState[type] = 0;
|
|
746
|
-
}
|
|
747
|
-
_checkPreviousNodePositionState(typeIndex, isStart = !0) {
|
|
748
|
-
let index = typeIndex, resultState;
|
|
749
|
-
for (; index >= 0; ) {
|
|
750
|
-
const type = NodePositionType[index];
|
|
751
|
-
let state;
|
|
752
|
-
if (isStart ? state = this._currentStartState[type] : state = this._currentEndState[type], state === void 0)
|
|
753
|
-
return;
|
|
754
|
-
if (resultState === void 0 && (resultState = state), state !== resultState)
|
|
755
|
-
return 0;
|
|
756
|
-
index--;
|
|
757
|
-
}
|
|
758
|
-
return resultState;
|
|
759
|
-
}
|
|
760
|
-
_getSelectionRuler(typeIndex, startPosition, endPosition, nextLength, current) {
|
|
761
|
-
let start_next = 0, end_next = nextLength;
|
|
762
|
-
const type = NodePositionType[typeIndex], nextType = NodePositionType[typeIndex + 1];
|
|
763
|
-
if (nextType === null || type === null)
|
|
764
|
-
return {
|
|
765
|
-
start_next,
|
|
766
|
-
end_next
|
|
767
|
-
};
|
|
768
|
-
const start = startPosition[type], end = endPosition[type];
|
|
769
|
-
this._setNodePositionState(type, start, end, current);
|
|
770
|
-
const preStartNestType = this._checkPreviousNodePositionState(typeIndex), preEndNestType = this._checkPreviousNodePositionState(typeIndex, !1);
|
|
771
|
-
return preStartNestType === 1 && (start_next = startPosition[nextType]), preEndNestType === 2 && (end_next = endPosition[nextType]), {
|
|
772
|
-
start_next,
|
|
773
|
-
end_next
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
777
|
-
_selectionIterator(startPosition, endPosition, func) {
|
|
778
|
-
var _a28, _b2;
|
|
779
|
-
const skeleton = this._docSkeleton;
|
|
780
|
-
if (!skeleton)
|
|
781
|
-
return [];
|
|
782
|
-
const { pageType, path } = startPosition;
|
|
783
|
-
this._liquid.reset();
|
|
784
|
-
const skeletonData = skeleton.getSkeletonData();
|
|
785
|
-
if (skeletonData == null)
|
|
786
|
-
return [];
|
|
787
|
-
const { pages, skeHeaders, skeFooters } = skeletonData, { page: pageIndex, segmentPage } = startPosition, { page: endPageIndex, segmentPage: endSegmentPage } = endPosition;
|
|
788
|
-
if (this._resetCurrentNodePositionState(), this._documentOffsetConfig == null)
|
|
789
|
-
return [];
|
|
790
|
-
const { pageLayoutType, pageMarginLeft, pageMarginTop } = this._documentOffsetConfig, skipPageIndex = pageType === DocumentSkeletonPageType.BODY || pageType === DocumentSkeletonPageType.CELL ? pageIndex : segmentPage;
|
|
791
|
-
for (let p2 = 0; p2 < skipPageIndex; p2++) {
|
|
792
|
-
const page = pages[p2];
|
|
793
|
-
this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
794
|
-
}
|
|
795
|
-
const endIndex = pageType === DocumentSkeletonPageType.BODY || pageType === DocumentSkeletonPageType.CELL ? endPageIndex : endSegmentPage;
|
|
796
|
-
for (let p2 = skipPageIndex; p2 <= endIndex; p2++) {
|
|
797
|
-
const page = pages[p2], { headerId, footerId, pageWidth } = page;
|
|
798
|
-
let segmentPage2 = page;
|
|
799
|
-
if (pageType === DocumentSkeletonPageType.HEADER ? segmentPage2 = (_a28 = skeHeaders.get(headerId)) == null ? void 0 : _a28.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
|
-
this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
801
|
-
continue;
|
|
802
|
-
}
|
|
803
|
-
const sections = segmentPage2.sections, { start_next: start_s, end_next: end_s } = this._getSelectionRuler(
|
|
804
|
-
NodePositionMap.page,
|
|
805
|
-
startPosition,
|
|
806
|
-
endPosition,
|
|
807
|
-
sections.length - 1,
|
|
808
|
-
pageType === DocumentSkeletonPageType.BODY || pageType === DocumentSkeletonPageType.CELL ? p2 : 0
|
|
809
|
-
);
|
|
810
|
-
switch (this._liquid.translateSave(), pageType) {
|
|
811
|
-
case DocumentSkeletonPageType.HEADER:
|
|
812
|
-
this._liquid.translatePagePadding({
|
|
813
|
-
...segmentPage2,
|
|
814
|
-
marginLeft: page.marginLeft
|
|
815
|
-
// Because header or footer margin Left is 0.
|
|
816
|
-
});
|
|
817
|
-
break;
|
|
818
|
-
case DocumentSkeletonPageType.FOOTER: {
|
|
819
|
-
const footerTop = page.pageHeight - segmentPage2.height - segmentPage2.marginBottom;
|
|
820
|
-
this._liquid.translate(page.marginLeft, footerTop);
|
|
821
|
-
break;
|
|
822
|
-
}
|
|
823
|
-
case DocumentSkeletonPageType.CELL: {
|
|
824
|
-
this._liquid.translatePagePadding(page);
|
|
825
|
-
const rowSke = segmentPage2.parent, tableSke = rowSke.parent, { left: cellLeft } = segmentPage2, { top: tableTop, left: tableLeft } = tableSke, { top: rowTop } = rowSke;
|
|
826
|
-
this._liquid.translate(tableLeft + cellLeft, tableTop + rowTop), this._liquid.translatePagePadding(segmentPage2);
|
|
827
|
-
break;
|
|
828
|
-
}
|
|
829
|
-
default:
|
|
830
|
-
this._liquid.translatePagePadding(page);
|
|
831
|
-
break;
|
|
832
|
-
}
|
|
833
|
-
for (let s = start_s; s <= end_s; s++) {
|
|
834
|
-
const section = sections[s], columns = section.columns, { start_next: start_c, end_next: end_c } = this._getSelectionRuler(
|
|
835
|
-
NodePositionMap.section,
|
|
836
|
-
startPosition,
|
|
837
|
-
endPosition,
|
|
838
|
-
columns.length - 1,
|
|
839
|
-
s
|
|
840
|
-
);
|
|
841
|
-
this._liquid.translateSection(section);
|
|
842
|
-
for (let c = start_c; c <= end_c; c++) {
|
|
843
|
-
const column = columns[c], lines = column.lines, { start_next: start_l, end_next: end_l } = this._getSelectionRuler(
|
|
844
|
-
NodePositionMap.column,
|
|
845
|
-
startPosition,
|
|
846
|
-
endPosition,
|
|
847
|
-
lines.length - 1,
|
|
848
|
-
c
|
|
849
|
-
);
|
|
850
|
-
this._liquid.translateColumn(column);
|
|
851
|
-
for (let l2 = start_l; l2 <= end_l; l2++) {
|
|
852
|
-
const line = lines[l2], { divides } = line, { start_next: start_d, end_next: end_d } = this._getSelectionRuler(
|
|
853
|
-
NodePositionMap.line,
|
|
854
|
-
startPosition,
|
|
855
|
-
endPosition,
|
|
856
|
-
divides.length - 1,
|
|
857
|
-
l2
|
|
858
|
-
);
|
|
859
|
-
this._liquid.translateSave(), this._liquid.translateLine(line, !0, !1);
|
|
860
|
-
for (let d = start_d; d <= end_d; d++) {
|
|
861
|
-
const divide = divides[d];
|
|
862
|
-
this._liquid.translateSave(), this._liquid.translateDivide(divide);
|
|
863
|
-
const { glyphGroup } = divide, { start_next: start_sp, end_next: end_sp } = this._getSelectionRuler(
|
|
864
|
-
NodePositionMap.divide,
|
|
865
|
-
startPosition,
|
|
866
|
-
endPosition,
|
|
867
|
-
glyphGroup.length - 1,
|
|
868
|
-
d
|
|
869
|
-
);
|
|
870
|
-
let isFirst = !1, isLast = !1;
|
|
871
|
-
p2 === skipPageIndex && s === start_s && c === start_c && l2 === start_l && d === start_d && (isFirst = !0), p2 === endIndex && s === end_s && c === end_c && l2 === end_l && d === end_d && (isLast = !0), func && func(start_sp, end_sp, isFirst, isLast, divide, line, column, section, segmentPage2), this._liquid.translateRestore();
|
|
872
|
-
}
|
|
873
|
-
this._liquid.translateRestore();
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
this._liquid.translateRestore(), this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
};
|
|
881
|
-
__name(_NodePositionConvertToCursor, "NodePositionConvertToCursor");
|
|
882
|
-
let NodePositionConvertToCursor = _NodePositionConvertToCursor;
|
|
883
|
-
function isValidRectRange(anchorNodePosition, focusNodePosition) {
|
|
884
|
-
const { path: anchorPath } = anchorNodePosition, { path: focusPath } = focusNodePosition;
|
|
885
|
-
if (anchorPath.length !== focusPath.length || anchorPath.indexOf("cells") === -1)
|
|
886
|
-
return !1;
|
|
887
|
-
const tableIdIndex = anchorPath.indexOf("skeTables") + 1, rowIndex = anchorPath.indexOf("rows") + 1, cellIndex = anchorPath.indexOf("cells") + 1, anchorTableId = getTableIdAndSliceIndex(anchorPath[tableIdIndex]).tableId, focusTableId = getTableIdAndSliceIndex(focusPath[tableIdIndex]).tableId;
|
|
888
|
-
if (anchorTableId !== focusTableId)
|
|
889
|
-
return !1;
|
|
890
|
-
const anchorRowIndex = anchorPath[rowIndex], focusRowIndex = focusPath[rowIndex], anchorCellIndex = anchorPath[cellIndex], focusCellIndex = focusPath[cellIndex];
|
|
891
|
-
return !(anchorRowIndex === focusRowIndex && anchorCellIndex === focusCellIndex);
|
|
892
|
-
}
|
|
893
|
-
__name(isValidRectRange, "isValidRectRange");
|
|
894
|
-
function isInSameTableCell(anchorNodePosition, focusNodePosition) {
|
|
895
|
-
const { path: anchorPath } = anchorNodePosition, { path: focusPath } = focusNodePosition;
|
|
896
|
-
return anchorPath.indexOf("cells") === -1 || focusPath.indexOf("cells") === -1 ? !1 : Tools.diffValue(anchorPath, focusPath);
|
|
897
|
-
}
|
|
898
|
-
__name(isInSameTableCell, "isInSameTableCell");
|
|
899
|
-
function compareNodePositionInTable(a, b) {
|
|
900
|
-
if (isInSameTableCell(a, b))
|
|
901
|
-
return compareNodePositionLogic(a, b);
|
|
902
|
-
const { path: aPath } = a, { path: bPath } = b, aTableId = aPath[aPath.length - 5], bTableId = bPath[bPath.length - 5];
|
|
903
|
-
if (aTableId !== bTableId && typeof aTableId == "string" && typeof bTableId == "string") {
|
|
904
|
-
const aSlideId = aTableId.split("#-#")[1], bSlideId = bTableId.split("#-#")[1];
|
|
905
|
-
return +aSlideId < +bSlideId;
|
|
906
|
-
}
|
|
907
|
-
const aRowCount = aPath[aPath.length - 3], bRowCount = bPath[bPath.length - 3], aCellCount = aPath[aPath.length - 1], bCellCount = bPath[bPath.length - 1];
|
|
908
|
-
return aRowCount < bRowCount ? !0 : aRowCount > bRowCount ? !1 : aCellCount <= bCellCount;
|
|
909
|
-
}
|
|
910
|
-
__name(compareNodePositionInTable, "compareNodePositionInTable");
|
|
911
|
-
function firstGlyphInCellPage(cellPage) {
|
|
912
|
-
return cellPage.sections[0].columns[0].lines[0].divides[0].glyphGroup[0];
|
|
913
|
-
}
|
|
914
|
-
__name(firstGlyphInCellPage, "firstGlyphInCellPage");
|
|
915
|
-
function lastGlyphInCellPage(cellPage) {
|
|
916
|
-
const { sections } = cellPage, lastSection = sections[sections.length - 1], lastColumn = lastSection.columns[lastSection.columns.length - 1], lastLine = lastColumn.lines[lastColumn.lines.length - 1], lastGlyphGroup = lastLine.divides[lastLine.divides.length - 1].glyphGroup;
|
|
917
|
-
return lastGlyphGroup[lastGlyphGroup.length - 2];
|
|
918
|
-
}
|
|
919
|
-
__name(lastGlyphInCellPage, "lastGlyphInCellPage");
|
|
920
|
-
const _NodePositionConvertToRectRange = class _NodePositionConvertToRectRange {
|
|
921
|
-
constructor(_documentOffsetConfig, _docSkeleton) {
|
|
922
|
-
__publicField(this, "_liquid", new Liquid());
|
|
923
|
-
this._documentOffsetConfig = _documentOffsetConfig, this._docSkeleton = _docSkeleton;
|
|
924
|
-
}
|
|
925
|
-
// eslint-disable-next-line max-lines-per-function
|
|
926
|
-
getRangePointData(startNodePosition, endNodePosition) {
|
|
927
|
-
const pointGroup = [], skeletonData = this._docSkeleton.getSkeletonData();
|
|
928
|
-
if (skeletonData == null)
|
|
929
|
-
return;
|
|
930
|
-
const { pages } = skeletonData, { segmentPage: startSegmentPage, page: startPage, pageType } = startNodePosition, { segmentPage: endSegmentPage, page: endPage } = endNodePosition, rectInfo = this._getTableRectRangeInfo(startNodePosition, endNodePosition);
|
|
931
|
-
if (rectInfo == null)
|
|
932
|
-
return;
|
|
933
|
-
const {
|
|
934
|
-
tableId,
|
|
935
|
-
startRowIndex: startRow,
|
|
936
|
-
startColumnIndex: startColumn,
|
|
937
|
-
endRowIndex: endRow,
|
|
938
|
-
endColumnIndex: endColumn
|
|
939
|
-
} = rectInfo;
|
|
940
|
-
this._liquid.reset();
|
|
941
|
-
const { pageLayoutType, pageMarginLeft, pageMarginTop } = this._documentOffsetConfig, skipPageIndex = pageType === DocumentSkeletonPageType.BODY || pageType === DocumentSkeletonPageType.CELL ? startPage : startSegmentPage;
|
|
942
|
-
for (let p2 = 0; p2 < skipPageIndex; p2++) {
|
|
943
|
-
const page = pages[p2];
|
|
944
|
-
this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
945
|
-
}
|
|
946
|
-
const endIndex = pageType === DocumentSkeletonPageType.BODY || pageType === DocumentSkeletonPageType.CELL ? endPage : endSegmentPage;
|
|
947
|
-
for (let p2 = skipPageIndex; p2 <= endIndex; p2++) {
|
|
948
|
-
const page = pages[p2];
|
|
949
|
-
this._liquid.translatePagePadding(page);
|
|
950
|
-
const { skeTables } = page;
|
|
951
|
-
let table = null;
|
|
952
|
-
for (const [id, tableSke] of skeTables.entries())
|
|
953
|
-
id.startsWith(tableId) && (table = tableSke);
|
|
954
|
-
if (table == null) {
|
|
955
|
-
this._liquid.restorePagePadding(page), this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
956
|
-
continue;
|
|
957
|
-
}
|
|
958
|
-
this._liquid.translateSave(), this._liquid.translate(0, table.top);
|
|
959
|
-
const { x, y } = this._liquid;
|
|
960
|
-
for (const row of table.rows)
|
|
961
|
-
if (row.index >= startRow && row.index <= endRow) {
|
|
962
|
-
const rowStartCell = row.cells[startColumn], rowEndCell = row.cells[endColumn], position = {
|
|
963
|
-
startX: x + rowStartCell.left,
|
|
964
|
-
startY: y + row.top,
|
|
965
|
-
endX: x + rowEndCell.left + rowEndCell.pageWidth,
|
|
966
|
-
endY: y + row.top + row.height
|
|
967
|
-
};
|
|
968
|
-
pointGroup.push(pushToPoints(position));
|
|
969
|
-
}
|
|
970
|
-
this._liquid.translateRestore(), this._liquid.restorePagePadding(page), this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
971
|
-
}
|
|
972
|
-
return {
|
|
973
|
-
pointGroup,
|
|
974
|
-
startRow,
|
|
975
|
-
startColumn,
|
|
976
|
-
endRow,
|
|
977
|
-
endColumn,
|
|
978
|
-
tableId
|
|
979
|
-
};
|
|
980
|
-
}
|
|
981
|
-
getNodePositionGroup(anchorNodePosition, focusNodePosition) {
|
|
982
|
-
const nodePositionGroup = [], compare = compareNodePositionInTable(anchorNodePosition, focusNodePosition), startNodePosition = compare ? anchorNodePosition : focusNodePosition, endNodePosition = compare ? focusNodePosition : anchorNodePosition, { segmentPage } = startNodePosition, rectInfo = this._getTableRectRangeInfo(startNodePosition, endNodePosition);
|
|
983
|
-
if (rectInfo == null)
|
|
984
|
-
return;
|
|
985
|
-
const { tableId, pages, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex } = rectInfo, tables = [];
|
|
986
|
-
for (const page of pages) {
|
|
987
|
-
const { skeTables } = page;
|
|
988
|
-
for (const [id, table] of skeTables.entries())
|
|
989
|
-
id.startsWith(tableId) && tables.push(table);
|
|
990
|
-
}
|
|
991
|
-
if (tables.length === 0)
|
|
992
|
-
return;
|
|
993
|
-
for (const table of tables)
|
|
994
|
-
this._collectPositionGroup(table, nodePositionGroup, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex, segmentPage, compare);
|
|
995
|
-
const totalColumns = tables[0].rows[0].cells.length;
|
|
996
|
-
if (startColumnIndex === 0 && endColumnIndex === totalColumns - 1) {
|
|
997
|
-
const firstPosition = nodePositionGroup[0], lastPosition = nodePositionGroup[nodePositionGroup.length - 1];
|
|
998
|
-
nodePositionGroup.length = 0, nodePositionGroup.push({
|
|
999
|
-
anchor: compare ? firstPosition.anchor : lastPosition.anchor,
|
|
1000
|
-
focus: compare ? lastPosition.focus : firstPosition.focus
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
return nodePositionGroup;
|
|
1004
|
-
}
|
|
1005
|
-
_collectPositionGroup(table, nodePositionGroup, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex, segmentPage, compare) {
|
|
1006
|
-
for (let i = 0; i < table.rows.length; i++) {
|
|
1007
|
-
const row = table.rows[i];
|
|
1008
|
-
if (row.index < startRowIndex)
|
|
1009
|
-
continue;
|
|
1010
|
-
if (row.index > endRowIndex)
|
|
1011
|
-
break;
|
|
1012
|
-
const startCellInRow = row.cells[startColumnIndex], endCellInRow = row.cells[endColumnIndex], startCellGlyph = firstGlyphInCellPage(startCellInRow), endCellGlyph = lastGlyphInCellPage(endCellInRow);
|
|
1013
|
-
if (startCellGlyph == null || endCellGlyph == null)
|
|
1014
|
-
continue;
|
|
1015
|
-
const startPosition = this._docSkeleton.findPositionByGlyph(startCellGlyph, segmentPage), endPosition = this._docSkeleton.findPositionByGlyph(endCellGlyph, segmentPage);
|
|
1016
|
-
if (startPosition == null || endPosition == null)
|
|
1017
|
-
continue;
|
|
1018
|
-
const anchor = compare ? startPosition : endPosition, focus = compare ? endPosition : startPosition;
|
|
1019
|
-
nodePositionGroup.push({
|
|
1020
|
-
anchor: {
|
|
1021
|
-
...anchor,
|
|
1022
|
-
isBack: !0
|
|
1023
|
-
// true or false is the same.
|
|
1024
|
-
},
|
|
1025
|
-
focus: {
|
|
1026
|
-
...focus,
|
|
1027
|
-
isBack: !0
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
_getTableRectRangeInfo(startNodePosition, endNodePosition) {
|
|
1033
|
-
const skeletonData = this._docSkeleton.getSkeletonData();
|
|
1034
|
-
if (skeletonData == null)
|
|
1035
|
-
return;
|
|
1036
|
-
const { pages } = skeletonData, { path: startPath } = startNodePosition, { path: endPath } = endNodePosition, startCell = getPageFromPath(skeletonData, startPath), endCell = getPageFromPath(skeletonData, endPath);
|
|
1037
|
-
if (startCell == null || endCell == null)
|
|
1038
|
-
return;
|
|
1039
|
-
const tableId = startCell.segmentId, startRow = startCell.parent.index, startColumn = startCell.parent.cells.indexOf(startCell), endRow = (endCell == null ? void 0 : endCell.parent).index, endColumn = (endCell == null ? void 0 : endCell.parent).cells.indexOf(endCell);
|
|
1040
|
-
return {
|
|
1041
|
-
pages,
|
|
1042
|
-
tableId,
|
|
1043
|
-
startCell,
|
|
1044
|
-
endCell,
|
|
1045
|
-
startRowIndex: startRow,
|
|
1046
|
-
startColumnIndex: startColumn,
|
|
1047
|
-
endRowIndex: endRow,
|
|
1048
|
-
endColumnIndex: endColumn
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
|
-
__name(_NodePositionConvertToRectRange, "NodePositionConvertToRectRange");
|
|
1053
|
-
let NodePositionConvertToRectRange = _NodePositionConvertToRectRange;
|
|
1054
|
-
const TEXT_RANGE_KEY_PREFIX = "__TestSelectionRange__", TEXT_ANCHOR_KEY_PREFIX = "__TestSelectionAnchor__", ID_LENGTH$2 = 6, BLINK_ON = 500, BLINK_OFF = 500, TEXT_RANGE_LAYER_INDEX = 3;
|
|
1055
|
-
function getAnchorBounding(pointsGroup) {
|
|
1056
|
-
const points = pointsGroup[0], startPoint = points[0], endPoint = points[2], { x: startX, y: startY } = startPoint, { x: endX, y: endY } = endPoint;
|
|
1057
|
-
return {
|
|
1058
|
-
left: startX,
|
|
1059
|
-
top: startY,
|
|
1060
|
-
width: endX - startX,
|
|
1061
|
-
height: endY - startY
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
|
-
__name(getAnchorBounding, "getAnchorBounding");
|
|
1065
|
-
function getLineBounding(pointsGroup) {
|
|
1066
|
-
return pointsGroup.map((line) => {
|
|
1067
|
-
let xMin = 1 / 0, xMax = -1 / 0, yMin = 1 / 0, yMax = -1 / 0;
|
|
1068
|
-
return line.forEach((point) => {
|
|
1069
|
-
xMin = Math.min(point.x, xMin), xMax = Math.max(point.x, xMax), yMax = Math.max(point.y, yMax), yMin = Math.min(point.y, yMin);
|
|
1070
|
-
}), {
|
|
1071
|
-
left: xMin,
|
|
1072
|
-
right: xMax,
|
|
1073
|
-
top: yMin,
|
|
1074
|
-
bottom: yMax
|
|
1075
|
-
};
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
__name(getLineBounding, "getLineBounding");
|
|
1079
|
-
const _TextRange = class _TextRange {
|
|
1080
|
-
constructor(_scene, _document, _docSkeleton, anchorNodePosition, focusNodePosition, style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE, _segmentId = "", _segmentPage = -1) {
|
|
1081
|
-
__publicField(this, "rangeType", DOC_RANGE_TYPE.TEXT);
|
|
1082
|
-
// Identifies whether the range is the current one, most of which is the last range.
|
|
1083
|
-
__publicField(this, "_current", !1);
|
|
1084
|
-
// The rendered range graphic when collapsed is false
|
|
1085
|
-
__publicField(this, "_rangeShape");
|
|
1086
|
-
// The rendered range graphic when collapsed is true
|
|
1087
|
-
__publicField(this, "_anchorShape");
|
|
1088
|
-
__publicField(this, "_cursorList", []);
|
|
1089
|
-
__publicField(this, "_anchorBlinkTimer", null);
|
|
1090
|
-
this._scene = _scene, this._document = _document, this._docSkeleton = _docSkeleton, this.anchorNodePosition = anchorNodePosition, this.focusNodePosition = focusNodePosition, this.style = style, this._segmentId = _segmentId, this._segmentPage = _segmentPage, this._anchorBlink(), this.refresh();
|
|
1091
|
-
}
|
|
1092
|
-
_anchorBlink() {
|
|
1093
|
-
setTimeout(() => {
|
|
1094
|
-
this._anchorShape && this._anchorShape.visible && this.deactivateStatic();
|
|
1095
|
-
}, BLINK_ON), this._anchorBlinkTimer = setInterval(() => {
|
|
1096
|
-
this._anchorShape && this._anchorShape.visible && (this.activeStatic(), setTimeout(() => {
|
|
1097
|
-
this.deactivateStatic();
|
|
1098
|
-
}, BLINK_ON));
|
|
1099
|
-
}, BLINK_OFF + BLINK_ON);
|
|
1100
|
-
}
|
|
1101
|
-
// The start position of the range
|
|
1102
|
-
get startOffset() {
|
|
1103
|
-
var _a28;
|
|
1104
|
-
const { startOffset } = (_a28 = getOneTextSelectionRange(this._cursorList)) != null ? _a28 : {}, body = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId).getBody();
|
|
1105
|
-
if (startOffset == null || body == null)
|
|
1106
|
-
return startOffset;
|
|
1107
|
-
const maxLength = body.dataStream.length - 2;
|
|
1108
|
-
return Math.min(maxLength, startOffset);
|
|
1109
|
-
}
|
|
1110
|
-
// The end position of the range
|
|
1111
|
-
get endOffset() {
|
|
1112
|
-
var _a28;
|
|
1113
|
-
const { endOffset } = (_a28 = getOneTextSelectionRange(this._cursorList)) != null ? _a28 : {}, body = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId).getBody();
|
|
1114
|
-
if (endOffset == null || body == null)
|
|
1115
|
-
return endOffset;
|
|
1116
|
-
const maxLength = body.dataStream.length - 2;
|
|
1117
|
-
return Math.min(endOffset, maxLength);
|
|
1118
|
-
}
|
|
1119
|
-
get collapsed() {
|
|
1120
|
-
const { startOffset, endOffset } = this;
|
|
1121
|
-
return startOffset != null && startOffset === endOffset;
|
|
1122
|
-
}
|
|
1123
|
-
get startNodePosition() {
|
|
1124
|
-
if (this.anchorNodePosition == null)
|
|
1125
|
-
return null;
|
|
1126
|
-
if (this.focusNodePosition == null)
|
|
1127
|
-
return this.anchorNodePosition;
|
|
1128
|
-
const { start } = compareNodePosition(this.anchorNodePosition, this.focusNodePosition);
|
|
1129
|
-
return start;
|
|
1130
|
-
}
|
|
1131
|
-
get endNodePosition() {
|
|
1132
|
-
if (this.anchorNodePosition == null)
|
|
1133
|
-
return this.focusNodePosition;
|
|
1134
|
-
if (this.focusNodePosition == null)
|
|
1135
|
-
return null;
|
|
1136
|
-
const { end } = compareNodePosition(this.anchorNodePosition, this.focusNodePosition);
|
|
1137
|
-
return end;
|
|
1138
|
-
}
|
|
1139
|
-
get direction() {
|
|
1140
|
-
const { collapsed, anchorNodePosition, focusNodePosition } = this;
|
|
1141
|
-
return collapsed || anchorNodePosition == null || focusNodePosition == null ? RANGE_DIRECTION.NONE : compareNodePositionLogic(anchorNodePosition, focusNodePosition) ? RANGE_DIRECTION.FORWARD : RANGE_DIRECTION.BACKWARD;
|
|
1142
|
-
}
|
|
1143
|
-
get segmentId() {
|
|
1144
|
-
return this._segmentId;
|
|
1145
|
-
}
|
|
1146
|
-
get segmentPage() {
|
|
1147
|
-
return this._segmentPage;
|
|
1148
|
-
}
|
|
1149
|
-
getAbsolutePosition() {
|
|
1150
|
-
const anchor = this.anchorNodePosition, focus = this.focusNodePosition;
|
|
1151
|
-
if (this._isEmpty())
|
|
1152
|
-
return;
|
|
1153
|
-
const documentOffsetConfig = this._document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, convertor = new NodePositionConvertToCursor(documentOffsetConfig, this._docSkeleton);
|
|
1154
|
-
if (this._isCollapsed()) {
|
|
1155
|
-
const { contentBoxPointGroup, cursorList: cursorList2 } = convertor.getRangePointData(anchor, anchor);
|
|
1156
|
-
if (this._setCursorList(cursorList2), contentBoxPointGroup.length === 0)
|
|
1157
|
-
return;
|
|
1158
|
-
const pos2 = getAnchorBounding(contentBoxPointGroup);
|
|
1159
|
-
return {
|
|
1160
|
-
...pos2,
|
|
1161
|
-
left: pos2.left + docsLeft,
|
|
1162
|
-
top: pos2.top + docsTop
|
|
1163
|
-
};
|
|
1164
|
-
}
|
|
1165
|
-
const { borderBoxPointGroup, cursorList } = convertor.getRangePointData(anchor, focus);
|
|
1166
|
-
if (this._setCursorList(cursorList), borderBoxPointGroup.length === 0)
|
|
1167
|
-
return;
|
|
1168
|
-
const pos = getAnchorBounding(borderBoxPointGroup);
|
|
1169
|
-
return {
|
|
1170
|
-
...pos,
|
|
1171
|
-
left: pos.left + docsLeft,
|
|
1172
|
-
top: pos.top + docsTop
|
|
1173
|
-
};
|
|
1174
|
-
}
|
|
1175
|
-
getAnchor() {
|
|
1176
|
-
return this._anchorShape;
|
|
1177
|
-
}
|
|
1178
|
-
activeStatic() {
|
|
1179
|
-
var _a28, _b2;
|
|
1180
|
-
(_b2 = this._anchorShape) == null || _b2.setProps({
|
|
1181
|
-
stroke: ((_a28 = this.style) == null ? void 0 : _a28.strokeActive) || getColor(COLORS.black, 1)
|
|
1182
|
-
});
|
|
1183
|
-
}
|
|
1184
|
-
deactivateStatic() {
|
|
1185
|
-
var _a28, _b2;
|
|
1186
|
-
(_b2 = this._anchorShape) == null || _b2.setProps({
|
|
1187
|
-
stroke: ((_a28 = this.style) == null ? void 0 : _a28.stroke) || getColor(COLORS.black, 0)
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1190
|
-
isActive() {
|
|
1191
|
-
return this._current === !0;
|
|
1192
|
-
}
|
|
1193
|
-
activate() {
|
|
1194
|
-
this._current = !0;
|
|
1195
|
-
}
|
|
1196
|
-
deactivate() {
|
|
1197
|
-
this._current = !1;
|
|
1198
|
-
}
|
|
1199
|
-
dispose() {
|
|
1200
|
-
var _a28, _b2;
|
|
1201
|
-
(_a28 = this._rangeShape) == null || _a28.dispose(), this._rangeShape = null, (_b2 = this._anchorShape) == null || _b2.dispose(), this._anchorShape = null, this._anchorBlinkTimer && (clearInterval(this._anchorBlinkTimer), this._anchorBlinkTimer = null);
|
|
1202
|
-
}
|
|
1203
|
-
isIntersection(compareRange) {
|
|
1204
|
-
const { startOffset: activeStart, endOffset: activeEnd } = this, { startOffset: compareStart, endOffset: compareEnd } = compareRange;
|
|
1205
|
-
return activeStart == null || activeEnd == null || compareStart == null || compareEnd == null ? !1 : activeStart <= compareEnd && activeEnd >= compareStart;
|
|
1206
|
-
}
|
|
1207
|
-
// render cursor and selection.
|
|
1208
|
-
refresh() {
|
|
1209
|
-
var _a28, _b2;
|
|
1210
|
-
const { _document, _docSkeleton } = this, anchor = this.anchorNodePosition, focus = this.focusNodePosition;
|
|
1211
|
-
if ((_a28 = this._anchorShape) == null || _a28.hide(), (_b2 = this._rangeShape) == null || _b2.hide(), this._isEmpty())
|
|
1212
|
-
return;
|
|
1213
|
-
const documentOffsetConfig = _document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, convertor = new NodePositionConvertToCursor(documentOffsetConfig, _docSkeleton);
|
|
1214
|
-
if (this._isCollapsed()) {
|
|
1215
|
-
const { contentBoxPointGroup, cursorList: cursorList2 } = convertor.getRangePointData(anchor, anchor);
|
|
1216
|
-
if (this._setCursorList(cursorList2), contentBoxPointGroup.length > 0) {
|
|
1217
|
-
const glyphAtCursor = _docSkeleton.findGlyphByPosition(anchor);
|
|
1218
|
-
this._createOrUpdateAnchor(contentBoxPointGroup, docsLeft, docsTop, glyphAtCursor);
|
|
1219
|
-
}
|
|
1220
|
-
return;
|
|
1221
|
-
}
|
|
1222
|
-
const { borderBoxPointGroup, cursorList } = convertor.getRangePointData(anchor, focus);
|
|
1223
|
-
this._setCursorList(cursorList), borderBoxPointGroup.length > 0 && this._createOrUpdateRange(borderBoxPointGroup, docsLeft, docsTop);
|
|
1224
|
-
}
|
|
1225
|
-
_isEmpty() {
|
|
1226
|
-
return this.anchorNodePosition == null && this.focusNodePosition == null;
|
|
1227
|
-
}
|
|
1228
|
-
_isCollapsed() {
|
|
1229
|
-
const anchor = this.anchorNodePosition, focus = this.focusNodePosition;
|
|
1230
|
-
if (anchor != null && focus == null)
|
|
1231
|
-
return !0;
|
|
1232
|
-
if (anchor == null || focus == null)
|
|
1233
|
-
return !1;
|
|
1234
|
-
const keys = Object.keys(NodePositionMap);
|
|
1235
|
-
for (const key of keys) {
|
|
1236
|
-
const startNodeValue = anchor[key], endNodeValue = focus[key];
|
|
1237
|
-
if (startNodeValue !== endNodeValue)
|
|
1238
|
-
return !1;
|
|
1239
|
-
}
|
|
1240
|
-
return anchor.isBack === focus.isBack;
|
|
1241
|
-
}
|
|
1242
|
-
_createOrUpdateRange(pointsGroup, left, top) {
|
|
1243
|
-
var _a28;
|
|
1244
|
-
if (this._rangeShape) {
|
|
1245
|
-
this._rangeShape.translate(left, top), this._rangeShape.updatePointGroup(pointsGroup), this._rangeShape.show();
|
|
1246
|
-
return;
|
|
1247
|
-
}
|
|
1248
|
-
const OPACITY = 0.3, polygon = new RegularPolygon(TEXT_RANGE_KEY_PREFIX + Tools.generateRandomId(ID_LENGTH$2), {
|
|
1249
|
-
pointsGroup,
|
|
1250
|
-
fill: ((_a28 = this.style) == null ? void 0 : _a28.fill) || getColor(COLORS.black, OPACITY),
|
|
1251
|
-
left,
|
|
1252
|
-
top,
|
|
1253
|
-
evented: !1,
|
|
1254
|
-
debounceParentDirty: !1
|
|
1255
|
-
});
|
|
1256
|
-
this._rangeShape = polygon, this._scene.addObject(polygon, TEXT_RANGE_LAYER_INDEX);
|
|
1257
|
-
}
|
|
1258
|
-
_createOrUpdateAnchor(pointsGroup, docsLeft, docsTop, glyph) {
|
|
1259
|
-
var _a28, _b2, _c;
|
|
1260
|
-
const bounding = getAnchorBounding(pointsGroup), { left: boundingLeft } = bounding;
|
|
1261
|
-
let { top: boundingTop, height } = bounding;
|
|
1262
|
-
const MIN_CURSOR_HEIGHT = 14;
|
|
1263
|
-
height < MIN_CURSOR_HEIGHT && (boundingTop -= MIN_CURSOR_HEIGHT - height, height = MIN_CURSOR_HEIGHT);
|
|
1264
|
-
const ITALIC_DEGREE = 12;
|
|
1265
|
-
let left = boundingLeft + docsLeft;
|
|
1266
|
-
const top = boundingTop + docsTop, isItalic = ((_a28 = glyph == null ? void 0 : glyph.ts) == null ? void 0 : _a28.it) === BooleanNumber.TRUE;
|
|
1267
|
-
if (isItalic && (left += height * Math.tan(ITALIC_DEGREE * Math.PI / 180) / 2), this._anchorShape) {
|
|
1268
|
-
this._anchorShape.transformByState({ left, top, height }), this._anchorShape.show(), isItalic ? this._anchorShape.skew(-ITALIC_DEGREE, 0) : this._anchorShape.skew(0, 0);
|
|
1269
|
-
return;
|
|
1270
|
-
}
|
|
1271
|
-
const anchor = new Rect(TEXT_ANCHOR_KEY_PREFIX + Tools.generateRandomId(ID_LENGTH$2), {
|
|
1272
|
-
left,
|
|
1273
|
-
top,
|
|
1274
|
-
height,
|
|
1275
|
-
strokeWidth: ((_b2 = this.style) == null ? void 0 : _b2.strokeWidth) || 1.5,
|
|
1276
|
-
stroke: ((_c = this.style) == null ? void 0 : _c.strokeActive) || getColor(COLORS.black, 1),
|
|
1277
|
-
evented: !1
|
|
1278
|
-
});
|
|
1279
|
-
isItalic && anchor.skew(-ITALIC_DEGREE, 0), this._anchorShape = anchor, this._scene.addObject(anchor, TEXT_RANGE_LAYER_INDEX);
|
|
1280
|
-
}
|
|
1281
|
-
_setCursorList(cursorList) {
|
|
1282
|
-
cursorList.length !== 0 && (this._cursorList = cursorList);
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
|
-
__name(_TextRange, "TextRange");
|
|
1286
|
-
let TextRange = _TextRange;
|
|
1287
|
-
const RECT_RANGE_KEY_PREFIX = "__DocTableRectRange__", ID_LENGTH$1 = 6;
|
|
1288
|
-
function convertPositionsToRectRanges(scene, document2, docSkeleton, anchorNodePosition, focusNodePosition, style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE, segmentId = "", segmentPage = -1) {
|
|
1289
|
-
const documentOffsetConfig = document2.getOffsetConfig(), nodePositionGroup = new NodePositionConvertToRectRange(documentOffsetConfig, docSkeleton).getNodePositionGroup(anchorNodePosition, focusNodePosition);
|
|
1290
|
-
return (nodePositionGroup != null ? nodePositionGroup : []).map((position) => new RectRange(
|
|
1291
|
-
scene,
|
|
1292
|
-
document2,
|
|
1293
|
-
docSkeleton,
|
|
1294
|
-
position.anchor,
|
|
1295
|
-
position.focus,
|
|
1296
|
-
style,
|
|
1297
|
-
segmentId,
|
|
1298
|
-
segmentPage
|
|
1299
|
-
));
|
|
1300
|
-
}
|
|
1301
|
-
__name(convertPositionsToRectRanges, "convertPositionsToRectRanges");
|
|
1302
|
-
const _RectRange = class _RectRange {
|
|
1303
|
-
constructor(_scene, _document, _docSkeleton, anchorNodePosition, focusNodePosition, style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE, _segmentId = "", _segmentPage = -1) {
|
|
1304
|
-
__publicField(this, "rangeType", DOC_RANGE_TYPE.RECT);
|
|
1305
|
-
// The rendered rect range
|
|
1306
|
-
__publicField(this, "_rangeShape");
|
|
1307
|
-
// Identifies whether the range is the current one, most of which is the last range.
|
|
1308
|
-
__publicField(this, "_current", !1);
|
|
1309
|
-
// Rect Range start row.
|
|
1310
|
-
__publicField(this, "_startRow");
|
|
1311
|
-
// Rect Range start column.
|
|
1312
|
-
__publicField(this, "_startCol");
|
|
1313
|
-
// Rect Range end row.
|
|
1314
|
-
__publicField(this, "_endRow");
|
|
1315
|
-
// Rect Range end column.
|
|
1316
|
-
__publicField(this, "_endCol");
|
|
1317
|
-
// table id in view model.
|
|
1318
|
-
__publicField(this, "_tableId");
|
|
1319
|
-
this._scene = _scene, this._document = _document, this._docSkeleton = _docSkeleton, this.anchorNodePosition = anchorNodePosition, this.focusNodePosition = focusNodePosition, this.style = style, this._segmentId = _segmentId, this._segmentPage = _segmentPage, this.refresh();
|
|
1320
|
-
}
|
|
1321
|
-
get startOffset() {
|
|
1322
|
-
const { startNodePosition } = this;
|
|
1323
|
-
return this._docSkeleton.findCharIndexByPosition(startNodePosition);
|
|
1324
|
-
}
|
|
1325
|
-
get endOffset() {
|
|
1326
|
-
const { endNodePosition } = this;
|
|
1327
|
-
return this._docSkeleton.findCharIndexByPosition(endNodePosition);
|
|
1328
|
-
}
|
|
1329
|
-
get collapsed() {
|
|
1330
|
-
return !1;
|
|
1331
|
-
}
|
|
1332
|
-
get startRow() {
|
|
1333
|
-
return this._startRow;
|
|
1334
|
-
}
|
|
1335
|
-
get startColumn() {
|
|
1336
|
-
return this._startCol;
|
|
1337
|
-
}
|
|
1338
|
-
get endRow() {
|
|
1339
|
-
return this._endRow;
|
|
1340
|
-
}
|
|
1341
|
-
get endColumn() {
|
|
1342
|
-
return this._endCol;
|
|
1343
|
-
}
|
|
1344
|
-
get tableId() {
|
|
1345
|
-
return this._tableId;
|
|
1346
|
-
}
|
|
1347
|
-
get segmentId() {
|
|
1348
|
-
return this._segmentId;
|
|
1349
|
-
}
|
|
1350
|
-
get segmentPage() {
|
|
1351
|
-
return this._segmentPage;
|
|
1352
|
-
}
|
|
1353
|
-
get spanEntireRow() {
|
|
1354
|
-
var _a28;
|
|
1355
|
-
const table = (_a28 = this._docSkeleton.getViewModel().getSnapshot().tableSource) == null ? void 0 : _a28[this._tableId], { _startCol, _endCol } = this;
|
|
1356
|
-
if (table == null)
|
|
1357
|
-
throw new Error("Table is not found.");
|
|
1358
|
-
const { tableColumns } = table;
|
|
1359
|
-
return _startCol === 0 && _endCol === tableColumns.length - 1;
|
|
1360
|
-
}
|
|
1361
|
-
get spanEntireColumn() {
|
|
1362
|
-
var _a28;
|
|
1363
|
-
const table = (_a28 = this._docSkeleton.getViewModel().getSnapshot().tableSource) == null ? void 0 : _a28[this._tableId], { _startRow, _endRow } = this;
|
|
1364
|
-
if (table == null)
|
|
1365
|
-
throw new Error("Table is not found.");
|
|
1366
|
-
const { tableRows } = table;
|
|
1367
|
-
return _startRow === 0 && _endRow === tableRows.length - 1;
|
|
1368
|
-
}
|
|
1369
|
-
get spanEntireTable() {
|
|
1370
|
-
return this.spanEntireRow && this.spanEntireColumn;
|
|
1371
|
-
}
|
|
1372
|
-
get startNodePosition() {
|
|
1373
|
-
const { anchorNodePosition, focusNodePosition } = this;
|
|
1374
|
-
return compareNodePositionInTable(anchorNodePosition, focusNodePosition) ? anchorNodePosition : focusNodePosition;
|
|
1375
|
-
}
|
|
1376
|
-
get endNodePosition() {
|
|
1377
|
-
const { anchorNodePosition, focusNodePosition } = this;
|
|
1378
|
-
return compareNodePositionInTable(anchorNodePosition, focusNodePosition) ? focusNodePosition : anchorNodePosition;
|
|
1379
|
-
}
|
|
1380
|
-
get direction() {
|
|
1381
|
-
const { anchorNodePosition, focusNodePosition } = this;
|
|
1382
|
-
return compareNodePositionInTable(anchorNodePosition, focusNodePosition) ? RANGE_DIRECTION.FORWARD : RANGE_DIRECTION.BACKWARD;
|
|
1383
|
-
}
|
|
1384
|
-
isActive() {
|
|
1385
|
-
return this._current === !0;
|
|
1386
|
-
}
|
|
1387
|
-
activate() {
|
|
1388
|
-
this._current = !0;
|
|
1389
|
-
}
|
|
1390
|
-
deactivate() {
|
|
1391
|
-
this._current = !1;
|
|
1392
|
-
}
|
|
1393
|
-
dispose() {
|
|
1394
|
-
var _a28;
|
|
1395
|
-
(_a28 = this._rangeShape) == null || _a28.dispose(), this._rangeShape = null;
|
|
1396
|
-
}
|
|
1397
|
-
isIntersection(compareRange) {
|
|
1398
|
-
const { startRow, startColumn, endRow, endColumn } = this, { startRow: cStartRow, startColumn: cStartColumn, endRow: cEndRow, endColumn: cEndColumn } = compareRange, rect1 = {
|
|
1399
|
-
left: startColumn,
|
|
1400
|
-
top: startRow,
|
|
1401
|
-
right: endColumn,
|
|
1402
|
-
bottom: endRow
|
|
1403
|
-
}, rect2 = {
|
|
1404
|
-
left: cStartColumn,
|
|
1405
|
-
top: cStartRow,
|
|
1406
|
-
right: cEndColumn,
|
|
1407
|
-
bottom: cEndRow
|
|
1408
|
-
};
|
|
1409
|
-
return Rectangle.hasIntersectionBetweenTwoRect(rect1, rect2);
|
|
1410
|
-
}
|
|
1411
|
-
refresh() {
|
|
1412
|
-
var _a28;
|
|
1413
|
-
(_a28 = this._rangeShape) == null || _a28.hide();
|
|
1414
|
-
const { startNodePosition, endNodePosition, _document, _docSkeleton } = this, documentOffsetConfig = _document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, rectInfo = new NodePositionConvertToRectRange(documentOffsetConfig, _docSkeleton).getRangePointData(startNodePosition, endNodePosition);
|
|
1415
|
-
if (rectInfo == null)
|
|
1416
|
-
return;
|
|
1417
|
-
const { pointGroup = [], startRow, endRow, startColumn, endColumn, tableId } = rectInfo;
|
|
1418
|
-
(pointGroup == null ? void 0 : pointGroup.length) > 0 && this._createOrUpdateRange(pointGroup, docsLeft, docsTop), this._updateTableInfo(startRow, endRow, startColumn, endColumn, tableId);
|
|
1419
|
-
}
|
|
1420
|
-
_updateTableInfo(startRow, endRow, startCol, endCol, tableId) {
|
|
1421
|
-
this._startRow = startRow, this._endRow = endRow, this._startCol = startCol, this._endCol = endCol, this._tableId = tableId;
|
|
1422
|
-
}
|
|
1423
|
-
_createOrUpdateRange(pointsGroup, left, top) {
|
|
1424
|
-
var _a28;
|
|
1425
|
-
if (this._rangeShape) {
|
|
1426
|
-
this._rangeShape.translate(left, top), this._rangeShape.updatePointGroup(pointsGroup), this._rangeShape.show();
|
|
1427
|
-
return;
|
|
1428
|
-
}
|
|
1429
|
-
const OPACITY = 0.3, polygon = new RegularPolygon(RECT_RANGE_KEY_PREFIX + Tools.generateRandomId(ID_LENGTH$1), {
|
|
1430
|
-
pointsGroup,
|
|
1431
|
-
fill: ((_a28 = this.style) == null ? void 0 : _a28.fill) || getColor(COLORS.black, OPACITY),
|
|
1432
|
-
left,
|
|
1433
|
-
top,
|
|
1434
|
-
evented: !1,
|
|
1435
|
-
debounceParentDirty: !1
|
|
1436
|
-
});
|
|
1437
|
-
this._rangeShape = polygon, this._scene.addObject(polygon, TEXT_RANGE_LAYER_INDEX);
|
|
1438
|
-
}
|
|
1439
|
-
};
|
|
1440
|
-
__name(_RectRange, "RectRange");
|
|
1441
|
-
let RectRange = _RectRange;
|
|
1442
|
-
function getTextRangeFromCharIndex(startOffset, endOffset, scene, document2, skeleton, style, segmentId, segmentPage, startIsBack = !0, endIsBack = !0) {
|
|
1443
|
-
const startNodePosition = skeleton.findNodePositionByCharIndex(startOffset, startIsBack, segmentId, segmentPage), endNodePosition = skeleton.findNodePositionByCharIndex(endOffset, endIsBack, segmentId, segmentPage);
|
|
1444
|
-
if (!(startNodePosition == null || endNodePosition == null))
|
|
1445
|
-
return new TextRange(scene, document2, skeleton, startNodePosition, endNodePosition, style, segmentId, segmentPage);
|
|
1446
|
-
}
|
|
1447
|
-
__name(getTextRangeFromCharIndex, "getTextRangeFromCharIndex");
|
|
1448
|
-
function getRectRangeFromCharIndex(startOffset, endOffset, scene, document2, skeleton, style, segmentId, segmentPage) {
|
|
1449
|
-
const startNodePosition = skeleton.findNodePositionByCharIndex(startOffset, !0, segmentId, segmentPage), endNodePosition = skeleton.findNodePositionByCharIndex(endOffset, !0, segmentId, segmentPage);
|
|
1450
|
-
if (!(startNodePosition == null || endNodePosition == null))
|
|
1451
|
-
return new RectRange(scene, document2, skeleton, startNodePosition, endNodePosition, style, segmentId, segmentPage);
|
|
1452
|
-
}
|
|
1453
|
-
__name(getRectRangeFromCharIndex, "getRectRangeFromCharIndex");
|
|
1454
|
-
function getRangeListFromCharIndex(startOffset, endOffset, scene, document2, skeleton, style, segmentId, segmentPage) {
|
|
1455
|
-
const startNodePosition = skeleton.findNodePositionByCharIndex(startOffset, !0, segmentId, segmentPage), endNodePosition = skeleton.findNodePositionByCharIndex(endOffset, !0, segmentId, segmentPage);
|
|
1456
|
-
if (!(startNodePosition == null || endNodePosition == null))
|
|
1457
|
-
return getRangeListFromSelection(
|
|
1458
|
-
startNodePosition,
|
|
1459
|
-
endNodePosition,
|
|
1460
|
-
scene,
|
|
1461
|
-
document2,
|
|
1462
|
-
skeleton,
|
|
1463
|
-
style,
|
|
1464
|
-
segmentId,
|
|
1465
|
-
segmentPage
|
|
1466
|
-
);
|
|
1467
|
-
}
|
|
1468
|
-
__name(getRangeListFromCharIndex, "getRangeListFromCharIndex");
|
|
1469
|
-
function getRangeListFromSelection(anchorPosition, focusPosition, scene, document2, skeleton, style, segmentId, segmentPage) {
|
|
1470
|
-
const textRanges = [], rectRanges = [], rangeParams = [scene, document2, skeleton, anchorPosition, focusPosition, style, segmentId, segmentPage];
|
|
1471
|
-
if (isInSameTableCell(anchorPosition, focusPosition))
|
|
1472
|
-
return textRanges.push(new TextRange(...rangeParams)), {
|
|
1473
|
-
textRanges,
|
|
1474
|
-
rectRanges
|
|
1475
|
-
};
|
|
1476
|
-
if (isValidRectRange(anchorPosition, focusPosition)) {
|
|
1477
|
-
const ranges = convertPositionsToRectRanges(
|
|
1478
|
-
...rangeParams
|
|
1479
|
-
);
|
|
1480
|
-
return rectRanges.push(...ranges), {
|
|
1481
|
-
textRanges,
|
|
1482
|
-
rectRanges
|
|
1483
|
-
};
|
|
1484
|
-
}
|
|
1485
|
-
const viewModel = skeleton.getViewModel().getSelfOrHeaderFooterViewModel(segmentId), anchorOffset = skeleton.findCharIndexByPosition(anchorPosition), focusOffset = skeleton.findCharIndexByPosition(focusPosition);
|
|
1486
|
-
if (anchorOffset == null || focusOffset == null)
|
|
1487
|
-
return;
|
|
1488
|
-
const direction = anchorOffset <= focusOffset ? RANGE_DIRECTION.FORWARD : RANGE_DIRECTION.BACKWARD, startOffset = Math.min(anchorOffset, focusOffset), endOffset = Math.max(anchorOffset, focusOffset);
|
|
1489
|
-
let start = startOffset, end = endOffset;
|
|
1490
|
-
for (const section of viewModel.children)
|
|
1491
|
-
for (const paragraph of section.children) {
|
|
1492
|
-
const { startIndex, endIndex, children } = paragraph, table = children[0];
|
|
1493
|
-
let endInTable = !1;
|
|
1494
|
-
if (table) {
|
|
1495
|
-
const { startIndex: tableStart, endIndex: tableEnd, children: children2 } = table;
|
|
1496
|
-
let tableStartPosition = null, tableEndPosition = null;
|
|
1497
|
-
const startRow = children2.find((row) => row.startIndex <= startOffset && row.endIndex >= startOffset), endRow = children2.find((row) => row.startIndex <= endOffset && row.endIndex >= endOffset);
|
|
1498
|
-
if (startOffset > tableStart && startOffset < tableEnd)
|
|
1499
|
-
tableStartPosition = skeleton.findNodePositionByCharIndex(startRow.startIndex + 2, !0, segmentId, segmentPage), tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, !0, segmentId, segmentPage), start = tableEnd + 1;
|
|
1500
|
-
else if (endOffset > tableStart && endOffset < tableEnd)
|
|
1501
|
-
tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, !0, segmentId, segmentPage), tableEndPosition = skeleton.findNodePositionByCharIndex(endRow.endIndex - 3, !0, segmentId, segmentPage), end = tableStart - 1, endInTable = !0;
|
|
1502
|
-
else if (tableStart > startOffset && tableEnd < endOffset) {
|
|
1503
|
-
if (tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, !0, segmentId, segmentPage), tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, !0, segmentId, segmentPage), start <= tableStart - 1) {
|
|
1504
|
-
const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(tableStart - 1, !1, segmentId, segmentPage), ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep, fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
|
|
1505
|
-
textRanges.push(new TextRange(scene, document2, skeleton, ap, fp, style, segmentId, segmentPage));
|
|
1506
|
-
}
|
|
1507
|
-
start = tableEnd + 1;
|
|
1508
|
-
}
|
|
1509
|
-
if (tableStartPosition && tableEndPosition) {
|
|
1510
|
-
const ap = direction === RANGE_DIRECTION.FORWARD ? tableStartPosition : tableEndPosition, fp = direction === RANGE_DIRECTION.FORWARD ? tableEndPosition : tableStartPosition;
|
|
1511
|
-
rectRanges.push(...convertPositionsToRectRanges(
|
|
1512
|
-
scene,
|
|
1513
|
-
document2,
|
|
1514
|
-
skeleton,
|
|
1515
|
-
ap,
|
|
1516
|
-
fp,
|
|
1517
|
-
style,
|
|
1518
|
-
segmentId,
|
|
1519
|
-
segmentPage
|
|
1520
|
-
));
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
if (end >= startIndex && end <= endIndex || endInTable) {
|
|
1524
|
-
const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(end, !endInTable, segmentId, segmentPage), ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep, fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
|
|
1525
|
-
if (rectRanges.length && Tools.diffValue(ap, fp))
|
|
1526
|
-
continue;
|
|
1527
|
-
textRanges.push(new TextRange(scene, document2, skeleton, ap, fp, style, segmentId, segmentPage));
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
return {
|
|
1531
|
-
textRanges,
|
|
1532
|
-
rectRanges
|
|
1533
|
-
};
|
|
1534
|
-
}
|
|
1535
|
-
__name(getRangeListFromSelection, "getRangeListFromSelection");
|
|
1536
|
-
function getCanvasOffsetByEngine(engine) {
|
|
1537
|
-
const canvas = engine == null ? void 0 : engine.getCanvasElement();
|
|
1538
|
-
if (!canvas)
|
|
1539
|
-
return {
|
|
1540
|
-
left: 0,
|
|
1541
|
-
top: 0
|
|
1542
|
-
};
|
|
1543
|
-
const { top, left } = getOffsetRectForDom(canvas);
|
|
1544
|
-
return {
|
|
1545
|
-
left,
|
|
1546
|
-
top
|
|
1547
|
-
};
|
|
1548
|
-
}
|
|
1549
|
-
__name(getCanvasOffsetByEngine, "getCanvasOffsetByEngine");
|
|
1550
|
-
function getParagraphInfoByGlyph(node) {
|
|
1551
|
-
var _a28;
|
|
1552
|
-
const line = (_a28 = node.parent) == null ? void 0 : _a28.parent, column = line == null ? void 0 : line.parent;
|
|
1553
|
-
if (line == null || column == null)
|
|
1554
|
-
return;
|
|
1555
|
-
const { paragraphIndex } = line, lines = column.lines.filter((line2) => line2.paragraphIndex === paragraphIndex);
|
|
1556
|
-
let nodeIndex = -1, content = "", hasFound = !1;
|
|
1557
|
-
for (const line2 of lines)
|
|
1558
|
-
for (const divide of line2.divides)
|
|
1559
|
-
for (const glyph of divide.glyphGroup)
|
|
1560
|
-
hasFound || (nodeIndex += glyph.count), glyph === node && (hasFound = !0), content += glyph.count > 0 ? glyph.content : "";
|
|
1561
|
-
return {
|
|
1562
|
-
st: lines[0].st,
|
|
1563
|
-
ed: paragraphIndex,
|
|
1564
|
-
content,
|
|
1565
|
-
nodeIndex
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1568
|
-
__name(getParagraphInfoByGlyph, "getParagraphInfoByGlyph");
|
|
1569
|
-
function serializeTextRange(textRange) {
|
|
1570
|
-
const { startOffset, endOffset, collapsed, rangeType, startNodePosition, endNodePosition, direction, segmentId, segmentPage } = textRange;
|
|
1571
|
-
return {
|
|
1572
|
-
startOffset,
|
|
1573
|
-
endOffset,
|
|
1574
|
-
collapsed,
|
|
1575
|
-
rangeType,
|
|
1576
|
-
startNodePosition,
|
|
1577
|
-
endNodePosition,
|
|
1578
|
-
direction,
|
|
1579
|
-
segmentId,
|
|
1580
|
-
segmentPage,
|
|
1581
|
-
isActive: textRange.isActive()
|
|
1582
|
-
};
|
|
1583
|
-
}
|
|
1584
|
-
__name(serializeTextRange, "serializeTextRange");
|
|
1585
|
-
function serializeRectRange(rectRange) {
|
|
1586
|
-
const serializedTextRange = serializeTextRange(rectRange), {
|
|
1587
|
-
startRow,
|
|
1588
|
-
startColumn,
|
|
1589
|
-
endRow,
|
|
1590
|
-
endColumn,
|
|
1591
|
-
tableId,
|
|
1592
|
-
spanEntireRow,
|
|
1593
|
-
spanEntireColumn,
|
|
1594
|
-
spanEntireTable
|
|
1595
|
-
} = rectRange;
|
|
1596
|
-
return {
|
|
1597
|
-
...serializedTextRange,
|
|
1598
|
-
startRow,
|
|
1599
|
-
startColumn,
|
|
1600
|
-
endRow,
|
|
1601
|
-
endColumn,
|
|
1602
|
-
tableId,
|
|
1603
|
-
spanEntireRow,
|
|
1604
|
-
spanEntireColumn,
|
|
1605
|
-
spanEntireTable
|
|
1606
|
-
};
|
|
1607
|
-
}
|
|
1608
|
-
__name(serializeRectRange, "serializeRectRange");
|
|
1609
|
-
var __defProp$q = Object.defineProperty, __getOwnPropDesc$q = Object.getOwnPropertyDescriptor, __decorateClass$q = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1610
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1611
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1612
|
-
return kind && result && __defProp$q(target, key, result), result;
|
|
1613
|
-
}, "__decorateClass$q"), __decorateParam$q = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$q"), _a2;
|
|
1614
|
-
let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
1615
|
-
constructor(_context, _layoutService, _logService, _univerInstanceService, _docSkeletonManagerService) {
|
|
1616
|
-
super();
|
|
1617
|
-
__publicField(this, "_onInputBefore$", new Subject());
|
|
1618
|
-
__publicField(this, "onInputBefore$", this._onInputBefore$.asObservable());
|
|
1619
|
-
__publicField(this, "_onKeydown$", new Subject());
|
|
1620
|
-
__publicField(this, "onKeydown$", this._onKeydown$.asObservable());
|
|
1621
|
-
__publicField(this, "_onInput$", new Subject());
|
|
1622
|
-
__publicField(this, "onInput$", this._onInput$.asObservable());
|
|
1623
|
-
__publicField(this, "_onCompositionstart$", new BehaviorSubject(null));
|
|
1624
|
-
__publicField(this, "onCompositionstart$", this._onCompositionstart$.asObservable());
|
|
1625
|
-
__publicField(this, "_onCompositionupdate$", new BehaviorSubject(null));
|
|
1626
|
-
__publicField(this, "onCompositionupdate$", this._onCompositionupdate$.asObservable());
|
|
1627
|
-
__publicField(this, "_onCompositionend$", new BehaviorSubject(null));
|
|
1628
|
-
__publicField(this, "onCompositionend$", this._onCompositionend$.asObservable());
|
|
1629
|
-
__publicField(this, "_onSelectionStart$", new BehaviorSubject(null));
|
|
1630
|
-
__publicField(this, "onSelectionStart$", this._onSelectionStart$.asObservable());
|
|
1631
|
-
__publicField(this, "_onPaste$", new Subject());
|
|
1632
|
-
__publicField(this, "onPaste$", this._onPaste$.asObservable());
|
|
1633
|
-
__publicField(this, "_textSelectionInner$", new BehaviorSubject(null));
|
|
1634
|
-
__publicField(this, "textSelectionInner$", this._textSelectionInner$.asObservable());
|
|
1635
|
-
__publicField(this, "_onFocus$", new Subject());
|
|
1636
|
-
__publicField(this, "onFocus$", this._onFocus$.asObservable());
|
|
1637
|
-
__publicField(this, "_onBlur$", new Subject());
|
|
1638
|
-
__publicField(this, "onBlur$", this._onBlur$.asObservable());
|
|
1639
|
-
__publicField(this, "_onPointerDown$", new Subject());
|
|
1640
|
-
__publicField(this, "onPointerDown$", this._onPointerDown$.asObservable());
|
|
1641
|
-
__publicField(this, "_container");
|
|
1642
|
-
__publicField(this, "_inputParent");
|
|
1643
|
-
__publicField(this, "_input");
|
|
1644
|
-
__publicField(this, "_scrollTimers", []);
|
|
1645
|
-
__publicField(this, "_rangeList", []);
|
|
1646
|
-
// Use to cache range list in moving.
|
|
1647
|
-
__publicField(this, "_rangeListCache", []);
|
|
1648
|
-
// Rect range list.
|
|
1649
|
-
__publicField(this, "_rectRangeList", []);
|
|
1650
|
-
// Use to cache rect range list in moving.
|
|
1651
|
-
__publicField(this, "_rectRangeListCache", []);
|
|
1652
|
-
__publicField(this, "_anchorNodePosition", null);
|
|
1653
|
-
__publicField(this, "_focusNodePosition", null);
|
|
1654
|
-
__publicField(this, "_currentSegmentId", "");
|
|
1655
|
-
__publicField(this, "_currentSegmentPage", -1);
|
|
1656
|
-
__publicField(this, "_selectionStyle", NORMAL_TEXT_SELECTION_PLUGIN_STYLE);
|
|
1657
|
-
__publicField(this, "_viewPortObserverMap", /* @__PURE__ */ new Map());
|
|
1658
|
-
__publicField(this, "_isIMEInputApply", !1);
|
|
1659
|
-
__publicField(this, "_scenePointerMoveSubs", []);
|
|
1660
|
-
__publicField(this, "_scenePointerUpSubs", []);
|
|
1661
|
-
__publicField(this, "_editorFocusing", !0);
|
|
1662
|
-
// When the user switches editors, whether to clear the doc ranges.
|
|
1663
|
-
__publicField(this, "_reserveRanges", !1);
|
|
1664
|
-
this._context = _context, this._layoutService = _layoutService, this._logService = _logService, this._univerInstanceService = _univerInstanceService, this._docSkeletonManagerService = _docSkeletonManagerService, this._initDOM(), this._registerContainer(), this._setSystemHighlightColorToStyle(), this._listenCurrentUnitChange();
|
|
1665
|
-
}
|
|
1666
|
-
_listenCurrentUnitChange() {
|
|
1667
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((documentModel) => {
|
|
1668
|
-
if (documentModel == null)
|
|
1669
|
-
return;
|
|
1670
|
-
documentModel.getUnitId() !== this._context.unitId && !this._reserveRanges && this.removeAllRanges();
|
|
1671
|
-
});
|
|
1672
|
-
}
|
|
1673
|
-
get activeViewPort() {
|
|
1674
|
-
return this._context.scene.getViewports()[0];
|
|
1675
|
-
}
|
|
1676
|
-
setSegment(id) {
|
|
1677
|
-
this._currentSegmentId = id;
|
|
1678
|
-
}
|
|
1679
|
-
getSegment() {
|
|
1680
|
-
return this._currentSegmentId;
|
|
1681
|
-
}
|
|
1682
|
-
setSegmentPage(pageIndex) {
|
|
1683
|
-
this._currentSegmentPage = pageIndex;
|
|
1684
|
-
}
|
|
1685
|
-
getSegmentPage() {
|
|
1686
|
-
return this._currentSegmentPage;
|
|
1687
|
-
}
|
|
1688
|
-
setReserveRangesStatus(status) {
|
|
1689
|
-
this._reserveRanges = status;
|
|
1690
|
-
}
|
|
1691
|
-
_setRangeStyle(style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE) {
|
|
1692
|
-
this._selectionStyle = style;
|
|
1693
|
-
}
|
|
1694
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1695
|
-
addDocRanges(ranges, isEditing = !0, options) {
|
|
1696
|
-
const {
|
|
1697
|
-
_currentSegmentId: segmentId,
|
|
1698
|
-
_currentSegmentPage: segmentPage,
|
|
1699
|
-
_selectionStyle: style
|
|
1700
|
-
} = this, { scene, mainComponent } = this._context, document2 = mainComponent, docSkeleton = this._docSkeletonManagerService.getSkeleton();
|
|
1701
|
-
for (const range of ranges) {
|
|
1702
|
-
const { startOffset, endOffset, rangeType, startNodePosition, endNodePosition } = range;
|
|
1703
|
-
if (rangeType === DOC_RANGE_TYPE.RECT) {
|
|
1704
|
-
const rectRange = getRectRangeFromCharIndex(
|
|
1705
|
-
startOffset,
|
|
1706
|
-
endOffset,
|
|
1707
|
-
scene,
|
|
1708
|
-
document2,
|
|
1709
|
-
docSkeleton,
|
|
1710
|
-
style,
|
|
1711
|
-
segmentId,
|
|
1712
|
-
segmentPage
|
|
1713
|
-
);
|
|
1714
|
-
rectRange && this._addRectRanges([rectRange]);
|
|
1715
|
-
} else if (rangeType === DOC_RANGE_TYPE.TEXT) {
|
|
1716
|
-
let textRange = null;
|
|
1717
|
-
startNodePosition && endNodePosition ? textRange = getTextRangeFromCharIndex(
|
|
1718
|
-
startNodePosition.isBack ? startOffset : startOffset - 1,
|
|
1719
|
-
endNodePosition.isBack ? endOffset : endOffset - 1,
|
|
1720
|
-
scene,
|
|
1721
|
-
document2,
|
|
1722
|
-
docSkeleton,
|
|
1723
|
-
style,
|
|
1724
|
-
segmentId,
|
|
1725
|
-
segmentPage,
|
|
1726
|
-
startNodePosition.isBack,
|
|
1727
|
-
endNodePosition.isBack
|
|
1728
|
-
) : textRange = getTextRangeFromCharIndex(
|
|
1729
|
-
startOffset,
|
|
1730
|
-
endOffset,
|
|
1731
|
-
scene,
|
|
1732
|
-
document2,
|
|
1733
|
-
docSkeleton,
|
|
1734
|
-
style,
|
|
1735
|
-
segmentId,
|
|
1736
|
-
segmentPage
|
|
1737
|
-
), textRange && this._addTextRange(textRange);
|
|
1738
|
-
} else {
|
|
1739
|
-
const rangeList = getRangeListFromCharIndex(
|
|
1740
|
-
startOffset,
|
|
1741
|
-
endOffset,
|
|
1742
|
-
scene,
|
|
1743
|
-
document2,
|
|
1744
|
-
docSkeleton,
|
|
1745
|
-
style,
|
|
1746
|
-
segmentId,
|
|
1747
|
-
segmentPage
|
|
1748
|
-
);
|
|
1749
|
-
if (rangeList == null)
|
|
1750
|
-
continue;
|
|
1751
|
-
const { textRanges, rectRanges } = rangeList;
|
|
1752
|
-
for (const textRange of textRanges)
|
|
1753
|
-
this._addTextRange(textRange);
|
|
1754
|
-
this._addRectRanges(rectRanges);
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
this._textSelectionInner$.next({
|
|
1758
|
-
textRanges: this._getAllTextRanges(),
|
|
1759
|
-
rectRanges: this._getAllRectRanges(),
|
|
1760
|
-
segmentId,
|
|
1761
|
-
segmentPage,
|
|
1762
|
-
style,
|
|
1763
|
-
isEditing,
|
|
1764
|
-
options
|
|
1765
|
-
}), this._updateInputPosition(options == null ? void 0 : options.forceFocus);
|
|
1766
|
-
}
|
|
1767
|
-
setCursorManually(evtOffsetX, evtOffsetY) {
|
|
1768
|
-
const startNode = this._findNodeByCoord(evtOffsetX, evtOffsetY, {
|
|
1769
|
-
strict: !0,
|
|
1770
|
-
segmentId: this._currentSegmentId,
|
|
1771
|
-
segmentPage: this._currentSegmentPage
|
|
1772
|
-
}), position = this._getNodePosition(startNode);
|
|
1773
|
-
if (position == null) {
|
|
1774
|
-
this._removeAllRanges();
|
|
1775
|
-
return;
|
|
1776
|
-
}
|
|
1777
|
-
(startNode == null ? void 0 : startNode.node.streamType) === DataStreamTreeTokenType.PARAGRAPH && (position.isBack = !0), this._createTextRangeByAnchorPosition(position), this._textSelectionInner$.next({
|
|
1778
|
-
textRanges: this._getAllTextRanges(),
|
|
1779
|
-
rectRanges: this._getAllRectRanges(),
|
|
1780
|
-
segmentId: this._currentSegmentId,
|
|
1781
|
-
segmentPage: this._currentSegmentPage,
|
|
1782
|
-
style: this._selectionStyle,
|
|
1783
|
-
isEditing: !1
|
|
1784
|
-
});
|
|
1785
|
-
}
|
|
1786
|
-
// Sync canvas selection to dom selection.
|
|
1787
|
-
sync() {
|
|
1788
|
-
this._updateInputPosition();
|
|
1789
|
-
}
|
|
1790
|
-
/**
|
|
1791
|
-
* @deprecated
|
|
1792
|
-
*/
|
|
1793
|
-
activate(x, y, force = !1) {
|
|
1794
|
-
const isFocusing = this._input === document.activeElement || document.activeElement === document.body || document.activeElement === null;
|
|
1795
|
-
this._container.style.left = `${x}px`, this._container.style.top = `${y}px`, this._container.style.zIndex = "1000", (isFocusing || force) && this.focus();
|
|
1796
|
-
}
|
|
1797
|
-
hasFocus() {
|
|
1798
|
-
return document.activeElement === this._input;
|
|
1799
|
-
}
|
|
1800
|
-
focus() {
|
|
1801
|
-
this._editorFocusing && this._input.focus();
|
|
1802
|
-
}
|
|
1803
|
-
blur() {
|
|
1804
|
-
this._input.blur();
|
|
1805
|
-
}
|
|
1806
|
-
/**
|
|
1807
|
-
* @deprecated
|
|
1808
|
-
*/
|
|
1809
|
-
focusEditor() {
|
|
1810
|
-
this._editorFocusing = !0, this.focus();
|
|
1811
|
-
}
|
|
1812
|
-
/**
|
|
1813
|
-
* @deprecated
|
|
1814
|
-
*/
|
|
1815
|
-
blurEditor() {
|
|
1816
|
-
this._editorFocusing = !1, this.blur();
|
|
1817
|
-
}
|
|
1818
|
-
// FIXME: for editor cell editor we don't need to blur the input element
|
|
1819
|
-
/**
|
|
1820
|
-
* @deprecated
|
|
1821
|
-
*/
|
|
1822
|
-
deactivate() {
|
|
1823
|
-
this._container.style.left = "0px", this._container.style.top = "0px";
|
|
1824
|
-
}
|
|
1825
|
-
// Handler double click.
|
|
1826
|
-
__handleDblClick(evt) {
|
|
1827
|
-
const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this._findNodeByCoord(evtOffsetX, evtOffsetY, {
|
|
1828
|
-
strict: !1,
|
|
1829
|
-
segmentId: this._currentSegmentId,
|
|
1830
|
-
segmentPage: this._currentSegmentPage
|
|
1831
|
-
});
|
|
1832
|
-
if (startNode == null || startNode.node == null)
|
|
1833
|
-
return;
|
|
1834
|
-
const paragraphInfo = getParagraphInfoByGlyph(startNode.node);
|
|
1835
|
-
if (paragraphInfo == null)
|
|
1836
|
-
return;
|
|
1837
|
-
const { content, st, nodeIndex } = paragraphInfo;
|
|
1838
|
-
if (nodeIndex === -1 || Intl.Segmenter == null)
|
|
1839
|
-
return;
|
|
1840
|
-
const segments = new Intl.Segmenter(void 0, { granularity: "word" }).segment(content);
|
|
1841
|
-
let startOffset = Number.NEGATIVE_INFINITY, endOffset = Number.NEGATIVE_INFINITY;
|
|
1842
|
-
for (const { segment, index, isWordLike } of segments)
|
|
1843
|
-
if (index <= nodeIndex && nodeIndex < index + segment.length && isWordLike) {
|
|
1844
|
-
startOffset = index + st, endOffset = index + st + segment.length;
|
|
1845
|
-
break;
|
|
356
|
+
unitId,
|
|
357
|
+
actions: [],
|
|
358
|
+
textRanges
|
|
1846
359
|
}
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
}
|
|
1854
|
-
];
|
|
1855
|
-
this.addDocRanges(textRanges, !1, { forceFocus: !0 });
|
|
360
|
+
};
|
|
361
|
+
options && (doMutation.params.options = options);
|
|
362
|
+
const rawActions = [], jsonX = JSONX.getInstance();
|
|
363
|
+
if (!Tools.diffValue(body, prevBody)) {
|
|
364
|
+
const actions = jsonX.replaceOp(["body"], prevBody, body);
|
|
365
|
+
actions != null && rawActions.push(actions);
|
|
1856
366
|
}
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
strict: !1,
|
|
1861
|
-
segmentId: this._currentSegmentId,
|
|
1862
|
-
segmentPage: this._currentSegmentPage
|
|
1863
|
-
});
|
|
1864
|
-
if (startNode == null || startNode.node == null)
|
|
1865
|
-
return;
|
|
1866
|
-
const paragraphInfo = getParagraphInfoByGlyph(startNode.node);
|
|
1867
|
-
if (paragraphInfo == null)
|
|
1868
|
-
return;
|
|
1869
|
-
this.removeAllRanges();
|
|
1870
|
-
const { st, ed } = paragraphInfo, textRanges = [
|
|
1871
|
-
{
|
|
1872
|
-
startOffset: st,
|
|
1873
|
-
endOffset: ed
|
|
1874
|
-
}
|
|
1875
|
-
];
|
|
1876
|
-
this.addDocRanges(textRanges, !1, { forceFocus: !0 });
|
|
1877
|
-
}
|
|
1878
|
-
// Handle pointer down.
|
|
1879
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1880
|
-
__onPointDown(evt) {
|
|
1881
|
-
var _a28, _b2;
|
|
1882
|
-
this._editorFocusing = !0;
|
|
1883
|
-
const { scene, mainComponent } = this._context, skeleton = this._docSkeletonManagerService.getSkeleton(), { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this._findNodeByCoord(evtOffsetX, evtOffsetY, {
|
|
1884
|
-
strict: !1,
|
|
1885
|
-
segmentId: this._currentSegmentId,
|
|
1886
|
-
segmentPage: this._currentSegmentPage
|
|
1887
|
-
}), position = this._getNodePosition(startNode);
|
|
1888
|
-
if (position == null || startNode == null) {
|
|
1889
|
-
this._removeAllRanges();
|
|
1890
|
-
return;
|
|
367
|
+
if (!Tools.diffValue(tableSource, prevTableSource)) {
|
|
368
|
+
const actions = jsonX.replaceOp(["tableSource"], prevTableSource, tableSource);
|
|
369
|
+
actions != null && rawActions.push(actions);
|
|
1891
370
|
}
|
|
1892
|
-
(
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
const nodeCharIndex = skeleton.findCharIndexByPosition(position);
|
|
1896
|
-
if (typeof nodeCharIndex == "number" && docSelection.textRanges.some((textRange) => textRange.startOffset <= nodeCharIndex && textRange.endOffset > nodeCharIndex) || typeof nodeCharIndex == "number" && docSelection.rectRanges.some((rectRange) => rectRange.startOffset <= nodeCharIndex && rectRange.endOffset >= nodeCharIndex))
|
|
1897
|
-
return;
|
|
371
|
+
if (!Tools.diffValue(footers, prevFooters)) {
|
|
372
|
+
const actions = jsonX.replaceOp(["footers"], prevFooters, footers);
|
|
373
|
+
actions != null && rawActions.push(actions);
|
|
1898
374
|
}
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
this._scrollTimers.push(scrollTimer), scrollTimer.startScroll(evtOffsetX, evtOffsetY), this._onSelectionStart$.next((_a28 = this._getActiveRangeInstance()) == null ? void 0 : _a28.startNodePosition), (_b2 = scene.getTransformer()) == null || _b2.clearSelectedObjects();
|
|
1903
|
-
let preMoveOffsetX = evtOffsetX, preMoveOffsetY = evtOffsetY;
|
|
1904
|
-
this._scenePointerMoveSubs.push(scene.onPointerMove$.subscribeEvent((moveEvt) => {
|
|
1905
|
-
const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;
|
|
1906
|
-
scene.setCursor(CURSOR_TYPE.TEXT), !(Math.sqrt((moveOffsetX - preMoveOffsetX) ** 2 + (moveOffsetY - preMoveOffsetY) ** 2) < 3) && (this._moving(moveOffsetX, moveOffsetY), scrollTimer.scrolling(moveOffsetX, moveOffsetY, () => {
|
|
1907
|
-
this._moving(moveOffsetX, moveOffsetY);
|
|
1908
|
-
}), preMoveOffsetX = moveOffsetX, preMoveOffsetY = moveOffsetY);
|
|
1909
|
-
})), this._scenePointerUpSubs.push(scene.onPointerUp$.subscribeEvent(() => {
|
|
1910
|
-
if ([...this._scenePointerMoveSubs, ...this._scenePointerUpSubs].forEach((e) => {
|
|
1911
|
-
e.unsubscribe();
|
|
1912
|
-
}), scene.enableObjectsEvent(), this._anchorNodePosition && !this._focusNodePosition) {
|
|
1913
|
-
if (evt.ctrlKey) {
|
|
1914
|
-
this._disposeScrollTimers();
|
|
1915
|
-
return;
|
|
1916
|
-
}
|
|
1917
|
-
const textRange = new TextRange(scene, mainComponent, skeleton, this._anchorNodePosition, void 0, this._selectionStyle, this._currentSegmentId, this._currentSegmentPage);
|
|
1918
|
-
this._addTextRange(textRange);
|
|
1919
|
-
} else if (this._anchorNodePosition && this._focusNodePosition) {
|
|
1920
|
-
for (const textRange of this._rangeListCache)
|
|
1921
|
-
evt.ctrlKey ? textRange.collapsed ? textRange.dispose() : this._addTextRange(textRange) : this._addTextRange(textRange);
|
|
1922
|
-
this._addRectRanges(this._rectRangeListCache), this._rangeListCache = [], this._rectRangeListCache = [];
|
|
1923
|
-
}
|
|
1924
|
-
this._anchorNodePosition = null, this._focusNodePosition = null;
|
|
1925
|
-
const selectionInfo = {
|
|
1926
|
-
textRanges: this._getAllTextRanges(),
|
|
1927
|
-
rectRanges: this._getAllRectRanges(),
|
|
1928
|
-
segmentId: this._currentSegmentId,
|
|
1929
|
-
segmentPage: this._currentSegmentPage,
|
|
1930
|
-
style: this._selectionStyle,
|
|
1931
|
-
isEditing: !1
|
|
1932
|
-
};
|
|
1933
|
-
this._textSelectionInner$.next(selectionInfo), this._disposeScrollTimers(), this._updateInputPosition(!0);
|
|
1934
|
-
}));
|
|
1935
|
-
}
|
|
1936
|
-
removeAllRanges() {
|
|
1937
|
-
this._removeAllRanges(), this.deactivate();
|
|
1938
|
-
}
|
|
1939
|
-
getActiveTextRange() {
|
|
1940
|
-
return this._getActiveRangeInstance();
|
|
1941
|
-
}
|
|
1942
|
-
_disposeScrollTimers() {
|
|
1943
|
-
this._scrollTimers.forEach((timer) => {
|
|
1944
|
-
timer == null || timer.dispose();
|
|
1945
|
-
}), this._scrollTimers = [];
|
|
1946
|
-
}
|
|
1947
|
-
_setSystemHighlightColorToStyle() {
|
|
1948
|
-
const { r: r2, g, b, a } = getSystemHighlightColor(), style = {
|
|
1949
|
-
strokeWidth: 1.5,
|
|
1950
|
-
stroke: "rgba(0, 0, 0, 0)",
|
|
1951
|
-
strokeActive: "rgba(0, 0, 0, 1)",
|
|
1952
|
-
fill: `rgba(${r2}, ${g}, ${b}, ${a != null ? a : 0.3})`
|
|
1953
|
-
};
|
|
1954
|
-
this._setRangeStyle(style);
|
|
1955
|
-
}
|
|
1956
|
-
_getAllTextRanges() {
|
|
1957
|
-
return this._rangeList.map(serializeTextRange);
|
|
1958
|
-
}
|
|
1959
|
-
_getAllRectRanges() {
|
|
1960
|
-
return this._rectRangeList.map(serializeRectRange);
|
|
1961
|
-
}
|
|
1962
|
-
_getActiveRange() {
|
|
1963
|
-
const activeRange = this._rangeList.find((range) => range.isActive());
|
|
1964
|
-
if (activeRange == null)
|
|
1965
|
-
return null;
|
|
1966
|
-
const { startOffset, endOffset } = activeRange;
|
|
1967
|
-
return startOffset == null || endOffset == null ? null : serializeTextRange(activeRange);
|
|
1968
|
-
}
|
|
1969
|
-
_getActiveRangeInstance() {
|
|
1970
|
-
return this._rangeList.find((range) => range.isActive());
|
|
1971
|
-
}
|
|
1972
|
-
dispose() {
|
|
1973
|
-
super.dispose(), this._detachEvent(), this._removeAllRanges(), this._container.remove();
|
|
1974
|
-
}
|
|
1975
|
-
_initDOM() {
|
|
1976
|
-
const { unitId } = this._context, container = document.createElement("div");
|
|
1977
|
-
container.style.position = "fixed", container.style.left = "0px", container.style.top = "0px", container.id = `univer-doc-selection-container-${unitId}`;
|
|
1978
|
-
const inputParent = document.createElement("div"), inputDom = document.createElement("div");
|
|
1979
|
-
inputParent.appendChild(inputDom), container.appendChild(inputParent), this._container = container, this._inputParent = inputParent, this._input = inputDom, this._initInput(), this._initInputEvents(), document.body.appendChild(container);
|
|
1980
|
-
}
|
|
1981
|
-
_registerContainer() {
|
|
1982
|
-
this.disposeWithMe(
|
|
1983
|
-
// the content editable div should be regarded as part of the applications container
|
|
1984
|
-
this._layoutService.registerContainerElement(this._container)
|
|
1985
|
-
);
|
|
1986
|
-
}
|
|
1987
|
-
_initInput() {
|
|
1988
|
-
this._inputParent.style.cssText = `
|
|
1989
|
-
position:absolute;
|
|
1990
|
-
height:1px;
|
|
1991
|
-
width:1px;
|
|
1992
|
-
overflow: hidden;
|
|
1993
|
-
`, this._input.contentEditable = "true", this._input.classList.add("univer-editor"), this._input.style.cssText = `
|
|
1994
|
-
position: absolute;
|
|
1995
|
-
overflow: hidden;
|
|
1996
|
-
opacity: 1;
|
|
1997
|
-
background: #000;
|
|
1998
|
-
color: transparent;
|
|
1999
|
-
outline: none;
|
|
2000
|
-
z-index: -2;
|
|
2001
|
-
caret-color: transparent;
|
|
2002
|
-
white-space: pre-wrap;
|
|
2003
|
-
user-select: text;
|
|
2004
|
-
`;
|
|
2005
|
-
}
|
|
2006
|
-
_getNodePosition(node) {
|
|
2007
|
-
if (node == null)
|
|
2008
|
-
return;
|
|
2009
|
-
const { node: glyph, ratioX, segmentPage } = node, position = this._docSkeletonManagerService.getSkeleton().findPositionByGlyph(glyph, segmentPage);
|
|
2010
|
-
if (position == null)
|
|
2011
|
-
return;
|
|
2012
|
-
const isBack = ratioX < 0.5;
|
|
2013
|
-
return {
|
|
2014
|
-
...position,
|
|
2015
|
-
isBack
|
|
2016
|
-
};
|
|
2017
|
-
}
|
|
2018
|
-
_interactTextRanges(textRanges) {
|
|
2019
|
-
const newTextRanges = [];
|
|
2020
|
-
for (const range of this._rangeList) {
|
|
2021
|
-
if (textRanges.some((textRange) => textRange.isIntersection(range))) {
|
|
2022
|
-
range.dispose();
|
|
2023
|
-
continue;
|
|
2024
|
-
}
|
|
2025
|
-
newTextRanges.push(range);
|
|
375
|
+
if (!Tools.diffValue(headers, prevHeaders)) {
|
|
376
|
+
const actions = jsonX.replaceOp(["headers"], prevHeaders, headers);
|
|
377
|
+
actions != null && rawActions.push(actions);
|
|
2026
378
|
}
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
const newRanges = [];
|
|
2031
|
-
for (const range of this._rectRangeList) {
|
|
2032
|
-
if (rectRanges.some((rectRange) => rectRange.isIntersection(range))) {
|
|
2033
|
-
range.dispose();
|
|
2034
|
-
continue;
|
|
2035
|
-
}
|
|
2036
|
-
newRanges.push(range);
|
|
379
|
+
if (!Tools.diffValue(lists, prevLists)) {
|
|
380
|
+
const actions = jsonX.replaceOp(["lists"], prevLists, lists);
|
|
381
|
+
actions != null && rawActions.push(actions);
|
|
2037
382
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
const oldTextRanges = this._rangeList;
|
|
2042
|
-
this._rangeList = [];
|
|
2043
|
-
for (const textRange of oldTextRanges)
|
|
2044
|
-
textRange.collapsed ? textRange.dispose() : this._rangeList.push(textRange);
|
|
2045
|
-
}
|
|
2046
|
-
_removeAllRanges() {
|
|
2047
|
-
this._removeAllTextRanges(), this._removeAllRectRanges();
|
|
2048
|
-
}
|
|
2049
|
-
_removeAllCacheRanges() {
|
|
2050
|
-
this._rangeListCache.forEach((range) => {
|
|
2051
|
-
range.dispose();
|
|
2052
|
-
}), this._rectRangeListCache.forEach((range) => {
|
|
2053
|
-
range.dispose();
|
|
2054
|
-
}), this._rangeListCache = [], this._rectRangeListCache = [];
|
|
2055
|
-
}
|
|
2056
|
-
_removeAllTextRanges() {
|
|
2057
|
-
this._rangeList.forEach((range) => {
|
|
2058
|
-
range.dispose();
|
|
2059
|
-
}), this._rangeList = [];
|
|
2060
|
-
}
|
|
2061
|
-
_removeAllRectRanges() {
|
|
2062
|
-
this._rectRangeList.forEach((range) => {
|
|
2063
|
-
range.dispose();
|
|
2064
|
-
}), this._rectRangeList = [];
|
|
2065
|
-
}
|
|
2066
|
-
_removeAllCollapsedTextRanges() {
|
|
2067
|
-
for (const range of this._rangeList)
|
|
2068
|
-
range.collapsed && range.dispose();
|
|
2069
|
-
}
|
|
2070
|
-
_deactivateAllTextRanges() {
|
|
2071
|
-
this._rangeList.forEach((range) => {
|
|
2072
|
-
range.deactivate();
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
_deactivateAllRectRanges() {
|
|
2076
|
-
this._rectRangeList.forEach((range) => {
|
|
2077
|
-
range.deactivate();
|
|
2078
|
-
});
|
|
2079
|
-
}
|
|
2080
|
-
_addTextRangesToCache(textRanges) {
|
|
2081
|
-
this._rangeListCache.push(...textRanges);
|
|
2082
|
-
}
|
|
2083
|
-
_addTextRange(textRange) {
|
|
2084
|
-
this._deactivateAllTextRanges(), textRange.activate(), this._rangeList.push(textRange);
|
|
2085
|
-
}
|
|
2086
|
-
_addRectRangesToCache(rectRanges) {
|
|
2087
|
-
this._rectRangeListCache.push(...rectRanges);
|
|
2088
|
-
}
|
|
2089
|
-
_addRectRanges(rectRanges) {
|
|
2090
|
-
rectRanges.length !== 0 && (this._deactivateAllRectRanges(), rectRanges[rectRanges.length - 1].activate(), this._rectRangeList.push(...rectRanges));
|
|
2091
|
-
}
|
|
2092
|
-
_createTextRangeByAnchorPosition(position) {
|
|
2093
|
-
this._removeAllRanges();
|
|
2094
|
-
const { scene, mainComponent } = this._context, skeleton = this._docSkeletonManagerService.getSkeleton(), lastRange = new TextRange(scene, mainComponent, skeleton, position, void 0, this._selectionStyle, this._currentSegmentId, this._currentSegmentPage);
|
|
2095
|
-
this._addTextRange(lastRange);
|
|
2096
|
-
}
|
|
2097
|
-
_updateActiveRangePosition(position) {
|
|
2098
|
-
const activeTextRange = this._getActiveRangeInstance();
|
|
2099
|
-
if (activeTextRange == null || activeTextRange.anchorNodePosition == null) {
|
|
2100
|
-
this._logService.error(
|
|
2101
|
-
"[DocSelectionRenderService] _updateActiveRangeFocusPosition: active range has no anchor"
|
|
2102
|
-
);
|
|
2103
|
-
return;
|
|
383
|
+
if (!Tools.diffValue(drawings, prevDrawings)) {
|
|
384
|
+
const actions = jsonX.replaceOp(["drawings"], prevDrawings, drawings);
|
|
385
|
+
actions != null && rawActions.push(actions);
|
|
2104
386
|
}
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
return;
|
|
2109
|
-
const ranges = getRangeListFromSelection(
|
|
2110
|
-
_anchorNodePosition,
|
|
2111
|
-
_focusNodePosition,
|
|
2112
|
-
scene,
|
|
2113
|
-
mainComponent,
|
|
2114
|
-
skeleton,
|
|
2115
|
-
_selectionStyle,
|
|
2116
|
-
_currentSegmentId,
|
|
2117
|
-
_currentSegmentPage
|
|
2118
|
-
);
|
|
2119
|
-
if (ranges == null)
|
|
2120
|
-
return;
|
|
2121
|
-
const { textRanges, rectRanges } = ranges;
|
|
2122
|
-
this._addTextRangesToCache(textRanges), this._addRectRangesToCache(rectRanges), this.deactivate();
|
|
2123
|
-
}
|
|
2124
|
-
_isEmpty() {
|
|
2125
|
-
return this._rangeList.length === 0 && this._rectRangeList.length === 0;
|
|
2126
|
-
}
|
|
2127
|
-
_getCanvasOffset() {
|
|
2128
|
-
var _a28;
|
|
2129
|
-
const engine = (_a28 = this._context.scene) == null ? void 0 : _a28.getEngine();
|
|
2130
|
-
return getCanvasOffsetByEngine(engine);
|
|
2131
|
-
}
|
|
2132
|
-
_updateInputPosition(forceFocus = !1) {
|
|
2133
|
-
const activeRangeInstance = this._getActiveRangeInstance(), anchor = activeRangeInstance == null ? void 0 : activeRangeInstance.getAnchor();
|
|
2134
|
-
if (!anchor || anchor && !anchor.visible || this.activeViewPort == null) {
|
|
2135
|
-
this.focus();
|
|
2136
|
-
return;
|
|
387
|
+
if (!Tools.diffValue(drawingsOrder, prevDrawingsOrder)) {
|
|
388
|
+
const actions = jsonX.replaceOp(["drawingsOrder"], prevDrawingsOrder, drawingsOrder);
|
|
389
|
+
actions != null && rawActions.push(actions);
|
|
2137
390
|
}
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
const
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
this._updateInputPosition();
|
|
2197
|
-
}
|
|
2198
|
-
});
|
|
2199
|
-
this._viewPortObserverMap.set(unitId, {
|
|
2200
|
-
scrollBefore,
|
|
2201
|
-
scrollStop
|
|
2202
|
-
});
|
|
2203
|
-
}
|
|
2204
|
-
// FIXME: listeners here are not correctly disposed
|
|
2205
|
-
// eslint-disable-next-line max-lines-per-function
|
|
2206
|
-
_initInputEvents() {
|
|
2207
|
-
this.disposeWithMe(
|
|
2208
|
-
fromEvent(this._input, "keydown").subscribe((e) => {
|
|
2209
|
-
this._isIMEInputApply || this._eventHandle(e, (config) => {
|
|
2210
|
-
this._onKeydown$.next(config);
|
|
2211
|
-
});
|
|
2212
|
-
})
|
|
2213
|
-
), this.disposeWithMe(
|
|
2214
|
-
fromEvent(this._input, "input").subscribe((e) => {
|
|
2215
|
-
if (!(e.inputType === "historyUndo" || e.inputType === "historyRedo")) {
|
|
2216
|
-
if (this._rectRangeList.length > 0)
|
|
2217
|
-
return e.stopPropagation(), e.preventDefault();
|
|
2218
|
-
this._isIMEInputApply || this._eventHandle(e, (config) => {
|
|
2219
|
-
this._onInputBefore$.next(config), this._onInput$.next(config);
|
|
2220
|
-
});
|
|
2221
|
-
}
|
|
2222
|
-
})
|
|
2223
|
-
), this.disposeWithMe(
|
|
2224
|
-
fromEvent(this._input, "compositionstart").subscribe((e) => {
|
|
2225
|
-
if (this._rectRangeList.length > 0)
|
|
2226
|
-
return e.stopPropagation(), e.preventDefault();
|
|
2227
|
-
this._isIMEInputApply = !0, this._eventHandle(e, (config) => {
|
|
2228
|
-
this._onCompositionstart$.next(config);
|
|
2229
|
-
});
|
|
2230
|
-
})
|
|
2231
|
-
), this.disposeWithMe(
|
|
2232
|
-
fromEvent(this._input, "compositionend").subscribe((e) => {
|
|
2233
|
-
this._isIMEInputApply = !1, this._eventHandle(e, (config) => {
|
|
2234
|
-
this._onCompositionend$.next(config);
|
|
2235
|
-
});
|
|
2236
|
-
})
|
|
2237
|
-
), this.disposeWithMe(
|
|
2238
|
-
fromEvent(this._input, "compositionupdate").subscribe((e) => {
|
|
2239
|
-
this._eventHandle(e, (config) => {
|
|
2240
|
-
this._onInputBefore$.next(config), this._onCompositionupdate$.next(config);
|
|
2241
|
-
});
|
|
2242
|
-
})
|
|
2243
|
-
), this.disposeWithMe(
|
|
2244
|
-
fromEvent(this._input, "paste").subscribe((e) => {
|
|
2245
|
-
this._eventHandle(e, (config) => {
|
|
2246
|
-
this._onPaste$.next(config);
|
|
2247
|
-
});
|
|
2248
|
-
})
|
|
2249
|
-
), this.disposeWithMe(
|
|
2250
|
-
fromEvent(this._input, "focus").subscribe((e) => {
|
|
2251
|
-
this._eventHandle(e, (config) => {
|
|
2252
|
-
this._onFocus$.next(config);
|
|
2253
|
-
});
|
|
2254
|
-
})
|
|
2255
|
-
), this.disposeWithMe(
|
|
2256
|
-
fromEvent(this._input, "blur").subscribe((e) => {
|
|
2257
|
-
this._eventHandle(e, (config) => {
|
|
2258
|
-
this._onBlur$.next(config);
|
|
2259
|
-
});
|
|
2260
|
-
})
|
|
2261
|
-
);
|
|
2262
|
-
}
|
|
2263
|
-
_eventHandle(e, func) {
|
|
2264
|
-
const content = this._input.textContent || "";
|
|
2265
|
-
this._input.innerHTML = "";
|
|
2266
|
-
const activeRange = this._getActiveRange(), rangeList = this._getAllTextRanges();
|
|
2267
|
-
func({
|
|
2268
|
-
event: e,
|
|
2269
|
-
content,
|
|
2270
|
-
activeRange,
|
|
2271
|
-
rangeList
|
|
2272
|
-
});
|
|
2273
|
-
}
|
|
2274
|
-
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
2275
|
-
const document2 = this._context.mainComponent, { documentTransform } = document2.getOffsetConfig();
|
|
2276
|
-
if (this.activeViewPort == null || documentTransform == null)
|
|
2277
|
-
return;
|
|
2278
|
-
const originCoord = this.activeViewPort.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
2279
|
-
if (originCoord)
|
|
2280
|
-
return documentTransform.clone().invert().applyPoint(originCoord);
|
|
2281
|
-
}
|
|
2282
|
-
_findNodeByCoord(evtOffsetX, evtOffsetY, restrictions) {
|
|
2283
|
-
const coord = this._getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY);
|
|
2284
|
-
if (coord == null)
|
|
2285
|
-
return;
|
|
2286
|
-
const document2 = this._context.mainComponent, skeleton = this._docSkeletonManagerService.getSkeleton(), {
|
|
2287
|
-
pageLayoutType = PageLayoutType.VERTICAL,
|
|
2288
|
-
pageMarginLeft,
|
|
2289
|
-
pageMarginTop
|
|
2290
|
-
} = document2.getOffsetConfig();
|
|
2291
|
-
return skeleton.findNodeByCoord(
|
|
2292
|
-
coord,
|
|
2293
|
-
pageLayoutType,
|
|
2294
|
-
pageMarginLeft,
|
|
2295
|
-
pageMarginTop,
|
|
2296
|
-
restrictions
|
|
2297
|
-
);
|
|
2298
|
-
}
|
|
2299
|
-
_detachEvent() {
|
|
2300
|
-
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
|
-
}
|
|
2302
|
-
}, __name(_a2, "DocSelectionRenderService"), _a2);
|
|
2303
|
-
DocSelectionRenderService = __decorateClass$q([
|
|
2304
|
-
__decorateParam$q(1, ILayoutService),
|
|
2305
|
-
__decorateParam$q(2, ILogService),
|
|
2306
|
-
__decorateParam$q(3, IUniverInstanceService),
|
|
2307
|
-
__decorateParam$q(4, Inject(DocSkeletonManagerService))
|
|
2308
|
-
], DocSelectionRenderService);
|
|
391
|
+
return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
392
|
+
}, "handler")
|
|
393
|
+
}, ReplaceContentCommand = {
|
|
394
|
+
id: "doc.command-replace-content",
|
|
395
|
+
type: CommandType.COMMAND,
|
|
396
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
397
|
+
const { unitId, body, textRanges, segmentId = "", options } = params, univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), prevBody = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getSnapshot().body;
|
|
398
|
+
if (docDataModel == null || prevBody == null)
|
|
399
|
+
return !1;
|
|
400
|
+
const doMutation = getMutationParams(unitId, segmentId, docDataModel, prevBody, body);
|
|
401
|
+
return doMutation.params.textRanges = textRanges, options && (doMutation.params.options = options), doMutation.params.actions == null && textRanges ? (docSelectionManagerService.replaceDocRanges(textRanges, {
|
|
402
|
+
unitId,
|
|
403
|
+
subUnitId: unitId
|
|
404
|
+
}, !1), !0) : !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
405
|
+
}, "handler")
|
|
406
|
+
}, CoverContentCommand = {
|
|
407
|
+
id: "doc.command-cover-content",
|
|
408
|
+
type: CommandType.COMMAND,
|
|
409
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
410
|
+
const { unitId, body, segmentId = "" } = params, univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), docDatModel = univerInstanceService.getUniverDocInstance(unitId), prevBody = docDatModel == null ? void 0 : docDatModel.getSnapshot().body;
|
|
411
|
+
if (docDatModel == null || prevBody == null)
|
|
412
|
+
return !1;
|
|
413
|
+
const doMutation = getMutationParams(unitId, segmentId, docDatModel, prevBody, body);
|
|
414
|
+
return doMutation.params.noNeedSetTextRange = !0, doMutation.params.noHistory = !0, commandService.syncExecuteCommand(
|
|
415
|
+
doMutation.id,
|
|
416
|
+
doMutation.params
|
|
417
|
+
), undoRedoService.clearUndoRedo(unitId), !0;
|
|
418
|
+
}, "handler")
|
|
419
|
+
};
|
|
420
|
+
function getMutationActions(segmentId, docDatModel, prevBody, body) {
|
|
421
|
+
const textX = new TextX(), jsonX = JSONX.getInstance(), deleteLen = (prevBody == null ? void 0 : prevBody.dataStream.length) - 2;
|
|
422
|
+
deleteLen > 0 && textX.push({
|
|
423
|
+
t: TextXActionType.DELETE,
|
|
424
|
+
len: deleteLen
|
|
425
|
+
}), body.dataStream.length > 0 && textX.push({
|
|
426
|
+
t: TextXActionType.INSERT,
|
|
427
|
+
body,
|
|
428
|
+
len: body.dataStream.length
|
|
429
|
+
});
|
|
430
|
+
const path = getRichTextEditPath(docDatModel, segmentId);
|
|
431
|
+
return jsonX.editOp(textX.serialize(), path);
|
|
432
|
+
}
|
|
433
|
+
__name(getMutationActions, "getMutationActions");
|
|
434
|
+
function getMutationParams(unitId, segmentId, docDatModel, prevBody, body) {
|
|
435
|
+
const doMutation = {
|
|
436
|
+
id: RichTextEditingMutation.id,
|
|
437
|
+
params: {
|
|
438
|
+
unitId,
|
|
439
|
+
actions: [],
|
|
440
|
+
textRanges: []
|
|
441
|
+
}
|
|
442
|
+
}, actions = getMutationActions(segmentId, docDatModel, prevBody, body);
|
|
443
|
+
return doMutation.params.actions = actions, doMutation;
|
|
444
|
+
}
|
|
445
|
+
__name(getMutationParams, "getMutationParams");
|
|
446
|
+
CommandType.COMMAND;
|
|
2309
447
|
const _Editor = class _Editor extends Disposable {
|
|
2310
448
|
constructor(_param, _univerInstanceService, _docSelectionManagerService, _commandService, _undoRedoService) {
|
|
2311
449
|
super();
|
|
@@ -2599,11 +737,11 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2599
737
|
};
|
|
2600
738
|
__name(_Editor, "Editor");
|
|
2601
739
|
let Editor = _Editor;
|
|
2602
|
-
var __defProp$
|
|
2603
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
740
|
+
var __defProp$q = Object.defineProperty, __getOwnPropDesc$q = Object.getOwnPropertyDescriptor, __decorateClass$q = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
741
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2604
742
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2605
|
-
return kind && result && __defProp$
|
|
2606
|
-
}, "__decorateClass$
|
|
743
|
+
return kind && result && __defProp$q(target, key, result), result;
|
|
744
|
+
}, "__decorateClass$q"), __decorateParam$q = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$q");
|
|
2607
745
|
const editorFocusInElements = [
|
|
2608
746
|
"univer-editor",
|
|
2609
747
|
"univer-range-selector",
|
|
@@ -2701,7 +839,7 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2701
839
|
const editor = this.getEditor(editorUnitId);
|
|
2702
840
|
if (!editor)
|
|
2703
841
|
return !1;
|
|
2704
|
-
editor.setFocus(!0), this._contextService.setContextValue(EDITOR_ACTIVATED, !0), this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, !0), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, editor.isSingle()), this._spreadsheetFocusState || this.singleSelection(!!editor.isSingleChoice()), this._focusStyle$.next(editorUnitId), this.setFocusId(editorUnitId);
|
|
842
|
+
editor.setFocus(!0), this._contextService.setContextValue(EDITOR_ACTIVATED, !0), isInternalEditorID(editorUnitId) || (this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, !0), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, editor.isSingle())), this._spreadsheetFocusState || this.singleSelection(!!editor.isSingleChoice()), this._focusStyle$.next(editorUnitId), this.setFocusId(editorUnitId);
|
|
2705
843
|
}
|
|
2706
844
|
/** @deprecated */
|
|
2707
845
|
singleSelection(state) {
|
|
@@ -2731,8 +869,8 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2731
869
|
this._univerInstanceService.setCurrentUnitForType(editorUnitId);
|
|
2732
870
|
const valueCount = editor.getValue().length;
|
|
2733
871
|
this.focusStyle(editorUnitId), this._focus$.next({
|
|
2734
|
-
startOffset: valueCount
|
|
2735
|
-
endOffset: valueCount
|
|
872
|
+
startOffset: valueCount,
|
|
873
|
+
endOffset: valueCount
|
|
2736
874
|
});
|
|
2737
875
|
}
|
|
2738
876
|
/** @deprecated */
|
|
@@ -2896,14 +1034,14 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2896
1034
|
};
|
|
2897
1035
|
}
|
|
2898
1036
|
}, __name(_b, "EditorService"), _b);
|
|
2899
|
-
EditorService = __decorateClass$
|
|
2900
|
-
__decorateParam$
|
|
2901
|
-
__decorateParam$
|
|
2902
|
-
__decorateParam$
|
|
2903
|
-
__decorateParam$
|
|
2904
|
-
__decorateParam$
|
|
2905
|
-
__decorateParam$
|
|
2906
|
-
__decorateParam$
|
|
1037
|
+
EditorService = __decorateClass$q([
|
|
1038
|
+
__decorateParam$q(0, IUniverInstanceService),
|
|
1039
|
+
__decorateParam$q(1, IRenderManagerService),
|
|
1040
|
+
__decorateParam$q(2, Inject(LexerTreeBuilder)),
|
|
1041
|
+
__decorateParam$q(3, Inject(DocSelectionManagerService)),
|
|
1042
|
+
__decorateParam$q(4, IContextService),
|
|
1043
|
+
__decorateParam$q(5, ICommandService),
|
|
1044
|
+
__decorateParam$q(6, IUndoRedoService)
|
|
2907
1045
|
], EditorService);
|
|
2908
1046
|
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
1047
|
textEditorContainer,
|
|
@@ -2933,7 +1071,7 @@ function genSnapShotByValue(id = "", value = "") {
|
|
|
2933
1071
|
},
|
|
2934
1072
|
tableSource: {},
|
|
2935
1073
|
documentStyle: {
|
|
2936
|
-
documentFlavor: DocumentFlavor.
|
|
1074
|
+
documentFlavor: DocumentFlavor.UNSPECIFIED
|
|
2937
1075
|
}
|
|
2938
1076
|
};
|
|
2939
1077
|
}
|
|
@@ -3196,17 +1334,17 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width:
|
|
|
3196
1334
|
});
|
|
3197
1335
|
TodoList.displayName = "TodoList";
|
|
3198
1336
|
function r(e) {
|
|
3199
|
-
var t,
|
|
1337
|
+
var t, f3, n2 = "";
|
|
3200
1338
|
if (typeof e == "string" || typeof e == "number") n2 += e;
|
|
3201
1339
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
3202
1340
|
var o = e.length;
|
|
3203
|
-
for (t = 0; t < o; t++) e[t] && (
|
|
3204
|
-
} else for (
|
|
1341
|
+
for (t = 0; t < o; t++) e[t] && (f3 = r(e[t])) && (n2 && (n2 += " "), n2 += f3);
|
|
1342
|
+
} else for (f3 in e) e[f3] && (n2 && (n2 += " "), n2 += f3);
|
|
3205
1343
|
return n2;
|
|
3206
1344
|
}
|
|
3207
1345
|
__name(r, "r");
|
|
3208
1346
|
function clsx() {
|
|
3209
|
-
for (var e, t,
|
|
1347
|
+
for (var e, t, f3 = 0, n2 = "", o = arguments.length; f3 < o; f3++) (e = arguments[f3]) && (t = r(e)) && (n2 && (n2 += " "), n2 += t);
|
|
3210
1348
|
return n2;
|
|
3211
1349
|
}
|
|
3212
1350
|
__name(clsx, "clsx");
|
|
@@ -3436,7 +1574,7 @@ function getSegmentId(documentStyle, editArea, pageIndex) {
|
|
|
3436
1574
|
}
|
|
3437
1575
|
__name(getSegmentId, "getSegmentId");
|
|
3438
1576
|
const DocHeaderFooterOptions = /* @__PURE__ */ __name((props) => {
|
|
3439
|
-
const localeService = useDependency(LocaleService), univerInstanceService = useDependency(IUniverInstanceService), renderManagerService = useDependency(IRenderManagerService), commandService = useDependency(ICommandService),
|
|
1577
|
+
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) => {
|
|
3440
1578
|
var _a28;
|
|
3441
1579
|
setOptions((prev) => ({
|
|
3442
1580
|
...prev,
|
|
@@ -3486,12 +1624,9 @@ const DocHeaderFooterOptions = /* @__PURE__ */ __name((props) => {
|
|
|
3486
1624
|
}
|
|
3487
1625
|
}), docSelectionRenderService.removeAllRanges(), docSelectionRenderService.blur();
|
|
3488
1626
|
}, "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));
|
|
1627
|
+
commandService.executeCommand(CloseHeaderFooterCommand.id, {
|
|
1628
|
+
unitId
|
|
1629
|
+
});
|
|
3495
1630
|
}, "closeHeaderFooter");
|
|
3496
1631
|
return useEffect(() => {
|
|
3497
1632
|
const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle;
|
|
@@ -3633,11 +1768,11 @@ const _TextBubbleShape = class _TextBubbleShape extends Shape {
|
|
|
3633
1768
|
};
|
|
3634
1769
|
__name(_TextBubbleShape, "TextBubbleShape");
|
|
3635
1770
|
let TextBubbleShape = _TextBubbleShape;
|
|
3636
|
-
var __defProp$
|
|
3637
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1771
|
+
var __defProp$p = Object.defineProperty, __getOwnPropDesc$p = Object.getOwnPropertyDescriptor, __decorateClass$p = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1772
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
3638
1773
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
3639
|
-
return kind && result && __defProp$
|
|
3640
|
-
}, "__decorateClass$
|
|
1774
|
+
return kind && result && __defProp$p(target, key, result), result;
|
|
1775
|
+
}, "__decorateClass$p"), __decorateParam$p = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$p");
|
|
3641
1776
|
const HEADER_FOOTER_STROKE_COLOR = "rgba(58, 96, 247, 1)", HEADER_FOOTER_FILL_COLOR = "rgba(58, 96, 247, 0.08)";
|
|
3642
1777
|
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
1778
|
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
|
|
@@ -3690,15 +1825,28 @@ function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
|
|
|
3690
1825
|
}
|
|
3691
1826
|
}
|
|
3692
1827
|
__name(checkCreateHeaderFooterType, "checkCreateHeaderFooterType");
|
|
3693
|
-
var
|
|
3694
|
-
let DocHeaderFooterController = (
|
|
1828
|
+
var _a2;
|
|
1829
|
+
let DocHeaderFooterController = (_a2 = class extends Disposable {
|
|
3695
1830
|
constructor(_context, _commandService, _editorService, _instanceSrv, _renderManagerService, _docSkeletonManagerService, _docSelectionRenderService, _localeService, _componentManager) {
|
|
3696
1831
|
super();
|
|
3697
1832
|
__publicField(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
3698
1833
|
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
1834
|
}
|
|
3700
1835
|
_initialize() {
|
|
3701
|
-
this.
|
|
1836
|
+
this._init(), this._drawHeaderFooterLabel(), this._initCustomComponents(), this._listenSwitchMode();
|
|
1837
|
+
}
|
|
1838
|
+
// Close header footer panel when switch mode.
|
|
1839
|
+
_listenSwitchMode() {
|
|
1840
|
+
this.disposeWithMe(
|
|
1841
|
+
this._commandService.onCommandExecuted((command) => {
|
|
1842
|
+
if (RichTextEditingMutation.id === command.id) {
|
|
1843
|
+
const docDataModel = this._context.unit, editArea = this._docSkeletonManagerService.getViewModel().getEditArea(), documentFlavor = docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
1844
|
+
editArea !== DocumentEditArea.BODY && documentFlavor === DocumentFlavor.MODERN && this._commandService.executeCommand(CloseHeaderFooterCommand.id, {
|
|
1845
|
+
unitId: this._context.unitId
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
})
|
|
1849
|
+
);
|
|
3702
1850
|
}
|
|
3703
1851
|
_initCustomComponents() {
|
|
3704
1852
|
const componentManager = this._componentManager;
|
|
@@ -3709,15 +1857,15 @@ let DocHeaderFooterController = (_a3 = class extends Disposable {
|
|
|
3709
1857
|
docObject == null || docObject.document == null || this._loadedMap.has(docObject.document) || (this._initialMain(unitId), this._loadedMap.add(docObject.document));
|
|
3710
1858
|
}
|
|
3711
1859
|
_initialMain(unitId) {
|
|
3712
|
-
const docObject = neoGetDocObject(this._context), { document
|
|
3713
|
-
this.disposeWithMe(
|
|
3714
|
-
if (this._isEditorReadOnly(unitId))
|
|
1860
|
+
const docObject = neoGetDocObject(this._context), { document } = docObject;
|
|
1861
|
+
this.disposeWithMe(document.onDblclick$.subscribeEvent(async (evt) => {
|
|
1862
|
+
if (this._isEditorReadOnly(unitId) || !this._isTraditionalMode())
|
|
3715
1863
|
return;
|
|
3716
1864
|
const { offsetX, offsetY } = evt, {
|
|
3717
1865
|
pageLayoutType = PageLayoutType.VERTICAL,
|
|
3718
1866
|
pageMarginLeft,
|
|
3719
1867
|
pageMarginTop
|
|
3720
|
-
} =
|
|
1868
|
+
} = document.getOffsetConfig(), coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
|
|
3721
1869
|
if (coord == null)
|
|
3722
1870
|
return;
|
|
3723
1871
|
const viewModel = this._docSkeletonManagerService.getViewModel(), skeleton = this._docSkeletonManagerService.getSkeleton(), preEditArea = viewModel.getEditArea(), { editArea, pageNumber } = skeleton.findEditAreaByCoord(
|
|
@@ -3743,7 +1891,7 @@ let DocHeaderFooterController = (_a3 = class extends Disposable {
|
|
|
3743
1891
|
}));
|
|
3744
1892
|
}
|
|
3745
1893
|
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
3746
|
-
const docObject = neoGetDocObject(this._context), { document
|
|
1894
|
+
const docObject = neoGetDocObject(this._context), { document, scene } = docObject, { documentTransform } = document.getOffsetConfig(), activeViewport = scene.getViewports()[0];
|
|
3747
1895
|
if (activeViewport == null)
|
|
3748
1896
|
return;
|
|
3749
1897
|
const originCoord = activeViewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
@@ -3756,7 +1904,7 @@ let DocHeaderFooterController = (_a3 = class extends Disposable {
|
|
|
3756
1904
|
if (unitId == null)
|
|
3757
1905
|
return;
|
|
3758
1906
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
3759
|
-
if (this._editorService.isEditor(unitId) || this._instanceSrv.getUniverDocInstance(unitId) == null || currentRender == null)
|
|
1907
|
+
if (this._editorService.isEditor(unitId) || this._instanceSrv.getUniverDocInstance(unitId) == null || !this._isTraditionalMode() || currentRender == null)
|
|
3760
1908
|
return;
|
|
3761
1909
|
const { mainComponent } = currentRender, docsComponent = mainComponent;
|
|
3762
1910
|
this.disposeWithMe(
|
|
@@ -3824,19 +1972,22 @@ let DocHeaderFooterController = (_a3 = class extends Disposable {
|
|
|
3824
1972
|
const editor = this._editorService.getEditor(unitId);
|
|
3825
1973
|
return editor ? editor.isReadOnly() : !1;
|
|
3826
1974
|
}
|
|
1975
|
+
_isTraditionalMode() {
|
|
1976
|
+
return this._context.unit.getSnapshot().documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL;
|
|
1977
|
+
}
|
|
3827
1978
|
_getDocDataModel() {
|
|
3828
1979
|
return this._context.unit;
|
|
3829
1980
|
}
|
|
3830
|
-
}, __name(
|
|
3831
|
-
DocHeaderFooterController = __decorateClass$
|
|
3832
|
-
__decorateParam$
|
|
3833
|
-
__decorateParam$
|
|
3834
|
-
__decorateParam$
|
|
3835
|
-
__decorateParam$
|
|
3836
|
-
__decorateParam$
|
|
3837
|
-
__decorateParam$
|
|
3838
|
-
__decorateParam$
|
|
3839
|
-
__decorateParam$
|
|
1981
|
+
}, __name(_a2, "DocHeaderFooterController"), _a2);
|
|
1982
|
+
DocHeaderFooterController = __decorateClass$p([
|
|
1983
|
+
__decorateParam$p(1, ICommandService),
|
|
1984
|
+
__decorateParam$p(2, IEditorService),
|
|
1985
|
+
__decorateParam$p(3, IUniverInstanceService),
|
|
1986
|
+
__decorateParam$p(4, IRenderManagerService),
|
|
1987
|
+
__decorateParam$p(5, Inject(DocSkeletonManagerService)),
|
|
1988
|
+
__decorateParam$p(6, Inject(DocSelectionRenderService)),
|
|
1989
|
+
__decorateParam$p(7, Inject(LocaleService)),
|
|
1990
|
+
__decorateParam$p(8, Inject(ComponentManager))
|
|
3840
1991
|
], DocHeaderFooterController);
|
|
3841
1992
|
const SidebarDocHeaderFooterPanelOperation = {
|
|
3842
1993
|
id: "sidebar.operation.doc-header-footer-panel",
|
|
@@ -3926,12 +2077,12 @@ function createHeaderFooterAction(segmentId, createType, documentStyle, actions)
|
|
|
3926
2077
|
default:
|
|
3927
2078
|
throw new Error(`Unknown header footer type: ${createType}`);
|
|
3928
2079
|
}
|
|
3929
|
-
for (const [
|
|
3930
|
-
if (documentStyle[
|
|
3931
|
-
const replaceAction = jsonX.replaceOp(["documentStyle",
|
|
2080
|
+
for (const [k3, id] of [[key, firstSegmentId], [pairKey, secondSegmentId]])
|
|
2081
|
+
if (documentStyle[k3] != null) {
|
|
2082
|
+
const replaceAction = jsonX.replaceOp(["documentStyle", k3], documentStyle[k3], id);
|
|
3932
2083
|
actions.push(replaceAction);
|
|
3933
2084
|
} else {
|
|
3934
|
-
const insertAction2 = jsonX.insertOp(["documentStyle",
|
|
2085
|
+
const insertAction2 = jsonX.insertOp(["documentStyle", k3], id);
|
|
3935
2086
|
actions.push(insertAction2);
|
|
3936
2087
|
}
|
|
3937
2088
|
return actions;
|
|
@@ -3979,6 +2130,17 @@ const CoreHeaderFooterCommandId = "doc.command.core-header-footer", CoreHeaderFo
|
|
|
3979
2130
|
id: "doc.command.open-header-footer-panel",
|
|
3980
2131
|
type: CommandType.COMMAND,
|
|
3981
2132
|
handler: /* @__PURE__ */ __name(async (accessor, _params) => accessor.get(ICommandService).executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" }), "handler")
|
|
2133
|
+
}, CloseHeaderFooterCommand = {
|
|
2134
|
+
id: "doc.command.close-header-footer",
|
|
2135
|
+
type: CommandType.COMMAND,
|
|
2136
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2137
|
+
var _a28;
|
|
2138
|
+
const commandService = accessor.get(ICommandService), renderManagerService = accessor.get(IRenderManagerService), docSelectionManagerService = accessor.get(DocSelectionManagerService), { unitId } = params, renderObject = renderManagerService.getRenderById(unitId);
|
|
2139
|
+
if (renderObject == null)
|
|
2140
|
+
return !1;
|
|
2141
|
+
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();
|
|
2142
|
+
return viewModel == null || skeleton == null ? !1 : (docSelectionManagerService.replaceDocRanges([]), transformer.clearSelectedObjects(), docSelectionRenderService.setSegment(""), docSelectionRenderService.setSegmentPage(-1), viewModel.setEditArea(DocumentEditArea.BODY), skeleton.calculate(), (_a28 = renderObject.mainComponent) == null || _a28.makeDirty(!0), commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" }), !0);
|
|
2143
|
+
}, "handler")
|
|
3982
2144
|
}, 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
2145
|
docListTypePicker,
|
|
3984
2146
|
docListTypePickerItem,
|
|
@@ -4099,7 +2261,44 @@ const TabShortCut = {
|
|
|
4099
2261
|
staticParameters: {
|
|
4100
2262
|
shift: !0
|
|
4101
2263
|
}
|
|
4102
|
-
};
|
|
2264
|
+
};
|
|
2265
|
+
var __defProp$o = Object.defineProperty, __getOwnPropDesc$o = Object.getOwnPropertyDescriptor, __decorateClass$o = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2266
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2267
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2268
|
+
return kind && result && __defProp$o(target, key, result), result;
|
|
2269
|
+
}, "__decorateClass$o"), __decorateParam$o = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$o"), _a3;
|
|
2270
|
+
let DocMenuStyleService = (_a3 = class extends Disposable {
|
|
2271
|
+
constructor(_textSelectionManagerService) {
|
|
2272
|
+
super();
|
|
2273
|
+
__publicField(this, "_cacheStyle", null);
|
|
2274
|
+
this._textSelectionManagerService = _textSelectionManagerService, this._init();
|
|
2275
|
+
}
|
|
2276
|
+
_init() {
|
|
2277
|
+
this._listenDocRangeChange();
|
|
2278
|
+
}
|
|
2279
|
+
_listenDocRangeChange() {
|
|
2280
|
+
this.disposeWithMe(
|
|
2281
|
+
this._textSelectionManagerService.textSelection$.subscribe(() => {
|
|
2282
|
+
this._clearStyleCache();
|
|
2283
|
+
})
|
|
2284
|
+
);
|
|
2285
|
+
}
|
|
2286
|
+
getStyleCache() {
|
|
2287
|
+
return this._cacheStyle;
|
|
2288
|
+
}
|
|
2289
|
+
setStyleCache(style) {
|
|
2290
|
+
this._cacheStyle = {
|
|
2291
|
+
...this._cacheStyle,
|
|
2292
|
+
...style
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2295
|
+
_clearStyleCache() {
|
|
2296
|
+
this._cacheStyle = null;
|
|
2297
|
+
}
|
|
2298
|
+
}, __name(_a3, "DocMenuStyleService"), _a3);
|
|
2299
|
+
DocMenuStyleService = __decorateClass$o([
|
|
2300
|
+
__decorateParam$o(0, Inject(DocSelectionManagerService))
|
|
2301
|
+
], DocMenuStyleService);
|
|
4103
2302
|
function handleInlineFormat(preCommandId, params, commandService) {
|
|
4104
2303
|
return commandService.executeCommand(SetInlineFormatCommand.id, {
|
|
4105
2304
|
preCommandId,
|
|
@@ -4245,10 +2444,10 @@ const SetInlineFormatBoldCommandId = "doc.command.set-inline-format-bold", SetIn
|
|
|
4245
2444
|
type: CommandType.COMMAND,
|
|
4246
2445
|
// eslint-disable-next-line max-lines-per-function
|
|
4247
2446
|
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();
|
|
2447
|
+
const { value, preCommandId } = params, commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), docMenuStyleService = accessor.get(DocMenuStyleService), docRanges = docSelectionManagerService.getDocRanges();
|
|
4249
2448
|
if (docRanges.length === 0)
|
|
4250
2449
|
return !1;
|
|
4251
|
-
const segmentId = docRanges[0].segmentId, docDataModel = univerInstanceService.
|
|
2450
|
+
const segmentId = docRanges[0].segmentId, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
4252
2451
|
if (docDataModel == null)
|
|
4253
2452
|
return !1;
|
|
4254
2453
|
const unitId = docDataModel.getUnitId();
|
|
@@ -4301,6 +2500,14 @@ const SetInlineFormatBoldCommandId = "doc.command.set-inline-format-bold", SetIn
|
|
|
4301
2500
|
const { startOffset, endOffset } = range;
|
|
4302
2501
|
if (startOffset == null || endOffset == null)
|
|
4303
2502
|
continue;
|
|
2503
|
+
if (startOffset === endOffset) {
|
|
2504
|
+
docMenuStyleService.setStyleCache(
|
|
2505
|
+
{
|
|
2506
|
+
[COMMAND_ID_TO_FORMAT_KEY_MAP[preCommandId]]: formatValue
|
|
2507
|
+
}
|
|
2508
|
+
);
|
|
2509
|
+
continue;
|
|
2510
|
+
}
|
|
4304
2511
|
const body = {
|
|
4305
2512
|
dataStream: "",
|
|
4306
2513
|
textRuns: [
|
|
@@ -4315,13 +2522,11 @@ const SetInlineFormatBoldCommandId = "doc.command.set-inline-format-bold", SetIn
|
|
|
4315
2522
|
}, len = startOffset - memoryCursor.cursor;
|
|
4316
2523
|
len !== 0 && textX.push({
|
|
4317
2524
|
t: TextXActionType.RETAIN,
|
|
4318
|
-
len
|
|
4319
|
-
segmentId
|
|
2525
|
+
len
|
|
4320
2526
|
}), textX.push({
|
|
4321
2527
|
t: TextXActionType.RETAIN,
|
|
4322
2528
|
body,
|
|
4323
|
-
len: endOffset - startOffset
|
|
4324
|
-
segmentId
|
|
2529
|
+
len: endOffset - startOffset
|
|
4325
2530
|
}), memoryCursor.reset(), memoryCursor.moveCursor(endOffset);
|
|
4326
2531
|
}
|
|
4327
2532
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -4545,8 +2750,7 @@ const ChangeListNestingLevelCommand = {
|
|
|
4545
2750
|
len: paragraphStart
|
|
4546
2751
|
}), textX.push({
|
|
4547
2752
|
t: TextXActionType.DELETE,
|
|
4548
|
-
len: paragraphEnd - paragraphStart
|
|
4549
|
-
line: 1
|
|
2753
|
+
len: paragraphEnd - paragraphStart
|
|
4550
2754
|
}), textX.push({
|
|
4551
2755
|
t: TextXActionType.RETAIN,
|
|
4552
2756
|
len: 1,
|
|
@@ -4643,8 +2847,7 @@ const AlignOperationCommand = {
|
|
|
4643
2847
|
const { startIndex } = paragraph;
|
|
4644
2848
|
textX.push({
|
|
4645
2849
|
t: TextXActionType.RETAIN,
|
|
4646
|
-
len: startIndex - memoryCursor.cursor
|
|
4647
|
-
segmentId
|
|
2850
|
+
len: startIndex - memoryCursor.cursor
|
|
4648
2851
|
});
|
|
4649
2852
|
const paragraphStyle = {
|
|
4650
2853
|
...paragraph.paragraphStyle,
|
|
@@ -4663,7 +2866,6 @@ const AlignOperationCommand = {
|
|
|
4663
2866
|
}
|
|
4664
2867
|
]
|
|
4665
2868
|
},
|
|
4666
|
-
segmentId,
|
|
4667
2869
|
coverType: UpdateDocsAttributeType.REPLACE
|
|
4668
2870
|
}), memoryCursor.moveCursorTo(startIndex + 1);
|
|
4669
2871
|
}
|
|
@@ -4817,7 +3019,7 @@ function genEmptyTable(rowCount, colCount) {
|
|
|
4817
3019
|
const paragraphs = [], sectionBreaks = [];
|
|
4818
3020
|
for (let i = 0; i < rowCount; i++) {
|
|
4819
3021
|
dataStream += DataStreamTreeTokenType.TABLE_ROW_START;
|
|
4820
|
-
for (let
|
|
3022
|
+
for (let j2 = 0; j2 < colCount; j2++)
|
|
4821
3023
|
dataStream += `${DataStreamTreeTokenType.TABLE_CELL_START}\r
|
|
4822
3024
|
${DataStreamTreeTokenType.TABLE_CELL_END}`, paragraphs.push({
|
|
4823
3025
|
startIndex: dataStream.length - 3,
|
|
@@ -5350,8 +3552,7 @@ const InnerPasteCommand = {
|
|
|
5350
3552
|
if (collapsed)
|
|
5351
3553
|
textX.push({
|
|
5352
3554
|
t: TextXActionType.RETAIN,
|
|
5353
|
-
len
|
|
5354
|
-
segmentId
|
|
3555
|
+
len
|
|
5355
3556
|
});
|
|
5356
3557
|
else {
|
|
5357
3558
|
const { dos } = BuildTextUtils.selection.getDeleteActions(selection, segmentId, memoryCursor.cursor, originBody);
|
|
@@ -5360,9 +3561,7 @@ const InnerPasteCommand = {
|
|
|
5360
3561
|
textX.push({
|
|
5361
3562
|
t: TextXActionType.INSERT,
|
|
5362
3563
|
body: cloneBody,
|
|
5363
|
-
len: body.dataStream.length
|
|
5364
|
-
line: 0,
|
|
5365
|
-
segmentId
|
|
3564
|
+
len: body.dataStream.length
|
|
5366
3565
|
}), memoryCursor.reset(), memoryCursor.moveCursor(endOffset);
|
|
5367
3566
|
}
|
|
5368
3567
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -5383,9 +3582,8 @@ function getCutActionsFromTextRanges(selections, docDataModel, segmentId) {
|
|
|
5383
3582
|
const len = startOffset - memoryCursor.cursor;
|
|
5384
3583
|
collapsed ? textX.push({
|
|
5385
3584
|
t: TextXActionType.RETAIN,
|
|
5386
|
-
len
|
|
5387
|
-
|
|
5388
|
-
}) : textX.push(...BuildTextUtils.selection.getDeleteExculdeLastLineBreakActions(selection, originBody, segmentId, memoryCursor.cursor, !1)), memoryCursor.reset(), memoryCursor.moveCursor(endOffset);
|
|
3585
|
+
len
|
|
3586
|
+
}) : textX.push(...BuildTextUtils.selection.getDeleteExcludeLastLineBreakActions(selection, originBody, segmentId, memoryCursor.cursor, !1)), memoryCursor.reset(), memoryCursor.moveCursor(endOffset);
|
|
5389
3587
|
}
|
|
5390
3588
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
5391
3589
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -5417,13 +3615,10 @@ function getCutActionsFromRectRanges(ranges, docDataModel, viewModel, segmentId)
|
|
|
5417
3615
|
const { offset, len, tableId } = actionParams;
|
|
5418
3616
|
offset - memoryCursor.cursor > 0 && textX.push({
|
|
5419
3617
|
t: TextXActionType.RETAIN,
|
|
5420
|
-
len: offset - memoryCursor.cursor
|
|
5421
|
-
segmentId
|
|
3618
|
+
len: offset - memoryCursor.cursor
|
|
5422
3619
|
}), textX.push({
|
|
5423
3620
|
t: TextXActionType.DELETE,
|
|
5424
|
-
len
|
|
5425
|
-
line: 0,
|
|
5426
|
-
segmentId
|
|
3621
|
+
len
|
|
5427
3622
|
});
|
|
5428
3623
|
const action = jsonX.removeOp(["tableSource", tableId]);
|
|
5429
3624
|
rawActions.push(action), memoryCursor.moveCursorTo(offset + len);
|
|
@@ -5434,13 +3629,10 @@ function getCutActionsFromRectRanges(ranges, docDataModel, viewModel, segmentId)
|
|
|
5434
3629
|
const { offset, rowIndexes, len, tableId } = actionParams;
|
|
5435
3630
|
offset - memoryCursor.cursor > 0 && textX.push({
|
|
5436
3631
|
t: TextXActionType.RETAIN,
|
|
5437
|
-
len: offset - memoryCursor.cursor
|
|
5438
|
-
segmentId
|
|
3632
|
+
len: offset - memoryCursor.cursor
|
|
5439
3633
|
}), textX.push({
|
|
5440
3634
|
t: TextXActionType.DELETE,
|
|
5441
|
-
len
|
|
5442
|
-
line: 0,
|
|
5443
|
-
segmentId
|
|
3635
|
+
len
|
|
5444
3636
|
});
|
|
5445
3637
|
for (const index of rowIndexes.reverse()) {
|
|
5446
3638
|
const action = jsonX.removeOp(["tableSource", tableId, "tableRows", index]);
|
|
@@ -5456,13 +3648,10 @@ function getCutActionsFromRectRanges(ranges, docDataModel, viewModel, segmentId)
|
|
|
5456
3648
|
const { retain, delete: delLen } = offset;
|
|
5457
3649
|
retain - memoryCursor.cursor > 0 && textX.push({
|
|
5458
3650
|
t: TextXActionType.RETAIN,
|
|
5459
|
-
len: retain - memoryCursor.cursor
|
|
5460
|
-
segmentId
|
|
3651
|
+
len: retain - memoryCursor.cursor
|
|
5461
3652
|
}), textX.push({
|
|
5462
3653
|
t: TextXActionType.DELETE,
|
|
5463
|
-
len: delLen
|
|
5464
|
-
line: 0,
|
|
5465
|
-
segmentId
|
|
3654
|
+
len: delLen
|
|
5466
3655
|
}), memoryCursor.moveCursorTo(retain + delLen);
|
|
5467
3656
|
}
|
|
5468
3657
|
}
|
|
@@ -5510,133 +3699,6 @@ const INNER_CUT_COMMAND_ID = "doc.command.inner-cut", CutContentCommand = {
|
|
|
5510
3699
|
};
|
|
5511
3700
|
return doMutation.params.actions = getCutActionsFromDocRanges(selections, rectRanges, docDataModel, viewModel, segmentId), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
5512
3701
|
}, "handler")
|
|
5513
|
-
};
|
|
5514
|
-
var DeleteDirection = /* @__PURE__ */ ((DeleteDirection2) => (DeleteDirection2[DeleteDirection2.LEFT = 0] = "LEFT", DeleteDirection2[DeleteDirection2.RIGHT = 1] = "RIGHT", DeleteDirection2))(DeleteDirection || {});
|
|
5515
|
-
const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
5516
|
-
id: EditorInsertTextCommandId,
|
|
5517
|
-
type: CommandType.COMMAND,
|
|
5518
|
-
// eslint-disable-next-line max-lines-per-function
|
|
5519
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5520
|
-
var _a28;
|
|
5521
|
-
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
|
-
if (docDataModel == null)
|
|
5523
|
-
return !1;
|
|
5524
|
-
const activeRange = docSelectionManagerService.getActiveTextRange(), originBody = docDataModel.getSelfOrHeaderFooterModel((_a28 = activeRange == null ? void 0 : activeRange.segmentId) != null ? _a28 : "").getBody();
|
|
5525
|
-
if (!originBody)
|
|
5526
|
-
return !1;
|
|
5527
|
-
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
|
-
{
|
|
5529
|
-
startOffset: startOffset + cursorMove,
|
|
5530
|
-
endOffset: startOffset + cursorMove,
|
|
5531
|
-
style: activeRange == null ? void 0 : activeRange.style,
|
|
5532
|
-
collapsed
|
|
5533
|
-
}
|
|
5534
|
-
], doMutation = {
|
|
5535
|
-
id: RichTextEditingMutation.id,
|
|
5536
|
-
params: {
|
|
5537
|
-
unitId,
|
|
5538
|
-
actions: [],
|
|
5539
|
-
textRanges,
|
|
5540
|
-
debounce: !0
|
|
5541
|
-
}
|
|
5542
|
-
}, textX = new TextX(), jsonX = JSONX.getInstance();
|
|
5543
|
-
if (collapsed)
|
|
5544
|
-
startOffset > 0 && textX.push({
|
|
5545
|
-
t: TextXActionType.RETAIN,
|
|
5546
|
-
len: startOffset,
|
|
5547
|
-
segmentId
|
|
5548
|
-
});
|
|
5549
|
-
else {
|
|
5550
|
-
const { dos, retain } = BuildTextUtils.selection.getDeleteActions(actualRange, segmentId, 0, originBody);
|
|
5551
|
-
textX.push(...dos), doMutation.params.textRanges = [{
|
|
5552
|
-
startOffset: startOffset + cursorMove + retain,
|
|
5553
|
-
endOffset: startOffset + cursorMove + retain,
|
|
5554
|
-
collapsed
|
|
5555
|
-
}];
|
|
5556
|
-
}
|
|
5557
|
-
textX.push({
|
|
5558
|
-
t: TextXActionType.INSERT,
|
|
5559
|
-
body,
|
|
5560
|
-
len: body.dataStream.length,
|
|
5561
|
-
line: 0,
|
|
5562
|
-
segmentId
|
|
5563
|
-
});
|
|
5564
|
-
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
5565
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
5566
|
-
}, "handler")
|
|
5567
|
-
}, DeleteCommand = {
|
|
5568
|
-
id: "doc.command.delete-text",
|
|
5569
|
-
type: CommandType.COMMAND,
|
|
5570
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5571
|
-
var _a28;
|
|
5572
|
-
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
|
-
if (docDataModel == null || body == null)
|
|
5574
|
-
return !1;
|
|
5575
|
-
const { startOffset } = range, dataStream = body.dataStream, start = direction === DeleteDirection.LEFT ? startOffset - len : startOffset, end = start + len - 1, relativeCustomRanges = (_a28 = body.customRanges) == null ? void 0 : _a28.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
|
-
for (let i = 0; i < len; i++)
|
|
5577
|
-
deleteIndexes.push(start + i);
|
|
5578
|
-
toDeleteRanges == null || toDeleteRanges.forEach((range2) => {
|
|
5579
|
-
deleteIndexes.push(range2.startIndex, range2.endIndex);
|
|
5580
|
-
}), deleteIndexes.sort((pre, aft) => pre - aft);
|
|
5581
|
-
const deleteStart = deleteIndexes[0], doMutation = {
|
|
5582
|
-
id: RichTextEditingMutation.id,
|
|
5583
|
-
params: {
|
|
5584
|
-
unitId,
|
|
5585
|
-
actions: [],
|
|
5586
|
-
textRanges: [{
|
|
5587
|
-
startOffset: deleteStart,
|
|
5588
|
-
endOffset: deleteStart,
|
|
5589
|
-
collapsed: !0
|
|
5590
|
-
}],
|
|
5591
|
-
debounce: !0
|
|
5592
|
-
}
|
|
5593
|
-
}, textX = new TextX(), jsonX = JSONX.getInstance();
|
|
5594
|
-
let cursor = 0;
|
|
5595
|
-
for (let i = 0; i < deleteIndexes.length; i++) {
|
|
5596
|
-
const deleteIndex = deleteIndexes[i];
|
|
5597
|
-
deleteIndex - cursor > 0 && textX.push({
|
|
5598
|
-
t: TextXActionType.RETAIN,
|
|
5599
|
-
len: deleteIndex - cursor,
|
|
5600
|
-
segmentId
|
|
5601
|
-
}), textX.push({
|
|
5602
|
-
t: TextXActionType.DELETE,
|
|
5603
|
-
len: 1,
|
|
5604
|
-
segmentId,
|
|
5605
|
-
line: 0
|
|
5606
|
-
}), cursor = deleteIndex + 1;
|
|
5607
|
-
}
|
|
5608
|
-
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
5609
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
5610
|
-
}, "handler")
|
|
5611
|
-
}, UpdateCommand = {
|
|
5612
|
-
id: "doc.command.update-text",
|
|
5613
|
-
type: CommandType.COMMAND,
|
|
5614
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5615
|
-
const { range, segmentId, updateBody, coverType, unitId, textRanges } = params, commandService = accessor.get(ICommandService), docDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
|
|
5616
|
-
if (docDataModel == null)
|
|
5617
|
-
return !1;
|
|
5618
|
-
const doMutation = {
|
|
5619
|
-
id: RichTextEditingMutation.id,
|
|
5620
|
-
params: {
|
|
5621
|
-
unitId,
|
|
5622
|
-
actions: [],
|
|
5623
|
-
textRanges
|
|
5624
|
-
}
|
|
5625
|
-
}, textX = new TextX(), jsonX = JSONX.getInstance(), { startOffset, endOffset } = range;
|
|
5626
|
-
textX.push({
|
|
5627
|
-
t: TextXActionType.RETAIN,
|
|
5628
|
-
len: startOffset,
|
|
5629
|
-
segmentId
|
|
5630
|
-
}), textX.push({
|
|
5631
|
-
t: TextXActionType.RETAIN,
|
|
5632
|
-
body: updateBody,
|
|
5633
|
-
len: endOffset - startOffset,
|
|
5634
|
-
segmentId,
|
|
5635
|
-
coverType
|
|
5636
|
-
});
|
|
5637
|
-
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
5638
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
5639
|
-
}, "handler")
|
|
5640
3702
|
}, getDeleteSelection = BuildTextUtils.selection.getDeleteSelection, DeleteCustomBlockCommand = {
|
|
5641
3703
|
id: "doc.command.delete-custom-block",
|
|
5642
3704
|
type: CommandType.COMMAND,
|
|
@@ -5662,13 +3724,10 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5662
3724
|
}, textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [];
|
|
5663
3725
|
startOffset > 0 && textX.push({
|
|
5664
3726
|
t: TextXActionType.RETAIN,
|
|
5665
|
-
len: direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset
|
|
5666
|
-
segmentId
|
|
3727
|
+
len: direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset
|
|
5667
3728
|
}), textX.push({
|
|
5668
3729
|
t: TextXActionType.DELETE,
|
|
5669
|
-
len: 1
|
|
5670
|
-
line: 0,
|
|
5671
|
-
segmentId
|
|
3730
|
+
len: 1
|
|
5672
3731
|
});
|
|
5673
3732
|
const path = getRichTextEditPath(documentDataModel, segmentId);
|
|
5674
3733
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -5683,13 +3742,24 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5683
3742
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { direction, range } = params, activeRange = docSelectionManagerService.getActiveTextRange(), ranges = docSelectionManagerService.getTextRanges();
|
|
5684
3743
|
if (activeRange == null || ranges == null)
|
|
5685
3744
|
return !1;
|
|
5686
|
-
const { segmentId, style } = activeRange, docDataModel = univerInstanceService.
|
|
5687
|
-
if (
|
|
3745
|
+
const { segmentId, style } = activeRange, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), originBody = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
3746
|
+
if (docDataModel == null || originBody == null)
|
|
5688
3747
|
return !1;
|
|
5689
3748
|
const actualRange = getDeleteSelection(activeRange, originBody), unitId = docDataModel.getUnitId(), { startOffset, collapsed } = actualRange;
|
|
5690
3749
|
if (!collapsed)
|
|
5691
3750
|
return !1;
|
|
5692
|
-
const startIndex = direction === DeleteDirection.LEFT ? startOffset : startOffset + 1
|
|
3751
|
+
const startIndex = direction === DeleteDirection.LEFT ? startOffset : startOffset + 1;
|
|
3752
|
+
let curParagraph, nextParagraph;
|
|
3753
|
+
for (const paragraph of originBody.paragraphs) {
|
|
3754
|
+
if (paragraph.startIndex >= startIndex) {
|
|
3755
|
+
nextParagraph = paragraph;
|
|
3756
|
+
break;
|
|
3757
|
+
}
|
|
3758
|
+
curParagraph = paragraph;
|
|
3759
|
+
}
|
|
3760
|
+
if (curParagraph == null || nextParagraph == null)
|
|
3761
|
+
return !1;
|
|
3762
|
+
const cursor = direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset, textRanges = [
|
|
5693
3763
|
{
|
|
5694
3764
|
startOffset: cursor,
|
|
5695
3765
|
endOffset: cursor,
|
|
@@ -5704,25 +3774,28 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
5704
3774
|
prevTextRanges: [range]
|
|
5705
3775
|
}
|
|
5706
3776
|
}, textX = new TextX(), jsonX = JSONX.getInstance();
|
|
5707
|
-
textX.push({
|
|
3777
|
+
curParagraph.startIndex > 0 && textX.push({
|
|
5708
3778
|
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
|
|
3779
|
+
len: curParagraph.startIndex
|
|
5717
3780
|
}), textX.push({
|
|
3781
|
+
t: TextXActionType.DELETE,
|
|
3782
|
+
len: 1
|
|
3783
|
+
}), nextParagraph.startIndex > curParagraph.startIndex + 1 && textX.push({
|
|
5718
3784
|
t: TextXActionType.RETAIN,
|
|
5719
|
-
len: 1
|
|
5720
|
-
segmentId
|
|
3785
|
+
len: nextParagraph.startIndex - curParagraph.startIndex - 1
|
|
5721
3786
|
}), textX.push({
|
|
5722
|
-
t: TextXActionType.
|
|
5723
|
-
len:
|
|
5724
|
-
|
|
5725
|
-
|
|
3787
|
+
t: TextXActionType.RETAIN,
|
|
3788
|
+
len: 1,
|
|
3789
|
+
coverType: UpdateDocsAttributeType.REPLACE,
|
|
3790
|
+
body: {
|
|
3791
|
+
dataStream: "",
|
|
3792
|
+
paragraphs: [
|
|
3793
|
+
{
|
|
3794
|
+
...Tools.deepClone(curParagraph),
|
|
3795
|
+
startIndex: 0
|
|
3796
|
+
}
|
|
3797
|
+
]
|
|
3798
|
+
}
|
|
5726
3799
|
});
|
|
5727
3800
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
5728
3801
|
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
@@ -5758,7 +3831,7 @@ const DeleteLeftCommand = {
|
|
|
5758
3831
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
|
|
5759
3832
|
let result = !0;
|
|
5760
3833
|
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
5761
|
-
if (
|
|
3834
|
+
if (docDataModel == null)
|
|
5762
3835
|
return !1;
|
|
5763
3836
|
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
3837
|
if (skeleton == null)
|
|
@@ -5986,43 +4059,6 @@ const DeleteLeftCommand = {
|
|
|
5986
4059
|
return result;
|
|
5987
4060
|
}, "handler")
|
|
5988
4061
|
};
|
|
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
4062
|
function getTextRangesWhenDelete(activeRange, ranges) {
|
|
6027
4063
|
let cursor = activeRange.endOffset;
|
|
6028
4064
|
for (const range of ranges) {
|
|
@@ -6780,6 +4816,55 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6780
4816
|
const docClipboardService = accessor.get(IDocClipboardService), clipboardItems = await accessor.get(IClipboardInterfaceService).read();
|
|
6781
4817
|
return clipboardItems.length === 0 ? !1 : docClipboardService.paste(clipboardItems);
|
|
6782
4818
|
}, "handler")
|
|
4819
|
+
}, SwitchDocModeCommand = {
|
|
4820
|
+
id: "doc.command.switch-mode",
|
|
4821
|
+
type: CommandType.COMMAND,
|
|
4822
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
4823
|
+
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
4824
|
+
var _a28, _b2, _c, _d, _e;
|
|
4825
|
+
const commandService = accessor.get(ICommandService), renderManagerService = accessor.get(IRenderManagerService), docSelectionManagerService = accessor.get(DocSelectionManagerService), docDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
|
|
4826
|
+
if (docDataModel == null)
|
|
4827
|
+
return !1;
|
|
4828
|
+
const unitId = docDataModel.getUnitId(), skeleton = (_a28 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a28.with(DocSkeletonManagerService).getSkeleton(), docSelectionRenderService = (_b2 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _b2.with(DocSelectionRenderService);
|
|
4829
|
+
if (skeleton == null || docSelectionRenderService == null)
|
|
4830
|
+
return !1;
|
|
4831
|
+
const segmentId = docSelectionRenderService == null ? void 0 : docSelectionRenderService.getSegment(), segmentPage = docSelectionRenderService == null ? void 0 : docSelectionRenderService.getSegmentPage(), oldDocumentFlavor = docDataModel.getSnapshot().documentStyle.documentFlavor, docRanges = docSelectionManagerService.getDocRanges(), doMutation = {
|
|
4832
|
+
id: RichTextEditingMutation.id,
|
|
4833
|
+
params: {
|
|
4834
|
+
unitId,
|
|
4835
|
+
actions: [],
|
|
4836
|
+
textRanges: oldDocumentFlavor === DocumentFlavor.TRADITIONAL && segmentId ? [] : docRanges
|
|
4837
|
+
}
|
|
4838
|
+
}, jsonX = JSONX.getInstance(), rawActions = [];
|
|
4839
|
+
let action;
|
|
4840
|
+
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)
|
|
4841
|
+
rawActions.push(action);
|
|
4842
|
+
else
|
|
4843
|
+
return !1;
|
|
4844
|
+
if (oldDocumentFlavor !== DocumentFlavor.MODERN) {
|
|
4845
|
+
const snapshot = docDataModel.getSnapshot(), { drawings = {}, body } = snapshot, customBlocks = (_c = body == null ? void 0 : body.customBlocks) != null ? _c : [];
|
|
4846
|
+
for (const drawingId in drawings) {
|
|
4847
|
+
const drawing = drawings[drawingId], customBlock = customBlocks.find((block) => block.blockId === drawingId);
|
|
4848
|
+
if (customBlock == null)
|
|
4849
|
+
continue;
|
|
4850
|
+
const drawingPositionV = drawing.docTransform.positionV, { relativeFrom: prevRelativeFrom, posOffset: prevPosOffset } = drawingPositionV;
|
|
4851
|
+
if (prevRelativeFrom === ObjectRelativeFromV.PARAGRAPH)
|
|
4852
|
+
continue;
|
|
4853
|
+
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((l3) => l3.paragraphIndex === (line == null ? void 0 : line.paragraphIndex) && l3.paragraphStart), page = (_e = column == null ? void 0 : column.parent) == null ? void 0 : _e.parent;
|
|
4854
|
+
if (glyph == null || line == null || paragraphStartLine == null || column == null || page == null)
|
|
4855
|
+
continue;
|
|
4856
|
+
let delta = 0;
|
|
4857
|
+
prevRelativeFrom === ObjectRelativeFromV.LINE ? delta -= line.top : prevRelativeFrom === ObjectRelativeFromV.PAGE && (delta += page.marginTop), delta += paragraphStartLine.top;
|
|
4858
|
+
const newPositionV = {
|
|
4859
|
+
...drawingPositionV,
|
|
4860
|
+
relativeFrom: ObjectRelativeFromV.PARAGRAPH,
|
|
4861
|
+
posOffset: (prevPosOffset != null ? prevPosOffset : 0) - delta
|
|
4862
|
+
}, updateDrawingAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionV"], drawingPositionV, newPositionV);
|
|
4863
|
+
updateDrawingAction && rawActions.push(updateDrawingAction);
|
|
4864
|
+
}
|
|
4865
|
+
}
|
|
4866
|
+
return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
4867
|
+
}, "handler")
|
|
6783
4868
|
}, DocTableDeleteRowsCommand = {
|
|
6784
4869
|
id: "doc.table.delete-rows",
|
|
6785
4870
|
type: CommandType.COMMAND,
|
|
@@ -6814,13 +4899,10 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6814
4899
|
};
|
|
6815
4900
|
offset > 0 && textX.push({
|
|
6816
4901
|
t: TextXActionType.RETAIN,
|
|
6817
|
-
len: offset
|
|
6818
|
-
segmentId
|
|
4902
|
+
len: offset
|
|
6819
4903
|
}), textX.push({
|
|
6820
4904
|
t: TextXActionType.DELETE,
|
|
6821
|
-
len
|
|
6822
|
-
line: 0,
|
|
6823
|
-
segmentId
|
|
4905
|
+
len
|
|
6824
4906
|
});
|
|
6825
4907
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
6826
4908
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -6866,13 +4948,10 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6866
4948
|
const { retain, delete: deleteLen } = offset;
|
|
6867
4949
|
retain > 0 && textX.push({
|
|
6868
4950
|
t: TextXActionType.RETAIN,
|
|
6869
|
-
len: retain
|
|
6870
|
-
segmentId
|
|
4951
|
+
len: retain
|
|
6871
4952
|
}), textX.push({
|
|
6872
4953
|
t: TextXActionType.DELETE,
|
|
6873
|
-
len: deleteLen
|
|
6874
|
-
line: 0,
|
|
6875
|
-
segmentId
|
|
4954
|
+
len: deleteLen
|
|
6876
4955
|
});
|
|
6877
4956
|
}
|
|
6878
4957
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -6919,13 +4998,10 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6919
4998
|
};
|
|
6920
4999
|
offset > 0 && textX.push({
|
|
6921
5000
|
t: TextXActionType.RETAIN,
|
|
6922
|
-
len: offset
|
|
6923
|
-
segmentId
|
|
5001
|
+
len: offset
|
|
6924
5002
|
}), textX.push({
|
|
6925
5003
|
t: TextXActionType.DELETE,
|
|
6926
|
-
len
|
|
6927
|
-
line: 0,
|
|
6928
|
-
segmentId
|
|
5004
|
+
len
|
|
6929
5005
|
});
|
|
6930
5006
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
6931
5007
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -6979,16 +5055,13 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
6979
5055
|
};
|
|
6980
5056
|
offset > 0 && textX.push({
|
|
6981
5057
|
t: TextXActionType.RETAIN,
|
|
6982
|
-
len: offset
|
|
6983
|
-
segmentId
|
|
5058
|
+
len: offset
|
|
6984
5059
|
});
|
|
6985
5060
|
const insertBody = getInsertRowBody(colCount);
|
|
6986
5061
|
textX.push({
|
|
6987
5062
|
t: TextXActionType.INSERT,
|
|
6988
5063
|
body: insertBody,
|
|
6989
|
-
len: insertBody.dataStream.length
|
|
6990
|
-
line: 0,
|
|
6991
|
-
segmentId
|
|
5064
|
+
len: insertBody.dataStream.length
|
|
6992
5065
|
});
|
|
6993
5066
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
6994
5067
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -7028,16 +5101,13 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
7028
5101
|
for (const offset of offsets) {
|
|
7029
5102
|
textX.push({
|
|
7030
5103
|
t: TextXActionType.RETAIN,
|
|
7031
|
-
len: offset
|
|
7032
|
-
segmentId
|
|
5104
|
+
len: offset
|
|
7033
5105
|
});
|
|
7034
5106
|
const insertBody = getInsertColumnBody();
|
|
7035
5107
|
textX.push({
|
|
7036
5108
|
t: TextXActionType.INSERT,
|
|
7037
5109
|
body: insertBody,
|
|
7038
|
-
len: insertBody.dataStream.length
|
|
7039
|
-
line: 0,
|
|
7040
|
-
segmentId
|
|
5110
|
+
len: insertBody.dataStream.length
|
|
7041
5111
|
});
|
|
7042
5112
|
}
|
|
7043
5113
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
@@ -7071,45 +5141,47 @@ const BreakLineCommand = {
|
|
|
7071
5141
|
id: "doc.command.break-line",
|
|
7072
5142
|
type: CommandType.COMMAND,
|
|
7073
5143
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
7074
|
-
var _a28, _b2
|
|
5144
|
+
var _a28, _b2;
|
|
7075
5145
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), activeTextRange = docSelectionManagerService.getActiveTextRange(), rectRanges = docSelectionManagerService.getRectRanges();
|
|
7076
5146
|
if (activeTextRange == null)
|
|
7077
5147
|
return !1;
|
|
7078
5148
|
if (rectRanges && rectRanges.length) {
|
|
7079
5149
|
const { startOffset: startOffset2 } = activeTextRange;
|
|
7080
|
-
return docSelectionManagerService.
|
|
5150
|
+
return docSelectionManagerService.replaceDocRanges([{
|
|
7081
5151
|
startOffset: startOffset2,
|
|
7082
5152
|
endOffset: startOffset2
|
|
7083
5153
|
}]), !0;
|
|
7084
5154
|
}
|
|
7085
|
-
const { segmentId } = activeTextRange, docDataModel = univerInstanceService.
|
|
7086
|
-
if (
|
|
5155
|
+
const { segmentId } = activeTextRange, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), body = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId != null ? segmentId : "").getBody();
|
|
5156
|
+
if (docDataModel == null || body == null)
|
|
7087
5157
|
return !1;
|
|
7088
5158
|
const unitId = docDataModel.getUnitId(), { startOffset, endOffset } = BuildTextUtils.selection.getInsertSelection(activeTextRange, body), prevParagraph = ((_a28 = body.paragraphs) != null ? _a28 : []).find((p2) => p2.startIndex >= startOffset);
|
|
7089
5159
|
if (!prevParagraph)
|
|
7090
5160
|
return !1;
|
|
7091
|
-
const
|
|
7092
|
-
|
|
7093
|
-
|
|
5161
|
+
const prevParagraphIndex = prevParagraph.startIndex, insertBody = {
|
|
5162
|
+
dataStream: DataStreamTreeTokenType.PARAGRAPH,
|
|
5163
|
+
paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
5164
|
+
}, deleteRange = {
|
|
7094
5165
|
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, {
|
|
5166
|
+
endOffset
|
|
5167
|
+
}, result = await commandService.executeCommand(InsertCommand.id, {
|
|
7107
5168
|
unitId,
|
|
7108
|
-
body:
|
|
5169
|
+
body: insertBody,
|
|
7109
5170
|
range: deleteRange,
|
|
7110
|
-
segmentId
|
|
7111
|
-
cursorOffset: 1
|
|
5171
|
+
segmentId
|
|
7112
5172
|
});
|
|
5173
|
+
if (((_b2 = prevParagraph.bullet) == null ? void 0 : _b2.listType) === PresetListType.CHECK_LIST_CHECKED) {
|
|
5174
|
+
const params = {
|
|
5175
|
+
index: prevParagraphIndex + 1 - (endOffset - startOffset),
|
|
5176
|
+
segmentId,
|
|
5177
|
+
textRanges: [{
|
|
5178
|
+
startOffset: startOffset + 1,
|
|
5179
|
+
endOffset: startOffset + 1
|
|
5180
|
+
}]
|
|
5181
|
+
};
|
|
5182
|
+
return !!await commandService.executeCommand(ToggleCheckListCommand.id, params) && result;
|
|
5183
|
+
}
|
|
5184
|
+
return result;
|
|
7113
5185
|
}, "handler")
|
|
7114
5186
|
}, CreateDocTableCommandId = "doc.command.create-table", CreateDocTableCommand = {
|
|
7115
5187
|
id: CreateDocTableCommandId,
|
|
@@ -7143,17 +5215,14 @@ const BreakLineCommand = {
|
|
|
7143
5215
|
};
|
|
7144
5216
|
startOffset > 0 && textX.push({
|
|
7145
5217
|
t: TextXActionType.RETAIN,
|
|
7146
|
-
len: startOffset
|
|
7147
|
-
segmentId
|
|
5218
|
+
len: startOffset
|
|
7148
5219
|
}), needCreateParagraph && textX.push({
|
|
7149
5220
|
t: TextXActionType.INSERT,
|
|
7150
5221
|
body: {
|
|
7151
5222
|
dataStream: DataStreamTreeTokenType.PARAGRAPH,
|
|
7152
5223
|
paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
7153
5224
|
},
|
|
7154
|
-
len: 1
|
|
7155
|
-
line: 0,
|
|
7156
|
-
segmentId
|
|
5225
|
+
len: 1
|
|
7157
5226
|
});
|
|
7158
5227
|
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
5228
|
if (page == null)
|
|
@@ -7173,9 +5242,7 @@ const BreakLineCommand = {
|
|
|
7173
5242
|
}
|
|
7174
5243
|
]
|
|
7175
5244
|
},
|
|
7176
|
-
len: tableDataStream.length
|
|
7177
|
-
line: 0,
|
|
7178
|
-
segmentId
|
|
5245
|
+
len: tableDataStream.length
|
|
7179
5246
|
});
|
|
7180
5247
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
7181
5248
|
rawActions.push(jsonX.editOp(textX.serialize(), path));
|
|
@@ -7235,8 +5302,7 @@ const BreakLineCommand = {
|
|
|
7235
5302
|
const { startIndex } = paragraph;
|
|
7236
5303
|
textX.push({
|
|
7237
5304
|
t: TextXActionType.RETAIN,
|
|
7238
|
-
len: startIndex - memoryCursor.cursor
|
|
7239
|
-
segmentId
|
|
5305
|
+
len: startIndex - memoryCursor.cursor
|
|
7240
5306
|
});
|
|
7241
5307
|
const paragraphStyle = {
|
|
7242
5308
|
...paragraph.paragraphStyle,
|
|
@@ -7255,7 +5321,6 @@ const BreakLineCommand = {
|
|
|
7255
5321
|
}
|
|
7256
5322
|
]
|
|
7257
5323
|
},
|
|
7258
|
-
segmentId,
|
|
7259
5324
|
coverType: UpdateDocsAttributeType.REPLACE
|
|
7260
5325
|
}), memoryCursor.moveCursorTo(startIndex + 1);
|
|
7261
5326
|
}
|
|
@@ -7767,6 +5832,38 @@ function getInsertTableHiddenObservable(accessor) {
|
|
|
7767
5832
|
});
|
|
7768
5833
|
}
|
|
7769
5834
|
__name(getInsertTableHiddenObservable, "getInsertTableHiddenObservable");
|
|
5835
|
+
function getHeaderFooterDisabledObservable(accessor) {
|
|
5836
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
|
|
5837
|
+
return new Observable((subscriber) => {
|
|
5838
|
+
const subscription0 = commandService.onCommandExecuted((command) => {
|
|
5839
|
+
if (command.id === SwitchDocModeCommand.id) {
|
|
5840
|
+
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
5841
|
+
if (docDataModel == null) {
|
|
5842
|
+
subscriber.next(!0);
|
|
5843
|
+
return;
|
|
5844
|
+
}
|
|
5845
|
+
const documentStyle = docDataModel.getSnapshot().documentStyle;
|
|
5846
|
+
subscriber.next((documentStyle == null ? void 0 : documentStyle.documentFlavor) !== DocumentFlavor.TRADITIONAL);
|
|
5847
|
+
}
|
|
5848
|
+
}), subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
5849
|
+
var _a28;
|
|
5850
|
+
if (unitId == null) {
|
|
5851
|
+
subscriber.next(!0);
|
|
5852
|
+
return;
|
|
5853
|
+
}
|
|
5854
|
+
const docDataModel = univerInstanceService.getUnit(unitId);
|
|
5855
|
+
if (docDataModel == null) {
|
|
5856
|
+
subscriber.next(!0);
|
|
5857
|
+
return;
|
|
5858
|
+
}
|
|
5859
|
+
return subscriber.next(((_a28 = docDataModel.getSnapshot().documentStyle) == null ? void 0 : _a28.documentFlavor) !== DocumentFlavor.TRADITIONAL);
|
|
5860
|
+
});
|
|
5861
|
+
return () => {
|
|
5862
|
+
subscription.unsubscribe(), subscription0.dispose();
|
|
5863
|
+
};
|
|
5864
|
+
});
|
|
5865
|
+
}
|
|
5866
|
+
__name(getHeaderFooterDisabledObservable, "getHeaderFooterDisabledObservable");
|
|
7770
5867
|
function getTableDisabledObservable(accessor) {
|
|
7771
5868
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService);
|
|
7772
5869
|
return new Observable((subscriber) => {
|
|
@@ -8112,6 +6209,7 @@ function HeaderFooterMenuItemFactory(accessor) {
|
|
|
8112
6209
|
type: MenuItemType.BUTTON,
|
|
8113
6210
|
icon: "HeaderFooterSingle",
|
|
8114
6211
|
tooltip: "toolbar.headerFooter",
|
|
6212
|
+
disabled$: getHeaderFooterDisabledObservable(accessor),
|
|
8115
6213
|
hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getHeaderFooterMenuHiddenObservable(accessor), (one, two) => one || two)
|
|
8116
6214
|
};
|
|
8117
6215
|
}
|
|
@@ -8324,6 +6422,28 @@ function CheckListMenuItemFactory(accessor) {
|
|
|
8324
6422
|
};
|
|
8325
6423
|
}
|
|
8326
6424
|
__name(CheckListMenuItemFactory, "CheckListMenuItemFactory");
|
|
6425
|
+
function DocSwitchModeMenuItemFactory(accessor) {
|
|
6426
|
+
const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService);
|
|
6427
|
+
return {
|
|
6428
|
+
id: SwitchDocModeCommand.id,
|
|
6429
|
+
type: MenuItemType.BUTTON,
|
|
6430
|
+
icon: "KeyboardSingle",
|
|
6431
|
+
tooltip: "toolbar.documentFlavor",
|
|
6432
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, void 0, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
|
|
6433
|
+
activated$: new Observable((subscriber) => {
|
|
6434
|
+
var _a28;
|
|
6435
|
+
const subscription = commandService.onCommandExecuted((c) => {
|
|
6436
|
+
var _a29;
|
|
6437
|
+
if (c.id === SwitchDocModeCommand.id) {
|
|
6438
|
+
const instance2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
6439
|
+
subscriber.next(((_a29 = instance2 == null ? void 0 : instance2.getSnapshot()) == null ? void 0 : _a29.documentStyle.documentFlavor) === DocumentFlavor.MODERN);
|
|
6440
|
+
}
|
|
6441
|
+
}), instance = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
6442
|
+
return subscriber.next(((_a28 = instance == null ? void 0 : instance.getSnapshot()) == null ? void 0 : _a28.documentStyle.documentFlavor) === DocumentFlavor.MODERN), () => subscription.dispose();
|
|
6443
|
+
})
|
|
6444
|
+
};
|
|
6445
|
+
}
|
|
6446
|
+
__name(DocSwitchModeMenuItemFactory, "DocSwitchModeMenuItemFactory");
|
|
8327
6447
|
function ResetBackgroundColorMenuItemFactory(accessor) {
|
|
8328
6448
|
return {
|
|
8329
6449
|
id: ResetInlineFormatTextBackgroundColorCommand.id,
|
|
@@ -8363,13 +6483,17 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
8363
6483
|
}
|
|
8364
6484
|
__name(BackgroundColorSelectorMenuItemFactory, "BackgroundColorSelectorMenuItemFactory");
|
|
8365
6485
|
function getFontStyleAtCursor(accessor) {
|
|
8366
|
-
var _a28;
|
|
8367
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(DocSelectionManagerService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveTextRange();
|
|
6486
|
+
var _a28, _b2;
|
|
6487
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(DocSelectionManagerService), docMenuStyleService = accessor.get(DocMenuStyleService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveTextRange(), cacheStyle = (_a28 = docMenuStyleService.getStyleCache()) != null ? _a28 : {};
|
|
8368
6488
|
if (docDataModel == null || activeTextRange == null)
|
|
8369
|
-
return
|
|
8370
|
-
|
|
6489
|
+
return {
|
|
6490
|
+
ts: cacheStyle
|
|
6491
|
+
};
|
|
6492
|
+
const { startOffset, segmentId } = activeTextRange, textRuns = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b2.textRuns;
|
|
8371
6493
|
if (textRuns == null)
|
|
8372
|
-
return
|
|
6494
|
+
return {
|
|
6495
|
+
ts: cacheStyle
|
|
6496
|
+
};
|
|
8373
6497
|
let textRun;
|
|
8374
6498
|
for (let i = textRuns.length - 1; i >= 0; i--) {
|
|
8375
6499
|
const curTextRun = textRuns[i];
|
|
@@ -8378,7 +6502,13 @@ function getFontStyleAtCursor(accessor) {
|
|
|
8378
6502
|
break;
|
|
8379
6503
|
}
|
|
8380
6504
|
}
|
|
8381
|
-
return
|
|
6505
|
+
return {
|
|
6506
|
+
...textRun,
|
|
6507
|
+
ts: {
|
|
6508
|
+
...textRun == null ? void 0 : textRun.ts,
|
|
6509
|
+
...cacheStyle
|
|
6510
|
+
}
|
|
6511
|
+
};
|
|
8382
6512
|
}
|
|
8383
6513
|
__name(getFontStyleAtCursor, "getFontStyleAtCursor");
|
|
8384
6514
|
function getParagraphStyleAtCursor(accessor) {
|
|
@@ -8486,6 +6616,10 @@ const menuSchema = {
|
|
|
8486
6616
|
[OpenHeaderFooterPanelCommand.id]: {
|
|
8487
6617
|
order: 9,
|
|
8488
6618
|
menuItemFactory: HeaderFooterMenuItemFactory
|
|
6619
|
+
},
|
|
6620
|
+
[SwitchDocModeCommand.id]: {
|
|
6621
|
+
order: 10,
|
|
6622
|
+
menuItemFactory: DocSwitchModeMenuItemFactory
|
|
8489
6623
|
}
|
|
8490
6624
|
},
|
|
8491
6625
|
[ContextMenuPosition.MAIN_AREA]: {
|
|
@@ -8687,8 +6821,8 @@ var __defProp$j = Object.defineProperty, __getOwnPropDesc$j = Object.getOwnPrope
|
|
|
8687
6821
|
return kind && result && __defProp$j(target, key, result), result;
|
|
8688
6822
|
}, "__decorateClass$j"), __decorateParam$j = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$j"), _a8;
|
|
8689
6823
|
let DocRenderController = (_a8 = class extends RxDisposable {
|
|
8690
|
-
constructor(_context,
|
|
8691
|
-
super(), this._context = _context, this.
|
|
6824
|
+
constructor(_context, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _editorService, _renderManagerService, _univerInstanceService) {
|
|
6825
|
+
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
6826
|
}
|
|
8693
6827
|
reRender(unitId) {
|
|
8694
6828
|
var _a28, _b2;
|
|
@@ -8709,8 +6843,6 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8709
6843
|
top: 0,
|
|
8710
6844
|
bottom: 0,
|
|
8711
6845
|
right: 0,
|
|
8712
|
-
explicitViewportWidthSet: !1,
|
|
8713
|
-
explicitViewportHeightSet: !1,
|
|
8714
6846
|
isWheelPreventDefaultX: !0
|
|
8715
6847
|
});
|
|
8716
6848
|
scene.attachControl(), scene.onMouseWheel$.subscribeEvent((evt, state) => {
|
|
@@ -8733,8 +6865,8 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8733
6865
|
}
|
|
8734
6866
|
_addComponent() {
|
|
8735
6867
|
const { scene, unit: documentModel, components } = this._context, config = {
|
|
8736
|
-
pageMarginLeft:
|
|
8737
|
-
pageMarginTop:
|
|
6868
|
+
pageMarginLeft: 20,
|
|
6869
|
+
pageMarginTop: 20
|
|
8738
6870
|
}, documents = new Documents(DOCS_VIEW_KEY.MAIN, void 0, config);
|
|
8739
6871
|
documents.zIndex = DOCS_COMPONENT_DEFAULT_Z_INDEX;
|
|
8740
6872
|
const docBackground = new DocBackground(DOCS_VIEW_KEY.BACKGROUND, void 0, config);
|
|
@@ -8766,9 +6898,11 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8766
6898
|
if (pages == null)
|
|
8767
6899
|
return;
|
|
8768
6900
|
let width = 0, height = 0;
|
|
6901
|
+
const documentFlavor = this._context.unit.getSnapshot().documentStyle.documentFlavor;
|
|
8769
6902
|
for (let i = 0, len = pages.length; i < len; i++) {
|
|
8770
|
-
const page = pages[i]
|
|
8771
|
-
|
|
6903
|
+
const page = pages[i];
|
|
6904
|
+
let { pageWidth, pageHeight, marginLeft, marginRight, marginTop, marginBottom } = page;
|
|
6905
|
+
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
6906
|
}
|
|
8773
6907
|
docsComponent.resize(width, height), docBackground.resize(width, height);
|
|
8774
6908
|
const editor = this._editorService.getEditor(unitId);
|
|
@@ -8776,13 +6910,12 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8776
6910
|
}
|
|
8777
6911
|
}, __name(_a8, "DocRenderController"), _a8);
|
|
8778
6912
|
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)
|
|
6913
|
+
__decorateParam$j(1, ICommandService),
|
|
6914
|
+
__decorateParam$j(2, Inject(DocSelectionRenderService)),
|
|
6915
|
+
__decorateParam$j(3, Inject(DocSkeletonManagerService)),
|
|
6916
|
+
__decorateParam$j(4, IEditorService),
|
|
6917
|
+
__decorateParam$j(5, IRenderManagerService),
|
|
6918
|
+
__decorateParam$j(6, IUniverInstanceService)
|
|
8786
6919
|
], DocRenderController);
|
|
8787
6920
|
const _DocIMEInputManagerService = class _DocIMEInputManagerService extends RxDisposable {
|
|
8788
6921
|
constructor(_context) {
|
|
@@ -8840,8 +6973,8 @@ const IMEInputCommand = {
|
|
|
8840
6973
|
type: CommandType.COMMAND,
|
|
8841
6974
|
// eslint-disable-next-line max-lines-per-function
|
|
8842
6975
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
8843
|
-
var _a28;
|
|
8844
|
-
const { unitId, newText, oldTextLen, isCompositionEnd, isCompositionStart } = params, commandService = accessor.get(ICommandService),
|
|
6976
|
+
var _a28, _b2;
|
|
6977
|
+
const { unitId, newText, oldTextLen, isCompositionEnd, isCompositionStart } = params, commandService = accessor.get(ICommandService), renderManagerService = accessor.get(IRenderManagerService), univerInstanceService = accessor.get(IUniverInstanceService), docMenuStyleService = accessor.get(DocMenuStyleService), imeInputManagerService = (_a28 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a28.with(DocIMEInputManagerService), docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
8845
6978
|
if (docDataModel == null || imeInputManagerService == null)
|
|
8846
6979
|
return !1;
|
|
8847
6980
|
const previousActiveRange = imeInputManagerService.getActiveRange();
|
|
@@ -8866,9 +6999,9 @@ const IMEInputCommand = {
|
|
|
8866
6999
|
actions: [],
|
|
8867
7000
|
textRanges
|
|
8868
7001
|
}
|
|
8869
|
-
}, textX = new TextX(), jsonX = JSONX.getInstance();
|
|
7002
|
+
}, styleCache = docMenuStyleService.getStyleCache(), curTextRun = getTextRunAtPosition((_b2 = body.textRuns) != null ? _b2 : [], startOffset + oldTextLen, styleCache), textX = new TextX(), jsonX = JSONX.getInstance();
|
|
8870
7003
|
if (!previousActiveRange.collapsed && isCompositionStart) {
|
|
8871
|
-
const { dos, retain
|
|
7004
|
+
const { dos, retain } = BuildTextUtils.selection.getDeleteActions(previousActiveRange, segmentId, 0, body);
|
|
8872
7005
|
textX.push(...dos), doMutation.params.textRanges = [{
|
|
8873
7006
|
startOffset: startOffset + len + retain,
|
|
8874
7007
|
endOffset: startOffset + len + retain,
|
|
@@ -8877,22 +7010,22 @@ const IMEInputCommand = {
|
|
|
8877
7010
|
} else
|
|
8878
7011
|
textX.push({
|
|
8879
7012
|
t: TextXActionType.RETAIN,
|
|
8880
|
-
len: startOffset
|
|
8881
|
-
segmentId
|
|
7013
|
+
len: startOffset
|
|
8882
7014
|
});
|
|
8883
7015
|
oldTextLen > 0 && textX.push({
|
|
8884
7016
|
t: TextXActionType.DELETE,
|
|
8885
|
-
len: oldTextLen
|
|
8886
|
-
line: 0,
|
|
8887
|
-
segmentId
|
|
7017
|
+
len: oldTextLen
|
|
8888
7018
|
}), textX.push({
|
|
8889
7019
|
t: TextXActionType.INSERT,
|
|
8890
7020
|
body: {
|
|
8891
|
-
dataStream: newText
|
|
7021
|
+
dataStream: newText,
|
|
7022
|
+
textRuns: curTextRun ? [{
|
|
7023
|
+
...curTextRun,
|
|
7024
|
+
st: 0,
|
|
7025
|
+
ed: newText.length
|
|
7026
|
+
}] : []
|
|
8892
7027
|
},
|
|
8893
|
-
len: newText.length
|
|
8894
|
-
line: 0,
|
|
8895
|
-
segmentId
|
|
7028
|
+
len: newText.length
|
|
8896
7029
|
});
|
|
8897
7030
|
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
8898
7031
|
doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation.params.noHistory = !isCompositionEnd, doMutation.params.isCompositionEnd = isCompositionEnd;
|
|
@@ -9192,8 +7325,8 @@ function findLineBeforeAndAfterTable(table) {
|
|
|
9192
7325
|
lineAfterTable
|
|
9193
7326
|
};
|
|
9194
7327
|
const { st, ed } = table, pages = tablePage.type === DocumentSkeletonPageType.CELL ? [tablePage] : tablePage.parent.pages;
|
|
9195
|
-
return lineIterator(pages, (
|
|
9196
|
-
|
|
7328
|
+
return lineIterator(pages, (l3) => {
|
|
7329
|
+
l3.st === ed + 1 ? lineAfterTable = l3 : l3.ed === st - 1 && (lineBeforeTable = l3);
|
|
9197
7330
|
}), {
|
|
9198
7331
|
lineBeforeTable,
|
|
9199
7332
|
lineAfterTable
|
|
@@ -9727,10 +7860,10 @@ function transformOffset2Bound(offsetX, offsetY, scene) {
|
|
|
9727
7860
|
}
|
|
9728
7861
|
__name(transformOffset2Bound, "transformOffset2Bound");
|
|
9729
7862
|
const calcDocRangePositions$1 = /* @__PURE__ */ __name((range, currentRender) => {
|
|
9730
|
-
const { scene, mainComponent, engine } = currentRender, skeleton = currentRender.with(DocSkeletonManagerService).getSkeleton(), startPosition = skeleton.findNodePositionByCharIndex(range.startOffset, !1, range.segmentId, range.segmentPage), endPosition = skeleton.findNodePositionByCharIndex(range.endOffset, !1, range.segmentId, range.segmentPage),
|
|
7863
|
+
const { scene, mainComponent, engine } = currentRender, skeleton = currentRender.with(DocSkeletonManagerService).getSkeleton(), startPosition = skeleton.findNodePositionByCharIndex(range.startOffset, !1, range.segmentId, range.segmentPage), endPosition = skeleton.findNodePositionByCharIndex(range.endOffset, !1, range.segmentId, range.segmentPage), document = mainComponent;
|
|
9731
7864
|
if (!endPosition || !startPosition)
|
|
9732
7865
|
return;
|
|
9733
|
-
const documentOffsetConfig =
|
|
7866
|
+
const documentOffsetConfig = document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, canvasElement = engine.getCanvasElement(), canvasClientRect = canvasElement.getBoundingClientRect(), widthOfCanvas = pxToNum(canvasElement.style.width), { top, left, width } = canvasClientRect, scaleAdjust = width / widthOfCanvas, { scaleX, scaleY } = scene.getAncestorScale(), convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { borderBoxPointGroup } = convertor.getRangePointData(startPosition, endPosition);
|
|
9734
7867
|
return getLineBounding(borderBoxPointGroup).map((bound) => transformBound2OffsetBound(bound, scene)).map((i) => ({
|
|
9735
7868
|
left: (i.left + docsLeft * scaleX) * scaleAdjust + left,
|
|
9736
7869
|
right: (i.right + docsLeft * scaleX) * scaleAdjust + left,
|
|
@@ -9954,7 +8087,7 @@ let DocEventManagerService = (_a15 = class extends Disposable {
|
|
|
9954
8087
|
}));
|
|
9955
8088
|
const onPointerDown$ = fromEventSubject(this._context.mainComponent.onPointerDown$), onPointerUp$ = fromEventSubject(this._context.scene.onPointerUp$);
|
|
9956
8089
|
this.disposeWithMe(onPointerDown$.pipe(
|
|
9957
|
-
|
|
8090
|
+
switchMap((down) => onPointerUp$.pipe(take(1), map$1((up) => ({ down, up })))),
|
|
9958
8091
|
filter$1(({ down, up }) => down.target === up.target && up.timeStamp - down.timeStamp < 300)
|
|
9959
8092
|
// filter(({ down, up }) => down.offsetX === up.offsetX && down.offsetY === up.offsetY)
|
|
9960
8093
|
).subscribe(({ down }) => {
|
|
@@ -10097,8 +8230,8 @@ let DocChecklistRenderController = (_a16 = class extends Disposable {
|
|
|
10097
8230
|
})
|
|
10098
8231
|
);
|
|
10099
8232
|
}
|
|
10100
|
-
_getTransformCoordForDocumentOffset(
|
|
10101
|
-
const { documentTransform } =
|
|
8233
|
+
_getTransformCoordForDocumentOffset(document, viewport, evtOffsetX, evtOffsetY) {
|
|
8234
|
+
const { documentTransform } = document.getOffsetConfig(), originCoord = viewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
10102
8235
|
if (originCoord)
|
|
10103
8236
|
return documentTransform.clone().invert().applyPoint(originCoord);
|
|
10104
8237
|
}
|
|
@@ -10243,7 +8376,7 @@ let DocEditorBridgeController = (_a19 = class extends Disposable {
|
|
|
10243
8376
|
), this.disposeWithMe(
|
|
10244
8377
|
this._docSelectionRenderService.onBlur$.subscribe(() => {
|
|
10245
8378
|
const { unitId } = this._context, editor = this._editorService.getEditor(unitId), focusEditor = this._editorService.getFocusEditor();
|
|
10246
|
-
editor == null || editor.isSheetEditor() || focusEditor && focusEditor.getEditorId() === unitId || this._editorService.blur();
|
|
8379
|
+
editor == null || editor.isSheetEditor() || focusEditor && focusEditor.getEditorId() === unitId || unitId.includes("range_selector") || unitId.includes("embedding_formula_editor") || this._editorService.blur();
|
|
10247
8380
|
})
|
|
10248
8381
|
);
|
|
10249
8382
|
}
|
|
@@ -10323,14 +8456,14 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
|
|
|
10323
8456
|
return kind && result && __defProp$7(target, key, result), result;
|
|
10324
8457
|
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a20;
|
|
10325
8458
|
let DocIMEInputController = (_a20 = class extends Disposable {
|
|
10326
|
-
constructor(_context,
|
|
8459
|
+
constructor(_context, _docSelectionRenderService, _docImeInputManagerService, _docSkeletonManagerService, _commandService) {
|
|
10327
8460
|
super();
|
|
10328
8461
|
__publicField(this, "_previousIMEContent", "");
|
|
10329
8462
|
__publicField(this, "_isCompositionStart", !0);
|
|
10330
8463
|
__publicField(this, "_onStartSubscription");
|
|
10331
8464
|
__publicField(this, "_onUpdateSubscription");
|
|
10332
8465
|
__publicField(this, "_onEndSubscription");
|
|
10333
|
-
this._context = _context, this.
|
|
8466
|
+
this._context = _context, this._docSelectionRenderService = _docSelectionRenderService, this._docImeInputManagerService = _docImeInputManagerService, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._initialize();
|
|
10334
8467
|
}
|
|
10335
8468
|
dispose() {
|
|
10336
8469
|
var _a28, _b2, _c;
|
|
@@ -10359,18 +8492,14 @@ let DocIMEInputController = (_a20 = class extends Disposable {
|
|
|
10359
8492
|
});
|
|
10360
8493
|
}
|
|
10361
8494
|
async _updateContent(config, isUpdate) {
|
|
10362
|
-
var _a28;
|
|
10363
8495
|
if (config == null)
|
|
10364
8496
|
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;
|
|
8497
|
+
const unitId = this._context.unitId, skeleton = this._docSkeletonManagerService.getSkeleton(), { event, activeRange } = config;
|
|
10369
8498
|
if (skeleton == null || activeRange == null)
|
|
10370
8499
|
return;
|
|
10371
8500
|
const content = event.data;
|
|
10372
8501
|
content === this._previousIMEContent && isUpdate || (await this._commandService.executeCommand(IMEInputCommand.id, {
|
|
10373
|
-
unitId
|
|
8502
|
+
unitId,
|
|
10374
8503
|
newText: content,
|
|
10375
8504
|
oldTextLen: this._previousIMEContent.length,
|
|
10376
8505
|
isCompositionStart: this._isCompositionStart,
|
|
@@ -10382,11 +8511,10 @@ let DocIMEInputController = (_a20 = class extends Disposable {
|
|
|
10382
8511
|
}
|
|
10383
8512
|
}, __name(_a20, "DocIMEInputController"), _a20);
|
|
10384
8513
|
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)
|
|
8514
|
+
__decorateParam$7(1, Inject(DocSelectionRenderService)),
|
|
8515
|
+
__decorateParam$7(2, Inject(DocIMEInputManagerService)),
|
|
8516
|
+
__decorateParam$7(3, Inject(DocSkeletonManagerService)),
|
|
8517
|
+
__decorateParam$7(4, ICommandService)
|
|
10390
8518
|
], DocIMEInputController);
|
|
10391
8519
|
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
10392
8520
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -10394,10 +8522,10 @@ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPrope
|
|
|
10394
8522
|
return kind && result && __defProp$6(target, key, result), result;
|
|
10395
8523
|
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a21;
|
|
10396
8524
|
let DocInputController = (_a21 = class extends Disposable {
|
|
10397
|
-
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService) {
|
|
8525
|
+
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService, _docMenuStyleService) {
|
|
10398
8526
|
super();
|
|
10399
8527
|
__publicField(this, "_onInputSubscription");
|
|
10400
|
-
this._context = _context, this._docSelectionRenderService = _docSelectionRenderService, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._init();
|
|
8528
|
+
this._context = _context, this._docSelectionRenderService = _docSelectionRenderService, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._docMenuStyleService = _docMenuStyleService, this._init();
|
|
10401
8529
|
}
|
|
10402
8530
|
dispose() {
|
|
10403
8531
|
var _a28;
|
|
@@ -10408,16 +8536,24 @@ let DocInputController = (_a21 = class extends Disposable {
|
|
|
10408
8536
|
}
|
|
10409
8537
|
_initialNormalInput() {
|
|
10410
8538
|
this._onInputSubscription = this._docSelectionRenderService.onInput$.subscribe(async (config) => {
|
|
8539
|
+
var _a28;
|
|
10411
8540
|
if (config == null)
|
|
10412
8541
|
return;
|
|
10413
|
-
const unitId = this._context
|
|
10414
|
-
if (e.data == null || skeleton == null ||
|
|
8542
|
+
const { unitId } = this._context, { event, content = "", activeRange } = config, e = event, skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
8543
|
+
if (e.data == null || skeleton == null || activeRange == null)
|
|
10415
8544
|
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];
|
|
8545
|
+
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((_a28 = originBody == null ? void 0 : originBody.textRuns) != null ? _a28 : [], activeRange.endOffset, cacheStyle);
|
|
10417
8546
|
await this._commandService.executeCommand(InsertCommand.id, {
|
|
10418
8547
|
unitId,
|
|
10419
8548
|
body: {
|
|
10420
|
-
dataStream: content
|
|
8549
|
+
dataStream: content,
|
|
8550
|
+
textRuns: curTextRun ? [
|
|
8551
|
+
{
|
|
8552
|
+
...curTextRun,
|
|
8553
|
+
st: 0,
|
|
8554
|
+
ed: content.length
|
|
8555
|
+
}
|
|
8556
|
+
] : []
|
|
10421
8557
|
},
|
|
10422
8558
|
range: activeRange,
|
|
10423
8559
|
segmentId,
|
|
@@ -10429,7 +8565,8 @@ let DocInputController = (_a21 = class extends Disposable {
|
|
|
10429
8565
|
DocInputController = __decorateClass$6([
|
|
10430
8566
|
__decorateParam$6(1, Inject(DocSelectionRenderService)),
|
|
10431
8567
|
__decorateParam$6(2, Inject(DocSkeletonManagerService)),
|
|
10432
|
-
__decorateParam$6(3, ICommandService)
|
|
8568
|
+
__decorateParam$6(3, ICommandService),
|
|
8569
|
+
__decorateParam$6(4, Inject(DocMenuStyleService))
|
|
10433
8570
|
], DocInputController);
|
|
10434
8571
|
const _DocPageLayoutService = class _DocPageLayoutService extends Disposable {
|
|
10435
8572
|
constructor(_context) {
|
|
@@ -10441,8 +8578,8 @@ const _DocPageLayoutService = class _DocPageLayoutService extends Disposable {
|
|
|
10441
8578
|
if (parent == null || docsWidth === Number.POSITIVE_INFINITY || docsHeight === Number.POSITIVE_INFINITY)
|
|
10442
8579
|
return;
|
|
10443
8580
|
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 ?
|
|
8581
|
+
let docsLeft = 0, docsTop = pageMarginTop, sceneWidth = 0, sceneHeight = 0, scrollToX = Number.POSITIVE_INFINITY;
|
|
8582
|
+
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
8583
|
const viewport = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
10447
8584
|
return scrollToX !== Number.POSITIVE_INFINITY && viewport != null && viewport.scrollToViewportPos({
|
|
10448
8585
|
viewportScrollX: scrollToX
|
|
@@ -10502,7 +8639,7 @@ let DocSelectionRenderController = (_a23 = class extends Disposable {
|
|
|
10502
8639
|
if (params == null)
|
|
10503
8640
|
return;
|
|
10504
8641
|
const { unitId, docRanges, isEditing, options } = params;
|
|
10505
|
-
unitId === this._context.unitId && (this._docSelectionRenderService.removeAllRanges(),
|
|
8642
|
+
unitId === this._context.unitId && (this._docSelectionRenderService.removeAllRanges(), this._docSelectionRenderService.addDocRanges(docRanges, isEditing, options));
|
|
10506
8643
|
})
|
|
10507
8644
|
);
|
|
10508
8645
|
}
|
|
@@ -10515,12 +8652,12 @@ let DocSelectionRenderController = (_a23 = class extends Disposable {
|
|
|
10515
8652
|
}
|
|
10516
8653
|
// eslint-disable-next-line max-lines-per-function
|
|
10517
8654
|
_initialMain(unitId) {
|
|
10518
|
-
const docObject = neoGetDocObject(this._context), { document
|
|
10519
|
-
this.disposeWithMe(
|
|
10520
|
-
this._isEditorReadOnly(unitId) || (
|
|
10521
|
-
})), this.disposeWithMe(
|
|
10522
|
-
|
|
10523
|
-
})), this.disposeWithMe(
|
|
8655
|
+
const docObject = neoGetDocObject(this._context), { document, scene } = docObject;
|
|
8656
|
+
this.disposeWithMe(document.onPointerEnter$.subscribeEvent(() => {
|
|
8657
|
+
this._isEditorReadOnly(unitId) || (document.cursor = CURSOR_TYPE.TEXT);
|
|
8658
|
+
})), this.disposeWithMe(document.onPointerLeave$.subscribeEvent(() => {
|
|
8659
|
+
document.cursor = CURSOR_TYPE.DEFAULT, scene.resetCursor();
|
|
8660
|
+
})), this.disposeWithMe(document.onPointerDown$.subscribeEvent((evt, state) => {
|
|
10524
8661
|
if (this._isEditorReadOnly(unitId))
|
|
10525
8662
|
return;
|
|
10526
8663
|
const docDataModel = this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
@@ -10531,7 +8668,7 @@ let DocSelectionRenderController = (_a23 = class extends Disposable {
|
|
|
10531
8668
|
pageLayoutType = PageLayoutType.VERTICAL,
|
|
10532
8669
|
pageMarginLeft,
|
|
10533
8670
|
pageMarginTop
|
|
10534
|
-
} =
|
|
8671
|
+
} = document.getOffsetConfig(), { editArea } = skeleton.findEditAreaByCoord(
|
|
10535
8672
|
coord,
|
|
10536
8673
|
pageLayoutType,
|
|
10537
8674
|
pageMarginLeft,
|
|
@@ -10547,14 +8684,14 @@ let DocSelectionRenderController = (_a23 = class extends Disposable {
|
|
|
10547
8684
|
}, 0);
|
|
10548
8685
|
}
|
|
10549
8686
|
evt.button !== 2 && state.stopPropagation();
|
|
10550
|
-
})), this.disposeWithMe(
|
|
8687
|
+
})), this.disposeWithMe(document.onDblclick$.subscribeEvent((evt) => {
|
|
10551
8688
|
this._isEditorReadOnly(unitId) || this._docSelectionRenderService.__handleDblClick(evt);
|
|
10552
|
-
})), this.disposeWithMe(
|
|
8689
|
+
})), this.disposeWithMe(document.onTripleClick$.subscribeEvent((evt) => {
|
|
10553
8690
|
this._isEditorReadOnly(unitId) || this._docSelectionRenderService.__handleTripleClick(evt);
|
|
10554
8691
|
}));
|
|
10555
8692
|
}
|
|
10556
8693
|
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
10557
|
-
const docObject = neoGetDocObject(this._context), { document
|
|
8694
|
+
const docObject = neoGetDocObject(this._context), { document, scene } = docObject, { documentTransform } = document.getOffsetConfig(), activeViewport = scene.getViewports()[0];
|
|
10558
8695
|
if (activeViewport == null)
|
|
10559
8696
|
return;
|
|
10560
8697
|
const originCoord = activeViewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
@@ -10625,6 +8762,9 @@ let DocZoomRenderController = (_a24 = class extends Disposable {
|
|
|
10625
8762
|
const documentModel = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
10626
8763
|
if (!documentModel)
|
|
10627
8764
|
return;
|
|
8765
|
+
const { documentFlavor } = documentModel.getSnapshot().documentStyle;
|
|
8766
|
+
if (documentFlavor === DocumentFlavor.MODERN)
|
|
8767
|
+
return;
|
|
10628
8768
|
const deltaFactor = Math.abs(e.deltaX);
|
|
10629
8769
|
let ratioDelta = deltaFactor < 40 ? 0.2 : deltaFactor < 80 ? 0.4 : 0.2;
|
|
10630
8770
|
ratioDelta *= e.deltaY > 0 ? -1 : 1, scene.scaleX < 1 && (ratioDelta /= 2);
|
|
@@ -10654,12 +8794,19 @@ let DocZoomRenderController = (_a24 = class extends Disposable {
|
|
|
10654
8794
|
const zoomRatio = this._context.unit.zoomRatio || 1;
|
|
10655
8795
|
this.updateViewZoom(zoomRatio);
|
|
10656
8796
|
}
|
|
10657
|
-
}))
|
|
8797
|
+
})), this.disposeWithMe(
|
|
8798
|
+
this._commandService.beforeCommandExecuted((command) => {
|
|
8799
|
+
command.id === SwitchDocModeCommand.id && this._commandService.executeCommand(SetDocZoomRatioCommand.id, {
|
|
8800
|
+
zoomRatio: 1,
|
|
8801
|
+
unitId: this._context.unitId
|
|
8802
|
+
});
|
|
8803
|
+
})
|
|
8804
|
+
);
|
|
10658
8805
|
}
|
|
10659
8806
|
updateViewZoom(zoomRatio, needRefreshSelection = !0) {
|
|
10660
8807
|
var _a28;
|
|
10661
8808
|
const docObject = neoGetDocObject(this._context);
|
|
10662
|
-
docObject.scene.scale(zoomRatio, zoomRatio), this._docPageLayoutService.calculatePagePosition(), needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && this._textSelectionManagerService.refreshSelection(), (_a28 = docObject.scene.getTransformer()) == null || _a28.clearSelectedObjects();
|
|
8809
|
+
docObject.scene.scale(zoomRatio, zoomRatio), this._editorService.isEditor(this._context.unitId) || this._docPageLayoutService.calculatePagePosition(), needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && this._textSelectionManagerService.refreshSelection(), (_a28 = docObject.scene.getTransformer()) == null || _a28.clearSelectedObjects();
|
|
10663
8810
|
}
|
|
10664
8811
|
}, __name(_a24, "DocZoomRenderController"), _a24);
|
|
10665
8812
|
DocZoomRenderController = __decorateClass$3([
|
|
@@ -10691,6 +8838,16 @@ let DocStateChangeManagerService = (_a25 = class extends RxDisposable {
|
|
|
10691
8838
|
__publicField(this, "_changeStateCacheTimer", null);
|
|
10692
8839
|
this._undoRedoService = _undoRedoService, this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._docStateEmitService = _docStateEmitService, this._renderManagerService = _renderManagerService, this._initialize(), this._listenDocStateChange();
|
|
10693
8840
|
}
|
|
8841
|
+
getStateCache(unitId) {
|
|
8842
|
+
var _a28, _b2;
|
|
8843
|
+
return {
|
|
8844
|
+
history: (_a28 = this._historyStateCache.get(unitId)) != null ? _a28 : [],
|
|
8845
|
+
collaboration: (_b2 = this._changeStateCache.get(unitId)) != null ? _b2 : []
|
|
8846
|
+
};
|
|
8847
|
+
}
|
|
8848
|
+
setStateCache(unitId, cache) {
|
|
8849
|
+
this._historyStateCache.set(unitId, cache.history), this._changeStateCache.set(unitId, cache.collaboration);
|
|
8850
|
+
}
|
|
10694
8851
|
_setChangeState(changeState) {
|
|
10695
8852
|
this._cacheChangeState(changeState, "history"), this._cacheChangeState(changeState, "collaboration");
|
|
10696
8853
|
}
|
|
@@ -10712,7 +8869,7 @@ let DocStateChangeManagerService = (_a25 = class extends RxDisposable {
|
|
|
10712
8869
|
var _a28;
|
|
10713
8870
|
if (changeStateInfo == null)
|
|
10714
8871
|
return;
|
|
10715
|
-
const { isCompositionEnd, ...changeState } = changeStateInfo, imeInputManagerService = (_a28 = this._renderManagerService.getRenderById(changeStateInfo.unitId)) == null ? void 0 : _a28.with(DocIMEInputManagerService);
|
|
8872
|
+
const { isCompositionEnd, isSync, syncer, ...changeState } = changeStateInfo, imeInputManagerService = (_a28 = this._renderManagerService.getRenderById(isSync ? syncer : changeStateInfo.unitId)) == null ? void 0 : _a28.with(DocIMEInputManagerService);
|
|
10716
8873
|
if (imeInputManagerService != null) {
|
|
10717
8874
|
if (isCompositionEnd) {
|
|
10718
8875
|
const historyParams = imeInputManagerService.fetchComposedUndoRedoMutationParams();
|
|
@@ -10798,7 +8955,9 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
|
|
|
10798
8955
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10799
8956
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10800
8957
|
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")
|
|
8958
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
|
|
8959
|
+
const DOC_MAIN_CANVAS_ID = "univer-doc-main-canvas";
|
|
8960
|
+
var _a26;
|
|
10802
8961
|
let DocsRenderService = (_a26 = class extends RxDisposable {
|
|
10803
8962
|
constructor(_instanceSrv, _renderManagerService) {
|
|
10804
8963
|
super(), this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._init();
|
|
@@ -10807,8 +8966,11 @@ let DocsRenderService = (_a26 = class extends RxDisposable {
|
|
|
10807
8966
|
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
8967
|
}
|
|
10809
8968
|
_createRenderer(doc) {
|
|
10810
|
-
|
|
10811
|
-
|
|
8969
|
+
var _a28;
|
|
8970
|
+
const unitId = doc.getUnitId(), workbookId = (_a28 = this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a28.getUnitId();
|
|
8971
|
+
this._renderManagerService.created$.subscribe((renderer) => {
|
|
8972
|
+
renderer.unitId === workbookId && (renderer.engine.getCanvas().setId(DOC_MAIN_CANVAS_ID), renderer.engine.getCanvas().getContext().setId(DOC_MAIN_CANVAS_ID));
|
|
8973
|
+
}), this._renderManagerService.has(unitId) || (this._createRenderWithId(unitId), this._renderManagerService.setCurrent(unitId));
|
|
10812
8974
|
}
|
|
10813
8975
|
_createRenderWithId(unitId) {
|
|
10814
8976
|
this._renderManagerService.createRender(unitId);
|
|
@@ -10965,6 +9127,7 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
10965
9127
|
DocTableDeleteRowsCommand,
|
|
10966
9128
|
DocTableDeleteColumnsCommand,
|
|
10967
9129
|
DocTableDeleteTableCommand,
|
|
9130
|
+
CloseHeaderFooterCommand,
|
|
10968
9131
|
DocTableTabCommand,
|
|
10969
9132
|
TabCommand,
|
|
10970
9133
|
AfterSpaceCommand,
|
|
@@ -10975,6 +9138,7 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
10975
9138
|
ToggleCheckListCommand,
|
|
10976
9139
|
QuickListCommand,
|
|
10977
9140
|
IMEInputCommand,
|
|
9141
|
+
SwitchDocModeCommand,
|
|
10978
9142
|
DocParagraphSettingCommand,
|
|
10979
9143
|
InnerPasteCommand,
|
|
10980
9144
|
CutContentCommand,
|
|
@@ -11025,7 +9189,8 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
11025
9189
|
[DocCanvasPopManagerService],
|
|
11026
9190
|
[DocsRenderService],
|
|
11027
9191
|
[DocStateChangeManagerService],
|
|
11028
|
-
[DocAutoFormatService]
|
|
9192
|
+
[DocAutoFormatService],
|
|
9193
|
+
[DocMenuStyleService]
|
|
11029
9194
|
], this._config.override).forEach((d) => injector.add(d));
|
|
11030
9195
|
}
|
|
11031
9196
|
_markDocAsFocused() {
|
|
@@ -11051,8 +9216,8 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
11051
9216
|
[DocIMEInputManagerService],
|
|
11052
9217
|
[DocRenderController],
|
|
11053
9218
|
[DocZoomRenderController]
|
|
11054
|
-
].forEach((
|
|
11055
|
-
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC,
|
|
9219
|
+
].forEach((m3) => {
|
|
9220
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m3);
|
|
11056
9221
|
});
|
|
11057
9222
|
}
|
|
11058
9223
|
_initRenderModules() {
|
|
@@ -11068,8 +9233,8 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
11068
9233
|
[DocInputController],
|
|
11069
9234
|
[DocIMEInputController],
|
|
11070
9235
|
[DocEditorBridgeController]
|
|
11071
|
-
].forEach((
|
|
11072
|
-
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC,
|
|
9236
|
+
].forEach((m3) => {
|
|
9237
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m3);
|
|
11073
9238
|
});
|
|
11074
9239
|
}
|
|
11075
9240
|
}, __name(_a27, "UniverDocsUIPlugin"), _a27);
|
|
@@ -11136,7 +9301,7 @@ export {
|
|
|
11136
9301
|
DocUIController,
|
|
11137
9302
|
DocsRenderService,
|
|
11138
9303
|
Editor,
|
|
11139
|
-
EditorInsertTextCommandId,
|
|
9304
|
+
E as EditorInsertTextCommandId,
|
|
11140
9305
|
EditorService,
|
|
11141
9306
|
EnterCommand,
|
|
11142
9307
|
IDocClipboardService,
|
|
@@ -11151,7 +9316,7 @@ export {
|
|
|
11151
9316
|
MoveSelectionOperation,
|
|
11152
9317
|
NORMAL_TEXT_SELECTION_PLUGIN_NAME,
|
|
11153
9318
|
NodePositionConvertToCursor,
|
|
11154
|
-
NodePositionConvertToRectRange,
|
|
9319
|
+
h as NodePositionConvertToRectRange,
|
|
11155
9320
|
OrderListCommand,
|
|
11156
9321
|
wordPastePlugin$1 as PastePluginLark,
|
|
11157
9322
|
univerPastePlugin as PastePluginUniver,
|
|
@@ -11159,7 +9324,7 @@ export {
|
|
|
11159
9324
|
QuickListCommand,
|
|
11160
9325
|
RangeSelector,
|
|
11161
9326
|
RangeSelectorService,
|
|
11162
|
-
RectRange,
|
|
9327
|
+
R as RectRange,
|
|
11163
9328
|
ReplaceContentCommand,
|
|
11164
9329
|
ReplaceSnapshotCommand,
|
|
11165
9330
|
ResetInlineFormatTextBackgroundColorCommand,
|
|
@@ -11177,26 +9342,23 @@ export {
|
|
|
11177
9342
|
SetInlineFormatTextBackgroundColorCommand,
|
|
11178
9343
|
SetInlineFormatTextColorCommand,
|
|
11179
9344
|
SetInlineFormatUnderlineCommand,
|
|
11180
|
-
TEXT_RANGE_LAYER_INDEX,
|
|
9345
|
+
T as TEXT_RANGE_LAYER_INDEX,
|
|
11181
9346
|
TabCommand,
|
|
11182
9347
|
TextEditor,
|
|
11183
|
-
TextRange,
|
|
9348
|
+
m as TextRange,
|
|
11184
9349
|
ToggleCheckListCommand,
|
|
11185
9350
|
UniverDocsUIPlugin,
|
|
11186
9351
|
UpdateCommand,
|
|
11187
9352
|
VIEWPORT_KEY,
|
|
11188
9353
|
addCustomDecorationBySelectionFactory,
|
|
11189
9354
|
addCustomDecorationFactory,
|
|
11190
|
-
|
|
11191
|
-
addCustomRangeFactory,
|
|
11192
|
-
convertPositionsToRectRanges,
|
|
9355
|
+
k as convertPositionsToRectRanges,
|
|
11193
9356
|
deleteCustomDecorationFactory,
|
|
11194
|
-
deleteCustomRangeFactory,
|
|
11195
9357
|
docDrawingPositionToTransform,
|
|
11196
9358
|
genTableSource,
|
|
11197
9359
|
generateParagraphs,
|
|
11198
9360
|
getAnchorBounding,
|
|
11199
|
-
getCanvasOffsetByEngine,
|
|
9361
|
+
l as getCanvasOffsetByEngine,
|
|
11200
9362
|
getCommandSkeleton,
|
|
11201
9363
|
getCursorWhenDelete,
|
|
11202
9364
|
getCustomBlockIdsInSelections,
|
|
@@ -11206,17 +9368,16 @@ export {
|
|
|
11206
9368
|
getEmptyTableCell,
|
|
11207
9369
|
getEmptyTableRow,
|
|
11208
9370
|
getLineBounding,
|
|
11209
|
-
getOneTextSelectionRange,
|
|
9371
|
+
j as getOneTextSelectionRange,
|
|
11210
9372
|
getParagraphsInRange,
|
|
11211
9373
|
getParagraphsInRanges,
|
|
11212
9374
|
getRichTextEditPath,
|
|
11213
9375
|
getTableColumn,
|
|
11214
9376
|
hasParagraphInTable,
|
|
11215
9377
|
isInSameTableCell,
|
|
11216
|
-
isValidRectRange,
|
|
9378
|
+
f as isValidRectRange,
|
|
11217
9379
|
menuSchema,
|
|
11218
9380
|
neoGetDocObject,
|
|
11219
|
-
replaceSelectionFactory,
|
|
11220
9381
|
transformToDocDrawingPosition,
|
|
11221
9382
|
whenDocAndEditorFocused
|
|
11222
9383
|
};
|