@univerjs/docs-ui 0.3.0 → 0.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +8 -7
- package/lib/es/index.js +332 -141
- package/lib/locale/fa-IR.json +81 -0
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +2 -2
- package/lib/types/commands/commands/replace-content.command.d.ts +14 -1
- package/lib/types/components/editor/TextEditor.d.ts +2 -2
- package/lib/types/components/editor/utils.d.ts +7 -0
- package/lib/types/components/range-selector/RangeSelector.d.ts +2 -2
- package/lib/types/controllers/config.schema.d.ts +1 -1
- package/lib/types/controllers/doc-header-footer.controller.d.ts +2 -2
- package/lib/types/controllers/render-controllers/back-scroll.render-controller.d.ts +2 -2
- package/lib/types/controllers/render-controllers/doc-clipboard.controller.d.ts +4 -2
- package/lib/types/controllers/render-controllers/doc-editor-bridge.controller.d.ts +2 -2
- package/lib/types/controllers/render-controllers/doc-resize.render-controller.d.ts +1 -1
- package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +2 -2
- package/lib/types/docs-ui-plugin.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/fa-IR.d.ts +3 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +1 -1
- package/lib/types/services/doc-state-change-manager.service.d.ts +1 -1
- package/lib/types/services/editor/editor-manager.service.d.ts +14 -4
- package/lib/types/services/editor/editor.d.ts +30 -18
- package/lib/types/services/selection/convert-rect-range.d.ts +1 -1
- package/lib/types/services/selection/doc-selection-render.service.d.ts +4 -2
- package/lib/types/services/selection/rect-range.d.ts +1 -1
- package/lib/types/services/selection/selection-utils.d.ts +3 -3
- package/lib/umd/index.js +8 -7
- package/package.json +14 -22
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { Inject, Disposable, toDisposable, UniverInstanceType, BuildTextUtils, IUniverInstanceService, TextX, JSONX, TextXActionType, getBodySlice, Tools, UpdateDocsAttributeType, ObjectRelativeFromH, ObjectRelativeFromV, CommandType, ICommandService, IUndoRedoService, DOC_RANGE_TYPE, RANGE_DIRECTION, COLORS, BooleanNumber, Rectangle, RxDisposable, DataStreamTreeTokenType, ILogService, DEFAULT_STYLES, createIdentifier, EDITOR_ACTIVATED, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, FOCUSING_EDITOR_INPUT_FORMULA, DEFAULT_EMPTY_DOCUMENT_VALUE, VerticalAlign, HorizontalAlign, IContextService, useDependency, LocaleService, isInternalEditorID, debounce,
|
|
5
|
+
import { Inject, Disposable, toDisposable, UniverInstanceType, BuildTextUtils, IUniverInstanceService, TextX, JSONX, TextXActionType, getBodySlice, Tools, UpdateDocsAttributeType, ObjectRelativeFromH, ObjectRelativeFromV, CommandType, ICommandService, IUndoRedoService, DOC_RANGE_TYPE, RANGE_DIRECTION, COLORS, BooleanNumber, Rectangle, RxDisposable, DataStreamTreeTokenType, ILogService, DEFAULT_STYLES, createIdentifier, EDITOR_ACTIVATED, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, FOCUSING_EDITOR_INPUT_FORMULA, DEFAULT_EMPTY_DOCUMENT_VALUE, VerticalAlign, HorizontalAlign, IContextService, DocumentFlavor, useDependency, LocaleService, isInternalEditorID, debounce, PresetListType, sequenceExecuteAsync, FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_COMMON_DRAWINGS, MemoryCursor, BaselineOffset, PRESET_LIST_TYPE, GridType, sortRulesFactory, useObservable, TableCellHeightRule, TableSizeType, generateRandomId, TableAlignmentType, TableTextWrapType, PositionedObjectLayoutType, getCustomRangeSlice, getCustomDecorationSlice, LRUMap, ColorKit, skipParseTagNames, CustomRangeType, DataStreamTreeNodeType, SliceBodyType, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, normalizeBody, updateAttributeByInsert, SpacingRule, ThemeService, Injector, connectInjector, IConfigService, QuickListTypeMap, Direction, DisposableCollection, fromEventSubject, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, checkForSubstrings, UndoCommandId, RedoCommandId, DependentOn, Plugin, touchDependencies, mergeOverrideWithDependencies } from "@univerjs/core";
|
|
6
6
|
import { DocSelectionManagerService, RichTextEditingMutation, DocSkeletonManagerService, SetTextSelectionsOperation, DocStateEmitService, DocInterceptorService } from "@univerjs/docs";
|
|
7
7
|
import { IRenderManagerService, Liquid, GlyphType, DocumentSkeletonPageType, getPageFromPath, getTableIdAndSliceIndex, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, getColor, RegularPolygon, Rect, getOffsetRectForDom, ScrollTimer, CURSOR_TYPE, getSystemHighlightColor, Vector2, PageLayoutType, DocumentEditArea, Shape, Path, getCharSpaceApply, getNumberUnitValue, hasListGlyph, isIndentByGlyph, isFirstGlyph, getParagraphByGlyph, pixelToPt, ptToPixel, parseDataStreamToTree, Viewport, ScrollBar, Layer, Documents, DocBackground, lineIterator, getLastLine, pxToNum, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
8
8
|
import * as require$$0 from "react";
|
|
@@ -11,7 +11,6 @@ import { LexerTreeBuilder, operatorToken, isReferenceStrings, serializeRange, se
|
|
|
11
11
|
import { Subject, BehaviorSubject, takeUntil, fromEvent, merge, combineLatest, Observable, map as map$1, distinctUntilChanged, filter as filter$1, throttleTime, mergeMap, take, animationFrameScheduler } from "rxjs";
|
|
12
12
|
import { ILayoutService, useEvent, ComponentManager, ISidebarService, KeyCode, MetaKeys, IClipboardInterfaceService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, CopyCommand, CutCommand, PasteCommand, IConfirmService, MenuItemType, getMenuHiddenObservable, FONT_FAMILY_LIST, FONT_SIZE_LIST, getHeaderFooterMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, FontFamily, FontFamilyItem, FontSize, BuiltInUIPart, IMenuManagerService, IUIPartsService, IShortcutService, ICanvasPopupService, IContextMenuService, SetEditorResizeOperation } from "@univerjs/ui";
|
|
13
13
|
import { Tooltip, Dialog, Button, Input, Checkbox, InputNumber, Slider, Select, ColorPicker } from "@univerjs/design";
|
|
14
|
-
import clsx from "clsx";
|
|
15
14
|
import { filter, bufferTime, map } from "rxjs/operators";
|
|
16
15
|
var __defProp$r = Object.defineProperty, __getOwnPropDesc$r = Object.getOwnPropertyDescriptor, __decorateClass$r = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
17
16
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -321,10 +320,11 @@ function addCustomRangeBySelectionFactory(accessor, param) {
|
|
|
321
320
|
}
|
|
322
321
|
__name(addCustomRangeBySelectionFactory, "addCustomRangeBySelectionFactory");
|
|
323
322
|
function deleteCustomRangeFactory(accessor, params) {
|
|
324
|
-
|
|
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
325
|
if (!documentDataModel)
|
|
326
326
|
return !1;
|
|
327
|
-
const doMutation = {
|
|
327
|
+
const textRange = selection != null && selection.collapsed ? { index: selection.startOffset } : void 0, doMutation = {
|
|
328
328
|
id: RichTextEditingMutation.id,
|
|
329
329
|
params: {
|
|
330
330
|
unitId: params.unitId,
|
|
@@ -336,12 +336,13 @@ function deleteCustomRangeFactory(accessor, params) {
|
|
|
336
336
|
documentDataModel,
|
|
337
337
|
rangeId: params.rangeId,
|
|
338
338
|
insert,
|
|
339
|
-
segmentId
|
|
339
|
+
segmentId,
|
|
340
|
+
textRange
|
|
340
341
|
});
|
|
341
342
|
if (!textX)
|
|
342
343
|
return !1;
|
|
343
344
|
const path = getRichTextEditPath(documentDataModel, segmentId);
|
|
344
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation;
|
|
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;
|
|
345
346
|
}
|
|
346
347
|
__name(deleteCustomRangeFactory, "deleteCustomRangeFactory");
|
|
347
348
|
function hasParagraphInTable(paragraph, tables) {
|
|
@@ -445,15 +446,82 @@ function isElementVisible(element2) {
|
|
|
445
446
|
return !(rect.width === 0 || rect.height === 0 || rect.bottom < 0 || rect.top > window.innerHeight || rect.right < 0 || rect.left > window.innerWidth);
|
|
446
447
|
}
|
|
447
448
|
__name(isElementVisible, "isElementVisible");
|
|
448
|
-
const
|
|
449
|
+
const ReplaceSnapshotCommand = {
|
|
450
|
+
id: "doc.command-replace-snapshot",
|
|
451
|
+
type: CommandType.COMMAND,
|
|
452
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
453
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
454
|
+
const { unitId, snapshot, textRanges, segmentId = "", options } = params, univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), prevSnapshot = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getSnapshot();
|
|
455
|
+
if (docDataModel == null || prevSnapshot == null)
|
|
456
|
+
return !1;
|
|
457
|
+
const { body, tableSource, footers, headers, lists, drawings, drawingsOrder } = snapshot, {
|
|
458
|
+
body: prevBody,
|
|
459
|
+
tableSource: prevTableSource,
|
|
460
|
+
footers: prevFooters,
|
|
461
|
+
headers: prevHeaders,
|
|
462
|
+
lists: prevLists,
|
|
463
|
+
drawings: prevDrawings,
|
|
464
|
+
drawingsOrder: prevDrawingsOrder
|
|
465
|
+
} = prevSnapshot;
|
|
466
|
+
if (body == null || prevBody == null)
|
|
467
|
+
return !1;
|
|
468
|
+
if (Tools.diffValue(body, prevBody) && textRanges)
|
|
469
|
+
return docSelectionManagerService.replaceDocRanges(textRanges, {
|
|
470
|
+
unitId,
|
|
471
|
+
subUnitId: unitId
|
|
472
|
+
}, !1), !0;
|
|
473
|
+
const doMutation = {
|
|
474
|
+
id: RichTextEditingMutation.id,
|
|
475
|
+
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 = {
|
|
449
514
|
id: "doc.command-replace-content",
|
|
450
515
|
type: CommandType.COMMAND,
|
|
451
516
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
452
|
-
const { unitId, body, textRanges, segmentId = "", options } = params, univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), docDataModel = univerInstanceService.
|
|
453
|
-
if (docDataModel == null || prevBody == null
|
|
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)
|
|
454
519
|
return !1;
|
|
455
520
|
const doMutation = getMutationParams(unitId, segmentId, docDataModel, prevBody, body);
|
|
456
|
-
return doMutation.params.textRanges = textRanges, options && (doMutation.params.options = options),
|
|
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);
|
|
457
525
|
}, "handler")
|
|
458
526
|
}, CoverContentCommand = {
|
|
459
527
|
id: "doc.command-cover-content",
|
|
@@ -469,15 +537,8 @@ const ReplaceContentCommand = {
|
|
|
469
537
|
), undoRedoService.clearUndoRedo(unitId), !0;
|
|
470
538
|
}, "handler")
|
|
471
539
|
};
|
|
472
|
-
function
|
|
473
|
-
const
|
|
474
|
-
id: RichTextEditingMutation.id,
|
|
475
|
-
params: {
|
|
476
|
-
unitId,
|
|
477
|
-
actions: [],
|
|
478
|
-
textRanges: []
|
|
479
|
-
}
|
|
480
|
-
}, textX = new TextX(), jsonX = JSONX.getInstance(), deleteLen = (prevBody == null ? void 0 : prevBody.dataStream.length) - 2;
|
|
540
|
+
function getMutationActions(segmentId, docDatModel, prevBody, body) {
|
|
541
|
+
const textX = new TextX(), jsonX = JSONX.getInstance(), deleteLen = (prevBody == null ? void 0 : prevBody.dataStream.length) - 2;
|
|
481
542
|
deleteLen > 0 && textX.push({
|
|
482
543
|
t: TextXActionType.DELETE,
|
|
483
544
|
len: deleteLen,
|
|
@@ -491,7 +552,19 @@ function getMutationParams(unitId, segmentId, docDatModel, prevBody, body) {
|
|
|
491
552
|
segmentId
|
|
492
553
|
});
|
|
493
554
|
const path = getRichTextEditPath(docDatModel, segmentId);
|
|
494
|
-
return
|
|
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;
|
|
495
568
|
}
|
|
496
569
|
__name(getMutationParams, "getMutationParams");
|
|
497
570
|
CommandType.COMMAND;
|
|
@@ -917,14 +990,16 @@ const _NodePositionConvertToRectRange = class _NodePositionConvertToRectRange {
|
|
|
917
990
|
}
|
|
918
991
|
if (tables.length === 0)
|
|
919
992
|
return;
|
|
920
|
-
const totalColumns = tables[0].rows[0].cells.length;
|
|
921
|
-
if (startColumnIndex === 0 && endColumnIndex === totalColumns - 1)
|
|
922
|
-
return nodePositionGroup.push({
|
|
923
|
-
anchor: anchorNodePosition,
|
|
924
|
-
focus: focusNodePosition
|
|
925
|
-
}), nodePositionGroup;
|
|
926
993
|
for (const table of tables)
|
|
927
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
|
+
}
|
|
928
1003
|
return nodePositionGroup;
|
|
929
1004
|
}
|
|
930
1005
|
_collectPositionGroup(table, nodePositionGroup, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex, segmentPage, compare) {
|
|
@@ -1364,8 +1439,8 @@ const _RectRange = class _RectRange {
|
|
|
1364
1439
|
};
|
|
1365
1440
|
__name(_RectRange, "RectRange");
|
|
1366
1441
|
let RectRange = _RectRange;
|
|
1367
|
-
function getTextRangeFromCharIndex(startOffset, endOffset, scene, document2, skeleton, style, segmentId, segmentPage) {
|
|
1368
|
-
const startNodePosition = skeleton.findNodePositionByCharIndex(startOffset,
|
|
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);
|
|
1369
1444
|
if (!(startNodePosition == null || endNodePosition == null))
|
|
1370
1445
|
return new TextRange(scene, document2, skeleton, startNodePosition, endNodePosition, style, segmentId, segmentPage);
|
|
1371
1446
|
}
|
|
@@ -1616,7 +1691,6 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1616
1691
|
_setRangeStyle(style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE) {
|
|
1617
1692
|
this._selectionStyle = style;
|
|
1618
1693
|
}
|
|
1619
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1620
1694
|
addDocRanges(ranges, isEditing = !0, options) {
|
|
1621
1695
|
const {
|
|
1622
1696
|
_currentSegmentId: segmentId,
|
|
@@ -1624,9 +1698,9 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1624
1698
|
_selectionStyle: style
|
|
1625
1699
|
} = this, { scene, mainComponent } = this._context, document2 = mainComponent, docSkeleton = this._docSkeletonManagerService.getSkeleton();
|
|
1626
1700
|
for (const range of ranges) {
|
|
1627
|
-
const { startOffset, endOffset, rangeType } = range;
|
|
1701
|
+
const { startOffset, endOffset, rangeType, startNodePosition, endNodePosition } = range;
|
|
1628
1702
|
if (rangeType === DOC_RANGE_TYPE.RECT) {
|
|
1629
|
-
const
|
|
1703
|
+
const rectRange = getRectRangeFromCharIndex(
|
|
1630
1704
|
startOffset,
|
|
1631
1705
|
endOffset,
|
|
1632
1706
|
scene,
|
|
@@ -1638,15 +1712,17 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1638
1712
|
);
|
|
1639
1713
|
rectRange && this._addRectRanges([rectRange]);
|
|
1640
1714
|
} else if (rangeType === DOC_RANGE_TYPE.TEXT) {
|
|
1641
|
-
const
|
|
1642
|
-
startOffset,
|
|
1643
|
-
endOffset,
|
|
1715
|
+
const textRange = getTextRangeFromCharIndex(
|
|
1716
|
+
startNodePosition != null && startNodePosition.isBack ? startOffset : startOffset - 1,
|
|
1717
|
+
endNodePosition != null && endNodePosition.isBack ? endOffset : endOffset - 1,
|
|
1644
1718
|
scene,
|
|
1645
1719
|
document2,
|
|
1646
1720
|
docSkeleton,
|
|
1647
1721
|
style,
|
|
1648
1722
|
segmentId,
|
|
1649
|
-
segmentPage
|
|
1723
|
+
segmentPage,
|
|
1724
|
+
startNodePosition == null ? void 0 : startNodePosition.isBack,
|
|
1725
|
+
endNodePosition == null ? void 0 : endNodePosition.isBack
|
|
1650
1726
|
);
|
|
1651
1727
|
textRange && this._addTextRange(textRange);
|
|
1652
1728
|
} else {
|
|
@@ -1705,7 +1781,7 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1705
1781
|
* @deprecated
|
|
1706
1782
|
*/
|
|
1707
1783
|
activate(x, y, force = !1) {
|
|
1708
|
-
const isFocusing = this._input === document.activeElement;
|
|
1784
|
+
const isFocusing = this._input === document.activeElement || document.activeElement === document.body || document.activeElement === null;
|
|
1709
1785
|
this._container.style.left = `${x}px`, this._container.style.top = `${y}px`, this._container.style.zIndex = "1000", (isFocusing || force) && this.focus();
|
|
1710
1786
|
}
|
|
1711
1787
|
hasFocus() {
|
|
@@ -1811,7 +1887,7 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1811
1887
|
return;
|
|
1812
1888
|
}
|
|
1813
1889
|
const { segmentId, segmentPage } = startNode;
|
|
1814
|
-
segmentId && this._currentSegmentId && segmentId !== this._currentSegmentId && this.setSegment(segmentId), segmentId && segmentPage !== this._currentSegmentPage && this.setSegmentPage(segmentPage), this._anchorNodePosition = position, evt.shiftKey && this._getActiveRangeInstance() ? this._updateActiveRangePosition(position) :
|
|
1890
|
+
segmentId && this._currentSegmentId && segmentId !== this._currentSegmentId && this.setSegment(segmentId), segmentId && segmentPage !== this._currentSegmentPage && this.setSegmentPage(segmentPage), this._anchorNodePosition = position, evt.shiftKey && this._getActiveRangeInstance() ? this._updateActiveRangePosition(position) : evt.ctrlKey ? this._removeAllCollapsedTextRanges() : this._isEmpty() || this._removeAllRanges(), scene.disableObjectsEvent();
|
|
1815
1891
|
const scrollTimer = ScrollTimer.create(scene);
|
|
1816
1892
|
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();
|
|
1817
1893
|
let preMoveOffsetX = evtOffsetX, preMoveOffsetY = evtOffsetY;
|
|
@@ -1824,11 +1900,15 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1824
1900
|
if ([...this._scenePointerMoveSubs, ...this._scenePointerUpSubs].forEach((e) => {
|
|
1825
1901
|
e.unsubscribe();
|
|
1826
1902
|
}), scene.enableObjectsEvent(), this._anchorNodePosition && !this._focusNodePosition) {
|
|
1903
|
+
if (evt.ctrlKey) {
|
|
1904
|
+
this._disposeScrollTimers();
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1827
1907
|
const textRange = new TextRange(scene, mainComponent, skeleton, this._anchorNodePosition, void 0, this._selectionStyle, this._currentSegmentId, this._currentSegmentPage);
|
|
1828
1908
|
this._addTextRange(textRange);
|
|
1829
1909
|
} else if (this._anchorNodePosition && this._focusNodePosition) {
|
|
1830
1910
|
for (const textRange of this._rangeListCache)
|
|
1831
|
-
this._addTextRange(textRange);
|
|
1911
|
+
evt.ctrlKey ? textRange.collapsed ? textRange.dispose() : this._addTextRange(textRange) : this._addTextRange(textRange);
|
|
1832
1912
|
this._addRectRanges(this._rectRangeListCache), this._rangeListCache = [], this._rectRangeListCache = [];
|
|
1833
1913
|
}
|
|
1834
1914
|
this._anchorNodePosition = null, this._focusNodePosition = null;
|
|
@@ -1840,9 +1920,7 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1840
1920
|
style: this._selectionStyle,
|
|
1841
1921
|
isEditing: !1
|
|
1842
1922
|
};
|
|
1843
|
-
this._textSelectionInner$.next(selectionInfo), this.
|
|
1844
|
-
timer == null || timer.dispose();
|
|
1845
|
-
}), this._scrollTimers = [], this._updateInputPosition(!0);
|
|
1923
|
+
this._textSelectionInner$.next(selectionInfo), this._disposeScrollTimers(), this._updateInputPosition(!0);
|
|
1846
1924
|
}));
|
|
1847
1925
|
}
|
|
1848
1926
|
removeAllRanges() {
|
|
@@ -1851,12 +1929,17 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1851
1929
|
getActiveTextRange() {
|
|
1852
1930
|
return this._getActiveRangeInstance();
|
|
1853
1931
|
}
|
|
1932
|
+
_disposeScrollTimers() {
|
|
1933
|
+
this._scrollTimers.forEach((timer) => {
|
|
1934
|
+
timer == null || timer.dispose();
|
|
1935
|
+
}), this._scrollTimers = [];
|
|
1936
|
+
}
|
|
1854
1937
|
_setSystemHighlightColorToStyle() {
|
|
1855
|
-
const { r, g, b, a } = getSystemHighlightColor(), style = {
|
|
1938
|
+
const { r: r2, g, b, a } = getSystemHighlightColor(), style = {
|
|
1856
1939
|
strokeWidth: 1.5,
|
|
1857
1940
|
stroke: "rgba(0, 0, 0, 0)",
|
|
1858
1941
|
strokeActive: "rgba(0, 0, 0, 1)",
|
|
1859
|
-
fill: `rgba(${
|
|
1942
|
+
fill: `rgba(${r2}, ${g}, ${b}, ${a != null ? a : 0.3})`
|
|
1860
1943
|
};
|
|
1861
1944
|
this._setRangeStyle(style);
|
|
1862
1945
|
}
|
|
@@ -1970,6 +2053,10 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1970
2053
|
range.dispose();
|
|
1971
2054
|
}), this._rectRangeList = [];
|
|
1972
2055
|
}
|
|
2056
|
+
_removeAllCollapsedTextRanges() {
|
|
2057
|
+
for (const range of this._rangeList)
|
|
2058
|
+
range.collapsed && range.dispose();
|
|
2059
|
+
}
|
|
1973
2060
|
_deactivateAllTextRanges() {
|
|
1974
2061
|
this._rangeList.forEach((range) => {
|
|
1975
2062
|
range.deactivate();
|
|
@@ -2324,23 +2411,18 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2324
2411
|
}
|
|
2325
2412
|
// get editor id.
|
|
2326
2413
|
getEditorId() {
|
|
2327
|
-
return this.
|
|
2414
|
+
return this._getEditorId();
|
|
2328
2415
|
}
|
|
2329
2416
|
// get document data.
|
|
2330
2417
|
getDocumentData() {
|
|
2331
|
-
|
|
2332
|
-
return this._univerInstanceService.getUnit(editorUnitId, UniverInstanceType.UNIVER_DOC).getSnapshot();
|
|
2418
|
+
return this._getDocDataModel().getSnapshot();
|
|
2333
2419
|
}
|
|
2334
2420
|
// Set the new document data.
|
|
2335
2421
|
setDocumentData(data, textRanges) {
|
|
2336
|
-
const { id
|
|
2337
|
-
this._commandService.executeCommand(
|
|
2422
|
+
const { id } = data;
|
|
2423
|
+
this._commandService.executeCommand(ReplaceSnapshotCommand.id, {
|
|
2338
2424
|
unitId: id,
|
|
2339
|
-
|
|
2340
|
-
...body,
|
|
2341
|
-
dataStream: body != null && body.dataStream.endsWith(`\r
|
|
2342
|
-
`) ? body.dataStream.substring(0, body.dataStream.length - 2) : body.dataStream
|
|
2343
|
-
},
|
|
2425
|
+
snapshot: data,
|
|
2344
2426
|
textRanges
|
|
2345
2427
|
});
|
|
2346
2428
|
}
|
|
@@ -2349,11 +2431,8 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2349
2431
|
const editorUnitId = this.getEditorId();
|
|
2350
2432
|
return this._undoRedoService.clearUndoRedo(editorUnitId);
|
|
2351
2433
|
}
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
*/
|
|
2355
|
-
get documentDataModel() {
|
|
2356
|
-
return this._param.documentDataModel;
|
|
2434
|
+
dispose() {
|
|
2435
|
+
this._getDocDataModel().dispose();
|
|
2357
2436
|
}
|
|
2358
2437
|
/**
|
|
2359
2438
|
* @deprecated use getEditorId.
|
|
@@ -2361,6 +2440,12 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2361
2440
|
get editorUnitId() {
|
|
2362
2441
|
return this._param.editorUnitId;
|
|
2363
2442
|
}
|
|
2443
|
+
/**
|
|
2444
|
+
* @deprecated @TODO: @JOCS remove this in the future.
|
|
2445
|
+
*/
|
|
2446
|
+
get params() {
|
|
2447
|
+
return this._param;
|
|
2448
|
+
}
|
|
2364
2449
|
get cancelDefaultResizeListener() {
|
|
2365
2450
|
return this._param.cancelDefaultResizeListener;
|
|
2366
2451
|
}
|
|
@@ -2368,7 +2453,8 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2368
2453
|
return this._param.render;
|
|
2369
2454
|
}
|
|
2370
2455
|
isSingleChoice() {
|
|
2371
|
-
|
|
2456
|
+
var _a28;
|
|
2457
|
+
return (_a28 = this._param.isSingleChoice) != null ? _a28 : !1;
|
|
2372
2458
|
}
|
|
2373
2459
|
/** @deprecated */
|
|
2374
2460
|
setOpenForSheetUnitId(unitId) {
|
|
@@ -2439,13 +2525,13 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2439
2525
|
*/
|
|
2440
2526
|
getValue() {
|
|
2441
2527
|
var _a28;
|
|
2442
|
-
return (((_a28 = this.
|
|
2528
|
+
return (((_a28 = this._getDocDataModel().getBody()) == null ? void 0 : _a28.dataStream) || "").replace(/\r\n/g, "").replace(/\n/g, "").replace(/\n/g, "");
|
|
2443
2529
|
}
|
|
2444
2530
|
/**
|
|
2445
2531
|
* @deprecated use getDocumentData.
|
|
2446
2532
|
*/
|
|
2447
2533
|
getBody() {
|
|
2448
|
-
return this.
|
|
2534
|
+
return this._getDocDataModel().getBody();
|
|
2449
2535
|
}
|
|
2450
2536
|
/**
|
|
2451
2537
|
* @deprecated.
|
|
@@ -2456,32 +2542,46 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2456
2542
|
...param
|
|
2457
2543
|
};
|
|
2458
2544
|
}
|
|
2545
|
+
/**
|
|
2546
|
+
* @deprecated.
|
|
2547
|
+
*/
|
|
2459
2548
|
verticalAlign() {
|
|
2460
|
-
var _a28
|
|
2461
|
-
const
|
|
2462
|
-
if (
|
|
2549
|
+
var _a28;
|
|
2550
|
+
const docDataModel = this._getDocDataModel();
|
|
2551
|
+
if (docDataModel == null)
|
|
2463
2552
|
return;
|
|
2464
2553
|
const { width, height } = this._param.editorDom.getBoundingClientRect();
|
|
2465
2554
|
if (height === 0 || width === 0)
|
|
2466
2555
|
return;
|
|
2467
2556
|
if (!this.isSingle()) {
|
|
2468
|
-
|
|
2557
|
+
docDataModel.updateDocumentDataPageSize(width, void 0);
|
|
2469
2558
|
return;
|
|
2470
2559
|
}
|
|
2471
2560
|
let fontSize = DEFAULT_STYLES.fs;
|
|
2472
|
-
(
|
|
2561
|
+
(_a28 = this._param.canvasStyle) != null && _a28.fontSize && (fontSize = this._param.canvasStyle.fontSize);
|
|
2473
2562
|
const top = (height - fontSize * 4 / 3) / 2 - 2;
|
|
2474
|
-
|
|
2563
|
+
docDataModel.updateDocumentDataMargin({
|
|
2475
2564
|
t: top < 0 ? 0 : top
|
|
2476
|
-
}),
|
|
2565
|
+
}), docDataModel.updateDocumentDataPageSize(void 0, void 0);
|
|
2477
2566
|
}
|
|
2567
|
+
/**
|
|
2568
|
+
* @deprecated.
|
|
2569
|
+
*/
|
|
2478
2570
|
updateCanvasStyle() {
|
|
2479
2571
|
var _a28;
|
|
2480
|
-
const
|
|
2481
|
-
if (
|
|
2572
|
+
const docDataModel = this._getDocDataModel();
|
|
2573
|
+
if (docDataModel == null)
|
|
2482
2574
|
return;
|
|
2483
2575
|
const documentStyle = {};
|
|
2484
|
-
(_a28 = this._param.canvasStyle) != null && _a28.fontSize && (documentStyle.textStyle == null && (documentStyle.textStyle = {}), documentStyle.textStyle.fs = this._param.canvasStyle.fontSize),
|
|
2576
|
+
(_a28 = this._param.canvasStyle) != null && _a28.fontSize && (documentStyle.textStyle == null && (documentStyle.textStyle = {}), documentStyle.textStyle.fs = this._param.canvasStyle.fontSize), docDataModel.updateDocumentStyle(documentStyle);
|
|
2577
|
+
}
|
|
2578
|
+
_getDocDataModel() {
|
|
2579
|
+
const editorUnitId = this._getEditorId();
|
|
2580
|
+
return this._univerInstanceService.getUnit(editorUnitId, UniverInstanceType.UNIVER_DOC);
|
|
2581
|
+
}
|
|
2582
|
+
_getEditorId() {
|
|
2583
|
+
var _a28;
|
|
2584
|
+
return ((_a28 = this._param.initialSnapshot) == null ? void 0 : _a28.id) || this._param.editorUnitId || "";
|
|
2485
2585
|
}
|
|
2486
2586
|
};
|
|
2487
2587
|
__name(_Editor, "Editor");
|
|
@@ -2539,6 +2639,7 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2539
2639
|
})
|
|
2540
2640
|
);
|
|
2541
2641
|
}
|
|
2642
|
+
/** @deprecated */
|
|
2542
2643
|
_blurSheetEditor(target) {
|
|
2543
2644
|
if (editorFocusInElements.some((item) => target.classList.contains(item)))
|
|
2544
2645
|
return;
|
|
@@ -2561,10 +2662,12 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2561
2662
|
isEditor(editorUnitId) {
|
|
2562
2663
|
return this._editors.has(editorUnitId);
|
|
2563
2664
|
}
|
|
2665
|
+
/** @deprecated */
|
|
2564
2666
|
isSheetEditor(editorUnitId) {
|
|
2565
2667
|
const editor = this._editors.get(editorUnitId);
|
|
2566
2668
|
return !!(editor && editor.isSheetEditor());
|
|
2567
2669
|
}
|
|
2670
|
+
/** @deprecated */
|
|
2568
2671
|
closeRangePrompt() {
|
|
2569
2672
|
const documentDataModel = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
2570
2673
|
if (!documentDataModel)
|
|
@@ -2580,15 +2683,18 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2580
2683
|
getSpreadsheetFocusState() {
|
|
2581
2684
|
return this._spreadsheetFocusState;
|
|
2582
2685
|
}
|
|
2686
|
+
/** @deprecated */
|
|
2583
2687
|
focusStyle(editorUnitId) {
|
|
2584
2688
|
const editor = this.getEditor(editorUnitId);
|
|
2585
2689
|
if (!editor)
|
|
2586
2690
|
return !1;
|
|
2587
2691
|
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);
|
|
2588
2692
|
}
|
|
2693
|
+
/** @deprecated */
|
|
2589
2694
|
singleSelection(state) {
|
|
2590
2695
|
this._singleSelection$.next(state);
|
|
2591
2696
|
}
|
|
2697
|
+
/** @deprecated */
|
|
2592
2698
|
selectionChangingState() {
|
|
2593
2699
|
const editorUnitId = this.getFocusId();
|
|
2594
2700
|
if (editorUnitId == null)
|
|
@@ -2663,10 +2769,12 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2663
2769
|
getFirstEditor() {
|
|
2664
2770
|
return [...this.getAllEditor().values()][0];
|
|
2665
2771
|
}
|
|
2772
|
+
/** @deprecated */
|
|
2666
2773
|
resize(unitId) {
|
|
2667
2774
|
const editor = this.getEditor(unitId);
|
|
2668
2775
|
editor != null && (editor.verticalAlign(), this._resize$.next(unitId));
|
|
2669
2776
|
}
|
|
2777
|
+
/** @deprecated */
|
|
2670
2778
|
isVisible(id) {
|
|
2671
2779
|
var _a28;
|
|
2672
2780
|
return (_a28 = this.getEditor(id)) == null ? void 0 : _a28.isVisible();
|
|
@@ -2688,8 +2796,9 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2688
2796
|
return this._currentSheetSubUnitId;
|
|
2689
2797
|
}
|
|
2690
2798
|
register(config, container) {
|
|
2691
|
-
var _a28, _b2, _c, _d
|
|
2692
|
-
const { initialSnapshot,
|
|
2799
|
+
var _a28, _b2, _c, _d;
|
|
2800
|
+
const { initialSnapshot, canvasStyle = {} } = config, editorUnitId = initialSnapshot.id;
|
|
2801
|
+
this._univerInstanceService.getUnit(editorUnitId, UniverInstanceType.UNIVER_DOC) == null && this._univerInstanceService.createUnit(
|
|
2693
2802
|
UniverInstanceType.UNIVER_DOC,
|
|
2694
2803
|
initialSnapshot || this._getBlank(editorUnitId),
|
|
2695
2804
|
{ makeCurrent: !1 }
|
|
@@ -2698,13 +2807,13 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2698
2807
|
if (render2 == null && (this._renderManagerService.create(editorUnitId), render2 = this._renderManagerService.getRenderById(editorUnitId)), render2) {
|
|
2699
2808
|
render2.engine.setContainer(container);
|
|
2700
2809
|
const editor = new Editor(
|
|
2701
|
-
{ ...config, render: render2,
|
|
2810
|
+
{ ...config, render: render2, editorDom: container, canvasStyle },
|
|
2702
2811
|
this._univerInstanceService,
|
|
2703
2812
|
this._docSelectionManagerService,
|
|
2704
2813
|
this._commandService,
|
|
2705
2814
|
this._undoRedoService
|
|
2706
2815
|
);
|
|
2707
|
-
this._editors.set(editorUnitId, editor),
|
|
2816
|
+
this._editors.set(editorUnitId, editor), config.scrollBar || (_d = (_c = (_b2 = (_a28 = render2.mainComponent) == null ? void 0 : _a28.getScene()) == null ? void 0 : _b2.getViewports()) == null ? void 0 : _c[0].getScrollBar()) == null || _d.dispose(), !editor.isSheetEditor() && !config.noNeedVerticalAlign && (editor.verticalAlign(), editor.updateCanvasStyle());
|
|
2708
2817
|
}
|
|
2709
2818
|
return toDisposable(() => {
|
|
2710
2819
|
this._unRegister(editorUnitId);
|
|
@@ -2712,15 +2821,17 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2712
2821
|
}
|
|
2713
2822
|
_unRegister(editorUnitId) {
|
|
2714
2823
|
const editor = this._editors.get(editorUnitId);
|
|
2715
|
-
if (editor == null || (this._renderManagerService.removeRender(editorUnitId), editor.
|
|
2824
|
+
if (editor == null || (this._renderManagerService.removeRender(editorUnitId), editor.dispose(), this._editors.delete(editorUnitId), this._univerInstanceService.disposeUnit(editorUnitId), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, !1), !this.isSheetEditor(editorUnitId))) return;
|
|
2716
2825
|
if (this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).length > 0) {
|
|
2717
2826
|
const current = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
2718
2827
|
current && this._univerInstanceService.focusUnit(current.getUnitId());
|
|
2719
2828
|
}
|
|
2720
2829
|
}
|
|
2830
|
+
/** @deprecated */
|
|
2721
2831
|
refreshValueChange(editorUnitId) {
|
|
2722
2832
|
this._refreshValueChange(editorUnitId);
|
|
2723
2833
|
}
|
|
2834
|
+
/** @deprecated */
|
|
2724
2835
|
checkValueLegality(editorUnitId) {
|
|
2725
2836
|
const editor = this._editors.get(editorUnitId);
|
|
2726
2837
|
if (editor == null)
|
|
@@ -2788,7 +2899,33 @@ const IEditorService = createIdentifier("univer.editor.service"), textEditorCont
|
|
|
2788
2899
|
textEditorContainerDisabled,
|
|
2789
2900
|
textEditorContainerPlaceholder,
|
|
2790
2901
|
textEditorValidationError
|
|
2791
|
-
}
|
|
2902
|
+
};
|
|
2903
|
+
function genSnapShotByValue(id = "", value = "") {
|
|
2904
|
+
const dataStream = `${value}${DEFAULT_EMPTY_DOCUMENT_VALUE}`, paragraphs = [], sectionBreaks = [];
|
|
2905
|
+
for (let i = 0; i < dataStream.length; i++)
|
|
2906
|
+
dataStream[i] === "\r" && paragraphs.push({
|
|
2907
|
+
startIndex: i
|
|
2908
|
+
}), dataStream[i] === `
|
|
2909
|
+
` && sectionBreaks.push({
|
|
2910
|
+
startIndex: i
|
|
2911
|
+
});
|
|
2912
|
+
return {
|
|
2913
|
+
id,
|
|
2914
|
+
body: {
|
|
2915
|
+
dataStream,
|
|
2916
|
+
tables: [],
|
|
2917
|
+
textRuns: [],
|
|
2918
|
+
paragraphs,
|
|
2919
|
+
sectionBreaks
|
|
2920
|
+
},
|
|
2921
|
+
tableSource: {},
|
|
2922
|
+
documentStyle: {
|
|
2923
|
+
documentFlavor: DocumentFlavor.MODERN
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
}
|
|
2927
|
+
__name(genSnapShotByValue, "genSnapShotByValue");
|
|
2928
|
+
const excludeProps = /* @__PURE__ */ new Set([
|
|
2792
2929
|
"snapshot",
|
|
2793
2930
|
"resizeCallBack",
|
|
2794
2931
|
"cancelDefaultResizeListener",
|
|
@@ -2843,10 +2980,12 @@ function TextEditor(props) {
|
|
|
2843
2980
|
cancelDefaultResizeListener !== !0 && editorService.resize(id), resizeCallBack && resizeCallBack(editorDom);
|
|
2844
2981
|
});
|
|
2845
2982
|
resizeObserver.observe(editorDom);
|
|
2983
|
+
const initialSnapshot = snapshot != null ? snapshot : genSnapShotByValue(id, value);
|
|
2984
|
+
initialSnapshot.id !== id && (initialSnapshot.id = id);
|
|
2846
2985
|
const registerSubscription = editorService.register(
|
|
2847
2986
|
{
|
|
2848
2987
|
editorUnitId: id,
|
|
2849
|
-
initialSnapshot
|
|
2988
|
+
initialSnapshot,
|
|
2850
2989
|
cancelDefaultResizeListener,
|
|
2851
2990
|
isSheetEditor,
|
|
2852
2991
|
canvasStyle,
|
|
@@ -2866,7 +3005,7 @@ function TextEditor(props) {
|
|
|
2866
3005
|
const activeChange = debounce((state) => {
|
|
2867
3006
|
setActive(state), onActive && onActive(state);
|
|
2868
3007
|
}, 30), ANIMATION_DELAY = 160, valueChange = debounce((editor) => {
|
|
2869
|
-
const unitId = editor.
|
|
3008
|
+
const unitId = editor.getEditorId(), isLegality = editorService.checkValueLegality(unitId);
|
|
2870
3009
|
setTimeout(() => {
|
|
2871
3010
|
const rect = editor.getBoundingClientRect();
|
|
2872
3011
|
setValidationOffset([rect.left, rect.top - 16]), rect.left + rect.top > 0 && setValidationVisible(isLegality), editor.onlyInputFormula() ? setValidationContent(localeService.t("textEditor.formulaError")) : setValidationContent(localeService.t("textEditor.rangeError"));
|
|
@@ -3043,6 +3182,21 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width:
|
|
|
3043
3182
|
}));
|
|
3044
3183
|
});
|
|
3045
3184
|
TodoList.displayName = "TodoList";
|
|
3185
|
+
function r(e) {
|
|
3186
|
+
var t, f2, n2 = "";
|
|
3187
|
+
if (typeof e == "string" || typeof e == "number") n2 += e;
|
|
3188
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
3189
|
+
var o = e.length;
|
|
3190
|
+
for (t = 0; t < o; t++) e[t] && (f2 = r(e[t])) && (n2 && (n2 += " "), n2 += f2);
|
|
3191
|
+
} else for (f2 in e) e[f2] && (n2 && (n2 += " "), n2 += f2);
|
|
3192
|
+
return n2;
|
|
3193
|
+
}
|
|
3194
|
+
__name(r, "r");
|
|
3195
|
+
function clsx() {
|
|
3196
|
+
for (var e, t, f2 = 0, n2 = "", o = arguments.length; f2 < o; f2++) (e = arguments[f2]) && (t = r(e)) && (n2 && (n2 += " "), n2 += t);
|
|
3197
|
+
return n2;
|
|
3198
|
+
}
|
|
3199
|
+
__name(clsx, "clsx");
|
|
3046
3200
|
const _RangeSelectorService = class _RangeSelectorService extends Disposable {
|
|
3047
3201
|
constructor() {
|
|
3048
3202
|
super(...arguments);
|
|
@@ -3092,13 +3246,11 @@ const IRangeSelectorService = createIdentifier(
|
|
|
3092
3246
|
rangeSelectorModalContainerDeleteButton,
|
|
3093
3247
|
rangeSelectorModalAdd,
|
|
3094
3248
|
rangeSelectorModalAddButton
|
|
3095
|
-
},
|
|
3096
|
-
pointerEvents: "none"
|
|
3097
|
-
cursor: "not-allowed",
|
|
3098
|
-
opacity: 0.5
|
|
3249
|
+
}, dialogOnlyInputStyle = {
|
|
3250
|
+
pointerEvents: "none"
|
|
3099
3251
|
};
|
|
3100
3252
|
function RangeSelector(props) {
|
|
3101
|
-
const { onChange, id, value = "", width = 220, placeholder = "", size = "middle", onActive, onValid, isSingleChoice = !1, openForSheetUnitId, openForSheetSubUnitId, isReadonly = !1, className, textEditorClassName, onSelectorVisibleChange: _onSelectorVisibleChange
|
|
3253
|
+
const { dialogOnly, onChange, id, value = "", width = 220, placeholder = "", size = "middle", onActive, onValid, isSingleChoice = !1, openForSheetUnitId, openForSheetSubUnitId, isReadonly = !1, className, textEditorClassName, onSelectorVisibleChange: _onSelectorVisibleChange } = props, onSelectorVisibleChange = useEvent(_onSelectorVisibleChange), [rangeDataList, setRangeDataList] = useState([""]), addNewItem = /* @__PURE__ */ __name((newValue) => {
|
|
3102
3254
|
setRangeDataList((prevRangeDataList) => [...prevRangeDataList, newValue]);
|
|
3103
3255
|
}, "addNewItem"), removeItem = /* @__PURE__ */ __name((indexToRemove) => {
|
|
3104
3256
|
setRangeDataList(
|
|
@@ -3115,7 +3267,7 @@ function RangeSelector(props) {
|
|
|
3115
3267
|
const newList = [...prevRangeDataList];
|
|
3116
3268
|
return newList.length > 0 && (newList[newList.length - 1] = newValue), newList;
|
|
3117
3269
|
});
|
|
3118
|
-
}, "changeLastItem"), editorService = useDependency(IEditorService), rangeSelectorService = useDependency(IRangeSelectorService), univerInstanceService = useDependency(IUniverInstanceService), [selectorVisible, setSelectorVisible] = useState(!1), localeService = useDependency(LocaleService), [active, setActive] = useState(!1), [valid, setValid] = useState(!0), [rangeValue, setRangeValue] = useState(value), [currentInputIndex, setCurrentInputIndex] = useState(-1), selectorRef = useRef(null), currentInputIndexRef = useRef(-1), openForSheetUnitIdRef = useRef(openForSheetUnitId), openForSheetSubUnitIdRef = useRef(openForSheetSubUnitId), isSingleChoiceRef = useRef(isSingleChoice), isReadonlyRef = useRef(isReadonly)
|
|
3270
|
+
}, "changeLastItem"), editorService = useDependency(IEditorService), rangeSelectorService = useDependency(IRangeSelectorService), univerInstanceService = useDependency(IUniverInstanceService), [selectorVisible, setSelectorVisible] = useState(!1), localeService = useDependency(LocaleService), [active, setActive] = useState(!1), [valid, setValid] = useState(!0), [rangeValue, setRangeValue] = useState(value), [currentInputIndex, setCurrentInputIndex] = useState(-1), selectorRef = useRef(null), currentInputIndexRef = useRef(-1), openForSheetUnitIdRef = useRef(openForSheetUnitId), openForSheetSubUnitIdRef = useRef(openForSheetSubUnitId), isSingleChoiceRef = useRef(isSingleChoice), isReadonlyRef = useRef(isReadonly);
|
|
3119
3271
|
useEffect(() => {
|
|
3120
3272
|
const selector = selectorRef.current;
|
|
3121
3273
|
if (!selector)
|
|
@@ -3203,13 +3355,22 @@ function RangeSelector(props) {
|
|
|
3203
3355
|
let sClassName = styles$6.rangeSelector;
|
|
3204
3356
|
isReadonly ? sClassName = `${styles$6.rangeSelector} ${styles$6.rangeSelectorDisabled}` : valid ? active && (sClassName = `${styles$6.rangeSelector} ${styles$6.rangeSelectorActive}`) : sClassName = `${styles$6.rangeSelector} ${styles$6.rangeSelectorError}`, textEditorClassName && (sClassName = `${sClassName} ${textEditorClassName}`);
|
|
3205
3357
|
let height = 28;
|
|
3206
|
-
size === "mini" ? height = 20 : size === "small" ? height = 24 : size === "large" && (height = 32)
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3358
|
+
return size === "mini" ? height = 20 : size === "small" ? height = 24 : size === "large" && (height = 32), /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3359
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3360
|
+
"div",
|
|
3361
|
+
{
|
|
3362
|
+
className: sClassName,
|
|
3363
|
+
ref: selectorRef,
|
|
3364
|
+
style: { width, height, cursor: dialogOnly ? "pointer" : void 0 },
|
|
3365
|
+
onClickCapture: /* @__PURE__ */ __name((event) => {
|
|
3366
|
+
dialogOnly && (event.stopPropagation(), event.preventDefault(), handleOpenModal());
|
|
3367
|
+
}, "onClickCapture"),
|
|
3368
|
+
children: [
|
|
3369
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TextEditor, { style: dialogOnly ? dialogOnlyInputStyle : void 0, placeholder, value, isReadonly, isSingleChoice, openForSheetUnitId, openForSheetSubUnitId, onValid: onEditorValid, onActive: onEditorActive, onChange: handleTextValueChange, id, onlyInputRange: !0, canvasStyle: { fontSize: 10 }, className: styles$6.rangeSelectorEditor }),
|
|
3370
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { title: localeService.t("rangeSelector.buttonTooltip"), placement: "bottom", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: styles$6.rangeSelectorIcon, onClick: handleOpenModal, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectRangeSingle, {}) }) })
|
|
3371
|
+
]
|
|
3372
|
+
}
|
|
3373
|
+
),
|
|
3213
3374
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3214
3375
|
Dialog,
|
|
3215
3376
|
{
|
|
@@ -5280,7 +5441,7 @@ const InnerPasteCommand = {
|
|
|
5280
5441
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
5281
5442
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5282
5443
|
var _a28, _b2, _c, _d;
|
|
5283
|
-
const { segmentId, textRanges, doc } = params, commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), originSelections = docSelectionManagerService.getTextRanges(), { body, tableSource, drawings } = doc;
|
|
5444
|
+
const { segmentId, textRanges, doc } = params, commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), originSelections = docSelectionManagerService.getTextRanges(), rectRanges = docSelectionManagerService.getRectRanges(), { body, tableSource, drawings } = doc;
|
|
5284
5445
|
if (!Array.isArray(originSelections) || originSelections.length === 0 || body == null)
|
|
5285
5446
|
return !1;
|
|
5286
5447
|
const docDataModel = univerInstanceService.getCurrentUniverDocInstance(), originBody = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
@@ -5297,7 +5458,7 @@ const InnerPasteCommand = {
|
|
|
5297
5458
|
}, memoryCursor = new MemoryCursor();
|
|
5298
5459
|
memoryCursor.reset();
|
|
5299
5460
|
const textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [], hasTable = !!((_a28 = body.tables) != null && _a28.length), hasCustomBlock = !!((_b2 = body.customBlocks) != null && _b2.length);
|
|
5300
|
-
if (hasTable && segmentId || hasTable && hasRangeInTable(selections))
|
|
5461
|
+
if (hasTable && segmentId || hasTable && hasRangeInTable(selections) || selections.length && (rectRanges != null && rectRanges.length))
|
|
5301
5462
|
return !1;
|
|
5302
5463
|
for (const selection of selections) {
|
|
5303
5464
|
const { startOffset, endOffset, collapsed } = selection, len = startOffset - memoryCursor.cursor, cloneBody = Tools.deepClone(body);
|
|
@@ -6632,7 +6793,8 @@ let DocClipboardService = (_a4 = class extends Disposable {
|
|
|
6632
6793
|
async _setClipboardData(documentBodyList, snapshot, needCache = !0) {
|
|
6633
6794
|
var _a28, _b2;
|
|
6634
6795
|
const copyId = genId(), text = (documentBodyList.length > 1 ? documentBodyList.map((body) => body.dataStream).join(`
|
|
6635
|
-
`) : documentBodyList[0].dataStream).replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, "")
|
|
6796
|
+
`) : documentBodyList[0].dataStream).replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, "").replaceAll(DataStreamTreeTokenType.TABLE_START, "").replaceAll(DataStreamTreeTokenType.TABLE_END, "").replaceAll(DataStreamTreeTokenType.TABLE_ROW_START, "").replaceAll(DataStreamTreeTokenType.TABLE_ROW_END, "").replaceAll(DataStreamTreeTokenType.TABLE_CELL_START, "").replaceAll(DataStreamTreeTokenType.TABLE_CELL_END, "").replaceAll(`\r
|
|
6797
|
+
`, " ");
|
|
6636
6798
|
let html = this._umdToHtml.convert(documentBodyList);
|
|
6637
6799
|
if (documentBodyList.length === 1 && needCache) {
|
|
6638
6800
|
html = html.replace(/(<[a-z]+)/, (_p0, p1) => `${p1} data-copy-id="${copyId}"`);
|
|
@@ -6726,10 +6888,6 @@ function whenDocOrEditor(contextService) {
|
|
|
6726
6888
|
return contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED);
|
|
6727
6889
|
}
|
|
6728
6890
|
__name(whenDocOrEditor, "whenDocOrEditor");
|
|
6729
|
-
function whenFocusEditor(contextService) {
|
|
6730
|
-
return contextService.getContextValue(EDITOR_ACTIVATED);
|
|
6731
|
-
}
|
|
6732
|
-
__name(whenFocusEditor, "whenFocusEditor");
|
|
6733
6891
|
const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
6734
6892
|
id: CopyCommand.id,
|
|
6735
6893
|
name: "doc.command.copy",
|
|
@@ -7554,7 +7712,6 @@ let DocParagraphSettingController = (_a5 = class extends Disposable {
|
|
|
7554
7712
|
}
|
|
7555
7713
|
}, __name(_a5, "DocParagraphSettingController"), _a5);
|
|
7556
7714
|
DocParagraphSettingController = __decorateClass$m([
|
|
7557
|
-
OnLifecycle(LifecycleStages.Rendered, DocParagraphSettingController),
|
|
7558
7715
|
__decorateParam$m(0, ICommandService),
|
|
7559
7716
|
__decorateParam$m(1, Inject(ComponentManager)),
|
|
7560
7717
|
__decorateParam$m(2, Inject(ISidebarService))
|
|
@@ -8100,7 +8257,7 @@ function HeaderFooterMenuItemFactory(accessor) {
|
|
|
8100
8257
|
return {
|
|
8101
8258
|
id: OpenHeaderFooterPanelCommand.id,
|
|
8102
8259
|
type: MenuItemType.BUTTON,
|
|
8103
|
-
icon: "
|
|
8260
|
+
icon: "HeaderFooterSingle",
|
|
8104
8261
|
tooltip: "toolbar.headerFooter",
|
|
8105
8262
|
hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getHeaderFooterMenuHiddenObservable(accessor), (one, two) => one || two)
|
|
8106
8263
|
};
|
|
@@ -8601,7 +8758,6 @@ let DocUIController = (_a6 = class extends Disposable {
|
|
|
8601
8758
|
}
|
|
8602
8759
|
}, __name(_a6, "DocUIController"), _a6);
|
|
8603
8760
|
DocUIController = __decorateClass$l([
|
|
8604
|
-
OnLifecycle(LifecycleStages.Rendered, DocUIController),
|
|
8605
8761
|
__decorateParam$l(0, Inject(Injector)),
|
|
8606
8762
|
__decorateParam$l(1, Inject(ComponentManager)),
|
|
8607
8763
|
__decorateParam$l(2, ICommandService),
|
|
@@ -8628,7 +8784,7 @@ let DocBackScrollRenderController = (_a7 = class extends RxDisposable {
|
|
|
8628
8784
|
if (params == null)
|
|
8629
8785
|
return;
|
|
8630
8786
|
const { isEditing, unitId } = params;
|
|
8631
|
-
unitId !== this._context.unitId || !isEditing || this._scrollToSelection();
|
|
8787
|
+
unitId !== this._context.unitId || !isEditing || this._context.unitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY && this._scrollToSelection();
|
|
8632
8788
|
});
|
|
8633
8789
|
}
|
|
8634
8790
|
scrollToRange(range) {
|
|
@@ -8639,10 +8795,11 @@ let DocBackScrollRenderController = (_a7 = class extends RxDisposable {
|
|
|
8639
8795
|
this.scrollToNode(anchorNodePosition);
|
|
8640
8796
|
}
|
|
8641
8797
|
scrollToNode(startNodePosition) {
|
|
8798
|
+
var _a28;
|
|
8642
8799
|
const { unitId, scene, mainComponent } = this._context, skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
8643
8800
|
if (mainComponent == null || skeleton == null)
|
|
8644
8801
|
return;
|
|
8645
|
-
const documentOffsetConfig = mainComponent.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { contentBoxPointGroup } = convertor.getRangePointData(startNodePosition, startNodePosition), { left: aLeft, top: aTop, height } = getAnchorBounding(contentBoxPointGroup), left = aLeft + docsLeft, top = aTop + docsTop, viewportMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN),
|
|
8802
|
+
const documentOffsetConfig = mainComponent.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { contentBoxPointGroup } = convertor.getRangePointData(startNodePosition, startNodePosition), { left: aLeft, top: aTop, height } = getAnchorBounding(contentBoxPointGroup), left = aLeft + docsLeft, top = aTop + docsTop, viewportMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN), editor = this._editorService.getEditor(unitId);
|
|
8646
8803
|
if (viewportMain == null)
|
|
8647
8804
|
return;
|
|
8648
8805
|
const {
|
|
@@ -8652,7 +8809,7 @@ let DocBackScrollRenderController = (_a7 = class extends RxDisposable {
|
|
|
8652
8809
|
bottom: boundBottom
|
|
8653
8810
|
} = viewportMain.getBounding().viewBound;
|
|
8654
8811
|
let offsetY = 0, offsetX = 0;
|
|
8655
|
-
const delta =
|
|
8812
|
+
const delta = editor ? (_a28 = editor.params.backScrollOffset) != null ? _a28 : 0 : 100;
|
|
8656
8813
|
top < boundTop ? offsetY = top - boundTop - delta : top > boundBottom - height && (offsetY = top - boundBottom + height + delta), left < boundLeft ? offsetX = left - boundLeft : left > boundRight - ANCHOR_WIDTH && (offsetX = left - boundRight + ANCHOR_WIDTH);
|
|
8657
8814
|
const config = viewportMain.transViewportScroll2ScrollValue(offsetX, offsetY);
|
|
8658
8815
|
viewportMain.scrollByBarDeltaValue(config);
|
|
@@ -8683,13 +8840,15 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8683
8840
|
reRender(unitId) {
|
|
8684
8841
|
var _a28, _b2;
|
|
8685
8842
|
const docSkeletonManagerService = (_a28 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a28.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
8686
|
-
if (!
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
this.
|
|
8843
|
+
if (!skeleton || !!skeleton.getViewModel().getDataModel().getSnapshot().disabled)
|
|
8844
|
+
return;
|
|
8845
|
+
skeleton.calculate();
|
|
8846
|
+
const editor = this._editorService.getEditor(unitId);
|
|
8847
|
+
if (this._editorService.isEditor(unitId) && !(editor != null && editor.params.scrollBar)) {
|
|
8848
|
+
(_b2 = this._context.mainComponent) == null || _b2.makeDirty();
|
|
8849
|
+
return;
|
|
8692
8850
|
}
|
|
8851
|
+
this._recalculateSizeBySkeleton(skeleton);
|
|
8693
8852
|
}
|
|
8694
8853
|
_addNewRender() {
|
|
8695
8854
|
const { scene, engine } = this._context, viewMain = new Viewport(VIEWPORT_KEY.VIEW_MAIN, scene, {
|
|
@@ -8758,7 +8917,9 @@ let DocRenderController = (_a8 = class extends RxDisposable {
|
|
|
8758
8917
|
const page = pages[i], { pageWidth, pageHeight } = page;
|
|
8759
8918
|
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));
|
|
8760
8919
|
}
|
|
8761
|
-
docsComponent.resize(width, height), docBackground.resize(width, height)
|
|
8920
|
+
docsComponent.resize(width, height), docBackground.resize(width, height);
|
|
8921
|
+
const editor = this._editorService.getEditor(unitId);
|
|
8922
|
+
(!this._editorService.isEditor(unitId) || editor != null && editor.params.scrollBar) && scene.resize(width, height);
|
|
8762
8923
|
}
|
|
8763
8924
|
}, __name(_a8, "DocRenderController"), _a8);
|
|
8764
8925
|
DocRenderController = __decorateClass$j([
|
|
@@ -9147,7 +9308,6 @@ let DocAutoFormatController = (_a11 = class extends Disposable {
|
|
|
9147
9308
|
}
|
|
9148
9309
|
}, __name(_a11, "DocAutoFormatController"), _a11);
|
|
9149
9310
|
DocAutoFormatController = __decorateClass$g([
|
|
9150
|
-
OnLifecycle(LifecycleStages.Rendered, DocAutoFormatController),
|
|
9151
9311
|
__decorateParam$g(0, Inject(DocAutoFormatService))
|
|
9152
9312
|
], DocAutoFormatController);
|
|
9153
9313
|
function firstLineInTable(table) {
|
|
@@ -9188,24 +9348,50 @@ function findLineBeforeAndAfterTable(table) {
|
|
|
9188
9348
|
}
|
|
9189
9349
|
__name(findLineBeforeAndAfterTable, "findLineBeforeAndAfterTable");
|
|
9190
9350
|
function findBellowCell(cell) {
|
|
9191
|
-
|
|
9351
|
+
var _a28, _b2;
|
|
9352
|
+
const row = cell.parent, table = row == null ? void 0 : row.parent, tableId = table == null ? void 0 : table.tableId;
|
|
9192
9353
|
if (row == null || table == null)
|
|
9193
9354
|
return;
|
|
9194
|
-
const bellowRow = table.rows[table.rows.indexOf(row) + 1];
|
|
9195
|
-
if (bellowRow == null)
|
|
9355
|
+
const col = row.cells.indexOf(cell), bellowRow = table.rows[table.rows.indexOf(row) + 1];
|
|
9356
|
+
if (bellowRow == null) {
|
|
9357
|
+
if (tableId.indexOf("#-#")) {
|
|
9358
|
+
const [id, index] = tableId.split("#-#"), pages = (_b2 = (_a28 = table.parent) == null ? void 0 : _a28.parent) == null ? void 0 : _b2.pages, nextTableId = `${id}#-#${Number.parseInt(index) + 1}`;
|
|
9359
|
+
if (pages)
|
|
9360
|
+
for (const page of pages) {
|
|
9361
|
+
const { skeTables } = page;
|
|
9362
|
+
if (skeTables.has(nextTableId)) {
|
|
9363
|
+
const nextTable = skeTables.get(nextTableId);
|
|
9364
|
+
if (nextTable != null && nextTable.rows.length)
|
|
9365
|
+
return nextTable.rows[0].cells[col];
|
|
9366
|
+
}
|
|
9367
|
+
}
|
|
9368
|
+
}
|
|
9196
9369
|
return;
|
|
9197
|
-
|
|
9370
|
+
}
|
|
9198
9371
|
return bellowRow.cells[col];
|
|
9199
9372
|
}
|
|
9200
9373
|
__name(findBellowCell, "findBellowCell");
|
|
9201
9374
|
function findAboveCell(cell) {
|
|
9375
|
+
var _a28, _b2;
|
|
9202
9376
|
const row = cell.parent, table = row == null ? void 0 : row.parent;
|
|
9203
9377
|
if (row == null || table == null)
|
|
9204
9378
|
return;
|
|
9205
|
-
const aboveRow = table.rows[table.rows.indexOf(row) - 1];
|
|
9206
|
-
if (aboveRow == null)
|
|
9379
|
+
const aboveRow = table.rows[table.rows.indexOf(row) - 1], col = row.cells.indexOf(cell);
|
|
9380
|
+
if (aboveRow == null) {
|
|
9381
|
+
if (table.tableId.indexOf("#-#")) {
|
|
9382
|
+
const [id, index] = table.tableId.split("#-#"), pages = (_b2 = (_a28 = table.parent) == null ? void 0 : _a28.parent) == null ? void 0 : _b2.pages, nextTableId = `${id}#-#${Number.parseInt(index) - 1}`;
|
|
9383
|
+
if (pages)
|
|
9384
|
+
for (const page of pages) {
|
|
9385
|
+
const { skeTables } = page;
|
|
9386
|
+
if (skeTables.has(nextTableId)) {
|
|
9387
|
+
const nextTable = skeTables.get(nextTableId);
|
|
9388
|
+
if (nextTable != null && nextTable.rows.length)
|
|
9389
|
+
return nextTable.rows[nextTable.rows.length - 1].cells[col];
|
|
9390
|
+
}
|
|
9391
|
+
}
|
|
9392
|
+
}
|
|
9207
9393
|
return;
|
|
9208
|
-
|
|
9394
|
+
}
|
|
9209
9395
|
return aboveRow.cells[col];
|
|
9210
9396
|
}
|
|
9211
9397
|
__name(findAboveCell, "findAboveCell");
|
|
@@ -9379,8 +9565,8 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9379
9565
|
direction === Direction.LEFT ? cursor = Math.min(range.startIndex, cursor) : cursor = Math.max(range.endIndex + 1, cursor);
|
|
9380
9566
|
}), this._textSelectionManagerService.replaceTextRanges([
|
|
9381
9567
|
{
|
|
9382
|
-
startOffset: cursor,
|
|
9383
|
-
endOffset: cursor,
|
|
9568
|
+
startOffset: Math.max(0, cursor),
|
|
9569
|
+
endOffset: Math.max(0, cursor),
|
|
9384
9570
|
style
|
|
9385
9571
|
}
|
|
9386
9572
|
], !1), this._scrollToFocusNodePosition(docDataModel.getUnitId(), cursor);
|
|
@@ -9395,8 +9581,8 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9395
9581
|
let cursor;
|
|
9396
9582
|
collapsed ? cursor = direction === Direction.UP ? 0 : dataStreamLength - 2 : cursor = direction === Direction.UP ? startOffset : endOffset, this._textSelectionManagerService.replaceTextRanges([
|
|
9397
9583
|
{
|
|
9398
|
-
startOffset: cursor,
|
|
9399
|
-
endOffset: cursor,
|
|
9584
|
+
startOffset: Math.max(0, cursor),
|
|
9585
|
+
endOffset: Math.max(0, cursor),
|
|
9400
9586
|
style
|
|
9401
9587
|
}
|
|
9402
9588
|
], !1);
|
|
@@ -9537,7 +9723,6 @@ let DocMoveCursorController = (_a12 = class extends Disposable {
|
|
|
9537
9723
|
}
|
|
9538
9724
|
}, __name(_a12, "DocMoveCursorController"), _a12);
|
|
9539
9725
|
DocMoveCursorController = __decorateClass$f([
|
|
9540
|
-
OnLifecycle(LifecycleStages.Rendered, DocMoveCursorController),
|
|
9541
9726
|
__decorateParam$f(0, IUniverInstanceService),
|
|
9542
9727
|
__decorateParam$f(1, IRenderManagerService),
|
|
9543
9728
|
__decorateParam$f(2, Inject(DocSelectionManagerService)),
|
|
@@ -9641,7 +9826,6 @@ let DocTableController = (_a13 = class extends Disposable {
|
|
|
9641
9826
|
}
|
|
9642
9827
|
}, __name(_a13, "DocTableController"), _a13);
|
|
9643
9828
|
DocTableController = __decorateClass$e([
|
|
9644
|
-
OnLifecycle(LifecycleStages.Rendered, DocTableController),
|
|
9645
9829
|
__decorateParam$e(0, ICommandService),
|
|
9646
9830
|
__decorateParam$e(1, Inject(ComponentManager))
|
|
9647
9831
|
], DocTableController);
|
|
@@ -10078,8 +10262,8 @@ var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPrope
|
|
|
10078
10262
|
return kind && result && __defProp$a(target, key, result), result;
|
|
10079
10263
|
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a17;
|
|
10080
10264
|
let DocClipboardController = (_a17 = class extends RxDisposable {
|
|
10081
|
-
constructor(_context, _commandService, _docClipboardService, _docSelectionRenderService, _contextService) {
|
|
10082
|
-
super(), this._context = _context, this._commandService = _commandService, this._docClipboardService = _docClipboardService, this._docSelectionRenderService = _docSelectionRenderService, this._contextService = _contextService, this._init();
|
|
10265
|
+
constructor(_context, _commandService, _docClipboardService, _docSelectionRenderService, _contextService, _editorService) {
|
|
10266
|
+
super(), this._context = _context, this._commandService = _commandService, this._docClipboardService = _docClipboardService, this._docSelectionRenderService = _docSelectionRenderService, this._contextService = _contextService, this._editorService = _editorService, this._init();
|
|
10083
10267
|
}
|
|
10084
10268
|
_init() {
|
|
10085
10269
|
this._initLegacyPasteCommand();
|
|
@@ -10094,7 +10278,7 @@ let DocClipboardController = (_a17 = class extends RxDisposable {
|
|
|
10094
10278
|
const clipboardEvent = config.event;
|
|
10095
10279
|
let htmlContent = (_a29 = clipboardEvent.clipboardData) == null ? void 0 : _a29.getData("text/html");
|
|
10096
10280
|
const textContent = (_b2 = clipboardEvent.clipboardData) == null ? void 0 : _b2.getData("text/plain");
|
|
10097
|
-
|
|
10281
|
+
this._editorService.getEditor(this._context.unitId) && (htmlContent != null ? htmlContent : "").indexOf("</table>") > -1 && (htmlContent = ""), this._docClipboardService.legacyPaste(htmlContent, textContent);
|
|
10098
10282
|
});
|
|
10099
10283
|
}
|
|
10100
10284
|
}, __name(_a17, "DocClipboardController"), _a17);
|
|
@@ -10102,7 +10286,8 @@ DocClipboardController = __decorateClass$a([
|
|
|
10102
10286
|
__decorateParam$a(1, ICommandService),
|
|
10103
10287
|
__decorateParam$a(2, IDocClipboardService),
|
|
10104
10288
|
__decorateParam$a(3, Inject(DocSelectionRenderService)),
|
|
10105
|
-
__decorateParam$a(4, IContextService)
|
|
10289
|
+
__decorateParam$a(4, IContextService),
|
|
10290
|
+
__decorateParam$a(5, IEditorService)
|
|
10106
10291
|
], DocClipboardController);
|
|
10107
10292
|
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
10108
10293
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -10264,7 +10449,8 @@ let DocEditorBridgeController = (_a19 = class extends Disposable {
|
|
|
10264
10449
|
const params = command.params, { unitId } = params;
|
|
10265
10450
|
if (this._editorService.isSheetEditor(unitId) || unitId !== this._context.unitId)
|
|
10266
10451
|
return;
|
|
10267
|
-
this.
|
|
10452
|
+
const editor = this._editorService.getEditor(unitId);
|
|
10453
|
+
editor && !editor.params.scrollBar && (this._resize(unitId), this._valueChange());
|
|
10268
10454
|
}
|
|
10269
10455
|
})
|
|
10270
10456
|
);
|
|
@@ -10749,7 +10935,6 @@ let DocStateChangeManagerService = (_a25 = class extends RxDisposable {
|
|
|
10749
10935
|
}
|
|
10750
10936
|
}, __name(_a25, "DocStateChangeManagerService"), _a25);
|
|
10751
10937
|
DocStateChangeManagerService = __decorateClass$2([
|
|
10752
|
-
OnLifecycle(LifecycleStages.Ready, DocStateChangeManagerService),
|
|
10753
10938
|
__decorateParam$2(0, Inject(IUndoRedoService)),
|
|
10754
10939
|
__decorateParam$2(1, ICommandService),
|
|
10755
10940
|
__decorateParam$2(2, IUniverInstanceService),
|
|
@@ -10781,7 +10966,6 @@ let DocsRenderService = (_a26 = class extends RxDisposable {
|
|
|
10781
10966
|
}
|
|
10782
10967
|
}, __name(_a26, "DocsRenderService"), _a26);
|
|
10783
10968
|
DocsRenderService = __decorateClass$1([
|
|
10784
|
-
OnLifecycle(LifecycleStages.Ready, DocsRenderService),
|
|
10785
10969
|
__decorateParam$1(0, IUniverInstanceService),
|
|
10786
10970
|
__decorateParam$1(1, IRenderManagerService)
|
|
10787
10971
|
], DocsRenderService);
|
|
@@ -10871,10 +11055,21 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
10871
11055
|
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), this._initDependencies(_injector), this._initializeShortcut(), this._initCommand();
|
|
10872
11056
|
}
|
|
10873
11057
|
onReady() {
|
|
10874
|
-
this._initRenderBasics(), this._markDocAsFocused()
|
|
11058
|
+
this._initRenderBasics(), this._markDocAsFocused(), touchDependencies(this._injector, [
|
|
11059
|
+
[DocStateChangeManagerService],
|
|
11060
|
+
[DocsRenderService]
|
|
11061
|
+
]);
|
|
10875
11062
|
}
|
|
10876
11063
|
onRendered() {
|
|
10877
|
-
this._initUI(), this._initRenderModules()
|
|
11064
|
+
this._initUI(), this._initRenderModules(), touchDependencies(this._injector, [
|
|
11065
|
+
[DocAutoFormatController],
|
|
11066
|
+
[DocMoveCursorController],
|
|
11067
|
+
[DocParagraphSettingController],
|
|
11068
|
+
[DocTableController],
|
|
11069
|
+
// FIXME: LifecycleStages.Rendered must be used, otherwise the menu cannot be added to the DOM, but the sheet ui
|
|
11070
|
+
// plugin can be added in LifecycleStages.Ready
|
|
11071
|
+
[DocUIController]
|
|
11072
|
+
]);
|
|
10878
11073
|
}
|
|
10879
11074
|
_initCommand() {
|
|
10880
11075
|
[
|
|
@@ -10931,6 +11126,7 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
10931
11126
|
InnerPasteCommand,
|
|
10932
11127
|
CutContentCommand,
|
|
10933
11128
|
ReplaceContentCommand,
|
|
11129
|
+
ReplaceSnapshotCommand,
|
|
10934
11130
|
CoverContentCommand,
|
|
10935
11131
|
SetDocZoomRatioCommand,
|
|
10936
11132
|
SelectAllOperation,
|
|
@@ -10964,14 +11160,12 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
10964
11160
|
mergeOverrideWithDependencies([
|
|
10965
11161
|
[DocClipboardController],
|
|
10966
11162
|
[DocEditorBridgeController],
|
|
10967
|
-
// Controller
|
|
10968
11163
|
[DocUIController],
|
|
10969
11164
|
[DocAutoFormatController],
|
|
10970
11165
|
[DocTableController],
|
|
10971
11166
|
[DocMoveCursorController],
|
|
10972
11167
|
[AppUIController],
|
|
10973
11168
|
[DocParagraphSettingController],
|
|
10974
|
-
// Services
|
|
10975
11169
|
[IEditorService, { useClass: EditorService }],
|
|
10976
11170
|
[IRangeSelectorService, { useClass: RangeSelectorService }],
|
|
10977
11171
|
[IDocClipboardService, { useClass: DocClipboardService }],
|
|
@@ -10997,13 +11191,11 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
10997
11191
|
}
|
|
10998
11192
|
_initRenderBasics() {
|
|
10999
11193
|
[
|
|
11000
|
-
// Services.
|
|
11001
11194
|
[DocSkeletonManagerService],
|
|
11002
11195
|
[DocSelectionRenderService],
|
|
11003
11196
|
[DocInterceptorService],
|
|
11004
11197
|
[DocPageLayoutService],
|
|
11005
11198
|
[DocIMEInputManagerService],
|
|
11006
|
-
// Controllers.
|
|
11007
11199
|
[DocRenderController],
|
|
11008
11200
|
[DocZoomRenderController]
|
|
11009
11201
|
].forEach((m2) => {
|
|
@@ -11012,9 +11204,7 @@ let UniverDocsUIPlugin = (_a27 = class extends Plugin {
|
|
|
11012
11204
|
}
|
|
11013
11205
|
_initRenderModules() {
|
|
11014
11206
|
[
|
|
11015
|
-
// Services
|
|
11016
11207
|
[DocEventManagerService],
|
|
11017
|
-
// Controllers.
|
|
11018
11208
|
[DocBackScrollRenderController],
|
|
11019
11209
|
[DocSelectionRenderController],
|
|
11020
11210
|
[DocHeaderFooterController],
|
|
@@ -11118,6 +11308,7 @@ export {
|
|
|
11118
11308
|
RangeSelectorService,
|
|
11119
11309
|
RectRange,
|
|
11120
11310
|
ReplaceContentCommand,
|
|
11311
|
+
ReplaceSnapshotCommand,
|
|
11121
11312
|
ResetInlineFormatTextBackgroundColorCommand,
|
|
11122
11313
|
SelectAllOperation,
|
|
11123
11314
|
SetDocZoomRatioCommand,
|