@ones-editor/editor 3.0.1-beta.8 → 3.0.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -8948,7 +8948,7 @@ div.editor-root.compact.no-heading-collapse.no-block-menu > .editor-content {
|
|
|
8948
8948
|
display: none;
|
|
8949
8949
|
}
|
|
8950
8950
|
.error-info-bar[data-type=error] .content {
|
|
8951
|
-
background:
|
|
8951
|
+
background: #f6f7f9;
|
|
8952
8952
|
color: #575859;
|
|
8953
8953
|
}
|
|
8954
8954
|
.error-info-bar[data-type=warning] .content {
|
|
@@ -24745,6 +24745,15 @@ var __publicField = (obj, key, value) => {
|
|
|
24745
24745
|
}
|
|
24746
24746
|
return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
|
|
24747
24747
|
}
|
|
24748
|
+
function apiResultToDocVersions(versions) {
|
|
24749
|
+
if (Array.isArray(versions)) {
|
|
24750
|
+
return versions.map((v, index2, arr) => ({
|
|
24751
|
+
...v,
|
|
24752
|
+
versionIndex: arr.length - index2
|
|
24753
|
+
}));
|
|
24754
|
+
}
|
|
24755
|
+
return versions;
|
|
24756
|
+
}
|
|
24748
24757
|
const logger$48 = getLogger("create-text-op");
|
|
24749
24758
|
function createTextOp(text2, attributes) {
|
|
24750
24759
|
assert(logger$48, text2, "text is empty");
|
|
@@ -38820,7 +38829,7 @@ ${codeText}
|
|
|
38820
38829
|
const server = this.apiServer();
|
|
38821
38830
|
const api = `${server}/versions?withExtra=true`;
|
|
38822
38831
|
const ret = await this.request(api);
|
|
38823
|
-
const versions = ret.data.versions;
|
|
38832
|
+
const versions = apiResultToDocVersions(ret.data.versions);
|
|
38824
38833
|
versions.forEach((v) => {
|
|
38825
38834
|
if (v.extra) {
|
|
38826
38835
|
v.extra = JSON.parse(v.extra);
|
|
@@ -40695,7 +40704,7 @@ ${codeText}
|
|
|
40695
40704
|
const ret = await this.request(api, {
|
|
40696
40705
|
params
|
|
40697
40706
|
});
|
|
40698
|
-
const versions = ret.data.versions;
|
|
40707
|
+
const versions = apiResultToDocVersions(ret.data.versions);
|
|
40699
40708
|
versions.forEach((v) => {
|
|
40700
40709
|
if (v.extra) {
|
|
40701
40710
|
v.extra = JSON.parse(v.extra);
|
|
@@ -53246,59 +53255,57 @@ ${codeText}
|
|
|
53246
53255
|
async handleBeforePasteDoc(editor, doc2) {
|
|
53247
53256
|
const groupIds = /* @__PURE__ */ new Map();
|
|
53248
53257
|
const startIds = /* @__PURE__ */ new Map();
|
|
53249
|
-
|
|
53250
|
-
|
|
53251
|
-
if (
|
|
53252
|
-
|
|
53253
|
-
|
|
53254
|
-
|
|
53255
|
-
|
|
53256
|
-
|
|
53258
|
+
doc2.blocks.root.forEach((block, index2) => {
|
|
53259
|
+
if (block.type === "list") {
|
|
53260
|
+
if (index2 === 0) {
|
|
53261
|
+
const startBlock = editor.selection.startBlock;
|
|
53262
|
+
if (isListBlock(startBlock)) {
|
|
53263
|
+
const { start, groupId: groupId2, level, type } = getListBlockProperties(startBlock);
|
|
53264
|
+
const newType = getListType(block);
|
|
53265
|
+
const oldGroupId = block.groupId;
|
|
53266
|
+
block.groupId = groupId2;
|
|
53267
|
+
block.start = start;
|
|
53268
|
+
block.level = level;
|
|
53269
|
+
const data2 = makeListBlockTypeData(type);
|
|
53270
|
+
Object.assign(block, data2);
|
|
53271
|
+
if (level === block.level && type === newType) {
|
|
53272
|
+
groupIds.set(oldGroupId, groupId2);
|
|
53273
|
+
startIds.set(groupId2, start);
|
|
53274
|
+
}
|
|
53275
|
+
this.fixStartByList = new FixStartByWillDeletedList(editor, startBlock);
|
|
53276
|
+
return;
|
|
53277
|
+
}
|
|
53278
|
+
const preBlock = getPrevBlock(startBlock);
|
|
53279
|
+
if (preBlock && isListBlock(preBlock)) {
|
|
53280
|
+
const { start, groupId: groupId2, level, type } = getListBlockProperties(preBlock);
|
|
53281
|
+
const newType = getListType(block);
|
|
53282
|
+
if (level === block.level && type === newType) {
|
|
53257
53283
|
const oldGroupId = block.groupId;
|
|
53258
53284
|
block.groupId = groupId2;
|
|
53259
|
-
block.start = start;
|
|
53285
|
+
block.start = start + 1;
|
|
53260
53286
|
block.level = level;
|
|
53261
|
-
|
|
53262
|
-
|
|
53263
|
-
|
|
53264
|
-
groupIds.set(oldGroupId, groupId2);
|
|
53265
|
-
startIds.set(groupId2, start);
|
|
53266
|
-
}
|
|
53267
|
-
this.fixStartByList = new FixStartByWillDeletedList(editor, startBlock);
|
|
53287
|
+
groupIds.set(oldGroupId, groupId2);
|
|
53288
|
+
startIds.set(groupId2, start + 1);
|
|
53289
|
+
this.fixStartByList = new FixStartByWillDeletedList(editor, preBlock);
|
|
53268
53290
|
return;
|
|
53269
53291
|
}
|
|
53270
|
-
const preBlock = getPrevBlock(startBlock);
|
|
53271
|
-
if (preBlock && isListBlock(preBlock)) {
|
|
53272
|
-
const { start, groupId: groupId2, level, type } = getListBlockProperties(preBlock);
|
|
53273
|
-
const newType = getListType(block);
|
|
53274
|
-
if (level === block.level && type === newType) {
|
|
53275
|
-
const oldGroupId = block.groupId;
|
|
53276
|
-
block.groupId = groupId2;
|
|
53277
|
-
block.start = start + 1;
|
|
53278
|
-
block.level = level;
|
|
53279
|
-
groupIds.set(oldGroupId, groupId2);
|
|
53280
|
-
startIds.set(groupId2, start + 1);
|
|
53281
|
-
this.fixStartByList = new FixStartByWillDeletedList(editor, preBlock);
|
|
53282
|
-
return;
|
|
53283
|
-
}
|
|
53284
|
-
}
|
|
53285
|
-
}
|
|
53286
|
-
const groupId = groupIds.get(block.groupId);
|
|
53287
|
-
if (!groupId) {
|
|
53288
|
-
const newGroupId = genId();
|
|
53289
|
-
groupIds.set(block.groupId, newGroupId);
|
|
53290
|
-
block.groupId = newGroupId;
|
|
53291
|
-
block.start = 1;
|
|
53292
|
-
startIds.set(newGroupId, 1);
|
|
53293
|
-
} else {
|
|
53294
|
-
const start = startIds.get(groupId);
|
|
53295
|
-
assert(logger$21, start, "start is null");
|
|
53296
|
-
block.start = start + 1;
|
|
53297
|
-
block.groupId = groupId;
|
|
53298
|
-
startIds.set(groupId, start + 1);
|
|
53299
53292
|
}
|
|
53300
53293
|
}
|
|
53301
|
-
|
|
53294
|
+
const groupId = groupIds.get(block.groupId);
|
|
53295
|
+
if (!groupId) {
|
|
53296
|
+
const newGroupId = genId();
|
|
53297
|
+
groupIds.set(block.groupId, newGroupId);
|
|
53298
|
+
block.groupId = newGroupId;
|
|
53299
|
+
block.start = 1;
|
|
53300
|
+
startIds.set(newGroupId, 1);
|
|
53301
|
+
} else {
|
|
53302
|
+
const start = startIds.get(groupId);
|
|
53303
|
+
assert(logger$21, start, "start is null");
|
|
53304
|
+
block.start = start + 1;
|
|
53305
|
+
block.groupId = groupId;
|
|
53306
|
+
startIds.set(groupId, start + 1);
|
|
53307
|
+
}
|
|
53308
|
+
}
|
|
53302
53309
|
});
|
|
53303
53310
|
return false;
|
|
53304
53311
|
}
|
|
@@ -67331,6 +67338,7 @@ ${codeText}
|
|
|
67331
67338
|
});
|
|
67332
67339
|
editor.addListener("blur", this.removePlaceholder);
|
|
67333
67340
|
editor.addListener("focus", this.applyPlaceholder);
|
|
67341
|
+
editor.blockHooks.push(this);
|
|
67334
67342
|
}
|
|
67335
67343
|
destroy(editor) {
|
|
67336
67344
|
editor.removeListener("selectionChanged", this.handleSelectionChange);
|
|
@@ -67415,6 +67423,11 @@ ${codeText}
|
|
|
67415
67423
|
handleUpdateCompositionText(editor) {
|
|
67416
67424
|
this.applyPlaceholder(editor);
|
|
67417
67425
|
}
|
|
67426
|
+
update(editor, path, container, blockElement, blockData) {
|
|
67427
|
+
if (path.length === 1 && this.isDocumentTitleBlock(path[0].containerId, path[0].blockIndex)) {
|
|
67428
|
+
blockElement.setAttribute("data-document-title", "");
|
|
67429
|
+
}
|
|
67430
|
+
}
|
|
67418
67431
|
removePlaceholder(editor) {
|
|
67419
67432
|
removeAllPlaceholders(editor);
|
|
67420
67433
|
}
|
|
@@ -75476,6 +75489,11 @@ ${codeText}
|
|
|
75476
75489
|
});
|
|
75477
75490
|
});
|
|
75478
75491
|
__publicField(this, "handleClose", () => {
|
|
75492
|
+
const activeElem = document.activeElement;
|
|
75493
|
+
const tagName = activeElem ? activeElem.tagName.toLowerCase() : "";
|
|
75494
|
+
if (tagName === "input" || tagName === "textarea") {
|
|
75495
|
+
return;
|
|
75496
|
+
}
|
|
75479
75497
|
this.editor.focus();
|
|
75480
75498
|
});
|
|
75481
75499
|
__publicField(this, "handleSelectionChange", () => {
|
|
@@ -78865,14 +78883,13 @@ ${docStr}
|
|
|
78865
78883
|
insertIndex += 1;
|
|
78866
78884
|
} else {
|
|
78867
78885
|
editor.clearSelectedContents();
|
|
78868
|
-
const { blockId } = editor.selection.range.start;
|
|
78886
|
+
const { blockId, offset } = editor.selection.range.start;
|
|
78869
78887
|
const block = editor.getBlockById(blockId);
|
|
78870
78888
|
insertIndex = getBlockIndex(block);
|
|
78871
78889
|
container = getParentContainer(block);
|
|
78872
|
-
if (!isEmptyTextBlock(editor, block)) {
|
|
78890
|
+
if (!isEmptyTextBlock(editor, block) && offset > 0) {
|
|
78873
78891
|
insertIndex += 1;
|
|
78874
|
-
}
|
|
78875
|
-
if (isRootContainer(container) && insertIndex === 0) {
|
|
78892
|
+
} else if (isRootContainer(container) && insertIndex === 0 && isTitleBlock$2(block)) {
|
|
78876
78893
|
insertIndex += 1;
|
|
78877
78894
|
}
|
|
78878
78895
|
}
|
|
@@ -81583,6 +81600,9 @@ ${docStr}
|
|
|
81583
81600
|
var _a;
|
|
81584
81601
|
let name;
|
|
81585
81602
|
if (ver.version !== -1) {
|
|
81603
|
+
if (typeof ver.versionIndex === "number") {
|
|
81604
|
+
return `v${ver.versionIndex}`;
|
|
81605
|
+
}
|
|
81586
81606
|
const date = new Date((_a = ver.created) != null ? _a : ver.version);
|
|
81587
81607
|
name = formatDate(date, "YYYY-MM-DD hh:mm");
|
|
81588
81608
|
} else {
|
|
@@ -81890,11 +81910,6 @@ ${docStr}
|
|
|
81890
81910
|
};
|
|
81891
81911
|
versions.forEach((ver, index2) => {
|
|
81892
81912
|
addVersion(ver, false, versions, ver.created === this.options.versions[0].created);
|
|
81893
|
-
if (ver.minorVersions && ver.minorVersions.length > 0) {
|
|
81894
|
-
ver.minorVersions.forEach((v) => {
|
|
81895
|
-
addVersion(v, true, versions, false);
|
|
81896
|
-
});
|
|
81897
|
-
}
|
|
81898
81913
|
});
|
|
81899
81914
|
return versionListFragment;
|
|
81900
81915
|
}
|
|
@@ -81956,6 +81971,16 @@ ${docStr}
|
|
|
81956
81971
|
}
|
|
81957
81972
|
}
|
|
81958
81973
|
getVersionItemByVersionNum(version) {
|
|
81974
|
+
if (typeof version === "string" && version.startsWith("v")) {
|
|
81975
|
+
const index2 = Number.parseInt(version.substring(1), 10);
|
|
81976
|
+
const versionItem2 = Array.from(this.versionsList.children).find(
|
|
81977
|
+
(e2) => e2.versionData.versionIndex === index2
|
|
81978
|
+
);
|
|
81979
|
+
if (this.isVersionElement(versionItem2)) {
|
|
81980
|
+
return versionItem2;
|
|
81981
|
+
}
|
|
81982
|
+
return null;
|
|
81983
|
+
}
|
|
81959
81984
|
const versionItem = Array.from(this.versionsList.children).find(
|
|
81960
81985
|
(e2) => e2.versionData.version.toString() === `${version}`
|
|
81961
81986
|
);
|
|
@@ -83358,7 +83383,10 @@ ${docStr}
|
|
|
83358
83383
|
const versionList2 = new VersionList({
|
|
83359
83384
|
enableEdit: ((_a = this.versionOptions) == null ? void 0 : _a.enableEdit) || false,
|
|
83360
83385
|
getDisabledTip: (_b = this.versionOptions) == null ? void 0 : _b.getDisabledTip,
|
|
83361
|
-
versions,
|
|
83386
|
+
versions: versions.map((i, index2, arr) => ({
|
|
83387
|
+
...i,
|
|
83388
|
+
versionIndex: arr.length - index2
|
|
83389
|
+
})),
|
|
83362
83390
|
versionHelper: this.versionHelper,
|
|
83363
83391
|
useCreatedBy: (_c = this.versionOptions) == null ? void 0 : _c.useCreatedBy,
|
|
83364
83392
|
onSelectVersion: this.handleSelectVersion,
|
|
@@ -91418,7 +91446,7 @@ ${data2.plantumlText}
|
|
|
91418
91446
|
})(ReservedMediaSrcType || {});
|
|
91419
91447
|
const DefaultMaxSize = 10 * 1024 * 1024;
|
|
91420
91448
|
const DefaultAudioExt = ["wav", "mp3", "aac", "ogg", "webm", "flac"];
|
|
91421
|
-
const DefaultVideoExt = ["ogg", "mp4", "webm"];
|
|
91449
|
+
const DefaultVideoExt = ["ogg", "mp4", "webm", "mov", "avi"];
|
|
91422
91450
|
const noop = () => {
|
|
91423
91451
|
};
|
|
91424
91452
|
function getMediaOptionsFromEditor(editor) {
|
|
@@ -93376,7 +93404,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
93376
93404
|
return void 0;
|
|
93377
93405
|
}
|
|
93378
93406
|
function inlineStyleFontFamily(text2) {
|
|
93379
|
-
return
|
|
93407
|
+
return void 0;
|
|
93380
93408
|
}
|
|
93381
93409
|
function inlineStyleBackgroundColor(text2) {
|
|
93382
93410
|
const color = attributesOfText(text2, "inline-style-background-color");
|
|
@@ -93403,7 +93431,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
93403
93431
|
subScript: !!attributesOfText(text2, "style-sub"),
|
|
93404
93432
|
math: attributesOfText(text2, "type") === "math" ? attributesOfText(text2, "src") : void 0,
|
|
93405
93433
|
mention: isMention,
|
|
93406
|
-
fontFamily: inlineStyleFontFamily(
|
|
93434
|
+
fontFamily: inlineStyleFontFamily(),
|
|
93407
93435
|
background: inlineStyleBackgroundColor(text2),
|
|
93408
93436
|
color: isMention ? "338fe5" : styleColorToColor(attributeOfStyleColor(text2, "style-color-", 6)) || inlineStyleColor(text2),
|
|
93409
93437
|
highlight: attributeOfStyleColor(text2, "style-bg-color-", 13)
|
|
@@ -95960,7 +95988,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
95960
95988
|
}
|
|
95961
95989
|
}
|
|
95962
95990
|
});
|
|
95963
|
-
editor.version = "3.0.
|
|
95991
|
+
editor.version = "3.0.2-beta.1";
|
|
95964
95992
|
return editor;
|
|
95965
95993
|
}
|
|
95966
95994
|
function isDoc(doc2) {
|
|
@@ -96094,7 +96122,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
96094
96122
|
OnesEditorDropTarget.register(editor);
|
|
96095
96123
|
OnesEditorTocProvider.register(editor);
|
|
96096
96124
|
OnesEditorExclusiveBlock.register(editor);
|
|
96097
|
-
editor.version = "3.0.
|
|
96125
|
+
editor.version = "3.0.2-beta.1";
|
|
96098
96126
|
return editor;
|
|
96099
96127
|
}
|
|
96100
96128
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -142186,6 +142214,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
142186
142214
|
exports2.addMonths = addMonths;
|
|
142187
142215
|
exports2.adjustSelectionPos = adjustSelectionPos$1;
|
|
142188
142216
|
exports2.animateScrollTo = animateScrollTo;
|
|
142217
|
+
exports2.apiResultToDocVersions = apiResultToDocVersions;
|
|
142189
142218
|
exports2.applyPlaceholderToBlock = applyPlaceholderToBlock;
|
|
142190
142219
|
exports2.assert = assert;
|
|
142191
142220
|
exports2.autoShowHideTemplates = autoShowHideTemplates;
|