@univerjs/docs-ui 0.2.4 → 0.2.6
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 +4 -4
- package/lib/es/index.js +2134 -1729
- package/lib/index.css +1 -1
- package/lib/types/controllers/app-ui-controller.d.ts +1 -2
- package/lib/types/controllers/doc-container-ui-controller.d.ts +1 -2
- package/lib/types/controllers/doc-ui.controller.d.ts +8 -4
- package/lib/types/controllers/menu/context-menu.d.ts +7 -0
- package/lib/types/controllers/menu/menu.d.ts +1 -1
- package/lib/types/controllers/render-controllers/contextmenu.render-controller.d.ts +18 -0
- package/lib/types/controllers/render-controllers/doc-hover.render-controller.d.ts +11 -0
- package/lib/types/controllers/render-controllers/doc-resize.render-controller.d.ts +12 -0
- package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +4 -3
- package/lib/types/controllers/shortcut/toolbar.shortcut.d.ts +14 -0
- package/lib/types/docs-ui-plugin.d.ts +1 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +2 -3
- package/lib/types/services/doc-hover-manager.service.d.ts +18 -0
- package/lib/types/services/doc-page-layout.service.d.ts +8 -0
- package/lib/types/services/doc-popup-manager.service.d.ts +1 -2
- package/lib/types/views/count-bar/CountBar.d.ts +8 -0
- package/lib/types/views/count-bar/ZoomSlider.d.ts +3 -0
- package/lib/types/views/count-bar/index.d.ts +16 -0
- package/lib/types/views/doc-footer/DocFooter.d.ts +3 -0
- package/lib/types/views/doc-footer/index.d.ts +16 -0
- package/lib/umd/index.js +4 -4
- package/package.json +15 -17
- package/lib/types/services/doc-mark-selection.service.d.ts +0 -27
package/lib/es/index.js
CHANGED
|
@@ -1,610 +1,626 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { TextSelectionManagerService
|
|
8
|
-
import { pixelToPt
|
|
9
|
-
import { takeUntil
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return t.getContextValue(Ue) && t.getContextValue(dt) && !t.getContextValue(Xt);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, Tools, LRUMap, BaselineOffset, BooleanNumber, ColorKit, DataStreamTreeTokenType, CustomRangeType, skipParseTagNames, createIdentifier, Inject, IUniverInstanceService, ILogService, ICommandService, Disposable, SliceBodyType, normalizeBody, UniverInstanceType, toDisposable, RxDisposable, Direction, EDITOR_ACTIVATED, LocaleService, Injector, Optional, useDependency, useObservable, CommandType, DocumentFlavor, JSONX, ThemeService, HorizontalAlign, connectInjector, OnLifecycle, LifecycleStages, IContextService, checkForSubstrings, IConfigService, isInternalEditorID, DisposableCollection, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, fromEventSubject, Plugin, ObjectRelativeFromH, ObjectRelativeFromV } from "@univerjs/core";
|
|
6
|
+
import { IClipboardInterfaceService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, IEditorService, KeyCode, MetaKeys, ILayoutService, ISidebarService, ComponentManager, MenuGroup, MenuItemType, MenuPosition, getMenuHiddenObservable, FONT_FAMILY_LIST, FONT_SIZE_LIST, getHeaderFooterMenuHiddenObservable, CopyCommand, CutCommand, PasteCommand, FontFamily, FontFamilyItem, FontSize, BuiltInUIPart, IMenuService, IUIPartsService, IShortcutService, SetEditorResizeOperation, ICanvasPopupService, IContextMenuService } from "@univerjs/ui";
|
|
7
|
+
import { TextSelectionManagerService, DocCustomRangeService, CutContentCommand, InnerPasteCommand, getDeleteSelection, DocSkeletonManagerService, VIEWPORT_KEY, getDocObject, MoveCursorOperation, MoveSelectionOperation, SelectAllOperation, SetDocZoomRatioOperation, neoGetDocObject, RichTextEditingMutation, SetInlineFormatBoldCommand, SetTextSelectionsOperation, SetInlineFormatCommand, SetInlineFormatItalicCommand, SetInlineFormatUnderlineCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatTextColorCommand, AlignLeftCommand, AlignOperationCommand, AlignCenterCommand, AlignRightCommand, AlignJustifyCommand, OrderListCommand, BulletListCommand, ResetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextBackgroundColorCommand, DeleteLeftCommand, BreakLineCommand, DeleteRightCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_VIEW_KEY, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, SetDocZoomRatioCommand, DocInterceptorService } from "@univerjs/docs";
|
|
8
|
+
import { pixelToPt, ptToPixel, NodePositionConvertToCursor, getAnchorBounding, IRenderManagerService, ITextSelectionRenderManager, Shape, DocumentEditArea, PageLayoutType, Vector2, Rect, Path, ScrollBar, Viewport, Layer, Documents, DocBackground, CURSOR_TYPE, pxToNum, getLineBounding, TRANSFORM_CHANGE_OBSERVABLE_TYPE } from "@univerjs/engine-render";
|
|
9
|
+
import { takeUntil, Observable, combineLatest, fromEvent, BehaviorSubject, map, filter, throttleTime, debounceTime } from "rxjs";
|
|
10
|
+
import require$$0, { useMemo, useCallback, useState, useEffect } from "react";
|
|
11
|
+
import { Slider, Checkbox, InputNumber, Button, ColorPicker } from "@univerjs/design";
|
|
12
|
+
import clsx from "clsx";
|
|
13
|
+
function whenDocAndEditorFocused(contextService) {
|
|
14
|
+
return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
__name(whenDocAndEditorFocused, "whenDocAndEditorFocused");
|
|
17
|
+
function whenDocAndEditorFocusedWithBreakLine(contextService) {
|
|
18
|
+
return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE) && !contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
__name(whenDocAndEditorFocusedWithBreakLine, "whenDocAndEditorFocusedWithBreakLine");
|
|
21
|
+
const COPY_CONTENT_CACHE_LIMIT = 10, ID_LENGTH = 6;
|
|
22
|
+
function genId() {
|
|
23
|
+
return Tools.generateRandomId(ID_LENGTH);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
__name(genId, "genId");
|
|
26
|
+
function extractId(html) {
|
|
27
|
+
const match = html.match(/data-copy-id="([^\s]+)"/);
|
|
28
|
+
return match && match[1] ? match[1] : null;
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
__name(extractId, "extractId");
|
|
31
|
+
const _CopyContentCache = class _CopyContentCache {
|
|
29
32
|
constructor() {
|
|
30
|
-
|
|
33
|
+
__publicField(this, "_cache", new LRUMap(COPY_CONTENT_CACHE_LIMIT));
|
|
31
34
|
}
|
|
32
|
-
set(
|
|
33
|
-
this._cache.set(
|
|
35
|
+
set(id, clipboardData) {
|
|
36
|
+
this._cache.set(id, clipboardData);
|
|
34
37
|
}
|
|
35
|
-
get(
|
|
36
|
-
return this._cache.get(
|
|
38
|
+
get(id) {
|
|
39
|
+
return this._cache.get(id);
|
|
37
40
|
}
|
|
38
41
|
clear() {
|
|
39
42
|
this._cache.clear();
|
|
40
43
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
};
|
|
45
|
+
__name(_CopyContentCache, "CopyContentCache");
|
|
46
|
+
let CopyContentCache = _CopyContentCache;
|
|
47
|
+
const copyContentCache = new CopyContentCache();
|
|
48
|
+
function extractNodeStyle(node) {
|
|
49
|
+
const styles2 = node.style, docStyles = {}, tagName = node.tagName.toLowerCase();
|
|
50
|
+
switch (tagName) {
|
|
46
51
|
case "b":
|
|
47
52
|
case "em":
|
|
48
53
|
case "strong": {
|
|
49
|
-
|
|
54
|
+
docStyles.bl = BooleanNumber.TRUE;
|
|
50
55
|
break;
|
|
51
56
|
}
|
|
52
57
|
case "s": {
|
|
53
|
-
|
|
54
|
-
s:
|
|
58
|
+
docStyles.st = {
|
|
59
|
+
s: BooleanNumber.TRUE
|
|
55
60
|
};
|
|
56
61
|
break;
|
|
57
62
|
}
|
|
58
63
|
case "u": {
|
|
59
|
-
|
|
60
|
-
s:
|
|
64
|
+
docStyles.ul = {
|
|
65
|
+
s: BooleanNumber.TRUE
|
|
61
66
|
};
|
|
62
67
|
break;
|
|
63
68
|
}
|
|
64
69
|
case "i": {
|
|
65
|
-
|
|
70
|
+
docStyles.it = BooleanNumber.TRUE;
|
|
66
71
|
break;
|
|
67
72
|
}
|
|
68
73
|
case "sub":
|
|
69
74
|
case "sup": {
|
|
70
|
-
|
|
75
|
+
docStyles.va = tagName === "sup" ? BaselineOffset.SUPERSCRIPT : BaselineOffset.SUBSCRIPT;
|
|
71
76
|
break;
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
|
-
for (let
|
|
75
|
-
const
|
|
76
|
-
switch (
|
|
79
|
+
for (let i = 0; i < styles2.length; i++) {
|
|
80
|
+
const cssRule = styles2[i], cssValue = styles2.getPropertyValue(cssRule);
|
|
81
|
+
switch (cssRule) {
|
|
77
82
|
case "font-family": {
|
|
78
|
-
|
|
83
|
+
docStyles.ff = cssValue;
|
|
79
84
|
break;
|
|
80
85
|
}
|
|
81
86
|
case "font-size": {
|
|
82
|
-
const
|
|
83
|
-
Number.isNaN(
|
|
87
|
+
const fontSize = Number.parseInt(cssValue);
|
|
88
|
+
Number.isNaN(fontSize) || (cssValue.endsWith("pt") ? docStyles.fs = fontSize : cssValue.endsWith("px") && (docStyles.fs = pixelToPt(fontSize)));
|
|
84
89
|
break;
|
|
85
90
|
}
|
|
86
91
|
case "font-style": {
|
|
87
|
-
|
|
92
|
+
cssValue === "italic" && (docStyles.it = BooleanNumber.TRUE);
|
|
88
93
|
break;
|
|
89
94
|
}
|
|
90
95
|
case "font-weight": {
|
|
91
|
-
(Number(
|
|
96
|
+
(Number(cssValue) > 400 || String(cssValue) === "bold") && (docStyles.bl = BooleanNumber.TRUE);
|
|
92
97
|
break;
|
|
93
98
|
}
|
|
94
99
|
case "text-decoration": {
|
|
95
|
-
/underline/.test(
|
|
96
|
-
s:
|
|
97
|
-
} : /overline/.test(
|
|
98
|
-
s:
|
|
99
|
-
} : /line-through/.test(
|
|
100
|
-
s:
|
|
100
|
+
/underline/.test(cssValue) ? docStyles.ul = {
|
|
101
|
+
s: BooleanNumber.TRUE
|
|
102
|
+
} : /overline/.test(cssValue) ? docStyles.ol = {
|
|
103
|
+
s: BooleanNumber.TRUE
|
|
104
|
+
} : /line-through/.test(cssValue) && (docStyles.st = {
|
|
105
|
+
s: BooleanNumber.TRUE
|
|
101
106
|
});
|
|
102
107
|
break;
|
|
103
108
|
}
|
|
104
109
|
case "color": {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
rgb:
|
|
110
|
+
const color = new ColorKit(cssValue);
|
|
111
|
+
color.isValid && (docStyles.cl = {
|
|
112
|
+
rgb: color.toRgbString()
|
|
108
113
|
});
|
|
109
114
|
break;
|
|
110
115
|
}
|
|
111
116
|
case "background-color": {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
rgb:
|
|
117
|
+
const color = new ColorKit(cssValue);
|
|
118
|
+
color.isValid && (docStyles.bg = {
|
|
119
|
+
rgb: color.toRgbString()
|
|
115
120
|
});
|
|
116
121
|
break;
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
|
-
return
|
|
125
|
+
return docStyles;
|
|
121
126
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
__name(extractNodeStyle, "extractNodeStyle");
|
|
128
|
+
function parseToDom(rawHtml) {
|
|
129
|
+
const parser = new DOMParser(), html = `<x-univer id="univer-root">${rawHtml}</x-univer>`;
|
|
130
|
+
return parser.parseFromString(html, "text/html").querySelector("#univer-root");
|
|
125
131
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
132
|
+
__name(parseToDom, "parseToDom");
|
|
133
|
+
function matchFilter(node, filter2) {
|
|
134
|
+
const tagName = node.tagName.toLowerCase();
|
|
135
|
+
return typeof filter2 == "string" ? tagName === filter2 : Array.isArray(filter2) ? filter2.some((name) => name === tagName) : filter2(node);
|
|
129
136
|
}
|
|
130
|
-
|
|
137
|
+
__name(matchFilter, "matchFilter");
|
|
138
|
+
const _HtmlToUDMService = class _HtmlToUDMService {
|
|
131
139
|
constructor() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
__publicField(this, "_styleCache", /* @__PURE__ */ new Map());
|
|
141
|
+
__publicField(this, "_styleRules", []);
|
|
142
|
+
__publicField(this, "_afterProcessRules", []);
|
|
135
143
|
}
|
|
136
|
-
static use(
|
|
137
|
-
if (this._pluginList.includes(
|
|
138
|
-
throw new Error(`Univer paste plugin ${
|
|
139
|
-
this._pluginList.push(
|
|
144
|
+
static use(plugin) {
|
|
145
|
+
if (this._pluginList.includes(plugin))
|
|
146
|
+
throw new Error(`Univer paste plugin ${plugin.name} already added`);
|
|
147
|
+
this._pluginList.push(plugin);
|
|
140
148
|
}
|
|
141
|
-
convert(
|
|
142
|
-
const
|
|
149
|
+
convert(html) {
|
|
150
|
+
const pastePlugin = _HtmlToUDMService._pluginList.find((plugin) => plugin.checkPasteType(html)), dom = parseToDom(html), newDocBody = {
|
|
143
151
|
dataStream: "",
|
|
144
152
|
textRuns: []
|
|
145
153
|
};
|
|
146
|
-
return
|
|
154
|
+
return pastePlugin && (this._styleRules = [...pastePlugin.stylesRules], this._afterProcessRules = [...pastePlugin.afterProcessRules]), this._styleCache.clear(), this._process(null, dom == null ? void 0 : dom.childNodes, newDocBody), this._styleCache.clear(), this._styleRules = [], this._afterProcessRules = [], newDocBody;
|
|
147
155
|
}
|
|
148
|
-
_process(
|
|
149
|
-
var
|
|
150
|
-
for (const
|
|
151
|
-
if (
|
|
152
|
-
if (((
|
|
156
|
+
_process(parent, nodes, doc) {
|
|
157
|
+
var _a19, _b, _c;
|
|
158
|
+
for (const node of nodes)
|
|
159
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
160
|
+
if (((_a19 = node.nodeValue) == null ? void 0 : _a19.trim()) === "")
|
|
153
161
|
continue;
|
|
154
|
-
let
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
...(
|
|
162
|
+
let text = (_b = node.nodeValue) == null ? void 0 : _b.replace(/[\r\n]/g, ""), style;
|
|
163
|
+
if (parent && parent.nodeType === Node.ELEMENT_NODE && parent.tagName.toUpperCase() === "A") {
|
|
164
|
+
const id = Tools.generateRandomId();
|
|
165
|
+
text = `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${text}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`, doc.customRanges = [
|
|
166
|
+
...(_c = doc.customRanges) != null ? _c : [],
|
|
159
167
|
{
|
|
160
|
-
startIndex:
|
|
161
|
-
endIndex:
|
|
162
|
-
rangeId:
|
|
163
|
-
rangeType:
|
|
168
|
+
startIndex: doc.dataStream.length,
|
|
169
|
+
endIndex: doc.dataStream.length + text.length - 1,
|
|
170
|
+
rangeId: id,
|
|
171
|
+
rangeType: CustomRangeType.HYPERLINK
|
|
164
172
|
}
|
|
165
|
-
],
|
|
166
|
-
...
|
|
167
|
-
[
|
|
173
|
+
], doc.payloads = {
|
|
174
|
+
...doc.payloads,
|
|
175
|
+
[id]: parent.href
|
|
168
176
|
};
|
|
169
177
|
}
|
|
170
|
-
|
|
171
|
-
st:
|
|
172
|
-
ed:
|
|
173
|
-
ts:
|
|
178
|
+
parent && this._styleCache.has(parent) && (style = this._styleCache.get(parent)), doc.dataStream += text, style && Object.getOwnPropertyNames(style).length && doc.textRuns.push({
|
|
179
|
+
st: doc.dataStream.length - text.length,
|
|
180
|
+
ed: doc.dataStream.length,
|
|
181
|
+
ts: style
|
|
174
182
|
});
|
|
175
183
|
} else {
|
|
176
|
-
if (
|
|
184
|
+
if (skipParseTagNames.includes(node.nodeName.toLowerCase()))
|
|
177
185
|
continue;
|
|
178
|
-
if (
|
|
179
|
-
const
|
|
180
|
-
this._styleCache.set(
|
|
181
|
-
const { childNodes
|
|
182
|
-
this._process(
|
|
183
|
-
const
|
|
184
|
-
({ filter:
|
|
186
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
187
|
+
const parentStyles = parent ? this._styleCache.get(parent) : {}, styleRule = this._styleRules.find(({ filter: filter2 }) => matchFilter(node, filter2)), nodeStyles = styleRule ? styleRule.getStyle(node) : extractNodeStyle(node);
|
|
188
|
+
this._styleCache.set(node, { ...parentStyles, ...nodeStyles });
|
|
189
|
+
const { childNodes } = node;
|
|
190
|
+
this._process(node, childNodes, doc);
|
|
191
|
+
const afterProcessRule = this._afterProcessRules.find(
|
|
192
|
+
({ filter: filter2 }) => matchFilter(node, filter2)
|
|
185
193
|
);
|
|
186
|
-
|
|
194
|
+
afterProcessRule && afterProcessRule.handler(doc, node);
|
|
187
195
|
}
|
|
188
196
|
}
|
|
189
197
|
}
|
|
190
198
|
};
|
|
191
|
-
|
|
192
|
-
let
|
|
193
|
-
const
|
|
199
|
+
__name(_HtmlToUDMService, "HtmlToUDMService"), __publicField(_HtmlToUDMService, "_pluginList", []);
|
|
200
|
+
let HtmlToUDMService = _HtmlToUDMService;
|
|
201
|
+
const wordPastePlugin$1 = {
|
|
194
202
|
name: "univer-doc-paste-plugin-lark",
|
|
195
|
-
checkPasteType(
|
|
196
|
-
return /lark-record-clipboard/i.test(
|
|
203
|
+
checkPasteType(html) {
|
|
204
|
+
return /lark-record-clipboard/i.test(html);
|
|
197
205
|
},
|
|
198
206
|
// TODO: @JOCS, support inline code copy from lark.
|
|
199
207
|
stylesRules: [
|
|
200
208
|
{
|
|
201
209
|
filter: ["s"],
|
|
202
|
-
getStyle(
|
|
203
|
-
const
|
|
210
|
+
getStyle(node) {
|
|
211
|
+
const inlineStyle = extractNodeStyle(node);
|
|
204
212
|
return {
|
|
205
213
|
st: {
|
|
206
|
-
s:
|
|
214
|
+
s: BooleanNumber.TRUE
|
|
207
215
|
},
|
|
208
|
-
...
|
|
216
|
+
...inlineStyle
|
|
209
217
|
};
|
|
210
218
|
}
|
|
211
219
|
}
|
|
212
220
|
],
|
|
213
221
|
afterProcessRules: [
|
|
214
222
|
{
|
|
215
|
-
filter(
|
|
216
|
-
return
|
|
223
|
+
filter(el) {
|
|
224
|
+
return el.tagName === "DIV" && /ace-line/i.test(el.className);
|
|
217
225
|
},
|
|
218
|
-
handler(
|
|
219
|
-
|
|
220
|
-
startIndex:
|
|
221
|
-
}),
|
|
226
|
+
handler(doc) {
|
|
227
|
+
doc.paragraphs == null && (doc.paragraphs = []), doc.paragraphs.push({
|
|
228
|
+
startIndex: doc.dataStream.length
|
|
229
|
+
}), doc.dataStream += "\r";
|
|
222
230
|
}
|
|
223
231
|
}
|
|
224
232
|
]
|
|
225
|
-
},
|
|
226
|
-
function
|
|
227
|
-
const
|
|
228
|
-
for (let
|
|
229
|
-
const
|
|
230
|
-
switch (
|
|
233
|
+
}, PastePluginLark = wordPastePlugin$1;
|
|
234
|
+
function getParagraphStyle(el) {
|
|
235
|
+
const styles2 = el.style, paragraphStyle = {};
|
|
236
|
+
for (let i = 0; i < styles2.length; i++) {
|
|
237
|
+
const cssRule = styles2[i], cssValue = styles2.getPropertyValue(cssRule);
|
|
238
|
+
switch (cssRule) {
|
|
231
239
|
case "margin-top": {
|
|
232
|
-
const
|
|
233
|
-
|
|
240
|
+
const marginTopValue = Number.parseInt(cssValue);
|
|
241
|
+
paragraphStyle.spaceAbove = { v: /pt/.test(cssValue) ? ptToPixel(marginTopValue) : marginTopValue };
|
|
234
242
|
break;
|
|
235
243
|
}
|
|
236
244
|
case "margin-bottom": {
|
|
237
|
-
const
|
|
238
|
-
|
|
245
|
+
const marginBottomValue = Number.parseInt(cssValue);
|
|
246
|
+
paragraphStyle.spaceBelow = { v: /pt/.test(cssValue) ? ptToPixel(marginBottomValue) : marginBottomValue };
|
|
239
247
|
break;
|
|
240
248
|
}
|
|
241
249
|
case "line-height": {
|
|
242
|
-
const
|
|
243
|
-
|
|
250
|
+
const lineHeightValue = Number.parseFloat(cssValue);
|
|
251
|
+
paragraphStyle.lineSpacing = lineHeightValue;
|
|
244
252
|
break;
|
|
245
253
|
}
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
|
-
return Object.getOwnPropertyNames(
|
|
256
|
+
return Object.getOwnPropertyNames(paragraphStyle).length ? paragraphStyle : null;
|
|
249
257
|
}
|
|
250
|
-
|
|
258
|
+
__name(getParagraphStyle, "getParagraphStyle");
|
|
259
|
+
const wordPastePlugin = {
|
|
251
260
|
name: "univer-doc-paste-plugin-word",
|
|
252
|
-
checkPasteType(
|
|
253
|
-
return /word|mso/i.test(
|
|
261
|
+
checkPasteType(html) {
|
|
262
|
+
return /word|mso/i.test(html);
|
|
254
263
|
},
|
|
255
264
|
stylesRules: [
|
|
256
265
|
{
|
|
257
266
|
filter: ["b"],
|
|
258
|
-
getStyle(
|
|
259
|
-
const
|
|
260
|
-
return { bl:
|
|
267
|
+
getStyle(node) {
|
|
268
|
+
const inlineStyle = extractNodeStyle(node);
|
|
269
|
+
return { bl: BooleanNumber.TRUE, ...inlineStyle };
|
|
261
270
|
}
|
|
262
271
|
}
|
|
263
272
|
],
|
|
264
273
|
afterProcessRules: [
|
|
265
274
|
{
|
|
266
|
-
filter(
|
|
267
|
-
return
|
|
275
|
+
filter(el) {
|
|
276
|
+
return el.tagName === "P";
|
|
268
277
|
},
|
|
269
|
-
handler(
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
startIndex:
|
|
273
|
-
},
|
|
274
|
-
|
|
278
|
+
handler(doc, el) {
|
|
279
|
+
doc.paragraphs == null && (doc.paragraphs = []);
|
|
280
|
+
const paragraph = {
|
|
281
|
+
startIndex: doc.dataStream.length
|
|
282
|
+
}, paragraphStyle = getParagraphStyle(el);
|
|
283
|
+
paragraphStyle && (paragraph.paragraphStyle = paragraphStyle), doc.paragraphs.push(paragraph), doc.dataStream += "\r";
|
|
275
284
|
}
|
|
276
285
|
}
|
|
277
286
|
]
|
|
278
|
-
},
|
|
287
|
+
}, PastePluginWord = wordPastePlugin, univerPastePlugin = {
|
|
279
288
|
name: "univer-doc-paste-plugin-univer",
|
|
280
|
-
checkPasteType(
|
|
281
|
-
return /UniverNormal/i.test(
|
|
289
|
+
checkPasteType(html) {
|
|
290
|
+
return /UniverNormal/i.test(html);
|
|
282
291
|
},
|
|
283
292
|
stylesRules: [],
|
|
284
293
|
afterProcessRules: [
|
|
285
294
|
{
|
|
286
|
-
filter(
|
|
287
|
-
return
|
|
295
|
+
filter(el) {
|
|
296
|
+
return el.tagName === "P" && /UniverNormal/i.test(el.className);
|
|
288
297
|
},
|
|
289
|
-
handler(
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
startIndex:
|
|
293
|
-
},
|
|
294
|
-
|
|
298
|
+
handler(doc, el) {
|
|
299
|
+
doc.paragraphs == null && (doc.paragraphs = []);
|
|
300
|
+
const paragraph = {
|
|
301
|
+
startIndex: doc.dataStream.length
|
|
302
|
+
}, paragraphStyle = getParagraphStyle(el);
|
|
303
|
+
paragraphStyle && (paragraph.paragraphStyle = paragraphStyle), doc.paragraphs.push(paragraph), doc.dataStream += "\r";
|
|
295
304
|
}
|
|
296
305
|
}
|
|
297
306
|
]
|
|
298
|
-
},
|
|
299
|
-
function
|
|
300
|
-
const { st:
|
|
301
|
-
let
|
|
302
|
-
const
|
|
303
|
-
return
|
|
307
|
+
}, PastePluginUniver = univerPastePlugin;
|
|
308
|
+
function covertTextRunToHtml(dataStream, textRun) {
|
|
309
|
+
const { st: start, ed, ts = {} } = textRun, { ff, fs, it, bl, ul, st, ol, bg, cl, va } = ts;
|
|
310
|
+
let html = dataStream.slice(start, ed);
|
|
311
|
+
const style = [];
|
|
312
|
+
return it === BooleanNumber.TRUE && (html = `<i>${html}</i>`), va === BaselineOffset.SUPERSCRIPT ? html = `<sup>${html}</sup>` : va === BaselineOffset.SUBSCRIPT && (html = `<sub>${html}</sub>`), (ul == null ? void 0 : ul.s) === BooleanNumber.TRUE && (html = `<u>${html}</u>`), (st == null ? void 0 : st.s) === BooleanNumber.TRUE && (html = `<s>${html}</s>`), bl === BooleanNumber.TRUE && (html = `<strong>${html}</strong>`), ff && style.push(`font-family: ${ff}`), cl && style.push(`color: ${cl.rgb}`), fs && style.push(`font-size: ${fs}pt`), ol && style.push("text-decoration: overline"), bg && style.push(`background: ${bg.rgb}`), style.length ? `<span style="${style.join("; ")};">${html}</span>` : html;
|
|
304
313
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
314
|
+
__name(covertTextRunToHtml, "covertTextRunToHtml");
|
|
315
|
+
function getBodySliceHtml(body, startIndex, endIndex) {
|
|
316
|
+
const { dataStream, textRuns = [] } = body;
|
|
317
|
+
let cursorIndex = startIndex;
|
|
318
|
+
const spanList = [];
|
|
319
|
+
for (const textRun of textRuns) {
|
|
320
|
+
const { st, ed } = textRun;
|
|
321
|
+
Tools.hasIntersectionBetweenTwoRanges(startIndex, endIndex, st, ed) && (st > cursorIndex ? (spanList.push(dataStream.slice(cursorIndex, st)), spanList.push(covertTextRunToHtml(dataStream, {
|
|
322
|
+
...textRun,
|
|
323
|
+
ed: Math.min(ed, endIndex)
|
|
324
|
+
}))) : spanList.push(covertTextRunToHtml(dataStream, {
|
|
325
|
+
...textRun,
|
|
326
|
+
st: cursorIndex,
|
|
327
|
+
ed: Math.min(ed, endIndex)
|
|
328
|
+
}))), cursorIndex = Math.max(startIndex, Math.min(ed, endIndex));
|
|
329
|
+
}
|
|
330
|
+
return cursorIndex !== endIndex && spanList.push(dataStream.slice(cursorIndex, endIndex)), spanList.join("");
|
|
321
331
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
332
|
+
__name(getBodySliceHtml, "getBodySliceHtml");
|
|
333
|
+
function convertBodyToHtml(body, withParagraphInfo = !0) {
|
|
334
|
+
var _a19;
|
|
335
|
+
if (withParagraphInfo && ((_a19 = body.paragraphs) != null && _a19.length)) {
|
|
336
|
+
const { dataStream, paragraphs = [] } = body;
|
|
337
|
+
let result = "", cursorIndex = -1;
|
|
338
|
+
for (const paragraph of paragraphs) {
|
|
339
|
+
const { startIndex, paragraphStyle = {} } = paragraph, { spaceAbove, spaceBelow, lineSpacing } = paragraphStyle, style = [];
|
|
340
|
+
spaceAbove != null && (typeof spaceAbove == "number" ? style.push(`margin-top: ${spaceAbove}px`) : style.push(`margin-top: ${spaceAbove.v}px`)), spaceBelow != null && (typeof spaceBelow == "number" ? style.push(`margin-bottom: ${spaceBelow}px`) : style.push(`margin-bottom: ${spaceBelow.v}px`)), lineSpacing != null && style.push(`line-height: ${lineSpacing}`), startIndex > cursorIndex + 1 ? result += `<p class="UniverNormal" ${style.length ? `style="${style.join("; ")};"` : ""}>${getBodySliceHtml(body, cursorIndex + 1, startIndex)}</p>` : result += `<p class="UniverNormal" ${style.length ? `style="${style.join("; ")};"` : ""}></p>`, cursorIndex = startIndex;
|
|
330
341
|
}
|
|
331
|
-
return
|
|
342
|
+
return cursorIndex !== dataStream.length && (result += getBodySliceHtml(body, cursorIndex, dataStream.length)), result;
|
|
332
343
|
} else
|
|
333
|
-
return
|
|
344
|
+
return getBodySliceHtml(body, 0, body.dataStream.length);
|
|
334
345
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
346
|
+
__name(convertBodyToHtml, "convertBodyToHtml");
|
|
347
|
+
const _UDMToHtmlService = class _UDMToHtmlService {
|
|
348
|
+
convert(bodyList) {
|
|
349
|
+
if (bodyList.length === 0)
|
|
338
350
|
throw new Error("The bodyList length at least to be 1");
|
|
339
|
-
if (
|
|
340
|
-
return
|
|
341
|
-
let
|
|
342
|
-
for (const
|
|
343
|
-
|
|
344
|
-
return
|
|
351
|
+
if (bodyList.length === 1)
|
|
352
|
+
return convertBodyToHtml(bodyList[0]);
|
|
353
|
+
let html = "";
|
|
354
|
+
for (const body of bodyList)
|
|
355
|
+
html += '<p className="UniverNormal">', html += convertBodyToHtml(body, !1), html += "</p>";
|
|
356
|
+
return html;
|
|
345
357
|
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
+
};
|
|
359
|
+
__name(_UDMToHtmlService, "UDMToHtmlService");
|
|
360
|
+
let UDMToHtmlService = _UDMToHtmlService;
|
|
361
|
+
var __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
362
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
363
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
364
|
+
return kind && result && __defProp$h(target, key, result), result;
|
|
365
|
+
}, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h");
|
|
366
|
+
HtmlToUDMService.use(PastePluginWord);
|
|
367
|
+
HtmlToUDMService.use(PastePluginLark);
|
|
368
|
+
HtmlToUDMService.use(PastePluginUniver);
|
|
369
|
+
const IDocClipboardService = createIdentifier("doc.clipboard-service");
|
|
370
|
+
var _a;
|
|
371
|
+
let DocClipboardService = (_a = class extends Disposable {
|
|
372
|
+
constructor(_univerInstanceService, _logService, _commandService, _clipboardInterfaceService, _textSelectionManagerService, _docCustomRangeService) {
|
|
358
373
|
super();
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
this._univerInstanceService =
|
|
363
|
-
}
|
|
364
|
-
async copy(
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
374
|
+
__publicField(this, "_clipboardHooks", []);
|
|
375
|
+
__publicField(this, "_htmlToUDM", new HtmlToUDMService());
|
|
376
|
+
__publicField(this, "_umdToHtml", new UDMToHtmlService());
|
|
377
|
+
this._univerInstanceService = _univerInstanceService, this._logService = _logService, this._commandService = _commandService, this._clipboardInterfaceService = _clipboardInterfaceService, this._textSelectionManagerService = _textSelectionManagerService, this._docCustomRangeService = _docCustomRangeService;
|
|
378
|
+
}
|
|
379
|
+
async copy(sliceType = SliceBodyType.copy) {
|
|
380
|
+
const documentBodyList = this._getDocumentBodyInRanges(sliceType);
|
|
381
|
+
if (documentBodyList.length === 0)
|
|
367
382
|
return !1;
|
|
368
383
|
try {
|
|
369
|
-
const
|
|
370
|
-
this._setClipboardData(
|
|
371
|
-
} catch (
|
|
372
|
-
return this._logService.error("[DocClipboardService] copy failed",
|
|
384
|
+
const activeRange = this._textSelectionManagerService.getActiveRange(), isCopyInHeaderFooter = !!(activeRange != null && activeRange.segmentId);
|
|
385
|
+
this._setClipboardData(documentBodyList, !isCopyInHeaderFooter);
|
|
386
|
+
} catch (e) {
|
|
387
|
+
return this._logService.error("[DocClipboardService] copy failed", e), !1;
|
|
373
388
|
}
|
|
374
389
|
return !0;
|
|
375
390
|
}
|
|
376
391
|
async cut() {
|
|
377
392
|
return this._cut();
|
|
378
393
|
}
|
|
379
|
-
async paste(
|
|
380
|
-
const
|
|
381
|
-
return this._paste(
|
|
394
|
+
async paste(items) {
|
|
395
|
+
const body = await this._generateBodyFromClipboardItems(items);
|
|
396
|
+
return this._paste(body);
|
|
382
397
|
}
|
|
383
|
-
async legacyPaste(
|
|
384
|
-
const
|
|
385
|
-
return this._paste(
|
|
398
|
+
async legacyPaste(html, text) {
|
|
399
|
+
const body = this._generateBodyFromHtmlAndText(html, text);
|
|
400
|
+
return this._paste(body);
|
|
386
401
|
}
|
|
387
402
|
async _cut() {
|
|
388
|
-
var
|
|
403
|
+
var _a19;
|
|
389
404
|
const {
|
|
390
|
-
segmentId
|
|
391
|
-
endOffset:
|
|
392
|
-
style
|
|
393
|
-
} = (
|
|
394
|
-
if (
|
|
405
|
+
segmentId,
|
|
406
|
+
endOffset: activeEndOffset,
|
|
407
|
+
style
|
|
408
|
+
} = (_a19 = this._textSelectionManagerService.getActiveRange()) != null ? _a19 : {}, ranges = this._textSelectionManagerService.getCurrentSelections();
|
|
409
|
+
if (segmentId == null && this._logService.error("[DocClipboardController] segmentId is not existed"), activeEndOffset == null || ranges == null)
|
|
395
410
|
return !1;
|
|
396
|
-
this.copy(
|
|
411
|
+
this.copy(SliceBodyType.cut);
|
|
397
412
|
try {
|
|
398
|
-
let
|
|
399
|
-
for (const
|
|
400
|
-
const { startOffset
|
|
401
|
-
|
|
413
|
+
let cursor = activeEndOffset;
|
|
414
|
+
for (const range of ranges) {
|
|
415
|
+
const { startOffset, endOffset } = range;
|
|
416
|
+
startOffset == null || endOffset == null || endOffset <= activeEndOffset && (cursor -= endOffset - startOffset);
|
|
402
417
|
}
|
|
403
|
-
const
|
|
418
|
+
const textRanges = [
|
|
404
419
|
{
|
|
405
|
-
startOffset:
|
|
406
|
-
endOffset:
|
|
407
|
-
style
|
|
420
|
+
startOffset: cursor,
|
|
421
|
+
endOffset: cursor,
|
|
422
|
+
style
|
|
408
423
|
}
|
|
409
424
|
];
|
|
410
|
-
return this._commandService.executeCommand(
|
|
425
|
+
return this._commandService.executeCommand(CutContentCommand.id, { segmentId, textRanges });
|
|
411
426
|
} catch {
|
|
412
427
|
return this._logService.error("[DocClipboardController] cut content failed"), !1;
|
|
413
428
|
}
|
|
414
429
|
}
|
|
415
|
-
async _paste(
|
|
416
|
-
var
|
|
417
|
-
let
|
|
418
|
-
const
|
|
419
|
-
if (!
|
|
430
|
+
async _paste(_body) {
|
|
431
|
+
var _a19, _b;
|
|
432
|
+
let body = normalizeBody(_body);
|
|
433
|
+
const unitId = (_a19 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a19.getUnitId();
|
|
434
|
+
if (!unitId)
|
|
420
435
|
return !1;
|
|
421
|
-
this._clipboardHooks.forEach((
|
|
422
|
-
|
|
423
|
-
}),
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
436
|
+
this._clipboardHooks.forEach((hook) => {
|
|
437
|
+
hook.onBeforePaste && (body = hook.onBeforePaste(body));
|
|
438
|
+
}), body.customRanges = (_b = body.customRanges) == null ? void 0 : _b.map((range) => this._docCustomRangeService.copyCustomRange(unitId, range));
|
|
439
|
+
const activeRange = this._textSelectionManagerService.getActiveRange(), { segmentId, endOffset: activeEndOffset, style } = activeRange || {}, ranges = this._textSelectionManagerService.getCurrentSelections();
|
|
440
|
+
if (segmentId == null && this._logService.error("[DocClipboardController] segmentId does not exist!"), activeEndOffset == null || ranges == null)
|
|
426
441
|
return !1;
|
|
427
442
|
try {
|
|
428
|
-
let
|
|
429
|
-
for (const
|
|
430
|
-
const { startOffset
|
|
431
|
-
|
|
443
|
+
let cursor = activeEndOffset;
|
|
444
|
+
for (const range of ranges) {
|
|
445
|
+
const { startOffset, endOffset } = range;
|
|
446
|
+
startOffset == null || endOffset == null || endOffset <= activeEndOffset && (cursor += body.dataStream.length - (endOffset - startOffset));
|
|
432
447
|
}
|
|
433
|
-
const
|
|
448
|
+
const textRanges = [
|
|
434
449
|
{
|
|
435
|
-
startOffset:
|
|
436
|
-
endOffset:
|
|
437
|
-
style
|
|
450
|
+
startOffset: cursor,
|
|
451
|
+
endOffset: cursor,
|
|
452
|
+
style
|
|
438
453
|
}
|
|
439
454
|
];
|
|
440
|
-
return this._commandService.executeCommand(
|
|
455
|
+
return this._commandService.executeCommand(InnerPasteCommand.id, { body, segmentId, textRanges });
|
|
441
456
|
} catch {
|
|
442
457
|
return this._logService.error("[DocClipboardController]", "clipboard is empty."), !1;
|
|
443
458
|
}
|
|
444
459
|
}
|
|
445
|
-
async _setClipboardData(
|
|
446
|
-
const
|
|
447
|
-
`) :
|
|
448
|
-
let
|
|
449
|
-
return
|
|
460
|
+
async _setClipboardData(documentBodyList, needCache = !0) {
|
|
461
|
+
const copyId = genId(), text = documentBodyList.length > 1 ? documentBodyList.map((body) => body.dataStream).join(`
|
|
462
|
+
`) : documentBodyList[0].dataStream;
|
|
463
|
+
let html = this._umdToHtml.convert(documentBodyList);
|
|
464
|
+
return documentBodyList.length === 1 && needCache && (html = html.replace(/(<[a-z]+)/, (_p0, p1) => `${p1} data-copy-id="${copyId}"`), copyContentCache.set(copyId, documentBodyList[0])), this._clipboardInterfaceService.write(text, html);
|
|
450
465
|
}
|
|
451
|
-
addClipboardHook(
|
|
452
|
-
return this._clipboardHooks.push(
|
|
453
|
-
const
|
|
454
|
-
|
|
466
|
+
addClipboardHook(hook) {
|
|
467
|
+
return this._clipboardHooks.push(hook), toDisposable(() => {
|
|
468
|
+
const index = this._clipboardHooks.indexOf(hook);
|
|
469
|
+
index > -1 && this._clipboardHooks.splice(index, 1);
|
|
455
470
|
});
|
|
456
471
|
}
|
|
457
|
-
_getDocumentBodyInRanges(
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
460
|
-
return
|
|
461
|
-
const { segmentId
|
|
462
|
-
for (const
|
|
463
|
-
const { startOffset
|
|
464
|
-
if (
|
|
472
|
+
_getDocumentBodyInRanges(sliceType) {
|
|
473
|
+
const ranges = this._textSelectionManagerService.getCurrentSelections(), activeRange = this._textSelectionManagerService.getActiveRange(), docDataModel = this._univerInstanceService.getCurrentUniverDocInstance(), results = [], body = docDataModel == null ? void 0 : docDataModel.getBody();
|
|
474
|
+
if (ranges == null || docDataModel == null || body == null || activeRange == null)
|
|
475
|
+
return results;
|
|
476
|
+
const { segmentId } = activeRange;
|
|
477
|
+
for (const range of ranges) {
|
|
478
|
+
const { startOffset, endOffset, collapsed } = range;
|
|
479
|
+
if (collapsed || startOffset == null || endOffset == null)
|
|
465
480
|
continue;
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
468
|
-
if (
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}),
|
|
473
|
-
let
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}),
|
|
481
|
+
const deleteRange = getDeleteSelection({ startOffset, endOffset, collapsed }, body), docBody = docDataModel.getSelfOrHeaderFooterModel(segmentId).sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
|
|
482
|
+
if (docBody != null) {
|
|
483
|
+
if (docBody.customRanges) {
|
|
484
|
+
const deleteRange2 = [];
|
|
485
|
+
docBody.customRanges.forEach((range2) => {
|
|
486
|
+
range2.startIndex === range2.endIndex && deleteRange2.push(range2);
|
|
487
|
+
}), docBody.customRanges = docBody.customRanges.filter((range2) => deleteRange2.indexOf(range2) === -1);
|
|
488
|
+
let text = "", cursor = 0;
|
|
489
|
+
deleteRange2.forEach((range2) => {
|
|
490
|
+
text += docBody.dataStream.slice(cursor, range2.endIndex), cursor = range2.endIndex + 1;
|
|
491
|
+
}), text += docBody.dataStream.slice(cursor, docBody.dataStream.length), docBody.dataStream = text;
|
|
477
492
|
}
|
|
478
|
-
|
|
493
|
+
results.push(docBody);
|
|
479
494
|
}
|
|
480
495
|
}
|
|
481
|
-
return
|
|
496
|
+
return results;
|
|
482
497
|
}
|
|
483
|
-
async _generateBodyFromClipboardItems(
|
|
498
|
+
async _generateBodyFromClipboardItems(items) {
|
|
484
499
|
try {
|
|
485
|
-
let
|
|
486
|
-
for (const
|
|
487
|
-
for (const
|
|
488
|
-
|
|
489
|
-
return this._generateBodyFromHtmlAndText(
|
|
490
|
-
} catch (
|
|
491
|
-
return Promise.reject(
|
|
500
|
+
let html = "", text = "";
|
|
501
|
+
for (const clipboardItem of items)
|
|
502
|
+
for (const type of clipboardItem.types)
|
|
503
|
+
type === PLAIN_TEXT_CLIPBOARD_MIME_TYPE ? text = await clipboardItem.getType(type).then((blob) => blob && blob.text()) : type === HTML_CLIPBOARD_MIME_TYPE && (html = await clipboardItem.getType(type).then((blob) => blob && blob.text()));
|
|
504
|
+
return this._generateBodyFromHtmlAndText(html, text);
|
|
505
|
+
} catch (e) {
|
|
506
|
+
return Promise.reject(e);
|
|
492
507
|
}
|
|
493
508
|
}
|
|
494
|
-
_generateBody(
|
|
495
|
-
const
|
|
496
|
-
if (!
|
|
497
|
-
const
|
|
498
|
-
|
|
509
|
+
_generateBody(text) {
|
|
510
|
+
const dataStream = text.replace(/\n/g, "\r");
|
|
511
|
+
if (!text.includes("\r") && Tools.isLegalUrl(text)) {
|
|
512
|
+
const id = Tools.generateRandomId(), docDataModel = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), urlText = `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${dataStream}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`, range = this._docCustomRangeService.copyCustomRange(
|
|
513
|
+
docDataModel.getUnitId(),
|
|
499
514
|
{
|
|
500
515
|
startIndex: 0,
|
|
501
|
-
endIndex:
|
|
502
|
-
rangeId:
|
|
503
|
-
rangeType:
|
|
504
|
-
data:
|
|
516
|
+
endIndex: urlText.length - 1,
|
|
517
|
+
rangeId: id,
|
|
518
|
+
rangeType: CustomRangeType.HYPERLINK,
|
|
519
|
+
data: text
|
|
505
520
|
}
|
|
506
521
|
);
|
|
507
522
|
return {
|
|
508
|
-
dataStream:
|
|
509
|
-
customRanges: [
|
|
523
|
+
dataStream: urlText,
|
|
524
|
+
customRanges: [range]
|
|
510
525
|
};
|
|
511
526
|
}
|
|
512
|
-
const
|
|
513
|
-
for (let
|
|
514
|
-
|
|
527
|
+
const paragraphs = [];
|
|
528
|
+
for (let i = 0; i < dataStream.length; i++)
|
|
529
|
+
dataStream[i] === "\r" && paragraphs.push({ startIndex: i });
|
|
515
530
|
return {
|
|
516
|
-
dataStream
|
|
517
|
-
paragraphs
|
|
531
|
+
dataStream,
|
|
532
|
+
paragraphs
|
|
518
533
|
};
|
|
519
534
|
}
|
|
520
|
-
_generateBodyFromHtmlAndText(
|
|
521
|
-
if (!
|
|
522
|
-
if (
|
|
523
|
-
return this._generateBody(
|
|
535
|
+
_generateBodyFromHtmlAndText(html, text) {
|
|
536
|
+
if (!html) {
|
|
537
|
+
if (text)
|
|
538
|
+
return this._generateBody(text);
|
|
524
539
|
throw new Error("[DocClipboardService] html and text cannot be both empty!");
|
|
525
540
|
}
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
const
|
|
529
|
-
if (
|
|
530
|
-
return
|
|
541
|
+
const copyId = extractId(html);
|
|
542
|
+
if (copyId) {
|
|
543
|
+
const copyCache = copyContentCache.get(copyId);
|
|
544
|
+
if (copyCache)
|
|
545
|
+
return copyCache;
|
|
531
546
|
}
|
|
532
|
-
return this._htmlToUDM.convert(
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
],
|
|
543
|
-
var
|
|
544
|
-
for (var
|
|
545
|
-
(
|
|
546
|
-
return
|
|
547
|
-
},
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
547
|
+
return this._htmlToUDM.convert(html);
|
|
548
|
+
}
|
|
549
|
+
}, __name(_a, "DocClipboardService"), _a);
|
|
550
|
+
DocClipboardService = __decorateClass$h([
|
|
551
|
+
__decorateParam$h(0, IUniverInstanceService),
|
|
552
|
+
__decorateParam$h(1, ILogService),
|
|
553
|
+
__decorateParam$h(2, ICommandService),
|
|
554
|
+
__decorateParam$h(3, IClipboardInterfaceService),
|
|
555
|
+
__decorateParam$h(4, Inject(TextSelectionManagerService)),
|
|
556
|
+
__decorateParam$h(5, Inject(DocCustomRangeService))
|
|
557
|
+
], DocClipboardService);
|
|
558
|
+
var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
559
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
560
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
561
|
+
return kind && result && __defProp$g(target, key, result), result;
|
|
562
|
+
}, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g");
|
|
563
|
+
const ANCHOR_WIDTH = 1.5;
|
|
564
|
+
var _a2;
|
|
565
|
+
let DocBackScrollRenderController = (_a2 = class extends RxDisposable {
|
|
566
|
+
constructor(_context, _textSelectionManagerService, _editorService, _univerInstanceService, _renderManagerService) {
|
|
567
|
+
super(), this._context = _context, this._textSelectionManagerService = _textSelectionManagerService, this._editorService = _editorService, this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this._init();
|
|
552
568
|
}
|
|
553
569
|
_init() {
|
|
554
|
-
this._textSelectionManagerService.textSelection$.pipe(
|
|
555
|
-
if (
|
|
570
|
+
this._textSelectionManagerService.textSelection$.pipe(takeUntil(this.dispose$)).subscribe((params) => {
|
|
571
|
+
if (params == null)
|
|
556
572
|
return;
|
|
557
|
-
const { isEditing
|
|
558
|
-
|
|
573
|
+
const { isEditing, unitId } = params;
|
|
574
|
+
isEditing && this._scrollToSelection(unitId);
|
|
559
575
|
});
|
|
560
576
|
}
|
|
561
|
-
scrollToRange(
|
|
562
|
-
var
|
|
563
|
-
const
|
|
564
|
-
if (!
|
|
577
|
+
scrollToRange(unitId, range) {
|
|
578
|
+
var _a19;
|
|
579
|
+
const docSkeletonManagerService = (_a19 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a19.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
580
|
+
if (!skeleton)
|
|
565
581
|
return;
|
|
566
|
-
const { startOffset
|
|
567
|
-
this.scrollToNode(
|
|
582
|
+
const { startOffset } = range, anchorNodePosition = skeleton.findNodePositionByCharIndex(startOffset);
|
|
583
|
+
this.scrollToNode(unitId, anchorNodePosition);
|
|
568
584
|
}
|
|
569
|
-
scrollToNode(
|
|
570
|
-
var
|
|
571
|
-
const
|
|
572
|
-
if (
|
|
585
|
+
scrollToNode(unitId, startNodePosition) {
|
|
586
|
+
var _a19;
|
|
587
|
+
const docObject = this._getDocObject(), docSkeletonManagerService = (_a19 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a19.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
588
|
+
if (docObject == null || skeleton == null)
|
|
573
589
|
return;
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
590
|
+
const documentOffsetConfig = docObject.document.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 = docObject.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN), isEditor = !!this._editorService.getEditor(unitId);
|
|
591
|
+
if (viewportMain == null)
|
|
576
592
|
return;
|
|
577
593
|
const {
|
|
578
|
-
left:
|
|
579
|
-
top:
|
|
580
|
-
right:
|
|
581
|
-
bottom:
|
|
582
|
-
} =
|
|
583
|
-
let
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
|
|
594
|
+
left: boundLeft,
|
|
595
|
+
top: boundTop,
|
|
596
|
+
right: boundRight,
|
|
597
|
+
bottom: boundBottom
|
|
598
|
+
} = viewportMain.getBounding().viewBound;
|
|
599
|
+
let offsetY = 0, offsetX = 0;
|
|
600
|
+
const delta = isEditor ? 0 : 100;
|
|
601
|
+
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);
|
|
602
|
+
const config = viewportMain.transViewportScroll2ScrollValue(offsetX, offsetY);
|
|
603
|
+
viewportMain.scrollByBarDeltaValue(config);
|
|
588
604
|
}
|
|
589
605
|
// Let the selection show on the current screen.
|
|
590
|
-
_scrollToSelection(
|
|
591
|
-
const
|
|
592
|
-
if (
|
|
606
|
+
_scrollToSelection(unitId) {
|
|
607
|
+
const activeTextRange = this._textSelectionManagerService.getActiveRange();
|
|
608
|
+
if (activeTextRange == null)
|
|
593
609
|
return;
|
|
594
|
-
const { collapsed
|
|
595
|
-
|
|
610
|
+
const { collapsed, startNodePosition } = activeTextRange;
|
|
611
|
+
collapsed && this.scrollToNode(unitId, startNodePosition);
|
|
596
612
|
}
|
|
597
613
|
_getDocObject() {
|
|
598
|
-
return
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
],
|
|
607
|
-
const
|
|
614
|
+
return getDocObject(this._univerInstanceService, this._renderManagerService);
|
|
615
|
+
}
|
|
616
|
+
}, __name(_a2, "DocBackScrollRenderController"), _a2);
|
|
617
|
+
DocBackScrollRenderController = __decorateClass$g([
|
|
618
|
+
__decorateParam$g(1, Inject(TextSelectionManagerService)),
|
|
619
|
+
__decorateParam$g(2, IEditorService),
|
|
620
|
+
__decorateParam$g(3, Inject(IUniverInstanceService)),
|
|
621
|
+
__decorateParam$g(4, IRenderManagerService)
|
|
622
|
+
], DocBackScrollRenderController);
|
|
623
|
+
const DefaultToolbarConfig = {
|
|
608
624
|
undo: !0,
|
|
609
625
|
redo: !0,
|
|
610
626
|
// Undo redo
|
|
@@ -632,7 +648,7 @@ const er = {
|
|
|
632
648
|
// 'Wrap mode'
|
|
633
649
|
textRotateMode: !0
|
|
634
650
|
// 'Text Rotation Mode'
|
|
635
|
-
},
|
|
651
|
+
}, DefaultDocContainerConfig = {
|
|
636
652
|
outerLeft: !1,
|
|
637
653
|
outerRight: !1,
|
|
638
654
|
header: !0,
|
|
@@ -645,85 +661,85 @@ const er = {
|
|
|
645
661
|
frozenContent: !1,
|
|
646
662
|
infoBar: !0,
|
|
647
663
|
toolbar: !0
|
|
648
|
-
},
|
|
664
|
+
}, DefaultDocUiConfig = {
|
|
649
665
|
layout: {
|
|
650
|
-
docContainerConfig:
|
|
651
|
-
toolbarConfig:
|
|
666
|
+
docContainerConfig: DefaultDocContainerConfig,
|
|
667
|
+
toolbarConfig: DefaultToolbarConfig
|
|
652
668
|
}
|
|
653
|
-
},
|
|
654
|
-
id:
|
|
655
|
-
binding:
|
|
656
|
-
preconditions:
|
|
669
|
+
}, DOC_UI_PLUGIN_NAME = "DocUI", MoveCursorUpShortcut = {
|
|
670
|
+
id: MoveCursorOperation.id,
|
|
671
|
+
binding: KeyCode.ARROW_UP,
|
|
672
|
+
preconditions: whenDocAndEditorFocused,
|
|
657
673
|
staticParameters: {
|
|
658
|
-
direction:
|
|
674
|
+
direction: Direction.UP
|
|
659
675
|
}
|
|
660
|
-
},
|
|
661
|
-
id:
|
|
662
|
-
binding:
|
|
663
|
-
preconditions:
|
|
676
|
+
}, MoveCursorDownShortcut = {
|
|
677
|
+
id: MoveCursorOperation.id,
|
|
678
|
+
binding: KeyCode.ARROW_DOWN,
|
|
679
|
+
preconditions: whenDocAndEditorFocused,
|
|
664
680
|
staticParameters: {
|
|
665
|
-
direction:
|
|
681
|
+
direction: Direction.DOWN
|
|
666
682
|
}
|
|
667
|
-
},
|
|
668
|
-
id:
|
|
669
|
-
binding:
|
|
670
|
-
preconditions:
|
|
683
|
+
}, MoveCursorLeftShortcut = {
|
|
684
|
+
id: MoveCursorOperation.id,
|
|
685
|
+
binding: KeyCode.ARROW_LEFT,
|
|
686
|
+
preconditions: whenDocAndEditorFocused,
|
|
671
687
|
staticParameters: {
|
|
672
|
-
direction:
|
|
688
|
+
direction: Direction.LEFT
|
|
673
689
|
}
|
|
674
|
-
},
|
|
675
|
-
id:
|
|
676
|
-
binding:
|
|
677
|
-
preconditions:
|
|
690
|
+
}, MoveCursorRightShortcut = {
|
|
691
|
+
id: MoveCursorOperation.id,
|
|
692
|
+
binding: KeyCode.ARROW_RIGHT,
|
|
693
|
+
preconditions: whenDocAndEditorFocused,
|
|
678
694
|
staticParameters: {
|
|
679
|
-
direction:
|
|
695
|
+
direction: Direction.RIGHT
|
|
680
696
|
}
|
|
681
|
-
},
|
|
682
|
-
id:
|
|
683
|
-
binding:
|
|
684
|
-
preconditions:
|
|
697
|
+
}, MoveSelectionUpShortcut = {
|
|
698
|
+
id: MoveSelectionOperation.id,
|
|
699
|
+
binding: KeyCode.ARROW_UP | MetaKeys.SHIFT,
|
|
700
|
+
preconditions: whenDocAndEditorFocused,
|
|
685
701
|
staticParameters: {
|
|
686
|
-
direction:
|
|
702
|
+
direction: Direction.UP
|
|
687
703
|
}
|
|
688
|
-
},
|
|
689
|
-
id:
|
|
690
|
-
binding:
|
|
691
|
-
preconditions:
|
|
704
|
+
}, MoveSelectionDownShortcut = {
|
|
705
|
+
id: MoveSelectionOperation.id,
|
|
706
|
+
binding: KeyCode.ARROW_DOWN | MetaKeys.SHIFT,
|
|
707
|
+
preconditions: whenDocAndEditorFocused,
|
|
692
708
|
staticParameters: {
|
|
693
|
-
direction:
|
|
709
|
+
direction: Direction.DOWN
|
|
694
710
|
}
|
|
695
|
-
},
|
|
696
|
-
id:
|
|
697
|
-
binding:
|
|
698
|
-
preconditions:
|
|
711
|
+
}, MoveSelectionLeftShortcut = {
|
|
712
|
+
id: MoveSelectionOperation.id,
|
|
713
|
+
binding: KeyCode.ARROW_LEFT | MetaKeys.SHIFT,
|
|
714
|
+
preconditions: whenDocAndEditorFocused,
|
|
699
715
|
staticParameters: {
|
|
700
|
-
direction:
|
|
716
|
+
direction: Direction.LEFT
|
|
701
717
|
}
|
|
702
|
-
},
|
|
703
|
-
id:
|
|
704
|
-
binding:
|
|
705
|
-
preconditions:
|
|
718
|
+
}, MoveSelectionRightShortcut = {
|
|
719
|
+
id: MoveSelectionOperation.id,
|
|
720
|
+
binding: KeyCode.ARROW_RIGHT | MetaKeys.SHIFT,
|
|
721
|
+
preconditions: whenDocAndEditorFocused,
|
|
706
722
|
staticParameters: {
|
|
707
|
-
direction:
|
|
723
|
+
direction: Direction.RIGHT
|
|
708
724
|
}
|
|
709
|
-
},
|
|
710
|
-
id:
|
|
711
|
-
binding:
|
|
712
|
-
preconditions: (
|
|
725
|
+
}, SelectAllShortcut = {
|
|
726
|
+
id: SelectAllOperation.id,
|
|
727
|
+
binding: KeyCode.A | MetaKeys.CTRL_COMMAND,
|
|
728
|
+
preconditions: /* @__PURE__ */ __name((contextService) => contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && (contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED)), "preconditions")
|
|
713
729
|
};
|
|
714
|
-
var
|
|
715
|
-
for (var
|
|
716
|
-
(
|
|
717
|
-
return
|
|
718
|
-
},
|
|
719
|
-
let
|
|
720
|
-
constructor(
|
|
721
|
-
|
|
730
|
+
var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
731
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
732
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
733
|
+
return kind && result && __defProp$f(target, key, result), result;
|
|
734
|
+
}, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), _a3;
|
|
735
|
+
let DocContainerUIController = (_a3 = class {
|
|
736
|
+
constructor(_config, _localeService, _injector) {
|
|
737
|
+
__publicField(this, "_docContainer");
|
|
722
738
|
// 获取SheetContainer组件
|
|
723
|
-
|
|
724
|
-
if (this._docContainer =
|
|
739
|
+
__publicField(this, "getComponent", /* @__PURE__ */ __name((ref) => {
|
|
740
|
+
if (this._docContainer = ref, !ref.getContentRef().current)
|
|
725
741
|
throw new Error("container is not ready");
|
|
726
|
-
});
|
|
742
|
+
}, "getComponent"));
|
|
727
743
|
/**
|
|
728
744
|
* Change language
|
|
729
745
|
* @param {string} lang new language
|
|
@@ -731,10 +747,10 @@ let rt = class {
|
|
|
731
747
|
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
732
748
|
*
|
|
733
749
|
*/
|
|
734
|
-
|
|
735
|
-
this._localeService.setLocale(
|
|
736
|
-
});
|
|
737
|
-
this._config =
|
|
750
|
+
__publicField(this, "changeLocale", /* @__PURE__ */ __name((locale) => {
|
|
751
|
+
this._localeService.setLocale(locale);
|
|
752
|
+
}, "changeLocale"));
|
|
753
|
+
this._config = _config, this._localeService = _localeService, this._injector = _injector;
|
|
738
754
|
}
|
|
739
755
|
getUIConfig() {
|
|
740
756
|
return {
|
|
@@ -747,27 +763,27 @@ let rt = class {
|
|
|
747
763
|
getContentRef() {
|
|
748
764
|
return this._docContainer.getContentRef();
|
|
749
765
|
}
|
|
750
|
-
UIDidMount(
|
|
766
|
+
UIDidMount(cb) {
|
|
751
767
|
if (this._docContainer)
|
|
752
|
-
return
|
|
768
|
+
return cb(this._docContainer);
|
|
753
769
|
}
|
|
754
770
|
getDocContainer() {
|
|
755
771
|
return this._docContainer;
|
|
756
772
|
}
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
],
|
|
762
|
-
var
|
|
763
|
-
for (var
|
|
764
|
-
(
|
|
765
|
-
return
|
|
766
|
-
},
|
|
767
|
-
let
|
|
768
|
-
constructor(
|
|
773
|
+
}, __name(_a3, "DocContainerUIController"), _a3);
|
|
774
|
+
DocContainerUIController = __decorateClass$f([
|
|
775
|
+
__decorateParam$f(1, Inject(LocaleService)),
|
|
776
|
+
__decorateParam$f(2, Inject(Injector))
|
|
777
|
+
], DocContainerUIController);
|
|
778
|
+
var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
779
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
780
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
781
|
+
return kind && result && __defProp$e(target, key, result), result;
|
|
782
|
+
}, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a4;
|
|
783
|
+
let AppUIController = (_a4 = class extends RxDisposable {
|
|
784
|
+
constructor(_config, _localeService, _injector, _textSelectionRenderManager, _layoutService) {
|
|
769
785
|
super();
|
|
770
|
-
|
|
786
|
+
__publicField(this, "_docContainerController");
|
|
771
787
|
/**
|
|
772
788
|
* Change language
|
|
773
789
|
* @param {string} locale new language
|
|
@@ -775,10 +791,10 @@ let _e = class extends Se {
|
|
|
775
791
|
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
776
792
|
*
|
|
777
793
|
*/
|
|
778
|
-
|
|
779
|
-
this._localeService.setLocale(
|
|
780
|
-
});
|
|
781
|
-
this._localeService =
|
|
794
|
+
__publicField(this, "changeLocale", /* @__PURE__ */ __name((locale) => {
|
|
795
|
+
this._localeService.setLocale(locale);
|
|
796
|
+
}, "changeLocale"));
|
|
797
|
+
this._localeService = _localeService, this._injector = _injector, this._textSelectionRenderManager = _textSelectionRenderManager, this._layoutService = _layoutService, this._docContainerController = this._injector.createInstance(DocContainerUIController, _config), this._registerContainer();
|
|
782
798
|
}
|
|
783
799
|
_registerContainer() {
|
|
784
800
|
this._layoutService && this.disposeWithMe(
|
|
@@ -789,457 +805,508 @@ let _e = class extends Se {
|
|
|
789
805
|
getDocContainerController() {
|
|
790
806
|
return this._docContainerController;
|
|
791
807
|
}
|
|
792
|
-
};
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
],
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
808
|
+
}, __name(_a4, "AppUIController"), _a4);
|
|
809
|
+
AppUIController = __decorateClass$e([
|
|
810
|
+
__decorateParam$e(1, Inject(LocaleService)),
|
|
811
|
+
__decorateParam$e(2, Inject(Injector)),
|
|
812
|
+
__decorateParam$e(3, ITextSelectionRenderManager),
|
|
813
|
+
__decorateParam$e(4, Optional(ILayoutService))
|
|
814
|
+
], AppUIController);
|
|
815
|
+
const 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`;
|
|
816
|
+
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
817
|
+
/**
|
|
818
|
+
* @license React
|
|
819
|
+
* react-jsx-runtime.production.min.js
|
|
820
|
+
*
|
|
821
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
822
|
+
*
|
|
823
|
+
* This source code is licensed under the MIT license found in the
|
|
824
|
+
* LICENSE file in the root directory of this source tree.
|
|
825
|
+
*/
|
|
826
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
827
|
+
function q(c, a, g) {
|
|
828
|
+
var b, d = {}, e = null, h = null;
|
|
829
|
+
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
|
|
830
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
831
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
832
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
833
|
+
}
|
|
834
|
+
__name(q, "q");
|
|
835
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
836
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
837
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
838
|
+
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
839
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
840
|
+
const docCountBar = "univer-doc-count-bar", styles$2 = {
|
|
841
|
+
docCountBar
|
|
842
|
+
}, ZOOM_MAP = [50, 80, 100, 130, 150, 170, 200, 400], DOC_ZOOM_RANGE = [10, 400];
|
|
843
|
+
function ZoomSlider() {
|
|
844
|
+
const commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), currentDoc$ = useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), []), documentDataModel = useObservable(currentDoc$), getCurrentZoom = useCallback(() => {
|
|
845
|
+
var _a19, _b;
|
|
846
|
+
if (!documentDataModel) return 100;
|
|
847
|
+
const currentZoom = ((_b = (_a19 = documentDataModel.getSettings()) == null ? void 0 : _a19.zoomRatio) != null ? _b : 1) * 100;
|
|
848
|
+
return Math.round(currentZoom);
|
|
849
|
+
}, [documentDataModel]), [zoom, setZoom] = useState(() => getCurrentZoom());
|
|
850
|
+
useEffect(() => (setZoom(getCurrentZoom()), commandService.onCommandExecuted((commandInfo) => {
|
|
851
|
+
if (commandInfo.id === SetDocZoomRatioOperation.id) {
|
|
852
|
+
const currentZoom = getCurrentZoom();
|
|
853
|
+
setZoom(currentZoom);
|
|
854
|
+
}
|
|
855
|
+
}).dispose), [commandService, getCurrentZoom]);
|
|
856
|
+
function handleChange(value) {
|
|
857
|
+
if (setZoom(value), documentDataModel == null)
|
|
858
|
+
return;
|
|
859
|
+
const zoomRatio = value / 100;
|
|
860
|
+
commandService.executeCommand(SetDocZoomRatioOperation.id, {
|
|
861
|
+
unitId: documentDataModel.getUnitId(),
|
|
862
|
+
zoomRatio
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
return __name(handleChange, "handleChange"), /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
866
|
+
Slider,
|
|
867
|
+
{
|
|
868
|
+
min: DOC_ZOOM_RANGE[0],
|
|
869
|
+
value: zoom,
|
|
870
|
+
shortcuts: ZOOM_MAP,
|
|
871
|
+
onChange: handleChange
|
|
872
|
+
}
|
|
873
|
+
);
|
|
805
874
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
875
|
+
__name(ZoomSlider, "ZoomSlider");
|
|
876
|
+
function CountBar(props) {
|
|
877
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("section", { className: styles$2.docCountBar, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ZoomSlider, {}) });
|
|
878
|
+
}
|
|
879
|
+
__name(CountBar, "CountBar");
|
|
880
|
+
const docFooterContainer = "univer-doc-footer-container", styles$1 = {
|
|
881
|
+
docFooterContainer
|
|
882
|
+
}, DocFooter = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.docFooterContainer, children: [
|
|
883
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", {}),
|
|
884
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CountBar, {})
|
|
885
|
+
] }), "DocFooter"), COLLAB_CURSOR_LABEL_HEIGHT = 18, COLLAB_CURSOR_LABEL_MAX_WIDTH = 200, COLLAB_CURSOR_LABEL_TEXT_PADDING_LR = 6, COLLAB_CURSOR_LABEL_TEXT_PADDING_TB = 4;
|
|
886
|
+
function drawBubble(ctx, props) {
|
|
887
|
+
let { radius, width, height } = props;
|
|
888
|
+
radius = radius != null ? radius : 0, width = width != null ? width : 30, height = height != null ? height : 30;
|
|
889
|
+
let bottomRight = 0;
|
|
890
|
+
bottomRight = Math.min(radius, width / 2, height / 2), ctx.beginPath(), ctx.moveTo(0, 0), ctx.lineTo(width, 0), ctx.lineTo(width, height - bottomRight), ctx.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, !1), ctx.lineTo(0, height), ctx.lineTo(0, 0), ctx.closePath(), props.fill && (ctx.save(), ctx.fillStyle = props.fill, props.fillRule === "evenodd" ? ctx.fill("evenodd") : ctx.fill(), ctx.restore());
|
|
891
|
+
}
|
|
892
|
+
__name(drawBubble, "drawBubble");
|
|
893
|
+
const _TextBubbleShape = class _TextBubbleShape extends Shape {
|
|
894
|
+
constructor(key, props) {
|
|
895
|
+
super(key, props);
|
|
896
|
+
__publicField(this, "color");
|
|
897
|
+
__publicField(this, "text");
|
|
898
|
+
this.color = props == null ? void 0 : props.color, this.text = props == null ? void 0 : props.text;
|
|
899
|
+
}
|
|
900
|
+
static drawWith(ctx, props) {
|
|
901
|
+
const { text, color } = props;
|
|
902
|
+
ctx.save(), ctx.font = "13px Source Han Sans CN";
|
|
903
|
+
const textWidth = ctx.measureText(text).width, realInfoWidth = Math.min(
|
|
904
|
+
textWidth + 2 * COLLAB_CURSOR_LABEL_TEXT_PADDING_LR,
|
|
905
|
+
COLLAB_CURSOR_LABEL_MAX_WIDTH
|
|
819
906
|
);
|
|
820
|
-
|
|
821
|
-
height:
|
|
822
|
-
width:
|
|
907
|
+
drawBubble(ctx, {
|
|
908
|
+
height: COLLAB_CURSOR_LABEL_HEIGHT,
|
|
909
|
+
width: realInfoWidth,
|
|
823
910
|
radius: 4,
|
|
824
|
-
fill:
|
|
911
|
+
fill: color,
|
|
825
912
|
evented: !1
|
|
826
|
-
}),
|
|
827
|
-
const
|
|
828
|
-
if (
|
|
829
|
-
let
|
|
830
|
-
for (const
|
|
831
|
-
const
|
|
832
|
-
if (
|
|
833
|
-
|
|
913
|
+
}), ctx.fillStyle = "rgba(58, 96, 247, 1)";
|
|
914
|
+
const offsetX = COLLAB_CURSOR_LABEL_TEXT_PADDING_LR, offsetY = COLLAB_CURSOR_LABEL_HEIGHT - COLLAB_CURSOR_LABEL_TEXT_PADDING_TB, maxTextWidth = COLLAB_CURSOR_LABEL_MAX_WIDTH - 2 * COLLAB_CURSOR_LABEL_TEXT_PADDING_LR;
|
|
915
|
+
if (textWidth > maxTextWidth) {
|
|
916
|
+
let truncatedText = "", currentWidth = 0;
|
|
917
|
+
for (const element of text) {
|
|
918
|
+
const charWidth = ctx.measureText(element).width;
|
|
919
|
+
if (currentWidth + charWidth <= maxTextWidth - ctx.measureText("...").width)
|
|
920
|
+
truncatedText += element, currentWidth += charWidth;
|
|
834
921
|
else {
|
|
835
|
-
|
|
922
|
+
truncatedText += "...";
|
|
836
923
|
break;
|
|
837
924
|
}
|
|
838
925
|
}
|
|
839
|
-
|
|
926
|
+
ctx.fillText(truncatedText, offsetX, offsetY);
|
|
840
927
|
} else
|
|
841
|
-
|
|
842
|
-
|
|
928
|
+
ctx.fillText(text, offsetX, offsetY);
|
|
929
|
+
ctx.restore();
|
|
843
930
|
}
|
|
844
|
-
_draw(
|
|
845
|
-
|
|
931
|
+
_draw(ctx) {
|
|
932
|
+
_TextBubbleShape.drawWith(ctx, this);
|
|
846
933
|
}
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
n !== void 0 && (i = "" + n), e.key !== void 0 && (i = "" + e.key), e.ref !== void 0 && (s = e.ref);
|
|
863
|
-
for (o in e) Tr.call(e, o) && !br.hasOwnProperty(o) && (r[o] = e[o]);
|
|
864
|
-
if (t && t.defaultProps) for (o in e = t.defaultProps, e) r[o] === void 0 && (r[o] = e[o]);
|
|
865
|
-
return { $$typeof: Cr, type: t, key: i, ref: s, props: r, _owner: Ir.current };
|
|
866
|
-
}
|
|
867
|
-
ke.Fragment = Er;
|
|
868
|
-
ke.jsx = fn;
|
|
869
|
-
ke.jsxs = fn;
|
|
870
|
-
pn.exports = ke;
|
|
871
|
-
var M = pn.exports;
|
|
872
|
-
const Mr = "univer-panel", yr = "univer-options-section", xr = "univer-options-form-item", Pr = "univer-options-input", Dr = "univer-options-margin-setting", $ = {
|
|
873
|
-
panel: Mr,
|
|
874
|
-
optionsSection: yr,
|
|
875
|
-
optionsFormItem: xr,
|
|
876
|
-
optionsInput: Pr,
|
|
877
|
-
optionsMarginSetting: Dr
|
|
878
|
-
}, Ar = (t) => {
|
|
879
|
-
const e = z(le), n = z(w), o = z(W), r = z(O), i = z(ne), s = z(te), { unitId: a } = t, [c, d] = an({}), g = (l, f) => {
|
|
880
|
-
var N;
|
|
881
|
-
d((Y) => ({
|
|
882
|
-
...Y,
|
|
883
|
-
[f]: l ? S.TRUE : S.FALSE
|
|
934
|
+
};
|
|
935
|
+
__name(_TextBubbleShape, "TextBubbleShape");
|
|
936
|
+
let TextBubbleShape = _TextBubbleShape;
|
|
937
|
+
const COMPONENT_DOC_HEADER_FOOTER_PANEL = "COMPONENT_DOC_HEADER_FOOTER_PANEL", panel = "univer-panel", optionsSection = "univer-options-section", optionsFormItem = "univer-options-form-item", optionsInput = "univer-options-input", optionsMarginSetting = "univer-options-margin-setting", styles = {
|
|
938
|
+
panel,
|
|
939
|
+
optionsSection,
|
|
940
|
+
optionsFormItem,
|
|
941
|
+
optionsInput,
|
|
942
|
+
optionsMarginSetting
|
|
943
|
+
}, DocHeaderFooterOptions = /* @__PURE__ */ __name((props) => {
|
|
944
|
+
const localeService = useDependency(LocaleService), univerInstanceService = useDependency(IUniverInstanceService), renderManagerService = useDependency(IRenderManagerService), commandService = useDependency(ICommandService), textSelectionRenderService = useDependency(ITextSelectionRenderManager), textSelectionManagerService = useDependency(TextSelectionManagerService), { unitId } = props, [options, setOptions] = useState({}), handleCheckboxChange = /* @__PURE__ */ __name((val, type) => {
|
|
945
|
+
var _a19;
|
|
946
|
+
setOptions((prev) => ({
|
|
947
|
+
...prev,
|
|
948
|
+
[type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
|
|
884
949
|
}));
|
|
885
|
-
const
|
|
886
|
-
if (
|
|
950
|
+
const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle, docSkeletonManagerService = (_a19 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a19.with(DocSkeletonManagerService), viewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
|
|
951
|
+
if (documentStyle == null || viewModel == null)
|
|
887
952
|
return;
|
|
888
|
-
const
|
|
889
|
-
let
|
|
890
|
-
const
|
|
891
|
-
let
|
|
892
|
-
if (
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
unitId
|
|
896
|
-
segmentId
|
|
953
|
+
const editArea = viewModel.getEditArea();
|
|
954
|
+
let needCreateHeaderFooter = !1;
|
|
955
|
+
const segmentPage = textSelectionRenderService.getSegmentPage();
|
|
956
|
+
let needChangeSegmentId = !1;
|
|
957
|
+
if (type === "useFirstPageHeaderFooter" && val === !0 && ((editArea === DocumentEditArea.HEADER && !documentStyle.firstPageHeaderId || editArea === DocumentEditArea.FOOTER && !documentStyle.firstPageFooterId) && (needCreateHeaderFooter = !0), needCreateHeaderFooter && segmentPage === 0 && (needChangeSegmentId = !0)), type === "evenAndOddHeaders" && val === !0 && ((editArea === DocumentEditArea.HEADER && !documentStyle.evenPageHeaderId || editArea === DocumentEditArea.FOOTER && !documentStyle.evenPageFooterId) && (needCreateHeaderFooter = !0), needCreateHeaderFooter && segmentPage % 2 === 1 && (needChangeSegmentId = !0)), needCreateHeaderFooter) {
|
|
958
|
+
const segmentId = Tools.generateRandomId(6);
|
|
959
|
+
needChangeSegmentId && textSelectionRenderService.setSegment(segmentId), commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
960
|
+
unitId,
|
|
961
|
+
segmentId,
|
|
897
962
|
headerFooterProps: {
|
|
898
|
-
[
|
|
963
|
+
[type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
|
|
899
964
|
}
|
|
900
965
|
});
|
|
901
966
|
} else
|
|
902
|
-
|
|
903
|
-
unitId
|
|
967
|
+
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
968
|
+
unitId,
|
|
904
969
|
headerFooterProps: {
|
|
905
|
-
[
|
|
970
|
+
[type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
|
|
906
971
|
}
|
|
907
972
|
});
|
|
908
|
-
},
|
|
909
|
-
|
|
910
|
-
...
|
|
911
|
-
[
|
|
912
|
-
})), await
|
|
913
|
-
unitId
|
|
973
|
+
}, "handleCheckboxChange"), handleMarginChange = /* @__PURE__ */ __name(async (val, type) => {
|
|
974
|
+
setOptions((prev) => ({
|
|
975
|
+
...prev,
|
|
976
|
+
[type]: val
|
|
977
|
+
})), await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
978
|
+
unitId,
|
|
914
979
|
headerFooterProps: {
|
|
915
|
-
[
|
|
980
|
+
[type]: val
|
|
916
981
|
}
|
|
917
|
-
}),
|
|
918
|
-
},
|
|
919
|
-
var
|
|
920
|
-
const
|
|
921
|
-
if (
|
|
982
|
+
}), textSelectionRenderService.removeAllTextRanges(), textSelectionRenderService.blur();
|
|
983
|
+
}, "handleMarginChange"), closeHeaderFooter = /* @__PURE__ */ __name(() => {
|
|
984
|
+
var _a19;
|
|
985
|
+
const renderObject = renderManagerService.getRenderById(unitId);
|
|
986
|
+
if (renderObject == null)
|
|
922
987
|
return;
|
|
923
|
-
const { scene
|
|
924
|
-
|
|
925
|
-
};
|
|
926
|
-
return
|
|
927
|
-
const
|
|
928
|
-
if (
|
|
929
|
-
const { marginHeader
|
|
930
|
-
|
|
931
|
-
marginHeader
|
|
932
|
-
marginFooter
|
|
933
|
-
useFirstPageHeaderFooter
|
|
934
|
-
evenAndOddHeaders
|
|
988
|
+
const { scene } = renderObject, transformer = scene.getTransformerByCreate(), docSkeletonManagerService = renderObject.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton(), viewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel(), render = renderManagerService.getRenderById(unitId);
|
|
989
|
+
render == null || viewModel == null || skeleton == null || (textSelectionManagerService.replaceTextRanges([]), transformer.clearSelectedObjects(), textSelectionRenderService.setSegment(""), textSelectionRenderService.setSegmentPage(-1), viewModel.setEditArea(DocumentEditArea.BODY), skeleton.calculate(), (_a19 = render.mainComponent) == null || _a19.makeDirty(!0));
|
|
990
|
+
}, "closeHeaderFooter");
|
|
991
|
+
return useEffect(() => {
|
|
992
|
+
const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle;
|
|
993
|
+
if (documentStyle) {
|
|
994
|
+
const { marginHeader, marginFooter, useFirstPageHeaderFooter, evenAndOddHeaders } = documentStyle;
|
|
995
|
+
setOptions({
|
|
996
|
+
marginHeader,
|
|
997
|
+
marginFooter,
|
|
998
|
+
useFirstPageHeaderFooter,
|
|
999
|
+
evenAndOddHeaders
|
|
935
1000
|
});
|
|
936
1001
|
}
|
|
937
|
-
}, [
|
|
938
|
-
/* @__PURE__ */
|
|
939
|
-
/* @__PURE__ */
|
|
940
|
-
|
|
1002
|
+
}, [unitId]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.options, children: [
|
|
1003
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.optionsSection, children: [
|
|
1004
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.optionsFormItem, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1005
|
+
Checkbox,
|
|
941
1006
|
{
|
|
942
|
-
checked:
|
|
943
|
-
onChange: (
|
|
944
|
-
|
|
945
|
-
},
|
|
946
|
-
children:
|
|
1007
|
+
checked: options.useFirstPageHeaderFooter === BooleanNumber.TRUE,
|
|
1008
|
+
onChange: /* @__PURE__ */ __name((val) => {
|
|
1009
|
+
handleCheckboxChange(val, "useFirstPageHeaderFooter");
|
|
1010
|
+
}, "onChange"),
|
|
1011
|
+
children: localeService.t("headerFooter.firstPageCheckBox")
|
|
947
1012
|
}
|
|
948
1013
|
) }),
|
|
949
|
-
/* @__PURE__ */
|
|
950
|
-
|
|
1014
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.optionsFormItem, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1015
|
+
Checkbox,
|
|
951
1016
|
{
|
|
952
|
-
checked:
|
|
953
|
-
onChange: (
|
|
954
|
-
|
|
955
|
-
},
|
|
956
|
-
children:
|
|
1017
|
+
checked: options.evenAndOddHeaders === BooleanNumber.TRUE,
|
|
1018
|
+
onChange: /* @__PURE__ */ __name((val) => {
|
|
1019
|
+
handleCheckboxChange(val, "evenAndOddHeaders");
|
|
1020
|
+
}, "onChange"),
|
|
1021
|
+
children: localeService.t("headerFooter.oddEvenCheckBox")
|
|
957
1022
|
}
|
|
958
1023
|
) })
|
|
959
1024
|
] }),
|
|
960
|
-
/* @__PURE__ */
|
|
961
|
-
/* @__PURE__ */
|
|
962
|
-
/* @__PURE__ */
|
|
963
|
-
/* @__PURE__ */
|
|
964
|
-
|
|
1025
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: clsx(styles.optionsSection, styles.optionsMarginSetting), children: [
|
|
1026
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.optionsMarginItem, children: [
|
|
1027
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: localeService.t("headerFooter.headerTopMargin") }),
|
|
1028
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1029
|
+
InputNumber,
|
|
965
1030
|
{
|
|
966
1031
|
min: 0,
|
|
967
1032
|
max: 200,
|
|
968
1033
|
precision: 1,
|
|
969
|
-
value:
|
|
970
|
-
onChange: (
|
|
971
|
-
|
|
972
|
-
},
|
|
973
|
-
className:
|
|
1034
|
+
value: options.marginHeader,
|
|
1035
|
+
onChange: /* @__PURE__ */ __name((val) => {
|
|
1036
|
+
handleMarginChange(val, "marginHeader");
|
|
1037
|
+
}, "onChange"),
|
|
1038
|
+
className: styles.optionsInput
|
|
974
1039
|
}
|
|
975
1040
|
)
|
|
976
1041
|
] }),
|
|
977
|
-
/* @__PURE__ */
|
|
978
|
-
/* @__PURE__ */
|
|
979
|
-
/* @__PURE__ */
|
|
980
|
-
|
|
1042
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.optionsMarginItem, children: [
|
|
1043
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: localeService.t("headerFooter.footerBottomMargin") }),
|
|
1044
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1045
|
+
InputNumber,
|
|
981
1046
|
{
|
|
982
1047
|
min: 0,
|
|
983
1048
|
max: 200,
|
|
984
1049
|
precision: 1,
|
|
985
|
-
value:
|
|
986
|
-
onChange: (
|
|
987
|
-
|
|
988
|
-
},
|
|
989
|
-
className:
|
|
1050
|
+
value: options.marginFooter,
|
|
1051
|
+
onChange: /* @__PURE__ */ __name((val) => {
|
|
1052
|
+
handleMarginChange(val, "marginFooter");
|
|
1053
|
+
}, "onChange"),
|
|
1054
|
+
className: styles.optionsInput
|
|
990
1055
|
}
|
|
991
1056
|
)
|
|
992
1057
|
] })
|
|
993
1058
|
] }),
|
|
994
|
-
/* @__PURE__ */
|
|
1059
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.optionsSection, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: closeHeaderFooter, children: localeService.t("headerFooter.closeHeaderFooter") }) })
|
|
995
1060
|
] });
|
|
996
|
-
},
|
|
997
|
-
var
|
|
998
|
-
const
|
|
999
|
-
return
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1061
|
+
}, "DocHeaderFooterOptions"), DocHeaderFooterPanel = /* @__PURE__ */ __name(() => {
|
|
1062
|
+
var _a19;
|
|
1063
|
+
const localeService = useDependency(LocaleService), renderManagerService = useDependency(IRenderManagerService), unitId = useDependency(IUniverInstanceService).getCurrentUniverDocInstance().getUnitId(), viewModel = ((_a19 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a19.with(DocSkeletonManagerService)).getViewModel(), [isEditHeaderFooter, setIsEditHeaderFooter] = useState(!0);
|
|
1064
|
+
return useEffect(() => {
|
|
1065
|
+
const editArea = viewModel.getEditArea();
|
|
1066
|
+
setIsEditHeaderFooter(editArea !== DocumentEditArea.BODY);
|
|
1067
|
+
const subscription = viewModel.editAreaChange$.subscribe((editArea2) => {
|
|
1068
|
+
editArea2 != null && setIsEditHeaderFooter(editArea2 !== DocumentEditArea.BODY);
|
|
1004
1069
|
});
|
|
1005
1070
|
return () => {
|
|
1006
|
-
|
|
1071
|
+
subscription.unsubscribe();
|
|
1007
1072
|
};
|
|
1008
|
-
}, []), /* @__PURE__ */
|
|
1009
|
-
},
|
|
1073
|
+
}, []), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.panel, children: isEditHeaderFooter ? /* @__PURE__ */ jsxRuntimeExports.jsx(DocHeaderFooterOptions, { unitId }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.panelDisableText, children: localeService.t("headerFooter.disableText") }) });
|
|
1074
|
+
}, "DocHeaderFooterPanel"), SidebarDocHeaderFooterPanelOperation = {
|
|
1010
1075
|
id: "sidebar.operation.doc-header-footer-panel",
|
|
1011
|
-
type:
|
|
1012
|
-
handler: async (
|
|
1013
|
-
const
|
|
1014
|
-
switch (
|
|
1076
|
+
type: CommandType.COMMAND,
|
|
1077
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
1078
|
+
const sidebarService = accessor.get(ISidebarService), localeService = accessor.get(LocaleService);
|
|
1079
|
+
switch (params.value) {
|
|
1015
1080
|
case "open":
|
|
1016
|
-
|
|
1017
|
-
header: { title:
|
|
1018
|
-
children: { label:
|
|
1019
|
-
onClose: () => {
|
|
1020
|
-
},
|
|
1081
|
+
sidebarService.open({
|
|
1082
|
+
header: { title: localeService.t("headerFooter.panel") },
|
|
1083
|
+
children: { label: COMPONENT_DOC_HEADER_FOOTER_PANEL },
|
|
1084
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
1085
|
+
}, "onClose"),
|
|
1021
1086
|
width: 400
|
|
1022
1087
|
});
|
|
1023
1088
|
break;
|
|
1024
1089
|
case "close":
|
|
1025
1090
|
default:
|
|
1026
|
-
|
|
1091
|
+
sidebarService.close();
|
|
1027
1092
|
break;
|
|
1028
1093
|
}
|
|
1029
1094
|
return !0;
|
|
1030
|
-
}
|
|
1095
|
+
}, "handler")
|
|
1031
1096
|
};
|
|
1032
|
-
var
|
|
1033
|
-
for (var
|
|
1034
|
-
(
|
|
1035
|
-
return
|
|
1036
|
-
},
|
|
1037
|
-
const
|
|
1038
|
-
var
|
|
1039
|
-
function
|
|
1040
|
-
const { documentStyle
|
|
1041
|
-
defaultHeaderId
|
|
1042
|
-
defaultFooterId
|
|
1043
|
-
evenPageHeaderId
|
|
1044
|
-
evenPageFooterId
|
|
1045
|
-
firstPageHeaderId
|
|
1046
|
-
firstPageFooterId
|
|
1047
|
-
evenAndOddHeaders
|
|
1048
|
-
useFirstPageHeaderFooter
|
|
1049
|
-
} =
|
|
1050
|
-
switch (
|
|
1051
|
-
case
|
|
1097
|
+
var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1098
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1099
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1100
|
+
return kind && result && __defProp$d(target, key, result), result;
|
|
1101
|
+
}, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d");
|
|
1102
|
+
const HEADER_FOOTER_STROKE_COLOR = "rgba(58, 96, 247, 1)", HEADER_FOOTER_FILL_COLOR = "rgba(58, 96, 247, 0.08)";
|
|
1103
|
+
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 || {});
|
|
1104
|
+
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
|
|
1105
|
+
const { documentStyle } = viewModel.getDataModel().getSnapshot(), {
|
|
1106
|
+
defaultHeaderId,
|
|
1107
|
+
defaultFooterId,
|
|
1108
|
+
evenPageHeaderId,
|
|
1109
|
+
evenPageFooterId,
|
|
1110
|
+
firstPageHeaderId,
|
|
1111
|
+
firstPageFooterId,
|
|
1112
|
+
evenAndOddHeaders,
|
|
1113
|
+
useFirstPageHeaderFooter
|
|
1114
|
+
} = documentStyle;
|
|
1115
|
+
switch (editArea) {
|
|
1116
|
+
case DocumentEditArea.BODY:
|
|
1052
1117
|
return {
|
|
1053
1118
|
createType: null,
|
|
1054
1119
|
headerFooterId: null
|
|
1055
1120
|
};
|
|
1056
|
-
case
|
|
1057
|
-
return
|
|
1121
|
+
case DocumentEditArea.HEADER:
|
|
1122
|
+
return useFirstPageHeaderFooter === BooleanNumber.TRUE && !firstPageHeaderId ? {
|
|
1058
1123
|
createType: 0,
|
|
1059
1124
|
headerFooterId: null
|
|
1060
|
-
} :
|
|
1125
|
+
} : evenAndOddHeaders === BooleanNumber.TRUE && segmentPage % 2 === 0 && !evenPageHeaderId ? {
|
|
1061
1126
|
createType: 4,
|
|
1062
1127
|
headerFooterId: null
|
|
1063
|
-
} :
|
|
1128
|
+
} : defaultHeaderId ? {
|
|
1064
1129
|
createType: null,
|
|
1065
|
-
headerFooterId:
|
|
1130
|
+
headerFooterId: defaultHeaderId
|
|
1066
1131
|
} : {
|
|
1067
1132
|
createType: 2,
|
|
1068
1133
|
headerFooterId: null
|
|
1069
1134
|
};
|
|
1070
|
-
case
|
|
1071
|
-
return
|
|
1135
|
+
case DocumentEditArea.FOOTER:
|
|
1136
|
+
return useFirstPageHeaderFooter === BooleanNumber.TRUE && !firstPageFooterId ? {
|
|
1072
1137
|
createType: 1,
|
|
1073
1138
|
headerFooterId: null
|
|
1074
|
-
} :
|
|
1139
|
+
} : evenAndOddHeaders === BooleanNumber.TRUE && segmentPage % 2 === 0 && !evenPageFooterId ? {
|
|
1075
1140
|
createType: 5,
|
|
1076
1141
|
headerFooterId: null
|
|
1077
|
-
} :
|
|
1142
|
+
} : defaultFooterId ? {
|
|
1078
1143
|
createType: null,
|
|
1079
|
-
headerFooterId:
|
|
1144
|
+
headerFooterId: defaultFooterId
|
|
1080
1145
|
} : {
|
|
1081
1146
|
createType: 3,
|
|
1082
1147
|
headerFooterId: null
|
|
1083
1148
|
};
|
|
1084
1149
|
default:
|
|
1085
|
-
throw new Error(`Invalid editArea: ${
|
|
1150
|
+
throw new Error(`Invalid editArea: ${editArea}`);
|
|
1086
1151
|
}
|
|
1087
1152
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1153
|
+
__name(checkCreateHeaderFooterType, "checkCreateHeaderFooterType");
|
|
1154
|
+
var _a5;
|
|
1155
|
+
let DocHeaderFooterController = (_a5 = class extends Disposable {
|
|
1156
|
+
constructor(_context, _commandService, _editorService, _instanceSrv, _renderManagerService, _docSkeletonManagerService, _textSelectionRenderManager, _localeService, _componentManager) {
|
|
1090
1157
|
super();
|
|
1091
|
-
|
|
1092
|
-
this._context =
|
|
1158
|
+
__publicField(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
1159
|
+
this._context = _context, this._commandService = _commandService, this._editorService = _editorService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._docSkeletonManagerService = _docSkeletonManagerService, this._textSelectionRenderManager = _textSelectionRenderManager, this._localeService = _localeService, this._componentManager = _componentManager, this._initialize();
|
|
1093
1160
|
}
|
|
1094
1161
|
_initialize() {
|
|
1095
|
-
this._context.unit.getSnapshot().documentStyle.documentFlavor ===
|
|
1162
|
+
this._context.unit.getSnapshot().documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL && (this._init(), this._drawHeaderFooterLabel(), this._registerCommands(), this._initCustomComponents());
|
|
1096
1163
|
}
|
|
1097
1164
|
_registerCommands() {
|
|
1098
1165
|
[
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
].forEach((
|
|
1166
|
+
CoreHeaderFooterCommand,
|
|
1167
|
+
OpenHeaderFooterPanelCommand,
|
|
1168
|
+
SidebarDocHeaderFooterPanelOperation
|
|
1169
|
+
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
1103
1170
|
}
|
|
1104
1171
|
_initCustomComponents() {
|
|
1105
|
-
const
|
|
1106
|
-
this.disposeWithMe(
|
|
1172
|
+
const componentManager = this._componentManager;
|
|
1173
|
+
this.disposeWithMe(componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
|
|
1107
1174
|
}
|
|
1108
1175
|
_init() {
|
|
1109
|
-
const { unitId
|
|
1110
|
-
|
|
1176
|
+
const { unitId } = this._context, docObject = neoGetDocObject(this._context);
|
|
1177
|
+
docObject == null || docObject.document == null || this._loadedMap.has(docObject.document) || (this._initialMain(unitId), this._loadedMap.add(docObject.document));
|
|
1111
1178
|
}
|
|
1112
|
-
_initialMain(
|
|
1113
|
-
const
|
|
1114
|
-
this.disposeWithMe(
|
|
1115
|
-
if (this._isEditorReadOnly(
|
|
1179
|
+
_initialMain(unitId) {
|
|
1180
|
+
const docObject = neoGetDocObject(this._context), { document } = docObject;
|
|
1181
|
+
this.disposeWithMe(document.onDblclick$.subscribeEvent(async (evt) => {
|
|
1182
|
+
if (this._isEditorReadOnly(unitId))
|
|
1116
1183
|
return;
|
|
1117
|
-
const { offsetX
|
|
1118
|
-
pageLayoutType
|
|
1119
|
-
pageMarginLeft
|
|
1120
|
-
pageMarginTop
|
|
1121
|
-
} =
|
|
1122
|
-
if (
|
|
1184
|
+
const { offsetX, offsetY } = evt, {
|
|
1185
|
+
pageLayoutType = PageLayoutType.VERTICAL,
|
|
1186
|
+
pageMarginLeft,
|
|
1187
|
+
pageMarginTop
|
|
1188
|
+
} = document.getOffsetConfig(), coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
|
|
1189
|
+
if (coord == null)
|
|
1123
1190
|
return;
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1191
|
+
const viewModel = this._docSkeletonManagerService.getViewModel(), skeleton = this._docSkeletonManagerService.getSkeleton(), preEditArea = viewModel.getEditArea(), { editArea, pageNumber } = skeleton.findEditAreaByCoord(
|
|
1192
|
+
coord,
|
|
1193
|
+
pageLayoutType,
|
|
1194
|
+
pageMarginLeft,
|
|
1195
|
+
pageMarginTop
|
|
1129
1196
|
);
|
|
1130
|
-
if (
|
|
1197
|
+
if (preEditArea === editArea)
|
|
1131
1198
|
return;
|
|
1132
|
-
|
|
1133
|
-
const { createType
|
|
1134
|
-
if (
|
|
1135
|
-
this._textSelectionRenderManager.setSegment(""), this._textSelectionRenderManager.setSegmentPage(-1), this._textSelectionRenderManager.setCursorManually(
|
|
1136
|
-
else if (
|
|
1137
|
-
const
|
|
1138
|
-
this._textSelectionRenderManager.setSegment(
|
|
1139
|
-
unitId
|
|
1140
|
-
createType
|
|
1141
|
-
segmentId
|
|
1199
|
+
viewModel.setEditArea(editArea);
|
|
1200
|
+
const { createType, headerFooterId } = checkCreateHeaderFooterType(viewModel, editArea, pageNumber);
|
|
1201
|
+
if (editArea === DocumentEditArea.BODY)
|
|
1202
|
+
this._textSelectionRenderManager.setSegment(""), this._textSelectionRenderManager.setSegmentPage(-1), this._textSelectionRenderManager.setCursorManually(offsetX, offsetY);
|
|
1203
|
+
else if (createType != null) {
|
|
1204
|
+
const segmentId = Tools.generateRandomId(6);
|
|
1205
|
+
this._textSelectionRenderManager.setSegment(segmentId), this._textSelectionRenderManager.setSegmentPage(pageNumber), await this._commandService.executeCommand(CoreHeaderFooterCommand.id, {
|
|
1206
|
+
unitId,
|
|
1207
|
+
createType,
|
|
1208
|
+
segmentId
|
|
1142
1209
|
});
|
|
1143
|
-
} else
|
|
1210
|
+
} else headerFooterId != null && (this._textSelectionRenderManager.setSegment(headerFooterId), this._textSelectionRenderManager.setSegmentPage(pageNumber), this._textSelectionRenderManager.setCursorManually(offsetX, offsetY));
|
|
1144
1211
|
}));
|
|
1145
1212
|
}
|
|
1146
|
-
_getTransformCoordForDocumentOffset(
|
|
1147
|
-
const
|
|
1148
|
-
if (
|
|
1213
|
+
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
1214
|
+
const docObject = neoGetDocObject(this._context), { document, scene } = docObject, { documentTransform } = document.getOffsetConfig(), activeViewport = scene.getViewports()[0];
|
|
1215
|
+
if (activeViewport == null)
|
|
1149
1216
|
return;
|
|
1150
|
-
const
|
|
1151
|
-
return
|
|
1217
|
+
const originCoord = activeViewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
1218
|
+
return documentTransform.clone().invert().applyPoint(originCoord);
|
|
1152
1219
|
}
|
|
1153
1220
|
// eslint-disable-next-line max-lines-per-function
|
|
1154
1221
|
_drawHeaderFooterLabel() {
|
|
1155
|
-
const
|
|
1156
|
-
this._renderManagerService.currentRender$.subscribe((
|
|
1157
|
-
if (
|
|
1222
|
+
const localeService = this._localeService;
|
|
1223
|
+
this._renderManagerService.currentRender$.subscribe((unitId) => {
|
|
1224
|
+
if (unitId == null)
|
|
1158
1225
|
return;
|
|
1159
|
-
const
|
|
1160
|
-
if (this._editorService.isEditor(
|
|
1226
|
+
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
1227
|
+
if (this._editorService.isEditor(unitId) || this._instanceSrv.getUniverDocInstance(unitId) == null || currentRender == null)
|
|
1161
1228
|
return;
|
|
1162
|
-
const { mainComponent
|
|
1229
|
+
const { mainComponent } = currentRender, docsComponent = mainComponent;
|
|
1163
1230
|
this.disposeWithMe(
|
|
1164
|
-
|
|
1231
|
+
toDisposable(
|
|
1165
1232
|
// eslint-disable-next-line max-lines-per-function
|
|
1166
|
-
|
|
1167
|
-
if (this._editorService.isEditor(
|
|
1233
|
+
docsComponent.pageRender$.subscribe((config) => {
|
|
1234
|
+
if (this._editorService.isEditor(unitId))
|
|
1168
1235
|
return;
|
|
1169
|
-
const
|
|
1170
|
-
if (
|
|
1236
|
+
const isEditBody = this._docSkeletonManagerService.getViewModel().getEditArea() === DocumentEditArea.BODY, { page, pageLeft, pageTop, ctx } = config, { pageWidth, pageHeight, marginTop, marginBottom } = page;
|
|
1237
|
+
if (ctx.save(), ctx.translate(pageLeft - 0.5, pageTop - 0.5), isEditBody ? (Rect.drawWith(ctx, {
|
|
1171
1238
|
left: 0,
|
|
1172
1239
|
top: 0,
|
|
1173
|
-
width:
|
|
1174
|
-
height:
|
|
1240
|
+
width: pageWidth,
|
|
1241
|
+
height: marginTop,
|
|
1175
1242
|
fill: "rgba(255, 255, 255, 0.5)"
|
|
1176
|
-
}),
|
|
1243
|
+
}), ctx.save(), ctx.translate(0, pageHeight - marginBottom), Rect.drawWith(ctx, {
|
|
1177
1244
|
left: 0,
|
|
1178
1245
|
top: 0,
|
|
1179
|
-
width:
|
|
1180
|
-
height:
|
|
1246
|
+
width: pageWidth,
|
|
1247
|
+
height: marginBottom,
|
|
1181
1248
|
fill: "rgba(255, 255, 255, 0.5)"
|
|
1182
|
-
}),
|
|
1249
|
+
}), ctx.restore()) : (ctx.save(), ctx.translate(0, marginTop), Rect.drawWith(ctx, {
|
|
1183
1250
|
left: 0,
|
|
1184
|
-
top:
|
|
1185
|
-
width:
|
|
1186
|
-
height:
|
|
1251
|
+
top: marginTop,
|
|
1252
|
+
width: pageWidth,
|
|
1253
|
+
height: pageHeight - marginTop - marginBottom,
|
|
1187
1254
|
fill: "rgba(255, 255, 255, 0.5)"
|
|
1188
|
-
}),
|
|
1189
|
-
const
|
|
1255
|
+
}), ctx.restore()), !isEditBody) {
|
|
1256
|
+
const headerPathConfigIPathProps = {
|
|
1190
1257
|
dataArray: [{
|
|
1191
1258
|
command: "M",
|
|
1192
|
-
points: [0,
|
|
1259
|
+
points: [0, marginTop]
|
|
1193
1260
|
}, {
|
|
1194
1261
|
command: "L",
|
|
1195
|
-
points: [
|
|
1262
|
+
points: [pageWidth, marginTop]
|
|
1196
1263
|
}],
|
|
1197
1264
|
strokeWidth: 1,
|
|
1198
|
-
stroke:
|
|
1199
|
-
},
|
|
1265
|
+
stroke: HEADER_FOOTER_STROKE_COLOR
|
|
1266
|
+
}, footerPathConfigIPathProps = {
|
|
1200
1267
|
dataArray: [{
|
|
1201
1268
|
command: "M",
|
|
1202
|
-
points: [0,
|
|
1269
|
+
points: [0, pageHeight - marginBottom]
|
|
1203
1270
|
}, {
|
|
1204
1271
|
command: "L",
|
|
1205
|
-
points: [
|
|
1272
|
+
points: [pageWidth, pageHeight - marginBottom]
|
|
1206
1273
|
}],
|
|
1207
1274
|
strokeWidth: 1,
|
|
1208
|
-
stroke:
|
|
1275
|
+
stroke: HEADER_FOOTER_STROKE_COLOR
|
|
1209
1276
|
};
|
|
1210
|
-
|
|
1211
|
-
text:
|
|
1212
|
-
color:
|
|
1213
|
-
}),
|
|
1214
|
-
text:
|
|
1215
|
-
color:
|
|
1277
|
+
Path.drawWith(ctx, headerPathConfigIPathProps), Path.drawWith(ctx, footerPathConfigIPathProps), ctx.translate(0, marginTop + 1), TextBubbleShape.drawWith(ctx, {
|
|
1278
|
+
text: localeService.t("headerFooter.header"),
|
|
1279
|
+
color: HEADER_FOOTER_FILL_COLOR
|
|
1280
|
+
}), ctx.translate(0, pageHeight - marginTop - marginBottom), TextBubbleShape.drawWith(ctx, {
|
|
1281
|
+
text: localeService.t("headerFooter.footer"),
|
|
1282
|
+
color: HEADER_FOOTER_FILL_COLOR
|
|
1216
1283
|
});
|
|
1217
1284
|
}
|
|
1218
|
-
|
|
1285
|
+
ctx.restore();
|
|
1219
1286
|
})
|
|
1220
1287
|
)
|
|
1221
1288
|
);
|
|
1222
1289
|
});
|
|
1223
1290
|
}
|
|
1224
|
-
_isEditorReadOnly(
|
|
1225
|
-
const
|
|
1226
|
-
return
|
|
1291
|
+
_isEditorReadOnly(unitId) {
|
|
1292
|
+
const editor = this._editorService.getEditor(unitId);
|
|
1293
|
+
return editor ? editor.isReadOnly() : !1;
|
|
1227
1294
|
}
|
|
1228
1295
|
_getDocDataModel() {
|
|
1229
1296
|
return this._context.unit;
|
|
1230
1297
|
}
|
|
1231
|
-
};
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
],
|
|
1242
|
-
function
|
|
1298
|
+
}, __name(_a5, "DocHeaderFooterController"), _a5);
|
|
1299
|
+
DocHeaderFooterController = __decorateClass$d([
|
|
1300
|
+
__decorateParam$d(1, ICommandService),
|
|
1301
|
+
__decorateParam$d(2, IEditorService),
|
|
1302
|
+
__decorateParam$d(3, IUniverInstanceService),
|
|
1303
|
+
__decorateParam$d(4, IRenderManagerService),
|
|
1304
|
+
__decorateParam$d(5, Inject(DocSkeletonManagerService)),
|
|
1305
|
+
__decorateParam$d(6, ITextSelectionRenderManager),
|
|
1306
|
+
__decorateParam$d(7, Inject(LocaleService)),
|
|
1307
|
+
__decorateParam$d(8, Inject(ComponentManager))
|
|
1308
|
+
], DocHeaderFooterController);
|
|
1309
|
+
function getEmptyHeaderFooterBody() {
|
|
1243
1310
|
return {
|
|
1244
1311
|
dataStream: `\r
|
|
1245
1312
|
`,
|
|
@@ -1269,750 +1336,901 @@ function jt() {
|
|
|
1269
1336
|
]
|
|
1270
1337
|
};
|
|
1271
1338
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1339
|
+
__name(getEmptyHeaderFooterBody, "getEmptyHeaderFooterBody");
|
|
1340
|
+
function createHeaderFooterAction(segmentId, createType, documentStyle, actions) {
|
|
1341
|
+
const jsonX = JSONX.getInstance(), ID_LEN = 6, firstSegmentId = segmentId != null ? segmentId : Tools.generateRandomId(ID_LEN), isHeader = createType === HeaderFooterType.DEFAULT_HEADER || createType === HeaderFooterType.FIRST_PAGE_HEADER || createType === HeaderFooterType.EVEN_PAGE_HEADER, insertAction = jsonX.insertOp([isHeader ? "headers" : "footers", firstSegmentId], {
|
|
1342
|
+
[isHeader ? "headerId" : "footerId"]: firstSegmentId,
|
|
1343
|
+
body: getEmptyHeaderFooterBody()
|
|
1276
1344
|
});
|
|
1277
|
-
|
|
1278
|
-
const
|
|
1279
|
-
[
|
|
1280
|
-
body:
|
|
1345
|
+
actions.push(insertAction);
|
|
1346
|
+
const secondSegmentId = Tools.generateRandomId(ID_LEN), insertPairAction = jsonX.insertOp([isHeader ? "footers" : "headers", secondSegmentId], {
|
|
1347
|
+
[isHeader ? "footers" : "headers"]: secondSegmentId,
|
|
1348
|
+
body: getEmptyHeaderFooterBody()
|
|
1281
1349
|
});
|
|
1282
|
-
|
|
1283
|
-
let
|
|
1284
|
-
switch (
|
|
1285
|
-
case
|
|
1286
|
-
|
|
1350
|
+
actions.push(insertPairAction);
|
|
1351
|
+
let key = "defaultHeaderId", pairKey = "defaultFooterId";
|
|
1352
|
+
switch (createType) {
|
|
1353
|
+
case HeaderFooterType.DEFAULT_HEADER:
|
|
1354
|
+
key = "defaultHeaderId", pairKey = "defaultFooterId";
|
|
1287
1355
|
break;
|
|
1288
|
-
case
|
|
1289
|
-
|
|
1356
|
+
case HeaderFooterType.DEFAULT_FOOTER:
|
|
1357
|
+
key = "defaultFooterId", pairKey = "defaultHeaderId";
|
|
1290
1358
|
break;
|
|
1291
|
-
case
|
|
1292
|
-
|
|
1359
|
+
case HeaderFooterType.FIRST_PAGE_HEADER:
|
|
1360
|
+
key = "firstPageHeaderId", pairKey = "firstPageFooterId";
|
|
1293
1361
|
break;
|
|
1294
|
-
case
|
|
1295
|
-
|
|
1362
|
+
case HeaderFooterType.FIRST_PAGE_FOOTER:
|
|
1363
|
+
key = "firstPageFooterId", pairKey = "firstPageHeaderId";
|
|
1296
1364
|
break;
|
|
1297
|
-
case
|
|
1298
|
-
|
|
1365
|
+
case HeaderFooterType.EVEN_PAGE_HEADER:
|
|
1366
|
+
key = "evenPageHeaderId", pairKey = "evenPageFooterId";
|
|
1299
1367
|
break;
|
|
1300
|
-
case
|
|
1301
|
-
|
|
1368
|
+
case HeaderFooterType.EVEN_PAGE_FOOTER:
|
|
1369
|
+
key = "evenPageFooterId", pairKey = "evenPageHeaderId";
|
|
1302
1370
|
break;
|
|
1303
1371
|
default:
|
|
1304
|
-
throw new Error(`Unknown header footer type: ${
|
|
1372
|
+
throw new Error(`Unknown header footer type: ${createType}`);
|
|
1305
1373
|
}
|
|
1306
|
-
for (const [
|
|
1307
|
-
if (
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1374
|
+
for (const [k2, id] of [[key, firstSegmentId], [pairKey, secondSegmentId]])
|
|
1375
|
+
if (documentStyle[k2] != null) {
|
|
1376
|
+
const replaceAction = jsonX.replaceOp(["documentStyle", k2], documentStyle[k2], id);
|
|
1377
|
+
actions.push(replaceAction);
|
|
1310
1378
|
} else {
|
|
1311
|
-
const
|
|
1312
|
-
|
|
1379
|
+
const insertAction2 = jsonX.insertOp(["documentStyle", k2], id);
|
|
1380
|
+
actions.push(insertAction2);
|
|
1313
1381
|
}
|
|
1314
|
-
return
|
|
1382
|
+
return actions;
|
|
1315
1383
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1384
|
+
__name(createHeaderFooterAction, "createHeaderFooterAction");
|
|
1385
|
+
const CoreHeaderFooterCommandId = "doc.command.core-header-footer", CoreHeaderFooterCommand = {
|
|
1386
|
+
id: CoreHeaderFooterCommandId,
|
|
1387
|
+
type: CommandType.COMMAND,
|
|
1319
1388
|
// eslint-disable-next-line max-lines-per-function
|
|
1320
|
-
handler: async (
|
|
1321
|
-
var
|
|
1322
|
-
const
|
|
1323
|
-
if (
|
|
1389
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
1390
|
+
var _a19;
|
|
1391
|
+
const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderManagerService = accessor.get(IRenderManagerService), { unitId, segmentId, createType, headerFooterProps } = params, docSkeletonManagerService = (_a19 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a19.with(DocSkeletonManagerService), docDataModel = univerInstanceService.getUniverDocInstance(unitId), docViewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
|
|
1392
|
+
if (docDataModel == null || docViewModel == null)
|
|
1324
1393
|
return !1;
|
|
1325
|
-
const
|
|
1394
|
+
const editArea = docViewModel.getEditArea(), { documentStyle } = docDataModel.getSnapshot(), isUpdateMargin = (headerFooterProps == null ? void 0 : headerFooterProps.marginFooter) != null || (headerFooterProps == null ? void 0 : headerFooterProps.marginHeader) != null, textRanges = [{
|
|
1326
1395
|
startOffset: 0,
|
|
1327
1396
|
endOffset: 0,
|
|
1328
1397
|
collapsed: !0
|
|
1329
|
-
}],
|
|
1330
|
-
id:
|
|
1398
|
+
}], doMutation = {
|
|
1399
|
+
id: RichTextEditingMutation.id,
|
|
1331
1400
|
params: {
|
|
1332
|
-
unitId
|
|
1401
|
+
unitId,
|
|
1333
1402
|
actions: [],
|
|
1334
|
-
textRanges
|
|
1403
|
+
textRanges,
|
|
1335
1404
|
debounce: !0
|
|
1336
1405
|
}
|
|
1337
1406
|
};
|
|
1338
|
-
|
|
1339
|
-
const
|
|
1340
|
-
return
|
|
1341
|
-
const
|
|
1342
|
-
if (
|
|
1407
|
+
isUpdateMargin && (doMutation.params.noNeedSetTextRange = !0);
|
|
1408
|
+
const jsonX = JSONX.getInstance(), rawActions = [];
|
|
1409
|
+
return createType != null && createHeaderFooterAction(segmentId, createType, documentStyle, rawActions), headerFooterProps != null && Object.keys(headerFooterProps).forEach((key) => {
|
|
1410
|
+
const value = headerFooterProps[key], oldValue = documentStyle[key];
|
|
1411
|
+
if (value === oldValue)
|
|
1343
1412
|
return;
|
|
1344
|
-
let
|
|
1345
|
-
if (
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
} else if (
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1413
|
+
let action;
|
|
1414
|
+
if (oldValue === void 0 ? action = jsonX.insertOp(["documentStyle", key], value) : action = jsonX.replaceOp(["documentStyle", key], oldValue, value), rawActions.push(action), key === "useFirstPageHeaderFooter" && value === BooleanNumber.TRUE && !documentStyle.firstPageHeaderId) {
|
|
1415
|
+
const headerFooterType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.FIRST_PAGE_HEADER : HeaderFooterType.FIRST_PAGE_FOOTER;
|
|
1416
|
+
createHeaderFooterAction(segmentId, headerFooterType, documentStyle, rawActions);
|
|
1417
|
+
} else if (key === "evenAndOddHeaders" && value === BooleanNumber.TRUE && !documentStyle.evenPageHeaderId) {
|
|
1418
|
+
const headerFooterType = editArea === DocumentEditArea.HEADER ? HeaderFooterType.EVEN_PAGE_HEADER : HeaderFooterType.EVEN_PAGE_FOOTER;
|
|
1419
|
+
createHeaderFooterAction(segmentId, headerFooterType, documentStyle, rawActions);
|
|
1351
1420
|
}
|
|
1352
|
-
}),
|
|
1353
|
-
}
|
|
1354
|
-
},
|
|
1421
|
+
}), rawActions.length === 0 ? !1 : (doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params));
|
|
1422
|
+
}, "handler")
|
|
1423
|
+
}, OpenHeaderFooterPanelCommand = {
|
|
1355
1424
|
id: "doc.command.open-header-footer-panel",
|
|
1356
|
-
type:
|
|
1357
|
-
handler: async (
|
|
1425
|
+
type: CommandType.COMMAND,
|
|
1426
|
+
handler: /* @__PURE__ */ __name(async (accessor, _params) => accessor.get(ICommandService).executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" }), "handler")
|
|
1358
1427
|
};
|
|
1359
|
-
function
|
|
1360
|
-
const
|
|
1428
|
+
function BoldMenuItemFactory(accessor) {
|
|
1429
|
+
const commandService = accessor.get(ICommandService);
|
|
1361
1430
|
return {
|
|
1362
|
-
id:
|
|
1363
|
-
group:
|
|
1364
|
-
type:
|
|
1431
|
+
id: SetInlineFormatBoldCommand.id,
|
|
1432
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1433
|
+
type: MenuItemType.BUTTON,
|
|
1365
1434
|
icon: "BoldSingle",
|
|
1366
1435
|
title: "Set bold",
|
|
1367
1436
|
tooltip: "toolbar.bold",
|
|
1368
|
-
positions: [
|
|
1369
|
-
activated$: new
|
|
1370
|
-
const
|
|
1371
|
-
var
|
|
1372
|
-
const
|
|
1373
|
-
if (
|
|
1374
|
-
const
|
|
1375
|
-
if (
|
|
1437
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1438
|
+
activated$: new Observable((subscriber) => {
|
|
1439
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1440
|
+
var _a19;
|
|
1441
|
+
const id = c.id;
|
|
1442
|
+
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1443
|
+
const textRun = getFontStyleAtCursor(accessor);
|
|
1444
|
+
if (textRun == null)
|
|
1376
1445
|
return;
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1446
|
+
const bl = (_a19 = textRun.ts) == null ? void 0 : _a19.bl;
|
|
1447
|
+
subscriber.next(bl === BooleanNumber.TRUE);
|
|
1379
1448
|
}
|
|
1380
1449
|
});
|
|
1381
|
-
return
|
|
1450
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1382
1451
|
}),
|
|
1383
|
-
hidden$:
|
|
1452
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1384
1453
|
};
|
|
1385
1454
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1455
|
+
__name(BoldMenuItemFactory, "BoldMenuItemFactory");
|
|
1456
|
+
function ItalicMenuItemFactory(accessor) {
|
|
1457
|
+
const commandService = accessor.get(ICommandService);
|
|
1388
1458
|
return {
|
|
1389
|
-
id:
|
|
1390
|
-
group:
|
|
1391
|
-
type:
|
|
1459
|
+
id: SetInlineFormatItalicCommand.id,
|
|
1460
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1461
|
+
type: MenuItemType.BUTTON,
|
|
1392
1462
|
icon: "ItalicSingle",
|
|
1393
1463
|
title: "Set italic",
|
|
1394
1464
|
tooltip: "toolbar.italic",
|
|
1395
|
-
positions: [
|
|
1396
|
-
activated$: new
|
|
1397
|
-
const
|
|
1398
|
-
var
|
|
1399
|
-
const
|
|
1400
|
-
if (
|
|
1401
|
-
const
|
|
1402
|
-
if (
|
|
1465
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1466
|
+
activated$: new Observable((subscriber) => {
|
|
1467
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1468
|
+
var _a19;
|
|
1469
|
+
const id = c.id;
|
|
1470
|
+
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1471
|
+
const textRun = getFontStyleAtCursor(accessor);
|
|
1472
|
+
if (textRun == null)
|
|
1403
1473
|
return;
|
|
1404
|
-
const
|
|
1405
|
-
|
|
1474
|
+
const it = (_a19 = textRun.ts) == null ? void 0 : _a19.it;
|
|
1475
|
+
subscriber.next(it === BooleanNumber.TRUE);
|
|
1406
1476
|
}
|
|
1407
1477
|
});
|
|
1408
|
-
return
|
|
1478
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1409
1479
|
}),
|
|
1410
|
-
hidden$:
|
|
1480
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1411
1481
|
};
|
|
1412
1482
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1483
|
+
__name(ItalicMenuItemFactory, "ItalicMenuItemFactory");
|
|
1484
|
+
function UnderlineMenuItemFactory(accessor) {
|
|
1485
|
+
const commandService = accessor.get(ICommandService);
|
|
1415
1486
|
return {
|
|
1416
|
-
id:
|
|
1417
|
-
group:
|
|
1418
|
-
type:
|
|
1487
|
+
id: SetInlineFormatUnderlineCommand.id,
|
|
1488
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1489
|
+
type: MenuItemType.BUTTON,
|
|
1419
1490
|
icon: "UnderlineSingle",
|
|
1420
1491
|
title: "Set underline",
|
|
1421
1492
|
tooltip: "toolbar.underline",
|
|
1422
|
-
positions: [
|
|
1423
|
-
activated$: new
|
|
1424
|
-
const
|
|
1425
|
-
var
|
|
1426
|
-
const
|
|
1427
|
-
if (
|
|
1428
|
-
const
|
|
1429
|
-
if (
|
|
1493
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1494
|
+
activated$: new Observable((subscriber) => {
|
|
1495
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1496
|
+
var _a19;
|
|
1497
|
+
const id = c.id;
|
|
1498
|
+
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1499
|
+
const textRun = getFontStyleAtCursor(accessor);
|
|
1500
|
+
if (textRun == null)
|
|
1430
1501
|
return;
|
|
1431
|
-
const
|
|
1432
|
-
|
|
1502
|
+
const ul = (_a19 = textRun.ts) == null ? void 0 : _a19.ul;
|
|
1503
|
+
subscriber.next((ul == null ? void 0 : ul.s) === BooleanNumber.TRUE);
|
|
1433
1504
|
}
|
|
1434
1505
|
});
|
|
1435
|
-
return
|
|
1506
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1436
1507
|
}),
|
|
1437
|
-
hidden$:
|
|
1508
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1438
1509
|
};
|
|
1439
1510
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1511
|
+
__name(UnderlineMenuItemFactory, "UnderlineMenuItemFactory");
|
|
1512
|
+
function StrikeThroughMenuItemFactory(accessor) {
|
|
1513
|
+
const commandService = accessor.get(ICommandService);
|
|
1442
1514
|
return {
|
|
1443
|
-
id:
|
|
1444
|
-
group:
|
|
1445
|
-
type:
|
|
1515
|
+
id: SetInlineFormatStrikethroughCommand.id,
|
|
1516
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1517
|
+
type: MenuItemType.BUTTON,
|
|
1446
1518
|
icon: "StrikethroughSingle",
|
|
1447
1519
|
title: "Set strike through",
|
|
1448
1520
|
tooltip: "toolbar.strikethrough",
|
|
1449
|
-
positions: [
|
|
1450
|
-
activated$: new
|
|
1451
|
-
const
|
|
1452
|
-
var
|
|
1453
|
-
const
|
|
1454
|
-
if (
|
|
1455
|
-
const
|
|
1456
|
-
if (
|
|
1521
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1522
|
+
activated$: new Observable((subscriber) => {
|
|
1523
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1524
|
+
var _a19;
|
|
1525
|
+
const id = c.id;
|
|
1526
|
+
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1527
|
+
const textRun = getFontStyleAtCursor(accessor);
|
|
1528
|
+
if (textRun == null)
|
|
1457
1529
|
return;
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1530
|
+
const st = (_a19 = textRun.ts) == null ? void 0 : _a19.st;
|
|
1531
|
+
subscriber.next((st == null ? void 0 : st.s) === BooleanNumber.TRUE);
|
|
1460
1532
|
}
|
|
1461
1533
|
});
|
|
1462
|
-
return
|
|
1534
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1463
1535
|
}),
|
|
1464
|
-
hidden$:
|
|
1536
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1465
1537
|
};
|
|
1466
1538
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1539
|
+
__name(StrikeThroughMenuItemFactory, "StrikeThroughMenuItemFactory");
|
|
1540
|
+
function SubscriptMenuItemFactory(accessor) {
|
|
1541
|
+
const commandService = accessor.get(ICommandService);
|
|
1469
1542
|
return {
|
|
1470
|
-
id:
|
|
1471
|
-
group:
|
|
1472
|
-
type:
|
|
1543
|
+
id: SetInlineFormatSubscriptCommand.id,
|
|
1544
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1545
|
+
type: MenuItemType.BUTTON,
|
|
1473
1546
|
icon: "SubscriptSingle",
|
|
1474
1547
|
tooltip: "toolbar.subscript",
|
|
1475
|
-
positions: [
|
|
1476
|
-
activated$: new
|
|
1477
|
-
const
|
|
1478
|
-
var
|
|
1479
|
-
const
|
|
1480
|
-
if (
|
|
1481
|
-
const
|
|
1482
|
-
if (
|
|
1548
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1549
|
+
activated$: new Observable((subscriber) => {
|
|
1550
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1551
|
+
var _a19;
|
|
1552
|
+
const id = c.id;
|
|
1553
|
+
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1554
|
+
const textRun = getFontStyleAtCursor(accessor);
|
|
1555
|
+
if (textRun == null)
|
|
1483
1556
|
return;
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1557
|
+
const va = (_a19 = textRun.ts) == null ? void 0 : _a19.va;
|
|
1558
|
+
subscriber.next(va === BaselineOffset.SUBSCRIPT);
|
|
1486
1559
|
}
|
|
1487
1560
|
});
|
|
1488
|
-
return
|
|
1561
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1489
1562
|
}),
|
|
1490
|
-
hidden$:
|
|
1563
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1491
1564
|
};
|
|
1492
1565
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1566
|
+
__name(SubscriptMenuItemFactory, "SubscriptMenuItemFactory");
|
|
1567
|
+
function SuperscriptMenuItemFactory(accessor) {
|
|
1568
|
+
const commandService = accessor.get(ICommandService);
|
|
1495
1569
|
return {
|
|
1496
|
-
id:
|
|
1497
|
-
group:
|
|
1498
|
-
type:
|
|
1570
|
+
id: SetInlineFormatSuperscriptCommand.id,
|
|
1571
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1572
|
+
type: MenuItemType.BUTTON,
|
|
1499
1573
|
icon: "SuperscriptSingle",
|
|
1500
1574
|
tooltip: "toolbar.superscript",
|
|
1501
|
-
positions: [
|
|
1502
|
-
activated$: new
|
|
1503
|
-
const
|
|
1504
|
-
var
|
|
1505
|
-
const
|
|
1506
|
-
if (
|
|
1507
|
-
const
|
|
1508
|
-
if (
|
|
1575
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1576
|
+
activated$: new Observable((subscriber) => {
|
|
1577
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1578
|
+
var _a19;
|
|
1579
|
+
const id = c.id;
|
|
1580
|
+
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1581
|
+
const textRun = getFontStyleAtCursor(accessor);
|
|
1582
|
+
if (textRun == null)
|
|
1509
1583
|
return;
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1584
|
+
const va = (_a19 = textRun.ts) == null ? void 0 : _a19.va;
|
|
1585
|
+
subscriber.next(va === BaselineOffset.SUPERSCRIPT);
|
|
1512
1586
|
}
|
|
1513
1587
|
});
|
|
1514
|
-
return
|
|
1588
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1515
1589
|
}),
|
|
1516
|
-
hidden$:
|
|
1590
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1517
1591
|
};
|
|
1518
1592
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1593
|
+
__name(SuperscriptMenuItemFactory, "SuperscriptMenuItemFactory");
|
|
1594
|
+
function FontFamilySelectorMenuItemFactory(accessor) {
|
|
1595
|
+
const commandService = accessor.get(ICommandService);
|
|
1521
1596
|
return {
|
|
1522
|
-
id:
|
|
1597
|
+
id: SetInlineFormatFontFamilyCommand.id,
|
|
1523
1598
|
tooltip: "toolbar.font",
|
|
1524
|
-
group:
|
|
1525
|
-
type:
|
|
1526
|
-
label:
|
|
1527
|
-
positions: [
|
|
1528
|
-
selections:
|
|
1599
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1600
|
+
type: MenuItemType.SELECTOR,
|
|
1601
|
+
label: FONT_FAMILY_COMPONENT,
|
|
1602
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1603
|
+
selections: FONT_FAMILY_LIST.map((item) => ({
|
|
1529
1604
|
label: {
|
|
1530
|
-
name:
|
|
1605
|
+
name: FONT_FAMILY_ITEM_COMPONENT,
|
|
1531
1606
|
hoverable: !0
|
|
1532
1607
|
},
|
|
1533
|
-
value:
|
|
1608
|
+
value: item.value
|
|
1534
1609
|
})),
|
|
1535
1610
|
// disabled$: getCurrentSheetDisabled$(accessor),
|
|
1536
|
-
value$: new
|
|
1537
|
-
const
|
|
1538
|
-
var
|
|
1539
|
-
const
|
|
1540
|
-
if (
|
|
1541
|
-
const
|
|
1542
|
-
if (
|
|
1611
|
+
value$: new Observable((subscriber) => {
|
|
1612
|
+
const defaultValue = FONT_FAMILY_LIST[0].value, disposable = commandService.onCommandExecuted((c) => {
|
|
1613
|
+
var _a19;
|
|
1614
|
+
const id = c.id;
|
|
1615
|
+
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatFontFamilyCommand.id) {
|
|
1616
|
+
const textRun = getFontStyleAtCursor(accessor);
|
|
1617
|
+
if (textRun == null)
|
|
1543
1618
|
return;
|
|
1544
|
-
const
|
|
1545
|
-
|
|
1619
|
+
const ff = (_a19 = textRun.ts) == null ? void 0 : _a19.ff;
|
|
1620
|
+
subscriber.next(ff != null ? ff : defaultValue);
|
|
1546
1621
|
}
|
|
1547
1622
|
});
|
|
1548
|
-
return
|
|
1623
|
+
return subscriber.next(defaultValue), disposable.dispose;
|
|
1549
1624
|
}),
|
|
1550
|
-
hidden$:
|
|
1625
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1551
1626
|
};
|
|
1552
1627
|
}
|
|
1553
|
-
|
|
1554
|
-
|
|
1628
|
+
__name(FontFamilySelectorMenuItemFactory, "FontFamilySelectorMenuItemFactory");
|
|
1629
|
+
function FontSizeSelectorMenuItemFactory(accessor) {
|
|
1630
|
+
const commandService = accessor.get(ICommandService);
|
|
1555
1631
|
return {
|
|
1556
|
-
id:
|
|
1557
|
-
group:
|
|
1558
|
-
type:
|
|
1632
|
+
id: SetInlineFormatFontSizeCommand.id,
|
|
1633
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1634
|
+
type: MenuItemType.SELECTOR,
|
|
1559
1635
|
tooltip: "toolbar.fontSize",
|
|
1560
1636
|
label: {
|
|
1561
|
-
name:
|
|
1637
|
+
name: FONT_SIZE_COMPONENT,
|
|
1562
1638
|
props: {
|
|
1563
1639
|
min: 1,
|
|
1564
1640
|
max: 400
|
|
1565
1641
|
// disabled$,
|
|
1566
1642
|
}
|
|
1567
1643
|
},
|
|
1568
|
-
positions: [
|
|
1569
|
-
selections:
|
|
1644
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1645
|
+
selections: FONT_SIZE_LIST,
|
|
1570
1646
|
// disabled$,
|
|
1571
|
-
value$: new
|
|
1572
|
-
const
|
|
1573
|
-
var
|
|
1574
|
-
const
|
|
1575
|
-
if (
|
|
1576
|
-
const
|
|
1577
|
-
if (
|
|
1647
|
+
value$: new Observable((subscriber) => {
|
|
1648
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1649
|
+
var _a19;
|
|
1650
|
+
const id = c.id;
|
|
1651
|
+
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatFontSizeCommand.id) {
|
|
1652
|
+
const textRun = getFontStyleAtCursor(accessor);
|
|
1653
|
+
if (textRun == null)
|
|
1578
1654
|
return;
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1655
|
+
const fs = (_a19 = textRun.ts) == null ? void 0 : _a19.fs;
|
|
1656
|
+
subscriber.next(fs != null ? fs : 14);
|
|
1581
1657
|
}
|
|
1582
1658
|
});
|
|
1583
|
-
return
|
|
1659
|
+
return subscriber.next(14), disposable.dispose;
|
|
1584
1660
|
}),
|
|
1585
|
-
hidden$:
|
|
1661
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1586
1662
|
};
|
|
1587
1663
|
}
|
|
1588
|
-
|
|
1589
|
-
|
|
1664
|
+
__name(FontSizeSelectorMenuItemFactory, "FontSizeSelectorMenuItemFactory");
|
|
1665
|
+
function TextColorSelectorMenuItemFactory(accessor) {
|
|
1666
|
+
const commandService = accessor.get(ICommandService), themeService = accessor.get(ThemeService);
|
|
1590
1667
|
return {
|
|
1591
|
-
id:
|
|
1668
|
+
id: SetInlineFormatTextColorCommand.id,
|
|
1592
1669
|
icon: "FontColor",
|
|
1593
1670
|
tooltip: "toolbar.textColor.main",
|
|
1594
|
-
group:
|
|
1595
|
-
type:
|
|
1596
|
-
positions: [
|
|
1671
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1672
|
+
type: MenuItemType.BUTTON_SELECTOR,
|
|
1673
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1597
1674
|
selections: [
|
|
1598
1675
|
{
|
|
1599
1676
|
label: {
|
|
1600
|
-
name:
|
|
1677
|
+
name: COLOR_PICKER_COMPONENT,
|
|
1601
1678
|
hoverable: !1
|
|
1602
1679
|
}
|
|
1603
1680
|
}
|
|
1604
1681
|
],
|
|
1605
|
-
value$: new
|
|
1606
|
-
const
|
|
1607
|
-
if (
|
|
1608
|
-
const
|
|
1609
|
-
|
|
1682
|
+
value$: new Observable((subscriber) => {
|
|
1683
|
+
const defaultColor = themeService.getCurrentTheme().textColor, disposable = commandService.onCommandExecuted((c) => {
|
|
1684
|
+
if (c.id === SetInlineFormatTextColorCommand.id) {
|
|
1685
|
+
const color = c.params.value;
|
|
1686
|
+
subscriber.next(color != null ? color : defaultColor);
|
|
1610
1687
|
}
|
|
1611
1688
|
});
|
|
1612
|
-
return
|
|
1689
|
+
return subscriber.next(defaultColor), disposable.dispose;
|
|
1613
1690
|
}),
|
|
1614
|
-
hidden$:
|
|
1691
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1615
1692
|
// disabled$: getCurrentSheetDisabled$(accessor),
|
|
1616
1693
|
};
|
|
1617
1694
|
}
|
|
1618
|
-
|
|
1695
|
+
__name(TextColorSelectorMenuItemFactory, "TextColorSelectorMenuItemFactory");
|
|
1696
|
+
function HeaderFooterMenuItemFactory(accessor) {
|
|
1619
1697
|
return {
|
|
1620
|
-
id:
|
|
1621
|
-
group:
|
|
1622
|
-
type:
|
|
1698
|
+
id: OpenHeaderFooterPanelCommand.id,
|
|
1699
|
+
group: MenuGroup.TOOLBAR_OTHERS,
|
|
1700
|
+
type: MenuItemType.BUTTON,
|
|
1623
1701
|
icon: "FreezeRowSingle",
|
|
1624
1702
|
tooltip: "toolbar.headerFooter",
|
|
1625
|
-
positions: [
|
|
1626
|
-
hidden$:
|
|
1703
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1704
|
+
hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getHeaderFooterMenuHiddenObservable(accessor), (one, two) => one || two)
|
|
1627
1705
|
};
|
|
1628
1706
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1707
|
+
__name(HeaderFooterMenuItemFactory, "HeaderFooterMenuItemFactory");
|
|
1708
|
+
function AlignLeftMenuItemFactory(accessor) {
|
|
1709
|
+
const commandService = accessor.get(ICommandService);
|
|
1631
1710
|
return {
|
|
1632
|
-
id:
|
|
1633
|
-
group:
|
|
1634
|
-
type:
|
|
1711
|
+
id: AlignLeftCommand.id,
|
|
1712
|
+
group: MenuGroup.TOOLBAR_LAYOUT,
|
|
1713
|
+
type: MenuItemType.BUTTON,
|
|
1635
1714
|
icon: "LeftJustifyingSingle",
|
|
1636
1715
|
tooltip: "toolbar.alignLeft",
|
|
1637
|
-
positions: [
|
|
1638
|
-
activated$: new
|
|
1639
|
-
const
|
|
1640
|
-
var
|
|
1641
|
-
const
|
|
1642
|
-
if (
|
|
1643
|
-
const
|
|
1644
|
-
if (
|
|
1716
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1717
|
+
activated$: new Observable((subscriber) => {
|
|
1718
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1719
|
+
var _a19;
|
|
1720
|
+
const id = c.id;
|
|
1721
|
+
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
1722
|
+
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
1723
|
+
if (paragraph == null)
|
|
1645
1724
|
return;
|
|
1646
|
-
const
|
|
1647
|
-
|
|
1725
|
+
const alignType = (_a19 = paragraph.paragraphStyle) == null ? void 0 : _a19.horizontalAlign;
|
|
1726
|
+
subscriber.next(alignType === HorizontalAlign.LEFT);
|
|
1648
1727
|
}
|
|
1649
1728
|
});
|
|
1650
|
-
return
|
|
1729
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1651
1730
|
}),
|
|
1652
|
-
hidden$:
|
|
1731
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1653
1732
|
};
|
|
1654
1733
|
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1734
|
+
__name(AlignLeftMenuItemFactory, "AlignLeftMenuItemFactory");
|
|
1735
|
+
function AlignCenterMenuItemFactory(accessor) {
|
|
1736
|
+
const commandService = accessor.get(ICommandService);
|
|
1657
1737
|
return {
|
|
1658
|
-
id:
|
|
1659
|
-
group:
|
|
1660
|
-
type:
|
|
1738
|
+
id: AlignCenterCommand.id,
|
|
1739
|
+
group: MenuGroup.TOOLBAR_LAYOUT,
|
|
1740
|
+
type: MenuItemType.BUTTON,
|
|
1661
1741
|
icon: "HorizontallySingle",
|
|
1662
1742
|
tooltip: "toolbar.alignCenter",
|
|
1663
|
-
positions: [
|
|
1664
|
-
activated$: new
|
|
1665
|
-
const
|
|
1666
|
-
var
|
|
1667
|
-
const
|
|
1668
|
-
if (
|
|
1669
|
-
const
|
|
1670
|
-
if (
|
|
1743
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1744
|
+
activated$: new Observable((subscriber) => {
|
|
1745
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1746
|
+
var _a19;
|
|
1747
|
+
const id = c.id;
|
|
1748
|
+
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
1749
|
+
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
1750
|
+
if (paragraph == null)
|
|
1671
1751
|
return;
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1752
|
+
const alignType = (_a19 = paragraph.paragraphStyle) == null ? void 0 : _a19.horizontalAlign;
|
|
1753
|
+
subscriber.next(alignType === HorizontalAlign.CENTER);
|
|
1674
1754
|
}
|
|
1675
1755
|
});
|
|
1676
|
-
return
|
|
1756
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1677
1757
|
}),
|
|
1678
|
-
hidden$:
|
|
1758
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1679
1759
|
};
|
|
1680
1760
|
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1761
|
+
__name(AlignCenterMenuItemFactory, "AlignCenterMenuItemFactory");
|
|
1762
|
+
function AlignRightMenuItemFactory(accessor) {
|
|
1763
|
+
const commandService = accessor.get(ICommandService);
|
|
1683
1764
|
return {
|
|
1684
|
-
id:
|
|
1685
|
-
group:
|
|
1686
|
-
type:
|
|
1765
|
+
id: AlignRightCommand.id,
|
|
1766
|
+
group: MenuGroup.TOOLBAR_LAYOUT,
|
|
1767
|
+
type: MenuItemType.BUTTON,
|
|
1687
1768
|
icon: "RightJustifyingSingle",
|
|
1688
1769
|
tooltip: "toolbar.alignRight",
|
|
1689
|
-
positions: [
|
|
1690
|
-
activated$: new
|
|
1691
|
-
const
|
|
1692
|
-
var
|
|
1693
|
-
const
|
|
1694
|
-
if (
|
|
1695
|
-
const
|
|
1696
|
-
if (
|
|
1770
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1771
|
+
activated$: new Observable((subscriber) => {
|
|
1772
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1773
|
+
var _a19;
|
|
1774
|
+
const id = c.id;
|
|
1775
|
+
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
1776
|
+
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
1777
|
+
if (paragraph == null)
|
|
1697
1778
|
return;
|
|
1698
|
-
const
|
|
1699
|
-
|
|
1779
|
+
const alignType = (_a19 = paragraph.paragraphStyle) == null ? void 0 : _a19.horizontalAlign;
|
|
1780
|
+
subscriber.next(alignType === HorizontalAlign.RIGHT);
|
|
1700
1781
|
}
|
|
1701
1782
|
});
|
|
1702
|
-
return
|
|
1783
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1703
1784
|
}),
|
|
1704
|
-
hidden$:
|
|
1785
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1705
1786
|
};
|
|
1706
1787
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1788
|
+
__name(AlignRightMenuItemFactory, "AlignRightMenuItemFactory");
|
|
1789
|
+
function AlignJustifyMenuItemFactory(accessor) {
|
|
1790
|
+
const commandService = accessor.get(ICommandService);
|
|
1709
1791
|
return {
|
|
1710
|
-
id:
|
|
1711
|
-
group:
|
|
1712
|
-
type:
|
|
1792
|
+
id: AlignJustifyCommand.id,
|
|
1793
|
+
group: MenuGroup.TOOLBAR_LAYOUT,
|
|
1794
|
+
type: MenuItemType.BUTTON,
|
|
1713
1795
|
icon: "AlignTextBothSingle",
|
|
1714
1796
|
tooltip: "toolbar.alignJustify",
|
|
1715
|
-
positions: [
|
|
1716
|
-
activated$: new
|
|
1717
|
-
const
|
|
1718
|
-
var
|
|
1719
|
-
const
|
|
1720
|
-
if (
|
|
1721
|
-
const
|
|
1722
|
-
if (
|
|
1797
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1798
|
+
activated$: new Observable((subscriber) => {
|
|
1799
|
+
const disposable = commandService.onCommandExecuted((c) => {
|
|
1800
|
+
var _a19;
|
|
1801
|
+
const id = c.id;
|
|
1802
|
+
if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
1803
|
+
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
1804
|
+
if (paragraph == null)
|
|
1723
1805
|
return;
|
|
1724
|
-
const
|
|
1725
|
-
|
|
1806
|
+
const alignType = (_a19 = paragraph.paragraphStyle) == null ? void 0 : _a19.horizontalAlign;
|
|
1807
|
+
subscriber.next(alignType === HorizontalAlign.JUSTIFIED);
|
|
1726
1808
|
}
|
|
1727
1809
|
});
|
|
1728
|
-
return
|
|
1810
|
+
return subscriber.next(!1), disposable.dispose;
|
|
1729
1811
|
}),
|
|
1730
|
-
hidden$:
|
|
1812
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1731
1813
|
};
|
|
1732
1814
|
}
|
|
1733
|
-
|
|
1815
|
+
__name(AlignJustifyMenuItemFactory, "AlignJustifyMenuItemFactory");
|
|
1816
|
+
function OrderListMenuItemFactory(accessor) {
|
|
1734
1817
|
return {
|
|
1735
|
-
id:
|
|
1736
|
-
group:
|
|
1737
|
-
type:
|
|
1818
|
+
id: OrderListCommand.id,
|
|
1819
|
+
group: MenuGroup.TOOLBAR_LAYOUT,
|
|
1820
|
+
type: MenuItemType.BUTTON,
|
|
1738
1821
|
icon: "OrderSingle",
|
|
1739
1822
|
tooltip: "toolbar.order",
|
|
1740
|
-
positions: [
|
|
1741
|
-
hidden$:
|
|
1823
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1824
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1742
1825
|
};
|
|
1743
1826
|
}
|
|
1744
|
-
|
|
1827
|
+
__name(OrderListMenuItemFactory, "OrderListMenuItemFactory");
|
|
1828
|
+
function BulletListMenuItemFactory(accessor) {
|
|
1745
1829
|
return {
|
|
1746
|
-
id:
|
|
1747
|
-
group:
|
|
1748
|
-
type:
|
|
1830
|
+
id: BulletListCommand.id,
|
|
1831
|
+
group: MenuGroup.TOOLBAR_LAYOUT,
|
|
1832
|
+
type: MenuItemType.BUTTON,
|
|
1749
1833
|
icon: "UnorderSingle",
|
|
1750
1834
|
tooltip: "toolbar.unorder",
|
|
1751
|
-
positions: [
|
|
1752
|
-
hidden$:
|
|
1835
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1836
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1753
1837
|
};
|
|
1754
1838
|
}
|
|
1755
|
-
|
|
1839
|
+
__name(BulletListMenuItemFactory, "BulletListMenuItemFactory");
|
|
1840
|
+
function ResetBackgroundColorMenuItemFactory(accessor) {
|
|
1756
1841
|
return {
|
|
1757
|
-
id:
|
|
1758
|
-
type:
|
|
1842
|
+
id: ResetInlineFormatTextBackgroundColorCommand.id,
|
|
1843
|
+
type: MenuItemType.BUTTON,
|
|
1759
1844
|
title: "toolbar.resetColor",
|
|
1760
1845
|
icon: "NoColor",
|
|
1761
|
-
positions:
|
|
1846
|
+
positions: SetInlineFormatTextBackgroundColorCommand.id
|
|
1762
1847
|
};
|
|
1763
1848
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1849
|
+
__name(ResetBackgroundColorMenuItemFactory, "ResetBackgroundColorMenuItemFactory");
|
|
1850
|
+
function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
1851
|
+
const commandService = accessor.get(ICommandService), themeService = accessor.get(ThemeService);
|
|
1766
1852
|
return {
|
|
1767
|
-
id:
|
|
1853
|
+
id: SetInlineFormatTextBackgroundColorCommand.id,
|
|
1768
1854
|
tooltip: "toolbar.fillColor.main",
|
|
1769
|
-
group:
|
|
1770
|
-
type:
|
|
1771
|
-
positions: [
|
|
1855
|
+
group: MenuGroup.TOOLBAR_FORMAT,
|
|
1856
|
+
type: MenuItemType.BUTTON_SELECTOR,
|
|
1857
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1772
1858
|
icon: "PaintBucket",
|
|
1773
1859
|
selections: [
|
|
1774
1860
|
{
|
|
1775
1861
|
label: {
|
|
1776
|
-
name:
|
|
1862
|
+
name: COLOR_PICKER_COMPONENT,
|
|
1777
1863
|
hoverable: !1
|
|
1778
1864
|
}
|
|
1779
1865
|
}
|
|
1780
1866
|
],
|
|
1781
|
-
value$: new
|
|
1782
|
-
const
|
|
1783
|
-
if (
|
|
1784
|
-
const
|
|
1785
|
-
|
|
1867
|
+
value$: new Observable((subscriber) => {
|
|
1868
|
+
const defaultColor = themeService.getCurrentTheme().primaryColor, disposable = commandService.onCommandExecuted((c) => {
|
|
1869
|
+
if (c.id === SetInlineFormatTextBackgroundColorCommand.id) {
|
|
1870
|
+
const color = c.params.value;
|
|
1871
|
+
subscriber.next(color != null ? color : defaultColor);
|
|
1786
1872
|
}
|
|
1787
1873
|
});
|
|
1788
|
-
return
|
|
1874
|
+
return subscriber.next(defaultColor), disposable.dispose;
|
|
1789
1875
|
}),
|
|
1790
|
-
hidden$:
|
|
1876
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1791
1877
|
};
|
|
1792
1878
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1879
|
+
__name(BackgroundColorSelectorMenuItemFactory, "BackgroundColorSelectorMenuItemFactory");
|
|
1880
|
+
function getFontStyleAtCursor(accessor) {
|
|
1881
|
+
var _a19;
|
|
1882
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(TextSelectionManagerService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveRange();
|
|
1883
|
+
if (docDataModel == null || activeTextRange == null)
|
|
1797
1884
|
return;
|
|
1798
|
-
const { startOffset
|
|
1799
|
-
if (
|
|
1885
|
+
const { startOffset, segmentId } = activeTextRange, textRuns = (_a19 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a19.textRuns;
|
|
1886
|
+
if (textRuns == null)
|
|
1800
1887
|
return;
|
|
1801
|
-
let
|
|
1802
|
-
for (let
|
|
1803
|
-
const
|
|
1804
|
-
if (
|
|
1805
|
-
|
|
1888
|
+
let textRun;
|
|
1889
|
+
for (let i = 0; i < textRuns.length; i++) {
|
|
1890
|
+
const curTextRun = textRuns[i], nextTextRun = textRuns[i + 1];
|
|
1891
|
+
if (nextTextRun && nextTextRun.st === nextTextRun.ed && startOffset === nextTextRun.st) {
|
|
1892
|
+
textRun = nextTextRun;
|
|
1806
1893
|
break;
|
|
1807
1894
|
}
|
|
1808
|
-
if (
|
|
1809
|
-
|
|
1895
|
+
if (curTextRun.st <= startOffset && startOffset <= curTextRun.ed) {
|
|
1896
|
+
textRun = curTextRun;
|
|
1810
1897
|
break;
|
|
1811
1898
|
}
|
|
1812
1899
|
}
|
|
1813
|
-
return
|
|
1900
|
+
return textRun;
|
|
1814
1901
|
}
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1902
|
+
__name(getFontStyleAtCursor, "getFontStyleAtCursor");
|
|
1903
|
+
function getParagraphStyleAtCursor(accessor) {
|
|
1904
|
+
var _a19;
|
|
1905
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(TextSelectionManagerService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveRange();
|
|
1906
|
+
if (docDataModel == null || activeTextRange == null)
|
|
1819
1907
|
return;
|
|
1820
|
-
const { startOffset
|
|
1821
|
-
if (
|
|
1908
|
+
const { startOffset, segmentId } = activeTextRange, paragraphs = (_a19 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a19.paragraphs;
|
|
1909
|
+
if (paragraphs == null)
|
|
1822
1910
|
return;
|
|
1823
|
-
let
|
|
1824
|
-
for (const
|
|
1825
|
-
const { startIndex
|
|
1826
|
-
if (
|
|
1827
|
-
return
|
|
1828
|
-
|
|
1911
|
+
let prevIndex = -1;
|
|
1912
|
+
for (const paragraph of paragraphs) {
|
|
1913
|
+
const { startIndex } = paragraph;
|
|
1914
|
+
if (startOffset > prevIndex && startOffset <= startIndex)
|
|
1915
|
+
return paragraph;
|
|
1916
|
+
prevIndex = startIndex;
|
|
1829
1917
|
}
|
|
1830
1918
|
return null;
|
|
1831
1919
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1920
|
+
__name(getParagraphStyleAtCursor, "getParagraphStyleAtCursor");
|
|
1921
|
+
function whenDocOrEditor(contextService) {
|
|
1922
|
+
return contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED);
|
|
1923
|
+
}
|
|
1924
|
+
__name(whenDocOrEditor, "whenDocOrEditor");
|
|
1925
|
+
const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
1926
|
+
id: CopyCommand.id,
|
|
1927
|
+
name: "doc.command.copy",
|
|
1928
|
+
type: CommandType.COMMAND,
|
|
1929
|
+
multi: !0,
|
|
1930
|
+
priority: DOC_CLIPBOARD_PRIORITY,
|
|
1931
|
+
preconditions: whenDocOrEditor,
|
|
1932
|
+
handler: /* @__PURE__ */ __name(async (accessor) => accessor.get(IDocClipboardService).copy(), "handler")
|
|
1933
|
+
}, DocCutCommand = {
|
|
1934
|
+
id: CutCommand.id,
|
|
1935
|
+
name: "doc.command.cut",
|
|
1936
|
+
type: CommandType.COMMAND,
|
|
1937
|
+
multi: !0,
|
|
1938
|
+
priority: DOC_CLIPBOARD_PRIORITY,
|
|
1939
|
+
preconditions: whenDocOrEditor,
|
|
1940
|
+
handler: /* @__PURE__ */ __name(async (accessor) => accessor.get(IDocClipboardService).cut(), "handler")
|
|
1941
|
+
}, DocPasteCommand = {
|
|
1942
|
+
id: PasteCommand.id,
|
|
1943
|
+
name: "doc.command.paste",
|
|
1944
|
+
type: CommandType.COMMAND,
|
|
1945
|
+
multi: !0,
|
|
1946
|
+
priority: DOC_CLIPBOARD_PRIORITY,
|
|
1947
|
+
preconditions: whenDocOrEditor,
|
|
1948
|
+
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
1949
|
+
const docClipboardService = accessor.get(IDocClipboardService), clipboardItems = await accessor.get(IClipboardInterfaceService).read();
|
|
1950
|
+
return clipboardItems.length === 0 ? !1 : docClipboardService.paste(clipboardItems);
|
|
1951
|
+
}, "handler")
|
|
1952
|
+
}, getDisableOnCollapsedObservable = /* @__PURE__ */ __name((accessor) => {
|
|
1953
|
+
const textSelectionManagerService = accessor.get(TextSelectionManagerService);
|
|
1954
|
+
return new Observable((subscriber) => {
|
|
1955
|
+
const observable = textSelectionManagerService.textSelection$.subscribe((selections) => {
|
|
1956
|
+
const range = textSelectionManagerService.getActiveRange();
|
|
1957
|
+
range && !range.collapsed ? subscriber.next(!1) : subscriber.next(!0);
|
|
1958
|
+
});
|
|
1959
|
+
return () => observable.unsubscribe();
|
|
1960
|
+
});
|
|
1961
|
+
}, "getDisableOnCollapsedObservable"), CopyMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1962
|
+
id: DocCopyCommand.id,
|
|
1963
|
+
group: MenuGroup.CONTEXT_MENU_FORMAT,
|
|
1964
|
+
type: MenuItemType.BUTTON,
|
|
1965
|
+
icon: "Copy",
|
|
1966
|
+
title: "rightClick.copy",
|
|
1967
|
+
positions: [MenuPosition.CONTEXT_MENU],
|
|
1968
|
+
disabled$: getDisableOnCollapsedObservable(accessor),
|
|
1969
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1970
|
+
}), "CopyMenuFactory"), CutMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1971
|
+
id: DocCutCommand.id,
|
|
1972
|
+
group: MenuGroup.CONTEXT_MENU_FORMAT,
|
|
1973
|
+
type: MenuItemType.BUTTON,
|
|
1974
|
+
icon: "Copy",
|
|
1975
|
+
title: "rightClick.cut",
|
|
1976
|
+
positions: [MenuPosition.CONTEXT_MENU],
|
|
1977
|
+
disabled$: getDisableOnCollapsedObservable(accessor),
|
|
1978
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1979
|
+
}), "CutMenuFactory"), PasteMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1980
|
+
id: DocPasteCommand.id,
|
|
1981
|
+
group: MenuGroup.CONTEXT_MENU_FORMAT,
|
|
1982
|
+
type: MenuItemType.BUTTON,
|
|
1983
|
+
icon: "PasteSpecial",
|
|
1984
|
+
title: "rightClick.paste",
|
|
1985
|
+
positions: [MenuPosition.CONTEXT_MENU],
|
|
1986
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1987
|
+
}), "PasteMenuFactory"), DeleteMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1988
|
+
id: DeleteLeftCommand.id,
|
|
1989
|
+
group: MenuGroup.CONTEXT_MENU_FORMAT,
|
|
1990
|
+
type: MenuItemType.BUTTON,
|
|
1991
|
+
icon: "PasteSpecial",
|
|
1992
|
+
title: "rightClick.delete",
|
|
1993
|
+
positions: [MenuPosition.CONTEXT_MENU],
|
|
1994
|
+
disabled$: getDisableOnCollapsedObservable(accessor),
|
|
1995
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
1996
|
+
}), "DeleteMenuFactory"), BoldShortCut = {
|
|
1997
|
+
id: SetInlineFormatBoldCommand.id,
|
|
1998
|
+
binding: KeyCode.B | MetaKeys.CTRL_COMMAND,
|
|
1999
|
+
preconditions: whenDocAndEditorFocused
|
|
2000
|
+
}, ItalicShortCut = {
|
|
2001
|
+
id: SetInlineFormatItalicCommand.id,
|
|
2002
|
+
binding: KeyCode.I | MetaKeys.CTRL_COMMAND,
|
|
2003
|
+
preconditions: whenDocAndEditorFocused
|
|
2004
|
+
}, UnderlineShortCut = {
|
|
2005
|
+
id: SetInlineFormatUnderlineCommand.id,
|
|
2006
|
+
binding: KeyCode.U | MetaKeys.CTRL_COMMAND,
|
|
2007
|
+
preconditions: whenDocAndEditorFocused
|
|
2008
|
+
}, StrikeThroughShortCut = {
|
|
2009
|
+
id: SetInlineFormatStrikethroughCommand.id,
|
|
2010
|
+
binding: KeyCode.X | MetaKeys.SHIFT | MetaKeys.CTRL_COMMAND,
|
|
2011
|
+
preconditions: whenDocAndEditorFocused
|
|
2012
|
+
}, SubscriptShortCut = {
|
|
2013
|
+
id: SetInlineFormatSubscriptCommand.id,
|
|
2014
|
+
binding: KeyCode.COMMA | MetaKeys.CTRL_COMMAND,
|
|
2015
|
+
preconditions: whenDocAndEditorFocused
|
|
2016
|
+
}, SuperscriptShortCut = {
|
|
2017
|
+
id: SetInlineFormatSuperscriptCommand.id,
|
|
2018
|
+
binding: KeyCode.PERIOD | MetaKeys.CTRL_COMMAND,
|
|
2019
|
+
preconditions: whenDocAndEditorFocused
|
|
2020
|
+
}, AlignLeftShortCut = {
|
|
2021
|
+
id: AlignLeftCommand.id,
|
|
2022
|
+
binding: KeyCode.L | MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT,
|
|
2023
|
+
preconditions: whenDocAndEditorFocused
|
|
2024
|
+
}, AlignRightShortCut = {
|
|
2025
|
+
id: AlignRightCommand.id,
|
|
2026
|
+
binding: KeyCode.R | MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT,
|
|
2027
|
+
preconditions: whenDocAndEditorFocused
|
|
2028
|
+
}, AlignCenterShortCut = {
|
|
2029
|
+
id: AlignCenterCommand.id,
|
|
2030
|
+
binding: KeyCode.E | MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT,
|
|
2031
|
+
preconditions: whenDocAndEditorFocused
|
|
2032
|
+
}, AlignJustifyShortCut = {
|
|
2033
|
+
id: AlignJustifyCommand.id,
|
|
2034
|
+
binding: KeyCode.J | MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT,
|
|
2035
|
+
preconditions: whenDocAndEditorFocused
|
|
2036
|
+
}, OrderListShortCut = {
|
|
2037
|
+
id: OrderListCommand.id,
|
|
2038
|
+
binding: KeyCode.Digit7 | MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT,
|
|
2039
|
+
preconditions: whenDocAndEditorFocused
|
|
2040
|
+
}, BulletListShortCut = {
|
|
2041
|
+
id: BulletListCommand.id,
|
|
2042
|
+
binding: KeyCode.Digit8 | MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT,
|
|
2043
|
+
preconditions: whenDocAndEditorFocused
|
|
2044
|
+
};
|
|
2045
|
+
var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2046
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2047
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2048
|
+
return kind && result && __defProp$c(target, key, result), result;
|
|
2049
|
+
}, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c"), _a6;
|
|
2050
|
+
let DocUIController = (_a6 = class extends Disposable {
|
|
2051
|
+
constructor(_config, _injector, _componentManager, _layoutService, _menuService, _uiPartsService, _univerInstanceService, _shortcutService) {
|
|
2052
|
+
super(), this._config = _config, this._injector = _injector, this._componentManager = _componentManager, this._layoutService = _layoutService, this._menuService = _menuService, this._uiPartsService = _uiPartsService, this._univerInstanceService = _univerInstanceService, this._shortcutService = _shortcutService, this._init();
|
|
1840
2053
|
}
|
|
1841
2054
|
_initCustomComponents() {
|
|
1842
|
-
const
|
|
1843
|
-
this.disposeWithMe(
|
|
2055
|
+
const componentManager = this._componentManager;
|
|
2056
|
+
this.disposeWithMe(componentManager.register(COLOR_PICKER_COMPONENT, ColorPicker)), this.disposeWithMe(componentManager.register(FONT_FAMILY_COMPONENT, FontFamily)), this.disposeWithMe(componentManager.register(FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem)), this.disposeWithMe(componentManager.register(FONT_SIZE_COMPONENT, FontSize));
|
|
2057
|
+
}
|
|
2058
|
+
_initUiParts() {
|
|
2059
|
+
var _a19, _b;
|
|
2060
|
+
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
2061
|
+
(_b = (_a19 = this._config.layout) == null ? void 0 : _a19.docContainerConfig) != null && _b.footer && !workbook && this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.FOOTER, () => connectInjector(DocFooter, this._injector)));
|
|
1844
2062
|
}
|
|
1845
2063
|
_initMenus() {
|
|
1846
|
-
const { menu
|
|
2064
|
+
const { menu = {} } = this._config;
|
|
2065
|
+
[
|
|
2066
|
+
BoldMenuItemFactory,
|
|
2067
|
+
ItalicMenuItemFactory,
|
|
2068
|
+
UnderlineMenuItemFactory,
|
|
2069
|
+
StrikeThroughMenuItemFactory,
|
|
2070
|
+
SubscriptMenuItemFactory,
|
|
2071
|
+
SuperscriptMenuItemFactory,
|
|
2072
|
+
FontSizeSelectorMenuItemFactory,
|
|
2073
|
+
FontFamilySelectorMenuItemFactory,
|
|
2074
|
+
TextColorSelectorMenuItemFactory,
|
|
2075
|
+
HeaderFooterMenuItemFactory,
|
|
2076
|
+
AlignLeftMenuItemFactory,
|
|
2077
|
+
AlignCenterMenuItemFactory,
|
|
2078
|
+
AlignRightMenuItemFactory,
|
|
2079
|
+
AlignJustifyMenuItemFactory,
|
|
2080
|
+
OrderListMenuItemFactory,
|
|
2081
|
+
BulletListMenuItemFactory,
|
|
2082
|
+
ResetBackgroundColorMenuItemFactory,
|
|
2083
|
+
BackgroundColorSelectorMenuItemFactory
|
|
2084
|
+
].forEach((factory) => {
|
|
2085
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory), menu));
|
|
2086
|
+
}), [
|
|
2087
|
+
CopyMenuFactory,
|
|
2088
|
+
CutMenuFactory,
|
|
2089
|
+
PasteMenuFactory,
|
|
2090
|
+
DeleteMenuFactory
|
|
2091
|
+
].forEach((factory) => {
|
|
2092
|
+
try {
|
|
2093
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory), menu));
|
|
2094
|
+
} catch {
|
|
2095
|
+
}
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
_initShortCut() {
|
|
1847
2099
|
[
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
qr,
|
|
1863
|
-
Qr,
|
|
1864
|
-
ei,
|
|
1865
|
-
ti
|
|
1866
|
-
].forEach((e) => {
|
|
1867
|
-
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), t));
|
|
2100
|
+
BoldShortCut,
|
|
2101
|
+
ItalicShortCut,
|
|
2102
|
+
UnderlineShortCut,
|
|
2103
|
+
StrikeThroughShortCut,
|
|
2104
|
+
SubscriptShortCut,
|
|
2105
|
+
SuperscriptShortCut,
|
|
2106
|
+
AlignCenterShortCut,
|
|
2107
|
+
AlignJustifyShortCut,
|
|
2108
|
+
AlignRightShortCut,
|
|
2109
|
+
AlignLeftShortCut,
|
|
2110
|
+
OrderListShortCut,
|
|
2111
|
+
BulletListShortCut
|
|
2112
|
+
].forEach((shortcut) => {
|
|
2113
|
+
this.disposeWithMe(this._shortcutService.registerShortcut(shortcut));
|
|
1868
2114
|
});
|
|
1869
2115
|
}
|
|
1870
2116
|
_init() {
|
|
1871
|
-
this._initCustomComponents(), this._initMenus(), this._initFocusHandler();
|
|
2117
|
+
this._initCustomComponents(), this._initMenus(), this._initFocusHandler(), this._initUiParts(), this._initShortCut();
|
|
1872
2118
|
}
|
|
1873
2119
|
_initFocusHandler() {
|
|
1874
2120
|
this.disposeWithMe(
|
|
1875
|
-
this._layoutService.registerFocusHandler(
|
|
1876
|
-
this._injector.get(
|
|
2121
|
+
this._layoutService.registerFocusHandler(UniverInstanceType.UNIVER_DOC, () => {
|
|
2122
|
+
this._injector.get(ITextSelectionRenderManager).focus();
|
|
1877
2123
|
})
|
|
1878
2124
|
);
|
|
1879
2125
|
}
|
|
2126
|
+
}, __name(_a6, "DocUIController"), _a6);
|
|
2127
|
+
DocUIController = __decorateClass$c([
|
|
2128
|
+
OnLifecycle(LifecycleStages.Rendered, DocUIController),
|
|
2129
|
+
__decorateParam$c(1, Inject(Injector)),
|
|
2130
|
+
__decorateParam$c(2, Inject(ComponentManager)),
|
|
2131
|
+
__decorateParam$c(3, ILayoutService),
|
|
2132
|
+
__decorateParam$c(4, IMenuService),
|
|
2133
|
+
__decorateParam$c(5, IUIPartsService),
|
|
2134
|
+
__decorateParam$c(6, IUniverInstanceService),
|
|
2135
|
+
__decorateParam$c(7, IShortcutService)
|
|
2136
|
+
], DocUIController);
|
|
2137
|
+
const BreakLineShortcut = {
|
|
2138
|
+
id: BreakLineCommand.id,
|
|
2139
|
+
preconditions: whenDocAndEditorFocusedWithBreakLine,
|
|
2140
|
+
binding: KeyCode.ENTER
|
|
2141
|
+
}, DeleteLeftShortcut = {
|
|
2142
|
+
id: DeleteLeftCommand.id,
|
|
2143
|
+
preconditions: whenDocAndEditorFocused,
|
|
2144
|
+
binding: KeyCode.BACKSPACE
|
|
2145
|
+
}, DeleteRightShortcut = {
|
|
2146
|
+
id: DeleteRightCommand.id,
|
|
2147
|
+
preconditions: whenDocAndEditorFocused,
|
|
2148
|
+
binding: KeyCode.DELETE
|
|
1880
2149
|
};
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
id: go.id,
|
|
1890
|
-
preconditions: Fo,
|
|
1891
|
-
binding: H.ENTER
|
|
1892
|
-
}, si = {
|
|
1893
|
-
id: po.id,
|
|
1894
|
-
preconditions: k,
|
|
1895
|
-
binding: H.BACKSPACE
|
|
1896
|
-
}, ai = {
|
|
1897
|
-
id: fo.id,
|
|
1898
|
-
preconditions: k,
|
|
1899
|
-
binding: H.DELETE
|
|
1900
|
-
};
|
|
1901
|
-
function ze(t) {
|
|
1902
|
-
return t.getContextValue(Ue) || t.getContextValue(qt);
|
|
1903
|
-
}
|
|
1904
|
-
const ft = 999, ci = {
|
|
1905
|
-
id: Vn.id,
|
|
1906
|
-
name: "doc.command.copy",
|
|
1907
|
-
type: de.COMMAND,
|
|
1908
|
-
multi: !0,
|
|
1909
|
-
priority: ft,
|
|
1910
|
-
preconditions: ze,
|
|
1911
|
-
handler: async (t) => t.get(Re).copy()
|
|
1912
|
-
}, li = {
|
|
1913
|
-
id: jn.id,
|
|
1914
|
-
name: "doc.command.cut",
|
|
1915
|
-
type: de.COMMAND,
|
|
1916
|
-
multi: !0,
|
|
1917
|
-
priority: ft,
|
|
1918
|
-
preconditions: ze,
|
|
1919
|
-
handler: async (t) => t.get(Re).cut()
|
|
1920
|
-
}, di = {
|
|
1921
|
-
id: Wn.id,
|
|
1922
|
-
name: "doc.command.paste",
|
|
1923
|
-
type: de.COMMAND,
|
|
1924
|
-
multi: !0,
|
|
1925
|
-
priority: ft,
|
|
1926
|
-
preconditions: ze,
|
|
1927
|
-
handler: async (t) => {
|
|
1928
|
-
const e = t.get(Re), o = await t.get(ut).read();
|
|
1929
|
-
return o.length === 0 ? !1 : e.paste(o);
|
|
1930
|
-
}
|
|
1931
|
-
};
|
|
1932
|
-
var ui = Object.defineProperty, hi = Object.getOwnPropertyDescriptor, gi = (t, e, n, o) => {
|
|
1933
|
-
for (var r = o > 1 ? void 0 : o ? hi(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
1934
|
-
(s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
|
|
1935
|
-
return o && r && ui(e, n, r), r;
|
|
1936
|
-
}, he = (t, e) => (n, o) => e(n, o, t);
|
|
1937
|
-
let Me = class extends Se {
|
|
1938
|
-
constructor(t, e, n, o, r) {
|
|
1939
|
-
super(), this._commandService = t, this._clipboardInterfaceService = e, this._docClipboardService = n, this._textSelectionRenderManager = o, this._contextService = r, this._init();
|
|
2150
|
+
var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2151
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2152
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2153
|
+
return kind && result && __defProp$b(target, key, result), result;
|
|
2154
|
+
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a7;
|
|
2155
|
+
let DocClipboardController = (_a7 = class extends RxDisposable {
|
|
2156
|
+
constructor(_commandService, _clipboardInterfaceService, _docClipboardService, _textSelectionRenderManager, _contextService) {
|
|
2157
|
+
super(), this._commandService = _commandService, this._clipboardInterfaceService = _clipboardInterfaceService, this._docClipboardService = _docClipboardService, this._textSelectionRenderManager = _textSelectionRenderManager, this._contextService = _contextService, this._init();
|
|
1940
2158
|
}
|
|
1941
2159
|
_init() {
|
|
1942
|
-
[
|
|
2160
|
+
[DocCopyCommand, DocCutCommand, DocPasteCommand].forEach((command) => this.disposeWithMe(this._commandService.registerMultipleCommand(command))), [InnerPasteCommand, CutContentCommand].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command))), this._initLegacyPasteCommand();
|
|
1943
2161
|
}
|
|
1944
2162
|
_initLegacyPasteCommand() {
|
|
1945
|
-
var
|
|
1946
|
-
(
|
|
1947
|
-
var
|
|
1948
|
-
if (!
|
|
2163
|
+
var _a19;
|
|
2164
|
+
(_a19 = this._textSelectionRenderManager) == null || _a19.onPaste$.pipe(takeUntil(this.dispose$)).subscribe((config) => {
|
|
2165
|
+
var _a20, _b;
|
|
2166
|
+
if (!whenDocOrEditor(this._contextService))
|
|
1949
2167
|
return;
|
|
1950
|
-
|
|
1951
|
-
const
|
|
1952
|
-
this._docClipboardService.legacyPaste(
|
|
2168
|
+
config.event.preventDefault();
|
|
2169
|
+
const clipboardEvent = config.event, htmlContent = (_a20 = clipboardEvent.clipboardData) == null ? void 0 : _a20.getData("text/html"), textContent = (_b = clipboardEvent.clipboardData) == null ? void 0 : _b.getData("text/plain");
|
|
2170
|
+
this._docClipboardService.legacyPaste(htmlContent, textContent);
|
|
1953
2171
|
});
|
|
1954
2172
|
}
|
|
1955
|
-
};
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
],
|
|
1964
|
-
var
|
|
1965
|
-
for (var
|
|
1966
|
-
(
|
|
1967
|
-
return
|
|
1968
|
-
},
|
|
1969
|
-
let
|
|
1970
|
-
constructor(
|
|
2173
|
+
}, __name(_a7, "DocClipboardController"), _a7);
|
|
2174
|
+
DocClipboardController = __decorateClass$b([
|
|
2175
|
+
OnLifecycle(LifecycleStages.Rendered, DocClipboardController),
|
|
2176
|
+
__decorateParam$b(0, ICommandService),
|
|
2177
|
+
__decorateParam$b(1, IClipboardInterfaceService),
|
|
2178
|
+
__decorateParam$b(2, IDocClipboardService),
|
|
2179
|
+
__decorateParam$b(3, ITextSelectionRenderManager),
|
|
2180
|
+
__decorateParam$b(4, IContextService)
|
|
2181
|
+
], DocClipboardController);
|
|
2182
|
+
var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2183
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2184
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2185
|
+
return kind && result && __defProp$a(target, key, result), result;
|
|
2186
|
+
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a8;
|
|
2187
|
+
let DocEditorBridgeController = (_a8 = class extends Disposable {
|
|
2188
|
+
constructor(_univerInstanceService, _editorService, _commandService, _textSelectionRenderManager, _renderManagerService) {
|
|
1971
2189
|
super();
|
|
1972
|
-
|
|
1973
|
-
this._univerInstanceService =
|
|
2190
|
+
__publicField(this, "_initialEditors", /* @__PURE__ */ new Set());
|
|
2191
|
+
this._univerInstanceService = _univerInstanceService, this._editorService = _editorService, this._commandService = _commandService, this._textSelectionRenderManager = _textSelectionRenderManager, this._renderManagerService = _renderManagerService, this._initialize();
|
|
1974
2192
|
}
|
|
1975
2193
|
_initialize() {
|
|
1976
2194
|
this.disposeWithMe(
|
|
1977
|
-
this._editorService.resize$.subscribe((
|
|
1978
|
-
this._resize(
|
|
2195
|
+
this._editorService.resize$.subscribe((unitId) => {
|
|
2196
|
+
this._resize(unitId);
|
|
1979
2197
|
})
|
|
1980
|
-
), this._editorService.getAllEditor().forEach((
|
|
1981
|
-
const
|
|
1982
|
-
this._initialEditors.has(
|
|
2198
|
+
), this._editorService.getAllEditor().forEach((editor) => {
|
|
2199
|
+
const unitId = editor.editorUnitId;
|
|
2200
|
+
this._initialEditors.has(unitId) || (this._initialEditors.add(unitId), this._resize(unitId));
|
|
1983
2201
|
}), this._commandExecutedListener(), this._initialSetValue(), this._initialBlur(), this._initialFocus(), this._initialValueChange();
|
|
1984
2202
|
}
|
|
1985
|
-
_resize(
|
|
1986
|
-
var
|
|
1987
|
-
if (
|
|
2203
|
+
_resize(unitId) {
|
|
2204
|
+
var _a19, _b, _c;
|
|
2205
|
+
if (unitId == null)
|
|
1988
2206
|
return;
|
|
1989
|
-
const
|
|
1990
|
-
if ((
|
|
2207
|
+
const editor = this._editorService.getEditor(unitId);
|
|
2208
|
+
if ((editor == null ? void 0 : editor.cancelDefaultResizeListener) === !0)
|
|
1991
2209
|
return;
|
|
1992
|
-
const
|
|
1993
|
-
if (!
|
|
2210
|
+
const editorDataModel = this._univerInstanceService.getUniverDocInstance(unitId);
|
|
2211
|
+
if (!editorDataModel)
|
|
1994
2212
|
return;
|
|
1995
|
-
const
|
|
1996
|
-
if (
|
|
2213
|
+
const skeleton = (_a19 = this._renderManagerService.getRenderById(editorDataModel.getUnitId())) == null ? void 0 : _a19.with(DocSkeletonManagerService).getSkeleton();
|
|
2214
|
+
if (editor == null || editor.render == null || skeleton == null || editorDataModel == null)
|
|
1997
2215
|
return;
|
|
1998
|
-
|
|
1999
|
-
const { marginTop
|
|
2000
|
-
let { actualHeight
|
|
2001
|
-
|
|
2002
|
-
const { width
|
|
2003
|
-
let
|
|
2004
|
-
const
|
|
2005
|
-
|
|
2006
|
-
width:
|
|
2007
|
-
height:
|
|
2008
|
-
}),
|
|
2216
|
+
skeleton.calculate();
|
|
2217
|
+
const { marginTop = 0, marginBottom = 0, marginLeft = 0, marginRight = 0 } = editorDataModel.getSnapshot().documentStyle, { scene, mainComponent } = editor.render;
|
|
2218
|
+
let { actualHeight, actualWidth } = skeleton.getActualSize();
|
|
2219
|
+
actualHeight += marginTop + marginBottom, actualWidth += marginLeft + marginRight;
|
|
2220
|
+
const { width, height } = editor.getBoundingClientRect(), viewportMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
2221
|
+
let scrollBar = viewportMain == null ? void 0 : viewportMain.getScrollBar();
|
|
2222
|
+
const contentWidth = Math.max(actualWidth, width), contentHeight = Math.max(actualHeight, height);
|
|
2223
|
+
scene.transformByState({
|
|
2224
|
+
width: contentWidth,
|
|
2225
|
+
height: contentHeight
|
|
2226
|
+
}), mainComponent == null || mainComponent.resize(contentWidth, contentHeight), editor.isSingle() ? actualWidth > width ? scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { barSize: 8, enableVertical: !1 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll() : (scrollBar = null, viewportMain == null || viewportMain.scrollToBarPos({ x: 0, y: 0 }), (_c = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _c.dispose()) : actualHeight > height ? scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { enableHorizontal: !1, barSize: 8 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll() : (scrollBar = null, viewportMain == null || viewportMain.scrollToBarPos({ x: 0, y: 0 }), (_b = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _b.dispose());
|
|
2009
2227
|
}
|
|
2010
2228
|
_initialSetValue() {
|
|
2011
2229
|
this.disposeWithMe(
|
|
2012
|
-
this._editorService.setValue$.subscribe((
|
|
2013
|
-
this._commandService.executeCommand(
|
|
2014
|
-
unitId:
|
|
2015
|
-
body:
|
|
2230
|
+
this._editorService.setValue$.subscribe((param) => {
|
|
2231
|
+
this._commandService.executeCommand(CoverContentCommand.id, {
|
|
2232
|
+
unitId: param.editorUnitId,
|
|
2233
|
+
body: param.body,
|
|
2016
2234
|
segmentId: null
|
|
2017
2235
|
});
|
|
2018
2236
|
})
|
|
@@ -2025,40 +2243,40 @@ let ye = class extends Q {
|
|
|
2025
2243
|
})
|
|
2026
2244
|
), this.disposeWithMe(
|
|
2027
2245
|
this._textSelectionRenderManager.onBlur$.subscribe(() => {
|
|
2028
|
-
var
|
|
2029
|
-
const
|
|
2030
|
-
if (
|
|
2246
|
+
var _a19;
|
|
2247
|
+
const unitId = (_a19 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a19.getUnitId();
|
|
2248
|
+
if (unitId == null)
|
|
2031
2249
|
return;
|
|
2032
|
-
const
|
|
2033
|
-
|
|
2250
|
+
const editor = this._editorService.getEditor(unitId), focusEditor = this._editorService.getFocusEditor();
|
|
2251
|
+
editor == null || editor.isSheetEditor() || focusEditor && focusEditor.editorUnitId === unitId || this._editorService.blur();
|
|
2034
2252
|
})
|
|
2035
2253
|
);
|
|
2036
2254
|
}
|
|
2037
2255
|
_initialFocus() {
|
|
2038
2256
|
this.disposeWithMe(
|
|
2039
|
-
this._editorService.focus$.subscribe((
|
|
2040
|
-
this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.addTextRanges([
|
|
2257
|
+
this._editorService.focus$.subscribe((textRange) => {
|
|
2258
|
+
this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.addTextRanges([textRange]);
|
|
2041
2259
|
})
|
|
2042
2260
|
);
|
|
2043
|
-
const
|
|
2261
|
+
const focusExcepts = [
|
|
2044
2262
|
"univer-formula-search",
|
|
2045
2263
|
"univer-formula-help",
|
|
2046
2264
|
"formula-help-decorator",
|
|
2047
2265
|
"univer-formula-help-param"
|
|
2048
2266
|
];
|
|
2049
2267
|
this.disposeWithMe(
|
|
2050
|
-
|
|
2051
|
-
const
|
|
2052
|
-
if (
|
|
2053
|
-
this._editorService.changeSpreadsheetFocusState(!0),
|
|
2268
|
+
fromEvent(window, "mousedown").subscribe((event) => {
|
|
2269
|
+
const hasSearch = event.target.classList[0] || "";
|
|
2270
|
+
if (checkForSubstrings(hasSearch, focusExcepts)) {
|
|
2271
|
+
this._editorService.changeSpreadsheetFocusState(!0), event.stopPropagation();
|
|
2054
2272
|
return;
|
|
2055
2273
|
}
|
|
2056
2274
|
this._editorService.changeSpreadsheetFocusState(!1);
|
|
2057
2275
|
})
|
|
2058
|
-
), this._univerInstanceService.getAllUnitsForType(
|
|
2059
|
-
const
|
|
2060
|
-
|
|
2061
|
-
this._editorService.changeSpreadsheetFocusState(!0),
|
|
2276
|
+
), this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((unit) => {
|
|
2277
|
+
const unitId = unit.getUnitId(), render = this._renderManagerService.getRenderById(unitId), canvasEle = render == null ? void 0 : render.engine.getCanvas().getCanvasEle();
|
|
2278
|
+
canvasEle != null && fromEvent(canvasEle, "mousedown").subscribe((evt) => {
|
|
2279
|
+
this._editorService.changeSpreadsheetFocusState(!0), evt.stopPropagation();
|
|
2062
2280
|
});
|
|
2063
2281
|
});
|
|
2064
2282
|
}
|
|
@@ -2074,60 +2292,60 @@ let ye = class extends Q {
|
|
|
2074
2292
|
);
|
|
2075
2293
|
}
|
|
2076
2294
|
_valueChange() {
|
|
2077
|
-
var
|
|
2078
|
-
const
|
|
2079
|
-
if (
|
|
2295
|
+
var _a19;
|
|
2296
|
+
const unitId = (_a19 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a19.getUnitId();
|
|
2297
|
+
if (unitId == null)
|
|
2080
2298
|
return;
|
|
2081
|
-
const
|
|
2082
|
-
|
|
2299
|
+
const editor = this._editorService.getEditor(unitId);
|
|
2300
|
+
editor == null || editor.isSheetEditor() || this._editorService.refreshValueChange(unitId);
|
|
2083
2301
|
}
|
|
2084
2302
|
/**
|
|
2085
2303
|
* Listen to document edits to refresh the size of the formula editor.
|
|
2086
2304
|
*/
|
|
2087
2305
|
_commandExecutedListener() {
|
|
2088
|
-
const
|
|
2306
|
+
const updateCommandList = [RichTextEditingMutation.id, SetEditorResizeOperation.id];
|
|
2089
2307
|
this.disposeWithMe(
|
|
2090
|
-
this._commandService.onCommandExecuted((
|
|
2091
|
-
if (
|
|
2092
|
-
const
|
|
2093
|
-
if (this._editorService.isSheetEditor(
|
|
2308
|
+
this._commandService.onCommandExecuted((command) => {
|
|
2309
|
+
if (updateCommandList.includes(command.id)) {
|
|
2310
|
+
const params = command.params, { unitId } = params;
|
|
2311
|
+
if (this._editorService.isSheetEditor(unitId))
|
|
2094
2312
|
return;
|
|
2095
|
-
this._resize(
|
|
2313
|
+
this._resize(unitId), this._valueChange();
|
|
2096
2314
|
}
|
|
2097
2315
|
})
|
|
2098
2316
|
);
|
|
2099
2317
|
}
|
|
2100
|
-
};
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
],
|
|
2109
|
-
var
|
|
2110
|
-
for (var
|
|
2111
|
-
(
|
|
2112
|
-
return
|
|
2113
|
-
},
|
|
2114
|
-
let
|
|
2115
|
-
constructor(
|
|
2116
|
-
super(), this._context =
|
|
2117
|
-
}
|
|
2118
|
-
reRender(
|
|
2119
|
-
var
|
|
2120
|
-
const
|
|
2121
|
-
if (!(!
|
|
2122
|
-
if (
|
|
2123
|
-
(
|
|
2318
|
+
}, __name(_a8, "DocEditorBridgeController"), _a8);
|
|
2319
|
+
DocEditorBridgeController = __decorateClass$a([
|
|
2320
|
+
OnLifecycle(LifecycleStages.Rendered, DocEditorBridgeController),
|
|
2321
|
+
__decorateParam$a(0, IUniverInstanceService),
|
|
2322
|
+
__decorateParam$a(1, IEditorService),
|
|
2323
|
+
__decorateParam$a(2, ICommandService),
|
|
2324
|
+
__decorateParam$a(3, ITextSelectionRenderManager),
|
|
2325
|
+
__decorateParam$a(4, IRenderManagerService)
|
|
2326
|
+
], DocEditorBridgeController);
|
|
2327
|
+
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2328
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2329
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2330
|
+
return kind && result && __defProp$9(target, key, result), result;
|
|
2331
|
+
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9"), _a9;
|
|
2332
|
+
let DocRenderController = (_a9 = class extends RxDisposable {
|
|
2333
|
+
constructor(_context, _commandService, _docSkeletonManagerService, _configService, _editorService, _renderManagerService) {
|
|
2334
|
+
super(), this._context = _context, this._commandService = _commandService, this._docSkeletonManagerService = _docSkeletonManagerService, this._configService = _configService, this._editorService = _editorService, this._renderManagerService = _renderManagerService, this._addNewRender(), this._initRenderRefresh(), this._initCommandListener();
|
|
2335
|
+
}
|
|
2336
|
+
reRender(unitId) {
|
|
2337
|
+
var _a19, _b;
|
|
2338
|
+
const docSkeletonManagerService = (_a19 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a19.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
2339
|
+
if (!(!skeleton || skeleton.getViewModel().getDataModel().getSnapshot().disabled)) {
|
|
2340
|
+
if (skeleton.calculate(), this._editorService.isEditor(unitId)) {
|
|
2341
|
+
(_b = this._context.mainComponent) == null || _b.makeDirty();
|
|
2124
2342
|
return;
|
|
2125
2343
|
}
|
|
2126
|
-
this._recalculateSizeBySkeleton(
|
|
2344
|
+
this._recalculateSizeBySkeleton(skeleton);
|
|
2127
2345
|
}
|
|
2128
2346
|
}
|
|
2129
2347
|
_addNewRender() {
|
|
2130
|
-
const { scene
|
|
2348
|
+
const { scene, engine, unit } = this._context, viewMain = new Viewport(VIEWPORT_KEY.VIEW_MAIN, scene, {
|
|
2131
2349
|
left: 0,
|
|
2132
2350
|
top: 0,
|
|
2133
2351
|
bottom: 0,
|
|
@@ -2136,238 +2354,243 @@ let st = class extends Se {
|
|
|
2136
2354
|
isRelativeY: !0,
|
|
2137
2355
|
isWheelPreventDefaultX: !0
|
|
2138
2356
|
});
|
|
2139
|
-
|
|
2140
|
-
const
|
|
2141
|
-
if (
|
|
2142
|
-
const
|
|
2143
|
-
let
|
|
2144
|
-
|
|
2357
|
+
scene.attachControl(), scene.onMouseWheel$.subscribeEvent((evt, state) => {
|
|
2358
|
+
const e = evt;
|
|
2359
|
+
if (e.ctrlKey) {
|
|
2360
|
+
const deltaFactor = Math.abs(e.deltaX);
|
|
2361
|
+
let scrollNum = deltaFactor < 40 ? 0.2 : deltaFactor < 80 ? 0.4 : 0.2;
|
|
2362
|
+
scrollNum *= e.deltaY > 0 ? -1 : 1, scene.scaleX < 1 && (scrollNum /= 2), scene.scaleX + scrollNum > 4 ? scene.scale(4, 4) : scene.scaleX + scrollNum < 0.1 ? scene.scale(0.1, 0.1) : e.preventDefault();
|
|
2145
2363
|
} else
|
|
2146
|
-
|
|
2147
|
-
}), this._configService.getConfig("hasScroll") !== !1 && new
|
|
2148
|
-
new
|
|
2149
|
-
new
|
|
2150
|
-
), this._addComponent(),
|
|
2151
|
-
|
|
2364
|
+
viewMain.onMouseWheel(e, state);
|
|
2365
|
+
}), this._configService.getConfig("hasScroll") !== !1 && new ScrollBar(viewMain), scene.addLayer(
|
|
2366
|
+
new Layer(scene, [], DOCS_COMPONENT_MAIN_LAYER_INDEX),
|
|
2367
|
+
new Layer(scene, [], DOCS_COMPONENT_HEADER_LAYER_INDEX)
|
|
2368
|
+
), this._addComponent(), unit.getShouldRenderLoopImmediately() && engine.runRenderLoop(() => {
|
|
2369
|
+
scene.render();
|
|
2152
2370
|
});
|
|
2153
2371
|
}
|
|
2154
2372
|
_addComponent() {
|
|
2155
|
-
const { scene
|
|
2156
|
-
pageMarginLeft:
|
|
2157
|
-
pageMarginTop:
|
|
2158
|
-
},
|
|
2159
|
-
|
|
2160
|
-
const
|
|
2161
|
-
|
|
2373
|
+
const { scene, unit: documentModel, components } = this._context, config = {
|
|
2374
|
+
pageMarginLeft: documentModel.documentStyle.marginLeft || 0,
|
|
2375
|
+
pageMarginTop: documentModel.documentStyle.marginTop || 0
|
|
2376
|
+
}, documents = new Documents(DOCS_VIEW_KEY.MAIN, void 0, config);
|
|
2377
|
+
documents.zIndex = DOCS_COMPONENT_DEFAULT_Z_INDEX;
|
|
2378
|
+
const docBackground = new DocBackground(DOCS_VIEW_KEY.BACKGROUND, void 0, config);
|
|
2379
|
+
docBackground.zIndex = DOCS_COMPONENT_DEFAULT_Z_INDEX, this._context.mainComponent = documents, components.set(DOCS_VIEW_KEY.MAIN, documents), components.set(DOCS_VIEW_KEY.BACKGROUND, docBackground), scene.addObjects([documents], DOCS_COMPONENT_MAIN_LAYER_INDEX), scene.addObjects([docBackground], DOCS_COMPONENT_BACKGROUND_LAYER_INDEX), this._editorService.getEditor(documentModel.getUnitId()) == null && scene.enableLayerCache(DOCS_COMPONENT_MAIN_LAYER_INDEX);
|
|
2162
2380
|
}
|
|
2163
2381
|
_initRenderRefresh() {
|
|
2164
|
-
this._docSkeletonManagerService.currentSkeletonBefore$.pipe(
|
|
2165
|
-
this._create(
|
|
2382
|
+
this._docSkeletonManagerService.currentSkeletonBefore$.pipe(takeUntil(this.dispose$)).subscribe((param) => {
|
|
2383
|
+
this._create(param);
|
|
2166
2384
|
});
|
|
2167
2385
|
}
|
|
2168
|
-
_create(
|
|
2169
|
-
if (!
|
|
2386
|
+
_create(skeleton) {
|
|
2387
|
+
if (!skeleton)
|
|
2170
2388
|
return;
|
|
2171
|
-
const { mainComponent
|
|
2172
|
-
|
|
2389
|
+
const { mainComponent, components } = this._context, docsComponent = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND);
|
|
2390
|
+
docsComponent.changeSkeleton(skeleton), docBackground.changeSkeleton(skeleton), this._recalculateSizeBySkeleton(skeleton);
|
|
2173
2391
|
}
|
|
2174
2392
|
_initCommandListener() {
|
|
2175
|
-
const
|
|
2176
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
2177
|
-
if (
|
|
2178
|
-
const
|
|
2179
|
-
this.reRender(
|
|
2393
|
+
const updateCommandList = [RichTextEditingMutation.id];
|
|
2394
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
2395
|
+
if (updateCommandList.includes(command.id)) {
|
|
2396
|
+
const params = command.params, { unitId } = params;
|
|
2397
|
+
this.reRender(unitId);
|
|
2180
2398
|
}
|
|
2181
2399
|
}));
|
|
2182
2400
|
}
|
|
2183
|
-
_recalculateSizeBySkeleton(
|
|
2184
|
-
var
|
|
2185
|
-
const { mainComponent
|
|
2186
|
-
if (
|
|
2401
|
+
_recalculateSizeBySkeleton(skeleton) {
|
|
2402
|
+
var _a19;
|
|
2403
|
+
const { mainComponent, scene, unitId, components } = this._context, docsComponent = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND), pages = (_a19 = skeleton.getSkeletonData()) == null ? void 0 : _a19.pages;
|
|
2404
|
+
if (pages == null)
|
|
2187
2405
|
return;
|
|
2188
|
-
let
|
|
2189
|
-
for (let
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2406
|
+
let width = 0, height = 0;
|
|
2407
|
+
for (let i = 0, len = pages.length; i < len; i++) {
|
|
2408
|
+
const page = pages[i], { pageWidth, pageHeight } = page;
|
|
2409
|
+
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));
|
|
2192
2410
|
}
|
|
2193
|
-
|
|
2411
|
+
docsComponent.resize(width, height), docBackground.resize(width, height), this._editorService.isEditor(unitId) || scene.resize(width, height);
|
|
2412
|
+
}
|
|
2413
|
+
}, __name(_a9, "DocRenderController"), _a9);
|
|
2414
|
+
DocRenderController = __decorateClass$9([
|
|
2415
|
+
__decorateParam$9(1, ICommandService),
|
|
2416
|
+
__decorateParam$9(2, Inject(DocSkeletonManagerService)),
|
|
2417
|
+
__decorateParam$9(3, IConfigService),
|
|
2418
|
+
__decorateParam$9(4, IEditorService),
|
|
2419
|
+
__decorateParam$9(5, IRenderManagerService)
|
|
2420
|
+
], DocRenderController);
|
|
2421
|
+
const _DocPageLayoutService = class _DocPageLayoutService extends Disposable {
|
|
2422
|
+
constructor(_context) {
|
|
2423
|
+
super(), this._context = _context;
|
|
2424
|
+
}
|
|
2425
|
+
calculatePagePosition() {
|
|
2426
|
+
var _a19, _b;
|
|
2427
|
+
const docObject = neoGetDocObject(this._context), zoomRatio = (_b = (_a19 = this._context.unit.getSettings()) == null ? void 0 : _a19.zoomRatio) != null ? _b : 1, { document: docsComponent, scene, docBackground } = docObject, parent = scene == null ? void 0 : scene.getParent(), { width: docsWidth, height: docsHeight, pageMarginLeft, pageMarginTop } = docsComponent;
|
|
2428
|
+
if (parent == null || docsWidth === Number.POSITIVE_INFINITY || docsHeight === Number.POSITIVE_INFINITY)
|
|
2429
|
+
return;
|
|
2430
|
+
const { width: engineWidth, height: engineHeight } = parent;
|
|
2431
|
+
let docsLeft = 0, docsTop = 0, sceneWidth = 0, sceneHeight = 0, scrollToX = Number.POSITIVE_INFINITY;
|
|
2432
|
+
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 ? (docsTop = engineHeight / 2 - docsHeight / 2, sceneHeight = (engineHeight - pageMarginTop * 2) / zoomRatio) : (docsTop = pageMarginTop, sceneHeight = docsHeight + pageMarginTop * 2), scene.resize(sceneWidth, sceneHeight + 200), docsComponent.translate(docsLeft, docsTop), docBackground.translate(docsLeft, docsTop);
|
|
2433
|
+
const viewport = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
2434
|
+
return scrollToX !== Number.POSITIVE_INFINITY && viewport != null && viewport.scrollToViewportPos({
|
|
2435
|
+
viewportScrollX: scrollToX
|
|
2436
|
+
}), this;
|
|
2194
2437
|
}
|
|
2195
2438
|
};
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
(
|
|
2206
|
-
return o && r && Ri(e, n, r), r;
|
|
2207
|
-
}, fe = (t, e) => (n, o) => e(n, o, t);
|
|
2208
|
-
let at = class extends Q {
|
|
2209
|
-
constructor(t, e, n, o, r, i) {
|
|
2210
|
-
super(), this._context = t, this._docSkeletonManagerService = e, this._univerInstanceService = n, this._commandService = o, this._textSelectionManagerService = r, this._editorService = i, this._init();
|
|
2439
|
+
__name(_DocPageLayoutService, "DocPageLayoutService");
|
|
2440
|
+
let DocPageLayoutService = _DocPageLayoutService;
|
|
2441
|
+
var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2442
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2443
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2444
|
+
return kind && result && __defProp$8(target, key, result), result;
|
|
2445
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a10;
|
|
2446
|
+
let DocZoomRenderController = (_a10 = class extends Disposable {
|
|
2447
|
+
constructor(_context, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService) {
|
|
2448
|
+
super(), this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._textSelectionManagerService = _textSelectionManagerService, this._editorService = _editorService, this._docPageLayoutService = _docPageLayoutService, this._init();
|
|
2211
2449
|
}
|
|
2212
2450
|
_init() {
|
|
2213
|
-
this._initSkeletonListener(), this._initCommandExecutedListener(), this._initRenderRefresher(), setTimeout(() => this.
|
|
2451
|
+
this._initSkeletonListener(), this._initCommandExecutedListener(), this._initRenderRefresher(), setTimeout(() => this.updateViewZoom(1, !0), 20);
|
|
2214
2452
|
}
|
|
2215
2453
|
_initRenderRefresher() {
|
|
2216
|
-
this._docSkeletonManagerService.currentSkeleton$.subscribe((
|
|
2217
|
-
if (
|
|
2454
|
+
this._docSkeletonManagerService.currentSkeleton$.subscribe((param) => {
|
|
2455
|
+
if (param == null)
|
|
2218
2456
|
return;
|
|
2219
|
-
const { unitId
|
|
2220
|
-
this._editorService.isEditor(
|
|
2221
|
-
if (!
|
|
2457
|
+
const { unitId, scene } = this._context;
|
|
2458
|
+
this._editorService.isEditor(unitId) || this.disposeWithMe(scene.onMouseWheel$.subscribeEvent((e) => {
|
|
2459
|
+
if (!e.ctrlKey)
|
|
2222
2460
|
return;
|
|
2223
|
-
const
|
|
2224
|
-
if (!
|
|
2461
|
+
const documentModel = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
2462
|
+
if (!documentModel)
|
|
2225
2463
|
return;
|
|
2226
|
-
const
|
|
2227
|
-
let
|
|
2228
|
-
|
|
2229
|
-
const
|
|
2230
|
-
let
|
|
2231
|
-
|
|
2232
|
-
zoomRatio:
|
|
2233
|
-
unitId:
|
|
2234
|
-
}),
|
|
2464
|
+
const deltaFactor = Math.abs(e.deltaX);
|
|
2465
|
+
let ratioDelta = deltaFactor < 40 ? 0.2 : deltaFactor < 80 ? 0.4 : 0.2;
|
|
2466
|
+
ratioDelta *= e.deltaY > 0 ? -1 : 1, scene.scaleX < 1 && (ratioDelta /= 2);
|
|
2467
|
+
const currentRatio = documentModel.zoomRatio;
|
|
2468
|
+
let nextRatio = +Number.parseFloat(`${currentRatio + ratioDelta}`).toFixed(1);
|
|
2469
|
+
nextRatio = nextRatio >= 4 ? 4 : nextRatio <= 0.1 ? 0.1 : nextRatio, this._commandService.executeCommand(SetDocZoomRatioCommand.id, {
|
|
2470
|
+
zoomRatio: nextRatio,
|
|
2471
|
+
unitId: documentModel.getUnitId()
|
|
2472
|
+
}), e.preventDefault();
|
|
2235
2473
|
}));
|
|
2236
2474
|
});
|
|
2237
2475
|
}
|
|
2238
2476
|
_initSkeletonListener() {
|
|
2239
|
-
this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe((
|
|
2240
|
-
if (
|
|
2477
|
+
this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe((param) => {
|
|
2478
|
+
if (param == null)
|
|
2241
2479
|
return;
|
|
2242
|
-
const
|
|
2243
|
-
if (!
|
|
2244
|
-
const
|
|
2245
|
-
this.
|
|
2480
|
+
const documentModel = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
2481
|
+
if (!documentModel) return;
|
|
2482
|
+
const zoomRatio = documentModel.zoomRatio || 1;
|
|
2483
|
+
this.updateViewZoom(zoomRatio, !1);
|
|
2246
2484
|
}));
|
|
2247
2485
|
}
|
|
2248
2486
|
_initCommandExecutedListener() {
|
|
2249
|
-
const
|
|
2250
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
2251
|
-
if (
|
|
2252
|
-
const
|
|
2253
|
-
if (!
|
|
2254
|
-
const
|
|
2255
|
-
if (
|
|
2487
|
+
const updateCommandList = [SetDocZoomRatioOperation.id];
|
|
2488
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
2489
|
+
if (updateCommandList.includes(command.id)) {
|
|
2490
|
+
const documentModel = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
2491
|
+
if (!documentModel) return;
|
|
2492
|
+
const params = command.params, { unitId } = params;
|
|
2493
|
+
if (unitId !== documentModel.getUnitId())
|
|
2256
2494
|
return;
|
|
2257
|
-
const
|
|
2258
|
-
this.
|
|
2495
|
+
const zoomRatio = documentModel.zoomRatio || 1;
|
|
2496
|
+
this.updateViewZoom(zoomRatio);
|
|
2259
2497
|
}
|
|
2260
2498
|
}));
|
|
2261
2499
|
}
|
|
2262
|
-
|
|
2263
|
-
var
|
|
2264
|
-
const
|
|
2265
|
-
|
|
2266
|
-
}
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
};
|
|
2284
|
-
at = Ci([
|
|
2285
|
-
fe(1, I(L)),
|
|
2286
|
-
fe(2, w),
|
|
2287
|
-
fe(3, O),
|
|
2288
|
-
fe(4, I(te)),
|
|
2289
|
-
fe(5, ee)
|
|
2290
|
-
], at);
|
|
2291
|
-
var Ei = Object.defineProperty, Ti = Object.getOwnPropertyDescriptor, Ii = (t, e, n, o) => {
|
|
2292
|
-
for (var r = o > 1 ? void 0 : o ? Ti(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
2293
|
-
(s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
|
|
2294
|
-
return o && r && Ei(e, n, r), r;
|
|
2295
|
-
}, ie = (t, e) => (n, o) => e(n, o, t);
|
|
2296
|
-
let ct = class extends Q {
|
|
2297
|
-
constructor(e, n, o, r, i, s, a) {
|
|
2500
|
+
updateViewZoom(zoomRatio, needRefreshSelection = !0) {
|
|
2501
|
+
var _a19;
|
|
2502
|
+
const docObject = neoGetDocObject(this._context);
|
|
2503
|
+
docObject.scene.scale(zoomRatio, zoomRatio), this._docPageLayoutService.calculatePagePosition(), needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && this._textSelectionManagerService.refreshSelection(), (_a19 = docObject.scene.getTransformer()) == null || _a19.clearSelectedObjects();
|
|
2504
|
+
}
|
|
2505
|
+
}, __name(_a10, "DocZoomRenderController"), _a10);
|
|
2506
|
+
DocZoomRenderController = __decorateClass$8([
|
|
2507
|
+
__decorateParam$8(1, Inject(DocSkeletonManagerService)),
|
|
2508
|
+
__decorateParam$8(2, IUniverInstanceService),
|
|
2509
|
+
__decorateParam$8(3, ICommandService),
|
|
2510
|
+
__decorateParam$8(4, Inject(TextSelectionManagerService)),
|
|
2511
|
+
__decorateParam$8(5, IEditorService),
|
|
2512
|
+
__decorateParam$8(6, Inject(DocPageLayoutService))
|
|
2513
|
+
], DocZoomRenderController);
|
|
2514
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2515
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2516
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2517
|
+
return kind && result && __defProp$7(target, key, result), result;
|
|
2518
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a11;
|
|
2519
|
+
let DocTextSelectionRenderController = (_a11 = class extends Disposable {
|
|
2520
|
+
constructor(_context, _commandService, _editorService, _instanceSrv, _textSelectionRenderManager, _docSkeletonManagerService, _textSelectionManagerService) {
|
|
2298
2521
|
super();
|
|
2299
|
-
|
|
2300
|
-
this._context =
|
|
2522
|
+
__publicField(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
2523
|
+
this._context = _context, this._commandService = _commandService, this._editorService = _editorService, this._instanceSrv = _instanceSrv, this._textSelectionRenderManager = _textSelectionRenderManager, this._docSkeletonManagerService = _docSkeletonManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._initialize();
|
|
2301
2524
|
}
|
|
2302
2525
|
_initialize() {
|
|
2303
2526
|
this._init(), this._skeletonListener(), this._commandExecutedListener();
|
|
2304
2527
|
}
|
|
2305
2528
|
_init() {
|
|
2306
|
-
const { unitId
|
|
2307
|
-
|
|
2529
|
+
const { unitId } = this._context, docObject = neoGetDocObject(this._context);
|
|
2530
|
+
docObject == null || docObject.document == null || this._loadedMap.has(docObject.document) || (this._initialMain(unitId), this._loadedMap.add(docObject.document));
|
|
2308
2531
|
}
|
|
2309
2532
|
// eslint-disable-next-line max-lines-per-function
|
|
2310
|
-
_initialMain(
|
|
2311
|
-
const
|
|
2312
|
-
this.disposeWithMe(
|
|
2313
|
-
this._isEditorReadOnly(
|
|
2314
|
-
})), this.disposeWithMe(
|
|
2315
|
-
|
|
2316
|
-
})), this.disposeWithMe(
|
|
2317
|
-
if (this._isEditorReadOnly(
|
|
2533
|
+
_initialMain(unitId) {
|
|
2534
|
+
const docObject = neoGetDocObject(this._context), { document, scene } = docObject;
|
|
2535
|
+
this.disposeWithMe(document.onPointerEnter$.subscribeEvent(() => {
|
|
2536
|
+
this._isEditorReadOnly(unitId) || (document.cursor = CURSOR_TYPE.TEXT);
|
|
2537
|
+
})), this.disposeWithMe(document.onPointerLeave$.subscribeEvent(() => {
|
|
2538
|
+
document.cursor = CURSOR_TYPE.DEFAULT, scene.resetCursor();
|
|
2539
|
+
})), this.disposeWithMe(document.onPointerDown$.subscribeEvent((evt, state) => {
|
|
2540
|
+
if (this._isEditorReadOnly(unitId))
|
|
2318
2541
|
return;
|
|
2319
|
-
const
|
|
2320
|
-
(
|
|
2321
|
-
const
|
|
2322
|
-
if (
|
|
2542
|
+
const docDataModel = this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
2543
|
+
(docDataModel == null ? void 0 : docDataModel.getUnitId()) !== unitId && this._instanceSrv.setCurrentUnitForType(unitId);
|
|
2544
|
+
const skeleton = this._docSkeletonManagerService.getSkeleton(), { offsetX, offsetY } = evt, coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
|
|
2545
|
+
if (coord != null) {
|
|
2323
2546
|
const {
|
|
2324
|
-
pageLayoutType
|
|
2325
|
-
pageMarginLeft
|
|
2326
|
-
pageMarginTop
|
|
2327
|
-
} =
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
),
|
|
2333
|
-
|
|
2547
|
+
pageLayoutType = PageLayoutType.VERTICAL,
|
|
2548
|
+
pageMarginLeft,
|
|
2549
|
+
pageMarginTop
|
|
2550
|
+
} = document.getOffsetConfig(), { editArea } = skeleton.findEditAreaByCoord(
|
|
2551
|
+
coord,
|
|
2552
|
+
pageLayoutType,
|
|
2553
|
+
pageMarginLeft,
|
|
2554
|
+
pageMarginTop
|
|
2555
|
+
), viewModel = this._docSkeletonManagerService.getViewModel(), preEditArea = viewModel.getEditArea();
|
|
2556
|
+
preEditArea !== DocumentEditArea.BODY && editArea !== DocumentEditArea.BODY && editArea !== preEditArea && viewModel.setEditArea(editArea);
|
|
2334
2557
|
}
|
|
2335
|
-
if (this._textSelectionRenderManager.eventTrigger(
|
|
2336
|
-
this._setEditorFocus(
|
|
2337
|
-
const { offsetX:
|
|
2558
|
+
if (this._textSelectionRenderManager.eventTrigger(evt), this._editorService.getEditor(unitId)) {
|
|
2559
|
+
this._setEditorFocus(unitId);
|
|
2560
|
+
const { offsetX: offsetX2, offsetY: offsetY2 } = evt;
|
|
2338
2561
|
setTimeout(() => {
|
|
2339
|
-
this._setEditorFocus(
|
|
2562
|
+
this._setEditorFocus(unitId), this._textSelectionRenderManager.setCursorManually(offsetX2, offsetY2);
|
|
2340
2563
|
}, 0);
|
|
2341
2564
|
}
|
|
2342
|
-
|
|
2343
|
-
})), this.disposeWithMe(
|
|
2344
|
-
this._isEditorReadOnly(
|
|
2345
|
-
})), this.disposeWithMe(
|
|
2346
|
-
this._isEditorReadOnly(
|
|
2565
|
+
evt.button !== 2 && state.stopPropagation();
|
|
2566
|
+
})), this.disposeWithMe(document.onDblclick$.subscribeEvent((evt) => {
|
|
2567
|
+
this._isEditorReadOnly(unitId) || this._textSelectionRenderManager.handleDblClick(evt);
|
|
2568
|
+
})), this.disposeWithMe(document.onTripleClick$.subscribeEvent((evt) => {
|
|
2569
|
+
this._isEditorReadOnly(unitId) || this._textSelectionRenderManager.handleTripleClick(evt);
|
|
2347
2570
|
}));
|
|
2348
2571
|
}
|
|
2349
|
-
_getTransformCoordForDocumentOffset(
|
|
2350
|
-
const
|
|
2351
|
-
if (
|
|
2572
|
+
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
2573
|
+
const docObject = neoGetDocObject(this._context), { document, scene } = docObject, { documentTransform } = document.getOffsetConfig(), activeViewport = scene.getViewports()[0];
|
|
2574
|
+
if (activeViewport == null)
|
|
2352
2575
|
return;
|
|
2353
|
-
const
|
|
2354
|
-
return
|
|
2576
|
+
const originCoord = activeViewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
2577
|
+
return documentTransform.clone().invert().applyPoint(originCoord);
|
|
2355
2578
|
}
|
|
2356
|
-
_isEditorReadOnly(
|
|
2357
|
-
const
|
|
2358
|
-
return
|
|
2579
|
+
_isEditorReadOnly(unitId) {
|
|
2580
|
+
const editor = this._editorService.getEditor(unitId);
|
|
2581
|
+
return editor ? editor.isReadOnly() : !1;
|
|
2359
2582
|
}
|
|
2360
|
-
_setEditorFocus(
|
|
2361
|
-
this._editorService.focusStyle(
|
|
2583
|
+
_setEditorFocus(unitId) {
|
|
2584
|
+
this._editorService.focusStyle(unitId);
|
|
2362
2585
|
}
|
|
2363
2586
|
_commandExecutedListener() {
|
|
2364
|
-
const
|
|
2587
|
+
const updateCommandList = [SetDocZoomRatioOperation.id];
|
|
2365
2588
|
this.disposeWithMe(
|
|
2366
|
-
this._commandService.onCommandExecuted((
|
|
2367
|
-
var
|
|
2368
|
-
if (
|
|
2369
|
-
const
|
|
2370
|
-
if (
|
|
2589
|
+
this._commandService.onCommandExecuted((command) => {
|
|
2590
|
+
var _a19;
|
|
2591
|
+
if (updateCommandList.includes(command.id)) {
|
|
2592
|
+
const params = command.params, { unitId: documentId } = params, unitId = (_a19 = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : _a19.unitId;
|
|
2593
|
+
if (documentId !== unitId)
|
|
2371
2594
|
return;
|
|
2372
2595
|
this._textSelectionManagerService.refreshSelection();
|
|
2373
2596
|
}
|
|
@@ -2376,14 +2599,14 @@ let ct = class extends Q {
|
|
|
2376
2599
|
}
|
|
2377
2600
|
_skeletonListener() {
|
|
2378
2601
|
this.disposeWithMe(
|
|
2379
|
-
this._docSkeletonManagerService.currentSkeleton$.subscribe((
|
|
2380
|
-
if (
|
|
2602
|
+
this._docSkeletonManagerService.currentSkeleton$.subscribe((skeleton) => {
|
|
2603
|
+
if (skeleton == null)
|
|
2381
2604
|
return;
|
|
2382
|
-
const { scene
|
|
2383
|
-
this._textSelectionRenderManager.changeRuntime(
|
|
2384
|
-
unitId
|
|
2605
|
+
const { scene, mainComponent, unitId } = this._context;
|
|
2606
|
+
this._textSelectionRenderManager.changeRuntime(skeleton, scene, mainComponent), this._textSelectionManagerService.setCurrentSelectionNotRefresh({
|
|
2607
|
+
unitId,
|
|
2385
2608
|
subUnitId: ""
|
|
2386
|
-
}),
|
|
2609
|
+
}), isInternalEditorID(unitId) || this._textSelectionManagerService.replaceTextRanges([
|
|
2387
2610
|
{
|
|
2388
2611
|
startOffset: 0,
|
|
2389
2612
|
endOffset: 0
|
|
@@ -2392,102 +2615,105 @@ let ct = class extends Q {
|
|
|
2392
2615
|
})
|
|
2393
2616
|
);
|
|
2394
2617
|
}
|
|
2395
|
-
};
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
],
|
|
2404
|
-
var
|
|
2405
|
-
for (var
|
|
2406
|
-
(
|
|
2407
|
-
return
|
|
2408
|
-
},
|
|
2409
|
-
function
|
|
2410
|
-
const
|
|
2618
|
+
}, __name(_a11, "DocTextSelectionRenderController"), _a11);
|
|
2619
|
+
DocTextSelectionRenderController = __decorateClass$7([
|
|
2620
|
+
__decorateParam$7(1, ICommandService),
|
|
2621
|
+
__decorateParam$7(2, IEditorService),
|
|
2622
|
+
__decorateParam$7(3, IUniverInstanceService),
|
|
2623
|
+
__decorateParam$7(4, ITextSelectionRenderManager),
|
|
2624
|
+
__decorateParam$7(5, Inject(DocSkeletonManagerService)),
|
|
2625
|
+
__decorateParam$7(6, Inject(TextSelectionManagerService))
|
|
2626
|
+
], DocTextSelectionRenderController);
|
|
2627
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2628
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2629
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2630
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
2631
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
|
|
2632
|
+
function transformBound2OffsetBound(originBound, scene) {
|
|
2633
|
+
const topLeft = transformPosition2Offset(originBound.left, originBound.top, scene), bottomRight = transformPosition2Offset(originBound.right, originBound.bottom, scene);
|
|
2411
2634
|
return {
|
|
2412
|
-
left:
|
|
2413
|
-
top:
|
|
2414
|
-
right:
|
|
2415
|
-
bottom:
|
|
2635
|
+
left: topLeft.x,
|
|
2636
|
+
top: topLeft.y,
|
|
2637
|
+
right: bottomRight.x,
|
|
2638
|
+
bottom: bottomRight.y
|
|
2416
2639
|
};
|
|
2417
2640
|
}
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2641
|
+
__name(transformBound2OffsetBound, "transformBound2OffsetBound");
|
|
2642
|
+
function transformPosition2Offset(x, y, scene) {
|
|
2643
|
+
const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
2644
|
+
if (!viewMain)
|
|
2421
2645
|
return {
|
|
2422
|
-
x
|
|
2423
|
-
y
|
|
2646
|
+
x,
|
|
2647
|
+
y
|
|
2424
2648
|
};
|
|
2425
|
-
const { viewportScrollX:
|
|
2649
|
+
const { viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain, offsetX = (x - actualScrollX) * scaleX, offsetY = (y - actualScrollY) * scaleY;
|
|
2426
2650
|
return {
|
|
2427
|
-
x:
|
|
2428
|
-
y:
|
|
2651
|
+
x: offsetX,
|
|
2652
|
+
y: offsetY
|
|
2429
2653
|
};
|
|
2430
2654
|
}
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2655
|
+
__name(transformPosition2Offset, "transformPosition2Offset");
|
|
2656
|
+
var _a12;
|
|
2657
|
+
let DocCanvasPopManagerService = (_a12 = class extends Disposable {
|
|
2658
|
+
constructor(_globalPopupManagerService, _renderManagerService, _univerInstanceService, _commandService) {
|
|
2659
|
+
super(), this._globalPopupManagerService = _globalPopupManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService;
|
|
2434
2660
|
}
|
|
2435
2661
|
// #region attach to object
|
|
2436
|
-
_createObjectPositionObserver(
|
|
2437
|
-
const
|
|
2438
|
-
const { scene
|
|
2439
|
-
left
|
|
2440
|
-
right:
|
|
2441
|
-
top
|
|
2442
|
-
bottom:
|
|
2443
|
-
},
|
|
2662
|
+
_createObjectPositionObserver(targetObject, currentRender) {
|
|
2663
|
+
const calc = /* @__PURE__ */ __name(() => {
|
|
2664
|
+
const { scene, engine } = currentRender, { left, top, width, height } = targetObject, bound = {
|
|
2665
|
+
left,
|
|
2666
|
+
right: left + width,
|
|
2667
|
+
top,
|
|
2668
|
+
bottom: top + height
|
|
2669
|
+
}, canvasElement = engine.getCanvasElement(), canvasClientRect = canvasElement.getBoundingClientRect(), widthOfCanvas = pxToNum(canvasElement.style.width), offsetBound = transformBound2OffsetBound(bound, scene), { top: topOffset, left: leftOffset, width: domWidth } = canvasClientRect, scaleAdjust = domWidth / widthOfCanvas;
|
|
2444
2670
|
return {
|
|
2445
|
-
left:
|
|
2446
|
-
right:
|
|
2447
|
-
top:
|
|
2448
|
-
bottom:
|
|
2671
|
+
left: offsetBound.left * scaleAdjust + leftOffset,
|
|
2672
|
+
right: offsetBound.right * scaleAdjust + leftOffset,
|
|
2673
|
+
top: offsetBound.top * scaleAdjust + topOffset,
|
|
2674
|
+
bottom: offsetBound.bottom * scaleAdjust + topOffset
|
|
2449
2675
|
};
|
|
2450
|
-
},
|
|
2451
|
-
|
|
2452
|
-
|
|
2676
|
+
}, "calc"), position = calc(), position$ = new BehaviorSubject(position), disposable = new DisposableCollection();
|
|
2677
|
+
disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
|
|
2678
|
+
commandInfo.id === SetDocZoomRatioOperation.id && position$.next(calc());
|
|
2453
2679
|
}));
|
|
2454
|
-
const
|
|
2455
|
-
return
|
|
2456
|
-
|
|
2680
|
+
const viewMain = currentRender.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
2681
|
+
return viewMain && disposable.add(viewMain.onScrollAfter$.subscribeEvent(() => {
|
|
2682
|
+
position$.next(calc());
|
|
2457
2683
|
})), {
|
|
2458
|
-
position
|
|
2459
|
-
position
|
|
2460
|
-
disposable
|
|
2684
|
+
position,
|
|
2685
|
+
position$,
|
|
2686
|
+
disposable
|
|
2461
2687
|
};
|
|
2462
2688
|
}
|
|
2463
|
-
_createRangePositionObserver(
|
|
2464
|
-
var
|
|
2465
|
-
const
|
|
2466
|
-
const { scene
|
|
2467
|
-
if (!
|
|
2689
|
+
_createRangePositionObserver(range, currentRender) {
|
|
2690
|
+
var _a19;
|
|
2691
|
+
const calc = /* @__PURE__ */ __name(() => {
|
|
2692
|
+
const { scene, mainComponent, engine } = currentRender, skeleton = currentRender.with(DocSkeletonManagerService).getSkeleton(), startPosition = skeleton.findNodePositionByCharIndex(range.startOffset), endPosition = skeleton.findNodePositionByCharIndex(range.endOffset), document = mainComponent;
|
|
2693
|
+
if (!endPosition || !startPosition)
|
|
2468
2694
|
return;
|
|
2469
|
-
const
|
|
2470
|
-
return
|
|
2471
|
-
left:
|
|
2472
|
-
right:
|
|
2473
|
-
top:
|
|
2474
|
-
bottom:
|
|
2695
|
+
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);
|
|
2696
|
+
return getLineBounding(borderBoxPointGroup).map((bound) => transformBound2OffsetBound(bound, scene)).map((i) => ({
|
|
2697
|
+
left: (i.left + docsLeft * scaleX) * scaleAdjust + left,
|
|
2698
|
+
right: (i.right + docsLeft * scaleX) * scaleAdjust + left,
|
|
2699
|
+
top: (i.top + docsTop * scaleY) * scaleAdjust + top,
|
|
2700
|
+
bottom: (i.bottom + docsTop * scaleY) * scaleAdjust + top
|
|
2475
2701
|
}));
|
|
2476
|
-
},
|
|
2477
|
-
|
|
2478
|
-
if (
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2702
|
+
}, "calc"), positions = (_a19 = calc()) != null ? _a19 : [], positions$ = new BehaviorSubject(positions), disposable = new DisposableCollection();
|
|
2703
|
+
disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
|
|
2704
|
+
if (commandInfo.id === SetDocZoomRatioOperation.id) {
|
|
2705
|
+
const position = calc();
|
|
2706
|
+
position && positions$.next(position);
|
|
2481
2707
|
}
|
|
2482
2708
|
}));
|
|
2483
|
-
const
|
|
2484
|
-
return
|
|
2485
|
-
const
|
|
2486
|
-
|
|
2709
|
+
const viewMain = currentRender.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
2710
|
+
return viewMain && disposable.add(viewMain.onScrollAfter$.subscribeEvent(() => {
|
|
2711
|
+
const position = calc();
|
|
2712
|
+
position && positions$.next(position);
|
|
2487
2713
|
})), {
|
|
2488
|
-
positions
|
|
2489
|
-
positions
|
|
2490
|
-
disposable
|
|
2714
|
+
positions,
|
|
2715
|
+
positions$,
|
|
2716
|
+
disposable
|
|
2491
2717
|
};
|
|
2492
2718
|
}
|
|
2493
2719
|
/**
|
|
@@ -2496,211 +2722,390 @@ let lt = class extends Q {
|
|
|
2496
2722
|
* @param popup popup item
|
|
2497
2723
|
* @returns disposable
|
|
2498
2724
|
*/
|
|
2499
|
-
attachPopupToObject(
|
|
2500
|
-
const
|
|
2501
|
-
if (!
|
|
2725
|
+
attachPopupToObject(targetObject, popup) {
|
|
2726
|
+
const unitId = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC).getUnitId(), currentRender = this._renderManagerService.getRenderById(unitId);
|
|
2727
|
+
if (!currentRender)
|
|
2502
2728
|
return {
|
|
2503
|
-
dispose: () => {
|
|
2504
|
-
}
|
|
2729
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
2730
|
+
}, "dispose")
|
|
2505
2731
|
};
|
|
2506
|
-
const { position
|
|
2507
|
-
...
|
|
2508
|
-
unitId
|
|
2732
|
+
const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender), id = this._globalPopupManagerService.addPopup({
|
|
2733
|
+
...popup,
|
|
2734
|
+
unitId,
|
|
2509
2735
|
subUnitId: "default",
|
|
2510
|
-
anchorRect:
|
|
2511
|
-
anchorRect$:
|
|
2736
|
+
anchorRect: position,
|
|
2737
|
+
anchorRect$: position$
|
|
2512
2738
|
});
|
|
2513
2739
|
return {
|
|
2514
|
-
dispose: () => {
|
|
2515
|
-
this._globalPopupManagerService.removePopup(
|
|
2516
|
-
}
|
|
2740
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
2741
|
+
this._globalPopupManagerService.removePopup(id), position$.complete(), disposable.dispose();
|
|
2742
|
+
}, "dispose")
|
|
2517
2743
|
};
|
|
2518
2744
|
}
|
|
2519
|
-
attachPopupToRange(
|
|
2520
|
-
const
|
|
2521
|
-
if (!
|
|
2745
|
+
attachPopupToRange(range, popup) {
|
|
2746
|
+
const unitId = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC).getUnitId(), { direction = "top" } = popup, currentRender = this._renderManagerService.getRenderById(unitId);
|
|
2747
|
+
if (!currentRender)
|
|
2522
2748
|
return {
|
|
2523
|
-
dispose: () => {
|
|
2524
|
-
}
|
|
2749
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
2750
|
+
}, "dispose")
|
|
2525
2751
|
};
|
|
2526
|
-
const { positions:
|
|
2527
|
-
...
|
|
2528
|
-
unitId
|
|
2752
|
+
const { positions: bounds, positions$: bounds$, disposable } = this._createRangePositionObserver(range, currentRender), position$ = bounds$.pipe(map((bounds2) => direction === "top" ? bounds2[0] : bounds2[bounds2.length - 1])), id = this._globalPopupManagerService.addPopup({
|
|
2753
|
+
...popup,
|
|
2754
|
+
unitId,
|
|
2529
2755
|
subUnitId: "default",
|
|
2530
|
-
anchorRect:
|
|
2531
|
-
anchorRect$:
|
|
2532
|
-
excludeRects:
|
|
2533
|
-
excludeRects$:
|
|
2534
|
-
direction:
|
|
2756
|
+
anchorRect: direction === "top" ? bounds[0] : bounds[bounds.length - 1],
|
|
2757
|
+
anchorRect$: position$,
|
|
2758
|
+
excludeRects: bounds,
|
|
2759
|
+
excludeRects$: bounds$,
|
|
2760
|
+
direction: direction === "top" ? "top" : "bottom"
|
|
2535
2761
|
});
|
|
2536
2762
|
return {
|
|
2537
|
-
dispose: () => {
|
|
2538
|
-
this._globalPopupManagerService.removePopup(
|
|
2539
|
-
}
|
|
2763
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
2764
|
+
this._globalPopupManagerService.removePopup(id), bounds$.complete(), disposable.dispose();
|
|
2765
|
+
}, "dispose")
|
|
2540
2766
|
};
|
|
2541
2767
|
}
|
|
2542
|
-
};
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
],
|
|
2549
|
-
var
|
|
2550
|
-
for (var
|
|
2551
|
-
(
|
|
2552
|
-
return
|
|
2553
|
-
},
|
|
2554
|
-
let
|
|
2555
|
-
constructor(
|
|
2556
|
-
super(), this._instanceSrv =
|
|
2768
|
+
}, __name(_a12, "DocCanvasPopManagerService"), _a12);
|
|
2769
|
+
DocCanvasPopManagerService = __decorateClass$6([
|
|
2770
|
+
__decorateParam$6(0, Inject(ICanvasPopupService)),
|
|
2771
|
+
__decorateParam$6(1, IRenderManagerService),
|
|
2772
|
+
__decorateParam$6(2, IUniverInstanceService),
|
|
2773
|
+
__decorateParam$6(3, ICommandService)
|
|
2774
|
+
], DocCanvasPopManagerService);
|
|
2775
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2776
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2777
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2778
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
2779
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a13;
|
|
2780
|
+
let DocsRenderService = (_a13 = class extends RxDisposable {
|
|
2781
|
+
constructor(_instanceSrv, _renderManagerService) {
|
|
2782
|
+
super(), this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._init();
|
|
2557
2783
|
}
|
|
2558
2784
|
_init() {
|
|
2559
|
-
this._renderManagerService.createRender$.pipe(
|
|
2785
|
+
this._renderManagerService.createRender$.pipe(takeUntil(this.dispose$)).subscribe((unitId) => this._createRenderWithId(unitId)), this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((doc) => this._createRenderer(doc)), this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentModel) => this._createRenderer(documentModel)), this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((doc) => this._disposeRenderer(doc));
|
|
2786
|
+
}
|
|
2787
|
+
_createRenderer(doc) {
|
|
2788
|
+
const unitId = doc.getUnitId();
|
|
2789
|
+
this._renderManagerService.has(unitId) || (this._createRenderWithId(unitId), this._renderManagerService.setCurrent(unitId));
|
|
2790
|
+
}
|
|
2791
|
+
_createRenderWithId(unitId) {
|
|
2792
|
+
this._renderManagerService.createRender(unitId);
|
|
2793
|
+
}
|
|
2794
|
+
_disposeRenderer(doc) {
|
|
2795
|
+
const unitId = doc.getUnitId();
|
|
2796
|
+
this._renderManagerService.removeRender(unitId);
|
|
2797
|
+
}
|
|
2798
|
+
}, __name(_a13, "DocsRenderService"), _a13);
|
|
2799
|
+
DocsRenderService = __decorateClass$5([
|
|
2800
|
+
OnLifecycle(LifecycleStages.Ready, DocsRenderService),
|
|
2801
|
+
__decorateParam$5(0, IUniverInstanceService),
|
|
2802
|
+
__decorateParam$5(1, IRenderManagerService)
|
|
2803
|
+
], DocsRenderService);
|
|
2804
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2805
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2806
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2807
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
2808
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
|
|
2809
|
+
const SKIP_UNIT_IDS$1 = [
|
|
2810
|
+
DEFAULT_EMPTY_DOCUMENT_VALUE,
|
|
2811
|
+
DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
|
|
2812
|
+
DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
|
|
2813
|
+
DOCS_ZEN_EDITOR_UNIT_ID_KEY
|
|
2814
|
+
];
|
|
2815
|
+
var _a14;
|
|
2816
|
+
let DocContextMenuRenderController = (_a14 = class extends Disposable {
|
|
2817
|
+
constructor(_context, _contextMenuService, _textSelectionManagerService, _commandService) {
|
|
2818
|
+
super(), this._context = _context, this._contextMenuService = _contextMenuService, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, SKIP_UNIT_IDS$1.includes(this._context.unitId) || (this._initPointerDown(), this._initEditChange());
|
|
2819
|
+
}
|
|
2820
|
+
_initPointerDown() {
|
|
2821
|
+
var _a19, _b;
|
|
2822
|
+
const documentsSubscription = ((_b = (_a19 = this._context) == null ? void 0 : _a19.mainComponent) == null ? void 0 : _b.onPointerDown$).subscribeEvent((event) => {
|
|
2823
|
+
event.button === 2 && this._contextMenuService.triggerContextMenu(event, MenuPosition.CONTEXT_MENU);
|
|
2824
|
+
});
|
|
2825
|
+
this.disposeWithMe(documentsSubscription);
|
|
2560
2826
|
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2827
|
+
_initEditChange() {
|
|
2828
|
+
this.disposeWithMe(
|
|
2829
|
+
this._commandService.onCommandExecuted((command) => {
|
|
2830
|
+
command.id === RichTextEditingMutation.id && this._contextMenuService.visible && this._contextMenuService.hideContextMenu();
|
|
2831
|
+
})
|
|
2832
|
+
);
|
|
2564
2833
|
}
|
|
2565
|
-
|
|
2566
|
-
|
|
2834
|
+
}, __name(_a14, "DocContextMenuRenderController"), _a14);
|
|
2835
|
+
DocContextMenuRenderController = __decorateClass$4([
|
|
2836
|
+
__decorateParam$4(1, IContextMenuService),
|
|
2837
|
+
__decorateParam$4(2, Inject(TextSelectionManagerService)),
|
|
2838
|
+
__decorateParam$4(3, ICommandService)
|
|
2839
|
+
], DocContextMenuRenderController);
|
|
2840
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2841
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2842
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2843
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
2844
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
|
|
2845
|
+
const SKIP_UNIT_IDS = [
|
|
2846
|
+
DEFAULT_EMPTY_DOCUMENT_VALUE,
|
|
2847
|
+
DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
|
|
2848
|
+
DOCS_NORMAL_EDITOR_UNIT_ID_KEY
|
|
2849
|
+
];
|
|
2850
|
+
var _a15;
|
|
2851
|
+
let DocResizeRenderController = (_a15 = class extends Disposable {
|
|
2852
|
+
constructor(_context, _docPageLayoutService, _textSelectionManagerService) {
|
|
2853
|
+
super(), this._context = _context, this._docPageLayoutService = _docPageLayoutService, this._textSelectionManagerService = _textSelectionManagerService, SKIP_UNIT_IDS.includes(this._context.unitId) || this._initResize();
|
|
2854
|
+
}
|
|
2855
|
+
_initResize() {
|
|
2856
|
+
this.disposeWithMe(
|
|
2857
|
+
fromEventSubject(this._context.engine.onTransformChange$).pipe(
|
|
2858
|
+
filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize),
|
|
2859
|
+
throttleTime(16)
|
|
2860
|
+
).subscribe(() => {
|
|
2861
|
+
this._docPageLayoutService.calculatePagePosition(), this._textSelectionManagerService.refreshSelection();
|
|
2862
|
+
})
|
|
2863
|
+
);
|
|
2567
2864
|
}
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2865
|
+
}, __name(_a15, "DocResizeRenderController"), _a15);
|
|
2866
|
+
DocResizeRenderController = __decorateClass$3([
|
|
2867
|
+
__decorateParam$3(1, Inject(DocPageLayoutService)),
|
|
2868
|
+
__decorateParam$3(2, Inject(TextSelectionManagerService))
|
|
2869
|
+
], DocResizeRenderController);
|
|
2870
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2871
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2872
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2873
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
2874
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a16;
|
|
2875
|
+
let DocHoverManagerService = (_a16 = class extends Disposable {
|
|
2876
|
+
constructor(_univerInstanceService, _renderManagerService) {
|
|
2877
|
+
super();
|
|
2878
|
+
__publicField(this, "_activeCustomRanges$", new BehaviorSubject([]));
|
|
2879
|
+
__publicField(this, "activeCustomRanges$", this._activeCustomRanges$.asObservable());
|
|
2880
|
+
__publicField(this, "_activeIndex$", new BehaviorSubject(null));
|
|
2881
|
+
__publicField(this, "activeIndex$", this._activeIndex$.asObservable());
|
|
2882
|
+
__publicField(this, "_scrolling", !1);
|
|
2883
|
+
this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this.disposeWithMe(() => {
|
|
2884
|
+
this._activeCustomRanges$.complete(), this._activeIndex$.complete();
|
|
2885
|
+
});
|
|
2571
2886
|
}
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
var
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2887
|
+
_getTransformCoordForDocumentOffset(document, viewport, evtOffsetX, evtOffsetY) {
|
|
2888
|
+
const { documentTransform } = document.getOffsetConfig(), originCoord = viewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
2889
|
+
if (originCoord)
|
|
2890
|
+
return documentTransform.clone().invert().applyPoint(originCoord);
|
|
2891
|
+
}
|
|
2892
|
+
_calcActiveCustomRanges(offsetX, offsetY) {
|
|
2893
|
+
var _a19, _b;
|
|
2894
|
+
const document = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
2895
|
+
if (!document) {
|
|
2896
|
+
this._activeCustomRanges$.next([]);
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
const currentRender = this._renderManagerService.getRenderById(document.getUnitId());
|
|
2900
|
+
if (!currentRender)
|
|
2901
|
+
return null;
|
|
2902
|
+
const documentComponent = currentRender.mainComponent, skeleton = currentRender.with(DocSkeletonManagerService).getSkeleton(), { pageLayoutType = PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop, docsLeft, docsTop } = documentComponent.getOffsetConfig(), coord = this._getTransformCoordForDocumentOffset(
|
|
2903
|
+
documentComponent,
|
|
2904
|
+
currentRender.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN),
|
|
2905
|
+
offsetX,
|
|
2906
|
+
offsetY
|
|
2907
|
+
);
|
|
2908
|
+
if (!coord)
|
|
2909
|
+
return;
|
|
2910
|
+
const node = skeleton.findNodeByCoord(
|
|
2911
|
+
coord,
|
|
2912
|
+
pageLayoutType,
|
|
2913
|
+
pageMarginLeft,
|
|
2914
|
+
pageMarginTop
|
|
2915
|
+
);
|
|
2916
|
+
if (node && node.node) {
|
|
2917
|
+
const left = node.node.left + pageMarginLeft, right = node.node.left + node.node.width + pageMarginLeft;
|
|
2918
|
+
if (coord.x < left || coord.x > right) {
|
|
2919
|
+
this._activeIndex$.next(null), this._activeCustomRanges$.next([]);
|
|
2920
|
+
return;
|
|
2921
|
+
}
|
|
2922
|
+
const index = node.node.parent.st + node.node.parent.glyphGroup.indexOf(node.node);
|
|
2923
|
+
index !== this._activeIndex$.value && this._activeIndex$.next(index);
|
|
2924
|
+
const ranges = (_b = (_a19 = document.getCustomRanges()) == null ? void 0 : _a19.filter((range) => range.startIndex <= index && range.endIndex >= index)) != null ? _b : [], currentRanges = this._activeCustomRanges$.value;
|
|
2925
|
+
if (currentRanges.length === ranges.length && currentRanges.every((range, i) => range.rangeId === ranges[i].rangeId))
|
|
2926
|
+
return;
|
|
2927
|
+
this._activeCustomRanges$.next(ranges);
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
onMouseMove(evt) {
|
|
2931
|
+
if (this._scrolling)
|
|
2932
|
+
return;
|
|
2933
|
+
const { offsetX, offsetY } = evt;
|
|
2934
|
+
this._calcActiveCustomRanges(offsetX, offsetY);
|
|
2935
|
+
}
|
|
2936
|
+
startScroll() {
|
|
2937
|
+
this._scrolling || (this._scrolling = !0);
|
|
2938
|
+
}
|
|
2939
|
+
endScroll() {
|
|
2940
|
+
this._scrolling = !1;
|
|
2941
|
+
}
|
|
2942
|
+
}, __name(_a16, "DocHoverManagerService"), _a16);
|
|
2943
|
+
DocHoverManagerService = __decorateClass$2([
|
|
2944
|
+
__decorateParam$2(0, IUniverInstanceService),
|
|
2945
|
+
__decorateParam$2(1, IRenderManagerService)
|
|
2946
|
+
], DocHoverManagerService);
|
|
2947
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2948
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2949
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2950
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
2951
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a17;
|
|
2952
|
+
let DocHoverRenderController = (_a17 = class extends Disposable {
|
|
2953
|
+
constructor(_context, _docHoverManagerService) {
|
|
2954
|
+
super(), this._context = _context, this._docHoverManagerService = _docHoverManagerService, this._initPointerDown(), this._initScroll();
|
|
2955
|
+
}
|
|
2956
|
+
_initPointerDown() {
|
|
2957
|
+
this.disposeWithMe(
|
|
2958
|
+
fromEventSubject(this._context.scene.onPointerMove$).pipe(debounceTime(200)).subscribe((evt) => {
|
|
2959
|
+
this._docHoverManagerService.onMouseMove(evt);
|
|
2960
|
+
})
|
|
2961
|
+
);
|
|
2962
|
+
}
|
|
2963
|
+
_initScroll() {
|
|
2964
|
+
const viewMain = this._context.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
2965
|
+
viewMain && (this.disposeWithMe(fromEventSubject(viewMain.onScrollAfter$).pipe(debounceTime(60)).subscribe(() => {
|
|
2966
|
+
this._docHoverManagerService.endScroll();
|
|
2967
|
+
})), this.disposeWithMe(viewMain.onScrollBefore$.subscribeEvent(() => {
|
|
2968
|
+
this._docHoverManagerService.startScroll();
|
|
2969
|
+
})));
|
|
2970
|
+
}
|
|
2971
|
+
}, __name(_a17, "DocHoverRenderController"), _a17);
|
|
2972
|
+
DocHoverRenderController = __decorateClass$1([
|
|
2973
|
+
__decorateParam$1(1, Inject(DocHoverManagerService))
|
|
2974
|
+
], DocHoverRenderController);
|
|
2975
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2976
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2977
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2978
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
2979
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a18;
|
|
2980
|
+
let UniverDocsUIPlugin = (_a18 = class extends Plugin {
|
|
2981
|
+
constructor(_config, _injector, _renderManagerSrv, _logService) {
|
|
2982
|
+
super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._logService = _logService, this._config = Tools.deepMerge({}, DefaultDocUiConfig, this._config), this._initDependencies(_injector), this._initializeCommands();
|
|
2586
2983
|
}
|
|
2587
2984
|
onReady() {
|
|
2588
|
-
this._initRenderBasics();
|
|
2985
|
+
this._initRenderBasics(), this._markDocAsFocused();
|
|
2589
2986
|
}
|
|
2590
2987
|
onRendered() {
|
|
2591
|
-
this._initUI(), this._initRenderModules()
|
|
2988
|
+
this._initUI(), this._initRenderModules();
|
|
2592
2989
|
}
|
|
2593
2990
|
_initializeCommands() {
|
|
2594
2991
|
[
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
].forEach((
|
|
2608
|
-
this._injector.get(
|
|
2992
|
+
MoveCursorUpShortcut,
|
|
2993
|
+
MoveCursorDownShortcut,
|
|
2994
|
+
MoveCursorRightShortcut,
|
|
2995
|
+
MoveCursorLeftShortcut,
|
|
2996
|
+
MoveSelectionUpShortcut,
|
|
2997
|
+
MoveSelectionDownShortcut,
|
|
2998
|
+
MoveSelectionLeftShortcut,
|
|
2999
|
+
MoveSelectionRightShortcut,
|
|
3000
|
+
SelectAllShortcut,
|
|
3001
|
+
DeleteLeftShortcut,
|
|
3002
|
+
DeleteRightShortcut,
|
|
3003
|
+
BreakLineShortcut
|
|
3004
|
+
].forEach((shortcut) => {
|
|
3005
|
+
this._injector.get(IShortcutService).registerShortcut(shortcut);
|
|
2609
3006
|
});
|
|
2610
3007
|
}
|
|
2611
|
-
_initDependencies(
|
|
3008
|
+
_initDependencies(injector) {
|
|
2612
3009
|
[
|
|
2613
|
-
[
|
|
2614
|
-
[
|
|
2615
|
-
[
|
|
2616
|
-
[
|
|
2617
|
-
[
|
|
2618
|
-
[
|
|
2619
|
-
[
|
|
2620
|
-
|
|
3010
|
+
[DocUIController, { useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(DocUIController, this._config), "useFactory") }],
|
|
3011
|
+
[DocClipboardController],
|
|
3012
|
+
[DocEditorBridgeController],
|
|
3013
|
+
[DocsRenderService],
|
|
3014
|
+
[AppUIController, { useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(AppUIController, this._config), "useFactory") }],
|
|
3015
|
+
[IDocClipboardService, { useClass: DocClipboardService }],
|
|
3016
|
+
[DocCanvasPopManagerService],
|
|
3017
|
+
[DocHoverManagerService]
|
|
3018
|
+
].forEach((d) => injector.add(d));
|
|
2621
3019
|
}
|
|
2622
3020
|
_markDocAsFocused() {
|
|
2623
|
-
const
|
|
3021
|
+
const currentService = this._injector.get(IUniverInstanceService), editorService = this._injector.get(IEditorService);
|
|
2624
3022
|
try {
|
|
2625
|
-
const
|
|
2626
|
-
if (!
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2629
|
-
} catch (
|
|
2630
|
-
this._logService.warn(
|
|
3023
|
+
const doc = currentService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
3024
|
+
if (!doc) return;
|
|
3025
|
+
const id = doc.getUnitId();
|
|
3026
|
+
editorService.isEditor(id) || currentService.focusUnit(doc.getUnitId());
|
|
3027
|
+
} catch (err) {
|
|
3028
|
+
this._logService.warn(err);
|
|
2631
3029
|
}
|
|
2632
3030
|
}
|
|
2633
3031
|
_initUI() {
|
|
2634
|
-
this._injector.get(
|
|
3032
|
+
this._injector.get(AppUIController);
|
|
2635
3033
|
}
|
|
2636
3034
|
_initRenderBasics() {
|
|
2637
3035
|
[
|
|
2638
|
-
[
|
|
2639
|
-
[
|
|
2640
|
-
[
|
|
2641
|
-
[
|
|
2642
|
-
|
|
2643
|
-
|
|
3036
|
+
[DocSkeletonManagerService],
|
|
3037
|
+
[DocInterceptorService],
|
|
3038
|
+
[DocPageLayoutService],
|
|
3039
|
+
[DocRenderController],
|
|
3040
|
+
[DocZoomRenderController]
|
|
3041
|
+
].forEach((m2) => {
|
|
3042
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m2);
|
|
2644
3043
|
});
|
|
2645
3044
|
}
|
|
2646
3045
|
_initRenderModules() {
|
|
2647
3046
|
[
|
|
2648
|
-
[
|
|
2649
|
-
[
|
|
2650
|
-
[
|
|
2651
|
-
|
|
2652
|
-
|
|
3047
|
+
[DocBackScrollRenderController],
|
|
3048
|
+
[DocTextSelectionRenderController],
|
|
3049
|
+
[DocHeaderFooterController],
|
|
3050
|
+
[DocResizeRenderController],
|
|
3051
|
+
[DocHoverRenderController],
|
|
3052
|
+
[DocContextMenuRenderController]
|
|
3053
|
+
].forEach((m2) => {
|
|
3054
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m2);
|
|
2653
3055
|
});
|
|
2654
3056
|
}
|
|
2655
|
-
},
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
],
|
|
2661
|
-
function
|
|
3057
|
+
}, __name(_a18, "UniverDocsUIPlugin"), __publicField(_a18, "pluginName", DOC_UI_PLUGIN_NAME), __publicField(_a18, "type", UniverInstanceType.UNIVER_DOC), _a18);
|
|
3058
|
+
UniverDocsUIPlugin = __decorateClass([
|
|
3059
|
+
__decorateParam(1, Inject(Injector)),
|
|
3060
|
+
__decorateParam(2, IRenderManagerService),
|
|
3061
|
+
__decorateParam(3, ILogService)
|
|
3062
|
+
], UniverDocsUIPlugin);
|
|
3063
|
+
function docDrawingPositionToTransform(position) {
|
|
2662
3064
|
return {
|
|
2663
|
-
left:
|
|
2664
|
-
top:
|
|
2665
|
-
width:
|
|
2666
|
-
height:
|
|
3065
|
+
left: position.positionH.posOffset,
|
|
3066
|
+
top: position.positionV.posOffset,
|
|
3067
|
+
width: position.size.width,
|
|
3068
|
+
height: position.size.height
|
|
2667
3069
|
};
|
|
2668
3070
|
}
|
|
2669
|
-
|
|
3071
|
+
__name(docDrawingPositionToTransform, "docDrawingPositionToTransform");
|
|
3072
|
+
function transformToDocDrawingPosition(transform, marginLeft = 0, marginTop = 0) {
|
|
2670
3073
|
return {
|
|
2671
3074
|
size: {
|
|
2672
|
-
width:
|
|
2673
|
-
height:
|
|
3075
|
+
width: transform.width,
|
|
3076
|
+
height: transform.height
|
|
2674
3077
|
},
|
|
2675
3078
|
positionH: {
|
|
2676
|
-
relativeFrom:
|
|
2677
|
-
posOffset: (
|
|
3079
|
+
relativeFrom: ObjectRelativeFromH.MARGIN,
|
|
3080
|
+
posOffset: (transform.left || 0) - marginLeft
|
|
2678
3081
|
},
|
|
2679
3082
|
positionV: {
|
|
2680
|
-
relativeFrom:
|
|
2681
|
-
posOffset: (
|
|
3083
|
+
relativeFrom: ObjectRelativeFromV.PAGE,
|
|
3084
|
+
posOffset: (transform.top || 0) - marginTop
|
|
2682
3085
|
},
|
|
2683
|
-
angle:
|
|
3086
|
+
angle: transform.angle || 0
|
|
2684
3087
|
};
|
|
2685
3088
|
}
|
|
3089
|
+
__name(transformToDocDrawingPosition, "transformToDocDrawingPosition");
|
|
2686
3090
|
export {
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
3091
|
+
DOC_UI_PLUGIN_NAME,
|
|
3092
|
+
DefaultDocContainerConfig,
|
|
3093
|
+
DefaultDocUiConfig,
|
|
3094
|
+
DefaultToolbarConfig,
|
|
3095
|
+
DocBackScrollRenderController,
|
|
3096
|
+
DocCanvasPopManagerService,
|
|
3097
|
+
DocCopyCommand,
|
|
3098
|
+
DocCutCommand,
|
|
3099
|
+
DocHoverManagerService,
|
|
3100
|
+
DocPasteCommand,
|
|
3101
|
+
DocRenderController,
|
|
3102
|
+
DocsRenderService,
|
|
3103
|
+
IDocClipboardService,
|
|
3104
|
+
PastePluginLark,
|
|
3105
|
+
PastePluginUniver,
|
|
3106
|
+
PastePluginWord,
|
|
3107
|
+
UniverDocsUIPlugin,
|
|
3108
|
+
docDrawingPositionToTransform,
|
|
3109
|
+
transformToDocDrawingPosition,
|
|
3110
|
+
whenDocAndEditorFocused
|
|
2706
3111
|
};
|