@ones-editor/editor 2.9.8-beta.21 → 2.9.8-beta.23
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/@ones-editor/core/src/core/types.d.ts +1 -0
- package/@ones-editor/list-block/src/index.d.ts +2 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/providers/list.d.ts +1 -1
- package/@ones-editor/ui-base/src/command-bar/command-bar.d.ts +1 -0
- package/@ones-editor/ui-base/src/command-bar/fixed-toolbar.d.ts +1 -0
- package/dist/index.js +121 -22
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ export default class ListProvider implements OnesEditorCommandProvider {
|
|
|
7
7
|
getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams): CommandItem[];
|
|
8
8
|
getInsertCommands(): CommandItem[];
|
|
9
9
|
convertToList(editor: OnesEditor, block: BlockElement, listType: 'unordered' | 'ordered' | 'unchecked'): void;
|
|
10
|
-
insertList(editor: OnesEditor, containerId: string, blockIndex: number, listType: 'unordered' | 'ordered' | 'unchecked'): void;
|
|
10
|
+
insertList(editor: OnesEditor, containerId: string, blockIndex: number, listType: 'unordered' | 'ordered' | 'unchecked', command: CommandItem): void;
|
|
11
11
|
executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItem): boolean;
|
|
12
12
|
executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, command: CommandItem) => boolean;
|
|
13
13
|
}
|
|
@@ -22,6 +22,7 @@ export default abstract class CommandBar extends TypedEmitter<CommandBarEvents>
|
|
|
22
22
|
get isSubCommandBar(): boolean;
|
|
23
23
|
updateItems(items: CommandItem[]): void;
|
|
24
24
|
handleDocumentKeydown: (event: KeyboardEvent) => boolean;
|
|
25
|
+
protected canClose(): boolean;
|
|
25
26
|
protected handleDocumentMouseDown: (event: MouseEvent | TouchEvent) => void;
|
|
26
27
|
protected handleHidden: () => void;
|
|
27
28
|
protected handleShown: () => void;
|
|
@@ -6,6 +6,7 @@ export default class FixedToolbar extends CommandBar {
|
|
|
6
6
|
handleDocumentKeydown: (event: KeyboardEvent) => boolean;
|
|
7
7
|
protected initCommandBarElement(elem: HTMLElement): void;
|
|
8
8
|
protected initItemElement(item: CommandItem, elem: CommandItemElement): void;
|
|
9
|
+
protected canClose(): boolean;
|
|
9
10
|
close(): void;
|
|
10
11
|
getSubBarCreateOptions: (item: CommandItem) => CommandBarOptions;
|
|
11
12
|
getSubBarOptions: (item: CommandItem) => ManualShowCommandBarOptions;
|
package/dist/index.js
CHANGED
|
@@ -28825,10 +28825,19 @@ var __publicField = (obj, key, value) => {
|
|
|
28825
28825
|
});
|
|
28826
28826
|
this.editor = editor;
|
|
28827
28827
|
const block = editor.getFirstBlock();
|
|
28828
|
-
const blockId = getBlockId(block);
|
|
28829
28828
|
this.caret = new EditorCaret(editor);
|
|
28830
|
-
|
|
28831
|
-
|
|
28829
|
+
if (isComplexKindBlock(editor, block)) {
|
|
28830
|
+
const simpleBlock = complexBlockGetFirstSimpleChild(editor, block, {
|
|
28831
|
+
visibleOnly: true
|
|
28832
|
+
}) || block;
|
|
28833
|
+
const blockId = getBlockId(simpleBlock);
|
|
28834
|
+
const pos = createSimpleBlockPosition(blockId, 0, "normal");
|
|
28835
|
+
this._range = createEditorSelectionRange(editor, { anchor: pos, focus: pos });
|
|
28836
|
+
} else {
|
|
28837
|
+
const blockId = getBlockId(block);
|
|
28838
|
+
const pos = createSimpleBlockPosition(blockId, 0, "normal");
|
|
28839
|
+
this._range = createEditorSelectionRange(editor, { anchor: pos, focus: pos });
|
|
28840
|
+
}
|
|
28832
28841
|
this.lastCaretRect = null;
|
|
28833
28842
|
this.editor.addListener("blockDeleted", this.handleBlockDelete);
|
|
28834
28843
|
setTimeout(() => {
|
|
@@ -41411,12 +41420,18 @@ ${codeText}
|
|
|
41411
41420
|
return true;
|
|
41412
41421
|
});
|
|
41413
41422
|
__publicField(this, "handleDocumentMouseDown", (event) => {
|
|
41414
|
-
var _a, _b;
|
|
41423
|
+
var _a, _b, _c;
|
|
41415
41424
|
if (event.target instanceof Element) {
|
|
41416
41425
|
if ((_b = (_a = this.options).beforeClose) == null ? void 0 : _b.call(_a, event)) {
|
|
41417
41426
|
return;
|
|
41418
41427
|
}
|
|
41419
41428
|
if (!this.isInCommandBar(event.target)) {
|
|
41429
|
+
if (((_c = this.canClose) == null ? void 0 : _c.call(this)) === false) {
|
|
41430
|
+
return;
|
|
41431
|
+
}
|
|
41432
|
+
if (!this.isVisible) {
|
|
41433
|
+
return;
|
|
41434
|
+
}
|
|
41420
41435
|
const events2 = this.listeners("closing");
|
|
41421
41436
|
for (let i = 0; i < events2.length; i++) {
|
|
41422
41437
|
if (events2[i](this, event) === false) {
|
|
@@ -41676,6 +41691,9 @@ ${codeText}
|
|
|
41676
41691
|
this.content.appendChild(child);
|
|
41677
41692
|
});
|
|
41678
41693
|
}
|
|
41694
|
+
canClose() {
|
|
41695
|
+
return true;
|
|
41696
|
+
}
|
|
41679
41697
|
get popper() {
|
|
41680
41698
|
return this.content.closest("[data-tippy-root]");
|
|
41681
41699
|
}
|
|
@@ -42702,6 +42720,12 @@ ${codeText}
|
|
|
42702
42720
|
initItemElement(item, elem) {
|
|
42703
42721
|
initToolbarItem(item, elem, this.options);
|
|
42704
42722
|
}
|
|
42723
|
+
canClose() {
|
|
42724
|
+
if (this.subBar) {
|
|
42725
|
+
return true;
|
|
42726
|
+
}
|
|
42727
|
+
return false;
|
|
42728
|
+
}
|
|
42705
42729
|
close() {
|
|
42706
42730
|
this.clearSelectedItem();
|
|
42707
42731
|
if (this.subBar) {
|
|
@@ -43871,6 +43895,9 @@ ${codeText}
|
|
|
43871
43895
|
__publicField(this, "handlePaletteClick", (type, value) => {
|
|
43872
43896
|
this.setLatestColors(type, value);
|
|
43873
43897
|
this.emit("onClick", type, value);
|
|
43898
|
+
setTimeout(() => {
|
|
43899
|
+
this.editor.emit("textColorChanged", this.editor, this);
|
|
43900
|
+
}, 100);
|
|
43874
43901
|
});
|
|
43875
43902
|
__publicField(this, "handleButtonClick", () => {
|
|
43876
43903
|
const [color, backgroundColor] = this.latestColors;
|
|
@@ -43896,6 +43923,9 @@ ${codeText}
|
|
|
43896
43923
|
this.emit("onClick", "backgroundColor", backgroundColor);
|
|
43897
43924
|
}
|
|
43898
43925
|
this.currentTextColors = [color, backgroundColor];
|
|
43926
|
+
setTimeout(() => {
|
|
43927
|
+
this.editor.emit("textColorChanged", this.editor, this);
|
|
43928
|
+
}, 100);
|
|
43899
43929
|
});
|
|
43900
43930
|
__publicField(this, "setLatestColors", (type, value) => {
|
|
43901
43931
|
var _a, _b;
|
|
@@ -43933,6 +43963,13 @@ ${codeText}
|
|
|
43933
43963
|
this.element.addEventListener("click", this.handleButtonClick);
|
|
43934
43964
|
this.bindColorButtonEvents();
|
|
43935
43965
|
this.element.setAttribute(`data-editor-tooltip-${editor.clientId}`, this.name);
|
|
43966
|
+
this.editor.addListener("textColorChanged", (e2, sender) => {
|
|
43967
|
+
if (sender !== this) {
|
|
43968
|
+
this.latestColors = this.getColorsFromLocalStorage();
|
|
43969
|
+
this.setCurrentButtonColor(this.latestColors);
|
|
43970
|
+
this.updatePaletteColor();
|
|
43971
|
+
}
|
|
43972
|
+
});
|
|
43936
43973
|
}
|
|
43937
43974
|
bindColorButtonEvents() {
|
|
43938
43975
|
if (clientType.isMobile) {
|
|
@@ -53197,15 +53234,15 @@ ${codeText}
|
|
|
53197
53234
|
__publicField(this, "id", "ListProvider");
|
|
53198
53235
|
__publicField(this, "executeInsertCommand", (editor, containerId, blockIndex, command) => {
|
|
53199
53236
|
if (command.id === "unordered-list") {
|
|
53200
|
-
this.insertList(editor, containerId, blockIndex, "unordered");
|
|
53237
|
+
this.insertList(editor, containerId, blockIndex, "unordered", command);
|
|
53201
53238
|
return true;
|
|
53202
53239
|
}
|
|
53203
53240
|
if (command.id === "ordered-list") {
|
|
53204
|
-
this.insertList(editor, containerId, blockIndex, "ordered");
|
|
53241
|
+
this.insertList(editor, containerId, blockIndex, "ordered", command);
|
|
53205
53242
|
return true;
|
|
53206
53243
|
}
|
|
53207
53244
|
if (command.id === "check-list") {
|
|
53208
|
-
this.insertList(editor, containerId, blockIndex, "unchecked");
|
|
53245
|
+
this.insertList(editor, containerId, blockIndex, "unchecked", command);
|
|
53209
53246
|
return true;
|
|
53210
53247
|
}
|
|
53211
53248
|
return false;
|
|
@@ -53288,21 +53325,66 @@ ${codeText}
|
|
|
53288
53325
|
});
|
|
53289
53326
|
}
|
|
53290
53327
|
}
|
|
53291
|
-
insertList(editor, containerId, blockIndex, listType) {
|
|
53328
|
+
insertList(editor, containerId, blockIndex, listType, command) {
|
|
53292
53329
|
var _a;
|
|
53293
|
-
|
|
53294
|
-
|
|
53295
|
-
|
|
53330
|
+
editor.getChildContainerData(containerId);
|
|
53331
|
+
let sourceIndex = blockIndex;
|
|
53332
|
+
let insertBefore = true;
|
|
53333
|
+
if (((_a = command.source) == null ? void 0 : _a.indexOf("/insert-block-after")) !== -1) {
|
|
53334
|
+
insertBefore = false;
|
|
53335
|
+
if (blockIndex > 0) {
|
|
53336
|
+
sourceIndex = blockIndex - 1;
|
|
53337
|
+
}
|
|
53338
|
+
}
|
|
53339
|
+
const currentBlock = editor.findBlockByIndex(containerId, sourceIndex);
|
|
53340
|
+
if (!currentBlock) {
|
|
53341
|
+
return;
|
|
53342
|
+
}
|
|
53343
|
+
const convertResult = convertBlockFrom(editor, currentBlock, "list", {
|
|
53296
53344
|
offset: 0,
|
|
53297
53345
|
data: {
|
|
53298
53346
|
listType
|
|
53299
53347
|
}
|
|
53300
53348
|
});
|
|
53301
|
-
|
|
53302
|
-
|
|
53303
|
-
|
|
53304
|
-
|
|
53349
|
+
const newData = convertResult == null ? void 0 : convertResult.blockData;
|
|
53350
|
+
if (!newData) {
|
|
53351
|
+
return;
|
|
53352
|
+
}
|
|
53353
|
+
const oldData = editor.getBlockData(currentBlock);
|
|
53354
|
+
const oldType = getListType(oldData);
|
|
53355
|
+
const newType = getListType(newData);
|
|
53356
|
+
if (oldType === newType) {
|
|
53357
|
+
if (typeof newData.start === "number") {
|
|
53358
|
+
if (typeof oldData.start === "number") {
|
|
53359
|
+
if (insertBefore) {
|
|
53360
|
+
newData.start = oldData.start - 1;
|
|
53361
|
+
} else {
|
|
53362
|
+
newData.start = oldData.start + 1;
|
|
53363
|
+
}
|
|
53364
|
+
} else {
|
|
53365
|
+
if (insertBefore) {
|
|
53366
|
+
newData.start -= 1;
|
|
53367
|
+
} else {
|
|
53368
|
+
newData.start += 1;
|
|
53369
|
+
}
|
|
53370
|
+
}
|
|
53371
|
+
}
|
|
53372
|
+
if (typeof newData.start === "number" && newData.start <= 0) {
|
|
53373
|
+
newData.start = 1;
|
|
53374
|
+
}
|
|
53375
|
+
newData.groupId = oldData.groupId;
|
|
53376
|
+
}
|
|
53377
|
+
newData.text = [];
|
|
53378
|
+
if (oldType === newType) {
|
|
53379
|
+
newData.heading = oldData.heading;
|
|
53380
|
+
} else {
|
|
53381
|
+
delete newData.heading;
|
|
53305
53382
|
}
|
|
53383
|
+
editor.undoManager.runInGroup(() => {
|
|
53384
|
+
const newBlock = editor.insertBlock(containerId, blockIndex, newData);
|
|
53385
|
+
const fix = new FixStartByList(editor, newBlock);
|
|
53386
|
+
fix.fix();
|
|
53387
|
+
});
|
|
53306
53388
|
}
|
|
53307
53389
|
executeCommand(editor, block, range, command) {
|
|
53308
53390
|
if (!isTextKindBlock(editor, block)) {
|
|
@@ -64261,7 +64343,7 @@ $$${mathData.mathjaxText}$$
|
|
|
64261
64343
|
const failedLoad = !!block.querySelector(".images > .image-container.error, .images > .image-container.empty ");
|
|
64262
64344
|
const width = calImageBlockStyleWidth(editor, blockData, parentContainer, failedLoad);
|
|
64263
64345
|
const height = calBlockHeight(editor, blockData, parentContainer, failedLoad);
|
|
64264
|
-
if (width.startsWith("0")
|
|
64346
|
+
if (width.startsWith("0") || height.startsWith("0")) {
|
|
64265
64347
|
const image = block.querySelector("img");
|
|
64266
64348
|
if (image) {
|
|
64267
64349
|
image.onload = () => {
|
|
@@ -94125,9 +94207,11 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
94125
94207
|
Heading3Icon,
|
|
94126
94208
|
Heading4Icon,
|
|
94127
94209
|
Heading5Icon,
|
|
94128
|
-
Heading6Icon
|
|
94210
|
+
Heading6Icon,
|
|
94211
|
+
Heading7Icon,
|
|
94212
|
+
Heading8Icon
|
|
94129
94213
|
];
|
|
94130
|
-
for (let i = 1; i <=
|
|
94214
|
+
for (let i = 1; i <= 8; i++) {
|
|
94131
94215
|
this.children.push({
|
|
94132
94216
|
name: i18n$1.t("commands.heading", { name: `${i}` }),
|
|
94133
94217
|
id: `heading-${i}`,
|
|
@@ -94362,6 +94446,8 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
94362
94446
|
event.stopPropagation();
|
|
94363
94447
|
});
|
|
94364
94448
|
this.provider = new ColorStyleProvider(editor);
|
|
94449
|
+
this.latestColors = this.getColorsFromLocalStorage();
|
|
94450
|
+
this.setCurrentButtonColor(this.latestColors);
|
|
94365
94451
|
this.addListener("onClick", this.handleChangeColor);
|
|
94366
94452
|
this.element.addEventListener("mousedown", this.handleMousedown);
|
|
94367
94453
|
}
|
|
@@ -94529,7 +94615,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
94529
94615
|
async onClick(editor, item) {
|
|
94530
94616
|
const block = editor.getBlockById(editor.selection.range.start.blockId);
|
|
94531
94617
|
const container = editor.getParentContainer(block);
|
|
94532
|
-
|
|
94618
|
+
let index2 = editor.getBlockIndex(block);
|
|
94533
94619
|
const file2 = await selectFile("*");
|
|
94534
94620
|
if (!file2) {
|
|
94535
94621
|
return;
|
|
@@ -94547,7 +94633,14 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
94547
94633
|
creator: editor.doc.getUser().displayName,
|
|
94548
94634
|
previewType: FilePreviewType.Card
|
|
94549
94635
|
};
|
|
94550
|
-
|
|
94636
|
+
if (!isEmptyTextBlock(editor, block)) {
|
|
94637
|
+
index2 += 1;
|
|
94638
|
+
}
|
|
94639
|
+
const embedBlock = editor.insertEmbed(getContainerId(container), index2, "office", data2);
|
|
94640
|
+
const nextBlock = getNextBlock(embedBlock);
|
|
94641
|
+
if (nextBlock && isTextKindBlock(editor, nextBlock)) {
|
|
94642
|
+
editor.selection.selectBlock(nextBlock, 0);
|
|
94643
|
+
}
|
|
94551
94644
|
}
|
|
94552
94645
|
}
|
|
94553
94646
|
class InsertMentionItem {
|
|
@@ -94741,6 +94834,12 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
94741
94834
|
tooltipId: editor.clientId,
|
|
94742
94835
|
id: "main-toolbar"
|
|
94743
94836
|
});
|
|
94837
|
+
this.toolbar.addListener("closing", () => {
|
|
94838
|
+
setTimeout(() => {
|
|
94839
|
+
editor.focus();
|
|
94840
|
+
}, 100);
|
|
94841
|
+
return true;
|
|
94842
|
+
});
|
|
94744
94843
|
this.toolbar.addListener("click", this.handleClick);
|
|
94745
94844
|
this.editor.addListener("selectionChanged", this.handleSelectionChanged);
|
|
94746
94845
|
this.updateState();
|
|
@@ -95365,7 +95464,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
95365
95464
|
}
|
|
95366
95465
|
}
|
|
95367
95466
|
});
|
|
95368
|
-
editor.version = "2.9.8-beta.
|
|
95467
|
+
editor.version = "2.9.8-beta.23";
|
|
95369
95468
|
return editor;
|
|
95370
95469
|
}
|
|
95371
95470
|
function isDoc(doc2) {
|
|
@@ -95497,7 +95596,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
95497
95596
|
OnesEditorDropTarget.register(editor);
|
|
95498
95597
|
OnesEditorTocProvider.register(editor);
|
|
95499
95598
|
OnesEditorExclusiveBlock.register(editor);
|
|
95500
|
-
editor.version = "2.9.8-beta.
|
|
95599
|
+
editor.version = "2.9.8-beta.23";
|
|
95501
95600
|
return editor;
|
|
95502
95601
|
}
|
|
95503
95602
|
async function showDocVersions(editor, options, serverUrl) {
|