@enos5/enos-vue-default 1.8.16 → 1.8.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-Ber986DY.js +87 -0
- package/dist/code-Ber986DY.js.map +1 -0
- package/dist/components/TableList.vue.d.ts +11 -0
- package/dist/components/TableListForm.vue.d.ts +11 -0
- package/dist/components/TableSearch.vue.d.ts +11 -0
- package/dist/default-CIJCtYmL.js +276 -0
- package/dist/default-CIJCtYmL.js.map +1 -0
- package/dist/dom-DNRnXSoJ.js +7016 -0
- package/dist/dom-DNRnXSoJ.js.map +1 -0
- package/dist/image-BBEGvs_X.js +1408 -0
- package/dist/image-BBEGvs_X.js.map +1 -0
- package/dist/index.js +2 -62
- package/dist/index.node.js +2 -62
- package/dist/link-BCKWs7cm.js +1421 -0
- package/dist/link-BCKWs7cm.js.map +1 -0
- package/dist/lists-DO3bIHZE.js +496 -0
- package/dist/lists-DO3bIHZE.js.map +1 -0
- package/dist/plugin-DyVd9Eh7.js +6258 -0
- package/dist/plugin-DyVd9Eh7.js.map +1 -0
- package/dist/silver-DMBzT-QW.js +28483 -0
- package/dist/silver-DMBzT-QW.js.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/table-CAjD5lLC.js +3169 -0
- package/dist/table-CAjD5lLC.js.map +1 -0
- package/dist/tinymce-DQF9Ibks.js +33699 -0
- package/dist/tinymce-DQF9Ibks.js.map +1 -0
- package/package.json +1 -1
- package/dist/_commonjsHelpers-CUmg6egw.js +0 -7
- package/dist/_commonjsHelpers-CUmg6egw.js.map +0 -1
- package/dist/index-1G1T4Qrv.js +0 -31373
- package/dist/index-1G1T4Qrv.js.map +0 -1
- package/dist/index-BBGZQp5w.js +0 -7816
- package/dist/index-BBGZQp5w.js.map +0 -1
- package/dist/index-BR_u7CCm.js +0 -3351
- package/dist/index-BR_u7CCm.js.map +0 -1
- package/dist/index-Bsqrrc8R.js +0 -315
- package/dist/index-Bsqrrc8R.js.map +0 -1
- package/dist/index-CiFpmPug.js +0 -122
- package/dist/index-CiFpmPug.js.map +0 -1
- package/dist/index-CuSlJQwq.js +0 -1581
- package/dist/index-CuSlJQwq.js.map +0 -1
- package/dist/index-D72Leh_x.js +0 -573
- package/dist/index-D72Leh_x.js.map +0 -1
- package/dist/index-ukywSRmc.js +0 -1581
- package/dist/index-ukywSRmc.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.node.js.map +0 -1
- package/dist/plugin-D1NKz8QO.js +0 -6559
- package/dist/plugin-D1NKz8QO.js.map +0 -1
- package/dist/tinymce-Dg510HCs.js +0 -35756
- package/dist/tinymce-Dg510HCs.js.map +0 -1
package/dist/index-ukywSRmc.js
DELETED
|
@@ -1,1581 +0,0 @@
|
|
|
1
|
-
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.js";
|
|
2
|
-
function _mergeNamespaces(n, m) {
|
|
3
|
-
for (var i = 0; i < m.length; i++) {
|
|
4
|
-
const e = m[i];
|
|
5
|
-
if (typeof e !== "string" && !Array.isArray(e)) {
|
|
6
|
-
for (const k in e) {
|
|
7
|
-
if (k !== "default" && !(k in n)) {
|
|
8
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
9
|
-
if (d) {
|
|
10
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: () => e[k]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
|
|
20
|
-
}
|
|
21
|
-
var image = {};
|
|
22
|
-
var plugin = {};
|
|
23
|
-
var hasRequiredPlugin;
|
|
24
|
-
function requirePlugin() {
|
|
25
|
-
if (hasRequiredPlugin) return plugin;
|
|
26
|
-
hasRequiredPlugin = 1;
|
|
27
|
-
(function() {
|
|
28
|
-
var global$4 = tinymce.util.Tools.resolve("tinymce.PluginManager");
|
|
29
|
-
const getPrototypeOf = Object.getPrototypeOf;
|
|
30
|
-
const hasProto = (v, constructor, predicate) => {
|
|
31
|
-
if (predicate(v, constructor.prototype)) {
|
|
32
|
-
return true;
|
|
33
|
-
} else {
|
|
34
|
-
return v.constructor?.name === constructor.name;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const typeOf = (x) => {
|
|
38
|
-
const t = typeof x;
|
|
39
|
-
if (x === null) {
|
|
40
|
-
return "null";
|
|
41
|
-
} else if (t === "object" && Array.isArray(x)) {
|
|
42
|
-
return "array";
|
|
43
|
-
} else if (t === "object" && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
|
44
|
-
return "string";
|
|
45
|
-
} else {
|
|
46
|
-
return t;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const isType = (type) => (value) => typeOf(value) === type;
|
|
50
|
-
const isSimpleType = (type) => (value) => typeof value === type;
|
|
51
|
-
const eq = (t) => (a) => t === a;
|
|
52
|
-
const is = (value, constructor) => isObject(value) && hasProto(value, constructor, (o, proto) => getPrototypeOf(o) === proto);
|
|
53
|
-
const isString = isType("string");
|
|
54
|
-
const isObject = isType("object");
|
|
55
|
-
const isPlainObject = (value) => is(value, Object);
|
|
56
|
-
const isArray = isType("array");
|
|
57
|
-
const isNull = eq(null);
|
|
58
|
-
const isBoolean = isSimpleType("boolean");
|
|
59
|
-
const isNullable = (a) => a === null || a === void 0;
|
|
60
|
-
const isNonNullable = (a) => !isNullable(a);
|
|
61
|
-
const isFunction = isSimpleType("function");
|
|
62
|
-
const isNumber = isSimpleType("number");
|
|
63
|
-
const isArrayOf = (value, pred) => {
|
|
64
|
-
if (isArray(value)) {
|
|
65
|
-
for (let i = 0, len = value.length; i < len; ++i) {
|
|
66
|
-
if (!pred(value[i])) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
};
|
|
74
|
-
const noop = () => {
|
|
75
|
-
};
|
|
76
|
-
class Optional {
|
|
77
|
-
tag;
|
|
78
|
-
value;
|
|
79
|
-
// Sneaky optimisation: every instance of Optional.none is identical, so just
|
|
80
|
-
// reuse the same object
|
|
81
|
-
static singletonNone = new Optional(false);
|
|
82
|
-
// The internal representation has a `tag` and a `value`, but both are
|
|
83
|
-
// private: able to be console.logged, but not able to be accessed by code
|
|
84
|
-
constructor(tag, value) {
|
|
85
|
-
this.tag = tag;
|
|
86
|
-
this.value = value;
|
|
87
|
-
}
|
|
88
|
-
// --- Identities ---
|
|
89
|
-
/**
|
|
90
|
-
* Creates a new `Optional<T>` that **does** contain a value.
|
|
91
|
-
*/
|
|
92
|
-
static some(value) {
|
|
93
|
-
return new Optional(true, value);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Create a new `Optional<T>` that **does not** contain a value. `T` can be
|
|
97
|
-
* any type because we don't actually have a `T`.
|
|
98
|
-
*/
|
|
99
|
-
static none() {
|
|
100
|
-
return Optional.singletonNone;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Perform a transform on an `Optional` type. Regardless of whether this
|
|
104
|
-
* `Optional` contains a value or not, `fold` will return a value of type `U`.
|
|
105
|
-
* If this `Optional` does not contain a value, the `U` will be created by
|
|
106
|
-
* calling `onNone`. If this `Optional` does contain a value, the `U` will be
|
|
107
|
-
* created by calling `onSome`.
|
|
108
|
-
*
|
|
109
|
-
* For the FP enthusiasts in the room, this function:
|
|
110
|
-
* 1. Could be used to implement all of the functions below
|
|
111
|
-
* 2. Forms a catamorphism
|
|
112
|
-
*/
|
|
113
|
-
fold(onNone, onSome) {
|
|
114
|
-
if (this.tag) {
|
|
115
|
-
return onSome(this.value);
|
|
116
|
-
} else {
|
|
117
|
-
return onNone();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Determine if this `Optional` object contains a value.
|
|
122
|
-
*/
|
|
123
|
-
isSome() {
|
|
124
|
-
return this.tag;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Determine if this `Optional` object **does not** contain a value.
|
|
128
|
-
*/
|
|
129
|
-
isNone() {
|
|
130
|
-
return !this.tag;
|
|
131
|
-
}
|
|
132
|
-
// --- Functor (name stolen from Haskell / maths) ---
|
|
133
|
-
/**
|
|
134
|
-
* Perform a transform on an `Optional` object, **if** there is a value. If
|
|
135
|
-
* you provide a function to turn a T into a U, this is the function you use
|
|
136
|
-
* to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
|
|
137
|
-
* a value then the output will also contain a value (that value being the
|
|
138
|
-
* output of `mapper(this.value)`), and if this **does not** contain a value
|
|
139
|
-
* then neither will the output.
|
|
140
|
-
*/
|
|
141
|
-
map(mapper) {
|
|
142
|
-
if (this.tag) {
|
|
143
|
-
return Optional.some(mapper(this.value));
|
|
144
|
-
} else {
|
|
145
|
-
return Optional.none();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// --- Monad (name stolen from Haskell / maths) ---
|
|
149
|
-
/**
|
|
150
|
-
* Perform a transform on an `Optional` object, **if** there is a value.
|
|
151
|
-
* Unlike `map`, here the transform itself also returns an `Optional`.
|
|
152
|
-
*/
|
|
153
|
-
bind(binder) {
|
|
154
|
-
if (this.tag) {
|
|
155
|
-
return binder(this.value);
|
|
156
|
-
} else {
|
|
157
|
-
return Optional.none();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// --- Traversable (name stolen from Haskell / maths) ---
|
|
161
|
-
/**
|
|
162
|
-
* For a given predicate, this function finds out if there **exists** a value
|
|
163
|
-
* inside this `Optional` object that meets the predicate. In practice, this
|
|
164
|
-
* means that for `Optional`s that do not contain a value it returns false (as
|
|
165
|
-
* no predicate-meeting value exists).
|
|
166
|
-
*/
|
|
167
|
-
exists(predicate) {
|
|
168
|
-
return this.tag && predicate(this.value);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* For a given predicate, this function finds out if **all** the values inside
|
|
172
|
-
* this `Optional` object meet the predicate. In practice, this means that
|
|
173
|
-
* for `Optional`s that do not contain a value it returns true (as all 0
|
|
174
|
-
* objects do meet the predicate).
|
|
175
|
-
*/
|
|
176
|
-
forall(predicate) {
|
|
177
|
-
return !this.tag || predicate(this.value);
|
|
178
|
-
}
|
|
179
|
-
filter(predicate) {
|
|
180
|
-
if (!this.tag || predicate(this.value)) {
|
|
181
|
-
return this;
|
|
182
|
-
} else {
|
|
183
|
-
return Optional.none();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
// --- Getters ---
|
|
187
|
-
/**
|
|
188
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
189
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
190
|
-
* value.
|
|
191
|
-
*/
|
|
192
|
-
getOr(replacement) {
|
|
193
|
-
return this.tag ? this.value : replacement;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
197
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
198
|
-
* value. Unlike `getOr`, in this method the `replacement` object is also
|
|
199
|
-
* `Optional` - meaning that this method will always return an `Optional`.
|
|
200
|
-
*/
|
|
201
|
-
or(replacement) {
|
|
202
|
-
return this.tag ? this : replacement;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
206
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
207
|
-
* value. Unlike `getOr`, in this method the `replacement` value is
|
|
208
|
-
* "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
|
|
209
|
-
* pass a function which (if called) will **return** the `value` you want to
|
|
210
|
-
* use.
|
|
211
|
-
*/
|
|
212
|
-
getOrThunk(thunk) {
|
|
213
|
-
return this.tag ? this.value : thunk();
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
217
|
-
* `replacement` value if the provided Optional object does not contain a
|
|
218
|
-
* value.
|
|
219
|
-
*
|
|
220
|
-
* Unlike `or`, in this method the `replacement` value is "thunked" - that is
|
|
221
|
-
* to say that you don't pass a value to `orThunk`, you pass a function which
|
|
222
|
-
* (if called) will **return** the `value` you want to use.
|
|
223
|
-
*
|
|
224
|
-
* Unlike `getOrThunk`, in this method the `replacement` value is also
|
|
225
|
-
* `Optional`, meaning that this method will always return an `Optional`.
|
|
226
|
-
*/
|
|
227
|
-
orThunk(thunk) {
|
|
228
|
-
return this.tag ? this : thunk();
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Get the value out of the inside of the `Optional` object, throwing an
|
|
232
|
-
* exception if the provided `Optional` object does not contain a value.
|
|
233
|
-
*
|
|
234
|
-
* WARNING:
|
|
235
|
-
* You should only be using this function if you know that the `Optional`
|
|
236
|
-
* object **is not** empty (otherwise you're throwing exceptions in production
|
|
237
|
-
* code, which is bad).
|
|
238
|
-
*
|
|
239
|
-
* In tests this is more acceptable.
|
|
240
|
-
*
|
|
241
|
-
* Prefer other methods to this, such as `.each`.
|
|
242
|
-
*/
|
|
243
|
-
getOrDie(message) {
|
|
244
|
-
if (!this.tag) {
|
|
245
|
-
throw new Error(message ?? "Called getOrDie on None");
|
|
246
|
-
} else {
|
|
247
|
-
return this.value;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
// --- Interop with null and undefined ---
|
|
251
|
-
/**
|
|
252
|
-
* Creates an `Optional` value from a nullable (or undefined-able) input.
|
|
253
|
-
* Null, or undefined, is converted to `None`, and anything else is converted
|
|
254
|
-
* to `Some`.
|
|
255
|
-
*/
|
|
256
|
-
static from(value) {
|
|
257
|
-
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Converts an `Optional` to a nullable type, by getting the value if it
|
|
261
|
-
* exists, or returning `null` if it does not.
|
|
262
|
-
*/
|
|
263
|
-
getOrNull() {
|
|
264
|
-
return this.tag ? this.value : null;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Converts an `Optional` to an undefined-able type, by getting the value if
|
|
268
|
-
* it exists, or returning `undefined` if it does not.
|
|
269
|
-
*/
|
|
270
|
-
getOrUndefined() {
|
|
271
|
-
return this.value;
|
|
272
|
-
}
|
|
273
|
-
// --- Utilities ---
|
|
274
|
-
/**
|
|
275
|
-
* If the `Optional` contains a value, perform an action on that value.
|
|
276
|
-
* Unlike the rest of the methods on this type, `.each` has side-effects. If
|
|
277
|
-
* you want to transform an `Optional<T>` **into** something, then this is not
|
|
278
|
-
* the method for you. If you want to use an `Optional<T>` to **do**
|
|
279
|
-
* something, then this is the method for you - provided you're okay with not
|
|
280
|
-
* doing anything in the case where the `Optional` doesn't have a value inside
|
|
281
|
-
* it. If you're not sure whether your use-case fits into transforming
|
|
282
|
-
* **into** something or **doing** something, check whether it has a return
|
|
283
|
-
* value. If it does, you should be performing a transform.
|
|
284
|
-
*/
|
|
285
|
-
each(worker) {
|
|
286
|
-
if (this.tag) {
|
|
287
|
-
worker(this.value);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Turn the `Optional` object into an array that contains all of the values
|
|
292
|
-
* stored inside the `Optional`. In practice, this means the output will have
|
|
293
|
-
* either 0 or 1 elements.
|
|
294
|
-
*/
|
|
295
|
-
toArray() {
|
|
296
|
-
return this.tag ? [this.value] : [];
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Turn the `Optional` object into a string for debugging or printing. Not
|
|
300
|
-
* recommended for production code, but good for debugging. Also note that
|
|
301
|
-
* these days an `Optional` object can be logged to the console directly, and
|
|
302
|
-
* its inner value (if it exists) will be visible.
|
|
303
|
-
*/
|
|
304
|
-
toString() {
|
|
305
|
-
return this.tag ? `some(${this.value})` : "none()";
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
const nativePush = Array.prototype.push;
|
|
309
|
-
const flatten = (xs) => {
|
|
310
|
-
const r = [];
|
|
311
|
-
for (let i = 0, len = xs.length; i < len; ++i) {
|
|
312
|
-
if (!isArray(xs[i])) {
|
|
313
|
-
throw new Error("Arr.flatten item " + i + " was not an array, input: " + xs);
|
|
314
|
-
}
|
|
315
|
-
nativePush.apply(r, xs[i]);
|
|
316
|
-
}
|
|
317
|
-
return r;
|
|
318
|
-
};
|
|
319
|
-
const get = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
320
|
-
const head = (xs) => get(xs, 0);
|
|
321
|
-
const findMap = (arr, f) => {
|
|
322
|
-
for (let i = 0; i < arr.length; i++) {
|
|
323
|
-
const r = f(arr[i], i);
|
|
324
|
-
if (r.isSome()) {
|
|
325
|
-
return r;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return Optional.none();
|
|
329
|
-
};
|
|
330
|
-
const keys = Object.keys;
|
|
331
|
-
const hasOwnProperty = Object.hasOwnProperty;
|
|
332
|
-
const each = (obj, f) => {
|
|
333
|
-
const props = keys(obj);
|
|
334
|
-
for (let k = 0, len = props.length; k < len; k++) {
|
|
335
|
-
const i = props[k];
|
|
336
|
-
const x = obj[i];
|
|
337
|
-
f(x, i);
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
const objAcc = (r) => (x, i) => {
|
|
341
|
-
r[i] = x;
|
|
342
|
-
};
|
|
343
|
-
const internalFilter = (obj, pred, onTrue, onFalse) => {
|
|
344
|
-
each(obj, (x, i) => {
|
|
345
|
-
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
346
|
-
});
|
|
347
|
-
};
|
|
348
|
-
const filter = (obj, pred) => {
|
|
349
|
-
const t = {};
|
|
350
|
-
internalFilter(obj, pred, objAcc(t), noop);
|
|
351
|
-
return t;
|
|
352
|
-
};
|
|
353
|
-
const has = (obj, key) => hasOwnProperty.call(obj, key);
|
|
354
|
-
const hasNonNullableKey = (obj, key) => has(obj, key) && obj[key] !== void 0 && obj[key] !== null;
|
|
355
|
-
const deep = (old, nu) => {
|
|
356
|
-
const bothObjects = isPlainObject(old) && isPlainObject(nu);
|
|
357
|
-
return bothObjects ? deepMerge(old, nu) : nu;
|
|
358
|
-
};
|
|
359
|
-
const baseMerge = (merger) => {
|
|
360
|
-
return (...objects) => {
|
|
361
|
-
if (objects.length === 0) {
|
|
362
|
-
throw new Error(`Can't merge zero objects`);
|
|
363
|
-
}
|
|
364
|
-
const ret = {};
|
|
365
|
-
for (let j = 0; j < objects.length; j++) {
|
|
366
|
-
const curObject = objects[j];
|
|
367
|
-
for (const key in curObject) {
|
|
368
|
-
if (has(curObject, key)) {
|
|
369
|
-
ret[key] = merger(ret[key], curObject[key]);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return ret;
|
|
374
|
-
};
|
|
375
|
-
};
|
|
376
|
-
const deepMerge = baseMerge(deep);
|
|
377
|
-
const isNotEmpty = (s) => s.length > 0;
|
|
378
|
-
const fromHtml = (html, scope) => {
|
|
379
|
-
const doc = scope || document;
|
|
380
|
-
const div = doc.createElement("div");
|
|
381
|
-
div.innerHTML = html;
|
|
382
|
-
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
383
|
-
const message = "HTML does not have a single root node";
|
|
384
|
-
console.error(message, html);
|
|
385
|
-
throw new Error(message);
|
|
386
|
-
}
|
|
387
|
-
return fromDom(div.childNodes[0]);
|
|
388
|
-
};
|
|
389
|
-
const fromTag = (tag, scope) => {
|
|
390
|
-
const doc = scope || document;
|
|
391
|
-
const node = doc.createElement(tag);
|
|
392
|
-
return fromDom(node);
|
|
393
|
-
};
|
|
394
|
-
const fromText = (text, scope) => {
|
|
395
|
-
const doc = scope || document;
|
|
396
|
-
const node = doc.createTextNode(text);
|
|
397
|
-
return fromDom(node);
|
|
398
|
-
};
|
|
399
|
-
const fromDom = (node) => {
|
|
400
|
-
if (node === null || node === void 0) {
|
|
401
|
-
throw new Error("Node cannot be null or undefined");
|
|
402
|
-
}
|
|
403
|
-
return {
|
|
404
|
-
dom: node
|
|
405
|
-
};
|
|
406
|
-
};
|
|
407
|
-
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
408
|
-
const SugarElement = {
|
|
409
|
-
fromHtml,
|
|
410
|
-
fromTag,
|
|
411
|
-
fromText,
|
|
412
|
-
fromDom,
|
|
413
|
-
fromPoint
|
|
414
|
-
};
|
|
415
|
-
const rawSet = (dom, key, value) => {
|
|
416
|
-
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
417
|
-
dom.setAttribute(key, value + "");
|
|
418
|
-
} else {
|
|
419
|
-
console.error("Invalid call to Attribute.set. Key ", key, ":: Value ", value, ":: Element ", dom);
|
|
420
|
-
throw new Error("Attribute value was not simple");
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
const set = (element, key, value) => {
|
|
424
|
-
rawSet(element.dom, key, value);
|
|
425
|
-
};
|
|
426
|
-
const remove = (element, key) => {
|
|
427
|
-
element.dom.removeAttribute(key);
|
|
428
|
-
};
|
|
429
|
-
var global$3 = tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");
|
|
430
|
-
var global$2 = tinymce.util.Tools.resolve("tinymce.util.URI");
|
|
431
|
-
const option = (name) => (editor) => editor.options.get(name);
|
|
432
|
-
const register$2 = (editor) => {
|
|
433
|
-
const registerOption = editor.options.register;
|
|
434
|
-
registerOption("image_dimensions", {
|
|
435
|
-
processor: "boolean",
|
|
436
|
-
default: true
|
|
437
|
-
});
|
|
438
|
-
registerOption("image_advtab", {
|
|
439
|
-
processor: "boolean",
|
|
440
|
-
default: false
|
|
441
|
-
});
|
|
442
|
-
registerOption("image_uploadtab", {
|
|
443
|
-
processor: "boolean",
|
|
444
|
-
default: true
|
|
445
|
-
});
|
|
446
|
-
registerOption("image_prepend_url", {
|
|
447
|
-
processor: "string",
|
|
448
|
-
default: ""
|
|
449
|
-
});
|
|
450
|
-
registerOption("image_class_list", {
|
|
451
|
-
processor: "object[]"
|
|
452
|
-
});
|
|
453
|
-
registerOption("image_description", {
|
|
454
|
-
processor: "boolean",
|
|
455
|
-
default: true
|
|
456
|
-
});
|
|
457
|
-
registerOption("image_title", {
|
|
458
|
-
processor: "boolean",
|
|
459
|
-
default: false
|
|
460
|
-
});
|
|
461
|
-
registerOption("image_caption", {
|
|
462
|
-
processor: "boolean",
|
|
463
|
-
default: false
|
|
464
|
-
});
|
|
465
|
-
registerOption("image_list", {
|
|
466
|
-
processor: (value) => {
|
|
467
|
-
const valid = value === false || isString(value) || isArrayOf(value, isObject) || isFunction(value);
|
|
468
|
-
return valid ? { value, valid } : { valid: false, message: "Must be false, a string, an array or a function." };
|
|
469
|
-
},
|
|
470
|
-
default: false
|
|
471
|
-
});
|
|
472
|
-
};
|
|
473
|
-
const hasDimensions = option("image_dimensions");
|
|
474
|
-
const hasAdvTab = option("image_advtab");
|
|
475
|
-
const hasUploadTab = option("image_uploadtab");
|
|
476
|
-
const getPrependUrl = option("image_prepend_url");
|
|
477
|
-
const getClassList = option("image_class_list");
|
|
478
|
-
const hasDescription = option("image_description");
|
|
479
|
-
const hasImageTitle = option("image_title");
|
|
480
|
-
const hasImageCaption = option("image_caption");
|
|
481
|
-
const getImageList = option("image_list");
|
|
482
|
-
const showAccessibilityOptions = option("a11y_advanced_options");
|
|
483
|
-
const isAutomaticUploadsEnabled = option("automatic_uploads");
|
|
484
|
-
const hasUploadUrl = (editor) => isNotEmpty(editor.options.get("images_upload_url"));
|
|
485
|
-
const hasUploadHandler = (editor) => isNonNullable(editor.options.get("images_upload_handler"));
|
|
486
|
-
const parseIntAndGetMax = (val1, val2) => Math.max(parseInt(val1, 10), parseInt(val2, 10));
|
|
487
|
-
const getImageSize = (url) => new Promise((callback) => {
|
|
488
|
-
const img = document.createElement("img");
|
|
489
|
-
const done = (dimensions) => {
|
|
490
|
-
if (img.parentNode) {
|
|
491
|
-
img.parentNode.removeChild(img);
|
|
492
|
-
}
|
|
493
|
-
callback(dimensions);
|
|
494
|
-
};
|
|
495
|
-
img.addEventListener("load", () => {
|
|
496
|
-
const width = parseIntAndGetMax(img.width, img.clientWidth);
|
|
497
|
-
const height = parseIntAndGetMax(img.height, img.clientHeight);
|
|
498
|
-
const dimensions = { width, height };
|
|
499
|
-
done(Promise.resolve(dimensions));
|
|
500
|
-
});
|
|
501
|
-
img.addEventListener("error", () => {
|
|
502
|
-
done(Promise.reject(`Failed to get image dimensions for: ${url}`));
|
|
503
|
-
});
|
|
504
|
-
const style = img.style;
|
|
505
|
-
style.visibility = "hidden";
|
|
506
|
-
style.position = "fixed";
|
|
507
|
-
style.bottom = style.left = "0px";
|
|
508
|
-
style.width = style.height = "auto";
|
|
509
|
-
document.body.appendChild(img);
|
|
510
|
-
img.src = url;
|
|
511
|
-
});
|
|
512
|
-
const removePixelSuffix = (value) => {
|
|
513
|
-
if (value) {
|
|
514
|
-
value = value.replace(/px$/, "");
|
|
515
|
-
}
|
|
516
|
-
return value;
|
|
517
|
-
};
|
|
518
|
-
const addPixelSuffix = (value) => {
|
|
519
|
-
if (value.length > 0 && /^[0-9]+$/.test(value)) {
|
|
520
|
-
value += "px";
|
|
521
|
-
}
|
|
522
|
-
return value;
|
|
523
|
-
};
|
|
524
|
-
const mergeMargins = (css) => {
|
|
525
|
-
if (css.margin) {
|
|
526
|
-
const splitMargin = String(css.margin).split(" ");
|
|
527
|
-
switch (splitMargin.length) {
|
|
528
|
-
case 1:
|
|
529
|
-
css["margin-top"] = css["margin-top"] || splitMargin[0];
|
|
530
|
-
css["margin-right"] = css["margin-right"] || splitMargin[0];
|
|
531
|
-
css["margin-bottom"] = css["margin-bottom"] || splitMargin[0];
|
|
532
|
-
css["margin-left"] = css["margin-left"] || splitMargin[0];
|
|
533
|
-
break;
|
|
534
|
-
case 2:
|
|
535
|
-
css["margin-top"] = css["margin-top"] || splitMargin[0];
|
|
536
|
-
css["margin-right"] = css["margin-right"] || splitMargin[1];
|
|
537
|
-
css["margin-bottom"] = css["margin-bottom"] || splitMargin[0];
|
|
538
|
-
css["margin-left"] = css["margin-left"] || splitMargin[1];
|
|
539
|
-
break;
|
|
540
|
-
case 3:
|
|
541
|
-
css["margin-top"] = css["margin-top"] || splitMargin[0];
|
|
542
|
-
css["margin-right"] = css["margin-right"] || splitMargin[1];
|
|
543
|
-
css["margin-bottom"] = css["margin-bottom"] || splitMargin[2];
|
|
544
|
-
css["margin-left"] = css["margin-left"] || splitMargin[1];
|
|
545
|
-
break;
|
|
546
|
-
case 4:
|
|
547
|
-
css["margin-top"] = css["margin-top"] || splitMargin[0];
|
|
548
|
-
css["margin-right"] = css["margin-right"] || splitMargin[1];
|
|
549
|
-
css["margin-bottom"] = css["margin-bottom"] || splitMargin[2];
|
|
550
|
-
css["margin-left"] = css["margin-left"] || splitMargin[3];
|
|
551
|
-
}
|
|
552
|
-
delete css.margin;
|
|
553
|
-
}
|
|
554
|
-
return css;
|
|
555
|
-
};
|
|
556
|
-
const createImageList = (editor, callback) => {
|
|
557
|
-
const imageList = getImageList(editor);
|
|
558
|
-
if (isString(imageList)) {
|
|
559
|
-
fetch(imageList).then((res) => {
|
|
560
|
-
if (res.ok) {
|
|
561
|
-
res.json().then(callback);
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
} else if (isFunction(imageList)) {
|
|
565
|
-
imageList(callback);
|
|
566
|
-
} else {
|
|
567
|
-
callback(imageList);
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
const waitLoadImage = (editor, data, imgElm) => {
|
|
571
|
-
const selectImage = () => {
|
|
572
|
-
imgElm.onload = imgElm.onerror = null;
|
|
573
|
-
if (editor.selection) {
|
|
574
|
-
editor.selection.select(imgElm);
|
|
575
|
-
editor.nodeChanged();
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
imgElm.onload = () => {
|
|
579
|
-
if (!data.width && !data.height && hasDimensions(editor)) {
|
|
580
|
-
editor.dom.setAttribs(imgElm, {
|
|
581
|
-
width: String(imgElm.clientWidth),
|
|
582
|
-
height: String(imgElm.clientHeight)
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
selectImage();
|
|
586
|
-
};
|
|
587
|
-
imgElm.onerror = selectImage;
|
|
588
|
-
};
|
|
589
|
-
const blobToDataUri = (blob) => new Promise((resolve, reject) => {
|
|
590
|
-
const reader = new FileReader();
|
|
591
|
-
reader.onload = () => {
|
|
592
|
-
resolve(reader.result);
|
|
593
|
-
};
|
|
594
|
-
reader.onerror = () => {
|
|
595
|
-
reject(reader.error?.message);
|
|
596
|
-
};
|
|
597
|
-
reader.readAsDataURL(blob);
|
|
598
|
-
});
|
|
599
|
-
const isPlaceholderImage = (imgElm) => imgElm.nodeName === "IMG" && (imgElm.hasAttribute("data-mce-object") || imgElm.hasAttribute("data-mce-placeholder"));
|
|
600
|
-
const isSafeImageUrl = (editor, src) => {
|
|
601
|
-
const getOption = editor.options.get;
|
|
602
|
-
return global$2.isDomSafe(src, "img", {
|
|
603
|
-
allow_html_data_urls: getOption("allow_html_data_urls"),
|
|
604
|
-
allow_script_urls: getOption("allow_script_urls"),
|
|
605
|
-
allow_svg_data_urls: getOption("allow_svg_data_urls")
|
|
606
|
-
});
|
|
607
|
-
};
|
|
608
|
-
const DOM = global$3.DOM;
|
|
609
|
-
const getHspace = (image2) => {
|
|
610
|
-
if (image2.style.marginLeft && image2.style.marginRight && image2.style.marginLeft === image2.style.marginRight) {
|
|
611
|
-
return removePixelSuffix(image2.style.marginLeft);
|
|
612
|
-
} else {
|
|
613
|
-
return "";
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
|
-
const getVspace = (image2) => {
|
|
617
|
-
if (image2.style.marginTop && image2.style.marginBottom && image2.style.marginTop === image2.style.marginBottom) {
|
|
618
|
-
return removePixelSuffix(image2.style.marginTop);
|
|
619
|
-
} else {
|
|
620
|
-
return "";
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
const getBorder = (image2) => {
|
|
624
|
-
if (image2.style.borderWidth) {
|
|
625
|
-
return removePixelSuffix(image2.style.borderWidth);
|
|
626
|
-
} else {
|
|
627
|
-
return "";
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
const getAttrib = (image2, name) => {
|
|
631
|
-
if (image2.hasAttribute(name)) {
|
|
632
|
-
return image2.getAttribute(name) ?? "";
|
|
633
|
-
} else {
|
|
634
|
-
return "";
|
|
635
|
-
}
|
|
636
|
-
};
|
|
637
|
-
const hasCaption = (image2) => image2.parentNode !== null && image2.parentNode.nodeName === "FIGURE";
|
|
638
|
-
const updateAttrib = (image2, name, value) => {
|
|
639
|
-
if (value === "" || value === null) {
|
|
640
|
-
image2.removeAttribute(name);
|
|
641
|
-
} else {
|
|
642
|
-
image2.setAttribute(name, value);
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
const wrapInFigure = (image2) => {
|
|
646
|
-
const figureElm = DOM.create("figure", { class: "image" });
|
|
647
|
-
DOM.insertAfter(figureElm, image2);
|
|
648
|
-
figureElm.appendChild(image2);
|
|
649
|
-
figureElm.appendChild(DOM.create("figcaption", { contentEditable: "true" }, "Caption"));
|
|
650
|
-
figureElm.contentEditable = "false";
|
|
651
|
-
};
|
|
652
|
-
const removeFigure = (image2) => {
|
|
653
|
-
const figureElm = image2.parentNode;
|
|
654
|
-
if (isNonNullable(figureElm)) {
|
|
655
|
-
DOM.insertAfter(image2, figureElm);
|
|
656
|
-
DOM.remove(figureElm);
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
const toggleCaption = (image2) => {
|
|
660
|
-
if (hasCaption(image2)) {
|
|
661
|
-
removeFigure(image2);
|
|
662
|
-
} else {
|
|
663
|
-
wrapInFigure(image2);
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
const normalizeStyle = (image2, normalizeCss2) => {
|
|
667
|
-
const attrValue = image2.getAttribute("style");
|
|
668
|
-
const value = normalizeCss2(attrValue !== null ? attrValue : "");
|
|
669
|
-
if (value.length > 0) {
|
|
670
|
-
image2.setAttribute("style", value);
|
|
671
|
-
image2.setAttribute("data-mce-style", value);
|
|
672
|
-
} else {
|
|
673
|
-
image2.removeAttribute("style");
|
|
674
|
-
}
|
|
675
|
-
};
|
|
676
|
-
const setSize = (name, normalizeCss2) => (image2, name2, value) => {
|
|
677
|
-
const styles = image2.style;
|
|
678
|
-
if (styles[name2]) {
|
|
679
|
-
styles[name2] = addPixelSuffix(value);
|
|
680
|
-
normalizeStyle(image2, normalizeCss2);
|
|
681
|
-
} else {
|
|
682
|
-
updateAttrib(image2, name2, value);
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
const getSize = (image2, name) => {
|
|
686
|
-
if (image2.style[name]) {
|
|
687
|
-
return removePixelSuffix(image2.style[name]);
|
|
688
|
-
} else {
|
|
689
|
-
return getAttrib(image2, name);
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
const setHspace = (image2, value) => {
|
|
693
|
-
const pxValue = addPixelSuffix(value);
|
|
694
|
-
image2.style.marginLeft = pxValue;
|
|
695
|
-
image2.style.marginRight = pxValue;
|
|
696
|
-
};
|
|
697
|
-
const setVspace = (image2, value) => {
|
|
698
|
-
const pxValue = addPixelSuffix(value);
|
|
699
|
-
image2.style.marginTop = pxValue;
|
|
700
|
-
image2.style.marginBottom = pxValue;
|
|
701
|
-
};
|
|
702
|
-
const setBorder = (image2, value) => {
|
|
703
|
-
const pxValue = addPixelSuffix(value);
|
|
704
|
-
image2.style.borderWidth = pxValue;
|
|
705
|
-
};
|
|
706
|
-
const setBorderStyle = (image2, value) => {
|
|
707
|
-
image2.style.borderStyle = value;
|
|
708
|
-
};
|
|
709
|
-
const getBorderStyle = (image2) => image2.style.borderStyle ?? "";
|
|
710
|
-
const isFigure = (elm) => isNonNullable(elm) && elm.nodeName === "FIGURE";
|
|
711
|
-
const isImage = (elm) => elm.nodeName === "IMG";
|
|
712
|
-
const getIsDecorative = (image2) => {
|
|
713
|
-
const alt = DOM.getAttrib(image2, "alt");
|
|
714
|
-
const role = DOM.getAttrib(image2, "role");
|
|
715
|
-
const hasAlt = image2.hasAttribute("alt");
|
|
716
|
-
return hasAlt && alt.length === 0 || role === "presentation" || role === "none";
|
|
717
|
-
};
|
|
718
|
-
const getAlt = (image2) => {
|
|
719
|
-
if (getIsDecorative(image2)) {
|
|
720
|
-
return "";
|
|
721
|
-
} else {
|
|
722
|
-
return getAttrib(image2, "alt");
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
const defaultData = () => ({
|
|
726
|
-
src: "",
|
|
727
|
-
alt: "",
|
|
728
|
-
title: "",
|
|
729
|
-
width: "",
|
|
730
|
-
height: "",
|
|
731
|
-
class: "",
|
|
732
|
-
style: "",
|
|
733
|
-
caption: false,
|
|
734
|
-
hspace: "",
|
|
735
|
-
vspace: "",
|
|
736
|
-
border: "",
|
|
737
|
-
borderStyle: "",
|
|
738
|
-
isDecorative: false
|
|
739
|
-
});
|
|
740
|
-
const getStyleValue = (normalizeCss2, data) => {
|
|
741
|
-
const image2 = document.createElement("img");
|
|
742
|
-
updateAttrib(image2, "style", data.style);
|
|
743
|
-
if (getHspace(image2) || data.hspace !== "") {
|
|
744
|
-
setHspace(image2, data.hspace);
|
|
745
|
-
}
|
|
746
|
-
if (getVspace(image2) || data.vspace !== "") {
|
|
747
|
-
setVspace(image2, data.vspace);
|
|
748
|
-
}
|
|
749
|
-
if (getBorder(image2) || data.border !== "") {
|
|
750
|
-
setBorder(image2, data.border);
|
|
751
|
-
}
|
|
752
|
-
if (getBorderStyle(image2) || data.borderStyle !== "") {
|
|
753
|
-
setBorderStyle(image2, data.borderStyle);
|
|
754
|
-
}
|
|
755
|
-
return normalizeCss2(image2.getAttribute("style") ?? "");
|
|
756
|
-
};
|
|
757
|
-
const create = (normalizeCss2, data) => {
|
|
758
|
-
const image2 = document.createElement("img");
|
|
759
|
-
write(normalizeCss2, { ...data, caption: false }, image2);
|
|
760
|
-
setAlt(image2, data.alt, data.isDecorative);
|
|
761
|
-
if (data.caption) {
|
|
762
|
-
const figure = DOM.create("figure", { class: "image" });
|
|
763
|
-
figure.appendChild(image2);
|
|
764
|
-
figure.appendChild(DOM.create("figcaption", { contentEditable: "true" }, "Caption"));
|
|
765
|
-
figure.contentEditable = "false";
|
|
766
|
-
return figure;
|
|
767
|
-
} else {
|
|
768
|
-
return image2;
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
const read = (normalizeCss2, image2) => ({
|
|
772
|
-
src: getAttrib(image2, "src"),
|
|
773
|
-
alt: getAlt(image2),
|
|
774
|
-
title: getAttrib(image2, "title"),
|
|
775
|
-
width: getSize(image2, "width"),
|
|
776
|
-
height: getSize(image2, "height"),
|
|
777
|
-
class: getAttrib(image2, "class"),
|
|
778
|
-
style: normalizeCss2(getAttrib(image2, "style")),
|
|
779
|
-
caption: hasCaption(image2),
|
|
780
|
-
hspace: getHspace(image2),
|
|
781
|
-
vspace: getVspace(image2),
|
|
782
|
-
border: getBorder(image2),
|
|
783
|
-
borderStyle: getBorderStyle(image2),
|
|
784
|
-
isDecorative: getIsDecorative(image2)
|
|
785
|
-
});
|
|
786
|
-
const updateProp = (image2, oldData, newData, name, set2) => {
|
|
787
|
-
if (newData[name] !== oldData[name]) {
|
|
788
|
-
set2(image2, name, String(newData[name]));
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
const setAlt = (image2, alt, isDecorative) => {
|
|
792
|
-
if (isDecorative) {
|
|
793
|
-
DOM.setAttrib(image2, "role", "presentation");
|
|
794
|
-
const sugarImage = SugarElement.fromDom(image2);
|
|
795
|
-
set(sugarImage, "alt", "");
|
|
796
|
-
} else {
|
|
797
|
-
if (isNull(alt)) {
|
|
798
|
-
const sugarImage = SugarElement.fromDom(image2);
|
|
799
|
-
remove(sugarImage, "alt");
|
|
800
|
-
} else {
|
|
801
|
-
const sugarImage = SugarElement.fromDom(image2);
|
|
802
|
-
set(sugarImage, "alt", alt);
|
|
803
|
-
}
|
|
804
|
-
if (DOM.getAttrib(image2, "role") === "presentation") {
|
|
805
|
-
DOM.setAttrib(image2, "role", "");
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
};
|
|
809
|
-
const updateAlt = (image2, oldData, newData) => {
|
|
810
|
-
if (newData.alt !== oldData.alt || newData.isDecorative !== oldData.isDecorative) {
|
|
811
|
-
setAlt(image2, newData.alt, newData.isDecorative);
|
|
812
|
-
}
|
|
813
|
-
};
|
|
814
|
-
const normalized = (set2, normalizeCss2) => (image2, name, value) => {
|
|
815
|
-
set2(image2, value);
|
|
816
|
-
normalizeStyle(image2, normalizeCss2);
|
|
817
|
-
};
|
|
818
|
-
const write = (normalizeCss2, newData, image2) => {
|
|
819
|
-
const oldData = read(normalizeCss2, image2);
|
|
820
|
-
updateProp(image2, oldData, newData, "caption", (image3, _name, _value) => toggleCaption(image3));
|
|
821
|
-
updateProp(image2, oldData, newData, "src", updateAttrib);
|
|
822
|
-
updateProp(image2, oldData, newData, "title", updateAttrib);
|
|
823
|
-
updateProp(image2, oldData, newData, "width", setSize("width", normalizeCss2));
|
|
824
|
-
updateProp(image2, oldData, newData, "height", setSize("height", normalizeCss2));
|
|
825
|
-
updateProp(image2, oldData, newData, "class", updateAttrib);
|
|
826
|
-
updateProp(image2, oldData, newData, "style", normalized((image3, value) => updateAttrib(image3, "style", value), normalizeCss2));
|
|
827
|
-
updateProp(image2, oldData, newData, "hspace", normalized(setHspace, normalizeCss2));
|
|
828
|
-
updateProp(image2, oldData, newData, "vspace", normalized(setVspace, normalizeCss2));
|
|
829
|
-
updateProp(image2, oldData, newData, "border", normalized(setBorder, normalizeCss2));
|
|
830
|
-
updateProp(image2, oldData, newData, "borderStyle", normalized(setBorderStyle, normalizeCss2));
|
|
831
|
-
updateAlt(image2, oldData, newData);
|
|
832
|
-
};
|
|
833
|
-
const normalizeCss$1 = (editor, cssText) => {
|
|
834
|
-
const css = editor.dom.styles.parse(cssText);
|
|
835
|
-
const mergedCss = mergeMargins(css);
|
|
836
|
-
const compressed = editor.dom.styles.parse(editor.dom.styles.serialize(mergedCss));
|
|
837
|
-
return editor.dom.styles.serialize(compressed);
|
|
838
|
-
};
|
|
839
|
-
const getSelectedImage = (editor) => {
|
|
840
|
-
const imgElm = editor.selection.getNode();
|
|
841
|
-
const figureElm = editor.dom.getParent(imgElm, "figure.image");
|
|
842
|
-
if (figureElm) {
|
|
843
|
-
return editor.dom.select("img", figureElm)[0];
|
|
844
|
-
}
|
|
845
|
-
if (imgElm && (imgElm.nodeName !== "IMG" || isPlaceholderImage(imgElm))) {
|
|
846
|
-
return null;
|
|
847
|
-
}
|
|
848
|
-
return imgElm;
|
|
849
|
-
};
|
|
850
|
-
const splitTextBlock = (editor, figure) => {
|
|
851
|
-
const dom = editor.dom;
|
|
852
|
-
const textBlockElements = filter(editor.schema.getTextBlockElements(), (_, parentElm) => !editor.schema.isValidChild(parentElm, "figure"));
|
|
853
|
-
const textBlock = dom.getParent(figure.parentNode, (node) => hasNonNullableKey(textBlockElements, node.nodeName), editor.getBody());
|
|
854
|
-
if (textBlock) {
|
|
855
|
-
return dom.split(textBlock, figure) ?? figure;
|
|
856
|
-
} else {
|
|
857
|
-
return figure;
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
const readImageDataFromSelection = (editor) => {
|
|
861
|
-
const image2 = getSelectedImage(editor);
|
|
862
|
-
return image2 ? read((css) => normalizeCss$1(editor, css), image2) : defaultData();
|
|
863
|
-
};
|
|
864
|
-
const insertImageAtCaret = (editor, data) => {
|
|
865
|
-
const elm = create((css) => normalizeCss$1(editor, css), data);
|
|
866
|
-
editor.dom.setAttrib(elm, "data-mce-id", "__mcenew");
|
|
867
|
-
editor.focus();
|
|
868
|
-
editor.insertContent(elm.outerHTML);
|
|
869
|
-
const insertedElm = editor.dom.select('*[data-mce-id="__mcenew"]')[0];
|
|
870
|
-
editor.dom.setAttrib(insertedElm, "data-mce-id", null);
|
|
871
|
-
if (isFigure(insertedElm)) {
|
|
872
|
-
const figure = splitTextBlock(editor, insertedElm);
|
|
873
|
-
editor.selection.select(figure);
|
|
874
|
-
} else {
|
|
875
|
-
editor.selection.select(insertedElm);
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
const syncSrcAttr = (editor, image2) => {
|
|
879
|
-
editor.dom.setAttrib(image2, "src", image2.getAttribute("src"));
|
|
880
|
-
};
|
|
881
|
-
const deleteImage = (editor, image2) => {
|
|
882
|
-
if (image2) {
|
|
883
|
-
const elm = editor.dom.is(image2.parentNode, "figure.image") ? image2.parentNode : image2;
|
|
884
|
-
editor.dom.remove(elm);
|
|
885
|
-
editor.focus();
|
|
886
|
-
editor.nodeChanged();
|
|
887
|
-
if (editor.dom.isEmpty(editor.getBody())) {
|
|
888
|
-
editor.setContent("");
|
|
889
|
-
editor.selection.setCursorLocation();
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
};
|
|
893
|
-
const writeImageDataToSelection = (editor, data) => {
|
|
894
|
-
const image2 = getSelectedImage(editor);
|
|
895
|
-
if (image2) {
|
|
896
|
-
write((css) => normalizeCss$1(editor, css), data, image2);
|
|
897
|
-
syncSrcAttr(editor, image2);
|
|
898
|
-
if (isFigure(image2.parentNode)) {
|
|
899
|
-
editor.dom.setStyle(image2, "float", "");
|
|
900
|
-
const figure = image2.parentNode;
|
|
901
|
-
splitTextBlock(editor, figure);
|
|
902
|
-
editor.selection.select(image2.parentNode);
|
|
903
|
-
} else {
|
|
904
|
-
editor.selection.select(image2);
|
|
905
|
-
waitLoadImage(editor, data, image2);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
const sanitizeImageData = (editor, data) => {
|
|
910
|
-
const src = data.src;
|
|
911
|
-
return {
|
|
912
|
-
...data,
|
|
913
|
-
src: isSafeImageUrl(editor, src) ? src : ""
|
|
914
|
-
};
|
|
915
|
-
};
|
|
916
|
-
const insertOrUpdateImage = (editor, partialData) => {
|
|
917
|
-
const image2 = getSelectedImage(editor);
|
|
918
|
-
if (image2) {
|
|
919
|
-
const selectedImageData = read((css) => normalizeCss$1(editor, css), image2);
|
|
920
|
-
const data = { ...selectedImageData, ...partialData };
|
|
921
|
-
const sanitizedData = sanitizeImageData(editor, data);
|
|
922
|
-
if (data.src) {
|
|
923
|
-
writeImageDataToSelection(editor, sanitizedData);
|
|
924
|
-
} else {
|
|
925
|
-
deleteImage(editor, image2);
|
|
926
|
-
}
|
|
927
|
-
} else if (partialData.src) {
|
|
928
|
-
insertImageAtCaret(editor, { ...defaultData(), ...partialData });
|
|
929
|
-
}
|
|
930
|
-
};
|
|
931
|
-
var global$1 = tinymce.util.Tools.resolve("tinymce.util.ImageUploader");
|
|
932
|
-
var global = tinymce.util.Tools.resolve("tinymce.util.Tools");
|
|
933
|
-
const getValue = (item) => isString(item.value) ? item.value : "";
|
|
934
|
-
const getText = (item) => {
|
|
935
|
-
if (isString(item.text)) {
|
|
936
|
-
return item.text;
|
|
937
|
-
} else if (isString(item.title)) {
|
|
938
|
-
return item.title;
|
|
939
|
-
} else {
|
|
940
|
-
return "";
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
const sanitizeList = (list, extractValue) => {
|
|
944
|
-
const out = [];
|
|
945
|
-
global.each(list, (item) => {
|
|
946
|
-
const text = getText(item);
|
|
947
|
-
if (item.menu !== void 0) {
|
|
948
|
-
const items = sanitizeList(item.menu, extractValue);
|
|
949
|
-
out.push({ text, items });
|
|
950
|
-
} else {
|
|
951
|
-
const value = extractValue(item);
|
|
952
|
-
out.push({ text, value });
|
|
953
|
-
}
|
|
954
|
-
});
|
|
955
|
-
return out;
|
|
956
|
-
};
|
|
957
|
-
const sanitizer = (extractor = getValue) => (list) => {
|
|
958
|
-
if (list) {
|
|
959
|
-
return Optional.from(list).map((list2) => sanitizeList(list2, extractor));
|
|
960
|
-
} else {
|
|
961
|
-
return Optional.none();
|
|
962
|
-
}
|
|
963
|
-
};
|
|
964
|
-
const sanitize = (list) => sanitizer(getValue)(list);
|
|
965
|
-
const isGroup = (item) => has(item, "items");
|
|
966
|
-
const findEntryDelegate = (list, value) => findMap(list, (item) => {
|
|
967
|
-
if (isGroup(item)) {
|
|
968
|
-
return findEntryDelegate(item.items, value);
|
|
969
|
-
} else if (item.value === value) {
|
|
970
|
-
return Optional.some(item);
|
|
971
|
-
} else {
|
|
972
|
-
return Optional.none();
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
const findEntry = (optList, value) => optList.bind((list) => findEntryDelegate(list, value));
|
|
976
|
-
const ListUtils = {
|
|
977
|
-
sanitizer,
|
|
978
|
-
sanitize,
|
|
979
|
-
findEntry
|
|
980
|
-
};
|
|
981
|
-
const makeTab$2 = (_info) => ({
|
|
982
|
-
title: "Advanced",
|
|
983
|
-
name: "advanced",
|
|
984
|
-
items: [
|
|
985
|
-
{
|
|
986
|
-
type: "grid",
|
|
987
|
-
columns: 2,
|
|
988
|
-
items: [
|
|
989
|
-
{
|
|
990
|
-
type: "input",
|
|
991
|
-
label: "Vertical space",
|
|
992
|
-
name: "vspace",
|
|
993
|
-
inputMode: "numeric"
|
|
994
|
-
},
|
|
995
|
-
{
|
|
996
|
-
type: "input",
|
|
997
|
-
label: "Horizontal space",
|
|
998
|
-
name: "hspace",
|
|
999
|
-
inputMode: "numeric"
|
|
1000
|
-
},
|
|
1001
|
-
{
|
|
1002
|
-
type: "input",
|
|
1003
|
-
label: "Border width",
|
|
1004
|
-
name: "border",
|
|
1005
|
-
inputMode: "numeric"
|
|
1006
|
-
},
|
|
1007
|
-
{
|
|
1008
|
-
type: "listbox",
|
|
1009
|
-
name: "borderstyle",
|
|
1010
|
-
label: "Border style",
|
|
1011
|
-
items: [
|
|
1012
|
-
{ text: "Select...", value: "" },
|
|
1013
|
-
{ text: "Solid", value: "solid" },
|
|
1014
|
-
{ text: "Dotted", value: "dotted" },
|
|
1015
|
-
{ text: "Dashed", value: "dashed" },
|
|
1016
|
-
{ text: "Double", value: "double" },
|
|
1017
|
-
{ text: "Groove", value: "groove" },
|
|
1018
|
-
{ text: "Ridge", value: "ridge" },
|
|
1019
|
-
{ text: "Inset", value: "inset" },
|
|
1020
|
-
{ text: "Outset", value: "outset" },
|
|
1021
|
-
{ text: "None", value: "none" },
|
|
1022
|
-
{ text: "Hidden", value: "hidden" }
|
|
1023
|
-
]
|
|
1024
|
-
}
|
|
1025
|
-
]
|
|
1026
|
-
}
|
|
1027
|
-
]
|
|
1028
|
-
});
|
|
1029
|
-
const AdvTab = {
|
|
1030
|
-
makeTab: makeTab$2
|
|
1031
|
-
};
|
|
1032
|
-
const collect = (editor) => {
|
|
1033
|
-
const urlListSanitizer = ListUtils.sanitizer((item) => editor.convertURL(item.value || item.url || "", "src"));
|
|
1034
|
-
const futureImageList = new Promise((completer) => {
|
|
1035
|
-
createImageList(editor, (imageList) => {
|
|
1036
|
-
completer(urlListSanitizer(imageList).map((items) => flatten([
|
|
1037
|
-
[{ text: "None", value: "" }],
|
|
1038
|
-
items
|
|
1039
|
-
])));
|
|
1040
|
-
});
|
|
1041
|
-
});
|
|
1042
|
-
const alertErr = (message, callback) => {
|
|
1043
|
-
editor.windowManager.alert(message, callback);
|
|
1044
|
-
};
|
|
1045
|
-
const classList = ListUtils.sanitize(getClassList(editor));
|
|
1046
|
-
const hasAdvTab$1 = hasAdvTab(editor);
|
|
1047
|
-
const hasUploadTab$1 = hasUploadTab(editor);
|
|
1048
|
-
const hasUploadUrl$1 = hasUploadUrl(editor);
|
|
1049
|
-
const hasUploadHandler$1 = hasUploadHandler(editor);
|
|
1050
|
-
const image2 = readImageDataFromSelection(editor);
|
|
1051
|
-
const hasDescription$1 = hasDescription(editor);
|
|
1052
|
-
const hasImageTitle$1 = hasImageTitle(editor);
|
|
1053
|
-
const hasDimensions$1 = hasDimensions(editor);
|
|
1054
|
-
const hasImageCaption$1 = hasImageCaption(editor);
|
|
1055
|
-
const hasAccessibilityOptions = showAccessibilityOptions(editor);
|
|
1056
|
-
const automaticUploads = isAutomaticUploadsEnabled(editor);
|
|
1057
|
-
const prependURL = Optional.some(getPrependUrl(editor)).filter((preUrl) => isString(preUrl) && preUrl.length > 0);
|
|
1058
|
-
return futureImageList.then((imageList) => ({
|
|
1059
|
-
alertErr,
|
|
1060
|
-
image: image2,
|
|
1061
|
-
imageList,
|
|
1062
|
-
classList,
|
|
1063
|
-
hasAdvTab: hasAdvTab$1,
|
|
1064
|
-
hasUploadTab: hasUploadTab$1,
|
|
1065
|
-
hasUploadUrl: hasUploadUrl$1,
|
|
1066
|
-
hasUploadHandler: hasUploadHandler$1,
|
|
1067
|
-
hasDescription: hasDescription$1,
|
|
1068
|
-
hasImageTitle: hasImageTitle$1,
|
|
1069
|
-
hasDimensions: hasDimensions$1,
|
|
1070
|
-
hasImageCaption: hasImageCaption$1,
|
|
1071
|
-
prependURL,
|
|
1072
|
-
hasAccessibilityOptions,
|
|
1073
|
-
automaticUploads
|
|
1074
|
-
}));
|
|
1075
|
-
};
|
|
1076
|
-
const makeItems = (info) => {
|
|
1077
|
-
const imageUrl = {
|
|
1078
|
-
name: "src",
|
|
1079
|
-
type: "urlinput",
|
|
1080
|
-
filetype: "image",
|
|
1081
|
-
label: "Source",
|
|
1082
|
-
picker_text: "Browse files"
|
|
1083
|
-
};
|
|
1084
|
-
const imageList = info.imageList.map((items) => ({
|
|
1085
|
-
name: "images",
|
|
1086
|
-
type: "listbox",
|
|
1087
|
-
label: "Image list",
|
|
1088
|
-
items
|
|
1089
|
-
}));
|
|
1090
|
-
const imageDescription = {
|
|
1091
|
-
name: "alt",
|
|
1092
|
-
type: "input",
|
|
1093
|
-
label: "Alternative description",
|
|
1094
|
-
enabled: !(info.hasAccessibilityOptions && info.image.isDecorative)
|
|
1095
|
-
};
|
|
1096
|
-
const imageTitle = {
|
|
1097
|
-
name: "title",
|
|
1098
|
-
type: "input",
|
|
1099
|
-
label: "Image title"
|
|
1100
|
-
};
|
|
1101
|
-
const imageDimensions = {
|
|
1102
|
-
name: "dimensions",
|
|
1103
|
-
type: "sizeinput"
|
|
1104
|
-
};
|
|
1105
|
-
const isDecorative = {
|
|
1106
|
-
type: "label",
|
|
1107
|
-
label: "Accessibility",
|
|
1108
|
-
items: [{
|
|
1109
|
-
name: "isDecorative",
|
|
1110
|
-
type: "checkbox",
|
|
1111
|
-
label: "Image is decorative"
|
|
1112
|
-
}]
|
|
1113
|
-
};
|
|
1114
|
-
const classList = info.classList.map((items) => ({
|
|
1115
|
-
name: "classes",
|
|
1116
|
-
type: "listbox",
|
|
1117
|
-
label: "Class",
|
|
1118
|
-
items
|
|
1119
|
-
}));
|
|
1120
|
-
const caption = {
|
|
1121
|
-
type: "label",
|
|
1122
|
-
label: "Caption",
|
|
1123
|
-
items: [
|
|
1124
|
-
{
|
|
1125
|
-
type: "checkbox",
|
|
1126
|
-
name: "caption",
|
|
1127
|
-
label: "Show caption"
|
|
1128
|
-
}
|
|
1129
|
-
]
|
|
1130
|
-
};
|
|
1131
|
-
const getDialogContainerType = (useColumns) => useColumns ? { type: "grid", columns: 2 } : { type: "panel" };
|
|
1132
|
-
return flatten([
|
|
1133
|
-
[imageUrl],
|
|
1134
|
-
imageList.toArray(),
|
|
1135
|
-
info.hasAccessibilityOptions && info.hasDescription ? [isDecorative] : [],
|
|
1136
|
-
info.hasDescription ? [imageDescription] : [],
|
|
1137
|
-
info.hasImageTitle ? [imageTitle] : [],
|
|
1138
|
-
info.hasDimensions ? [imageDimensions] : [],
|
|
1139
|
-
[{
|
|
1140
|
-
...getDialogContainerType(info.classList.isSome() && info.hasImageCaption),
|
|
1141
|
-
items: flatten([
|
|
1142
|
-
classList.toArray(),
|
|
1143
|
-
info.hasImageCaption ? [caption] : []
|
|
1144
|
-
])
|
|
1145
|
-
}]
|
|
1146
|
-
]);
|
|
1147
|
-
};
|
|
1148
|
-
const makeTab$1 = (info) => ({
|
|
1149
|
-
title: "General",
|
|
1150
|
-
name: "general",
|
|
1151
|
-
items: makeItems(info)
|
|
1152
|
-
});
|
|
1153
|
-
const MainTab = {
|
|
1154
|
-
makeTab: makeTab$1,
|
|
1155
|
-
makeItems
|
|
1156
|
-
};
|
|
1157
|
-
const makeTab = (_info, onInvalidFiles) => {
|
|
1158
|
-
const items = [
|
|
1159
|
-
{
|
|
1160
|
-
type: "dropzone",
|
|
1161
|
-
name: "fileinput",
|
|
1162
|
-
onInvalidFiles
|
|
1163
|
-
}
|
|
1164
|
-
];
|
|
1165
|
-
return {
|
|
1166
|
-
title: "Upload",
|
|
1167
|
-
name: "upload",
|
|
1168
|
-
items
|
|
1169
|
-
};
|
|
1170
|
-
};
|
|
1171
|
-
const UploadTab = {
|
|
1172
|
-
makeTab
|
|
1173
|
-
};
|
|
1174
|
-
const createState = (info) => ({
|
|
1175
|
-
prevImage: ListUtils.findEntry(info.imageList, info.image.src),
|
|
1176
|
-
prevAlt: info.image.alt,
|
|
1177
|
-
open: true
|
|
1178
|
-
});
|
|
1179
|
-
const fromImageData = (image2) => ({
|
|
1180
|
-
src: {
|
|
1181
|
-
value: image2.src,
|
|
1182
|
-
meta: {}
|
|
1183
|
-
},
|
|
1184
|
-
images: image2.src,
|
|
1185
|
-
alt: image2.alt,
|
|
1186
|
-
title: image2.title,
|
|
1187
|
-
dimensions: {
|
|
1188
|
-
width: image2.width,
|
|
1189
|
-
height: image2.height
|
|
1190
|
-
},
|
|
1191
|
-
classes: image2.class,
|
|
1192
|
-
caption: image2.caption,
|
|
1193
|
-
style: image2.style,
|
|
1194
|
-
vspace: image2.vspace,
|
|
1195
|
-
border: image2.border,
|
|
1196
|
-
hspace: image2.hspace,
|
|
1197
|
-
borderstyle: image2.borderStyle,
|
|
1198
|
-
fileinput: [],
|
|
1199
|
-
isDecorative: image2.isDecorative
|
|
1200
|
-
});
|
|
1201
|
-
const toImageData = (data, removeEmptyAlt) => ({
|
|
1202
|
-
src: data.src.value,
|
|
1203
|
-
alt: (data.alt === null || data.alt.length === 0) && removeEmptyAlt ? null : data.alt,
|
|
1204
|
-
title: data.title,
|
|
1205
|
-
width: data.dimensions.width,
|
|
1206
|
-
height: data.dimensions.height,
|
|
1207
|
-
class: data.classes,
|
|
1208
|
-
style: data.style,
|
|
1209
|
-
caption: data.caption,
|
|
1210
|
-
hspace: data.hspace,
|
|
1211
|
-
vspace: data.vspace,
|
|
1212
|
-
border: data.border,
|
|
1213
|
-
borderStyle: data.borderstyle,
|
|
1214
|
-
isDecorative: data.isDecorative
|
|
1215
|
-
});
|
|
1216
|
-
const addPrependUrl2 = (info, srcURL) => {
|
|
1217
|
-
if (!/^(?:[a-zA-Z]+:)?\/\//.test(srcURL)) {
|
|
1218
|
-
return info.prependURL.bind((prependUrl) => {
|
|
1219
|
-
if (srcURL.substring(0, prependUrl.length) !== prependUrl) {
|
|
1220
|
-
return Optional.some(prependUrl + srcURL);
|
|
1221
|
-
}
|
|
1222
|
-
return Optional.none();
|
|
1223
|
-
});
|
|
1224
|
-
}
|
|
1225
|
-
return Optional.none();
|
|
1226
|
-
};
|
|
1227
|
-
const addPrependUrl = (info, api) => {
|
|
1228
|
-
const data = api.getData();
|
|
1229
|
-
addPrependUrl2(info, data.src.value).each((srcURL) => {
|
|
1230
|
-
api.setData({ src: { value: srcURL, meta: data.src.meta } });
|
|
1231
|
-
});
|
|
1232
|
-
};
|
|
1233
|
-
const formFillFromMeta2 = (info, data, meta) => {
|
|
1234
|
-
if (info.hasDescription && isString(meta.alt)) {
|
|
1235
|
-
data.alt = meta.alt;
|
|
1236
|
-
}
|
|
1237
|
-
if (info.hasAccessibilityOptions) {
|
|
1238
|
-
data.isDecorative = meta.isDecorative || data.isDecorative || false;
|
|
1239
|
-
}
|
|
1240
|
-
if (info.hasImageTitle && isString(meta.title)) {
|
|
1241
|
-
data.title = meta.title;
|
|
1242
|
-
}
|
|
1243
|
-
if (info.hasDimensions) {
|
|
1244
|
-
if (isString(meta.width)) {
|
|
1245
|
-
data.dimensions.width = meta.width;
|
|
1246
|
-
}
|
|
1247
|
-
if (isString(meta.height)) {
|
|
1248
|
-
data.dimensions.height = meta.height;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
if (isString(meta.class)) {
|
|
1252
|
-
ListUtils.findEntry(info.classList, meta.class).each((entry) => {
|
|
1253
|
-
data.classes = entry.value;
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
if (info.hasImageCaption) {
|
|
1257
|
-
if (isBoolean(meta.caption)) {
|
|
1258
|
-
data.caption = meta.caption;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
if (info.hasAdvTab) {
|
|
1262
|
-
if (isString(meta.style)) {
|
|
1263
|
-
data.style = meta.style;
|
|
1264
|
-
}
|
|
1265
|
-
if (isString(meta.vspace)) {
|
|
1266
|
-
data.vspace = meta.vspace;
|
|
1267
|
-
}
|
|
1268
|
-
if (isString(meta.border)) {
|
|
1269
|
-
data.border = meta.border;
|
|
1270
|
-
}
|
|
1271
|
-
if (isString(meta.hspace)) {
|
|
1272
|
-
data.hspace = meta.hspace;
|
|
1273
|
-
}
|
|
1274
|
-
if (isString(meta.borderstyle)) {
|
|
1275
|
-
data.borderstyle = meta.borderstyle;
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
const formFillFromMeta = (info, api) => {
|
|
1280
|
-
const data = api.getData();
|
|
1281
|
-
const meta = data.src.meta;
|
|
1282
|
-
if (meta !== void 0) {
|
|
1283
|
-
const newData = deepMerge({}, data);
|
|
1284
|
-
formFillFromMeta2(info, newData, meta);
|
|
1285
|
-
api.setData(newData);
|
|
1286
|
-
}
|
|
1287
|
-
};
|
|
1288
|
-
const calculateImageSize = (helpers, info, state, api) => {
|
|
1289
|
-
const data = api.getData();
|
|
1290
|
-
const url = data.src.value;
|
|
1291
|
-
const meta = data.src.meta || {};
|
|
1292
|
-
if (!meta.width && !meta.height && info.hasDimensions) {
|
|
1293
|
-
if (isNotEmpty(url)) {
|
|
1294
|
-
helpers.imageSize(url).then((size) => {
|
|
1295
|
-
if (state.open) {
|
|
1296
|
-
api.setData({ dimensions: size });
|
|
1297
|
-
}
|
|
1298
|
-
}).catch((e) => console.error(e));
|
|
1299
|
-
} else {
|
|
1300
|
-
api.setData({ dimensions: { width: "", height: "" } });
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
};
|
|
1304
|
-
const updateImagesDropdown = (info, state, api) => {
|
|
1305
|
-
const data = api.getData();
|
|
1306
|
-
const image2 = ListUtils.findEntry(info.imageList, data.src.value);
|
|
1307
|
-
state.prevImage = image2;
|
|
1308
|
-
api.setData({ images: image2.map((entry) => entry.value).getOr("") });
|
|
1309
|
-
};
|
|
1310
|
-
const changeSrc = (helpers, info, state, api) => {
|
|
1311
|
-
addPrependUrl(info, api);
|
|
1312
|
-
formFillFromMeta(info, api);
|
|
1313
|
-
calculateImageSize(helpers, info, state, api);
|
|
1314
|
-
updateImagesDropdown(info, state, api);
|
|
1315
|
-
};
|
|
1316
|
-
const changeImages = (helpers, info, state, api) => {
|
|
1317
|
-
const data = api.getData();
|
|
1318
|
-
const image2 = ListUtils.findEntry(info.imageList, data.images);
|
|
1319
|
-
image2.each((img) => {
|
|
1320
|
-
const updateAlt2 = data.alt === "" || state.prevImage.map((image3) => image3.text === data.alt).getOr(false);
|
|
1321
|
-
if (updateAlt2) {
|
|
1322
|
-
if (img.value === "") {
|
|
1323
|
-
api.setData({ src: img, alt: state.prevAlt });
|
|
1324
|
-
} else {
|
|
1325
|
-
api.setData({ src: img, alt: img.text });
|
|
1326
|
-
}
|
|
1327
|
-
} else {
|
|
1328
|
-
api.setData({ src: img });
|
|
1329
|
-
}
|
|
1330
|
-
});
|
|
1331
|
-
state.prevImage = image2;
|
|
1332
|
-
changeSrc(helpers, info, state, api);
|
|
1333
|
-
};
|
|
1334
|
-
const changeFileInput = (helpers, info, state, api) => {
|
|
1335
|
-
const data = api.getData();
|
|
1336
|
-
api.block("Uploading image");
|
|
1337
|
-
head(data.fileinput).fold(() => {
|
|
1338
|
-
api.unblock();
|
|
1339
|
-
}, (file) => {
|
|
1340
|
-
const blobUri = URL.createObjectURL(file);
|
|
1341
|
-
const finalize = () => {
|
|
1342
|
-
api.unblock();
|
|
1343
|
-
URL.revokeObjectURL(blobUri);
|
|
1344
|
-
};
|
|
1345
|
-
const updateSrcAndSwitchTab = (url) => {
|
|
1346
|
-
api.setData({ src: { value: url, meta: {} } });
|
|
1347
|
-
api.showTab("general");
|
|
1348
|
-
changeSrc(helpers, info, state, api);
|
|
1349
|
-
api.focus("src");
|
|
1350
|
-
};
|
|
1351
|
-
blobToDataUri(file).then((dataUrl) => {
|
|
1352
|
-
const blobInfo = helpers.createBlobCache(file, blobUri, dataUrl);
|
|
1353
|
-
if (info.automaticUploads) {
|
|
1354
|
-
helpers.uploadImage(blobInfo).then((result) => {
|
|
1355
|
-
updateSrcAndSwitchTab(result.url);
|
|
1356
|
-
finalize();
|
|
1357
|
-
}).catch((err) => {
|
|
1358
|
-
finalize();
|
|
1359
|
-
info.alertErr(err, () => {
|
|
1360
|
-
api.focus("fileinput");
|
|
1361
|
-
});
|
|
1362
|
-
});
|
|
1363
|
-
} else {
|
|
1364
|
-
helpers.addToBlobCache(blobInfo);
|
|
1365
|
-
updateSrcAndSwitchTab(blobInfo.blobUri());
|
|
1366
|
-
api.unblock();
|
|
1367
|
-
}
|
|
1368
|
-
});
|
|
1369
|
-
});
|
|
1370
|
-
};
|
|
1371
|
-
const changeHandler = (helpers, info, state) => (api, evt) => {
|
|
1372
|
-
if (evt.name === "src") {
|
|
1373
|
-
changeSrc(helpers, info, state, api);
|
|
1374
|
-
} else if (evt.name === "images") {
|
|
1375
|
-
changeImages(helpers, info, state, api);
|
|
1376
|
-
} else if (evt.name === "alt") {
|
|
1377
|
-
state.prevAlt = api.getData().alt;
|
|
1378
|
-
} else if (evt.name === "fileinput") {
|
|
1379
|
-
changeFileInput(helpers, info, state, api);
|
|
1380
|
-
} else if (evt.name === "isDecorative") {
|
|
1381
|
-
api.setEnabled("alt", !api.getData().isDecorative);
|
|
1382
|
-
}
|
|
1383
|
-
};
|
|
1384
|
-
const closeHandler = (state) => () => {
|
|
1385
|
-
state.open = false;
|
|
1386
|
-
};
|
|
1387
|
-
const makeDialogBody = (info) => {
|
|
1388
|
-
if (info.hasAdvTab || info.hasUploadUrl || info.hasUploadHandler) {
|
|
1389
|
-
const tabPanel = {
|
|
1390
|
-
type: "tabpanel",
|
|
1391
|
-
tabs: flatten([
|
|
1392
|
-
[MainTab.makeTab(info)],
|
|
1393
|
-
info.hasAdvTab ? [AdvTab.makeTab(info)] : [],
|
|
1394
|
-
info.hasUploadTab && (info.hasUploadUrl || info.hasUploadHandler) ? [UploadTab.makeTab(info, () => new Promise((r) => info.alertErr("Selected images do not have allowed extensions", r)))] : []
|
|
1395
|
-
])
|
|
1396
|
-
};
|
|
1397
|
-
return tabPanel;
|
|
1398
|
-
} else {
|
|
1399
|
-
const panel = {
|
|
1400
|
-
type: "panel",
|
|
1401
|
-
items: MainTab.makeItems(info)
|
|
1402
|
-
};
|
|
1403
|
-
return panel;
|
|
1404
|
-
}
|
|
1405
|
-
};
|
|
1406
|
-
const submitHandler = (editor, info, helpers) => (api) => {
|
|
1407
|
-
const data = deepMerge(fromImageData(info.image), api.getData());
|
|
1408
|
-
const finalData = {
|
|
1409
|
-
...data,
|
|
1410
|
-
style: getStyleValue(helpers.normalizeCss, toImageData(data, false))
|
|
1411
|
-
};
|
|
1412
|
-
editor.execCommand("mceUpdateImage", false, toImageData(finalData, info.hasAccessibilityOptions));
|
|
1413
|
-
editor.editorUpload.uploadImagesAuto();
|
|
1414
|
-
api.close();
|
|
1415
|
-
};
|
|
1416
|
-
const imageSize = (editor) => (url) => {
|
|
1417
|
-
if (!isSafeImageUrl(editor, url)) {
|
|
1418
|
-
return Promise.resolve({ width: "", height: "" });
|
|
1419
|
-
} else {
|
|
1420
|
-
return getImageSize(editor.documentBaseURI.toAbsolute(url)).then((dimensions) => ({
|
|
1421
|
-
width: String(dimensions.width),
|
|
1422
|
-
height: String(dimensions.height)
|
|
1423
|
-
}));
|
|
1424
|
-
}
|
|
1425
|
-
};
|
|
1426
|
-
const createBlobCache = (editor) => (file, blobUri, dataUrl) => editor.editorUpload.blobCache.create({
|
|
1427
|
-
blob: file,
|
|
1428
|
-
blobUri,
|
|
1429
|
-
name: file.name?.replace(/\.[^\.]+$/, ""),
|
|
1430
|
-
filename: file.name,
|
|
1431
|
-
base64: dataUrl.split(",")[1]
|
|
1432
|
-
});
|
|
1433
|
-
const addToBlobCache = (editor) => (blobInfo) => {
|
|
1434
|
-
editor.editorUpload.blobCache.add(blobInfo);
|
|
1435
|
-
};
|
|
1436
|
-
const normalizeCss = (editor) => (cssText) => normalizeCss$1(editor, cssText);
|
|
1437
|
-
const parseStyle = (editor) => (cssText) => editor.dom.parseStyle(cssText);
|
|
1438
|
-
const serializeStyle = (editor) => (stylesArg, name) => editor.dom.serializeStyle(stylesArg, name);
|
|
1439
|
-
const uploadImage = (editor) => (blobInfo) => global$1(editor).upload([blobInfo], false).then((results) => {
|
|
1440
|
-
if (results.length === 0) {
|
|
1441
|
-
return Promise.reject("Failed to upload image");
|
|
1442
|
-
} else if (results[0].status === false) {
|
|
1443
|
-
return Promise.reject(results[0].error?.message);
|
|
1444
|
-
} else {
|
|
1445
|
-
return results[0];
|
|
1446
|
-
}
|
|
1447
|
-
});
|
|
1448
|
-
const Dialog = (editor) => {
|
|
1449
|
-
const helpers = {
|
|
1450
|
-
imageSize: imageSize(editor),
|
|
1451
|
-
addToBlobCache: addToBlobCache(editor),
|
|
1452
|
-
createBlobCache: createBlobCache(editor),
|
|
1453
|
-
normalizeCss: normalizeCss(editor),
|
|
1454
|
-
parseStyle: parseStyle(editor),
|
|
1455
|
-
serializeStyle: serializeStyle(editor),
|
|
1456
|
-
uploadImage: uploadImage(editor)
|
|
1457
|
-
};
|
|
1458
|
-
const open = () => {
|
|
1459
|
-
collect(editor).then((info) => {
|
|
1460
|
-
const state = createState(info);
|
|
1461
|
-
return {
|
|
1462
|
-
title: "Insert/Edit Image",
|
|
1463
|
-
size: "normal",
|
|
1464
|
-
body: makeDialogBody(info),
|
|
1465
|
-
buttons: [
|
|
1466
|
-
{
|
|
1467
|
-
type: "cancel",
|
|
1468
|
-
name: "cancel",
|
|
1469
|
-
text: "Cancel"
|
|
1470
|
-
},
|
|
1471
|
-
{
|
|
1472
|
-
type: "submit",
|
|
1473
|
-
name: "save",
|
|
1474
|
-
text: "Save",
|
|
1475
|
-
primary: true
|
|
1476
|
-
}
|
|
1477
|
-
],
|
|
1478
|
-
initialData: fromImageData(info.image),
|
|
1479
|
-
onSubmit: submitHandler(editor, info, helpers),
|
|
1480
|
-
onChange: changeHandler(helpers, info, state),
|
|
1481
|
-
onClose: closeHandler(state)
|
|
1482
|
-
};
|
|
1483
|
-
}).then(editor.windowManager.open);
|
|
1484
|
-
};
|
|
1485
|
-
return {
|
|
1486
|
-
open
|
|
1487
|
-
};
|
|
1488
|
-
};
|
|
1489
|
-
const register$1 = (editor) => {
|
|
1490
|
-
editor.addCommand("mceImage", Dialog(editor).open);
|
|
1491
|
-
editor.addCommand("mceUpdateImage", (_ui, data) => {
|
|
1492
|
-
editor.undoManager.transact(() => insertOrUpdateImage(editor, data));
|
|
1493
|
-
});
|
|
1494
|
-
};
|
|
1495
|
-
const hasImageClass = (node) => {
|
|
1496
|
-
const className = node.attr("class");
|
|
1497
|
-
return isNonNullable(className) && /\bimage\b/.test(className);
|
|
1498
|
-
};
|
|
1499
|
-
const toggleContentEditableState = (state) => (nodes) => {
|
|
1500
|
-
let i = nodes.length;
|
|
1501
|
-
const toggleContentEditable = (node) => {
|
|
1502
|
-
node.attr("contenteditable", state ? "true" : null);
|
|
1503
|
-
};
|
|
1504
|
-
while (i--) {
|
|
1505
|
-
const node = nodes[i];
|
|
1506
|
-
if (hasImageClass(node)) {
|
|
1507
|
-
node.attr("contenteditable", state ? "false" : null);
|
|
1508
|
-
global.each(node.getAll("figcaption"), toggleContentEditable);
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
};
|
|
1512
|
-
const setup = (editor) => {
|
|
1513
|
-
editor.on("PreInit", () => {
|
|
1514
|
-
editor.parser.addNodeFilter("figure", toggleContentEditableState(true));
|
|
1515
|
-
editor.serializer.addNodeFilter("figure", toggleContentEditableState(false));
|
|
1516
|
-
});
|
|
1517
|
-
};
|
|
1518
|
-
const onSetupEditable = (editor) => (api) => {
|
|
1519
|
-
const nodeChanged = () => {
|
|
1520
|
-
api.setEnabled(editor.selection.isEditable());
|
|
1521
|
-
};
|
|
1522
|
-
editor.on("NodeChange", nodeChanged);
|
|
1523
|
-
nodeChanged();
|
|
1524
|
-
return () => {
|
|
1525
|
-
editor.off("NodeChange", nodeChanged);
|
|
1526
|
-
};
|
|
1527
|
-
};
|
|
1528
|
-
const register = (editor) => {
|
|
1529
|
-
editor.ui.registry.addToggleButton("image", {
|
|
1530
|
-
icon: "image",
|
|
1531
|
-
tooltip: "Insert/edit image",
|
|
1532
|
-
onAction: Dialog(editor).open,
|
|
1533
|
-
onSetup: (buttonApi) => {
|
|
1534
|
-
buttonApi.setActive(isNonNullable(getSelectedImage(editor)));
|
|
1535
|
-
const unbindSelectorChanged = editor.selection.selectorChangedWithUnbind("img:not([data-mce-object]):not([data-mce-placeholder]),figure.image", buttonApi.setActive).unbind;
|
|
1536
|
-
const unbindEditable = onSetupEditable(editor)(buttonApi);
|
|
1537
|
-
return () => {
|
|
1538
|
-
unbindSelectorChanged();
|
|
1539
|
-
unbindEditable();
|
|
1540
|
-
};
|
|
1541
|
-
}
|
|
1542
|
-
});
|
|
1543
|
-
editor.ui.registry.addMenuItem("image", {
|
|
1544
|
-
icon: "image",
|
|
1545
|
-
text: "Image...",
|
|
1546
|
-
onAction: Dialog(editor).open,
|
|
1547
|
-
onSetup: onSetupEditable(editor)
|
|
1548
|
-
});
|
|
1549
|
-
editor.ui.registry.addContextMenu("image", {
|
|
1550
|
-
update: (element) => editor.selection.isEditable() && (isFigure(element) || isImage(element) && !isPlaceholderImage(element)) ? ["image"] : []
|
|
1551
|
-
});
|
|
1552
|
-
};
|
|
1553
|
-
var Plugin = () => {
|
|
1554
|
-
global$4.add("image", (editor) => {
|
|
1555
|
-
register$2(editor);
|
|
1556
|
-
setup(editor);
|
|
1557
|
-
register(editor);
|
|
1558
|
-
register$1(editor);
|
|
1559
|
-
});
|
|
1560
|
-
};
|
|
1561
|
-
Plugin();
|
|
1562
|
-
})();
|
|
1563
|
-
return plugin;
|
|
1564
|
-
}
|
|
1565
|
-
var hasRequiredImage;
|
|
1566
|
-
function requireImage() {
|
|
1567
|
-
if (hasRequiredImage) return image;
|
|
1568
|
-
hasRequiredImage = 1;
|
|
1569
|
-
requirePlugin();
|
|
1570
|
-
return image;
|
|
1571
|
-
}
|
|
1572
|
-
var imageExports = requireImage();
|
|
1573
|
-
const index = /* @__PURE__ */ getDefaultExportFromCjs(imageExports);
|
|
1574
|
-
const index$1 = /* @__PURE__ */ _mergeNamespaces({
|
|
1575
|
-
__proto__: null,
|
|
1576
|
-
default: index
|
|
1577
|
-
}, [imageExports]);
|
|
1578
|
-
export {
|
|
1579
|
-
index$1 as i
|
|
1580
|
-
};
|
|
1581
|
-
//# sourceMappingURL=index-ukywSRmc.js.map
|