pressroom 0.1.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +22 -0
- data/MIT-LICENSE +20 -0
- data/README.md +172 -0
- data/Rakefile +8 -0
- data/app/assets/javascripts/pressroom/application.js +18 -0
- data/app/assets/javascripts/pressroom/controllers/editor_controller.js +146 -0
- data/app/assets/javascripts/pressroom/vendor/code.js +181 -0
- data/app/assets/javascripts/pressroom/vendor/delimiter.js +98 -0
- data/app/assets/javascripts/pressroom/vendor/editorjs.js +11217 -0
- data/app/assets/javascripts/pressroom/vendor/header.js +321 -0
- data/app/assets/javascripts/pressroom/vendor/image.js +1103 -0
- data/app/assets/javascripts/pressroom/vendor/inline-code.js +99 -0
- data/app/assets/javascripts/pressroom/vendor/list.js +2091 -0
- data/app/assets/javascripts/pressroom/vendor/marker.js +95 -0
- data/app/assets/javascripts/pressroom/vendor/quote.js +990 -0
- data/app/assets/javascripts/pressroom/vendor/stimulus.js +2563 -0
- data/app/assets/javascripts/pressroom/vendor/turbo.js +7256 -0
- data/app/assets/stylesheets/pressroom/admin.css +216 -0
- data/app/assets/stylesheets/pressroom/content.css +18 -0
- data/app/controllers/pressroom/application_controller.rb +41 -0
- data/app/controllers/pressroom/categories_controller.rb +50 -0
- data/app/controllers/pressroom/posts_controller.rb +98 -0
- data/app/controllers/pressroom/tags_controller.rb +39 -0
- data/app/controllers/pressroom/uploads_controller.rb +52 -0
- data/app/helpers/pressroom/application_helper.rb +4 -0
- data/app/helpers/pressroom/blocks_helper.rb +13 -0
- data/app/jobs/pressroom/application_job.rb +4 -0
- data/app/mailers/pressroom/application_mailer.rb +6 -0
- data/app/models/concerns/pressroom/authorable.rb +23 -0
- data/app/models/concerns/pressroom/sluggable.rb +66 -0
- data/app/models/pressroom/application_record.rb +7 -0
- data/app/models/pressroom/category.rb +54 -0
- data/app/models/pressroom/post.rb +90 -0
- data/app/models/pressroom/tag.rb +30 -0
- data/app/models/pressroom/tagging.rb +12 -0
- data/app/views/layouts/pressroom/admin.html.erb +34 -0
- data/app/views/layouts/pressroom/application.html.erb +17 -0
- data/app/views/pressroom/blocks/_code.html.erb +2 -0
- data/app/views/pressroom/blocks/_delimiter.html.erb +1 -0
- data/app/views/pressroom/blocks/_header.html.erb +5 -0
- data/app/views/pressroom/blocks/_image.html.erb +18 -0
- data/app/views/pressroom/blocks/_list.html.erb +6 -0
- data/app/views/pressroom/blocks/_list_items.html.erb +13 -0
- data/app/views/pressroom/blocks/_paragraph.html.erb +1 -0
- data/app/views/pressroom/blocks/_quote.html.erb +6 -0
- data/app/views/pressroom/categories/_form.html.erb +31 -0
- data/app/views/pressroom/categories/edit.html.erb +3 -0
- data/app/views/pressroom/categories/index.html.erb +34 -0
- data/app/views/pressroom/categories/new.html.erb +3 -0
- data/app/views/pressroom/posts/_form.html.erb +49 -0
- data/app/views/pressroom/posts/_post_row.html.erb +17 -0
- data/app/views/pressroom/posts/edit.html.erb +34 -0
- data/app/views/pressroom/posts/index.html.erb +38 -0
- data/app/views/pressroom/posts/new.html.erb +3 -0
- data/app/views/pressroom/tags/edit.html.erb +24 -0
- data/app/views/pressroom/tags/index.html.erb +27 -0
- data/config/editorjs_manifest.yml +53 -0
- data/config/importmap.rb +18 -0
- data/config/locales/pressroom.en.yml +16 -0
- data/config/locales/transliteration.ru.yml +70 -0
- data/config/locales/transliteration.uk.yml +70 -0
- data/config/routes.rb +17 -0
- data/db/migrate/20260821000001_create_pressroom_posts.rb +42 -0
- data/db/migrate/20260821000002_create_pressroom_taxonomy.rb +33 -0
- data/lib/pressroom/blocks/definition.rb +103 -0
- data/lib/pressroom/blocks/registry.rb +56 -0
- data/lib/pressroom/blocks/renderer.rb +97 -0
- data/lib/pressroom/blocks/sanitizer.rb +36 -0
- data/lib/pressroom/blocks/schema.rb +247 -0
- data/lib/pressroom/blocks/text_extractor.rb +46 -0
- data/lib/pressroom/built_in_blocks.rb +97 -0
- data/lib/pressroom/configuration.rb +64 -0
- data/lib/pressroom/engine.rb +33 -0
- data/lib/pressroom/errors.rb +11 -0
- data/lib/pressroom/feed.rb +69 -0
- data/lib/pressroom/transliteration.rb +213 -0
- data/lib/pressroom/version.rb +3 -0
- data/lib/pressroom.rb +70 -0
- data/lib/tasks/pressroom_tasks.rake +4 -0
- data/lib/tasks/pressroom_vendor.rake +31 -0
- metadata +171 -0
|
@@ -0,0 +1,2091 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.cdx-list{margin:0;padding:0;outline:none;display:grid;counter-reset:item;gap:var(--spacing-s);padding:var(--spacing-xs);--spacing-s: 8px;--spacing-xs: 6px;--list-counter-type: numeric;--radius-border: 5px;--checkbox-background: #fff;--color-border: #C9C9C9;--color-bg-checked: #369FFF;--line-height: 1.45em;--color-bg-checked-hover: #0059AB;--color-tick: #fff;--size-checkbox: 1.2em}.cdx-list__item{line-height:var(--line-height);display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto auto;grid-template-areas:"checkbox content" ". child"}.cdx-list__item-children{display:grid;grid-area:child;gap:var(--spacing-s);padding-top:var(--spacing-s)}.cdx-list__item [contenteditable]{outline:none}.cdx-list__item-content{word-break:break-word;white-space:pre-wrap;grid-area:content;padding-left:var(--spacing-s)}.cdx-list__item:before{counter-increment:item;white-space:nowrap}.cdx-list-ordered .cdx-list__item:before{content:counters(item,".",var(--list-counter-type)) "."}.cdx-list-ordered{counter-reset:item}.cdx-list-unordered .cdx-list__item:before{content:"•"}.cdx-list-checklist .cdx-list__item:before{content:""}.cdx-list__settings .cdx-settings-button{width:50%}.cdx-list__checkbox{padding-top:calc((var(--line-height) - var(--size-checkbox)) / 2);grid-area:checkbox;width:var(--size-checkbox);height:var(--size-checkbox);display:flex;cursor:pointer}.cdx-list__checkbox svg{opacity:0;height:var(--size-checkbox);width:var(--size-checkbox);left:-1px;top:-1px;position:absolute}@media (hover: hover){.cdx-list__checkbox:not(.cdx-list__checkbox--no-hover):hover .cdx-list__checkbox-check svg{opacity:1}}.cdx-list__checkbox--checked{line-height:var(--line-height)}@media (hover: hover){.cdx-list__checkbox--checked:not(.cdx-list__checkbox--checked--no-hover):hover .cdx-checklist__checkbox-check{background:var(--color-bg-checked-hover);border-color:var(--color-bg-checked-hover)}}.cdx-list__checkbox--checked .cdx-list__checkbox-check{background:var(--color-bg-checked);border-color:var(--color-bg-checked)}.cdx-list__checkbox--checked .cdx-list__checkbox-check svg{opacity:1}.cdx-list__checkbox--checked .cdx-list__checkbox-check svg path{stroke:var(--color-tick)}.cdx-list__checkbox--checked .cdx-list__checkbox-check:before{opacity:0;visibility:visible;transform:scale(2.5)}.cdx-list__checkbox-check{cursor:pointer;display:inline-block;position:relative;margin:0 auto;width:var(--size-checkbox);height:var(--size-checkbox);box-sizing:border-box;border-radius:var(--radius-border);border:1px solid var(--color-border);background:var(--checkbox-background)}.cdx-list__checkbox-check:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:100%;background-color:var(--color-bg-checked);visibility:hidden;pointer-events:none;transform:scale(1);transition:transform .4s ease-out,opacity .4s}.cdx-list__checkbox-check--disabled{pointer-events:none}.cdx-list-start-with-field{background:#F8F8F8;border:1px solid rgba(226,226,229,.2);border-radius:6px;padding:2px;display:grid;grid-template-columns:auto auto 1fr;grid-template-rows:auto}.cdx-list-start-with-field--invalid{background:#FFECED;border:1px solid #E13F3F}.cdx-list-start-with-field--invalid .cdx-list-start-with-field__input{color:#e13f3f}.cdx-list-start-with-field__input{font-size:14px;outline:none;font-weight:500;font-family:inherit;border:0;background:transparent;margin:0;padding:0;line-height:22px;min-width:calc(100% - var(--toolbox-buttons-size) - var(--icon-margin-right))}.cdx-list-start-with-field__input::placeholder{color:var(--grayText);font-weight:500}')),document.head.appendChild(e)}}catch(c){console.error("vite-plugin-css-injected-by-js",c)}})();
|
|
2
|
+
const Ct = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7 12L10.4884 15.8372C10.5677 15.9245 10.705 15.9245 10.7844 15.8372L17 9"/></svg>', Ae = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9.2 12L11.0586 13.8586C11.1367 13.9367 11.2633 13.9367 11.3414 13.8586L14.7 10.5"/><rect width="14" height="14" x="5" y="5" stroke="currentColor" stroke-width="2" rx="4"/></svg>', $e = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="9" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 17H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 12H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 7H4.99002"/></svg>', Be = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="12" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.79999 14L7.79999 7.2135C7.79999 7.12872 7.7011 7.0824 7.63597 7.13668L4.79999 9.5"/></svg>', St = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 14.2L10 7.4135C10 7.32872 9.90111 7.28241 9.83598 7.33668L7 9.7" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>', Ot = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 14.2L10 9.5" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 7.01L10 7" stroke="black" stroke-width="1.8" stroke-linecap="round"/></svg>', kt = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 14.2L10 7.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>', _t = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16.0087 14.2H16" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M7 14.2L7.78865 12M13 14.2L12.1377 12M7.78865 12C7.78865 12 9.68362 7 10 7C10.3065 7 12.1377 12 12.1377 12M7.78865 12L12.1377 12" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>', Et = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.2087 14.2H14.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M11.5 14.5C11.5 14.5 11 13.281 11 12.5M7 9.5C7 9.5 7.5 8.5 9 8.5C10.5 8.5 11 9.5 11 10.5L11 11.5M11 11.5L11 12.5M11 11.5C11 11.5 7 11 7 13C7 15.3031 11 15 11 12.5" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>', It = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 14.2L8 7.4135C8 7.32872 7.90111 7.28241 7.83598 7.33668L5 9.7" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M14 13L16.4167 10.7778M16.4167 10.7778L14 8.5M16.4167 10.7778H11.6562" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
3
|
+
var A = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
4
|
+
function wt(e) {
|
|
5
|
+
if (e.__esModule)
|
|
6
|
+
return e;
|
|
7
|
+
var t = e.default;
|
|
8
|
+
if (typeof t == "function") {
|
|
9
|
+
var n = function r() {
|
|
10
|
+
return this instanceof r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
n.prototype = t.prototype;
|
|
13
|
+
} else
|
|
14
|
+
n = {};
|
|
15
|
+
return Object.defineProperty(n, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
|
|
16
|
+
var i = Object.getOwnPropertyDescriptor(e, r);
|
|
17
|
+
Object.defineProperty(n, r, i.get ? i : {
|
|
18
|
+
enumerable: !0,
|
|
19
|
+
get: function() {
|
|
20
|
+
return e[r];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}), n;
|
|
24
|
+
}
|
|
25
|
+
var c = {}, V = {}, Y = {};
|
|
26
|
+
Object.defineProperty(Y, "__esModule", { value: !0 });
|
|
27
|
+
Y.allInputsSelector = Pt;
|
|
28
|
+
function Pt() {
|
|
29
|
+
var e = ["text", "password", "email", "number", "search", "tel", "url"];
|
|
30
|
+
return "[contenteditable=true], textarea, input:not([type]), " + e.map(function(t) {
|
|
31
|
+
return 'input[type="'.concat(t, '"]');
|
|
32
|
+
}).join(", ");
|
|
33
|
+
}
|
|
34
|
+
(function(e) {
|
|
35
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.allInputsSelector = void 0;
|
|
36
|
+
var t = Y;
|
|
37
|
+
Object.defineProperty(e, "allInputsSelector", { enumerable: !0, get: function() {
|
|
38
|
+
return t.allInputsSelector;
|
|
39
|
+
} });
|
|
40
|
+
})(V);
|
|
41
|
+
var k = {}, J = {};
|
|
42
|
+
Object.defineProperty(J, "__esModule", { value: !0 });
|
|
43
|
+
J.isNativeInput = jt;
|
|
44
|
+
function jt(e) {
|
|
45
|
+
var t = [
|
|
46
|
+
"INPUT",
|
|
47
|
+
"TEXTAREA"
|
|
48
|
+
];
|
|
49
|
+
return e && e.tagName ? t.includes(e.tagName) : !1;
|
|
50
|
+
}
|
|
51
|
+
(function(e) {
|
|
52
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isNativeInput = void 0;
|
|
53
|
+
var t = J;
|
|
54
|
+
Object.defineProperty(e, "isNativeInput", { enumerable: !0, get: function() {
|
|
55
|
+
return t.isNativeInput;
|
|
56
|
+
} });
|
|
57
|
+
})(k);
|
|
58
|
+
var Fe = {}, Q = {};
|
|
59
|
+
Object.defineProperty(Q, "__esModule", { value: !0 });
|
|
60
|
+
Q.append = Tt;
|
|
61
|
+
function Tt(e, t) {
|
|
62
|
+
Array.isArray(t) ? t.forEach(function(n) {
|
|
63
|
+
e.appendChild(n);
|
|
64
|
+
}) : e.appendChild(t);
|
|
65
|
+
}
|
|
66
|
+
(function(e) {
|
|
67
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.append = void 0;
|
|
68
|
+
var t = Q;
|
|
69
|
+
Object.defineProperty(e, "append", { enumerable: !0, get: function() {
|
|
70
|
+
return t.append;
|
|
71
|
+
} });
|
|
72
|
+
})(Fe);
|
|
73
|
+
var Z = {}, x = {};
|
|
74
|
+
Object.defineProperty(x, "__esModule", { value: !0 });
|
|
75
|
+
x.blockElements = Lt;
|
|
76
|
+
function Lt() {
|
|
77
|
+
return [
|
|
78
|
+
"address",
|
|
79
|
+
"article",
|
|
80
|
+
"aside",
|
|
81
|
+
"blockquote",
|
|
82
|
+
"canvas",
|
|
83
|
+
"div",
|
|
84
|
+
"dl",
|
|
85
|
+
"dt",
|
|
86
|
+
"fieldset",
|
|
87
|
+
"figcaption",
|
|
88
|
+
"figure",
|
|
89
|
+
"footer",
|
|
90
|
+
"form",
|
|
91
|
+
"h1",
|
|
92
|
+
"h2",
|
|
93
|
+
"h3",
|
|
94
|
+
"h4",
|
|
95
|
+
"h5",
|
|
96
|
+
"h6",
|
|
97
|
+
"header",
|
|
98
|
+
"hgroup",
|
|
99
|
+
"hr",
|
|
100
|
+
"li",
|
|
101
|
+
"main",
|
|
102
|
+
"nav",
|
|
103
|
+
"noscript",
|
|
104
|
+
"ol",
|
|
105
|
+
"output",
|
|
106
|
+
"p",
|
|
107
|
+
"pre",
|
|
108
|
+
"ruby",
|
|
109
|
+
"section",
|
|
110
|
+
"table",
|
|
111
|
+
"tbody",
|
|
112
|
+
"thead",
|
|
113
|
+
"tr",
|
|
114
|
+
"tfoot",
|
|
115
|
+
"ul",
|
|
116
|
+
"video"
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
(function(e) {
|
|
120
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.blockElements = void 0;
|
|
121
|
+
var t = x;
|
|
122
|
+
Object.defineProperty(e, "blockElements", { enumerable: !0, get: function() {
|
|
123
|
+
return t.blockElements;
|
|
124
|
+
} });
|
|
125
|
+
})(Z);
|
|
126
|
+
var Re = {}, ee = {};
|
|
127
|
+
Object.defineProperty(ee, "__esModule", { value: !0 });
|
|
128
|
+
ee.calculateBaseline = Mt;
|
|
129
|
+
function Mt(e) {
|
|
130
|
+
var t = window.getComputedStyle(e), n = parseFloat(t.fontSize), r = parseFloat(t.lineHeight) || n * 1.2, i = parseFloat(t.paddingTop), a = parseFloat(t.borderTopWidth), l = parseFloat(t.marginTop), s = n * 0.8, o = (r - n) / 2, d = l + a + i + o + s;
|
|
131
|
+
return d;
|
|
132
|
+
}
|
|
133
|
+
(function(e) {
|
|
134
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.calculateBaseline = void 0;
|
|
135
|
+
var t = ee;
|
|
136
|
+
Object.defineProperty(e, "calculateBaseline", { enumerable: !0, get: function() {
|
|
137
|
+
return t.calculateBaseline;
|
|
138
|
+
} });
|
|
139
|
+
})(Re);
|
|
140
|
+
var qe = {}, te = {}, ne = {}, re = {};
|
|
141
|
+
Object.defineProperty(re, "__esModule", { value: !0 });
|
|
142
|
+
re.isContentEditable = Nt;
|
|
143
|
+
function Nt(e) {
|
|
144
|
+
return e.contentEditable === "true";
|
|
145
|
+
}
|
|
146
|
+
(function(e) {
|
|
147
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isContentEditable = void 0;
|
|
148
|
+
var t = re;
|
|
149
|
+
Object.defineProperty(e, "isContentEditable", { enumerable: !0, get: function() {
|
|
150
|
+
return t.isContentEditable;
|
|
151
|
+
} });
|
|
152
|
+
})(ne);
|
|
153
|
+
Object.defineProperty(te, "__esModule", { value: !0 });
|
|
154
|
+
te.canSetCaret = Bt;
|
|
155
|
+
var At = k, $t = ne;
|
|
156
|
+
function Bt(e) {
|
|
157
|
+
var t = !0;
|
|
158
|
+
if ((0, At.isNativeInput)(e))
|
|
159
|
+
switch (e.type) {
|
|
160
|
+
case "file":
|
|
161
|
+
case "checkbox":
|
|
162
|
+
case "radio":
|
|
163
|
+
case "hidden":
|
|
164
|
+
case "submit":
|
|
165
|
+
case "button":
|
|
166
|
+
case "image":
|
|
167
|
+
case "reset":
|
|
168
|
+
t = !1;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
else
|
|
172
|
+
t = (0, $t.isContentEditable)(e);
|
|
173
|
+
return t;
|
|
174
|
+
}
|
|
175
|
+
(function(e) {
|
|
176
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.canSetCaret = void 0;
|
|
177
|
+
var t = te;
|
|
178
|
+
Object.defineProperty(e, "canSetCaret", { enumerable: !0, get: function() {
|
|
179
|
+
return t.canSetCaret;
|
|
180
|
+
} });
|
|
181
|
+
})(qe);
|
|
182
|
+
var $ = {}, ie = {};
|
|
183
|
+
function Wt(e, t, n) {
|
|
184
|
+
const r = n.value !== void 0 ? "value" : "get", i = n[r], a = `#${t}Cache`;
|
|
185
|
+
if (n[r] = function(...l) {
|
|
186
|
+
return this[a] === void 0 && (this[a] = i.apply(this, l)), this[a];
|
|
187
|
+
}, r === "get" && n.set) {
|
|
188
|
+
const l = n.set;
|
|
189
|
+
n.set = function(s) {
|
|
190
|
+
delete e[a], l.apply(this, s);
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return n;
|
|
194
|
+
}
|
|
195
|
+
function Ue() {
|
|
196
|
+
const e = {
|
|
197
|
+
win: !1,
|
|
198
|
+
mac: !1,
|
|
199
|
+
x11: !1,
|
|
200
|
+
linux: !1
|
|
201
|
+
}, t = Object.keys(e).find((n) => window.navigator.appVersion.toLowerCase().indexOf(n) !== -1);
|
|
202
|
+
return t !== void 0 && (e[t] = !0), e;
|
|
203
|
+
}
|
|
204
|
+
function ae(e) {
|
|
205
|
+
return e != null && e !== "" && (typeof e != "object" || Object.keys(e).length > 0);
|
|
206
|
+
}
|
|
207
|
+
function Dt(e) {
|
|
208
|
+
return !ae(e);
|
|
209
|
+
}
|
|
210
|
+
const Ht = () => typeof window < "u" && window.navigator !== null && ae(window.navigator.platform) && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1);
|
|
211
|
+
function Ft(e) {
|
|
212
|
+
const t = Ue();
|
|
213
|
+
return e = e.replace(/shift/gi, "⇧").replace(/backspace/gi, "⌫").replace(/enter/gi, "⏎").replace(/up/gi, "↑").replace(/left/gi, "→").replace(/down/gi, "↓").replace(/right/gi, "←").replace(/escape/gi, "⎋").replace(/insert/gi, "Ins").replace(/delete/gi, "␡").replace(/\+/gi, "+"), t.mac ? e = e.replace(/ctrl|cmd/gi, "⌘").replace(/alt/gi, "⌥") : e = e.replace(/cmd/gi, "Ctrl").replace(/windows/gi, "WIN"), e;
|
|
214
|
+
}
|
|
215
|
+
function Rt(e) {
|
|
216
|
+
return e[0].toUpperCase() + e.slice(1);
|
|
217
|
+
}
|
|
218
|
+
function qt(e) {
|
|
219
|
+
const t = document.createElement("div");
|
|
220
|
+
t.style.position = "absolute", t.style.left = "-999px", t.style.bottom = "-999px", t.innerHTML = e, document.body.appendChild(t);
|
|
221
|
+
const n = window.getSelection(), r = document.createRange();
|
|
222
|
+
if (r.selectNode(t), n === null)
|
|
223
|
+
throw new Error("Cannot copy text to clipboard");
|
|
224
|
+
n.removeAllRanges(), n.addRange(r), document.execCommand("copy"), document.body.removeChild(t);
|
|
225
|
+
}
|
|
226
|
+
function Ut(e, t, n) {
|
|
227
|
+
let r;
|
|
228
|
+
return (...i) => {
|
|
229
|
+
const a = this, l = () => {
|
|
230
|
+
r = void 0, n !== !0 && e.apply(a, i);
|
|
231
|
+
}, s = n === !0 && r !== void 0;
|
|
232
|
+
window.clearTimeout(r), r = window.setTimeout(l, t), s && e.apply(a, i);
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function S(e) {
|
|
236
|
+
return Object.prototype.toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
|
|
237
|
+
}
|
|
238
|
+
function Kt(e) {
|
|
239
|
+
return S(e) === "boolean";
|
|
240
|
+
}
|
|
241
|
+
function Ke(e) {
|
|
242
|
+
return S(e) === "function" || S(e) === "asyncfunction";
|
|
243
|
+
}
|
|
244
|
+
function zt(e) {
|
|
245
|
+
return Ke(e) && /^\s*class\s+/.test(e.toString());
|
|
246
|
+
}
|
|
247
|
+
function Xt(e) {
|
|
248
|
+
return S(e) === "number";
|
|
249
|
+
}
|
|
250
|
+
function M(e) {
|
|
251
|
+
return S(e) === "object";
|
|
252
|
+
}
|
|
253
|
+
function Gt(e) {
|
|
254
|
+
return Promise.resolve(e) === e;
|
|
255
|
+
}
|
|
256
|
+
function Vt(e) {
|
|
257
|
+
return S(e) === "string";
|
|
258
|
+
}
|
|
259
|
+
function Yt(e) {
|
|
260
|
+
return S(e) === "undefined";
|
|
261
|
+
}
|
|
262
|
+
function X(e, ...t) {
|
|
263
|
+
if (!t.length)
|
|
264
|
+
return e;
|
|
265
|
+
const n = t.shift();
|
|
266
|
+
if (M(e) && M(n))
|
|
267
|
+
for (const r in n)
|
|
268
|
+
M(n[r]) ? (e[r] === void 0 && Object.assign(e, { [r]: {} }), X(e[r], n[r])) : Object.assign(e, { [r]: n[r] });
|
|
269
|
+
return X(e, ...t);
|
|
270
|
+
}
|
|
271
|
+
function Jt(e, t, n) {
|
|
272
|
+
const r = `«${t}» is deprecated and will be removed in the next major release. Please use the «${n}» instead.`;
|
|
273
|
+
e && console.warn(r);
|
|
274
|
+
}
|
|
275
|
+
function Qt(e) {
|
|
276
|
+
try {
|
|
277
|
+
return new URL(e).href;
|
|
278
|
+
} catch {
|
|
279
|
+
}
|
|
280
|
+
return e.substring(0, 2) === "//" ? window.location.protocol + e : window.location.origin + e;
|
|
281
|
+
}
|
|
282
|
+
function Zt(e) {
|
|
283
|
+
return e > 47 && e < 58 || e === 32 || e === 13 || e === 229 || e > 64 && e < 91 || e > 95 && e < 112 || e > 185 && e < 193 || e > 218 && e < 223;
|
|
284
|
+
}
|
|
285
|
+
const xt = {
|
|
286
|
+
BACKSPACE: 8,
|
|
287
|
+
TAB: 9,
|
|
288
|
+
ENTER: 13,
|
|
289
|
+
SHIFT: 16,
|
|
290
|
+
CTRL: 17,
|
|
291
|
+
ALT: 18,
|
|
292
|
+
ESC: 27,
|
|
293
|
+
SPACE: 32,
|
|
294
|
+
LEFT: 37,
|
|
295
|
+
UP: 38,
|
|
296
|
+
DOWN: 40,
|
|
297
|
+
RIGHT: 39,
|
|
298
|
+
DELETE: 46,
|
|
299
|
+
META: 91,
|
|
300
|
+
SLASH: 191
|
|
301
|
+
}, en = {
|
|
302
|
+
LEFT: 0,
|
|
303
|
+
WHEEL: 1,
|
|
304
|
+
RIGHT: 2,
|
|
305
|
+
BACKWARD: 3,
|
|
306
|
+
FORWARD: 4
|
|
307
|
+
};
|
|
308
|
+
class tn {
|
|
309
|
+
constructor() {
|
|
310
|
+
this.completed = Promise.resolve();
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Add new promise to queue
|
|
314
|
+
* @param operation - promise should be added to queue
|
|
315
|
+
*/
|
|
316
|
+
add(t) {
|
|
317
|
+
return new Promise((n, r) => {
|
|
318
|
+
this.completed = this.completed.then(t).then(n).catch(r);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function nn(e, t, n = void 0) {
|
|
323
|
+
let r, i, a, l = null, s = 0;
|
|
324
|
+
n || (n = {});
|
|
325
|
+
const o = function() {
|
|
326
|
+
s = n.leading === !1 ? 0 : Date.now(), l = null, a = e.apply(r, i), l === null && (r = i = null);
|
|
327
|
+
};
|
|
328
|
+
return function() {
|
|
329
|
+
const d = Date.now();
|
|
330
|
+
!s && n.leading === !1 && (s = d);
|
|
331
|
+
const u = t - (d - s);
|
|
332
|
+
return r = this, i = arguments, u <= 0 || u > t ? (l && (clearTimeout(l), l = null), s = d, a = e.apply(r, i), l === null && (r = i = null)) : !l && n.trailing !== !1 && (l = setTimeout(o, u)), a;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
const rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
336
|
+
__proto__: null,
|
|
337
|
+
PromiseQueue: tn,
|
|
338
|
+
beautifyShortcut: Ft,
|
|
339
|
+
cacheable: Wt,
|
|
340
|
+
capitalize: Rt,
|
|
341
|
+
copyTextToClipboard: qt,
|
|
342
|
+
debounce: Ut,
|
|
343
|
+
deepMerge: X,
|
|
344
|
+
deprecationAssert: Jt,
|
|
345
|
+
getUserOS: Ue,
|
|
346
|
+
getValidUrl: Qt,
|
|
347
|
+
isBoolean: Kt,
|
|
348
|
+
isClass: zt,
|
|
349
|
+
isEmpty: Dt,
|
|
350
|
+
isFunction: Ke,
|
|
351
|
+
isIosDevice: Ht,
|
|
352
|
+
isNumber: Xt,
|
|
353
|
+
isObject: M,
|
|
354
|
+
isPrintableKey: Zt,
|
|
355
|
+
isPromise: Gt,
|
|
356
|
+
isString: Vt,
|
|
357
|
+
isUndefined: Yt,
|
|
358
|
+
keyCodes: xt,
|
|
359
|
+
mouseButtons: en,
|
|
360
|
+
notEmpty: ae,
|
|
361
|
+
throttle: nn,
|
|
362
|
+
typeOf: S
|
|
363
|
+
}, Symbol.toStringTag, { value: "Module" })), le = /* @__PURE__ */ wt(rn);
|
|
364
|
+
Object.defineProperty(ie, "__esModule", { value: !0 });
|
|
365
|
+
ie.containsOnlyInlineElements = sn;
|
|
366
|
+
var an = le, ln = Z;
|
|
367
|
+
function sn(e) {
|
|
368
|
+
var t;
|
|
369
|
+
(0, an.isString)(e) ? (t = document.createElement("div"), t.innerHTML = e) : t = e;
|
|
370
|
+
var n = function(r) {
|
|
371
|
+
return !(0, ln.blockElements)().includes(r.tagName.toLowerCase()) && Array.from(r.children).every(n);
|
|
372
|
+
};
|
|
373
|
+
return Array.from(t.children).every(n);
|
|
374
|
+
}
|
|
375
|
+
(function(e) {
|
|
376
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.containsOnlyInlineElements = void 0;
|
|
377
|
+
var t = ie;
|
|
378
|
+
Object.defineProperty(e, "containsOnlyInlineElements", { enumerable: !0, get: function() {
|
|
379
|
+
return t.containsOnlyInlineElements;
|
|
380
|
+
} });
|
|
381
|
+
})($);
|
|
382
|
+
var ze = {}, se = {}, B = {}, oe = {};
|
|
383
|
+
Object.defineProperty(oe, "__esModule", { value: !0 });
|
|
384
|
+
oe.make = on;
|
|
385
|
+
function on(e, t, n) {
|
|
386
|
+
var r;
|
|
387
|
+
t === void 0 && (t = null), n === void 0 && (n = {});
|
|
388
|
+
var i = document.createElement(e);
|
|
389
|
+
if (Array.isArray(t)) {
|
|
390
|
+
var a = t.filter(function(s) {
|
|
391
|
+
return s !== void 0;
|
|
392
|
+
});
|
|
393
|
+
(r = i.classList).add.apply(r, a);
|
|
394
|
+
} else
|
|
395
|
+
t !== null && i.classList.add(t);
|
|
396
|
+
for (var l in n)
|
|
397
|
+
Object.prototype.hasOwnProperty.call(n, l) && (i[l] = n[l]);
|
|
398
|
+
return i;
|
|
399
|
+
}
|
|
400
|
+
(function(e) {
|
|
401
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.make = void 0;
|
|
402
|
+
var t = oe;
|
|
403
|
+
Object.defineProperty(e, "make", { enumerable: !0, get: function() {
|
|
404
|
+
return t.make;
|
|
405
|
+
} });
|
|
406
|
+
})(B);
|
|
407
|
+
Object.defineProperty(se, "__esModule", { value: !0 });
|
|
408
|
+
se.fragmentToString = cn;
|
|
409
|
+
var un = B;
|
|
410
|
+
function cn(e) {
|
|
411
|
+
var t = (0, un.make)("div");
|
|
412
|
+
return t.appendChild(e), t.innerHTML;
|
|
413
|
+
}
|
|
414
|
+
(function(e) {
|
|
415
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.fragmentToString = void 0;
|
|
416
|
+
var t = se;
|
|
417
|
+
Object.defineProperty(e, "fragmentToString", { enumerable: !0, get: function() {
|
|
418
|
+
return t.fragmentToString;
|
|
419
|
+
} });
|
|
420
|
+
})(ze);
|
|
421
|
+
var Xe = {}, ue = {};
|
|
422
|
+
Object.defineProperty(ue, "__esModule", { value: !0 });
|
|
423
|
+
ue.getContentLength = fn;
|
|
424
|
+
var dn = k;
|
|
425
|
+
function fn(e) {
|
|
426
|
+
var t, n;
|
|
427
|
+
return (0, dn.isNativeInput)(e) ? e.value.length : e.nodeType === Node.TEXT_NODE ? e.length : (n = (t = e.textContent) === null || t === void 0 ? void 0 : t.length) !== null && n !== void 0 ? n : 0;
|
|
428
|
+
}
|
|
429
|
+
(function(e) {
|
|
430
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.getContentLength = void 0;
|
|
431
|
+
var t = ue;
|
|
432
|
+
Object.defineProperty(e, "getContentLength", { enumerable: !0, get: function() {
|
|
433
|
+
return t.getContentLength;
|
|
434
|
+
} });
|
|
435
|
+
})(Xe);
|
|
436
|
+
var ce = {}, de = {}, We = A && A.__spreadArray || function(e, t, n) {
|
|
437
|
+
if (n || arguments.length === 2)
|
|
438
|
+
for (var r = 0, i = t.length, a; r < i; r++)
|
|
439
|
+
(a || !(r in t)) && (a || (a = Array.prototype.slice.call(t, 0, r)), a[r] = t[r]);
|
|
440
|
+
return e.concat(a || Array.prototype.slice.call(t));
|
|
441
|
+
};
|
|
442
|
+
Object.defineProperty(de, "__esModule", { value: !0 });
|
|
443
|
+
de.getDeepestBlockElements = Ge;
|
|
444
|
+
var pn = $;
|
|
445
|
+
function Ge(e) {
|
|
446
|
+
return (0, pn.containsOnlyInlineElements)(e) ? [e] : Array.from(e.children).reduce(function(t, n) {
|
|
447
|
+
return We(We([], t, !0), Ge(n), !0);
|
|
448
|
+
}, []);
|
|
449
|
+
}
|
|
450
|
+
(function(e) {
|
|
451
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.getDeepestBlockElements = void 0;
|
|
452
|
+
var t = de;
|
|
453
|
+
Object.defineProperty(e, "getDeepestBlockElements", { enumerable: !0, get: function() {
|
|
454
|
+
return t.getDeepestBlockElements;
|
|
455
|
+
} });
|
|
456
|
+
})(ce);
|
|
457
|
+
var Ve = {}, fe = {}, W = {}, pe = {};
|
|
458
|
+
Object.defineProperty(pe, "__esModule", { value: !0 });
|
|
459
|
+
pe.isLineBreakTag = hn;
|
|
460
|
+
function hn(e) {
|
|
461
|
+
return [
|
|
462
|
+
"BR",
|
|
463
|
+
"WBR"
|
|
464
|
+
].includes(e.tagName);
|
|
465
|
+
}
|
|
466
|
+
(function(e) {
|
|
467
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isLineBreakTag = void 0;
|
|
468
|
+
var t = pe;
|
|
469
|
+
Object.defineProperty(e, "isLineBreakTag", { enumerable: !0, get: function() {
|
|
470
|
+
return t.isLineBreakTag;
|
|
471
|
+
} });
|
|
472
|
+
})(W);
|
|
473
|
+
var D = {}, he = {};
|
|
474
|
+
Object.defineProperty(he, "__esModule", { value: !0 });
|
|
475
|
+
he.isSingleTag = mn;
|
|
476
|
+
function mn(e) {
|
|
477
|
+
return [
|
|
478
|
+
"AREA",
|
|
479
|
+
"BASE",
|
|
480
|
+
"BR",
|
|
481
|
+
"COL",
|
|
482
|
+
"COMMAND",
|
|
483
|
+
"EMBED",
|
|
484
|
+
"HR",
|
|
485
|
+
"IMG",
|
|
486
|
+
"INPUT",
|
|
487
|
+
"KEYGEN",
|
|
488
|
+
"LINK",
|
|
489
|
+
"META",
|
|
490
|
+
"PARAM",
|
|
491
|
+
"SOURCE",
|
|
492
|
+
"TRACK",
|
|
493
|
+
"WBR"
|
|
494
|
+
].includes(e.tagName);
|
|
495
|
+
}
|
|
496
|
+
(function(e) {
|
|
497
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isSingleTag = void 0;
|
|
498
|
+
var t = he;
|
|
499
|
+
Object.defineProperty(e, "isSingleTag", { enumerable: !0, get: function() {
|
|
500
|
+
return t.isSingleTag;
|
|
501
|
+
} });
|
|
502
|
+
})(D);
|
|
503
|
+
Object.defineProperty(fe, "__esModule", { value: !0 });
|
|
504
|
+
fe.getDeepestNode = Ye;
|
|
505
|
+
var gn = k, vn = W, bn = D;
|
|
506
|
+
function Ye(e, t) {
|
|
507
|
+
t === void 0 && (t = !1);
|
|
508
|
+
var n = t ? "lastChild" : "firstChild", r = t ? "previousSibling" : "nextSibling";
|
|
509
|
+
if (e.nodeType === Node.ELEMENT_NODE && e[n]) {
|
|
510
|
+
var i = e[n];
|
|
511
|
+
if ((0, bn.isSingleTag)(i) && !(0, gn.isNativeInput)(i) && !(0, vn.isLineBreakTag)(i))
|
|
512
|
+
if (i[r])
|
|
513
|
+
i = i[r];
|
|
514
|
+
else if (i.parentNode !== null && i.parentNode[r])
|
|
515
|
+
i = i.parentNode[r];
|
|
516
|
+
else
|
|
517
|
+
return i.parentNode;
|
|
518
|
+
return Ye(i, t);
|
|
519
|
+
}
|
|
520
|
+
return e;
|
|
521
|
+
}
|
|
522
|
+
(function(e) {
|
|
523
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.getDeepestNode = void 0;
|
|
524
|
+
var t = fe;
|
|
525
|
+
Object.defineProperty(e, "getDeepestNode", { enumerable: !0, get: function() {
|
|
526
|
+
return t.getDeepestNode;
|
|
527
|
+
} });
|
|
528
|
+
})(Ve);
|
|
529
|
+
var Je = {}, me = {}, T = A && A.__spreadArray || function(e, t, n) {
|
|
530
|
+
if (n || arguments.length === 2)
|
|
531
|
+
for (var r = 0, i = t.length, a; r < i; r++)
|
|
532
|
+
(a || !(r in t)) && (a || (a = Array.prototype.slice.call(t, 0, r)), a[r] = t[r]);
|
|
533
|
+
return e.concat(a || Array.prototype.slice.call(t));
|
|
534
|
+
};
|
|
535
|
+
Object.defineProperty(me, "__esModule", { value: !0 });
|
|
536
|
+
me.findAllInputs = kn;
|
|
537
|
+
var yn = $, Cn = ce, Sn = V, On = k;
|
|
538
|
+
function kn(e) {
|
|
539
|
+
return Array.from(e.querySelectorAll((0, Sn.allInputsSelector)())).reduce(function(t, n) {
|
|
540
|
+
return (0, On.isNativeInput)(n) || (0, yn.containsOnlyInlineElements)(n) ? T(T([], t, !0), [n], !1) : T(T([], t, !0), (0, Cn.getDeepestBlockElements)(n), !0);
|
|
541
|
+
}, []);
|
|
542
|
+
}
|
|
543
|
+
(function(e) {
|
|
544
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.findAllInputs = void 0;
|
|
545
|
+
var t = me;
|
|
546
|
+
Object.defineProperty(e, "findAllInputs", { enumerable: !0, get: function() {
|
|
547
|
+
return t.findAllInputs;
|
|
548
|
+
} });
|
|
549
|
+
})(Je);
|
|
550
|
+
var Qe = {}, ge = {};
|
|
551
|
+
Object.defineProperty(ge, "__esModule", { value: !0 });
|
|
552
|
+
ge.isCollapsedWhitespaces = _n;
|
|
553
|
+
function _n(e) {
|
|
554
|
+
return !/[^\t\n\r ]/.test(e);
|
|
555
|
+
}
|
|
556
|
+
(function(e) {
|
|
557
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isCollapsedWhitespaces = void 0;
|
|
558
|
+
var t = ge;
|
|
559
|
+
Object.defineProperty(e, "isCollapsedWhitespaces", { enumerable: !0, get: function() {
|
|
560
|
+
return t.isCollapsedWhitespaces;
|
|
561
|
+
} });
|
|
562
|
+
})(Qe);
|
|
563
|
+
var ve = {}, be = {};
|
|
564
|
+
Object.defineProperty(be, "__esModule", { value: !0 });
|
|
565
|
+
be.isElement = In;
|
|
566
|
+
var En = le;
|
|
567
|
+
function In(e) {
|
|
568
|
+
return (0, En.isNumber)(e) ? !1 : !!e && !!e.nodeType && e.nodeType === Node.ELEMENT_NODE;
|
|
569
|
+
}
|
|
570
|
+
(function(e) {
|
|
571
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isElement = void 0;
|
|
572
|
+
var t = be;
|
|
573
|
+
Object.defineProperty(e, "isElement", { enumerable: !0, get: function() {
|
|
574
|
+
return t.isElement;
|
|
575
|
+
} });
|
|
576
|
+
})(ve);
|
|
577
|
+
var Ze = {}, ye = {}, Ce = {}, Se = {};
|
|
578
|
+
Object.defineProperty(Se, "__esModule", { value: !0 });
|
|
579
|
+
Se.isLeaf = wn;
|
|
580
|
+
function wn(e) {
|
|
581
|
+
return e === null ? !1 : e.childNodes.length === 0;
|
|
582
|
+
}
|
|
583
|
+
(function(e) {
|
|
584
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isLeaf = void 0;
|
|
585
|
+
var t = Se;
|
|
586
|
+
Object.defineProperty(e, "isLeaf", { enumerable: !0, get: function() {
|
|
587
|
+
return t.isLeaf;
|
|
588
|
+
} });
|
|
589
|
+
})(Ce);
|
|
590
|
+
var Oe = {}, ke = {};
|
|
591
|
+
Object.defineProperty(ke, "__esModule", { value: !0 });
|
|
592
|
+
ke.isNodeEmpty = Mn;
|
|
593
|
+
var Pn = W, jn = ve, Tn = k, Ln = D;
|
|
594
|
+
function Mn(e, t) {
|
|
595
|
+
var n = "";
|
|
596
|
+
return (0, Ln.isSingleTag)(e) && !(0, Pn.isLineBreakTag)(e) ? !1 : ((0, jn.isElement)(e) && (0, Tn.isNativeInput)(e) ? n = e.value : e.textContent !== null && (n = e.textContent.replace("", "")), t !== void 0 && (n = n.replace(new RegExp(t, "g"), "")), n.trim().length === 0);
|
|
597
|
+
}
|
|
598
|
+
(function(e) {
|
|
599
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isNodeEmpty = void 0;
|
|
600
|
+
var t = ke;
|
|
601
|
+
Object.defineProperty(e, "isNodeEmpty", { enumerable: !0, get: function() {
|
|
602
|
+
return t.isNodeEmpty;
|
|
603
|
+
} });
|
|
604
|
+
})(Oe);
|
|
605
|
+
Object.defineProperty(ye, "__esModule", { value: !0 });
|
|
606
|
+
ye.isEmpty = $n;
|
|
607
|
+
var Nn = Ce, An = Oe;
|
|
608
|
+
function $n(e, t) {
|
|
609
|
+
e.normalize();
|
|
610
|
+
for (var n = [e]; n.length > 0; ) {
|
|
611
|
+
var r = n.shift();
|
|
612
|
+
if (r) {
|
|
613
|
+
if (e = r, (0, Nn.isLeaf)(e) && !(0, An.isNodeEmpty)(e, t))
|
|
614
|
+
return !1;
|
|
615
|
+
n.push.apply(n, Array.from(e.childNodes));
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return !0;
|
|
619
|
+
}
|
|
620
|
+
(function(e) {
|
|
621
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isEmpty = void 0;
|
|
622
|
+
var t = ye;
|
|
623
|
+
Object.defineProperty(e, "isEmpty", { enumerable: !0, get: function() {
|
|
624
|
+
return t.isEmpty;
|
|
625
|
+
} });
|
|
626
|
+
})(Ze);
|
|
627
|
+
var xe = {}, _e = {};
|
|
628
|
+
Object.defineProperty(_e, "__esModule", { value: !0 });
|
|
629
|
+
_e.isFragment = Wn;
|
|
630
|
+
var Bn = le;
|
|
631
|
+
function Wn(e) {
|
|
632
|
+
return (0, Bn.isNumber)(e) ? !1 : !!e && !!e.nodeType && e.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
|
|
633
|
+
}
|
|
634
|
+
(function(e) {
|
|
635
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isFragment = void 0;
|
|
636
|
+
var t = _e;
|
|
637
|
+
Object.defineProperty(e, "isFragment", { enumerable: !0, get: function() {
|
|
638
|
+
return t.isFragment;
|
|
639
|
+
} });
|
|
640
|
+
})(xe);
|
|
641
|
+
var et = {}, Ee = {};
|
|
642
|
+
Object.defineProperty(Ee, "__esModule", { value: !0 });
|
|
643
|
+
Ee.isHTMLString = Hn;
|
|
644
|
+
var Dn = B;
|
|
645
|
+
function Hn(e) {
|
|
646
|
+
var t = (0, Dn.make)("div");
|
|
647
|
+
return t.innerHTML = e, t.childElementCount > 0;
|
|
648
|
+
}
|
|
649
|
+
(function(e) {
|
|
650
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isHTMLString = void 0;
|
|
651
|
+
var t = Ee;
|
|
652
|
+
Object.defineProperty(e, "isHTMLString", { enumerable: !0, get: function() {
|
|
653
|
+
return t.isHTMLString;
|
|
654
|
+
} });
|
|
655
|
+
})(et);
|
|
656
|
+
var tt = {}, Ie = {};
|
|
657
|
+
Object.defineProperty(Ie, "__esModule", { value: !0 });
|
|
658
|
+
Ie.offset = Fn;
|
|
659
|
+
function Fn(e) {
|
|
660
|
+
var t = e.getBoundingClientRect(), n = window.pageXOffset || document.documentElement.scrollLeft, r = window.pageYOffset || document.documentElement.scrollTop, i = t.top + r, a = t.left + n;
|
|
661
|
+
return {
|
|
662
|
+
top: i,
|
|
663
|
+
left: a,
|
|
664
|
+
bottom: i + t.height,
|
|
665
|
+
right: a + t.width
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
(function(e) {
|
|
669
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.offset = void 0;
|
|
670
|
+
var t = Ie;
|
|
671
|
+
Object.defineProperty(e, "offset", { enumerable: !0, get: function() {
|
|
672
|
+
return t.offset;
|
|
673
|
+
} });
|
|
674
|
+
})(tt);
|
|
675
|
+
var nt = {}, we = {};
|
|
676
|
+
Object.defineProperty(we, "__esModule", { value: !0 });
|
|
677
|
+
we.prepend = Rn;
|
|
678
|
+
function Rn(e, t) {
|
|
679
|
+
Array.isArray(t) ? (t = t.reverse(), t.forEach(function(n) {
|
|
680
|
+
return e.prepend(n);
|
|
681
|
+
})) : e.prepend(t);
|
|
682
|
+
}
|
|
683
|
+
(function(e) {
|
|
684
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.prepend = void 0;
|
|
685
|
+
var t = we;
|
|
686
|
+
Object.defineProperty(e, "prepend", { enumerable: !0, get: function() {
|
|
687
|
+
return t.prepend;
|
|
688
|
+
} });
|
|
689
|
+
})(nt);
|
|
690
|
+
(function(e) {
|
|
691
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.prepend = e.offset = e.make = e.isLineBreakTag = e.isSingleTag = e.isNodeEmpty = e.isLeaf = e.isHTMLString = e.isFragment = e.isEmpty = e.isElement = e.isContentEditable = e.isCollapsedWhitespaces = e.findAllInputs = e.isNativeInput = e.allInputsSelector = e.getDeepestNode = e.getDeepestBlockElements = e.getContentLength = e.fragmentToString = e.containsOnlyInlineElements = e.canSetCaret = e.calculateBaseline = e.blockElements = e.append = void 0;
|
|
692
|
+
var t = V;
|
|
693
|
+
Object.defineProperty(e, "allInputsSelector", { enumerable: !0, get: function() {
|
|
694
|
+
return t.allInputsSelector;
|
|
695
|
+
} });
|
|
696
|
+
var n = k;
|
|
697
|
+
Object.defineProperty(e, "isNativeInput", { enumerable: !0, get: function() {
|
|
698
|
+
return n.isNativeInput;
|
|
699
|
+
} });
|
|
700
|
+
var r = Fe;
|
|
701
|
+
Object.defineProperty(e, "append", { enumerable: !0, get: function() {
|
|
702
|
+
return r.append;
|
|
703
|
+
} });
|
|
704
|
+
var i = Z;
|
|
705
|
+
Object.defineProperty(e, "blockElements", { enumerable: !0, get: function() {
|
|
706
|
+
return i.blockElements;
|
|
707
|
+
} });
|
|
708
|
+
var a = Re;
|
|
709
|
+
Object.defineProperty(e, "calculateBaseline", { enumerable: !0, get: function() {
|
|
710
|
+
return a.calculateBaseline;
|
|
711
|
+
} });
|
|
712
|
+
var l = qe;
|
|
713
|
+
Object.defineProperty(e, "canSetCaret", { enumerable: !0, get: function() {
|
|
714
|
+
return l.canSetCaret;
|
|
715
|
+
} });
|
|
716
|
+
var s = $;
|
|
717
|
+
Object.defineProperty(e, "containsOnlyInlineElements", { enumerable: !0, get: function() {
|
|
718
|
+
return s.containsOnlyInlineElements;
|
|
719
|
+
} });
|
|
720
|
+
var o = ze;
|
|
721
|
+
Object.defineProperty(e, "fragmentToString", { enumerable: !0, get: function() {
|
|
722
|
+
return o.fragmentToString;
|
|
723
|
+
} });
|
|
724
|
+
var d = Xe;
|
|
725
|
+
Object.defineProperty(e, "getContentLength", { enumerable: !0, get: function() {
|
|
726
|
+
return d.getContentLength;
|
|
727
|
+
} });
|
|
728
|
+
var u = ce;
|
|
729
|
+
Object.defineProperty(e, "getDeepestBlockElements", { enumerable: !0, get: function() {
|
|
730
|
+
return u.getDeepestBlockElements;
|
|
731
|
+
} });
|
|
732
|
+
var p = Ve;
|
|
733
|
+
Object.defineProperty(e, "getDeepestNode", { enumerable: !0, get: function() {
|
|
734
|
+
return p.getDeepestNode;
|
|
735
|
+
} });
|
|
736
|
+
var g = Je;
|
|
737
|
+
Object.defineProperty(e, "findAllInputs", { enumerable: !0, get: function() {
|
|
738
|
+
return g.findAllInputs;
|
|
739
|
+
} });
|
|
740
|
+
var w = Qe;
|
|
741
|
+
Object.defineProperty(e, "isCollapsedWhitespaces", { enumerable: !0, get: function() {
|
|
742
|
+
return w.isCollapsedWhitespaces;
|
|
743
|
+
} });
|
|
744
|
+
var _ = ne;
|
|
745
|
+
Object.defineProperty(e, "isContentEditable", { enumerable: !0, get: function() {
|
|
746
|
+
return _.isContentEditable;
|
|
747
|
+
} });
|
|
748
|
+
var ut = ve;
|
|
749
|
+
Object.defineProperty(e, "isElement", { enumerable: !0, get: function() {
|
|
750
|
+
return ut.isElement;
|
|
751
|
+
} });
|
|
752
|
+
var ct = Ze;
|
|
753
|
+
Object.defineProperty(e, "isEmpty", { enumerable: !0, get: function() {
|
|
754
|
+
return ct.isEmpty;
|
|
755
|
+
} });
|
|
756
|
+
var dt = xe;
|
|
757
|
+
Object.defineProperty(e, "isFragment", { enumerable: !0, get: function() {
|
|
758
|
+
return dt.isFragment;
|
|
759
|
+
} });
|
|
760
|
+
var ft = et;
|
|
761
|
+
Object.defineProperty(e, "isHTMLString", { enumerable: !0, get: function() {
|
|
762
|
+
return ft.isHTMLString;
|
|
763
|
+
} });
|
|
764
|
+
var pt = Ce;
|
|
765
|
+
Object.defineProperty(e, "isLeaf", { enumerable: !0, get: function() {
|
|
766
|
+
return pt.isLeaf;
|
|
767
|
+
} });
|
|
768
|
+
var ht = Oe;
|
|
769
|
+
Object.defineProperty(e, "isNodeEmpty", { enumerable: !0, get: function() {
|
|
770
|
+
return ht.isNodeEmpty;
|
|
771
|
+
} });
|
|
772
|
+
var mt = W;
|
|
773
|
+
Object.defineProperty(e, "isLineBreakTag", { enumerable: !0, get: function() {
|
|
774
|
+
return mt.isLineBreakTag;
|
|
775
|
+
} });
|
|
776
|
+
var gt = D;
|
|
777
|
+
Object.defineProperty(e, "isSingleTag", { enumerable: !0, get: function() {
|
|
778
|
+
return gt.isSingleTag;
|
|
779
|
+
} });
|
|
780
|
+
var vt = B;
|
|
781
|
+
Object.defineProperty(e, "make", { enumerable: !0, get: function() {
|
|
782
|
+
return vt.make;
|
|
783
|
+
} });
|
|
784
|
+
var bt = tt;
|
|
785
|
+
Object.defineProperty(e, "offset", { enumerable: !0, get: function() {
|
|
786
|
+
return bt.offset;
|
|
787
|
+
} });
|
|
788
|
+
var yt = nt;
|
|
789
|
+
Object.defineProperty(e, "prepend", { enumerable: !0, get: function() {
|
|
790
|
+
return yt.prepend;
|
|
791
|
+
} });
|
|
792
|
+
})(c);
|
|
793
|
+
const m = "cdx-list", h = {
|
|
794
|
+
wrapper: m,
|
|
795
|
+
item: `${m}__item`,
|
|
796
|
+
itemContent: `${m}__item-content`,
|
|
797
|
+
itemChildren: `${m}__item-children`
|
|
798
|
+
};
|
|
799
|
+
class v {
|
|
800
|
+
/**
|
|
801
|
+
* Getter for all CSS classes used in unordered list rendering
|
|
802
|
+
*/
|
|
803
|
+
static get CSS() {
|
|
804
|
+
return {
|
|
805
|
+
...h,
|
|
806
|
+
orderedList: `${m}-ordered`
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Assign passed readonly mode and config to relevant class properties
|
|
811
|
+
* @param readonly - read-only mode flag
|
|
812
|
+
* @param config - user config for Tool
|
|
813
|
+
*/
|
|
814
|
+
constructor(t, n) {
|
|
815
|
+
this.config = n, this.readOnly = t;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Renders ol wrapper for list
|
|
819
|
+
* @param isRoot - boolean variable that represents level of the wrappre (root or childList)
|
|
820
|
+
* @returns - created html ol element
|
|
821
|
+
*/
|
|
822
|
+
renderWrapper(t) {
|
|
823
|
+
let n;
|
|
824
|
+
return t === !0 ? n = c.make("ol", [v.CSS.wrapper, v.CSS.orderedList]) : n = c.make("ol", [v.CSS.orderedList, v.CSS.itemChildren]), n;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Redners list item element
|
|
828
|
+
* @param content - content used in list item rendering
|
|
829
|
+
* @param _meta - meta of the list item unused in rendering of the ordered list
|
|
830
|
+
* @returns - created html list item element
|
|
831
|
+
*/
|
|
832
|
+
renderItem(t, n) {
|
|
833
|
+
const r = c.make("li", v.CSS.item), i = c.make("div", v.CSS.itemContent, {
|
|
834
|
+
innerHTML: t,
|
|
835
|
+
contentEditable: (!this.readOnly).toString()
|
|
836
|
+
});
|
|
837
|
+
return r.appendChild(i), r;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Return the item content
|
|
841
|
+
* @param item - item wrapper (<li>)
|
|
842
|
+
* @returns - item content string
|
|
843
|
+
*/
|
|
844
|
+
getItemContent(t) {
|
|
845
|
+
const n = t.querySelector(`.${v.CSS.itemContent}`);
|
|
846
|
+
return !n || c.isEmpty(n) ? "" : n.innerHTML;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Returns item meta, for ordered list
|
|
850
|
+
* @returns item meta object
|
|
851
|
+
*/
|
|
852
|
+
getItemMeta() {
|
|
853
|
+
return {};
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Returns default item meta used on creation of the new item
|
|
857
|
+
*/
|
|
858
|
+
composeDefaultMeta() {
|
|
859
|
+
return {};
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
class b {
|
|
863
|
+
/**
|
|
864
|
+
* Getter for all CSS classes used in unordered list rendering
|
|
865
|
+
*/
|
|
866
|
+
static get CSS() {
|
|
867
|
+
return {
|
|
868
|
+
...h,
|
|
869
|
+
unorderedList: `${m}-unordered`
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Assign passed readonly mode and config to relevant class properties
|
|
874
|
+
* @param readonly - read-only mode flag
|
|
875
|
+
* @param config - user config for Tool
|
|
876
|
+
*/
|
|
877
|
+
constructor(t, n) {
|
|
878
|
+
this.config = n, this.readOnly = t;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Renders ol wrapper for list
|
|
882
|
+
* @param isRoot - boolean variable that represents level of the wrappre (root or childList)
|
|
883
|
+
* @returns - created html ul element
|
|
884
|
+
*/
|
|
885
|
+
renderWrapper(t) {
|
|
886
|
+
let n;
|
|
887
|
+
return t === !0 ? n = c.make("ul", [b.CSS.wrapper, b.CSS.unorderedList]) : n = c.make("ul", [b.CSS.unorderedList, b.CSS.itemChildren]), n;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Redners list item element
|
|
891
|
+
* @param content - content used in list item rendering
|
|
892
|
+
* @param _meta - meta of the list item unused in rendering of the unordered list
|
|
893
|
+
* @returns - created html list item element
|
|
894
|
+
*/
|
|
895
|
+
renderItem(t, n) {
|
|
896
|
+
const r = c.make("li", b.CSS.item), i = c.make("div", b.CSS.itemContent, {
|
|
897
|
+
innerHTML: t,
|
|
898
|
+
contentEditable: (!this.readOnly).toString()
|
|
899
|
+
});
|
|
900
|
+
return r.appendChild(i), r;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Return the item content
|
|
904
|
+
* @param item - item wrapper (<li>)
|
|
905
|
+
* @returns - item content string
|
|
906
|
+
*/
|
|
907
|
+
getItemContent(t) {
|
|
908
|
+
const n = t.querySelector(`.${b.CSS.itemContent}`);
|
|
909
|
+
return !n || c.isEmpty(n) ? "" : n.innerHTML;
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Returns item meta, for unordered list
|
|
913
|
+
* @returns Item meta object
|
|
914
|
+
*/
|
|
915
|
+
getItemMeta() {
|
|
916
|
+
return {};
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Returns default item meta used on creation of the new item
|
|
920
|
+
*/
|
|
921
|
+
composeDefaultMeta() {
|
|
922
|
+
return {};
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
function O(e) {
|
|
926
|
+
return e.nodeType === Node.ELEMENT_NODE;
|
|
927
|
+
}
|
|
928
|
+
var j = {}, Pe = {}, H = {}, F = {};
|
|
929
|
+
Object.defineProperty(F, "__esModule", { value: !0 });
|
|
930
|
+
F.getContenteditableSlice = Un;
|
|
931
|
+
var qn = c;
|
|
932
|
+
function Un(e, t, n, r, i) {
|
|
933
|
+
var a;
|
|
934
|
+
i === void 0 && (i = !1);
|
|
935
|
+
var l = document.createRange();
|
|
936
|
+
if (r === "left" ? (l.setStart(e, 0), l.setEnd(t, n)) : (l.setStart(t, n), l.setEnd(e, e.childNodes.length)), i === !0) {
|
|
937
|
+
var s = l.extractContents();
|
|
938
|
+
return (0, qn.fragmentToString)(s);
|
|
939
|
+
}
|
|
940
|
+
var o = l.cloneContents(), d = document.createElement("div");
|
|
941
|
+
d.appendChild(o);
|
|
942
|
+
var u = (a = d.textContent) !== null && a !== void 0 ? a : "";
|
|
943
|
+
return u;
|
|
944
|
+
}
|
|
945
|
+
Object.defineProperty(H, "__esModule", { value: !0 });
|
|
946
|
+
H.checkContenteditableSliceForEmptiness = Xn;
|
|
947
|
+
var Kn = c, zn = F;
|
|
948
|
+
function Xn(e, t, n, r) {
|
|
949
|
+
var i = (0, zn.getContenteditableSlice)(e, t, n, r);
|
|
950
|
+
return (0, Kn.isCollapsedWhitespaces)(i);
|
|
951
|
+
}
|
|
952
|
+
(function(e) {
|
|
953
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.checkContenteditableSliceForEmptiness = void 0;
|
|
954
|
+
var t = H;
|
|
955
|
+
Object.defineProperty(e, "checkContenteditableSliceForEmptiness", { enumerable: !0, get: function() {
|
|
956
|
+
return t.checkContenteditableSliceForEmptiness;
|
|
957
|
+
} });
|
|
958
|
+
})(Pe);
|
|
959
|
+
var rt = {};
|
|
960
|
+
(function(e) {
|
|
961
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.getContenteditableSlice = void 0;
|
|
962
|
+
var t = F;
|
|
963
|
+
Object.defineProperty(e, "getContenteditableSlice", { enumerable: !0, get: function() {
|
|
964
|
+
return t.getContenteditableSlice;
|
|
965
|
+
} });
|
|
966
|
+
})(rt);
|
|
967
|
+
var it = {}, je = {};
|
|
968
|
+
Object.defineProperty(je, "__esModule", { value: !0 });
|
|
969
|
+
je.focus = Vn;
|
|
970
|
+
var Gn = c;
|
|
971
|
+
function Vn(e, t) {
|
|
972
|
+
var n, r;
|
|
973
|
+
if (t === void 0 && (t = !0), (0, Gn.isNativeInput)(e)) {
|
|
974
|
+
e.focus();
|
|
975
|
+
var i = t ? 0 : e.value.length;
|
|
976
|
+
e.setSelectionRange(i, i);
|
|
977
|
+
} else {
|
|
978
|
+
var a = document.createRange(), l = window.getSelection();
|
|
979
|
+
if (!l)
|
|
980
|
+
return;
|
|
981
|
+
var s = function(g, w) {
|
|
982
|
+
w === void 0 && (w = !1);
|
|
983
|
+
var _ = document.createTextNode("");
|
|
984
|
+
w ? g.insertBefore(_, g.firstChild) : g.appendChild(_), a.setStart(_, 0), a.setEnd(_, 0);
|
|
985
|
+
}, o = function(g) {
|
|
986
|
+
return g != null;
|
|
987
|
+
}, d = e.childNodes, u = t ? d[0] : d[d.length - 1];
|
|
988
|
+
if (o(u)) {
|
|
989
|
+
for (; o(u) && u.nodeType !== Node.TEXT_NODE; )
|
|
990
|
+
u = t ? u.firstChild : u.lastChild;
|
|
991
|
+
if (o(u) && u.nodeType === Node.TEXT_NODE) {
|
|
992
|
+
var p = (r = (n = u.textContent) === null || n === void 0 ? void 0 : n.length) !== null && r !== void 0 ? r : 0, i = t ? 0 : p;
|
|
993
|
+
a.setStart(u, i), a.setEnd(u, i);
|
|
994
|
+
} else
|
|
995
|
+
s(e, t);
|
|
996
|
+
} else
|
|
997
|
+
s(e);
|
|
998
|
+
l.removeAllRanges(), l.addRange(a);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
(function(e) {
|
|
1002
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.focus = void 0;
|
|
1003
|
+
var t = je;
|
|
1004
|
+
Object.defineProperty(e, "focus", { enumerable: !0, get: function() {
|
|
1005
|
+
return t.focus;
|
|
1006
|
+
} });
|
|
1007
|
+
})(it);
|
|
1008
|
+
var Te = {}, R = {};
|
|
1009
|
+
Object.defineProperty(R, "__esModule", { value: !0 });
|
|
1010
|
+
R.getCaretNodeAndOffset = Yn;
|
|
1011
|
+
function Yn() {
|
|
1012
|
+
var e = window.getSelection();
|
|
1013
|
+
if (e === null)
|
|
1014
|
+
return [null, 0];
|
|
1015
|
+
var t = e.focusNode, n = e.focusOffset;
|
|
1016
|
+
return t === null ? [null, 0] : (t.nodeType !== Node.TEXT_NODE && t.childNodes.length > 0 && (t.childNodes[n] !== void 0 ? (t = t.childNodes[n], n = 0) : (t = t.childNodes[n - 1], t.textContent !== null && (n = t.textContent.length))), [t, n]);
|
|
1017
|
+
}
|
|
1018
|
+
(function(e) {
|
|
1019
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.getCaretNodeAndOffset = void 0;
|
|
1020
|
+
var t = R;
|
|
1021
|
+
Object.defineProperty(e, "getCaretNodeAndOffset", { enumerable: !0, get: function() {
|
|
1022
|
+
return t.getCaretNodeAndOffset;
|
|
1023
|
+
} });
|
|
1024
|
+
})(Te);
|
|
1025
|
+
var at = {}, q = {};
|
|
1026
|
+
Object.defineProperty(q, "__esModule", { value: !0 });
|
|
1027
|
+
q.getRange = Jn;
|
|
1028
|
+
function Jn() {
|
|
1029
|
+
var e = window.getSelection();
|
|
1030
|
+
return e && e.rangeCount ? e.getRangeAt(0) : null;
|
|
1031
|
+
}
|
|
1032
|
+
(function(e) {
|
|
1033
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.getRange = void 0;
|
|
1034
|
+
var t = q;
|
|
1035
|
+
Object.defineProperty(e, "getRange", { enumerable: !0, get: function() {
|
|
1036
|
+
return t.getRange;
|
|
1037
|
+
} });
|
|
1038
|
+
})(at);
|
|
1039
|
+
var lt = {}, Le = {};
|
|
1040
|
+
Object.defineProperty(Le, "__esModule", { value: !0 });
|
|
1041
|
+
Le.isCaretAtEndOfInput = xn;
|
|
1042
|
+
var De = c, Qn = Te, Zn = Pe;
|
|
1043
|
+
function xn(e) {
|
|
1044
|
+
var t = (0, De.getDeepestNode)(e, !0);
|
|
1045
|
+
if (t === null)
|
|
1046
|
+
return !0;
|
|
1047
|
+
if ((0, De.isNativeInput)(t))
|
|
1048
|
+
return t.selectionEnd === t.value.length;
|
|
1049
|
+
var n = (0, Qn.getCaretNodeAndOffset)(), r = n[0], i = n[1];
|
|
1050
|
+
return r === null ? !1 : (0, Zn.checkContenteditableSliceForEmptiness)(e, r, i, "right");
|
|
1051
|
+
}
|
|
1052
|
+
(function(e) {
|
|
1053
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isCaretAtEndOfInput = void 0;
|
|
1054
|
+
var t = Le;
|
|
1055
|
+
Object.defineProperty(e, "isCaretAtEndOfInput", { enumerable: !0, get: function() {
|
|
1056
|
+
return t.isCaretAtEndOfInput;
|
|
1057
|
+
} });
|
|
1058
|
+
})(lt);
|
|
1059
|
+
var st = {}, Me = {};
|
|
1060
|
+
Object.defineProperty(Me, "__esModule", { value: !0 });
|
|
1061
|
+
Me.isCaretAtStartOfInput = nr;
|
|
1062
|
+
var L = c, er = R, tr = H;
|
|
1063
|
+
function nr(e) {
|
|
1064
|
+
var t = (0, L.getDeepestNode)(e);
|
|
1065
|
+
if (t === null || (0, L.isEmpty)(e))
|
|
1066
|
+
return !0;
|
|
1067
|
+
if ((0, L.isNativeInput)(t))
|
|
1068
|
+
return t.selectionEnd === 0;
|
|
1069
|
+
if ((0, L.isEmpty)(e))
|
|
1070
|
+
return !0;
|
|
1071
|
+
var n = (0, er.getCaretNodeAndOffset)(), r = n[0], i = n[1];
|
|
1072
|
+
return r === null ? !1 : (0, tr.checkContenteditableSliceForEmptiness)(e, r, i, "left");
|
|
1073
|
+
}
|
|
1074
|
+
(function(e) {
|
|
1075
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isCaretAtStartOfInput = void 0;
|
|
1076
|
+
var t = Me;
|
|
1077
|
+
Object.defineProperty(e, "isCaretAtStartOfInput", { enumerable: !0, get: function() {
|
|
1078
|
+
return t.isCaretAtStartOfInput;
|
|
1079
|
+
} });
|
|
1080
|
+
})(st);
|
|
1081
|
+
var ot = {}, Ne = {};
|
|
1082
|
+
Object.defineProperty(Ne, "__esModule", { value: !0 });
|
|
1083
|
+
Ne.save = ar;
|
|
1084
|
+
var rr = c, ir = q;
|
|
1085
|
+
function ar() {
|
|
1086
|
+
var e = (0, ir.getRange)(), t = (0, rr.make)("span");
|
|
1087
|
+
if (t.id = "cursor", t.hidden = !0, !!e)
|
|
1088
|
+
return e.insertNode(t), function() {
|
|
1089
|
+
var r = window.getSelection();
|
|
1090
|
+
r && (e.setStartAfter(t), e.setEndAfter(t), r.removeAllRanges(), r.addRange(e), setTimeout(function() {
|
|
1091
|
+
t.remove();
|
|
1092
|
+
}, 150));
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
(function(e) {
|
|
1096
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.save = void 0;
|
|
1097
|
+
var t = Ne;
|
|
1098
|
+
Object.defineProperty(e, "save", { enumerable: !0, get: function() {
|
|
1099
|
+
return t.save;
|
|
1100
|
+
} });
|
|
1101
|
+
})(ot);
|
|
1102
|
+
(function(e) {
|
|
1103
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.save = e.isCaretAtStartOfInput = e.isCaretAtEndOfInput = e.getRange = e.getCaretNodeAndOffset = e.focus = e.getContenteditableSlice = e.checkContenteditableSliceForEmptiness = void 0;
|
|
1104
|
+
var t = Pe;
|
|
1105
|
+
Object.defineProperty(e, "checkContenteditableSliceForEmptiness", { enumerable: !0, get: function() {
|
|
1106
|
+
return t.checkContenteditableSliceForEmptiness;
|
|
1107
|
+
} });
|
|
1108
|
+
var n = rt;
|
|
1109
|
+
Object.defineProperty(e, "getContenteditableSlice", { enumerable: !0, get: function() {
|
|
1110
|
+
return n.getContenteditableSlice;
|
|
1111
|
+
} });
|
|
1112
|
+
var r = it;
|
|
1113
|
+
Object.defineProperty(e, "focus", { enumerable: !0, get: function() {
|
|
1114
|
+
return r.focus;
|
|
1115
|
+
} });
|
|
1116
|
+
var i = Te;
|
|
1117
|
+
Object.defineProperty(e, "getCaretNodeAndOffset", { enumerable: !0, get: function() {
|
|
1118
|
+
return i.getCaretNodeAndOffset;
|
|
1119
|
+
} });
|
|
1120
|
+
var a = at;
|
|
1121
|
+
Object.defineProperty(e, "getRange", { enumerable: !0, get: function() {
|
|
1122
|
+
return a.getRange;
|
|
1123
|
+
} });
|
|
1124
|
+
var l = lt;
|
|
1125
|
+
Object.defineProperty(e, "isCaretAtEndOfInput", { enumerable: !0, get: function() {
|
|
1126
|
+
return l.isCaretAtEndOfInput;
|
|
1127
|
+
} });
|
|
1128
|
+
var s = st;
|
|
1129
|
+
Object.defineProperty(e, "isCaretAtStartOfInput", { enumerable: !0, get: function() {
|
|
1130
|
+
return s.isCaretAtStartOfInput;
|
|
1131
|
+
} });
|
|
1132
|
+
var o = ot;
|
|
1133
|
+
Object.defineProperty(e, "save", { enumerable: !0, get: function() {
|
|
1134
|
+
return o.save;
|
|
1135
|
+
} });
|
|
1136
|
+
})(j);
|
|
1137
|
+
class f {
|
|
1138
|
+
/**
|
|
1139
|
+
* Getter for all CSS classes used in unordered list rendering
|
|
1140
|
+
*/
|
|
1141
|
+
static get CSS() {
|
|
1142
|
+
return {
|
|
1143
|
+
...h,
|
|
1144
|
+
checklist: `${m}-checklist`,
|
|
1145
|
+
itemChecked: `${m}__checkbox--checked`,
|
|
1146
|
+
noHover: `${m}__checkbox--no-hover`,
|
|
1147
|
+
checkbox: `${m}__checkbox-check`,
|
|
1148
|
+
checkboxContainer: `${m}__checkbox`,
|
|
1149
|
+
checkboxCheckDisabled: `${m}__checkbox-check--disabled`
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Assign passed readonly mode and config to relevant class properties
|
|
1154
|
+
* @param readonly - read-only mode flag
|
|
1155
|
+
* @param config - user config for Tool
|
|
1156
|
+
*/
|
|
1157
|
+
constructor(t, n) {
|
|
1158
|
+
this.config = n, this.readOnly = t;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Renders ul wrapper for list
|
|
1162
|
+
* @param isRoot - boolean variable that represents level of the wrappre (root or childList)
|
|
1163
|
+
* @returns - created html ul element
|
|
1164
|
+
*/
|
|
1165
|
+
renderWrapper(t) {
|
|
1166
|
+
let n;
|
|
1167
|
+
return t === !0 ? (n = c.make("ul", [f.CSS.wrapper, f.CSS.checklist]), n.addEventListener("click", (r) => {
|
|
1168
|
+
const i = r.target;
|
|
1169
|
+
if (i) {
|
|
1170
|
+
const a = i.closest(`.${f.CSS.checkboxContainer}`);
|
|
1171
|
+
a && a.contains(i) && this.toggleCheckbox(a);
|
|
1172
|
+
}
|
|
1173
|
+
})) : n = c.make("ul", [f.CSS.checklist, f.CSS.itemChildren]), n;
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Redners list item element
|
|
1177
|
+
* @param content - content used in list item rendering
|
|
1178
|
+
* @param meta - meta of the list item used in rendering of the checklist
|
|
1179
|
+
* @returns - created html list item element
|
|
1180
|
+
*/
|
|
1181
|
+
renderItem(t, n) {
|
|
1182
|
+
const r = c.make("li", [f.CSS.item, f.CSS.item]), i = c.make("div", f.CSS.itemContent, {
|
|
1183
|
+
innerHTML: t,
|
|
1184
|
+
contentEditable: (!this.readOnly).toString()
|
|
1185
|
+
}), a = c.make("span", f.CSS.checkbox), l = c.make("div", f.CSS.checkboxContainer);
|
|
1186
|
+
return n.checked === !0 && l.classList.add(f.CSS.itemChecked), this.readOnly && l.classList.add(f.CSS.checkboxCheckDisabled), a.innerHTML = Ct, l.appendChild(a), r.appendChild(l), r.appendChild(i), r;
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Return the item content
|
|
1190
|
+
* @param item - item wrapper (<li>)
|
|
1191
|
+
* @returns - item content string
|
|
1192
|
+
*/
|
|
1193
|
+
getItemContent(t) {
|
|
1194
|
+
const n = t.querySelector(`.${f.CSS.itemContent}`);
|
|
1195
|
+
return !n || c.isEmpty(n) ? "" : n.innerHTML;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Return meta object of certain element
|
|
1199
|
+
* @param item - will be returned meta information of this item
|
|
1200
|
+
* @returns Item meta object
|
|
1201
|
+
*/
|
|
1202
|
+
getItemMeta(t) {
|
|
1203
|
+
const n = t.querySelector(`.${f.CSS.checkboxContainer}`);
|
|
1204
|
+
return {
|
|
1205
|
+
checked: n ? n.classList.contains(f.CSS.itemChecked) : !1
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Returns default item meta used on creation of the new item
|
|
1210
|
+
*/
|
|
1211
|
+
composeDefaultMeta() {
|
|
1212
|
+
return { checked: !1 };
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Toggle checklist item state
|
|
1216
|
+
* @param checkbox - checkbox element to be toggled
|
|
1217
|
+
*/
|
|
1218
|
+
toggleCheckbox(t) {
|
|
1219
|
+
t.classList.toggle(f.CSS.itemChecked), t.classList.add(f.CSS.noHover), t.addEventListener("mouseleave", () => this.removeSpecialHoverBehavior(t), { once: !0 });
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Removes class responsible for special hover behavior on an item
|
|
1223
|
+
* @param el - item wrapper
|
|
1224
|
+
*/
|
|
1225
|
+
removeSpecialHoverBehavior(t) {
|
|
1226
|
+
t.classList.remove(f.CSS.noHover);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
function U(e, t = "after") {
|
|
1230
|
+
const n = [];
|
|
1231
|
+
let r;
|
|
1232
|
+
function i(a) {
|
|
1233
|
+
switch (t) {
|
|
1234
|
+
case "after":
|
|
1235
|
+
return a.nextElementSibling;
|
|
1236
|
+
case "before":
|
|
1237
|
+
return a.previousElementSibling;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
for (r = i(e); r !== null; )
|
|
1241
|
+
n.push(r), r = i(r);
|
|
1242
|
+
return n.length !== 0 ? n : null;
|
|
1243
|
+
}
|
|
1244
|
+
function y(e, t = !0) {
|
|
1245
|
+
let n = e;
|
|
1246
|
+
return e.classList.contains(h.item) && (n = e.querySelector(`.${h.itemChildren}`)), n === null ? [] : t ? Array.from(n.querySelectorAll(`:scope > .${h.item}`)) : Array.from(n.querySelectorAll(`.${h.item}`));
|
|
1247
|
+
}
|
|
1248
|
+
function lr(e) {
|
|
1249
|
+
return e.nextElementSibling === null;
|
|
1250
|
+
}
|
|
1251
|
+
function sr(e) {
|
|
1252
|
+
return e.querySelector(`.${h.itemChildren}`) !== null;
|
|
1253
|
+
}
|
|
1254
|
+
function C(e) {
|
|
1255
|
+
return e.querySelector(`.${h.itemChildren}`);
|
|
1256
|
+
}
|
|
1257
|
+
function K(e) {
|
|
1258
|
+
let t = e;
|
|
1259
|
+
e.classList.contains(h.item) && (t = C(e)), t !== null && y(t).length === 0 && t.remove();
|
|
1260
|
+
}
|
|
1261
|
+
function N(e) {
|
|
1262
|
+
return e.querySelector(`.${h.itemContent}`);
|
|
1263
|
+
}
|
|
1264
|
+
function E(e, t = !0) {
|
|
1265
|
+
const n = N(e);
|
|
1266
|
+
n && j.focus(n, t);
|
|
1267
|
+
}
|
|
1268
|
+
class z {
|
|
1269
|
+
/**
|
|
1270
|
+
* Getter method to get current item
|
|
1271
|
+
* @returns current list item or null if caret position is not undefined
|
|
1272
|
+
*/
|
|
1273
|
+
get currentItem() {
|
|
1274
|
+
const t = window.getSelection();
|
|
1275
|
+
if (!t)
|
|
1276
|
+
return null;
|
|
1277
|
+
let n = t.anchorNode;
|
|
1278
|
+
return !n || (O(n) || (n = n.parentNode), !n) || !O(n) ? null : n.closest(`.${h.item}`);
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Method that returns nesting level of the current item, null if there is no selection
|
|
1282
|
+
*/
|
|
1283
|
+
get currentItemLevel() {
|
|
1284
|
+
const t = this.currentItem;
|
|
1285
|
+
if (t === null)
|
|
1286
|
+
return null;
|
|
1287
|
+
let n = t.parentNode, r = 0;
|
|
1288
|
+
for (; n !== null && n !== this.listWrapper; )
|
|
1289
|
+
O(n) && n.classList.contains(h.item) && (r += 1), n = n.parentNode;
|
|
1290
|
+
return r + 1;
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Assign all passed params and renderer to relevant class properties
|
|
1294
|
+
* @param params - tool constructor options
|
|
1295
|
+
* @param params.data - previously saved data
|
|
1296
|
+
* @param params.config - user config for Tool
|
|
1297
|
+
* @param params.api - Editor.js API
|
|
1298
|
+
* @param params.readOnly - read-only mode flag
|
|
1299
|
+
* @param renderer - renderer instance initialized in tool class
|
|
1300
|
+
*/
|
|
1301
|
+
constructor({ data: t, config: n, api: r, readOnly: i, block: a }, l) {
|
|
1302
|
+
this.config = n, this.data = t, this.readOnly = i, this.api = r, this.block = a, this.renderer = l;
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Function that is responsible for rendering list with contents
|
|
1306
|
+
* @returns Filled with content wrapper element of the list
|
|
1307
|
+
*/
|
|
1308
|
+
render() {
|
|
1309
|
+
return this.listWrapper = this.renderer.renderWrapper(!0), this.data.items.length ? this.appendItems(this.data.items, this.listWrapper) : this.appendItems(
|
|
1310
|
+
[
|
|
1311
|
+
{
|
|
1312
|
+
content: "",
|
|
1313
|
+
meta: {},
|
|
1314
|
+
items: []
|
|
1315
|
+
}
|
|
1316
|
+
],
|
|
1317
|
+
this.listWrapper
|
|
1318
|
+
), this.readOnly || this.listWrapper.addEventListener(
|
|
1319
|
+
"keydown",
|
|
1320
|
+
(t) => {
|
|
1321
|
+
switch (t.key) {
|
|
1322
|
+
case "Enter":
|
|
1323
|
+
t.shiftKey || this.enterPressed(t);
|
|
1324
|
+
break;
|
|
1325
|
+
case "Backspace":
|
|
1326
|
+
this.backspace(t);
|
|
1327
|
+
break;
|
|
1328
|
+
case "Tab":
|
|
1329
|
+
t.shiftKey ? this.shiftTab(t) : this.addTab(t);
|
|
1330
|
+
break;
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1333
|
+
!1
|
|
1334
|
+
), "start" in this.data.meta && this.data.meta.start !== void 0 && this.changeStartWith(this.data.meta.start), "counterType" in this.data.meta && this.data.meta.counterType !== void 0 && this.changeCounters(this.data.meta.counterType), this.listWrapper;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Function that is responsible for list content saving
|
|
1338
|
+
* @param wrapper - optional argument wrapper
|
|
1339
|
+
* @returns whole list saved data if wrapper not passes, otherwise will return data of the passed wrapper
|
|
1340
|
+
*/
|
|
1341
|
+
save(t) {
|
|
1342
|
+
const n = t ?? this.listWrapper, r = (l) => y(l).map((o) => {
|
|
1343
|
+
const d = C(o), u = this.renderer.getItemContent(o), p = this.renderer.getItemMeta(o), g = d ? r(d) : [];
|
|
1344
|
+
return {
|
|
1345
|
+
content: u,
|
|
1346
|
+
meta: p,
|
|
1347
|
+
items: g
|
|
1348
|
+
};
|
|
1349
|
+
}), i = n ? r(n) : [];
|
|
1350
|
+
let a = {
|
|
1351
|
+
style: this.data.style,
|
|
1352
|
+
meta: {},
|
|
1353
|
+
items: i
|
|
1354
|
+
};
|
|
1355
|
+
return this.data.style === "ordered" && (a.meta = {
|
|
1356
|
+
start: this.data.meta.start,
|
|
1357
|
+
counterType: this.data.meta.counterType
|
|
1358
|
+
}), a;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* On paste sanitzation config. Allow only tags that are allowed in the Tool.
|
|
1362
|
+
* @returns - config that determines tags supposted by paste handler
|
|
1363
|
+
* @todo - refactor and move to list instance
|
|
1364
|
+
*/
|
|
1365
|
+
static get pasteConfig() {
|
|
1366
|
+
return {
|
|
1367
|
+
tags: ["OL", "UL", "LI"]
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Method that specified hot to merge two List blocks.
|
|
1372
|
+
* Called by Editor.js by backspace at the beginning of the Block
|
|
1373
|
+
*
|
|
1374
|
+
* Content of the first item of the next List would be merged with deepest item in current list
|
|
1375
|
+
* Other items of the next List would be appended to the current list without any changes in nesting levels
|
|
1376
|
+
* @param data - data of the second list to be merged with current
|
|
1377
|
+
*/
|
|
1378
|
+
merge(t) {
|
|
1379
|
+
const n = this.block.holder.querySelectorAll(`.${h.item}`), r = n[n.length - 1], i = N(r);
|
|
1380
|
+
if (r === null || i === null || (i.insertAdjacentHTML("beforeend", t.items[0].content), this.listWrapper === void 0))
|
|
1381
|
+
return;
|
|
1382
|
+
const a = y(this.listWrapper);
|
|
1383
|
+
if (a.length === 0)
|
|
1384
|
+
return;
|
|
1385
|
+
const l = a[a.length - 1];
|
|
1386
|
+
let s = C(l);
|
|
1387
|
+
const o = t.items.shift();
|
|
1388
|
+
o !== void 0 && (o.items.length !== 0 && (s === null && (s = this.renderer.renderWrapper(!1)), this.appendItems(o.items, s)), t.items.length > 0 && this.appendItems(t.items, this.listWrapper));
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* On paste callback that is fired from Editor.
|
|
1392
|
+
* @param event - event with pasted data
|
|
1393
|
+
* @todo - refactor and move to list instance
|
|
1394
|
+
*/
|
|
1395
|
+
onPaste(t) {
|
|
1396
|
+
const n = t.detail.data;
|
|
1397
|
+
this.data = this.pasteHandler(n);
|
|
1398
|
+
const r = this.listWrapper;
|
|
1399
|
+
r && r.parentNode && r.parentNode.replaceChild(this.render(), r);
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Handle UL, OL and LI tags paste and returns List data
|
|
1403
|
+
* @param element - html element that contains whole list
|
|
1404
|
+
* @todo - refactor and move to list instance
|
|
1405
|
+
*/
|
|
1406
|
+
pasteHandler(t) {
|
|
1407
|
+
const { tagName: n } = t;
|
|
1408
|
+
let r = "unordered", i;
|
|
1409
|
+
switch (n) {
|
|
1410
|
+
case "OL":
|
|
1411
|
+
r = "ordered", i = "ol";
|
|
1412
|
+
break;
|
|
1413
|
+
case "UL":
|
|
1414
|
+
case "LI":
|
|
1415
|
+
r = "unordered", i = "ul";
|
|
1416
|
+
}
|
|
1417
|
+
const a = {
|
|
1418
|
+
style: r,
|
|
1419
|
+
meta: {},
|
|
1420
|
+
items: []
|
|
1421
|
+
};
|
|
1422
|
+
r === "ordered" && (this.data.meta.counterType = "numeric", this.data.meta.start = 1);
|
|
1423
|
+
const l = (s) => Array.from(s.querySelectorAll(":scope > li")).map((d) => {
|
|
1424
|
+
const u = d.querySelector(`:scope > ${i}`), p = u ? l(u) : [];
|
|
1425
|
+
return {
|
|
1426
|
+
content: d.innerHTML ?? "",
|
|
1427
|
+
meta: {},
|
|
1428
|
+
items: p
|
|
1429
|
+
};
|
|
1430
|
+
});
|
|
1431
|
+
return a.items = l(t), a;
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Changes ordered list start property value
|
|
1435
|
+
* @param index - new value of the start property
|
|
1436
|
+
*/
|
|
1437
|
+
changeStartWith(t) {
|
|
1438
|
+
this.listWrapper.style.setProperty("counter-reset", `item ${t - 1}`), this.data.meta.start = t;
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Changes ordered list counterType property value
|
|
1442
|
+
* @param counterType - new value of the counterType value
|
|
1443
|
+
*/
|
|
1444
|
+
changeCounters(t) {
|
|
1445
|
+
this.listWrapper.style.setProperty("--list-counter-type", t), this.data.meta.counterType = t;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Handles Enter keypress
|
|
1449
|
+
* @param event - keydown
|
|
1450
|
+
*/
|
|
1451
|
+
enterPressed(t) {
|
|
1452
|
+
var s;
|
|
1453
|
+
const n = this.currentItem;
|
|
1454
|
+
if (t.stopPropagation(), t.preventDefault(), t.isComposing || n === null)
|
|
1455
|
+
return;
|
|
1456
|
+
const r = ((s = this.renderer) == null ? void 0 : s.getItemContent(n).trim().length) === 0, i = n.parentNode === this.listWrapper, a = n.previousElementSibling === null, l = this.api.blocks.getCurrentBlockIndex();
|
|
1457
|
+
if (i && r)
|
|
1458
|
+
if (lr(n) && !sr(n)) {
|
|
1459
|
+
a ? this.convertItemToDefaultBlock(l, !0) : this.convertItemToDefaultBlock();
|
|
1460
|
+
return;
|
|
1461
|
+
} else {
|
|
1462
|
+
this.splitList(n);
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
else if (r) {
|
|
1466
|
+
this.unshiftItem(n);
|
|
1467
|
+
return;
|
|
1468
|
+
} else
|
|
1469
|
+
this.splitItem(n);
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Handle backspace
|
|
1473
|
+
* @param event - keydown
|
|
1474
|
+
*/
|
|
1475
|
+
backspace(t) {
|
|
1476
|
+
var r;
|
|
1477
|
+
const n = this.currentItem;
|
|
1478
|
+
if (n !== null && j.isCaretAtStartOfInput(n) && ((r = window.getSelection()) == null ? void 0 : r.isCollapsed) !== !1) {
|
|
1479
|
+
if (t.stopPropagation(), n.parentNode === this.listWrapper && n.previousElementSibling === null) {
|
|
1480
|
+
this.convertFirstItemToDefaultBlock();
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
t.preventDefault(), this.mergeItemWithPrevious(n);
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Reduce indentation for current item
|
|
1488
|
+
* @param event - keydown
|
|
1489
|
+
*/
|
|
1490
|
+
shiftTab(t) {
|
|
1491
|
+
t.stopPropagation(), t.preventDefault(), this.currentItem !== null && this.unshiftItem(this.currentItem);
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Decrease indentation of the passed item
|
|
1495
|
+
* @param item - list item to be unshifted
|
|
1496
|
+
*/
|
|
1497
|
+
unshiftItem(t) {
|
|
1498
|
+
if (!t.parentNode || !O(t.parentNode))
|
|
1499
|
+
return;
|
|
1500
|
+
const n = t.parentNode.closest(`.${h.item}`);
|
|
1501
|
+
if (!n)
|
|
1502
|
+
return;
|
|
1503
|
+
let r = C(t);
|
|
1504
|
+
if (t.parentElement === null)
|
|
1505
|
+
return;
|
|
1506
|
+
const i = U(t);
|
|
1507
|
+
i !== null && (r === null && (r = this.renderer.renderWrapper(!1)), i.forEach((a) => {
|
|
1508
|
+
r.appendChild(a);
|
|
1509
|
+
}), t.appendChild(r)), n.after(t), E(t, !1), K(n);
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Method that is used for list splitting and moving trailing items to the new separated list
|
|
1513
|
+
* @param item - current item html element
|
|
1514
|
+
*/
|
|
1515
|
+
splitList(t) {
|
|
1516
|
+
const n = y(t), r = this.block, i = this.api.blocks.getCurrentBlockIndex();
|
|
1517
|
+
if (n.length !== 0) {
|
|
1518
|
+
const o = n[0];
|
|
1519
|
+
this.unshiftItem(o), E(t, !1);
|
|
1520
|
+
}
|
|
1521
|
+
if (t.previousElementSibling === null && t.parentNode === this.listWrapper) {
|
|
1522
|
+
this.convertItemToDefaultBlock(i);
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
const a = U(t);
|
|
1526
|
+
if (a === null)
|
|
1527
|
+
return;
|
|
1528
|
+
const l = this.renderer.renderWrapper(!0);
|
|
1529
|
+
a.forEach((o) => {
|
|
1530
|
+
l.appendChild(o);
|
|
1531
|
+
});
|
|
1532
|
+
const s = this.save(l);
|
|
1533
|
+
s.meta.start = this.data.style == "ordered" ? 1 : void 0, this.api.blocks.insert(r == null ? void 0 : r.name, s, this.config, i + 1), this.convertItemToDefaultBlock(i + 1), l.remove();
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Method that is used for splitting item content and moving trailing content to the new sibling item
|
|
1537
|
+
* @param currentItem - current item html element
|
|
1538
|
+
*/
|
|
1539
|
+
splitItem(t) {
|
|
1540
|
+
const [n, r] = j.getCaretNodeAndOffset();
|
|
1541
|
+
if (n === null)
|
|
1542
|
+
return;
|
|
1543
|
+
const i = N(t);
|
|
1544
|
+
let a;
|
|
1545
|
+
i === null ? a = "" : a = j.getContenteditableSlice(i, n, r, "right", !0);
|
|
1546
|
+
const l = C(t), s = this.renderItem(a);
|
|
1547
|
+
t == null || t.after(s), l && s.appendChild(l), E(s);
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Method that is used for merging current item with previous one
|
|
1551
|
+
* Content of the current item would be appended to the previous item
|
|
1552
|
+
* Current item children would not change nesting level
|
|
1553
|
+
* @param item - current item html element
|
|
1554
|
+
*/
|
|
1555
|
+
mergeItemWithPrevious(t) {
|
|
1556
|
+
const n = t.previousElementSibling, r = t.parentNode;
|
|
1557
|
+
if (r === null || !O(r))
|
|
1558
|
+
return;
|
|
1559
|
+
const i = r.closest(`.${h.item}`);
|
|
1560
|
+
if (!n && !i || n && !O(n))
|
|
1561
|
+
return;
|
|
1562
|
+
let a;
|
|
1563
|
+
if (n) {
|
|
1564
|
+
const p = y(n, !1);
|
|
1565
|
+
p.length !== 0 && p.length !== 0 ? a = p[p.length - 1] : a = n;
|
|
1566
|
+
} else
|
|
1567
|
+
a = i;
|
|
1568
|
+
const l = this.renderer.getItemContent(t);
|
|
1569
|
+
if (!a)
|
|
1570
|
+
return;
|
|
1571
|
+
E(a, !1);
|
|
1572
|
+
const s = N(a);
|
|
1573
|
+
if (s === null)
|
|
1574
|
+
return;
|
|
1575
|
+
s.insertAdjacentHTML("beforeend", l);
|
|
1576
|
+
const o = y(t);
|
|
1577
|
+
if (o.length === 0) {
|
|
1578
|
+
t.remove(), K(a);
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
const d = n || i, u = C(d) ?? this.renderer.renderWrapper(!1);
|
|
1582
|
+
n ? o.forEach((p) => {
|
|
1583
|
+
u.appendChild(p);
|
|
1584
|
+
}) : o.forEach((p) => {
|
|
1585
|
+
u.prepend(p);
|
|
1586
|
+
}), C(d) === null && a.appendChild(u), t.remove();
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Add indentation to current item
|
|
1590
|
+
* @param event - keydown
|
|
1591
|
+
*/
|
|
1592
|
+
addTab(t) {
|
|
1593
|
+
var a;
|
|
1594
|
+
t.stopPropagation(), t.preventDefault();
|
|
1595
|
+
const n = this.currentItem;
|
|
1596
|
+
if (!n)
|
|
1597
|
+
return;
|
|
1598
|
+
if (((a = this.config) == null ? void 0 : a.maxLevel) !== void 0) {
|
|
1599
|
+
const l = this.currentItemLevel;
|
|
1600
|
+
if (l !== null && l === this.config.maxLevel)
|
|
1601
|
+
return;
|
|
1602
|
+
}
|
|
1603
|
+
const r = n.previousSibling;
|
|
1604
|
+
if (r === null || !O(r))
|
|
1605
|
+
return;
|
|
1606
|
+
const i = C(r);
|
|
1607
|
+
if (i)
|
|
1608
|
+
i.appendChild(n), y(n).forEach((s) => {
|
|
1609
|
+
i.appendChild(s);
|
|
1610
|
+
});
|
|
1611
|
+
else {
|
|
1612
|
+
const l = this.renderer.renderWrapper(!1);
|
|
1613
|
+
l.appendChild(n), y(n).forEach((o) => {
|
|
1614
|
+
l.appendChild(o);
|
|
1615
|
+
}), r.appendChild(l);
|
|
1616
|
+
}
|
|
1617
|
+
K(n), E(n, !1);
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Convert current item to default block with passed index
|
|
1621
|
+
* @param newBloxkIndex - optional parameter represents index, where would be inseted default block
|
|
1622
|
+
* @param removeList - optional parameter, that represents condition, if List should be removed
|
|
1623
|
+
*/
|
|
1624
|
+
convertItemToDefaultBlock(t, n) {
|
|
1625
|
+
let r;
|
|
1626
|
+
const i = this.currentItem, a = i !== null ? this.renderer.getItemContent(i) : "";
|
|
1627
|
+
n === !0 && this.api.blocks.delete(), t !== void 0 ? r = this.api.blocks.insert(void 0, { text: a }, void 0, t) : r = this.api.blocks.insert(), i == null || i.remove(), this.api.caret.setToBlock(r, "start");
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Convert first item of the list to default block
|
|
1631
|
+
* This method could be called when backspace button pressed at start of the first item of the list
|
|
1632
|
+
* First item of the list would be converted to the paragraph and first item children would be unshifted
|
|
1633
|
+
*/
|
|
1634
|
+
convertFirstItemToDefaultBlock() {
|
|
1635
|
+
const t = this.currentItem;
|
|
1636
|
+
if (t === null)
|
|
1637
|
+
return;
|
|
1638
|
+
const n = y(t);
|
|
1639
|
+
if (n.length !== 0) {
|
|
1640
|
+
const l = n[0];
|
|
1641
|
+
this.unshiftItem(l), E(t);
|
|
1642
|
+
}
|
|
1643
|
+
const r = U(t), i = this.api.blocks.getCurrentBlockIndex(), a = r === null;
|
|
1644
|
+
this.convertItemToDefaultBlock(i, a);
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* Method that calls render function of the renderer with a necessary item meta cast
|
|
1648
|
+
* @param itemContent - content to be rendered in new item
|
|
1649
|
+
* @param meta - meta used in list item rendering
|
|
1650
|
+
* @returns html element of the rendered item
|
|
1651
|
+
*/
|
|
1652
|
+
renderItem(t, n) {
|
|
1653
|
+
const r = n ?? this.renderer.composeDefaultMeta();
|
|
1654
|
+
switch (!0) {
|
|
1655
|
+
case this.renderer instanceof v:
|
|
1656
|
+
return this.renderer.renderItem(t, r);
|
|
1657
|
+
case this.renderer instanceof b:
|
|
1658
|
+
return this.renderer.renderItem(t, r);
|
|
1659
|
+
default:
|
|
1660
|
+
return this.renderer.renderItem(t, r);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Renders children list
|
|
1665
|
+
* @param items - list data used in item rendering
|
|
1666
|
+
* @param parentElement - where to append passed items
|
|
1667
|
+
*/
|
|
1668
|
+
appendItems(t, n) {
|
|
1669
|
+
t.forEach((r) => {
|
|
1670
|
+
var a;
|
|
1671
|
+
const i = this.renderItem(r.content, r.meta);
|
|
1672
|
+
if (n.appendChild(i), r.items.length) {
|
|
1673
|
+
const l = (a = this.renderer) == null ? void 0 : a.renderWrapper(!1);
|
|
1674
|
+
this.appendItems(r.items, l), i.appendChild(l);
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
const I = {
|
|
1680
|
+
wrapper: `${m}-start-with-field`,
|
|
1681
|
+
input: `${m}-start-with-field__input`,
|
|
1682
|
+
startWithElementWrapperInvalid: `${m}-start-with-field--invalid`
|
|
1683
|
+
};
|
|
1684
|
+
function or(e, { value: t, placeholder: n, attributes: r, sanitize: i }) {
|
|
1685
|
+
const a = c.make("div", I.wrapper), l = c.make("input", I.input, {
|
|
1686
|
+
placeholder: n,
|
|
1687
|
+
/**
|
|
1688
|
+
* Used to prevent focusing on the input by Tab key
|
|
1689
|
+
* (Popover in the Toolbar lays below the blocks,
|
|
1690
|
+
* so Tab in the last block will focus this hidden input if this property is not set)
|
|
1691
|
+
*/
|
|
1692
|
+
tabIndex: -1,
|
|
1693
|
+
/**
|
|
1694
|
+
* Value of the start property, if it is not specified, then it is set to one
|
|
1695
|
+
*/
|
|
1696
|
+
value: t
|
|
1697
|
+
});
|
|
1698
|
+
for (const s in r)
|
|
1699
|
+
l.setAttribute(s, r[s]);
|
|
1700
|
+
return a.appendChild(l), l.addEventListener("input", () => {
|
|
1701
|
+
i !== void 0 && (l.value = i(l.value));
|
|
1702
|
+
const s = l.checkValidity();
|
|
1703
|
+
!s && !a.classList.contains(I.startWithElementWrapperInvalid) && a.classList.add(I.startWithElementWrapperInvalid), s && a.classList.contains(I.startWithElementWrapperInvalid) && a.classList.remove(I.startWithElementWrapperInvalid), s && e(l.value);
|
|
1704
|
+
}), a;
|
|
1705
|
+
}
|
|
1706
|
+
const P = /* @__PURE__ */ new Map([
|
|
1707
|
+
/**
|
|
1708
|
+
* Value that represents default arabic numbers for counters
|
|
1709
|
+
*/
|
|
1710
|
+
["Numeric", "numeric"],
|
|
1711
|
+
/**
|
|
1712
|
+
* Value that represents lower roman numbers for counteres
|
|
1713
|
+
*/
|
|
1714
|
+
["Lower Roman", "lower-roman"],
|
|
1715
|
+
/**
|
|
1716
|
+
* Value that represents upper roman numbers for counters
|
|
1717
|
+
*/
|
|
1718
|
+
["Upper Roman", "upper-roman"],
|
|
1719
|
+
/**
|
|
1720
|
+
* Value that represents lower alpha characters for counters
|
|
1721
|
+
*/
|
|
1722
|
+
["Lower Alpha", "lower-alpha"],
|
|
1723
|
+
/**
|
|
1724
|
+
* Value that represents upper alpha characters for counters
|
|
1725
|
+
*/
|
|
1726
|
+
["Upper Alpha", "upper-alpha"]
|
|
1727
|
+
]), He = /* @__PURE__ */ new Map([
|
|
1728
|
+
/**
|
|
1729
|
+
* Value that represents Icon for Numeric counter type
|
|
1730
|
+
*/
|
|
1731
|
+
["numeric", St],
|
|
1732
|
+
/**
|
|
1733
|
+
* Value that represents Icon for Lower Roman counter type
|
|
1734
|
+
*/
|
|
1735
|
+
["lower-roman", Ot],
|
|
1736
|
+
/**
|
|
1737
|
+
* Value that represents Icon for Upper Roman counter type
|
|
1738
|
+
*/
|
|
1739
|
+
["upper-roman", kt],
|
|
1740
|
+
/**
|
|
1741
|
+
* Value that represents Icon for Lower Alpha counter type
|
|
1742
|
+
*/
|
|
1743
|
+
["lower-alpha", Et],
|
|
1744
|
+
/**
|
|
1745
|
+
* Value that represents Icon for Upper Alpha counter type
|
|
1746
|
+
*/
|
|
1747
|
+
["upper-alpha", _t]
|
|
1748
|
+
]);
|
|
1749
|
+
function ur(e) {
|
|
1750
|
+
return e.replace(/\D+/g, "");
|
|
1751
|
+
}
|
|
1752
|
+
function cr(e) {
|
|
1753
|
+
return typeof e.items[0] == "string";
|
|
1754
|
+
}
|
|
1755
|
+
function dr(e) {
|
|
1756
|
+
return !("meta" in e);
|
|
1757
|
+
}
|
|
1758
|
+
function fr(e) {
|
|
1759
|
+
return typeof e.items[0] != "string" && "text" in e.items[0] && "checked" in e.items[0] && typeof e.items[0].text == "string" && typeof e.items[0].checked == "boolean";
|
|
1760
|
+
}
|
|
1761
|
+
function pr(e) {
|
|
1762
|
+
const t = [];
|
|
1763
|
+
return cr(e) ? (e.items.forEach((n) => {
|
|
1764
|
+
t.push({
|
|
1765
|
+
content: n,
|
|
1766
|
+
meta: {},
|
|
1767
|
+
items: []
|
|
1768
|
+
});
|
|
1769
|
+
}), {
|
|
1770
|
+
style: e.style,
|
|
1771
|
+
meta: {},
|
|
1772
|
+
items: t
|
|
1773
|
+
}) : fr(e) ? (e.items.forEach((n) => {
|
|
1774
|
+
t.push({
|
|
1775
|
+
content: n.text,
|
|
1776
|
+
meta: {
|
|
1777
|
+
checked: n.checked
|
|
1778
|
+
},
|
|
1779
|
+
items: []
|
|
1780
|
+
});
|
|
1781
|
+
}), {
|
|
1782
|
+
style: "checklist",
|
|
1783
|
+
meta: {},
|
|
1784
|
+
items: t
|
|
1785
|
+
}) : dr(e) ? {
|
|
1786
|
+
style: e.style,
|
|
1787
|
+
meta: {},
|
|
1788
|
+
items: e.items
|
|
1789
|
+
} : structuredClone(e);
|
|
1790
|
+
}
|
|
1791
|
+
class G {
|
|
1792
|
+
/**
|
|
1793
|
+
* Notify core that read-only mode is supported
|
|
1794
|
+
*/
|
|
1795
|
+
static get isReadOnlySupported() {
|
|
1796
|
+
return !0;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Allow to use native Enter behaviour
|
|
1800
|
+
*/
|
|
1801
|
+
static get enableLineBreaks() {
|
|
1802
|
+
return !0;
|
|
1803
|
+
}
|
|
1804
|
+
/**
|
|
1805
|
+
* Get Tool toolbox settings
|
|
1806
|
+
* icon - Tool icon's SVG
|
|
1807
|
+
* title - title to show in toolbox
|
|
1808
|
+
*/
|
|
1809
|
+
static get toolbox() {
|
|
1810
|
+
return [
|
|
1811
|
+
{
|
|
1812
|
+
icon: $e,
|
|
1813
|
+
title: "Unordered List",
|
|
1814
|
+
data: {
|
|
1815
|
+
style: "unordered"
|
|
1816
|
+
}
|
|
1817
|
+
},
|
|
1818
|
+
{
|
|
1819
|
+
icon: Be,
|
|
1820
|
+
title: "Ordered List",
|
|
1821
|
+
data: {
|
|
1822
|
+
style: "ordered"
|
|
1823
|
+
}
|
|
1824
|
+
},
|
|
1825
|
+
{
|
|
1826
|
+
icon: Ae,
|
|
1827
|
+
title: "Checklist",
|
|
1828
|
+
data: {
|
|
1829
|
+
style: "checklist"
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
];
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* On paste sanitzation config. Allow only tags that are allowed in the Tool.
|
|
1836
|
+
* @returns - paste config object used in editor
|
|
1837
|
+
*/
|
|
1838
|
+
static get pasteConfig() {
|
|
1839
|
+
return {
|
|
1840
|
+
tags: ["OL", "UL", "LI"]
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Convert from text to list with import and export list to text
|
|
1845
|
+
*/
|
|
1846
|
+
static get conversionConfig() {
|
|
1847
|
+
return {
|
|
1848
|
+
export: (t) => G.joinRecursive(t),
|
|
1849
|
+
import: (t, n) => ({
|
|
1850
|
+
meta: {},
|
|
1851
|
+
items: [
|
|
1852
|
+
{
|
|
1853
|
+
content: t,
|
|
1854
|
+
meta: {},
|
|
1855
|
+
items: []
|
|
1856
|
+
}
|
|
1857
|
+
],
|
|
1858
|
+
style: (n == null ? void 0 : n.defaultStyle) !== void 0 ? n.defaultStyle : "unordered"
|
|
1859
|
+
})
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Get list style name
|
|
1864
|
+
*/
|
|
1865
|
+
get listStyle() {
|
|
1866
|
+
return this.data.style || this.defaultListStyle;
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Set list style
|
|
1870
|
+
* @param style - new style to set
|
|
1871
|
+
*/
|
|
1872
|
+
set listStyle(t) {
|
|
1873
|
+
var r;
|
|
1874
|
+
this.data.style = t, this.changeTabulatorByStyle();
|
|
1875
|
+
const n = this.list.render();
|
|
1876
|
+
(r = this.listElement) == null || r.replaceWith(n), this.listElement = n;
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Render plugin`s main Element and fill it with saved data
|
|
1880
|
+
* @param params - tool constructor options
|
|
1881
|
+
* @param params.data - previously saved data
|
|
1882
|
+
* @param params.config - user config for Tool
|
|
1883
|
+
* @param params.api - Editor.js API
|
|
1884
|
+
* @param params.readOnly - read-only mode flag
|
|
1885
|
+
*/
|
|
1886
|
+
constructor({ data: t, config: n, api: r, readOnly: i, block: a }) {
|
|
1887
|
+
var s;
|
|
1888
|
+
this.api = r, this.readOnly = i, this.config = n, this.block = a, this.defaultListStyle = ((s = this.config) == null ? void 0 : s.defaultStyle) || "unordered", this.defaultCounterTypes = this.config.counterTypes || Array.from(P.values());
|
|
1889
|
+
const l = {
|
|
1890
|
+
style: this.defaultListStyle,
|
|
1891
|
+
meta: {},
|
|
1892
|
+
items: []
|
|
1893
|
+
};
|
|
1894
|
+
this.data = Object.keys(t).length ? pr(t) : l, this.listStyle === "ordered" && this.data.meta.counterType === void 0 && (this.data.meta.counterType = "numeric"), this.changeTabulatorByStyle();
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Convert from list to text for conversionConfig
|
|
1898
|
+
* @param data - current data of the list
|
|
1899
|
+
* @returns - string of the recursively merged contents of the items of the list
|
|
1900
|
+
*/
|
|
1901
|
+
static joinRecursive(t) {
|
|
1902
|
+
return t.items.map((n) => `${n.content} ${G.joinRecursive(n)}`).join("");
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Function that is responsible for content rendering
|
|
1906
|
+
* @returns rendered list wrapper with all contents
|
|
1907
|
+
*/
|
|
1908
|
+
render() {
|
|
1909
|
+
return this.listElement = this.list.render(), this.listElement;
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Function that is responsible for content saving
|
|
1913
|
+
* @returns formatted content used in editor
|
|
1914
|
+
*/
|
|
1915
|
+
save() {
|
|
1916
|
+
return this.data = this.list.save(), this.data;
|
|
1917
|
+
}
|
|
1918
|
+
/**
|
|
1919
|
+
* Function that is responsible for mergind two lists into one
|
|
1920
|
+
* @param data - data of the next standing list, that should be merged with current
|
|
1921
|
+
*/
|
|
1922
|
+
merge(t) {
|
|
1923
|
+
this.list.merge(t);
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* Creates Block Tune allowing to change the list style
|
|
1927
|
+
* @returns array of tune configs
|
|
1928
|
+
*/
|
|
1929
|
+
renderSettings() {
|
|
1930
|
+
const t = [
|
|
1931
|
+
{
|
|
1932
|
+
label: this.api.i18n.t("Unordered"),
|
|
1933
|
+
icon: $e,
|
|
1934
|
+
closeOnActivate: !0,
|
|
1935
|
+
isActive: this.listStyle == "unordered",
|
|
1936
|
+
onActivate: () => {
|
|
1937
|
+
this.listStyle = "unordered";
|
|
1938
|
+
}
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
label: this.api.i18n.t("Ordered"),
|
|
1942
|
+
icon: Be,
|
|
1943
|
+
closeOnActivate: !0,
|
|
1944
|
+
isActive: this.listStyle == "ordered",
|
|
1945
|
+
onActivate: () => {
|
|
1946
|
+
this.listStyle = "ordered";
|
|
1947
|
+
}
|
|
1948
|
+
},
|
|
1949
|
+
{
|
|
1950
|
+
label: this.api.i18n.t("Checklist"),
|
|
1951
|
+
icon: Ae,
|
|
1952
|
+
closeOnActivate: !0,
|
|
1953
|
+
isActive: this.listStyle == "checklist",
|
|
1954
|
+
onActivate: () => {
|
|
1955
|
+
this.listStyle = "checklist";
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
];
|
|
1959
|
+
if (this.listStyle === "ordered") {
|
|
1960
|
+
const n = or(
|
|
1961
|
+
(a) => this.changeStartWith(Number(a)),
|
|
1962
|
+
{
|
|
1963
|
+
value: String(this.data.meta.start ?? 1),
|
|
1964
|
+
placeholder: "",
|
|
1965
|
+
attributes: {
|
|
1966
|
+
required: "true"
|
|
1967
|
+
},
|
|
1968
|
+
sanitize: (a) => ur(a)
|
|
1969
|
+
}
|
|
1970
|
+
), r = [
|
|
1971
|
+
{
|
|
1972
|
+
label: this.api.i18n.t("Start with"),
|
|
1973
|
+
icon: It,
|
|
1974
|
+
children: {
|
|
1975
|
+
items: [
|
|
1976
|
+
{
|
|
1977
|
+
element: n,
|
|
1978
|
+
// @ts-expect-error ts(2820) can not use PopoverItem enum from editor.js types
|
|
1979
|
+
type: "html"
|
|
1980
|
+
}
|
|
1981
|
+
]
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
], i = {
|
|
1985
|
+
label: this.api.i18n.t("Counter type"),
|
|
1986
|
+
icon: He.get(this.data.meta.counterType),
|
|
1987
|
+
children: {
|
|
1988
|
+
items: []
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
P.forEach((a, l) => {
|
|
1992
|
+
const s = P.get(l);
|
|
1993
|
+
this.defaultCounterTypes.includes(s) && i.children.items.push({
|
|
1994
|
+
title: this.api.i18n.t(l),
|
|
1995
|
+
icon: He.get(s),
|
|
1996
|
+
isActive: this.data.meta.counterType === P.get(l),
|
|
1997
|
+
closeOnActivate: !0,
|
|
1998
|
+
onActivate: () => {
|
|
1999
|
+
this.changeCounters(P.get(l));
|
|
2000
|
+
}
|
|
2001
|
+
});
|
|
2002
|
+
}), i.children.items.length > 1 && r.push(i), t.push({ type: "separator" }, ...r);
|
|
2003
|
+
}
|
|
2004
|
+
return t;
|
|
2005
|
+
}
|
|
2006
|
+
/**
|
|
2007
|
+
* On paste callback that is fired from Editor.
|
|
2008
|
+
* @param event - event with pasted data
|
|
2009
|
+
*/
|
|
2010
|
+
onPaste(t) {
|
|
2011
|
+
const { tagName: n } = t.detail.data;
|
|
2012
|
+
switch (n) {
|
|
2013
|
+
case "OL":
|
|
2014
|
+
this.listStyle = "ordered";
|
|
2015
|
+
break;
|
|
2016
|
+
case "UL":
|
|
2017
|
+
case "LI":
|
|
2018
|
+
this.listStyle = "unordered";
|
|
2019
|
+
}
|
|
2020
|
+
this.list.onPaste(t);
|
|
2021
|
+
}
|
|
2022
|
+
/**
|
|
2023
|
+
* Handle UL, OL and LI tags paste and returns List data
|
|
2024
|
+
* @param element - html element that contains whole list
|
|
2025
|
+
*/
|
|
2026
|
+
pasteHandler(t) {
|
|
2027
|
+
return this.list.pasteHandler(t);
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Changes ordered list counterType property value
|
|
2031
|
+
* @param counterType - new value of the counterType value
|
|
2032
|
+
*/
|
|
2033
|
+
changeCounters(t) {
|
|
2034
|
+
var n;
|
|
2035
|
+
(n = this.list) == null || n.changeCounters(t), this.data.meta.counterType = t;
|
|
2036
|
+
}
|
|
2037
|
+
/**
|
|
2038
|
+
* Changes ordered list start property value
|
|
2039
|
+
* @param index - new value of the start property
|
|
2040
|
+
*/
|
|
2041
|
+
changeStartWith(t) {
|
|
2042
|
+
var n;
|
|
2043
|
+
(n = this.list) == null || n.changeStartWith(t), this.data.meta.start = t;
|
|
2044
|
+
}
|
|
2045
|
+
/**
|
|
2046
|
+
* This method allows changing tabulator respectfully to passed style
|
|
2047
|
+
*/
|
|
2048
|
+
changeTabulatorByStyle() {
|
|
2049
|
+
switch (this.listStyle) {
|
|
2050
|
+
case "ordered":
|
|
2051
|
+
this.list = new z(
|
|
2052
|
+
{
|
|
2053
|
+
data: this.data,
|
|
2054
|
+
readOnly: this.readOnly,
|
|
2055
|
+
api: this.api,
|
|
2056
|
+
config: this.config,
|
|
2057
|
+
block: this.block
|
|
2058
|
+
},
|
|
2059
|
+
new v(this.readOnly, this.config)
|
|
2060
|
+
);
|
|
2061
|
+
break;
|
|
2062
|
+
case "unordered":
|
|
2063
|
+
this.list = new z(
|
|
2064
|
+
{
|
|
2065
|
+
data: this.data,
|
|
2066
|
+
readOnly: this.readOnly,
|
|
2067
|
+
api: this.api,
|
|
2068
|
+
config: this.config,
|
|
2069
|
+
block: this.block
|
|
2070
|
+
},
|
|
2071
|
+
new b(this.readOnly, this.config)
|
|
2072
|
+
);
|
|
2073
|
+
break;
|
|
2074
|
+
case "checklist":
|
|
2075
|
+
this.list = new z(
|
|
2076
|
+
{
|
|
2077
|
+
data: this.data,
|
|
2078
|
+
readOnly: this.readOnly,
|
|
2079
|
+
api: this.api,
|
|
2080
|
+
config: this.config,
|
|
2081
|
+
block: this.block
|
|
2082
|
+
},
|
|
2083
|
+
new f(this.readOnly, this.config)
|
|
2084
|
+
);
|
|
2085
|
+
break;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
export {
|
|
2090
|
+
G as default
|
|
2091
|
+
};
|