@univerjs/docs-ui 0.2.9 → 0.2.11
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 +117 -67
- package/lib/types/commands/commands/clipboard.command.d.ts +1 -0
- package/lib/umd/index.js +4 -4
- package/package.json +14 -14
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, Tools, LRUMap, BaselineOffset, BooleanNumber, ColorKit, DataStreamTreeTokenType, CustomRangeType, skipParseTagNames, DataStreamTreeNodeType, createIdentifier, Inject, IUniverInstanceService, ILogService, ICommandService, Disposable, SliceBodyType,
|
|
5
|
+
import { FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, Tools, LRUMap, BaselineOffset, BooleanNumber, ColorKit, DataStreamTreeTokenType, CustomRangeType, skipParseTagNames, DataStreamTreeNodeType, createIdentifier, Inject, IUniverInstanceService, ILogService, ICommandService, Disposable, SliceBodyType, UniverInstanceType, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, normalizeBody, toDisposable, getBodySlice, RxDisposable, Direction, EDITOR_ACTIVATED, LocaleService, Injector, Optional, useDependency, DocumentFlavor, CommandType, JSONX, useObservable, PresetListType, ThemeService, HorizontalAlign, MemoryCursor, TextX, TextXActionType, UpdateDocsAttributeType, generateRandomId, OnLifecycle, LifecycleStages, connectInjector, IContextService, checkForSubstrings, IConfigService, isInternalEditorID, DisposableCollection, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, fromEventSubject, QuickListTypeMap, Plugin, mergeOverrideWithDependencies, ObjectRelativeFromH, ObjectRelativeFromV } from "@univerjs/core";
|
|
6
6
|
import { IClipboardInterfaceService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, IEditorService, KeyCode, MetaKeys, ILayoutService, ComponentManager, ISidebarService, IConfirmService, 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
7
|
import { getEmptyTableCell, getEmptyTableRow, genTableSource, getTableColumn, TextSelectionManagerService, DocCustomRangeService, getCursorWhenDelete, CutContentCommand, InnerPasteCommand, getDeleteSelection, DocSkeletonManagerService, VIEWPORT_KEY, getDocObject, MoveCursorOperation, MoveSelectionOperation, SelectAllOperation, neoGetDocObject, RichTextEditingMutation, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatItalicCommand, SetInlineFormatUnderlineCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, AlignLeftCommand, AlignRightCommand, AlignCenterCommand, AlignJustifyCommand, OrderListCommand, BulletListCommand, TabCommand, CreateDocTableCommand, SetTextSelectionsOperation, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatTextColorCommand, AlignOperationCommand, CheckListCommand, ResetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextBackgroundColorCommand, getCommandSkeleton, getParagraphsInRange, getParagraphsInRanges, serializeDocRange, getRichTextEditPath, DeleteLeftCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableDeleteRowsCommand, DocTableDeleteColumnsCommand, DocTableDeleteTableCommand, EnterCommand, 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, ChangeListNestingLevelCommand, ChangeListNestingLevelType, DocTableTabCommand, AfterSpaceCommand, QuickListCommand, ListOperationCommand, BreakLineCommand, DocAutoFormatService, ToggleCheckListCommand, DocInterceptorService } from "@univerjs/docs";
|
|
8
8
|
import { pixelToPt, ptToPixel, parseDataStreamToTree, DOC_RANGE_TYPE, NodePositionConvertToCursor, getAnchorBounding, IRenderManagerService, ITextSelectionRenderManager, Shape, DocumentEditArea, PageLayoutType, Vector2, Rect, Path, getNumberUnitValue, ScrollBar, Viewport, Layer, Documents, DocBackground, CURSOR_TYPE, pxToNum, getLineBounding, TRANSFORM_CHANGE_OBSERVABLE_TYPE, isInSameTableCell } from "@univerjs/engine-render";
|
|
@@ -81,7 +81,7 @@ function extractNodeStyle(node) {
|
|
|
81
81
|
const cssRule = styles2[i], cssValue = styles2.getPropertyValue(cssRule);
|
|
82
82
|
switch (cssRule) {
|
|
83
83
|
case "font-family": {
|
|
84
|
-
docStyles.ff = cssValue;
|
|
84
|
+
docStyles.ff = cssValue.replace(/^"/g, "").replace(/"$/g, "");
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
87
87
|
case "font-size": {
|
|
@@ -108,10 +108,13 @@ function extractNodeStyle(node) {
|
|
|
108
108
|
break;
|
|
109
109
|
}
|
|
110
110
|
case "color": {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
try {
|
|
112
|
+
const color = new ColorKit(cssValue);
|
|
113
|
+
color.isValid && (docStyles.cl = {
|
|
114
|
+
rgb: color.toRgbString()
|
|
115
|
+
});
|
|
116
|
+
} catch {
|
|
117
|
+
}
|
|
115
118
|
break;
|
|
116
119
|
}
|
|
117
120
|
case "background-color": {
|
|
@@ -152,6 +155,9 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
|
|
|
152
155
|
const pastePlugin = _HtmlToUDMService._pluginList.find((plugin) => plugin.checkPasteType(html)), dom = parseToDom(html), docData = {
|
|
153
156
|
body: {
|
|
154
157
|
dataStream: "",
|
|
158
|
+
paragraphs: [],
|
|
159
|
+
sectionBreaks: [],
|
|
160
|
+
tables: [],
|
|
155
161
|
textRuns: []
|
|
156
162
|
},
|
|
157
163
|
tableSource: {}
|
|
@@ -206,7 +212,7 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
|
|
|
206
212
|
const tagName = node.tagName.toUpperCase(), body = doc.body;
|
|
207
213
|
switch (tagName) {
|
|
208
214
|
case "TABLE": {
|
|
209
|
-
body.dataStream[body.dataStream.length - 1] !== "\r" && (body.dataStream += "\r", (_a22 = body.paragraphs) == null || _a22.push({
|
|
215
|
+
body.dataStream[body.dataStream.length - 1] !== "\r" && (body.dataStream += "\r", body.paragraphs == null && (body.paragraphs = []), (_a22 = body.paragraphs) == null || _a22.push({
|
|
210
216
|
startIndex: body.dataStream.length - 1
|
|
211
217
|
}));
|
|
212
218
|
const table = genTableSource(0, 0, DEFAULT_TABLE_WIDTH);
|
|
@@ -229,7 +235,7 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
|
|
|
229
235
|
}
|
|
230
236
|
}
|
|
231
237
|
_processAfterTable(node, doc) {
|
|
232
|
-
var _a22;
|
|
238
|
+
var _a22, _b;
|
|
233
239
|
const tagName = node.tagName.toUpperCase(), body = doc.body;
|
|
234
240
|
doc.tableSource == null && (doc.tableSource = {}), body.tables == null && (body.tables = []), body.sectionBreaks == null && (body.sectionBreaks = []);
|
|
235
241
|
const { tableSource } = doc;
|
|
@@ -248,7 +254,9 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
|
|
|
248
254
|
break;
|
|
249
255
|
}
|
|
250
256
|
case "TD": {
|
|
251
|
-
(_a22 = body.
|
|
257
|
+
body.dataStream[body.dataStream.length - 1] !== "\r" && ((_a22 = body.paragraphs) == null || _a22.push({
|
|
258
|
+
startIndex: body.dataStream.length
|
|
259
|
+
}), body.dataStream += "\r"), (_b = body.sectionBreaks) == null || _b.push({
|
|
252
260
|
startIndex: body.dataStream.length
|
|
253
261
|
}), body.dataStream += `
|
|
254
262
|
${DataStreamTreeTokenType.TABLE_CELL_END}`;
|
|
@@ -501,12 +509,13 @@ let DocClipboardService = (_a = class extends Disposable {
|
|
|
501
509
|
this._univerInstanceService = _univerInstanceService, this._logService = _logService, this._commandService = _commandService, this._clipboardInterfaceService = _clipboardInterfaceService, this._textSelectionManagerService = _textSelectionManagerService, this._docCustomRangeService = _docCustomRangeService;
|
|
502
510
|
}
|
|
503
511
|
async copy(sliceType = SliceBodyType.copy) {
|
|
504
|
-
|
|
505
|
-
|
|
512
|
+
var _a22;
|
|
513
|
+
const { bodyList = [], needCache = !1, snapshot } = (_a22 = this._getDocumentBodyInRanges(sliceType)) != null ? _a22 : {};
|
|
514
|
+
if (bodyList.length === 0 || snapshot == null)
|
|
506
515
|
return !1;
|
|
507
516
|
try {
|
|
508
517
|
const activeRange = this._textSelectionManagerService.getActiveTextRangeWithStyle(), isCopyInHeaderFooter = !!(activeRange != null && activeRange.segmentId);
|
|
509
|
-
this._setClipboardData(bodyList, !isCopyInHeaderFooter && needCache);
|
|
518
|
+
this._setClipboardData(bodyList, snapshot, !isCopyInHeaderFooter && needCache);
|
|
510
519
|
} catch (e) {
|
|
511
520
|
return this._logService.error("[DocClipboardService] copy failed", e), !1;
|
|
512
521
|
}
|
|
@@ -520,7 +529,14 @@ let DocClipboardService = (_a = class extends Disposable {
|
|
|
520
529
|
return this._paste(partDocData);
|
|
521
530
|
}
|
|
522
531
|
async legacyPaste(html, text) {
|
|
532
|
+
var _a22;
|
|
523
533
|
const partDocData = this._genDocDataFromHtmlAndText(html, text);
|
|
534
|
+
if (((_a22 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a22.getUnitId()) === DOCS_NORMAL_EDITOR_UNIT_ID_KEY)
|
|
535
|
+
if (text) {
|
|
536
|
+
const textDocData = this._generateBody(text);
|
|
537
|
+
return this._paste({ body: textDocData });
|
|
538
|
+
} else
|
|
539
|
+
partDocData.body.textRuns = [];
|
|
524
540
|
return this._paste(partDocData);
|
|
525
541
|
}
|
|
526
542
|
async _cut() {
|
|
@@ -537,11 +553,13 @@ let DocClipboardService = (_a = class extends Disposable {
|
|
|
537
553
|
let cursor = 0;
|
|
538
554
|
if (rectRanges.length > 0)
|
|
539
555
|
cursor = getCursorWhenDelete(textRanges, rectRanges);
|
|
540
|
-
else if (activeEndOffset != null)
|
|
556
|
+
else if (activeEndOffset != null) {
|
|
557
|
+
cursor = activeEndOffset;
|
|
541
558
|
for (const range of textRanges) {
|
|
542
559
|
const { startOffset, endOffset } = range;
|
|
543
560
|
startOffset == null || endOffset == null || endOffset <= activeEndOffset && (cursor -= endOffset - startOffset);
|
|
544
561
|
}
|
|
562
|
+
}
|
|
545
563
|
const newTextRanges = [
|
|
546
564
|
{
|
|
547
565
|
startOffset: cursor,
|
|
@@ -594,11 +612,30 @@ let DocClipboardService = (_a = class extends Disposable {
|
|
|
594
612
|
return this._logService.error("[DocClipboardController]", "clipboard is empty."), !1;
|
|
595
613
|
}
|
|
596
614
|
}
|
|
597
|
-
async _setClipboardData(documentBodyList, needCache = !0) {
|
|
615
|
+
async _setClipboardData(documentBodyList, snapshot, needCache = !0) {
|
|
616
|
+
var _a22, _b;
|
|
598
617
|
const copyId = genId(), text = documentBodyList.length > 1 ? documentBodyList.map((body) => body.dataStream).join(`
|
|
599
618
|
`) : documentBodyList[0].dataStream;
|
|
600
619
|
let html = this._umdToHtml.convert(documentBodyList);
|
|
601
|
-
|
|
620
|
+
if (documentBodyList.length === 1 && needCache) {
|
|
621
|
+
html = html.replace(/(<[a-z]+)/, (_p0, p1) => `${p1} data-copy-id="${copyId}"`);
|
|
622
|
+
const body = documentBodyList[0], cache = { body };
|
|
623
|
+
if ((_a22 = body.customBlocks) != null && _a22.length) {
|
|
624
|
+
cache.drawings = {};
|
|
625
|
+
for (const block of body.customBlocks) {
|
|
626
|
+
const { blockId } = block, drawing = (_b = snapshot.drawings) == null ? void 0 : _b[blockId];
|
|
627
|
+
if (drawing) {
|
|
628
|
+
const id = Tools.generateRandomId(6);
|
|
629
|
+
block.blockId = id, cache.drawings[id] = {
|
|
630
|
+
...Tools.deepClone(drawing),
|
|
631
|
+
drawingId: id
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
copyContentCache.set(copyId, cache);
|
|
637
|
+
}
|
|
638
|
+
return this._clipboardInterfaceService.write(text, html);
|
|
602
639
|
}
|
|
603
640
|
addClipboardHook(hook) {
|
|
604
641
|
return this._clipboardHooks.push(hook), toDisposable(() => {
|
|
@@ -612,46 +649,41 @@ let DocClipboardService = (_a = class extends Disposable {
|
|
|
612
649
|
const docDataModel = this._univerInstanceService.getCurrentUniverDocInstance(), allRanges = this._textSelectionManagerService.getDocRanges(), results = [];
|
|
613
650
|
let needCache = !0;
|
|
614
651
|
if (docDataModel == null || allRanges.length === 0)
|
|
652
|
+
return;
|
|
653
|
+
const segmentId = allRanges[0].segmentId, body = (_a22 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a22.getBody(), snapshot = docDataModel.getSnapshot();
|
|
654
|
+
if (body != null) {
|
|
655
|
+
for (const range of allRanges) {
|
|
656
|
+
const { startOffset, endOffset, collapsed, rangeType } = range;
|
|
657
|
+
if (collapsed || startOffset == null || endOffset == null)
|
|
658
|
+
continue;
|
|
659
|
+
if (rangeType === DOC_RANGE_TYPE.RECT) {
|
|
660
|
+
needCache = !1;
|
|
661
|
+
const { spanEntireRow } = range;
|
|
662
|
+
let bodySlice;
|
|
663
|
+
bodySlice = getTableSlice(body, startOffset, endOffset), results.push(bodySlice);
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
const deleteRange = getDeleteSelection({ startOffset, endOffset, collapsed }, body), docBody = docDataModel.getSelfOrHeaderFooterModel(segmentId).sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
|
|
667
|
+
if (docBody != null) {
|
|
668
|
+
if (docBody.customRanges) {
|
|
669
|
+
const deleteRange2 = [];
|
|
670
|
+
docBody.customRanges.forEach((range2) => {
|
|
671
|
+
range2.startIndex === range2.endIndex && deleteRange2.push(range2);
|
|
672
|
+
}), docBody.customRanges = docBody.customRanges.filter((range2) => deleteRange2.indexOf(range2) === -1);
|
|
673
|
+
let text = "", cursor = 0;
|
|
674
|
+
deleteRange2.forEach((range2) => {
|
|
675
|
+
text += docBody.dataStream.slice(cursor, range2.endIndex), cursor = range2.endIndex + 1;
|
|
676
|
+
}), text += docBody.dataStream.slice(cursor, docBody.dataStream.length), docBody.dataStream = text;
|
|
677
|
+
}
|
|
678
|
+
results.push(docBody);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
615
681
|
return {
|
|
616
682
|
bodyList: results,
|
|
617
|
-
needCache
|
|
618
|
-
|
|
619
|
-
const segmentId = allRanges[0].segmentId, body = (_a22 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a22.getBody();
|
|
620
|
-
if (body == null)
|
|
621
|
-
return {
|
|
622
|
-
bodyList: results,
|
|
623
|
-
needCache
|
|
683
|
+
needCache,
|
|
684
|
+
snapshot
|
|
624
685
|
};
|
|
625
|
-
for (const range of allRanges) {
|
|
626
|
-
const { startOffset, endOffset, collapsed, rangeType } = range;
|
|
627
|
-
if (collapsed || startOffset == null || endOffset == null)
|
|
628
|
-
continue;
|
|
629
|
-
if (rangeType === DOC_RANGE_TYPE.RECT) {
|
|
630
|
-
needCache = !1;
|
|
631
|
-
const { spanEntireRow } = range;
|
|
632
|
-
let bodySlice;
|
|
633
|
-
bodySlice = getTableSlice(body, startOffset, endOffset), results.push(bodySlice);
|
|
634
|
-
continue;
|
|
635
|
-
}
|
|
636
|
-
const deleteRange = getDeleteSelection({ startOffset, endOffset, collapsed }, body), docBody = docDataModel.getSelfOrHeaderFooterModel(segmentId).sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
|
|
637
|
-
if (docBody != null) {
|
|
638
|
-
if (docBody.customRanges) {
|
|
639
|
-
const deleteRange2 = [];
|
|
640
|
-
docBody.customRanges.forEach((range2) => {
|
|
641
|
-
range2.startIndex === range2.endIndex && deleteRange2.push(range2);
|
|
642
|
-
}), docBody.customRanges = docBody.customRanges.filter((range2) => deleteRange2.indexOf(range2) === -1);
|
|
643
|
-
let text = "", cursor = 0;
|
|
644
|
-
deleteRange2.forEach((range2) => {
|
|
645
|
-
text += docBody.dataStream.slice(cursor, range2.endIndex), cursor = range2.endIndex + 1;
|
|
646
|
-
}), text += docBody.dataStream.slice(cursor, docBody.dataStream.length), docBody.dataStream = text;
|
|
647
|
-
}
|
|
648
|
-
results.push(docBody);
|
|
649
|
-
}
|
|
650
686
|
}
|
|
651
|
-
return {
|
|
652
|
-
bodyList: results,
|
|
653
|
-
needCache
|
|
654
|
-
};
|
|
655
687
|
}
|
|
656
688
|
async _genDocDataFromClipboardItems(items) {
|
|
657
689
|
try {
|
|
@@ -1938,8 +1970,10 @@ function BoldMenuItemFactory(accessor) {
|
|
|
1938
1970
|
const id = c.id;
|
|
1939
1971
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1940
1972
|
const textRun = getFontStyleAtCursor(accessor);
|
|
1941
|
-
if (textRun == null)
|
|
1973
|
+
if (textRun == null) {
|
|
1974
|
+
subscriber.next(!1);
|
|
1942
1975
|
return;
|
|
1976
|
+
}
|
|
1943
1977
|
const bl = (_a22 = textRun.ts) == null ? void 0 : _a22.bl;
|
|
1944
1978
|
subscriber.next(bl === BooleanNumber.TRUE);
|
|
1945
1979
|
}
|
|
@@ -1967,8 +2001,10 @@ function ItalicMenuItemFactory(accessor) {
|
|
|
1967
2001
|
const id = c.id;
|
|
1968
2002
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1969
2003
|
const textRun = getFontStyleAtCursor(accessor);
|
|
1970
|
-
if (textRun == null)
|
|
2004
|
+
if (textRun == null) {
|
|
2005
|
+
subscriber.next(!1);
|
|
1971
2006
|
return;
|
|
2007
|
+
}
|
|
1972
2008
|
const it = (_a22 = textRun.ts) == null ? void 0 : _a22.it;
|
|
1973
2009
|
subscriber.next(it === BooleanNumber.TRUE);
|
|
1974
2010
|
}
|
|
@@ -1996,8 +2032,10 @@ function UnderlineMenuItemFactory(accessor) {
|
|
|
1996
2032
|
const id = c.id;
|
|
1997
2033
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
1998
2034
|
const textRun = getFontStyleAtCursor(accessor);
|
|
1999
|
-
if (textRun == null)
|
|
2035
|
+
if (textRun == null) {
|
|
2036
|
+
subscriber.next(!1);
|
|
2000
2037
|
return;
|
|
2038
|
+
}
|
|
2001
2039
|
const ul = (_a22 = textRun.ts) == null ? void 0 : _a22.ul;
|
|
2002
2040
|
subscriber.next((ul == null ? void 0 : ul.s) === BooleanNumber.TRUE);
|
|
2003
2041
|
}
|
|
@@ -2025,8 +2063,10 @@ function StrikeThroughMenuItemFactory(accessor) {
|
|
|
2025
2063
|
const id = c.id;
|
|
2026
2064
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
2027
2065
|
const textRun = getFontStyleAtCursor(accessor);
|
|
2028
|
-
if (textRun == null)
|
|
2066
|
+
if (textRun == null) {
|
|
2067
|
+
subscriber.next(!1);
|
|
2029
2068
|
return;
|
|
2069
|
+
}
|
|
2030
2070
|
const st = (_a22 = textRun.ts) == null ? void 0 : _a22.st;
|
|
2031
2071
|
subscriber.next((st == null ? void 0 : st.s) === BooleanNumber.TRUE);
|
|
2032
2072
|
}
|
|
@@ -2053,8 +2093,10 @@ function SubscriptMenuItemFactory(accessor) {
|
|
|
2053
2093
|
const id = c.id;
|
|
2054
2094
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
2055
2095
|
const textRun = getFontStyleAtCursor(accessor);
|
|
2056
|
-
if (textRun == null)
|
|
2096
|
+
if (textRun == null) {
|
|
2097
|
+
subscriber.next(!1);
|
|
2057
2098
|
return;
|
|
2099
|
+
}
|
|
2058
2100
|
const va = (_a22 = textRun.ts) == null ? void 0 : _a22.va;
|
|
2059
2101
|
subscriber.next(va === BaselineOffset.SUBSCRIPT);
|
|
2060
2102
|
}
|
|
@@ -2081,8 +2123,10 @@ function SuperscriptMenuItemFactory(accessor) {
|
|
|
2081
2123
|
const id = c.id;
|
|
2082
2124
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
|
|
2083
2125
|
const textRun = getFontStyleAtCursor(accessor);
|
|
2084
|
-
if (textRun == null)
|
|
2126
|
+
if (textRun == null) {
|
|
2127
|
+
subscriber.next(!1);
|
|
2085
2128
|
return;
|
|
2129
|
+
}
|
|
2086
2130
|
const va = (_a22 = textRun.ts) == null ? void 0 : _a22.va;
|
|
2087
2131
|
subscriber.next(va === BaselineOffset.SUPERSCRIPT);
|
|
2088
2132
|
}
|
|
@@ -2117,8 +2161,10 @@ function FontFamilySelectorMenuItemFactory(accessor) {
|
|
|
2117
2161
|
const id = c.id;
|
|
2118
2162
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatFontFamilyCommand.id) {
|
|
2119
2163
|
const textRun = getFontStyleAtCursor(accessor);
|
|
2120
|
-
if (textRun == null)
|
|
2164
|
+
if (textRun == null) {
|
|
2165
|
+
subscriber.next(defaultValue);
|
|
2121
2166
|
return;
|
|
2167
|
+
}
|
|
2122
2168
|
const ff = (_a22 = textRun.ts) == null ? void 0 : _a22.ff;
|
|
2123
2169
|
subscriber.next(ff != null ? ff : defaultValue);
|
|
2124
2170
|
}
|
|
@@ -2154,8 +2200,10 @@ function FontSizeSelectorMenuItemFactory(accessor) {
|
|
|
2154
2200
|
const id = c.id;
|
|
2155
2201
|
if (id === SetTextSelectionsOperation.id || id === SetInlineFormatFontSizeCommand.id) {
|
|
2156
2202
|
const textRun = getFontStyleAtCursor(accessor);
|
|
2157
|
-
if (textRun == null)
|
|
2203
|
+
if (textRun == null) {
|
|
2204
|
+
subscriber.next(14);
|
|
2158
2205
|
return;
|
|
2206
|
+
}
|
|
2159
2207
|
const fs = (_a22 = textRun.ts) == null ? void 0 : _a22.fs;
|
|
2160
2208
|
subscriber.next(fs != null ? fs : 14);
|
|
2161
2209
|
}
|
|
@@ -2486,12 +2534,8 @@ function getFontStyleAtCursor(accessor) {
|
|
|
2486
2534
|
if (textRuns == null)
|
|
2487
2535
|
return;
|
|
2488
2536
|
let textRun;
|
|
2489
|
-
for (let i =
|
|
2490
|
-
const curTextRun = textRuns[i]
|
|
2491
|
-
if (nextTextRun && nextTextRun.st === nextTextRun.ed && startOffset === nextTextRun.st) {
|
|
2492
|
-
textRun = nextTextRun;
|
|
2493
|
-
break;
|
|
2494
|
-
}
|
|
2537
|
+
for (let i = textRuns.length - 1; i >= 0; i--) {
|
|
2538
|
+
const curTextRun = textRuns[i];
|
|
2495
2539
|
if (curTextRun.st <= startOffset && startOffset <= curTextRun.ed) {
|
|
2496
2540
|
textRun = curTextRun;
|
|
2497
2541
|
break;
|
|
@@ -2522,6 +2566,10 @@ function whenDocOrEditor(contextService) {
|
|
|
2522
2566
|
return contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED);
|
|
2523
2567
|
}
|
|
2524
2568
|
__name(whenDocOrEditor, "whenDocOrEditor");
|
|
2569
|
+
function whenFocusEditor(contextService) {
|
|
2570
|
+
return contextService.getContextValue(EDITOR_ACTIVATED);
|
|
2571
|
+
}
|
|
2572
|
+
__name(whenFocusEditor, "whenFocusEditor");
|
|
2525
2573
|
const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
2526
2574
|
id: CopyCommand.id,
|
|
2527
2575
|
name: "doc.command.copy",
|
|
@@ -3183,8 +3231,10 @@ let DocClipboardController = (_a8 = class extends RxDisposable {
|
|
|
3183
3231
|
if (!whenDocOrEditor(this._contextService))
|
|
3184
3232
|
return;
|
|
3185
3233
|
config.event.preventDefault();
|
|
3186
|
-
const clipboardEvent = config.event
|
|
3187
|
-
|
|
3234
|
+
const clipboardEvent = config.event;
|
|
3235
|
+
let htmlContent = (_a23 = clipboardEvent.clipboardData) == null ? void 0 : _a23.getData("text/html");
|
|
3236
|
+
const textContent = (_b = clipboardEvent.clipboardData) == null ? void 0 : _b.getData("text/plain");
|
|
3237
|
+
whenFocusEditor(this._contextService) && (htmlContent != null ? htmlContent : "").indexOf("</table>") > -1 && (htmlContent = ""), this._docClipboardService.legacyPaste(htmlContent, textContent);
|
|
3188
3238
|
});
|
|
3189
3239
|
}
|
|
3190
3240
|
}, __name(_a8, "DocClipboardController"), _a8);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IContextService, IMultiCommand } from '@univerjs/core';
|
|
2
2
|
export declare function whenDocOrEditor(contextService: IContextService): boolean;
|
|
3
|
+
export declare function whenFocusEditor(contextService: IContextService): boolean;
|
|
3
4
|
export declare const DocCopyCommand: IMultiCommand;
|
|
4
5
|
export declare const DocCutCommand: IMultiCommand;
|
|
5
6
|
export declare const DocPasteCommand: IMultiCommand;
|