@ones-editor/editor 2.2.0 → 2.2.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/@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/list-block/src/list-data/index.d.ts +2 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +430 -408
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
div.editor-root {
|
|
37
37
|
--text-color: #303030;
|
|
38
38
|
--primary-color: #0064ff;
|
|
39
|
-
--background-selection: #
|
|
39
|
+
--background-selection: #0064ff1a;
|
|
40
40
|
--background-code: #cdcdcd40;
|
|
41
41
|
}
|
|
42
42
|
div.editor-root {
|
|
@@ -175,7 +175,8 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
|
|
|
175
175
|
/* border: 1px solid #BCBEC0; */
|
|
176
176
|
background-color: var(--background-code);
|
|
177
177
|
padding: 4px;
|
|
178
|
-
font: 0.8em
|
|
178
|
+
font-size: 0.8em;
|
|
179
|
+
font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
|
|
179
180
|
}
|
|
180
181
|
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] > span.text.style-sub, div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] > span.inputting-insertion.style-sub {
|
|
181
182
|
vertical-align: sub;
|
|
@@ -360,7 +361,7 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
|
|
|
360
361
|
border-left: 4px solid #d4d6d9;
|
|
361
362
|
color: #87888a;
|
|
362
363
|
}
|
|
363
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]:not([data-list-level]) {
|
|
364
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]:not([data-list-level], [block-padding-level]) {
|
|
364
365
|
padding-left: 8px;
|
|
365
366
|
}
|
|
366
367
|
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="1"] {
|
|
@@ -7651,8 +7652,8 @@ var __publicField = (obj, key, value) => {
|
|
|
7651
7652
|
return value;
|
|
7652
7653
|
};
|
|
7653
7654
|
(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,
|
|
7655
|
+
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));
|
|
7656
|
+
})(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
7657
|
"use strict";
|
|
7657
7658
|
const _interopDefaultLegacy = (e2) => e2 && typeof e2 === "object" && "default" in e2 ? e2 : { default: e2 };
|
|
7658
7659
|
function _interopNamespace(e2) {
|
|
@@ -10494,322 +10495,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10494
10495
|
var _a;
|
|
10495
10496
|
return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
|
|
10496
10497
|
}
|
|
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");
|
|
10498
|
+
const logger$4s = getLogger("block-dom");
|
|
10813
10499
|
function isBlock$1(node) {
|
|
10814
10500
|
if (!(node instanceof HTMLDivElement)) {
|
|
10815
10501
|
return false;
|
|
@@ -10830,12 +10516,12 @@ var __publicField = (obj, key, value) => {
|
|
|
10830
10516
|
}
|
|
10831
10517
|
function getBlockId(block) {
|
|
10832
10518
|
const { id } = block;
|
|
10833
|
-
assert(logger$
|
|
10519
|
+
assert(logger$4s, id, "no block id");
|
|
10834
10520
|
return id;
|
|
10835
10521
|
}
|
|
10836
10522
|
function getBlockType(block) {
|
|
10837
10523
|
const type = block.getAttribute("data-block-type");
|
|
10838
|
-
assert(logger$
|
|
10524
|
+
assert(logger$4s, type, "invalid block dom, no data-type");
|
|
10839
10525
|
return type;
|
|
10840
10526
|
}
|
|
10841
10527
|
function getParentBlock(node) {
|
|
@@ -10858,12 +10544,12 @@ var __publicField = (obj, key, value) => {
|
|
|
10858
10544
|
}
|
|
10859
10545
|
function getParentContainer(block) {
|
|
10860
10546
|
const container = block.closest("div[data-type=editor-container]");
|
|
10861
|
-
assert(logger$
|
|
10547
|
+
assert(logger$4s, container, "failed to get block container");
|
|
10862
10548
|
return container;
|
|
10863
10549
|
}
|
|
10864
10550
|
function getBlockContent(block) {
|
|
10865
10551
|
const content = block.querySelector(":scope >div[data-type=block-content]");
|
|
10866
|
-
assert(logger$
|
|
10552
|
+
assert(logger$4s, content, "no block content");
|
|
10867
10553
|
return content;
|
|
10868
10554
|
}
|
|
10869
10555
|
function getBlockTools(block) {
|
|
@@ -10872,7 +10558,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10872
10558
|
tools = createElement("div", [], block);
|
|
10873
10559
|
tools.setAttribute("data-type", "block-tools");
|
|
10874
10560
|
}
|
|
10875
|
-
assert(logger$
|
|
10561
|
+
assert(logger$4s, tools, "no block tools");
|
|
10876
10562
|
return tools;
|
|
10877
10563
|
}
|
|
10878
10564
|
function getExistsBlockTools(block) {
|
|
@@ -10893,7 +10579,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10893
10579
|
function createBlockElement(editor, path, data2) {
|
|
10894
10580
|
const blockData = editor.editorDecorators.decorateBlock(path, data2);
|
|
10895
10581
|
const { id, type } = blockData;
|
|
10896
|
-
assert(logger$
|
|
10582
|
+
assert(logger$4s, id, "no block id");
|
|
10897
10583
|
const elem = createElement("div", [`${type}-block`], null);
|
|
10898
10584
|
elem.id = id;
|
|
10899
10585
|
elem.setAttribute("data-type", "editor-block");
|
|
@@ -10931,7 +10617,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10931
10617
|
}
|
|
10932
10618
|
function getBoxTypeFromElement(box) {
|
|
10933
10619
|
const type = box.getAttribute("data-box-type");
|
|
10934
|
-
assert(logger$
|
|
10620
|
+
assert(logger$4s, type, "not a valid box element, no type");
|
|
10935
10621
|
return type;
|
|
10936
10622
|
}
|
|
10937
10623
|
function isBox(node) {
|
|
@@ -10942,7 +10628,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10942
10628
|
}
|
|
10943
10629
|
function getBoxId(box) {
|
|
10944
10630
|
const { id } = box;
|
|
10945
|
-
assert(logger$
|
|
10631
|
+
assert(logger$4s, id, "no box id");
|
|
10946
10632
|
return id;
|
|
10947
10633
|
}
|
|
10948
10634
|
function getParentBox(node) {
|
|
@@ -10964,23 +10650,13 @@ var __publicField = (obj, key, value) => {
|
|
|
10964
10650
|
}
|
|
10965
10651
|
function getBoxContent(box) {
|
|
10966
10652
|
const content = box.querySelector("span[data-type=box-content]");
|
|
10967
|
-
assert(logger$
|
|
10653
|
+
assert(logger$4s, content, "invalid box dom, no content");
|
|
10968
10654
|
return content;
|
|
10969
10655
|
}
|
|
10970
10656
|
function createInsertionElement(type, id, attributes) {
|
|
10971
10657
|
const elem = createElement("span", [`${type}-insertion`], null);
|
|
10972
10658
|
elem.setAttribute("data-type", "editor-insertion");
|
|
10973
10659
|
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
10660
|
return elem;
|
|
10985
10661
|
}
|
|
10986
10662
|
function findInsertionById(editor, id) {
|
|
@@ -10996,7 +10672,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10996
10672
|
}
|
|
10997
10673
|
function getInsertionContent(insertion) {
|
|
10998
10674
|
const content = insertion.querySelector("span[data-type=insertion-content]");
|
|
10999
|
-
assert(logger$
|
|
10675
|
+
assert(logger$4s, content, "invalid insertion-child dom, no content");
|
|
11000
10676
|
return content;
|
|
11001
10677
|
}
|
|
11002
10678
|
function getPrevBlock(block) {
|
|
@@ -11043,7 +10719,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11043
10719
|
const container = getParentContainer(block);
|
|
11044
10720
|
const children = getChildBlocks(container);
|
|
11045
10721
|
const index2 = children.indexOf(block);
|
|
11046
|
-
assert(logger$
|
|
10722
|
+
assert(logger$4s, index2 !== -1, "invalid block & container dom, failed to get block index");
|
|
11047
10723
|
return index2;
|
|
11048
10724
|
}
|
|
11049
10725
|
function isInBlock(target) {
|
|
@@ -11068,6 +10744,38 @@ var __publicField = (obj, key, value) => {
|
|
|
11068
10744
|
function isTitleBlock$2(block) {
|
|
11069
10745
|
return block.hasAttribute("data-document-title");
|
|
11070
10746
|
}
|
|
10747
|
+
const logger$4r = getLogger("block-class");
|
|
10748
|
+
function getBlockClass(editor, block) {
|
|
10749
|
+
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10750
|
+
}
|
|
10751
|
+
function getTextBlockClass(editor, block) {
|
|
10752
|
+
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10753
|
+
assert(logger$4r, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
10754
|
+
return text2;
|
|
10755
|
+
}
|
|
10756
|
+
function getComplexBlockClass(editor, block) {
|
|
10757
|
+
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
10758
|
+
assert(logger$4r, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
10759
|
+
return complex;
|
|
10760
|
+
}
|
|
10761
|
+
function getBlockClassByType(editor, type) {
|
|
10762
|
+
return editor.editorBlocks.getBlockClass(type);
|
|
10763
|
+
}
|
|
10764
|
+
function isTextKindBlock(editor, block) {
|
|
10765
|
+
return getBlockClass(editor, block).blockKind === "text";
|
|
10766
|
+
}
|
|
10767
|
+
function isTextKindBlockType(editor, type) {
|
|
10768
|
+
return editor.editorBlocks.getBlockClass(type).blockKind === "text";
|
|
10769
|
+
}
|
|
10770
|
+
function isComplexKindBlock(editor, block) {
|
|
10771
|
+
return getBlockClass(editor, block).blockKind === "complex";
|
|
10772
|
+
}
|
|
10773
|
+
function isSimpleBlock(editor, block) {
|
|
10774
|
+
return !isComplexKindBlock(editor, block);
|
|
10775
|
+
}
|
|
10776
|
+
function getBlockKind(editor, block) {
|
|
10777
|
+
return getBlockClass(editor, block).blockKind;
|
|
10778
|
+
}
|
|
11071
10779
|
const logger$4q = getLogger("text-block-child");
|
|
11072
10780
|
function isTextBlockContentChild(elem) {
|
|
11073
10781
|
if (elem.tagName !== "SPAN") {
|
|
@@ -12464,19 +12172,6 @@ var __publicField = (obj, key, value) => {
|
|
|
12464
12172
|
}
|
|
12465
12173
|
return findTop ? getFirstChildBlock(retContainer) : getLastChildBlock(retContainer);
|
|
12466
12174
|
}
|
|
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
12175
|
function isFullSelectedOneComplexBlock(editor, complexRange) {
|
|
12481
12176
|
const range = complexRange || editor.selection.range;
|
|
12482
12177
|
const { start, end } = range;
|
|
@@ -12771,6 +12466,19 @@ var __publicField = (obj, key, value) => {
|
|
|
12771
12466
|
}
|
|
12772
12467
|
assert(logger$47, false, "failed to find parent container in complex block");
|
|
12773
12468
|
}
|
|
12469
|
+
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
12470
|
+
const blockId = getBlockId(complexBlock);
|
|
12471
|
+
assert(logger$47, blockId === anchor2.blockId, "invalid start pos");
|
|
12472
|
+
assert(logger$47, blockId === focus.blockId, "invalid end pos");
|
|
12473
|
+
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
12474
|
+
if (blockClass.adjustSelectionPos) {
|
|
12475
|
+
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
12476
|
+
}
|
|
12477
|
+
return {
|
|
12478
|
+
anchor: anchor2,
|
|
12479
|
+
focus
|
|
12480
|
+
};
|
|
12481
|
+
}
|
|
12774
12482
|
function adjustSelectionPos$1(editor, anchor2, focus) {
|
|
12775
12483
|
const anchorBlock = editor.getBlockById(anchor2.blockId);
|
|
12776
12484
|
const focusBlock = editor.getBlockById(focus.blockId);
|
|
@@ -24580,6 +24288,289 @@ var __publicField = (obj, key, value) => {
|
|
|
24580
24288
|
insertionType: "inputting",
|
|
24581
24289
|
updateInsertionContent: updateInsertionContent$1
|
|
24582
24290
|
};
|
|
24291
|
+
class EditorBlockRenderers {
|
|
24292
|
+
constructor(editor) {
|
|
24293
|
+
__publicField(this, "renders", []);
|
|
24294
|
+
this.editor = editor;
|
|
24295
|
+
}
|
|
24296
|
+
registerRender(render) {
|
|
24297
|
+
this.renders.push(render);
|
|
24298
|
+
}
|
|
24299
|
+
renderBox(path, attributes) {
|
|
24300
|
+
const result = {
|
|
24301
|
+
classes: [],
|
|
24302
|
+
attributes: {},
|
|
24303
|
+
styles: {}
|
|
24304
|
+
};
|
|
24305
|
+
this.renders.forEach((render) => {
|
|
24306
|
+
if (render.renderBox) {
|
|
24307
|
+
const ret = render.renderBox(this.editor, path, attributes);
|
|
24308
|
+
if (ret.classes) {
|
|
24309
|
+
result.classes.push(...ret.classes);
|
|
24310
|
+
}
|
|
24311
|
+
if (ret.attributes) {
|
|
24312
|
+
result.attributes = {
|
|
24313
|
+
...result.attributes,
|
|
24314
|
+
...ret.attributes
|
|
24315
|
+
};
|
|
24316
|
+
}
|
|
24317
|
+
if (ret.styles) {
|
|
24318
|
+
result.styles = {
|
|
24319
|
+
...result.styles,
|
|
24320
|
+
...ret.styles
|
|
24321
|
+
};
|
|
24322
|
+
}
|
|
24323
|
+
}
|
|
24324
|
+
});
|
|
24325
|
+
return result;
|
|
24326
|
+
}
|
|
24327
|
+
renderText(path, attributes) {
|
|
24328
|
+
const result = {
|
|
24329
|
+
classes: [],
|
|
24330
|
+
attributes: {},
|
|
24331
|
+
styles: {}
|
|
24332
|
+
};
|
|
24333
|
+
this.renders.forEach((render) => {
|
|
24334
|
+
if (render.renderText) {
|
|
24335
|
+
const ret = render.renderText(this.editor, path, attributes);
|
|
24336
|
+
if (ret.classes) {
|
|
24337
|
+
result.classes.push(...ret.classes);
|
|
24338
|
+
}
|
|
24339
|
+
if (ret.attributes) {
|
|
24340
|
+
result.attributes = {
|
|
24341
|
+
...result.attributes,
|
|
24342
|
+
...ret.attributes
|
|
24343
|
+
};
|
|
24344
|
+
}
|
|
24345
|
+
if (ret.styles) {
|
|
24346
|
+
result.styles = {
|
|
24347
|
+
...result.styles,
|
|
24348
|
+
...ret.styles
|
|
24349
|
+
};
|
|
24350
|
+
}
|
|
24351
|
+
}
|
|
24352
|
+
});
|
|
24353
|
+
return result;
|
|
24354
|
+
}
|
|
24355
|
+
renderBlock(editor, path, blockData) {
|
|
24356
|
+
const result = {
|
|
24357
|
+
classes: [],
|
|
24358
|
+
attributes: {},
|
|
24359
|
+
styles: {}
|
|
24360
|
+
};
|
|
24361
|
+
this.renders.forEach((render) => {
|
|
24362
|
+
if (render.renderBlock) {
|
|
24363
|
+
const ret = render.renderBlock(this.editor, path, blockData);
|
|
24364
|
+
if (ret.classes) {
|
|
24365
|
+
result.classes.push(...ret.classes);
|
|
24366
|
+
}
|
|
24367
|
+
if (ret.attributes) {
|
|
24368
|
+
result.attributes = {
|
|
24369
|
+
...result.attributes,
|
|
24370
|
+
...ret.attributes
|
|
24371
|
+
};
|
|
24372
|
+
}
|
|
24373
|
+
if (ret.styles) {
|
|
24374
|
+
result.styles = {
|
|
24375
|
+
...result.styles,
|
|
24376
|
+
...ret.styles
|
|
24377
|
+
};
|
|
24378
|
+
}
|
|
24379
|
+
}
|
|
24380
|
+
});
|
|
24381
|
+
return result;
|
|
24382
|
+
}
|
|
24383
|
+
updateBlock(editor, path, blockElement, blockData) {
|
|
24384
|
+
this.renders.forEach((render) => {
|
|
24385
|
+
var _a;
|
|
24386
|
+
(_a = render.updateBlock) == null ? void 0 : _a.call(render, editor, path, blockElement, blockData);
|
|
24387
|
+
});
|
|
24388
|
+
}
|
|
24389
|
+
}
|
|
24390
|
+
class OnesEditorHoveringBlock extends tinyTypedEmitter.TypedEmitter {
|
|
24391
|
+
constructor(editor) {
|
|
24392
|
+
super();
|
|
24393
|
+
__publicField(this, "hoveringBlock", null);
|
|
24394
|
+
__publicField(this, "hoveringElem", null);
|
|
24395
|
+
__publicField(this, "hoveringTextChild", null);
|
|
24396
|
+
__publicField(this, "filters", []);
|
|
24397
|
+
__publicField(this, "finders", []);
|
|
24398
|
+
__publicField(this, "handleDocumentMouseMove", (event) => {
|
|
24399
|
+
if (this.hoveringBlock) {
|
|
24400
|
+
for (const filter of this.filters) {
|
|
24401
|
+
if (filter.isInBlock(this.hoveringBlock, event)) {
|
|
24402
|
+
return;
|
|
24403
|
+
}
|
|
24404
|
+
}
|
|
24405
|
+
}
|
|
24406
|
+
const elem = getElementFromPoint(event.x, event.y, { noFilter: true });
|
|
24407
|
+
if (!elem) {
|
|
24408
|
+
this.setHoveringBlock(null, event, null, elem);
|
|
24409
|
+
return;
|
|
24410
|
+
}
|
|
24411
|
+
let block = getParentBlock(elem);
|
|
24412
|
+
if (!block || !isChildNode(this.editor.rootContainer, block)) {
|
|
24413
|
+
block = this.findBlockByFinders(event);
|
|
24414
|
+
if (!block) {
|
|
24415
|
+
this.setHoveringBlock(null, event, null, elem);
|
|
24416
|
+
return;
|
|
24417
|
+
}
|
|
24418
|
+
}
|
|
24419
|
+
const child = this.getParentTextContentChild(block, elem);
|
|
24420
|
+
this.setHoveringBlock(block, event, child, elem);
|
|
24421
|
+
});
|
|
24422
|
+
this.editor = editor;
|
|
24423
|
+
if (clientType.isMobile) {
|
|
24424
|
+
document.addEventListener("click", this.handleDocumentMouseMove);
|
|
24425
|
+
} else {
|
|
24426
|
+
document.addEventListener("mousemove", this.handleDocumentMouseMove);
|
|
24427
|
+
}
|
|
24428
|
+
}
|
|
24429
|
+
destroy() {
|
|
24430
|
+
document.removeEventListener("mousemove", this.handleDocumentMouseMove);
|
|
24431
|
+
this.filters.forEach((filter) => filter.destroy());
|
|
24432
|
+
this.filters = [];
|
|
24433
|
+
this.finders.forEach((finder) => finder.destroy());
|
|
24434
|
+
this.finders = [];
|
|
24435
|
+
}
|
|
24436
|
+
addFilter(filter) {
|
|
24437
|
+
this.filters.push(filter);
|
|
24438
|
+
}
|
|
24439
|
+
addFinder(finder) {
|
|
24440
|
+
this.finders.push(finder);
|
|
24441
|
+
}
|
|
24442
|
+
hoveringBlockId() {
|
|
24443
|
+
if (!this.hoveringBlock) {
|
|
24444
|
+
return "";
|
|
24445
|
+
}
|
|
24446
|
+
return getBlockId(this.hoveringBlock);
|
|
24447
|
+
}
|
|
24448
|
+
findBlockByFinders(event) {
|
|
24449
|
+
for (let i = 0; i < this.finders.length; i++) {
|
|
24450
|
+
const finder = this.finders[i];
|
|
24451
|
+
const b = finder.findTargetBlock(this.editor, event);
|
|
24452
|
+
if (b) {
|
|
24453
|
+
return b;
|
|
24454
|
+
}
|
|
24455
|
+
}
|
|
24456
|
+
return null;
|
|
24457
|
+
}
|
|
24458
|
+
setHoveringBlock(block, event, child, pointElem) {
|
|
24459
|
+
if (this.hoveringBlock === block && this.hoveringTextChild === child && this.hoveringElem === event.target) {
|
|
24460
|
+
return;
|
|
24461
|
+
}
|
|
24462
|
+
if (this.hoveringBlock !== block) {
|
|
24463
|
+
const oldBlock = this.hoveringBlock && isChildNode(this.editor.rootContainer, this.hoveringBlock) ? this.hoveringBlock : null;
|
|
24464
|
+
if (oldBlock) {
|
|
24465
|
+
removeClass(oldBlock, "hover");
|
|
24466
|
+
}
|
|
24467
|
+
if (block) {
|
|
24468
|
+
addClass(block, "hover");
|
|
24469
|
+
}
|
|
24470
|
+
this.emit("change", block, oldBlock, event);
|
|
24471
|
+
}
|
|
24472
|
+
if (this.hoveringElem !== pointElem || this.hoveringBlock !== block) {
|
|
24473
|
+
this.emit("targetChange", block, this.hoveringBlock, pointElem, this.hoveringElem);
|
|
24474
|
+
}
|
|
24475
|
+
const oldChild = this.hoveringTextChild;
|
|
24476
|
+
this.hoveringTextChild = child;
|
|
24477
|
+
this.hoveringElem = pointElem;
|
|
24478
|
+
this.hoveringBlock = block;
|
|
24479
|
+
this.emit("childChange", this.hoveringBlock, child, oldChild, event);
|
|
24480
|
+
}
|
|
24481
|
+
static get(editor) {
|
|
24482
|
+
return editor.addCustom("standard-hovering-block", () => new OnesEditorHoveringBlock(editor));
|
|
24483
|
+
}
|
|
24484
|
+
getParentTextContentChild(block, elem) {
|
|
24485
|
+
if (!isTextKindBlock(this.editor, block)) {
|
|
24486
|
+
return null;
|
|
24487
|
+
}
|
|
24488
|
+
const content = getBlockContent(block);
|
|
24489
|
+
if (elem.parentElement === content) {
|
|
24490
|
+
return elem;
|
|
24491
|
+
}
|
|
24492
|
+
const box = getParentBox(elem);
|
|
24493
|
+
return box;
|
|
24494
|
+
}
|
|
24495
|
+
}
|
|
24496
|
+
const COLOR_PREFIX = "style-color-";
|
|
24497
|
+
const BACKGROUND_COLOR_PREFIX$1 = "style-bg-color-";
|
|
24498
|
+
class StandardBlockRenderer {
|
|
24499
|
+
renderText(editor, path, attributes) {
|
|
24500
|
+
return this.generateCSSCustomProperties(attributes);
|
|
24501
|
+
}
|
|
24502
|
+
renderBlock(editor, path, blockData) {
|
|
24503
|
+
var _a, _b;
|
|
24504
|
+
const attributes = {};
|
|
24505
|
+
const styles = Object.entries(blockData).filter((k) => k[0].startsWith("style-"));
|
|
24506
|
+
styles.forEach(([key, value]) => {
|
|
24507
|
+
attributes[`data-${key}`] = `${value}`;
|
|
24508
|
+
});
|
|
24509
|
+
const classes = [];
|
|
24510
|
+
if (((_b = (_a = editor.selection) == null ? void 0 : _a.range) == null ? void 0 : _b.start.blockId) === blockData.id) {
|
|
24511
|
+
classes.push("focused");
|
|
24512
|
+
}
|
|
24513
|
+
if (typeof blockData.align === "string" && blockData.align) {
|
|
24514
|
+
attributes["data-style-align"] = blockData.align;
|
|
24515
|
+
}
|
|
24516
|
+
if (blockData.heading) {
|
|
24517
|
+
attributes["data-style-heading"] = String(blockData.heading);
|
|
24518
|
+
}
|
|
24519
|
+
if (blockData.quoted) {
|
|
24520
|
+
attributes["data-style-quoted"] = "true";
|
|
24521
|
+
}
|
|
24522
|
+
if (OnesEditorHoveringBlock.get(editor).hoveringBlockId() === blockData.id) {
|
|
24523
|
+
classes.push("hover");
|
|
24524
|
+
}
|
|
24525
|
+
return { attributes, classes };
|
|
24526
|
+
}
|
|
24527
|
+
updateBlock(editor, path, blockElement, blockData) {
|
|
24528
|
+
Array.from(blockElement.attributes).forEach((a) => {
|
|
24529
|
+
if (a.name.startsWith("data-style-")) {
|
|
24530
|
+
blockElement.removeAttribute(a.name);
|
|
24531
|
+
}
|
|
24532
|
+
});
|
|
24533
|
+
const { attributes, classes } = this.renderBlock(editor, path, blockData);
|
|
24534
|
+
if (attributes) {
|
|
24535
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
24536
|
+
blockElement.setAttribute(key, value);
|
|
24537
|
+
});
|
|
24538
|
+
}
|
|
24539
|
+
if (classes) {
|
|
24540
|
+
classes.forEach((c) => {
|
|
24541
|
+
addClass(blockElement, c);
|
|
24542
|
+
});
|
|
24543
|
+
}
|
|
24544
|
+
}
|
|
24545
|
+
generateCSSCustomProperties(attributes) {
|
|
24546
|
+
const classes = [];
|
|
24547
|
+
const newAttributes = {};
|
|
24548
|
+
const newStyles = {};
|
|
24549
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
24550
|
+
if (value === true) {
|
|
24551
|
+
if (key.startsWith(COLOR_PREFIX)) {
|
|
24552
|
+
newAttributes["data-style-color"] = key.substring(COLOR_PREFIX.length);
|
|
24553
|
+
} else if (key.startsWith(BACKGROUND_COLOR_PREFIX$1)) {
|
|
24554
|
+
newAttributes["data-style-bg-color"] = key.substring(BACKGROUND_COLOR_PREFIX$1.length);
|
|
24555
|
+
} else if (key.startsWith("style")) {
|
|
24556
|
+
classes.push(key);
|
|
24557
|
+
}
|
|
24558
|
+
} else if (typeof value === "string") {
|
|
24559
|
+
if (key === "link") {
|
|
24560
|
+
classes.push("link");
|
|
24561
|
+
newAttributes.link = value;
|
|
24562
|
+
}
|
|
24563
|
+
if (key === "inline-style-color") {
|
|
24564
|
+
newStyles.color = value;
|
|
24565
|
+
}
|
|
24566
|
+
if (key === "inline-style-background-color") {
|
|
24567
|
+
newStyles.backgroundColor = value;
|
|
24568
|
+
}
|
|
24569
|
+
}
|
|
24570
|
+
});
|
|
24571
|
+
return { classes, attributes: newAttributes, styles: newStyles };
|
|
24572
|
+
}
|
|
24573
|
+
}
|
|
24583
24574
|
const logger$3D = getLogger("editor-insertion");
|
|
24584
24575
|
class EditorInsertions {
|
|
24585
24576
|
constructor(editor) {
|
|
@@ -24597,8 +24588,22 @@ var __publicField = (obj, key, value) => {
|
|
|
24597
24588
|
assert(logger$3D, exists, `unknown insertion type: ${type}`);
|
|
24598
24589
|
return exists;
|
|
24599
24590
|
}
|
|
24591
|
+
createInsertionElement(type, id, attributes) {
|
|
24592
|
+
const elem = createInsertionElement(type, id);
|
|
24593
|
+
if (attributes) {
|
|
24594
|
+
const standardBlockRenderer = new StandardBlockRenderer();
|
|
24595
|
+
const { attributes: newAttributes } = standardBlockRenderer.generateCSSCustomProperties(attributes);
|
|
24596
|
+
if (newAttributes) {
|
|
24597
|
+
[...Object.entries(newAttributes)].forEach((item) => {
|
|
24598
|
+
const [key, value] = item;
|
|
24599
|
+
elem.setAttribute(key, value);
|
|
24600
|
+
});
|
|
24601
|
+
}
|
|
24602
|
+
}
|
|
24603
|
+
return elem;
|
|
24604
|
+
}
|
|
24600
24605
|
createInsertion(blockContent, insertion) {
|
|
24601
|
-
const insertionElement = createInsertionElement(insertion.type, insertion.id, insertion.attributes);
|
|
24606
|
+
const insertionElement = this.createInsertionElement(insertion.type, insertion.id, insertion.attributes);
|
|
24602
24607
|
const insertionContent = createInsertionContentElement(insertionElement);
|
|
24603
24608
|
const insertionClass = this.getInsertionClass(insertion.type);
|
|
24604
24609
|
insertionClass.updateInsertionContent(this.editor, insertionElement, insertionContent, insertion);
|
|
@@ -24707,7 +24712,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24707
24712
|
__publicField(this, "composing", false);
|
|
24708
24713
|
__publicField(this, "callbacks");
|
|
24709
24714
|
__publicField(this, "inputElement");
|
|
24710
|
-
__publicField(this, "
|
|
24715
|
+
__publicField(this, "handleBlur", () => {
|
|
24711
24716
|
this.editor.emit("blur", this.editor);
|
|
24712
24717
|
this.callbacks.onBlur();
|
|
24713
24718
|
});
|
|
@@ -24734,8 +24739,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24734
24739
|
return;
|
|
24735
24740
|
}
|
|
24736
24741
|
setTimeout(() => {
|
|
24737
|
-
this.
|
|
24738
|
-
this.callbacks.onBlur();
|
|
24742
|
+
this.handleBlur();
|
|
24739
24743
|
});
|
|
24740
24744
|
});
|
|
24741
24745
|
__publicField(this, "handleDocumentSelectionChange", () => {
|
|
@@ -24750,8 +24754,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24750
24754
|
return;
|
|
24751
24755
|
}
|
|
24752
24756
|
}
|
|
24753
|
-
this.
|
|
24754
|
-
this.callbacks.onBlur();
|
|
24757
|
+
this.handleBlur();
|
|
24755
24758
|
}, 100);
|
|
24756
24759
|
});
|
|
24757
24760
|
__publicField(this, "handleEditorSelectionChanged", () => {
|
|
@@ -24865,7 +24868,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24865
24868
|
document.addEventListener("selectionchange", this.handleDocumentSelectionChange);
|
|
24866
24869
|
this.editor.addListener("selectionChanged", this.handleEditorSelectionChanged);
|
|
24867
24870
|
this.editor.addListener("readonlyChanged", this.handleReadonlyChanged);
|
|
24868
|
-
window.addEventListener("blur", this.
|
|
24871
|
+
window.addEventListener("blur", this.handleBlur);
|
|
24869
24872
|
window.addEventListener("focus", this.handleWindowFocus);
|
|
24870
24873
|
}
|
|
24871
24874
|
isInCommandBar(target) {
|
|
@@ -24895,7 +24898,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24895
24898
|
input2.oninput = null;
|
|
24896
24899
|
input2.oncopy = null;
|
|
24897
24900
|
document.removeEventListener("paste", this.handlePaste);
|
|
24898
|
-
window.removeEventListener("blur", this.
|
|
24901
|
+
window.removeEventListener("blur", this.handleBlur);
|
|
24899
24902
|
window.removeEventListener("focus", this.handleWindowFocus);
|
|
24900
24903
|
input2.oncut = null;
|
|
24901
24904
|
}
|
|
@@ -26383,6 +26386,10 @@ var __publicField = (obj, key, value) => {
|
|
|
26383
26386
|
const firstBlock = getFirstChildBlock(nextContainer);
|
|
26384
26387
|
return firstBlock;
|
|
26385
26388
|
}
|
|
26389
|
+
const targetBlock = isFindPrev(type) ? getPrevBlock(parentComplexBlock) : getNextBlock(parentComplexBlock);
|
|
26390
|
+
if (targetBlock) {
|
|
26391
|
+
return targetBlock;
|
|
26392
|
+
}
|
|
26386
26393
|
return findNextBlockInComplexBlock(editor, parentComplexBlock, type);
|
|
26387
26394
|
}
|
|
26388
26395
|
function findNextOrPrevOfParentBlock(editor, block, type) {
|
|
@@ -28297,7 +28304,16 @@ ${codeText}
|
|
|
28297
28304
|
this.pasteDocs(docs, null, files);
|
|
28298
28305
|
}
|
|
28299
28306
|
});
|
|
28300
|
-
__publicField(this, "onBlur",
|
|
28307
|
+
__publicField(this, "onBlur", () => {
|
|
28308
|
+
var _a;
|
|
28309
|
+
for (const handler of this.handlers) {
|
|
28310
|
+
if ((_a = handler.handleBlur) == null ? void 0 : _a.call(handler, this.editor)) {
|
|
28311
|
+
return;
|
|
28312
|
+
}
|
|
28313
|
+
}
|
|
28314
|
+
this.debounceBlur();
|
|
28315
|
+
});
|
|
28316
|
+
__publicField(this, "debounceBlur", debounce__default.default(() => {
|
|
28301
28317
|
const range = this.editor.selection.range;
|
|
28302
28318
|
if (!range.isCollapsed()) {
|
|
28303
28319
|
let block = null;
|
|
@@ -28432,7 +28448,7 @@ ${codeText}
|
|
|
28432
28448
|
}
|
|
28433
28449
|
onFocus() {
|
|
28434
28450
|
addClass(this.editor.rootElement, "active");
|
|
28435
|
-
this.
|
|
28451
|
+
this.debounceBlur.cancel();
|
|
28436
28452
|
this.removeActiveForBlur.cancel();
|
|
28437
28453
|
}
|
|
28438
28454
|
addHandler(handler) {
|
|
@@ -30555,6 +30571,11 @@ ${codeText}
|
|
|
30555
30571
|
if (!value) {
|
|
30556
30572
|
delete attributes[key];
|
|
30557
30573
|
} else {
|
|
30574
|
+
const scriptKeys = ["style-sub", "style-super"];
|
|
30575
|
+
if (scriptKeys.includes(key)) {
|
|
30576
|
+
const [another] = scriptKeys.filter((keys) => keys !== key);
|
|
30577
|
+
delete attributes[another];
|
|
30578
|
+
}
|
|
30558
30579
|
attributes[key] = value;
|
|
30559
30580
|
}
|
|
30560
30581
|
});
|
|
@@ -48199,6 +48220,44 @@ ${codeText}
|
|
|
48199
48220
|
"Shift+Tab": handleShiftTab$3,
|
|
48200
48221
|
"Backspace": handleBackspace$2
|
|
48201
48222
|
};
|
|
48223
|
+
function getListType(listData) {
|
|
48224
|
+
if (listData.textOnly) {
|
|
48225
|
+
return "text-only";
|
|
48226
|
+
}
|
|
48227
|
+
if (listData.checkbox) {
|
|
48228
|
+
return listData.checkbox;
|
|
48229
|
+
}
|
|
48230
|
+
if (listData.ordered) {
|
|
48231
|
+
return "ordered";
|
|
48232
|
+
}
|
|
48233
|
+
return "unordered";
|
|
48234
|
+
}
|
|
48235
|
+
function getListMarker(listData) {
|
|
48236
|
+
var _a, _b;
|
|
48237
|
+
if (listData.checkbox) {
|
|
48238
|
+
return "";
|
|
48239
|
+
}
|
|
48240
|
+
const level = (_a = listData.level) != null ? _a : 1;
|
|
48241
|
+
if (listData.ordered) {
|
|
48242
|
+
const num = getListNumber(level, (_b = listData.start) != null ? _b : 1);
|
|
48243
|
+
return `${num}.`;
|
|
48244
|
+
}
|
|
48245
|
+
return getListBullet(level);
|
|
48246
|
+
}
|
|
48247
|
+
function pickTextBlockData(listBlockData) {
|
|
48248
|
+
const textBlockData = {
|
|
48249
|
+
id: genId(),
|
|
48250
|
+
type: "text",
|
|
48251
|
+
text: listBlockData.text
|
|
48252
|
+
};
|
|
48253
|
+
const keys = ["heading", "quoted", "align"];
|
|
48254
|
+
for (const key of keys) {
|
|
48255
|
+
if (listBlockData[key] !== void 0) {
|
|
48256
|
+
textBlockData[key] = listBlockData[key];
|
|
48257
|
+
}
|
|
48258
|
+
}
|
|
48259
|
+
return textBlockData;
|
|
48260
|
+
}
|
|
48202
48261
|
function findPreviousBrotherWithHeading(block, heading, level = 1) {
|
|
48203
48262
|
if (!heading) {
|
|
48204
48263
|
return null;
|
|
@@ -48295,7 +48354,9 @@ ${codeText}
|
|
|
48295
48354
|
const fixStart = new FixStartByBlock(editor, srcBlock, { start: 1 });
|
|
48296
48355
|
fixStart.fix();
|
|
48297
48356
|
}
|
|
48357
|
+
const pickedTextBlock = pickTextBlockData(srcData);
|
|
48298
48358
|
const blockData = {
|
|
48359
|
+
...pickedTextBlock,
|
|
48299
48360
|
id: genId(),
|
|
48300
48361
|
type: "list",
|
|
48301
48362
|
level,
|
|
@@ -48304,12 +48365,6 @@ ${codeText}
|
|
|
48304
48365
|
ordered: false,
|
|
48305
48366
|
text: text2
|
|
48306
48367
|
};
|
|
48307
|
-
if (srcData.quoted) {
|
|
48308
|
-
blockData.quoted = true;
|
|
48309
|
-
}
|
|
48310
|
-
if (srcData.heading) {
|
|
48311
|
-
blockData.heading = srcData.heading;
|
|
48312
|
-
}
|
|
48313
48368
|
if (type === "ordered") {
|
|
48314
48369
|
blockData.ordered = true;
|
|
48315
48370
|
} else if (type === "checked" || type === "unchecked") {
|
|
@@ -48323,30 +48378,6 @@ ${codeText}
|
|
|
48323
48378
|
}
|
|
48324
48379
|
};
|
|
48325
48380
|
}
|
|
48326
|
-
function getListType(listData) {
|
|
48327
|
-
if (listData.textOnly) {
|
|
48328
|
-
return "text-only";
|
|
48329
|
-
}
|
|
48330
|
-
if (listData.checkbox) {
|
|
48331
|
-
return listData.checkbox;
|
|
48332
|
-
}
|
|
48333
|
-
if (listData.ordered) {
|
|
48334
|
-
return "ordered";
|
|
48335
|
-
}
|
|
48336
|
-
return "unordered";
|
|
48337
|
-
}
|
|
48338
|
-
function getListMarker(listData) {
|
|
48339
|
-
var _a, _b;
|
|
48340
|
-
if (listData.checkbox) {
|
|
48341
|
-
return "";
|
|
48342
|
-
}
|
|
48343
|
-
const level = (_a = listData.level) != null ? _a : 1;
|
|
48344
|
-
if (listData.ordered) {
|
|
48345
|
-
const num = getListNumber(level, (_b = listData.start) != null ? _b : 1);
|
|
48346
|
-
return `${num}.`;
|
|
48347
|
-
}
|
|
48348
|
-
return getListBullet(level);
|
|
48349
|
-
}
|
|
48350
48381
|
function isCheck(type) {
|
|
48351
48382
|
return type === "checked" || type === "unchecked";
|
|
48352
48383
|
}
|
|
@@ -48497,17 +48528,7 @@ ${codeText}
|
|
|
48497
48528
|
function convertListToTextBlock(editor, block) {
|
|
48498
48529
|
ensureIsListBlock(block);
|
|
48499
48530
|
const listBlockData = editor.getBlockData(block);
|
|
48500
|
-
const textBlockData =
|
|
48501
|
-
id: genId(),
|
|
48502
|
-
type: "text",
|
|
48503
|
-
text: listBlockData.text
|
|
48504
|
-
};
|
|
48505
|
-
if (listBlockData.heading) {
|
|
48506
|
-
textBlockData.heading = listBlockData.heading;
|
|
48507
|
-
}
|
|
48508
|
-
if (listBlockData.heading) {
|
|
48509
|
-
textBlockData.heading = listBlockData.heading;
|
|
48510
|
-
}
|
|
48531
|
+
const textBlockData = pickTextBlockData(listBlockData);
|
|
48511
48532
|
const container = getParentContainer(block);
|
|
48512
48533
|
const blockIndex = getBlockIndex(block);
|
|
48513
48534
|
editor.deleteBlock(block);
|
|
@@ -86859,7 +86880,7 @@ ${data2.flowchartText}
|
|
|
86859
86880
|
}
|
|
86860
86881
|
}
|
|
86861
86882
|
});
|
|
86862
|
-
editor.version = "2.2.
|
|
86883
|
+
editor.version = "2.2.1";
|
|
86863
86884
|
if (Logger$2.level === LogLevel.DEBUG) {
|
|
86864
86885
|
window.setReauthFail = (fail) => {
|
|
86865
86886
|
window.isReauthError = fail;
|
|
@@ -86960,7 +86981,7 @@ ${data2.flowchartText}
|
|
|
86960
86981
|
});
|
|
86961
86982
|
editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
|
|
86962
86983
|
OnesEditorToolbar.register(editor);
|
|
86963
|
-
editor.version = "2.2.
|
|
86984
|
+
editor.version = "2.2.1";
|
|
86964
86985
|
return editor;
|
|
86965
86986
|
}
|
|
86966
86987
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -133230,6 +133251,7 @@ ${data2.flowchartText}
|
|
|
133230
133251
|
exports2.loadJs = loadJs;
|
|
133231
133252
|
exports2.loadJsPromise = loadJsPromise;
|
|
133232
133253
|
exports2.lockers = lockers;
|
|
133254
|
+
exports2.logger = logger$4a;
|
|
133233
133255
|
exports2.markdownToDoc = markdownToDoc;
|
|
133234
133256
|
exports2.mergeCommands = mergeCommands;
|
|
133235
133257
|
exports2.mergeDocs = mergeDocs;
|