@ones-editor/editor 1.1.30-beta.7 → 1.1.31-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
|
@@ -8239,27 +8239,66 @@ var __publicField = (obj, key, value) => {
|
|
|
8239
8239
|
reader.readAsText(blob);
|
|
8240
8240
|
});
|
|
8241
8241
|
}
|
|
8242
|
+
function select(element) {
|
|
8243
|
+
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
|
|
8244
|
+
element.select();
|
|
8245
|
+
} else {
|
|
8246
|
+
const selection = window.getSelection();
|
|
8247
|
+
const range = document.createRange();
|
|
8248
|
+
range.selectNodeContents(element);
|
|
8249
|
+
selection == null ? void 0 : selection.removeAllRanges();
|
|
8250
|
+
selection == null ? void 0 : selection.addRange(range);
|
|
8251
|
+
}
|
|
8252
|
+
}
|
|
8253
|
+
async function copyTextToClipboard(text2) {
|
|
8254
|
+
const textarea2 = document.createElement("textarea");
|
|
8255
|
+
try {
|
|
8256
|
+
if (text2 instanceof Blob) {
|
|
8257
|
+
text2 = await readBlob(text2);
|
|
8258
|
+
}
|
|
8259
|
+
textarea2.textContent = text2 != null ? text2 : "";
|
|
8260
|
+
textarea2.style.position = "fixed";
|
|
8261
|
+
textarea2.style.opacity = "0";
|
|
8262
|
+
document.body.appendChild(textarea2);
|
|
8263
|
+
select(textarea2);
|
|
8264
|
+
document.execCommand("copy");
|
|
8265
|
+
document.body.removeChild(textarea2);
|
|
8266
|
+
return true;
|
|
8267
|
+
} catch (ex) {
|
|
8268
|
+
logger$4g.error(ex);
|
|
8269
|
+
document.body.removeChild(textarea2);
|
|
8270
|
+
return false;
|
|
8271
|
+
}
|
|
8272
|
+
}
|
|
8273
|
+
async function copyHtmlToClipboard(html) {
|
|
8274
|
+
const div = document.createElement("div");
|
|
8275
|
+
try {
|
|
8276
|
+
if (html instanceof Blob) {
|
|
8277
|
+
html = await readBlob(html);
|
|
8278
|
+
}
|
|
8279
|
+
div.style.position = "fixed";
|
|
8280
|
+
div.style.opacity = "0";
|
|
8281
|
+
const body = /<body[^>]*>([\s\S]*)<\/body>/.exec(html != null ? html : "");
|
|
8282
|
+
div.innerHTML = body ? body[1] : html != null ? html : "";
|
|
8283
|
+
document.body.appendChild(div);
|
|
8284
|
+
select(div);
|
|
8285
|
+
document.execCommand("copy");
|
|
8286
|
+
document.body.removeChild(div);
|
|
8287
|
+
return true;
|
|
8288
|
+
} catch (ex) {
|
|
8289
|
+
logger$4g.error(ex);
|
|
8290
|
+
document.body.removeChild(div);
|
|
8291
|
+
return false;
|
|
8292
|
+
}
|
|
8293
|
+
}
|
|
8242
8294
|
async function execCommandCopy(items) {
|
|
8243
|
-
var _a;
|
|
8244
8295
|
if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
|
|
8245
|
-
const
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
}
|
|
8251
|
-
textarea2.textContent = text2 != null ? text2 : "";
|
|
8252
|
-
textarea2.style.position = "fixed";
|
|
8253
|
-
textarea2.style.opacity = "0";
|
|
8254
|
-
document.body.appendChild(textarea2);
|
|
8255
|
-
textarea2.select();
|
|
8256
|
-
document.execCommand("copy");
|
|
8257
|
-
document.body.removeChild(textarea2);
|
|
8258
|
-
return true;
|
|
8259
|
-
} catch (ex) {
|
|
8260
|
-
logger$4g.error(ex);
|
|
8261
|
-
document.body.removeChild(textarea2);
|
|
8262
|
-
return false;
|
|
8296
|
+
for (const item of [["text/html", copyHtmlToClipboard], ["text/plain", copyTextToClipboard]]) {
|
|
8297
|
+
const data = items.find((it) => it.type === item[0]);
|
|
8298
|
+
if (data) {
|
|
8299
|
+
const fn = item[1];
|
|
8300
|
+
return fn(data.data);
|
|
8301
|
+
}
|
|
8263
8302
|
}
|
|
8264
8303
|
}
|
|
8265
8304
|
return false;
|
|
@@ -25967,7 +26006,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25967
26006
|
}
|
|
25968
26007
|
function injectDocToHtmlFragment(htmlFragment, doc2) {
|
|
25969
26008
|
if (clientType.isFirefox) {
|
|
25970
|
-
return `<!doctype html><html><head><meta charset="utf8" /></head><body><
|
|
26009
|
+
return `<!doctype html><html><head><meta charset="utf8" /></head><body><span data-editor-doc="${toBase64URL(JSON.stringify(doc2))}" id="ones-editor-doc">${ZERO_WIDTH_SPACE_CHAR}</span>${htmlFragment}</body></html>`;
|
|
25971
26010
|
}
|
|
25972
26011
|
const meta = `<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${toBase64URL(JSON.stringify(doc2))}::ones-editor-doc" />`;
|
|
25973
26012
|
const html = `<!doctype html><html><head><meta charset="utf8" />${meta}</head><body>${htmlFragment}</body></html>`;
|
|
@@ -27609,6 +27648,9 @@ ${codeText}
|
|
|
27609
27648
|
}
|
|
27610
27649
|
}
|
|
27611
27650
|
return false;
|
|
27651
|
+
} catch (error2) {
|
|
27652
|
+
logger$2H.error(`failed to undo: ${error2.message}`);
|
|
27653
|
+
return false;
|
|
27612
27654
|
} finally {
|
|
27613
27655
|
this.undoRedoing = false;
|
|
27614
27656
|
}
|
|
@@ -41197,44 +41239,52 @@ ${codeText}
|
|
|
41197
41239
|
updateLeft();
|
|
41198
41240
|
}
|
|
41199
41241
|
function updateCellsDangerStatus(editor, tableBlock, isDanger = true, isCol) {
|
|
41200
|
-
|
|
41201
|
-
|
|
41202
|
-
|
|
41203
|
-
|
|
41204
|
-
|
|
41205
|
-
|
|
41206
|
-
|
|
41207
|
-
|
|
41208
|
-
|
|
41209
|
-
if (
|
|
41210
|
-
|
|
41211
|
-
|
|
41212
|
-
|
|
41213
|
-
|
|
41214
|
-
|
|
41242
|
+
try {
|
|
41243
|
+
const grid = TableGrid.fromBlock(tableBlock);
|
|
41244
|
+
const cells = grid.map((cell) => cell);
|
|
41245
|
+
const { fromCol, toCol, fromRow, toRow } = getAbstractTableSelectionRange(editor, tableBlock);
|
|
41246
|
+
for (let i = 0; i < cells.length; i++) {
|
|
41247
|
+
const row = cells[i];
|
|
41248
|
+
for (let j = 0; j < row.length; j++) {
|
|
41249
|
+
const cell = row[j];
|
|
41250
|
+
const isBelong = isCol ? j >= fromCol && j + cell.colSpan - 1 <= toCol : i >= fromRow && i + cell.rowSpan - 1 <= toRow;
|
|
41251
|
+
if (isDanger && isBelong) {
|
|
41252
|
+
if (!cell.virtual) {
|
|
41253
|
+
addClass(cell.cell, "danger");
|
|
41254
|
+
}
|
|
41255
|
+
} else {
|
|
41256
|
+
if (!cell.virtual) {
|
|
41257
|
+
removeClass(cell.cell, "danger");
|
|
41258
|
+
}
|
|
41215
41259
|
}
|
|
41216
41260
|
}
|
|
41217
41261
|
}
|
|
41262
|
+
} catch (error2) {
|
|
41263
|
+
logger$24.error("update cells danger status failed: ", error2.message);
|
|
41218
41264
|
}
|
|
41219
41265
|
}
|
|
41220
41266
|
function updateCellBarsDangerStatus(editor, tableBlock, isDanger = true, isCol) {
|
|
41221
|
-
|
|
41222
|
-
|
|
41223
|
-
|
|
41224
|
-
|
|
41225
|
-
|
|
41226
|
-
|
|
41227
|
-
const { fromCol, toCol, fromRow, toRow } = getAbstractTableSelectionRange(editor, tableBlock);
|
|
41228
|
-
if (!isCol) {
|
|
41229
|
-
for (let i = fromRow; i <= toRow; i++) {
|
|
41230
|
-
selectedRows.add(i);
|
|
41267
|
+
try {
|
|
41268
|
+
const selectedRows = /* @__PURE__ */ new Set();
|
|
41269
|
+
const selectedColumns = /* @__PURE__ */ new Set();
|
|
41270
|
+
if (!isDanger) {
|
|
41271
|
+
updateBarsDangerStatus(editor, tableBlock, Array.from(selectedRows), Array.from(selectedColumns));
|
|
41272
|
+
return;
|
|
41231
41273
|
}
|
|
41232
|
-
|
|
41233
|
-
|
|
41234
|
-
|
|
41274
|
+
const { fromCol, toCol, fromRow, toRow } = getAbstractTableSelectionRange(editor, tableBlock);
|
|
41275
|
+
if (!isCol) {
|
|
41276
|
+
for (let i = fromRow; i <= toRow; i++) {
|
|
41277
|
+
selectedRows.add(i);
|
|
41278
|
+
}
|
|
41279
|
+
} else {
|
|
41280
|
+
for (let j = fromCol; j <= toCol; j++) {
|
|
41281
|
+
selectedColumns.add(j);
|
|
41282
|
+
}
|
|
41235
41283
|
}
|
|
41284
|
+
updateBarsDangerStatus(editor, tableBlock, Array.from(selectedRows), Array.from(selectedColumns));
|
|
41285
|
+
} catch (error2) {
|
|
41286
|
+
logger$24.error("update cell bars danger status failed: ", error2.message);
|
|
41236
41287
|
}
|
|
41237
|
-
updateBarsDangerStatus(editor, tableBlock, Array.from(selectedRows), Array.from(selectedColumns));
|
|
41238
41288
|
}
|
|
41239
41289
|
function createEntireRowAndColumnRange(editor, tableBlock, isCol) {
|
|
41240
41290
|
const { fromCol, toCol, fromRow, toRow } = getAbstractTableSelectionRange(editor, tableBlock);
|
|
@@ -56657,8 +56707,8 @@ $$${mathData.mathjaxText}$$
|
|
|
56657
56707
|
return;
|
|
56658
56708
|
}
|
|
56659
56709
|
const target = event.target;
|
|
56660
|
-
const
|
|
56661
|
-
const block = getParentBlock(
|
|
56710
|
+
const select2 = target.closest(".language-select");
|
|
56711
|
+
const block = getParentBlock(select2);
|
|
56662
56712
|
assert(logger$1e, block, "no parent block");
|
|
56663
56713
|
assert(logger$1e, getBlockType(block) === "code", "not a code block");
|
|
56664
56714
|
const codeData = editor2.getBlockData(block);
|
|
@@ -56667,7 +56717,7 @@ $$${mathData.mathjaxText}$$
|
|
|
56667
56717
|
dropdown2.setSelectedId(codeData.language);
|
|
56668
56718
|
selectCodeBlock(editor2, block, { focusToEditor: false });
|
|
56669
56719
|
setTimeout(() => {
|
|
56670
|
-
dropdown2.show(
|
|
56720
|
+
dropdown2.show(select2);
|
|
56671
56721
|
});
|
|
56672
56722
|
addClass(codeBlock2, "editing-language");
|
|
56673
56723
|
dropdown2.onHide = () => {
|
|
@@ -57256,25 +57306,25 @@ ${codeText}
|
|
|
57256
57306
|
if (!editor.editorBlocks.hasBlock("table")) {
|
|
57257
57307
|
return false;
|
|
57258
57308
|
}
|
|
57259
|
-
|
|
57260
|
-
if (!tableBlock.convertFrom) {
|
|
57261
|
-
return false;
|
|
57262
|
-
}
|
|
57263
|
-
const convertResult = tableBlock.convertFrom(editor, block, { offset });
|
|
57264
|
-
if (!convertResult) {
|
|
57265
|
-
return false;
|
|
57266
|
-
}
|
|
57267
|
-
const { blockData: newBlockData, focusBlockId } = convertResult;
|
|
57268
|
-
if (!newBlockData) {
|
|
57269
|
-
return false;
|
|
57270
|
-
}
|
|
57271
|
-
editor.undoManager.runInGroup(() => {
|
|
57309
|
+
return editor.undoManager.runInGroup(() => {
|
|
57272
57310
|
var _a;
|
|
57311
|
+
const tableBlock = editor.editorBlocks.getBlockClass("table");
|
|
57312
|
+
if (!tableBlock.convertFrom) {
|
|
57313
|
+
return false;
|
|
57314
|
+
}
|
|
57315
|
+
const convertResult = tableBlock.convertFrom(editor, block, { offset });
|
|
57316
|
+
if (!convertResult) {
|
|
57317
|
+
return false;
|
|
57318
|
+
}
|
|
57319
|
+
const { blockData: newBlockData, focusBlockId } = convertResult;
|
|
57320
|
+
if (!newBlockData) {
|
|
57321
|
+
return false;
|
|
57322
|
+
}
|
|
57273
57323
|
const newBlock = editor.insertBlock(containerId, blockIndex, newBlockData, createBlockSimpleRange(editor, focusBlockId != null ? focusBlockId : newBlockData.id, 0));
|
|
57274
57324
|
editor.deleteBlock(block);
|
|
57275
57325
|
(_a = convertResult.onConverted) == null ? void 0 : _a.call(convertResult, editor, newBlock);
|
|
57326
|
+
return true;
|
|
57276
57327
|
});
|
|
57277
|
-
return true;
|
|
57278
57328
|
}
|
|
57279
57329
|
const ENTER_CONVERTER = {
|
|
57280
57330
|
mermaid: {
|
|
@@ -62340,7 +62390,7 @@ ${codeText}
|
|
|
62340
62390
|
const style$5 = "";
|
|
62341
62391
|
const logger$U = getLogger("html-to-doc");
|
|
62342
62392
|
function getDocFromHtmlInFirefox(html) {
|
|
62343
|
-
const reg = /(<
|
|
62393
|
+
const reg = /(<span data-editor-doc=")[\s\S]*( id="ones-editor-doc"\s?>)/g;
|
|
62344
62394
|
let htmlForParser = html;
|
|
62345
62395
|
if (isSafari()) {
|
|
62346
62396
|
htmlForParser = html.replace(/style="(.*)"/, "");
|
|
@@ -62349,7 +62399,7 @@ ${codeText}
|
|
|
62349
62399
|
if (!result || !result.length) {
|
|
62350
62400
|
return null;
|
|
62351
62401
|
}
|
|
62352
|
-
result = result.map((res) => res.replace(/(<
|
|
62402
|
+
result = result.map((res) => res.replace(/(<span data-editor-doc=")/g, "").replace(/(" id="ones-editor-doc"\s?>)/g, ""));
|
|
62353
62403
|
const base64 = result[0];
|
|
62354
62404
|
const jsonText = fromBase64(base64);
|
|
62355
62405
|
const doc2 = JSON.parse(jsonText);
|
|
@@ -77455,7 +77505,7 @@ ${data.flowchartText}
|
|
|
77455
77505
|
}
|
|
77456
77506
|
}
|
|
77457
77507
|
});
|
|
77458
|
-
editor.version = "1.1.
|
|
77508
|
+
editor.version = "1.1.31-beta.1";
|
|
77459
77509
|
if (Logger$2.level === LogLevel.DEBUG) {
|
|
77460
77510
|
window.setReauthFail = (fail) => {
|
|
77461
77511
|
window.isReauthError = fail;
|
|
@@ -77497,57 +77547,61 @@ ${data.flowchartText}
|
|
|
77497
77547
|
},
|
|
77498
77548
|
shortcuts: [TableShortcuts, FindReplaceShortcuts, TextStyleShortcuts, DefaultShortcuts]
|
|
77499
77549
|
});
|
|
77500
|
-
|
|
77501
|
-
editor.
|
|
77502
|
-
|
|
77503
|
-
|
|
77504
|
-
|
|
77505
|
-
|
|
77506
|
-
|
|
77507
|
-
|
|
77508
|
-
|
|
77509
|
-
|
|
77510
|
-
|
|
77511
|
-
|
|
77512
|
-
addPlaceholderToAllCurrentEmptyBlock: true
|
|
77513
|
-
})
|
|
77514
|
-
);
|
|
77515
|
-
editor.input.addHandler(new OnesEditorQuickMenu(editor, (_h = options.componentsOptions) == null ? void 0 : _h.quickMenu));
|
|
77516
|
-
editor.input.addHandler(new PasteSpecialHandler(editor));
|
|
77517
|
-
editor.input.addHandler(new OnesEditorPasteHandler(editor));
|
|
77518
|
-
editor.input.addHandler(new BlockLockerPasteHandler());
|
|
77519
|
-
editor.input.addHandler(new ListPasteHandler());
|
|
77520
|
-
editor.addCustom("block-menu", (editor2) => new OnesEditorBlockMenuButton(editor2));
|
|
77521
|
-
if (!clientType.isMobile) {
|
|
77522
|
-
editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
|
|
77523
|
-
}
|
|
77524
|
-
editor.addCustom("image-paste-handler", () => new ImagePasteHandler(editor));
|
|
77525
|
-
if (options == null ? void 0 : options.enableComments) {
|
|
77526
|
-
editor.addCustom(
|
|
77527
|
-
"editor-comments",
|
|
77528
|
-
(editor2) => new OnesEditorComments(editor2, new LocalDocCommentsProvider(editor2, doc2))
|
|
77550
|
+
try {
|
|
77551
|
+
editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor));
|
|
77552
|
+
editor.input.addHandler(new MarkdownInputHandler());
|
|
77553
|
+
editor.input.addHandler(
|
|
77554
|
+
new EnforceWithDocumentTitleHandler(editor, {
|
|
77555
|
+
hideTitle: options.hideTitle,
|
|
77556
|
+
headingLevel: 1,
|
|
77557
|
+
titlePlaceholder: i18n$1.t("placeholder.common.title"),
|
|
77558
|
+
contentPlaceholder: i18n$1.t("placeholder.common.content"),
|
|
77559
|
+
readonlyTitlePlaceholder: i18n$1.t("placeholder.local.readonlyTitle"),
|
|
77560
|
+
addPlaceholderToAllCurrentEmptyBlock: true
|
|
77561
|
+
})
|
|
77529
77562
|
);
|
|
77530
|
-
|
|
77531
|
-
|
|
77532
|
-
editor.
|
|
77533
|
-
|
|
77534
|
-
|
|
77535
|
-
|
|
77536
|
-
|
|
77537
|
-
|
|
77538
|
-
|
|
77539
|
-
|
|
77563
|
+
editor.input.addHandler(new OnesEditorQuickMenu(editor, (_h = options.componentsOptions) == null ? void 0 : _h.quickMenu));
|
|
77564
|
+
editor.input.addHandler(new PasteSpecialHandler(editor));
|
|
77565
|
+
editor.input.addHandler(new OnesEditorPasteHandler(editor));
|
|
77566
|
+
editor.input.addHandler(new BlockLockerPasteHandler());
|
|
77567
|
+
editor.input.addHandler(new ListPasteHandler());
|
|
77568
|
+
editor.addCustom("block-menu", (editor2) => new OnesEditorBlockMenuButton(editor2));
|
|
77569
|
+
if (!clientType.isMobile) {
|
|
77570
|
+
editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
|
|
77571
|
+
}
|
|
77572
|
+
editor.addCustom("image-paste-handler", () => new ImagePasteHandler(editor));
|
|
77573
|
+
if (options == null ? void 0 : options.enableComments) {
|
|
77574
|
+
editor.addCustom(
|
|
77575
|
+
"editor-comments",
|
|
77576
|
+
(editor2) => new OnesEditorComments(editor2, new LocalDocCommentsProvider(editor2, doc2))
|
|
77577
|
+
);
|
|
77540
77578
|
}
|
|
77541
|
-
|
|
77542
|
-
|
|
77543
|
-
|
|
77544
|
-
|
|
77579
|
+
if (options.enableContextMenu !== false) {
|
|
77580
|
+
editor.addCustom("editor-context-menu", (editor2) => new OnesEditorContextMenu(editor2));
|
|
77581
|
+
}
|
|
77582
|
+
editor.addCustom("heading-collapse", () => new HeadingBlockCollapseButton(editor));
|
|
77583
|
+
editor.addListener("clickLink", (editor2, event, link2) => {
|
|
77584
|
+
var _a2;
|
|
77585
|
+
if ((_a2 = options == null ? void 0 : options.events) == null ? void 0 : _a2.onClickLink) {
|
|
77586
|
+
options.events.onClickLink(editor2, event, link2);
|
|
77587
|
+
return;
|
|
77588
|
+
}
|
|
77589
|
+
const href = link2.getAttribute("link");
|
|
77590
|
+
if (href) {
|
|
77591
|
+
if (editor2.readonly || event.ctrlKey || event.metaKey) {
|
|
77592
|
+
window.open(href, "_blank");
|
|
77593
|
+
}
|
|
77545
77594
|
}
|
|
77595
|
+
});
|
|
77596
|
+
editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
|
|
77597
|
+
OnesEditorToolbar.register(editor);
|
|
77598
|
+
editor.version = "1.1.31-beta.1";
|
|
77599
|
+
} catch (error2) {
|
|
77600
|
+
if (options.readonly) {
|
|
77601
|
+
editor.readonly = true;
|
|
77546
77602
|
}
|
|
77547
|
-
|
|
77548
|
-
|
|
77549
|
-
OnesEditorToolbar.register(editor);
|
|
77550
|
-
editor.version = "1.1.30-beta.7";
|
|
77603
|
+
throw error2;
|
|
77604
|
+
}
|
|
77551
77605
|
return editor;
|
|
77552
77606
|
}
|
|
77553
77607
|
async function showDocVersions(editor, options, serverUrl) {
|