@ones-editor/editor 2.2.0 → 2.2.2
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/blocks/complex-blocks/complex-block-helper.d.ts +2 -5
- package/@ones-editor/core/src/core/blocks/text-blocks/base/child.d.ts +1 -2
- package/@ones-editor/core/src/core/blocks/text-blocks/base/line-breaks.d.ts +1 -2
- package/@ones-editor/core/src/core/blocks/text-blocks/base/range.d.ts +1 -2
- package/@ones-editor/core/src/core/blocks/text-blocks/base/text-offset.d.ts +1 -2
- package/@ones-editor/core/src/core/composition/editor-input.d.ts +1 -1
- package/@ones-editor/core/src/core/input-handler/input-handler.d.ts +2 -1
- package/@ones-editor/core/src/core/insertions/editor-insertions.d.ts +1 -0
- package/@ones-editor/core/src/core/selection/adjust-selection-pos.d.ts +5 -1
- package/@ones-editor/core/src/core/types.d.ts +1 -0
- package/@ones-editor/core/src/helper/hovering-block.d.ts +1 -2
- package/@ones-editor/excalidraw/package.json +4 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +379 -364
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6096,6 +6096,9 @@ div[data-command-bar-id=mobile-bottom-menu] .mobile-menu-wrap.editor-mention .co
|
|
|
6096
6096
|
flex: 1;
|
|
6097
6097
|
min-width: 0;
|
|
6098
6098
|
}
|
|
6099
|
+
.editor-root [data-type=editor-container].root div[data-type=editor-block].callout-block .callout-root .callout-content > .child {
|
|
6100
|
+
padding: 0;
|
|
6101
|
+
}
|
|
6099
6102
|
.editor-root [data-type=editor-container].root div[data-type=editor-block].callout-block .callout-root .callout-content div[data-type=editor-block].list-block > div.list-container,
|
|
6100
6103
|
.editor-root [data-type=editor-container].root div[data-type=editor-block].callout-block .callout-root .callout-content div[data-type=editor-block].list-block > div[data-type=block-content] {
|
|
6101
6104
|
background-color: transparent;
|
|
@@ -7651,8 +7654,8 @@ var __publicField = (obj, key, value) => {
|
|
|
7651
7654
|
return value;
|
|
7652
7655
|
};
|
|
7653
7656
|
(function(global2, factory) {
|
|
7654
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("kiwi-intl"), require("lodash.merge"), require("string-template"), require("nanoid"), require("events"), require("query-string"), require("js-base64"), require("snabbdom"), require("
|
|
7655
|
-
})(this, function(exports2, KiwiIntl, merge, stringFormat, nanoid$1, events, queryString, jsBase64, snabbdom,
|
|
7657
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("kiwi-intl"), require("lodash.merge"), require("string-template"), require("nanoid"), require("events"), require("query-string"), require("js-base64"), require("snabbdom"), require("lodash.clonedeep"), require("lodash.isequal"), require("quill-delta"), require("tiny-typed-emitter"), require("lodash.debounce"), require("lodash.intersection"), require("axios"), require("ot-json1"), require("lodash.findlastindex"), require("reconnecting-websocket"), require("fast-sha256"), require("tippy.js"), require("blueimp-md5"), require("css-color-converter"), require("markmap-view"), require("mime-db"), require("prismjs"), require("prismjs/components/prism-c"), require("prismjs/components/prism-cpp"), require("prismjs/components/prism-abap"), require("prismjs/components/prism-arduino"), require("prismjs/components/prism-bash"), require("prismjs/components/prism-basic"), require("prismjs/components/prism-clojure"), require("prismjs/components/prism-coffeescript"), require("prismjs/components/prism-csharp"), require("prismjs/components/prism-css"), require("prismjs/components/prism-dart"), require("prismjs/components/prism-diff"), require("prismjs/components/prism-docker"), require("prismjs/components/prism-elixir"), require("prismjs/components/prism-elm"), require("prismjs/components/prism-erlang"), require("prismjs/components/prism-flow"), require("prismjs/components/prism-fortran"), require("prismjs/components/prism-fsharp"), require("prismjs/components/prism-gherkin"), require("prismjs/components/prism-glsl"), require("prismjs/components/prism-go"), require("prismjs/components/prism-graphql"), require("prismjs/components/prism-groovy"), require("prismjs/components/prism-haskell"), require("prismjs/components/prism-java"), require("prismjs/components/prism-javascript"), require("prismjs/components/prism-json"), require("prismjs/components/prism-julia"), require("prismjs/components/prism-kotlin"), require("prismjs/components/prism-latex"), require("prismjs/components/prism-less"), require("prismjs/components/prism-lisp"), require("prismjs/components/prism-livescript"), require("prismjs/components/prism-lua"), require("prismjs/components/prism-makefile"), require("prismjs/components/prism-markdown"), require("prismjs/components/prism-markup"), require("prismjs/components/prism-matlab"), require("prismjs/components/prism-mermaid"), require("prismjs/components/prism-nix"), require("prismjs/components/prism-objectivec"), require("prismjs/components/prism-ocaml"), require("prismjs/components/prism-pascal"), require("prismjs/components/prism-perl"), require("prismjs/components/prism-php"), require("prismjs/components/prism-powershell"), require("prismjs/components/prism-prolog"), require("prismjs/components/prism-protobuf"), require("prismjs/components/prism-python"), require("prismjs/components/prism-r"), require("prismjs/components/prism-reason"), require("prismjs/components/prism-ruby"), require("prismjs/components/prism-rust"), require("prismjs/components/prism-sass"), require("prismjs/components/prism-scala"), require("prismjs/components/prism-scheme"), require("prismjs/components/prism-scss"), require("prismjs/components/prism-solidity"), require("prismjs/components/prism-sql"), require("prismjs/components/prism-swift"), require("prismjs/components/prism-typescript"), require("prismjs/components/prism-vbnet"), require("prismjs/components/prism-verilog"), require("prismjs/components/prism-vhdl"), require("prismjs/components/prism-visual-basic"), require("prismjs/components/prism-wasm"), require("prismjs/components/prism-yaml"), require("@better-scroll/core"), require("dom-to-image"), require("lodash.throttle"), require("@guyplusplus/turndown-plugin-gfm"), require("marked"), require("plantuml-encoder"), require("docx")) : typeof define === "function" && define.amd ? define(["exports", "kiwi-intl", "lodash.merge", "string-template", "nanoid", "events", "query-string", "js-base64", "snabbdom", "lodash.clonedeep", "lodash.isequal", "quill-delta", "tiny-typed-emitter", "lodash.debounce", "lodash.intersection", "axios", "ot-json1", "lodash.findlastindex", "reconnecting-websocket", "fast-sha256", "tippy.js", "blueimp-md5", "css-color-converter", "markmap-view", "mime-db", "prismjs", "prismjs/components/prism-c", "prismjs/components/prism-cpp", "prismjs/components/prism-abap", "prismjs/components/prism-arduino", "prismjs/components/prism-bash", "prismjs/components/prism-basic", "prismjs/components/prism-clojure", "prismjs/components/prism-coffeescript", "prismjs/components/prism-csharp", "prismjs/components/prism-css", "prismjs/components/prism-dart", "prismjs/components/prism-diff", "prismjs/components/prism-docker", "prismjs/components/prism-elixir", "prismjs/components/prism-elm", "prismjs/components/prism-erlang", "prismjs/components/prism-flow", "prismjs/components/prism-fortran", "prismjs/components/prism-fsharp", "prismjs/components/prism-gherkin", "prismjs/components/prism-glsl", "prismjs/components/prism-go", "prismjs/components/prism-graphql", "prismjs/components/prism-groovy", "prismjs/components/prism-haskell", "prismjs/components/prism-java", "prismjs/components/prism-javascript", "prismjs/components/prism-json", "prismjs/components/prism-julia", "prismjs/components/prism-kotlin", "prismjs/components/prism-latex", "prismjs/components/prism-less", "prismjs/components/prism-lisp", "prismjs/components/prism-livescript", "prismjs/components/prism-lua", "prismjs/components/prism-makefile", "prismjs/components/prism-markdown", "prismjs/components/prism-markup", "prismjs/components/prism-matlab", "prismjs/components/prism-mermaid", "prismjs/components/prism-nix", "prismjs/components/prism-objectivec", "prismjs/components/prism-ocaml", "prismjs/components/prism-pascal", "prismjs/components/prism-perl", "prismjs/components/prism-php", "prismjs/components/prism-powershell", "prismjs/components/prism-prolog", "prismjs/components/prism-protobuf", "prismjs/components/prism-python", "prismjs/components/prism-r", "prismjs/components/prism-reason", "prismjs/components/prism-ruby", "prismjs/components/prism-rust", "prismjs/components/prism-sass", "prismjs/components/prism-scala", "prismjs/components/prism-scheme", "prismjs/components/prism-scss", "prismjs/components/prism-solidity", "prismjs/components/prism-sql", "prismjs/components/prism-swift", "prismjs/components/prism-typescript", "prismjs/components/prism-vbnet", "prismjs/components/prism-verilog", "prismjs/components/prism-vhdl", "prismjs/components/prism-visual-basic", "prismjs/components/prism-wasm", "prismjs/components/prism-yaml", "@better-scroll/core", "dom-to-image", "lodash.throttle", "@guyplusplus/turndown-plugin-gfm", "marked", "plantuml-encoder", "docx"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["oneseditor-editor"] = {}, global2.KiwiIntl, global2.merge, global2.stringFormat, global2.nanoid$1, global2.events, global2.queryString, global2.jsBase64, global2.snabbdom, global2.cloneDeep, global2.isEqual, global2.Delta, global2.tinyTypedEmitter, global2.debounce, global2.intersection, global2.axios, global2.json1, global2.findLastIndex, global2.ReconnectingWebSocket, global2.sha256, global2.tippy$1, global2.md5, global2.cssColorConverter, global2.markmap, global2.mime, global2.Prism, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, global2.BetterScroll, global2.domToImage, global2.throttle$1, global2.turndownPluginGfm, global2.marked, global2.plantumlEncoder, global2.docx));
|
|
7658
|
+
})(this, function(exports2, KiwiIntl, merge, stringFormat, nanoid$1, events, queryString, jsBase64, snabbdom, cloneDeep, isEqual, Delta, tinyTypedEmitter, debounce, intersection, axios, json1, findLastIndex, ReconnectingWebSocket, sha256, tippy$1, md5, cssColorConverter, markmap, mime, Prism, prismC, prismCpp, prismAbap, prismArduino, prismBash, prismBasic, prismClojure, prismCoffeescript, prismCsharp, prismCss, prismDart, prismDiff, prismDocker, prismElixir, prismElm, prismErlang, prismFlow, prismFortran, prismFsharp, prismGherkin, prismGlsl, prismGo, prismGraphql, prismGroovy, prismHaskell, prismJava, prismJavascript, prismJson, prismJulia, prismKotlin, prismLatex, prismLess, prismLisp, prismLivescript, prismLua, prismMakefile, prismMarkdown, prismMarkup, prismMatlab, prismMermaid, prismNix, prismObjectivec, prismOcaml, prismPascal, prismPerl, prismPhp, prismPowershell, prismProlog, prismProtobuf, prismPython, prismR, prismReason, prismRuby, prismRust, prismSass, prismScala, prismScheme, prismScss, prismSolidity, prismSql, prismSwift, prismTypescript, prismVbnet, prismVerilog, prismVhdl, prismVisualBasic, prismWasm, prismYaml, BetterScroll, domToImage, throttle$1, turndownPluginGfm, marked, plantumlEncoder, docx) {
|
|
7656
7659
|
"use strict";
|
|
7657
7660
|
const _interopDefaultLegacy = (e2) => e2 && typeof e2 === "object" && "default" in e2 ? e2 : { default: e2 };
|
|
7658
7661
|
function _interopNamespace(e2) {
|
|
@@ -10494,322 +10497,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10494
10497
|
var _a;
|
|
10495
10498
|
return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
|
|
10496
10499
|
}
|
|
10497
|
-
|
|
10498
|
-
constructor(editor) {
|
|
10499
|
-
__publicField(this, "renders", []);
|
|
10500
|
-
this.editor = editor;
|
|
10501
|
-
}
|
|
10502
|
-
registerRender(render) {
|
|
10503
|
-
this.renders.push(render);
|
|
10504
|
-
}
|
|
10505
|
-
renderBox(path, attributes) {
|
|
10506
|
-
const result = {
|
|
10507
|
-
classes: [],
|
|
10508
|
-
attributes: {},
|
|
10509
|
-
styles: {}
|
|
10510
|
-
};
|
|
10511
|
-
this.renders.forEach((render) => {
|
|
10512
|
-
if (render.renderBox) {
|
|
10513
|
-
const ret = render.renderBox(this.editor, path, attributes);
|
|
10514
|
-
if (ret.classes) {
|
|
10515
|
-
result.classes.push(...ret.classes);
|
|
10516
|
-
}
|
|
10517
|
-
if (ret.attributes) {
|
|
10518
|
-
result.attributes = {
|
|
10519
|
-
...result.attributes,
|
|
10520
|
-
...ret.attributes
|
|
10521
|
-
};
|
|
10522
|
-
}
|
|
10523
|
-
if (ret.styles) {
|
|
10524
|
-
result.styles = {
|
|
10525
|
-
...result.styles,
|
|
10526
|
-
...ret.styles
|
|
10527
|
-
};
|
|
10528
|
-
}
|
|
10529
|
-
}
|
|
10530
|
-
});
|
|
10531
|
-
return result;
|
|
10532
|
-
}
|
|
10533
|
-
renderText(path, attributes) {
|
|
10534
|
-
const result = {
|
|
10535
|
-
classes: [],
|
|
10536
|
-
attributes: {},
|
|
10537
|
-
styles: {}
|
|
10538
|
-
};
|
|
10539
|
-
this.renders.forEach((render) => {
|
|
10540
|
-
if (render.renderText) {
|
|
10541
|
-
const ret = render.renderText(this.editor, path, attributes);
|
|
10542
|
-
if (ret.classes) {
|
|
10543
|
-
result.classes.push(...ret.classes);
|
|
10544
|
-
}
|
|
10545
|
-
if (ret.attributes) {
|
|
10546
|
-
result.attributes = {
|
|
10547
|
-
...result.attributes,
|
|
10548
|
-
...ret.attributes
|
|
10549
|
-
};
|
|
10550
|
-
}
|
|
10551
|
-
if (ret.styles) {
|
|
10552
|
-
result.styles = {
|
|
10553
|
-
...result.styles,
|
|
10554
|
-
...ret.styles
|
|
10555
|
-
};
|
|
10556
|
-
}
|
|
10557
|
-
}
|
|
10558
|
-
});
|
|
10559
|
-
return result;
|
|
10560
|
-
}
|
|
10561
|
-
renderBlock(editor, path, blockData) {
|
|
10562
|
-
const result = {
|
|
10563
|
-
classes: [],
|
|
10564
|
-
attributes: {},
|
|
10565
|
-
styles: {}
|
|
10566
|
-
};
|
|
10567
|
-
this.renders.forEach((render) => {
|
|
10568
|
-
if (render.renderBlock) {
|
|
10569
|
-
const ret = render.renderBlock(this.editor, path, blockData);
|
|
10570
|
-
if (ret.classes) {
|
|
10571
|
-
result.classes.push(...ret.classes);
|
|
10572
|
-
}
|
|
10573
|
-
if (ret.attributes) {
|
|
10574
|
-
result.attributes = {
|
|
10575
|
-
...result.attributes,
|
|
10576
|
-
...ret.attributes
|
|
10577
|
-
};
|
|
10578
|
-
}
|
|
10579
|
-
if (ret.styles) {
|
|
10580
|
-
result.styles = {
|
|
10581
|
-
...result.styles,
|
|
10582
|
-
...ret.styles
|
|
10583
|
-
};
|
|
10584
|
-
}
|
|
10585
|
-
}
|
|
10586
|
-
});
|
|
10587
|
-
return result;
|
|
10588
|
-
}
|
|
10589
|
-
updateBlock(editor, path, blockElement, blockData) {
|
|
10590
|
-
this.renders.forEach((render) => {
|
|
10591
|
-
var _a;
|
|
10592
|
-
(_a = render.updateBlock) == null ? void 0 : _a.call(render, editor, path, blockElement, blockData);
|
|
10593
|
-
});
|
|
10594
|
-
}
|
|
10595
|
-
}
|
|
10596
|
-
const logger$4s = getLogger("block-class");
|
|
10597
|
-
function getBlockClass(editor, block) {
|
|
10598
|
-
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10599
|
-
}
|
|
10600
|
-
function getTextBlockClass(editor, block) {
|
|
10601
|
-
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10602
|
-
assert(logger$4s, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
10603
|
-
return text2;
|
|
10604
|
-
}
|
|
10605
|
-
function getComplexBlockClass(editor, block) {
|
|
10606
|
-
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10607
|
-
assert(logger$4s, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
10608
|
-
return complex;
|
|
10609
|
-
}
|
|
10610
|
-
function getBlockClassByType(editor, type) {
|
|
10611
|
-
return editor.editorBlocks.getBlockClass(type);
|
|
10612
|
-
}
|
|
10613
|
-
function isTextKindBlock(editor, block) {
|
|
10614
|
-
return getBlockClass(editor, block).blockKind === "text";
|
|
10615
|
-
}
|
|
10616
|
-
function isTextKindBlockType(editor, type) {
|
|
10617
|
-
return editor.editorBlocks.getBlockClass(type).blockKind === "text";
|
|
10618
|
-
}
|
|
10619
|
-
function isComplexKindBlock(editor, block) {
|
|
10620
|
-
return getBlockClass(editor, block).blockKind === "complex";
|
|
10621
|
-
}
|
|
10622
|
-
function isSimpleBlock(editor, block) {
|
|
10623
|
-
return !isComplexKindBlock(editor, block);
|
|
10624
|
-
}
|
|
10625
|
-
function getBlockKind(editor, block) {
|
|
10626
|
-
return getBlockClass(editor, block).blockKind;
|
|
10627
|
-
}
|
|
10628
|
-
class OnesEditorHoveringBlock extends tinyTypedEmitter.TypedEmitter {
|
|
10629
|
-
constructor(editor) {
|
|
10630
|
-
super();
|
|
10631
|
-
__publicField(this, "hoveringBlock", null);
|
|
10632
|
-
__publicField(this, "hoveringElem", null);
|
|
10633
|
-
__publicField(this, "hoveringTextChild", null);
|
|
10634
|
-
__publicField(this, "filters", []);
|
|
10635
|
-
__publicField(this, "finders", []);
|
|
10636
|
-
__publicField(this, "handleDocumentMouseMove", (event) => {
|
|
10637
|
-
if (this.hoveringBlock) {
|
|
10638
|
-
for (const filter of this.filters) {
|
|
10639
|
-
if (filter.isInBlock(this.hoveringBlock, event)) {
|
|
10640
|
-
return;
|
|
10641
|
-
}
|
|
10642
|
-
}
|
|
10643
|
-
}
|
|
10644
|
-
const elem = getElementFromPoint(event.x, event.y, { noFilter: true });
|
|
10645
|
-
if (!elem) {
|
|
10646
|
-
this.setHoveringBlock(null, event, null, elem);
|
|
10647
|
-
return;
|
|
10648
|
-
}
|
|
10649
|
-
let block = getParentBlock(elem);
|
|
10650
|
-
if (!block || !isChildNode(this.editor.rootContainer, block)) {
|
|
10651
|
-
block = this.findBlockByFinders(event);
|
|
10652
|
-
if (!block) {
|
|
10653
|
-
this.setHoveringBlock(null, event, null, elem);
|
|
10654
|
-
return;
|
|
10655
|
-
}
|
|
10656
|
-
}
|
|
10657
|
-
const child = this.getParentTextContentChild(block, elem);
|
|
10658
|
-
this.setHoveringBlock(block, event, child, elem);
|
|
10659
|
-
});
|
|
10660
|
-
this.editor = editor;
|
|
10661
|
-
if (clientType.isMobile) {
|
|
10662
|
-
document.addEventListener("click", this.handleDocumentMouseMove);
|
|
10663
|
-
} else {
|
|
10664
|
-
document.addEventListener("mousemove", this.handleDocumentMouseMove);
|
|
10665
|
-
}
|
|
10666
|
-
}
|
|
10667
|
-
destroy() {
|
|
10668
|
-
document.removeEventListener("mousemove", this.handleDocumentMouseMove);
|
|
10669
|
-
this.filters.forEach((filter) => filter.destroy());
|
|
10670
|
-
this.filters = [];
|
|
10671
|
-
this.finders.forEach((finder) => finder.destroy());
|
|
10672
|
-
this.finders = [];
|
|
10673
|
-
}
|
|
10674
|
-
addFilter(filter) {
|
|
10675
|
-
this.filters.push(filter);
|
|
10676
|
-
}
|
|
10677
|
-
addFinder(finder) {
|
|
10678
|
-
this.finders.push(finder);
|
|
10679
|
-
}
|
|
10680
|
-
hoveringBlockId() {
|
|
10681
|
-
if (!this.hoveringBlock) {
|
|
10682
|
-
return "";
|
|
10683
|
-
}
|
|
10684
|
-
return getBlockId(this.hoveringBlock);
|
|
10685
|
-
}
|
|
10686
|
-
findBlockByFinders(event) {
|
|
10687
|
-
for (let i = 0; i < this.finders.length; i++) {
|
|
10688
|
-
const finder = this.finders[i];
|
|
10689
|
-
const b = finder.findTargetBlock(this.editor, event);
|
|
10690
|
-
if (b) {
|
|
10691
|
-
return b;
|
|
10692
|
-
}
|
|
10693
|
-
}
|
|
10694
|
-
return null;
|
|
10695
|
-
}
|
|
10696
|
-
setHoveringBlock(block, event, child, pointElem) {
|
|
10697
|
-
if (this.hoveringBlock === block && this.hoveringTextChild === child && this.hoveringElem === event.target) {
|
|
10698
|
-
return;
|
|
10699
|
-
}
|
|
10700
|
-
if (this.hoveringBlock !== block) {
|
|
10701
|
-
const oldBlock = this.hoveringBlock && isChildNode(this.editor.rootContainer, this.hoveringBlock) ? this.hoveringBlock : null;
|
|
10702
|
-
if (oldBlock) {
|
|
10703
|
-
removeClass(oldBlock, "hover");
|
|
10704
|
-
}
|
|
10705
|
-
if (block) {
|
|
10706
|
-
addClass(block, "hover");
|
|
10707
|
-
}
|
|
10708
|
-
this.emit("change", block, oldBlock, event);
|
|
10709
|
-
}
|
|
10710
|
-
if (this.hoveringElem !== pointElem || this.hoveringBlock !== block) {
|
|
10711
|
-
this.emit("targetChange", block, this.hoveringBlock, pointElem, this.hoveringElem);
|
|
10712
|
-
}
|
|
10713
|
-
const oldChild = this.hoveringTextChild;
|
|
10714
|
-
this.hoveringTextChild = child;
|
|
10715
|
-
this.hoveringElem = pointElem;
|
|
10716
|
-
this.hoveringBlock = block;
|
|
10717
|
-
this.emit("childChange", this.hoveringBlock, child, oldChild, event);
|
|
10718
|
-
}
|
|
10719
|
-
static get(editor) {
|
|
10720
|
-
return editor.addCustom("standard-hovering-block", () => new OnesEditorHoveringBlock(editor));
|
|
10721
|
-
}
|
|
10722
|
-
getParentTextContentChild(block, elem) {
|
|
10723
|
-
if (!isTextKindBlock(this.editor, block)) {
|
|
10724
|
-
return null;
|
|
10725
|
-
}
|
|
10726
|
-
const content = getBlockContent(block);
|
|
10727
|
-
if (elem.parentElement === content) {
|
|
10728
|
-
return elem;
|
|
10729
|
-
}
|
|
10730
|
-
const box = getParentBox(elem);
|
|
10731
|
-
return box;
|
|
10732
|
-
}
|
|
10733
|
-
}
|
|
10734
|
-
const COLOR_PREFIX = "style-color-";
|
|
10735
|
-
const BACKGROUND_COLOR_PREFIX$1 = "style-bg-color-";
|
|
10736
|
-
class StandardBlockRenderer {
|
|
10737
|
-
renderText(editor, path, attributes) {
|
|
10738
|
-
return this.generateCSSCustomProperties(attributes);
|
|
10739
|
-
}
|
|
10740
|
-
renderBlock(editor, path, blockData) {
|
|
10741
|
-
var _a, _b;
|
|
10742
|
-
const attributes = {};
|
|
10743
|
-
const styles = Object.entries(blockData).filter((k) => k[0].startsWith("style-"));
|
|
10744
|
-
styles.forEach(([key, value]) => {
|
|
10745
|
-
attributes[`data-${key}`] = `${value}`;
|
|
10746
|
-
});
|
|
10747
|
-
const classes = [];
|
|
10748
|
-
if (((_b = (_a = editor.selection) == null ? void 0 : _a.range) == null ? void 0 : _b.start.blockId) === blockData.id) {
|
|
10749
|
-
classes.push("focused");
|
|
10750
|
-
}
|
|
10751
|
-
if (typeof blockData.align === "string" && blockData.align) {
|
|
10752
|
-
attributes["data-style-align"] = blockData.align;
|
|
10753
|
-
}
|
|
10754
|
-
if (blockData.heading) {
|
|
10755
|
-
attributes["data-style-heading"] = String(blockData.heading);
|
|
10756
|
-
}
|
|
10757
|
-
if (blockData.quoted) {
|
|
10758
|
-
attributes["data-style-quoted"] = "true";
|
|
10759
|
-
}
|
|
10760
|
-
if (OnesEditorHoveringBlock.get(editor).hoveringBlockId() === blockData.id) {
|
|
10761
|
-
classes.push("hover");
|
|
10762
|
-
}
|
|
10763
|
-
return { attributes, classes };
|
|
10764
|
-
}
|
|
10765
|
-
updateBlock(editor, path, blockElement, blockData) {
|
|
10766
|
-
Array.from(blockElement.attributes).forEach((a) => {
|
|
10767
|
-
if (a.name.startsWith("data-style-")) {
|
|
10768
|
-
blockElement.removeAttribute(a.name);
|
|
10769
|
-
}
|
|
10770
|
-
});
|
|
10771
|
-
const { attributes, classes } = this.renderBlock(editor, path, blockData);
|
|
10772
|
-
if (attributes) {
|
|
10773
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
10774
|
-
blockElement.setAttribute(key, value);
|
|
10775
|
-
});
|
|
10776
|
-
}
|
|
10777
|
-
if (classes) {
|
|
10778
|
-
classes.forEach((c) => {
|
|
10779
|
-
addClass(blockElement, c);
|
|
10780
|
-
});
|
|
10781
|
-
}
|
|
10782
|
-
}
|
|
10783
|
-
generateCSSCustomProperties(attributes) {
|
|
10784
|
-
const classes = [];
|
|
10785
|
-
const newAttributes = {};
|
|
10786
|
-
const newStyles = {};
|
|
10787
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
10788
|
-
if (value === true) {
|
|
10789
|
-
if (key.startsWith(COLOR_PREFIX)) {
|
|
10790
|
-
newAttributes["data-style-color"] = key.substring(COLOR_PREFIX.length);
|
|
10791
|
-
} else if (key.startsWith(BACKGROUND_COLOR_PREFIX$1)) {
|
|
10792
|
-
newAttributes["data-style-bg-color"] = key.substring(BACKGROUND_COLOR_PREFIX$1.length);
|
|
10793
|
-
} else if (key.startsWith("style")) {
|
|
10794
|
-
classes.push(key);
|
|
10795
|
-
}
|
|
10796
|
-
} else if (typeof value === "string") {
|
|
10797
|
-
if (key === "link") {
|
|
10798
|
-
classes.push("link");
|
|
10799
|
-
newAttributes.link = value;
|
|
10800
|
-
}
|
|
10801
|
-
if (key === "inline-style-color") {
|
|
10802
|
-
newStyles.color = value;
|
|
10803
|
-
}
|
|
10804
|
-
if (key === "inline-style-background-color") {
|
|
10805
|
-
newStyles.backgroundColor = value;
|
|
10806
|
-
}
|
|
10807
|
-
}
|
|
10808
|
-
});
|
|
10809
|
-
return { classes, attributes: newAttributes, styles: newStyles };
|
|
10810
|
-
}
|
|
10811
|
-
}
|
|
10812
|
-
const logger$4r = getLogger("block-dom");
|
|
10500
|
+
const logger$4s = getLogger("block-dom");
|
|
10813
10501
|
function isBlock$1(node) {
|
|
10814
10502
|
if (!(node instanceof HTMLDivElement)) {
|
|
10815
10503
|
return false;
|
|
@@ -10830,12 +10518,12 @@ var __publicField = (obj, key, value) => {
|
|
|
10830
10518
|
}
|
|
10831
10519
|
function getBlockId(block) {
|
|
10832
10520
|
const { id } = block;
|
|
10833
|
-
assert(logger$
|
|
10521
|
+
assert(logger$4s, id, "no block id");
|
|
10834
10522
|
return id;
|
|
10835
10523
|
}
|
|
10836
10524
|
function getBlockType(block) {
|
|
10837
10525
|
const type = block.getAttribute("data-block-type");
|
|
10838
|
-
assert(logger$
|
|
10526
|
+
assert(logger$4s, type, "invalid block dom, no data-type");
|
|
10839
10527
|
return type;
|
|
10840
10528
|
}
|
|
10841
10529
|
function getParentBlock(node) {
|
|
@@ -10858,12 +10546,12 @@ var __publicField = (obj, key, value) => {
|
|
|
10858
10546
|
}
|
|
10859
10547
|
function getParentContainer(block) {
|
|
10860
10548
|
const container = block.closest("div[data-type=editor-container]");
|
|
10861
|
-
assert(logger$
|
|
10549
|
+
assert(logger$4s, container, "failed to get block container");
|
|
10862
10550
|
return container;
|
|
10863
10551
|
}
|
|
10864
10552
|
function getBlockContent(block) {
|
|
10865
10553
|
const content = block.querySelector(":scope >div[data-type=block-content]");
|
|
10866
|
-
assert(logger$
|
|
10554
|
+
assert(logger$4s, content, "no block content");
|
|
10867
10555
|
return content;
|
|
10868
10556
|
}
|
|
10869
10557
|
function getBlockTools(block) {
|
|
@@ -10872,7 +10560,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10872
10560
|
tools = createElement("div", [], block);
|
|
10873
10561
|
tools.setAttribute("data-type", "block-tools");
|
|
10874
10562
|
}
|
|
10875
|
-
assert(logger$
|
|
10563
|
+
assert(logger$4s, tools, "no block tools");
|
|
10876
10564
|
return tools;
|
|
10877
10565
|
}
|
|
10878
10566
|
function getExistsBlockTools(block) {
|
|
@@ -10893,7 +10581,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10893
10581
|
function createBlockElement(editor, path, data2) {
|
|
10894
10582
|
const blockData = editor.editorDecorators.decorateBlock(path, data2);
|
|
10895
10583
|
const { id, type } = blockData;
|
|
10896
|
-
assert(logger$
|
|
10584
|
+
assert(logger$4s, id, "no block id");
|
|
10897
10585
|
const elem = createElement("div", [`${type}-block`], null);
|
|
10898
10586
|
elem.id = id;
|
|
10899
10587
|
elem.setAttribute("data-type", "editor-block");
|
|
@@ -10931,7 +10619,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10931
10619
|
}
|
|
10932
10620
|
function getBoxTypeFromElement(box) {
|
|
10933
10621
|
const type = box.getAttribute("data-box-type");
|
|
10934
|
-
assert(logger$
|
|
10622
|
+
assert(logger$4s, type, "not a valid box element, no type");
|
|
10935
10623
|
return type;
|
|
10936
10624
|
}
|
|
10937
10625
|
function isBox(node) {
|
|
@@ -10942,7 +10630,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10942
10630
|
}
|
|
10943
10631
|
function getBoxId(box) {
|
|
10944
10632
|
const { id } = box;
|
|
10945
|
-
assert(logger$
|
|
10633
|
+
assert(logger$4s, id, "no box id");
|
|
10946
10634
|
return id;
|
|
10947
10635
|
}
|
|
10948
10636
|
function getParentBox(node) {
|
|
@@ -10964,23 +10652,13 @@ var __publicField = (obj, key, value) => {
|
|
|
10964
10652
|
}
|
|
10965
10653
|
function getBoxContent(box) {
|
|
10966
10654
|
const content = box.querySelector("span[data-type=box-content]");
|
|
10967
|
-
assert(logger$
|
|
10655
|
+
assert(logger$4s, content, "invalid box dom, no content");
|
|
10968
10656
|
return content;
|
|
10969
10657
|
}
|
|
10970
10658
|
function createInsertionElement(type, id, attributes) {
|
|
10971
10659
|
const elem = createElement("span", [`${type}-insertion`], null);
|
|
10972
10660
|
elem.setAttribute("data-type", "editor-insertion");
|
|
10973
10661
|
elem.setAttribute("data-insertion-id", id);
|
|
10974
|
-
if (attributes) {
|
|
10975
|
-
const standardBlockRenderer = new StandardBlockRenderer();
|
|
10976
|
-
const { attributes: newAttributes } = standardBlockRenderer.generateCSSCustomProperties(attributes);
|
|
10977
|
-
if (newAttributes) {
|
|
10978
|
-
[...Object.entries(newAttributes)].forEach((item) => {
|
|
10979
|
-
const [key, value] = item;
|
|
10980
|
-
elem.setAttribute(key, value);
|
|
10981
|
-
});
|
|
10982
|
-
}
|
|
10983
|
-
}
|
|
10984
10662
|
return elem;
|
|
10985
10663
|
}
|
|
10986
10664
|
function findInsertionById(editor, id) {
|
|
@@ -10996,7 +10674,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10996
10674
|
}
|
|
10997
10675
|
function getInsertionContent(insertion) {
|
|
10998
10676
|
const content = insertion.querySelector("span[data-type=insertion-content]");
|
|
10999
|
-
assert(logger$
|
|
10677
|
+
assert(logger$4s, content, "invalid insertion-child dom, no content");
|
|
11000
10678
|
return content;
|
|
11001
10679
|
}
|
|
11002
10680
|
function getPrevBlock(block) {
|
|
@@ -11043,7 +10721,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11043
10721
|
const container = getParentContainer(block);
|
|
11044
10722
|
const children = getChildBlocks(container);
|
|
11045
10723
|
const index2 = children.indexOf(block);
|
|
11046
|
-
assert(logger$
|
|
10724
|
+
assert(logger$4s, index2 !== -1, "invalid block & container dom, failed to get block index");
|
|
11047
10725
|
return index2;
|
|
11048
10726
|
}
|
|
11049
10727
|
function isInBlock(target) {
|
|
@@ -11068,6 +10746,38 @@ var __publicField = (obj, key, value) => {
|
|
|
11068
10746
|
function isTitleBlock$2(block) {
|
|
11069
10747
|
return block.hasAttribute("data-document-title");
|
|
11070
10748
|
}
|
|
10749
|
+
const logger$4r = getLogger("block-class");
|
|
10750
|
+
function getBlockClass(editor, block) {
|
|
10751
|
+
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10752
|
+
}
|
|
10753
|
+
function getTextBlockClass(editor, block) {
|
|
10754
|
+
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10755
|
+
assert(logger$4r, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
10756
|
+
return text2;
|
|
10757
|
+
}
|
|
10758
|
+
function getComplexBlockClass(editor, block) {
|
|
10759
|
+
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10760
|
+
assert(logger$4r, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
10761
|
+
return complex;
|
|
10762
|
+
}
|
|
10763
|
+
function getBlockClassByType(editor, type) {
|
|
10764
|
+
return editor.editorBlocks.getBlockClass(type);
|
|
10765
|
+
}
|
|
10766
|
+
function isTextKindBlock(editor, block) {
|
|
10767
|
+
return getBlockClass(editor, block).blockKind === "text";
|
|
10768
|
+
}
|
|
10769
|
+
function isTextKindBlockType(editor, type) {
|
|
10770
|
+
return editor.editorBlocks.getBlockClass(type).blockKind === "text";
|
|
10771
|
+
}
|
|
10772
|
+
function isComplexKindBlock(editor, block) {
|
|
10773
|
+
return getBlockClass(editor, block).blockKind === "complex";
|
|
10774
|
+
}
|
|
10775
|
+
function isSimpleBlock(editor, block) {
|
|
10776
|
+
return !isComplexKindBlock(editor, block);
|
|
10777
|
+
}
|
|
10778
|
+
function getBlockKind(editor, block) {
|
|
10779
|
+
return getBlockClass(editor, block).blockKind;
|
|
10780
|
+
}
|
|
11071
10781
|
const logger$4q = getLogger("text-block-child");
|
|
11072
10782
|
function isTextBlockContentChild(elem) {
|
|
11073
10783
|
if (elem.tagName !== "SPAN") {
|
|
@@ -12464,19 +12174,6 @@ var __publicField = (obj, key, value) => {
|
|
|
12464
12174
|
}
|
|
12465
12175
|
return findTop ? getFirstChildBlock(retContainer) : getLastChildBlock(retContainer);
|
|
12466
12176
|
}
|
|
12467
|
-
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
12468
|
-
const blockId = getBlockId(complexBlock);
|
|
12469
|
-
assert(logger$4a, blockId === anchor2.blockId, "invalid start pos");
|
|
12470
|
-
assert(logger$4a, blockId === focus.blockId, "invalid end pos");
|
|
12471
|
-
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
12472
|
-
if (blockClass.adjustSelectionPos) {
|
|
12473
|
-
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
12474
|
-
}
|
|
12475
|
-
return {
|
|
12476
|
-
anchor: anchor2,
|
|
12477
|
-
focus
|
|
12478
|
-
};
|
|
12479
|
-
}
|
|
12480
12177
|
function isFullSelectedOneComplexBlock(editor, complexRange) {
|
|
12481
12178
|
const range = complexRange || editor.selection.range;
|
|
12482
12179
|
const { start, end } = range;
|
|
@@ -12771,6 +12468,19 @@ var __publicField = (obj, key, value) => {
|
|
|
12771
12468
|
}
|
|
12772
12469
|
assert(logger$47, false, "failed to find parent container in complex block");
|
|
12773
12470
|
}
|
|
12471
|
+
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
12472
|
+
const blockId = getBlockId(complexBlock);
|
|
12473
|
+
assert(logger$47, blockId === anchor2.blockId, "invalid start pos");
|
|
12474
|
+
assert(logger$47, blockId === focus.blockId, "invalid end pos");
|
|
12475
|
+
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
12476
|
+
if (blockClass.adjustSelectionPos) {
|
|
12477
|
+
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
12478
|
+
}
|
|
12479
|
+
return {
|
|
12480
|
+
anchor: anchor2,
|
|
12481
|
+
focus
|
|
12482
|
+
};
|
|
12483
|
+
}
|
|
12774
12484
|
function adjustSelectionPos$1(editor, anchor2, focus) {
|
|
12775
12485
|
const anchorBlock = editor.getBlockById(anchor2.blockId);
|
|
12776
12486
|
const focusBlock = editor.getBlockById(focus.blockId);
|
|
@@ -24580,6 +24290,289 @@ var __publicField = (obj, key, value) => {
|
|
|
24580
24290
|
insertionType: "inputting",
|
|
24581
24291
|
updateInsertionContent: updateInsertionContent$1
|
|
24582
24292
|
};
|
|
24293
|
+
class EditorBlockRenderers {
|
|
24294
|
+
constructor(editor) {
|
|
24295
|
+
__publicField(this, "renders", []);
|
|
24296
|
+
this.editor = editor;
|
|
24297
|
+
}
|
|
24298
|
+
registerRender(render) {
|
|
24299
|
+
this.renders.push(render);
|
|
24300
|
+
}
|
|
24301
|
+
renderBox(path, attributes) {
|
|
24302
|
+
const result = {
|
|
24303
|
+
classes: [],
|
|
24304
|
+
attributes: {},
|
|
24305
|
+
styles: {}
|
|
24306
|
+
};
|
|
24307
|
+
this.renders.forEach((render) => {
|
|
24308
|
+
if (render.renderBox) {
|
|
24309
|
+
const ret = render.renderBox(this.editor, path, attributes);
|
|
24310
|
+
if (ret.classes) {
|
|
24311
|
+
result.classes.push(...ret.classes);
|
|
24312
|
+
}
|
|
24313
|
+
if (ret.attributes) {
|
|
24314
|
+
result.attributes = {
|
|
24315
|
+
...result.attributes,
|
|
24316
|
+
...ret.attributes
|
|
24317
|
+
};
|
|
24318
|
+
}
|
|
24319
|
+
if (ret.styles) {
|
|
24320
|
+
result.styles = {
|
|
24321
|
+
...result.styles,
|
|
24322
|
+
...ret.styles
|
|
24323
|
+
};
|
|
24324
|
+
}
|
|
24325
|
+
}
|
|
24326
|
+
});
|
|
24327
|
+
return result;
|
|
24328
|
+
}
|
|
24329
|
+
renderText(path, attributes) {
|
|
24330
|
+
const result = {
|
|
24331
|
+
classes: [],
|
|
24332
|
+
attributes: {},
|
|
24333
|
+
styles: {}
|
|
24334
|
+
};
|
|
24335
|
+
this.renders.forEach((render) => {
|
|
24336
|
+
if (render.renderText) {
|
|
24337
|
+
const ret = render.renderText(this.editor, path, attributes);
|
|
24338
|
+
if (ret.classes) {
|
|
24339
|
+
result.classes.push(...ret.classes);
|
|
24340
|
+
}
|
|
24341
|
+
if (ret.attributes) {
|
|
24342
|
+
result.attributes = {
|
|
24343
|
+
...result.attributes,
|
|
24344
|
+
...ret.attributes
|
|
24345
|
+
};
|
|
24346
|
+
}
|
|
24347
|
+
if (ret.styles) {
|
|
24348
|
+
result.styles = {
|
|
24349
|
+
...result.styles,
|
|
24350
|
+
...ret.styles
|
|
24351
|
+
};
|
|
24352
|
+
}
|
|
24353
|
+
}
|
|
24354
|
+
});
|
|
24355
|
+
return result;
|
|
24356
|
+
}
|
|
24357
|
+
renderBlock(editor, path, blockData) {
|
|
24358
|
+
const result = {
|
|
24359
|
+
classes: [],
|
|
24360
|
+
attributes: {},
|
|
24361
|
+
styles: {}
|
|
24362
|
+
};
|
|
24363
|
+
this.renders.forEach((render) => {
|
|
24364
|
+
if (render.renderBlock) {
|
|
24365
|
+
const ret = render.renderBlock(this.editor, path, blockData);
|
|
24366
|
+
if (ret.classes) {
|
|
24367
|
+
result.classes.push(...ret.classes);
|
|
24368
|
+
}
|
|
24369
|
+
if (ret.attributes) {
|
|
24370
|
+
result.attributes = {
|
|
24371
|
+
...result.attributes,
|
|
24372
|
+
...ret.attributes
|
|
24373
|
+
};
|
|
24374
|
+
}
|
|
24375
|
+
if (ret.styles) {
|
|
24376
|
+
result.styles = {
|
|
24377
|
+
...result.styles,
|
|
24378
|
+
...ret.styles
|
|
24379
|
+
};
|
|
24380
|
+
}
|
|
24381
|
+
}
|
|
24382
|
+
});
|
|
24383
|
+
return result;
|
|
24384
|
+
}
|
|
24385
|
+
updateBlock(editor, path, blockElement, blockData) {
|
|
24386
|
+
this.renders.forEach((render) => {
|
|
24387
|
+
var _a;
|
|
24388
|
+
(_a = render.updateBlock) == null ? void 0 : _a.call(render, editor, path, blockElement, blockData);
|
|
24389
|
+
});
|
|
24390
|
+
}
|
|
24391
|
+
}
|
|
24392
|
+
class OnesEditorHoveringBlock extends tinyTypedEmitter.TypedEmitter {
|
|
24393
|
+
constructor(editor) {
|
|
24394
|
+
super();
|
|
24395
|
+
__publicField(this, "hoveringBlock", null);
|
|
24396
|
+
__publicField(this, "hoveringElem", null);
|
|
24397
|
+
__publicField(this, "hoveringTextChild", null);
|
|
24398
|
+
__publicField(this, "filters", []);
|
|
24399
|
+
__publicField(this, "finders", []);
|
|
24400
|
+
__publicField(this, "handleDocumentMouseMove", (event) => {
|
|
24401
|
+
if (this.hoveringBlock) {
|
|
24402
|
+
for (const filter of this.filters) {
|
|
24403
|
+
if (filter.isInBlock(this.hoveringBlock, event)) {
|
|
24404
|
+
return;
|
|
24405
|
+
}
|
|
24406
|
+
}
|
|
24407
|
+
}
|
|
24408
|
+
const elem = getElementFromPoint(event.x, event.y, { noFilter: true });
|
|
24409
|
+
if (!elem) {
|
|
24410
|
+
this.setHoveringBlock(null, event, null, elem);
|
|
24411
|
+
return;
|
|
24412
|
+
}
|
|
24413
|
+
let block = getParentBlock(elem);
|
|
24414
|
+
if (!block || !isChildNode(this.editor.rootContainer, block)) {
|
|
24415
|
+
block = this.findBlockByFinders(event);
|
|
24416
|
+
if (!block) {
|
|
24417
|
+
this.setHoveringBlock(null, event, null, elem);
|
|
24418
|
+
return;
|
|
24419
|
+
}
|
|
24420
|
+
}
|
|
24421
|
+
const child = this.getParentTextContentChild(block, elem);
|
|
24422
|
+
this.setHoveringBlock(block, event, child, elem);
|
|
24423
|
+
});
|
|
24424
|
+
this.editor = editor;
|
|
24425
|
+
if (clientType.isMobile) {
|
|
24426
|
+
document.addEventListener("click", this.handleDocumentMouseMove);
|
|
24427
|
+
} else {
|
|
24428
|
+
document.addEventListener("mousemove", this.handleDocumentMouseMove);
|
|
24429
|
+
}
|
|
24430
|
+
}
|
|
24431
|
+
destroy() {
|
|
24432
|
+
document.removeEventListener("mousemove", this.handleDocumentMouseMove);
|
|
24433
|
+
this.filters.forEach((filter) => filter.destroy());
|
|
24434
|
+
this.filters = [];
|
|
24435
|
+
this.finders.forEach((finder) => finder.destroy());
|
|
24436
|
+
this.finders = [];
|
|
24437
|
+
}
|
|
24438
|
+
addFilter(filter) {
|
|
24439
|
+
this.filters.push(filter);
|
|
24440
|
+
}
|
|
24441
|
+
addFinder(finder) {
|
|
24442
|
+
this.finders.push(finder);
|
|
24443
|
+
}
|
|
24444
|
+
hoveringBlockId() {
|
|
24445
|
+
if (!this.hoveringBlock) {
|
|
24446
|
+
return "";
|
|
24447
|
+
}
|
|
24448
|
+
return getBlockId(this.hoveringBlock);
|
|
24449
|
+
}
|
|
24450
|
+
findBlockByFinders(event) {
|
|
24451
|
+
for (let i = 0; i < this.finders.length; i++) {
|
|
24452
|
+
const finder = this.finders[i];
|
|
24453
|
+
const b = finder.findTargetBlock(this.editor, event);
|
|
24454
|
+
if (b) {
|
|
24455
|
+
return b;
|
|
24456
|
+
}
|
|
24457
|
+
}
|
|
24458
|
+
return null;
|
|
24459
|
+
}
|
|
24460
|
+
setHoveringBlock(block, event, child, pointElem) {
|
|
24461
|
+
if (this.hoveringBlock === block && this.hoveringTextChild === child && this.hoveringElem === event.target) {
|
|
24462
|
+
return;
|
|
24463
|
+
}
|
|
24464
|
+
if (this.hoveringBlock !== block) {
|
|
24465
|
+
const oldBlock = this.hoveringBlock && isChildNode(this.editor.rootContainer, this.hoveringBlock) ? this.hoveringBlock : null;
|
|
24466
|
+
if (oldBlock) {
|
|
24467
|
+
removeClass(oldBlock, "hover");
|
|
24468
|
+
}
|
|
24469
|
+
if (block) {
|
|
24470
|
+
addClass(block, "hover");
|
|
24471
|
+
}
|
|
24472
|
+
this.emit("change", block, oldBlock, event);
|
|
24473
|
+
}
|
|
24474
|
+
if (this.hoveringElem !== pointElem || this.hoveringBlock !== block) {
|
|
24475
|
+
this.emit("targetChange", block, this.hoveringBlock, pointElem, this.hoveringElem);
|
|
24476
|
+
}
|
|
24477
|
+
const oldChild = this.hoveringTextChild;
|
|
24478
|
+
this.hoveringTextChild = child;
|
|
24479
|
+
this.hoveringElem = pointElem;
|
|
24480
|
+
this.hoveringBlock = block;
|
|
24481
|
+
this.emit("childChange", this.hoveringBlock, child, oldChild, event);
|
|
24482
|
+
}
|
|
24483
|
+
static get(editor) {
|
|
24484
|
+
return editor.addCustom("standard-hovering-block", () => new OnesEditorHoveringBlock(editor));
|
|
24485
|
+
}
|
|
24486
|
+
getParentTextContentChild(block, elem) {
|
|
24487
|
+
if (!isTextKindBlock(this.editor, block)) {
|
|
24488
|
+
return null;
|
|
24489
|
+
}
|
|
24490
|
+
const content = getBlockContent(block);
|
|
24491
|
+
if (elem.parentElement === content) {
|
|
24492
|
+
return elem;
|
|
24493
|
+
}
|
|
24494
|
+
const box = getParentBox(elem);
|
|
24495
|
+
return box;
|
|
24496
|
+
}
|
|
24497
|
+
}
|
|
24498
|
+
const COLOR_PREFIX = "style-color-";
|
|
24499
|
+
const BACKGROUND_COLOR_PREFIX$1 = "style-bg-color-";
|
|
24500
|
+
class StandardBlockRenderer {
|
|
24501
|
+
renderText(editor, path, attributes) {
|
|
24502
|
+
return this.generateCSSCustomProperties(attributes);
|
|
24503
|
+
}
|
|
24504
|
+
renderBlock(editor, path, blockData) {
|
|
24505
|
+
var _a, _b;
|
|
24506
|
+
const attributes = {};
|
|
24507
|
+
const styles = Object.entries(blockData).filter((k) => k[0].startsWith("style-"));
|
|
24508
|
+
styles.forEach(([key, value]) => {
|
|
24509
|
+
attributes[`data-${key}`] = `${value}`;
|
|
24510
|
+
});
|
|
24511
|
+
const classes = [];
|
|
24512
|
+
if (((_b = (_a = editor.selection) == null ? void 0 : _a.range) == null ? void 0 : _b.start.blockId) === blockData.id) {
|
|
24513
|
+
classes.push("focused");
|
|
24514
|
+
}
|
|
24515
|
+
if (typeof blockData.align === "string" && blockData.align) {
|
|
24516
|
+
attributes["data-style-align"] = blockData.align;
|
|
24517
|
+
}
|
|
24518
|
+
if (blockData.heading) {
|
|
24519
|
+
attributes["data-style-heading"] = String(blockData.heading);
|
|
24520
|
+
}
|
|
24521
|
+
if (blockData.quoted) {
|
|
24522
|
+
attributes["data-style-quoted"] = "true";
|
|
24523
|
+
}
|
|
24524
|
+
if (OnesEditorHoveringBlock.get(editor).hoveringBlockId() === blockData.id) {
|
|
24525
|
+
classes.push("hover");
|
|
24526
|
+
}
|
|
24527
|
+
return { attributes, classes };
|
|
24528
|
+
}
|
|
24529
|
+
updateBlock(editor, path, blockElement, blockData) {
|
|
24530
|
+
Array.from(blockElement.attributes).forEach((a) => {
|
|
24531
|
+
if (a.name.startsWith("data-style-")) {
|
|
24532
|
+
blockElement.removeAttribute(a.name);
|
|
24533
|
+
}
|
|
24534
|
+
});
|
|
24535
|
+
const { attributes, classes } = this.renderBlock(editor, path, blockData);
|
|
24536
|
+
if (attributes) {
|
|
24537
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
24538
|
+
blockElement.setAttribute(key, value);
|
|
24539
|
+
});
|
|
24540
|
+
}
|
|
24541
|
+
if (classes) {
|
|
24542
|
+
classes.forEach((c) => {
|
|
24543
|
+
addClass(blockElement, c);
|
|
24544
|
+
});
|
|
24545
|
+
}
|
|
24546
|
+
}
|
|
24547
|
+
generateCSSCustomProperties(attributes) {
|
|
24548
|
+
const classes = [];
|
|
24549
|
+
const newAttributes = {};
|
|
24550
|
+
const newStyles = {};
|
|
24551
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
24552
|
+
if (value === true) {
|
|
24553
|
+
if (key.startsWith(COLOR_PREFIX)) {
|
|
24554
|
+
newAttributes["data-style-color"] = key.substring(COLOR_PREFIX.length);
|
|
24555
|
+
} else if (key.startsWith(BACKGROUND_COLOR_PREFIX$1)) {
|
|
24556
|
+
newAttributes["data-style-bg-color"] = key.substring(BACKGROUND_COLOR_PREFIX$1.length);
|
|
24557
|
+
} else if (key.startsWith("style")) {
|
|
24558
|
+
classes.push(key);
|
|
24559
|
+
}
|
|
24560
|
+
} else if (typeof value === "string") {
|
|
24561
|
+
if (key === "link") {
|
|
24562
|
+
classes.push("link");
|
|
24563
|
+
newAttributes.link = value;
|
|
24564
|
+
}
|
|
24565
|
+
if (key === "inline-style-color") {
|
|
24566
|
+
newStyles.color = value;
|
|
24567
|
+
}
|
|
24568
|
+
if (key === "inline-style-background-color") {
|
|
24569
|
+
newStyles.backgroundColor = value;
|
|
24570
|
+
}
|
|
24571
|
+
}
|
|
24572
|
+
});
|
|
24573
|
+
return { classes, attributes: newAttributes, styles: newStyles };
|
|
24574
|
+
}
|
|
24575
|
+
}
|
|
24583
24576
|
const logger$3D = getLogger("editor-insertion");
|
|
24584
24577
|
class EditorInsertions {
|
|
24585
24578
|
constructor(editor) {
|
|
@@ -24597,8 +24590,22 @@ var __publicField = (obj, key, value) => {
|
|
|
24597
24590
|
assert(logger$3D, exists, `unknown insertion type: ${type}`);
|
|
24598
24591
|
return exists;
|
|
24599
24592
|
}
|
|
24593
|
+
createInsertionElement(type, id, attributes) {
|
|
24594
|
+
const elem = createInsertionElement(type, id);
|
|
24595
|
+
if (attributes) {
|
|
24596
|
+
const standardBlockRenderer = new StandardBlockRenderer();
|
|
24597
|
+
const { attributes: newAttributes } = standardBlockRenderer.generateCSSCustomProperties(attributes);
|
|
24598
|
+
if (newAttributes) {
|
|
24599
|
+
[...Object.entries(newAttributes)].forEach((item) => {
|
|
24600
|
+
const [key, value] = item;
|
|
24601
|
+
elem.setAttribute(key, value);
|
|
24602
|
+
});
|
|
24603
|
+
}
|
|
24604
|
+
}
|
|
24605
|
+
return elem;
|
|
24606
|
+
}
|
|
24600
24607
|
createInsertion(blockContent, insertion) {
|
|
24601
|
-
const insertionElement = createInsertionElement(insertion.type, insertion.id, insertion.attributes);
|
|
24608
|
+
const insertionElement = this.createInsertionElement(insertion.type, insertion.id, insertion.attributes);
|
|
24602
24609
|
const insertionContent = createInsertionContentElement(insertionElement);
|
|
24603
24610
|
const insertionClass = this.getInsertionClass(insertion.type);
|
|
24604
24611
|
insertionClass.updateInsertionContent(this.editor, insertionElement, insertionContent, insertion);
|
|
@@ -24707,7 +24714,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24707
24714
|
__publicField(this, "composing", false);
|
|
24708
24715
|
__publicField(this, "callbacks");
|
|
24709
24716
|
__publicField(this, "inputElement");
|
|
24710
|
-
__publicField(this, "
|
|
24717
|
+
__publicField(this, "handleBlur", () => {
|
|
24711
24718
|
this.editor.emit("blur", this.editor);
|
|
24712
24719
|
this.callbacks.onBlur();
|
|
24713
24720
|
});
|
|
@@ -24734,8 +24741,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24734
24741
|
return;
|
|
24735
24742
|
}
|
|
24736
24743
|
setTimeout(() => {
|
|
24737
|
-
this.
|
|
24738
|
-
this.callbacks.onBlur();
|
|
24744
|
+
this.handleBlur();
|
|
24739
24745
|
});
|
|
24740
24746
|
});
|
|
24741
24747
|
__publicField(this, "handleDocumentSelectionChange", () => {
|
|
@@ -24750,8 +24756,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24750
24756
|
return;
|
|
24751
24757
|
}
|
|
24752
24758
|
}
|
|
24753
|
-
this.
|
|
24754
|
-
this.callbacks.onBlur();
|
|
24759
|
+
this.handleBlur();
|
|
24755
24760
|
}, 100);
|
|
24756
24761
|
});
|
|
24757
24762
|
__publicField(this, "handleEditorSelectionChanged", () => {
|
|
@@ -24865,7 +24870,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24865
24870
|
document.addEventListener("selectionchange", this.handleDocumentSelectionChange);
|
|
24866
24871
|
this.editor.addListener("selectionChanged", this.handleEditorSelectionChanged);
|
|
24867
24872
|
this.editor.addListener("readonlyChanged", this.handleReadonlyChanged);
|
|
24868
|
-
window.addEventListener("blur", this.
|
|
24873
|
+
window.addEventListener("blur", this.handleBlur);
|
|
24869
24874
|
window.addEventListener("focus", this.handleWindowFocus);
|
|
24870
24875
|
}
|
|
24871
24876
|
isInCommandBar(target) {
|
|
@@ -24895,7 +24900,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24895
24900
|
input2.oninput = null;
|
|
24896
24901
|
input2.oncopy = null;
|
|
24897
24902
|
document.removeEventListener("paste", this.handlePaste);
|
|
24898
|
-
window.removeEventListener("blur", this.
|
|
24903
|
+
window.removeEventListener("blur", this.handleBlur);
|
|
24899
24904
|
window.removeEventListener("focus", this.handleWindowFocus);
|
|
24900
24905
|
input2.oncut = null;
|
|
24901
24906
|
}
|
|
@@ -28297,7 +28302,16 @@ ${codeText}
|
|
|
28297
28302
|
this.pasteDocs(docs, null, files);
|
|
28298
28303
|
}
|
|
28299
28304
|
});
|
|
28300
|
-
__publicField(this, "onBlur",
|
|
28305
|
+
__publicField(this, "onBlur", () => {
|
|
28306
|
+
var _a;
|
|
28307
|
+
for (const handler of this.handlers) {
|
|
28308
|
+
if ((_a = handler.handleBlur) == null ? void 0 : _a.call(handler, this.editor)) {
|
|
28309
|
+
return;
|
|
28310
|
+
}
|
|
28311
|
+
}
|
|
28312
|
+
this.debounceBlur();
|
|
28313
|
+
});
|
|
28314
|
+
__publicField(this, "debounceBlur", debounce__default.default(() => {
|
|
28301
28315
|
const range = this.editor.selection.range;
|
|
28302
28316
|
if (!range.isCollapsed()) {
|
|
28303
28317
|
let block = null;
|
|
@@ -28432,7 +28446,7 @@ ${codeText}
|
|
|
28432
28446
|
}
|
|
28433
28447
|
onFocus() {
|
|
28434
28448
|
addClass(this.editor.rootElement, "active");
|
|
28435
|
-
this.
|
|
28449
|
+
this.debounceBlur.cancel();
|
|
28436
28450
|
this.removeActiveForBlur.cancel();
|
|
28437
28451
|
}
|
|
28438
28452
|
addHandler(handler) {
|
|
@@ -86859,7 +86873,7 @@ ${data2.flowchartText}
|
|
|
86859
86873
|
}
|
|
86860
86874
|
}
|
|
86861
86875
|
});
|
|
86862
|
-
editor.version = "2.2.
|
|
86876
|
+
editor.version = "2.2.2";
|
|
86863
86877
|
if (Logger$2.level === LogLevel.DEBUG) {
|
|
86864
86878
|
window.setReauthFail = (fail) => {
|
|
86865
86879
|
window.isReauthError = fail;
|
|
@@ -86960,7 +86974,7 @@ ${data2.flowchartText}
|
|
|
86960
86974
|
});
|
|
86961
86975
|
editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
|
|
86962
86976
|
OnesEditorToolbar.register(editor);
|
|
86963
|
-
editor.version = "2.2.
|
|
86977
|
+
editor.version = "2.2.2";
|
|
86964
86978
|
return editor;
|
|
86965
86979
|
}
|
|
86966
86980
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -133230,6 +133244,7 @@ ${data2.flowchartText}
|
|
|
133230
133244
|
exports2.loadJs = loadJs;
|
|
133231
133245
|
exports2.loadJsPromise = loadJsPromise;
|
|
133232
133246
|
exports2.lockers = lockers;
|
|
133247
|
+
exports2.logger = logger$4a;
|
|
133233
133248
|
exports2.markdownToDoc = markdownToDoc;
|
|
133234
133249
|
exports2.mergeCommands = mergeCommands;
|
|
133235
133250
|
exports2.mergeDocs = mergeDocs;
|