administrate 1.0.0.beta2 → 1.0.0.beta3
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 +4 -4
- data/app/assets/builds/administrate/application.js +329 -299
- data/app/assets/builds/administrate/application.js.map +4 -4
- data/app/views/administrate/application/new.html.erb +1 -1
- data/app/views/fields/rich_text/_form.html.erb +16 -0
- data/docs/customizing_dashboards.md +5 -5
- data/docs/customizing_page_views.md +22 -0
- data/docs/guides/scoping_has_many_relations.md +2 -2
- data/lib/administrate/field/associative.rb +1 -1
- data/lib/administrate/version.rb +1 -1
- data/lib/generators/administrate/views/index_generator.rb +4 -0
- metadata +8 -8
@@ -8203,7 +8203,7 @@
|
|
8203
8203
|
window.$ = import_jquery.default;
|
8204
8204
|
|
8205
8205
|
// node_modules/trix/dist/trix.esm.min.js
|
8206
|
-
var t = "2.1.
|
8206
|
+
var t = "2.1.4";
|
8207
8207
|
var e = "[data-trix-attachment]";
|
8208
8208
|
var i = { preview: { presentation: "gallery", caption: { name: true, size: true } }, file: { caption: { size: true } } };
|
8209
8209
|
var n = { default: { tagName: "div", parse: false }, quote: { tagName: "blockquote", nestable: true }, heading1: { tagName: "h1", terminal: true, breakOnReturn: true, group: false }, code: { tagName: "pre", terminal: true, htmlAttributes: ["language"], text: { plaintext: true } }, bulletList: { tagName: "ul", parse: false }, bullet: { tagName: "li", listAttribute: "bulletList", group: false, nestable: true, test(t2) {
|
@@ -8990,8 +8990,78 @@
|
|
8990
8990
|
return this.getChildViews()[0].createContainerElement(t2);
|
8991
8991
|
}
|
8992
8992
|
};
|
8993
|
-
var
|
8994
|
-
var re =
|
8993
|
+
var ne = "style href src width height language class".split(" ");
|
8994
|
+
var re = "javascript:".split(" ");
|
8995
|
+
var oe = "script iframe form noscript".split(" ");
|
8996
|
+
var se = class extends H {
|
8997
|
+
static setHTML(t2, e2) {
|
8998
|
+
const i2 = new this(e2).sanitize(), n2 = i2.getHTML ? i2.getHTML() : i2.outerHTML;
|
8999
|
+
t2.innerHTML = n2;
|
9000
|
+
}
|
9001
|
+
static sanitize(t2, e2) {
|
9002
|
+
const i2 = new this(t2, e2);
|
9003
|
+
return i2.sanitize(), i2;
|
9004
|
+
}
|
9005
|
+
constructor(t2) {
|
9006
|
+
let { allowedAttributes: e2, forbiddenProtocols: i2, forbiddenElements: n2 } = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
9007
|
+
super(...arguments), this.allowedAttributes = e2 || ne, this.forbiddenProtocols = i2 || re, this.forbiddenElements = n2 || oe, this.body = ae(t2);
|
9008
|
+
}
|
9009
|
+
sanitize() {
|
9010
|
+
return this.sanitizeElements(), this.normalizeListElementNesting();
|
9011
|
+
}
|
9012
|
+
getHTML() {
|
9013
|
+
return this.body.innerHTML;
|
9014
|
+
}
|
9015
|
+
getBody() {
|
9016
|
+
return this.body;
|
9017
|
+
}
|
9018
|
+
sanitizeElements() {
|
9019
|
+
const t2 = R(this.body), e2 = [];
|
9020
|
+
for (; t2.nextNode(); ) {
|
9021
|
+
const i2 = t2.currentNode;
|
9022
|
+
switch (i2.nodeType) {
|
9023
|
+
case Node.ELEMENT_NODE:
|
9024
|
+
this.elementIsRemovable(i2) ? e2.push(i2) : this.sanitizeElement(i2);
|
9025
|
+
break;
|
9026
|
+
case Node.COMMENT_NODE:
|
9027
|
+
e2.push(i2);
|
9028
|
+
}
|
9029
|
+
}
|
9030
|
+
return e2.forEach((t3) => k(t3)), this.body;
|
9031
|
+
}
|
9032
|
+
sanitizeElement(t2) {
|
9033
|
+
return t2.hasAttribute("href") && this.forbiddenProtocols.includes(t2.protocol) && t2.removeAttribute("href"), Array.from(t2.attributes).forEach((e2) => {
|
9034
|
+
let { name: i2 } = e2;
|
9035
|
+
this.allowedAttributes.includes(i2) || 0 === i2.indexOf("data-trix") || t2.removeAttribute(i2);
|
9036
|
+
}), t2;
|
9037
|
+
}
|
9038
|
+
normalizeListElementNesting() {
|
9039
|
+
return Array.from(this.body.querySelectorAll("ul,ol")).forEach((t2) => {
|
9040
|
+
const e2 = t2.previousElementSibling;
|
9041
|
+
e2 && "li" === E(e2) && e2.appendChild(t2);
|
9042
|
+
}), this.body;
|
9043
|
+
}
|
9044
|
+
elementIsRemovable(t2) {
|
9045
|
+
if ((null == t2 ? void 0 : t2.nodeType) === Node.ELEMENT_NODE)
|
9046
|
+
return this.elementIsForbidden(t2) || this.elementIsntSerializable(t2);
|
9047
|
+
}
|
9048
|
+
elementIsForbidden(t2) {
|
9049
|
+
return this.forbiddenElements.includes(E(t2));
|
9050
|
+
}
|
9051
|
+
elementIsntSerializable(t2) {
|
9052
|
+
return "false" === t2.getAttribute("data-trix-serialize") && !I(t2);
|
9053
|
+
}
|
9054
|
+
};
|
9055
|
+
var ae = function() {
|
9056
|
+
let t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "";
|
9057
|
+
t2 = t2.replace(/<\/html[^>]*>[^]*$/i, "</html>");
|
9058
|
+
const e2 = document.implementation.createHTMLDocument("");
|
9059
|
+
return e2.documentElement.innerHTML = t2, Array.from(e2.head.querySelectorAll("style")).forEach((t3) => {
|
9060
|
+
e2.body.appendChild(t3);
|
9061
|
+
}), e2.body;
|
9062
|
+
};
|
9063
|
+
var { css: le } = V;
|
9064
|
+
var ce = class extends ee {
|
8995
9065
|
constructor() {
|
8996
9066
|
super(...arguments), this.attachment = this.object, this.attachment.uploadProgressDelegate = this, this.attachmentPiece = this.options.piece;
|
8997
9067
|
}
|
@@ -9001,39 +9071,39 @@
|
|
9001
9071
|
createNodes() {
|
9002
9072
|
let t2;
|
9003
9073
|
const e2 = t2 = S({ tagName: "figure", className: this.getClassName(), data: this.getData(), editable: false }), i2 = this.getHref();
|
9004
|
-
return i2 && (t2 = S({ tagName: "a", editable: false, attributes: { href: i2, tabindex: -1 } }), e2.appendChild(t2)), this.attachment.hasContent() ? t2
|
9074
|
+
return i2 && (t2 = S({ tagName: "a", editable: false, attributes: { href: i2, tabindex: -1 } }), e2.appendChild(t2)), this.attachment.hasContent() ? se.setHTML(t2, this.attachment.getContent()) : this.createContentNodes().forEach((e3) => {
|
9005
9075
|
t2.appendChild(e3);
|
9006
|
-
}), t2.appendChild(this.createCaptionElement()), this.attachment.isPending() && (this.progressElement = S({ tagName: "progress", attributes: { class:
|
9076
|
+
}), t2.appendChild(this.createCaptionElement()), this.attachment.isPending() && (this.progressElement = S({ tagName: "progress", attributes: { class: le.attachmentProgress, value: this.attachment.getUploadProgress(), max: 100 }, data: { trixMutable: true, trixStoreKey: ["progressElement", this.attachment.id].join("/") } }), e2.appendChild(this.progressElement)), [ue("left"), e2, ue("right")];
|
9007
9077
|
}
|
9008
9078
|
createCaptionElement() {
|
9009
|
-
const t2 = S({ tagName: "figcaption", className:
|
9079
|
+
const t2 = S({ tagName: "figcaption", className: le.attachmentCaption }), e2 = this.attachmentPiece.getCaption();
|
9010
9080
|
if (e2)
|
9011
|
-
t2.classList.add("".concat(
|
9081
|
+
t2.classList.add("".concat(le.attachmentCaption, "--edited")), t2.textContent = e2;
|
9012
9082
|
else {
|
9013
9083
|
let e3, i2;
|
9014
9084
|
const n2 = this.getCaptionConfig();
|
9015
9085
|
if (n2.name && (e3 = this.attachment.getFilename()), n2.size && (i2 = this.attachment.getFormattedFilesize()), e3) {
|
9016
|
-
const i3 = S({ tagName: "span", className:
|
9086
|
+
const i3 = S({ tagName: "span", className: le.attachmentName, textContent: e3 });
|
9017
9087
|
t2.appendChild(i3);
|
9018
9088
|
}
|
9019
9089
|
if (i2) {
|
9020
9090
|
e3 && t2.appendChild(document.createTextNode(" "));
|
9021
|
-
const n3 = S({ tagName: "span", className:
|
9091
|
+
const n3 = S({ tagName: "span", className: le.attachmentSize, textContent: i2 });
|
9022
9092
|
t2.appendChild(n3);
|
9023
9093
|
}
|
9024
9094
|
}
|
9025
9095
|
return t2;
|
9026
9096
|
}
|
9027
9097
|
getClassName() {
|
9028
|
-
const t2 = [
|
9029
|
-
return e2 && t2.push("".concat(
|
9098
|
+
const t2 = [le.attachment, "".concat(le.attachment, "--").concat(this.attachment.getType())], e2 = this.attachment.getExtension();
|
9099
|
+
return e2 && t2.push("".concat(le.attachment, "--").concat(e2)), t2.join(" ");
|
9030
9100
|
}
|
9031
9101
|
getData() {
|
9032
9102
|
const t2 = { trixAttachment: JSON.stringify(this.attachment), trixContentType: this.attachment.getContentType(), trixId: this.attachment.id }, { attributes: e2 } = this.attachmentPiece;
|
9033
9103
|
return e2.isEmpty() || (t2.trixAttributes = JSON.stringify(e2)), this.attachment.isPending() && (t2.trixSerialize = false), t2;
|
9034
9104
|
}
|
9035
9105
|
getHref() {
|
9036
|
-
if (!
|
9106
|
+
if (!he(this.attachment.getContent(), "a"))
|
9037
9107
|
return this.attachment.getHref();
|
9038
9108
|
}
|
9039
9109
|
getCaptionConfig() {
|
@@ -9050,12 +9120,12 @@
|
|
9050
9120
|
e2 && (e2.value = t2);
|
9051
9121
|
}
|
9052
9122
|
};
|
9053
|
-
var
|
9054
|
-
var
|
9123
|
+
var ue = (t2) => S({ tagName: "span", textContent: h, data: { trixCursorTarget: t2, trixSerialize: false } });
|
9124
|
+
var he = function(t2, e2) {
|
9055
9125
|
const i2 = S("div");
|
9056
|
-
return i2
|
9126
|
+
return se.setHTML(i2, t2 || ""), i2.querySelector(e2);
|
9057
9127
|
};
|
9058
|
-
var
|
9128
|
+
var de = class extends ce {
|
9059
9129
|
constructor() {
|
9060
9130
|
super(...arguments), this.attachment.previewDelegate = this;
|
9061
9131
|
}
|
@@ -9089,7 +9159,7 @@
|
|
9089
9159
|
return this.refresh(this.image), this.refresh();
|
9090
9160
|
}
|
9091
9161
|
};
|
9092
|
-
var
|
9162
|
+
var ge = class extends ee {
|
9093
9163
|
constructor() {
|
9094
9164
|
super(...arguments), this.piece = this.object, this.attributes = this.piece.getAttributes(), this.textConfig = this.options.textConfig, this.context = this.options.context, this.piece.attachment ? this.attachment = this.piece.attachment : this.string = this.piece.toString();
|
9095
9165
|
}
|
@@ -9111,7 +9181,7 @@
|
|
9111
9181
|
return t2;
|
9112
9182
|
}
|
9113
9183
|
createAttachmentNodes() {
|
9114
|
-
const t2 = this.attachment.isPreviewable() ?
|
9184
|
+
const t2 = this.attachment.isPreviewable() ? de : ce;
|
9115
9185
|
return this.createChildView(t2, this.piece.attachment, { piece: this.piece }).getNodes();
|
9116
9186
|
}
|
9117
9187
|
createStringNodes() {
|
@@ -9169,7 +9239,7 @@
|
|
9169
9239
|
return this.context.isLast && (t2 = t2.replace(/\ $/, d)), t2 = t2.replace(/(\S)\ {3}(\S)/g, "$1 ".concat(d, " $2")).replace(/\ {2}/g, "".concat(d, " ")).replace(/\ {2}/g, " ".concat(d)), (this.context.isFirst || this.context.followsWhitespace) && (t2 = t2.replace(/^\ /, d)), t2;
|
9170
9240
|
}
|
9171
9241
|
};
|
9172
|
-
var
|
9242
|
+
var me = class extends ee {
|
9173
9243
|
constructor() {
|
9174
9244
|
super(...arguments), this.text = this.object, this.textConfig = this.options.textConfig;
|
9175
9245
|
}
|
@@ -9177,8 +9247,8 @@
|
|
9177
9247
|
const t2 = [], e2 = Xt.groupObjects(this.getPieces()), i2 = e2.length - 1;
|
9178
9248
|
for (let r2 = 0; r2 < e2.length; r2++) {
|
9179
9249
|
const o2 = e2[r2], s2 = {};
|
9180
|
-
0 === r2 && (s2.isFirst = true), r2 === i2 && (s2.isLast = true),
|
9181
|
-
const a2 = this.findOrCreateCachedChildView(
|
9250
|
+
0 === r2 && (s2.isFirst = true), r2 === i2 && (s2.isLast = true), pe(n2) && (s2.followsWhitespace = true);
|
9251
|
+
const a2 = this.findOrCreateCachedChildView(ge, o2, { textConfig: this.textConfig, context: s2 });
|
9182
9252
|
t2.push(...Array.from(a2.getNodes() || []));
|
9183
9253
|
var n2 = o2;
|
9184
9254
|
}
|
@@ -9188,9 +9258,9 @@
|
|
9188
9258
|
return Array.from(this.text.getPieces()).filter((t2) => !t2.hasAttribute("blockBreak"));
|
9189
9259
|
}
|
9190
9260
|
};
|
9191
|
-
var
|
9192
|
-
var { css:
|
9193
|
-
var
|
9261
|
+
var pe = (t2) => /\s$/.test(null == t2 ? void 0 : t2.toString());
|
9262
|
+
var { css: fe } = V;
|
9263
|
+
var be = class extends ee {
|
9194
9264
|
constructor() {
|
9195
9265
|
super(...arguments), this.block = this.object, this.attributes = this.block.getAttributes();
|
9196
9266
|
}
|
@@ -9200,7 +9270,7 @@
|
|
9200
9270
|
t2.push(S("br"));
|
9201
9271
|
else {
|
9202
9272
|
var e2;
|
9203
|
-
const i2 = null === (e2 = gt(this.block.getLastAttribute())) || void 0 === e2 ? void 0 : e2.text, n2 = this.findOrCreateCachedChildView(
|
9273
|
+
const i2 = null === (e2 = gt(this.block.getLastAttribute())) || void 0 === e2 ? void 0 : e2.text, n2 = this.findOrCreateCachedChildView(me, this.block.text, { textConfig: i2 });
|
9204
9274
|
t2.push(...Array.from(n2.getNodes() || [])), this.shouldAddExtraNewlineElement() && t2.push(S("br"));
|
9205
9275
|
}
|
9206
9276
|
if (this.attributes.length)
|
@@ -9219,7 +9289,7 @@
|
|
9219
9289
|
const n2 = this.attributes[t2], { tagName: r2, htmlAttributes: o2 = [] } = gt(n2);
|
9220
9290
|
if (0 === t2 && this.block.isRTL() && Object.assign(e2, { dir: "rtl" }), "attachmentGallery" === n2) {
|
9221
9291
|
const t3 = this.block.getBlockBreakPosition();
|
9222
|
-
i2 = "".concat(
|
9292
|
+
i2 = "".concat(fe.attachmentGallery, " ").concat(fe.attachmentGallery, "--").concat(t3);
|
9223
9293
|
}
|
9224
9294
|
return Object.entries(this.block.htmlAttributes).forEach((t3) => {
|
9225
9295
|
let [i3, n3] = t3;
|
@@ -9230,7 +9300,7 @@
|
|
9230
9300
|
return /\n\n$/.test(this.block.toString());
|
9231
9301
|
}
|
9232
9302
|
};
|
9233
|
-
var
|
9303
|
+
var ve = class extends ee {
|
9234
9304
|
static render(t2) {
|
9235
9305
|
const e2 = S("div"), i2 = new this(t2, { element: e2 });
|
9236
9306
|
return i2.render(), i2.sync(), e2;
|
@@ -9245,13 +9315,13 @@
|
|
9245
9315
|
if (this.childViews = [], this.shadowElement = S("div"), !this.document.isEmpty()) {
|
9246
9316
|
const t2 = Xt.groupObjects(this.document.getBlocks(), { asTree: true });
|
9247
9317
|
Array.from(t2).forEach((t3) => {
|
9248
|
-
const e2 = this.findOrCreateCachedChildView(
|
9318
|
+
const e2 = this.findOrCreateCachedChildView(be, t3);
|
9249
9319
|
Array.from(e2.getNodes()).map((t4) => this.shadowElement.appendChild(t4));
|
9250
9320
|
});
|
9251
9321
|
}
|
9252
9322
|
}
|
9253
9323
|
isSynced() {
|
9254
|
-
return
|
9324
|
+
return xe(this.shadowElement, this.element);
|
9255
9325
|
}
|
9256
9326
|
sync() {
|
9257
9327
|
const t2 = this.createDocumentFragmentForSync();
|
@@ -9260,26 +9330,26 @@
|
|
9260
9330
|
return this.element.appendChild(t2), this.didSync();
|
9261
9331
|
}
|
9262
9332
|
didSync() {
|
9263
|
-
return this.elementStore.reset(
|
9333
|
+
return this.elementStore.reset(Ae(this.element)), Rt(() => this.garbageCollectCachedViews());
|
9264
9334
|
}
|
9265
9335
|
createDocumentFragmentForSync() {
|
9266
9336
|
const t2 = document.createDocumentFragment();
|
9267
9337
|
return Array.from(this.shadowElement.childNodes).forEach((e2) => {
|
9268
9338
|
t2.appendChild(e2.cloneNode(true));
|
9269
|
-
}), Array.from(
|
9339
|
+
}), Array.from(Ae(t2)).forEach((t3) => {
|
9270
9340
|
const e2 = this.elementStore.remove(t3);
|
9271
9341
|
e2 && t3.parentNode.replaceChild(e2, t3);
|
9272
9342
|
}), t2;
|
9273
9343
|
}
|
9274
9344
|
};
|
9275
|
-
var
|
9276
|
-
var
|
9277
|
-
var
|
9278
|
-
function
|
9345
|
+
var Ae = (t2) => t2.querySelectorAll("[data-trix-store-key]");
|
9346
|
+
var xe = (t2, e2) => ye(t2.innerHTML) === ye(e2.innerHTML);
|
9347
|
+
var ye = (t2) => t2.replace(/ /g, " ");
|
9348
|
+
function Ce(t2) {
|
9279
9349
|
var e2, i2;
|
9280
9350
|
function n2(e3, i3) {
|
9281
9351
|
try {
|
9282
|
-
var o2 = t2[e3](i3), s2 = o2.value, a2 = s2 instanceof
|
9352
|
+
var o2 = t2[e3](i3), s2 = o2.value, a2 = s2 instanceof ke;
|
9283
9353
|
Promise.resolve(a2 ? s2.v : s2).then(function(i4) {
|
9284
9354
|
if (a2) {
|
9285
9355
|
var l2 = "return" === e3 ? "return" : "next";
|
@@ -9315,13 +9385,13 @@
|
|
9315
9385
|
});
|
9316
9386
|
}, "function" != typeof t2.return && (this.return = void 0);
|
9317
9387
|
}
|
9318
|
-
function
|
9388
|
+
function ke(t2, e2) {
|
9319
9389
|
this.v = t2, this.k = e2;
|
9320
9390
|
}
|
9321
|
-
function
|
9322
|
-
return (e2 =
|
9391
|
+
function Re(t2, e2, i2) {
|
9392
|
+
return (e2 = Ee(e2)) in t2 ? Object.defineProperty(t2, e2, { value: i2, enumerable: true, configurable: true, writable: true }) : t2[e2] = i2, t2;
|
9323
9393
|
}
|
9324
|
-
function
|
9394
|
+
function Ee(t2) {
|
9325
9395
|
var e2 = function(t3, e3) {
|
9326
9396
|
if ("object" != typeof t3 || null === t3)
|
9327
9397
|
return t3;
|
@@ -9336,16 +9406,16 @@
|
|
9336
9406
|
}(t2, "string");
|
9337
9407
|
return "symbol" == typeof e2 ? e2 : String(e2);
|
9338
9408
|
}
|
9339
|
-
|
9409
|
+
Ce.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
9340
9410
|
return this;
|
9341
|
-
},
|
9411
|
+
}, Ce.prototype.next = function(t2) {
|
9342
9412
|
return this._invoke("next", t2);
|
9343
|
-
},
|
9413
|
+
}, Ce.prototype.throw = function(t2) {
|
9344
9414
|
return this._invoke("throw", t2);
|
9345
|
-
},
|
9415
|
+
}, Ce.prototype.return = function(t2) {
|
9346
9416
|
return this._invoke("return", t2);
|
9347
9417
|
};
|
9348
|
-
var
|
9418
|
+
var Se = class extends nt {
|
9349
9419
|
static registerType(t2, e2) {
|
9350
9420
|
e2.type = t2, this.types[t2] = e2;
|
9351
9421
|
}
|
@@ -9419,8 +9489,8 @@
|
|
9419
9489
|
return false;
|
9420
9490
|
}
|
9421
9491
|
};
|
9422
|
-
|
9423
|
-
var
|
9492
|
+
Re(Se, "types", {});
|
9493
|
+
var Le = class extends te {
|
9424
9494
|
constructor(t2) {
|
9425
9495
|
super(...arguments), this.url = t2;
|
9426
9496
|
}
|
@@ -9429,7 +9499,7 @@
|
|
9429
9499
|
e2.onload = () => (e2.width = this.width = e2.naturalWidth, e2.height = this.height = e2.naturalHeight, t2(true, e2)), e2.onerror = () => t2(false), e2.src = this.url;
|
9430
9500
|
}
|
9431
9501
|
};
|
9432
|
-
var
|
9502
|
+
var De = class _De extends nt {
|
9433
9503
|
static attachmentForFile(t2) {
|
9434
9504
|
const e2 = new this(this.attributesForFile(t2));
|
9435
9505
|
return e2.setFile(t2), e2;
|
@@ -9468,7 +9538,7 @@
|
|
9468
9538
|
return null != this.file && !(this.getURL() || this.getHref());
|
9469
9539
|
}
|
9470
9540
|
isPreviewable() {
|
9471
|
-
return this.attributes.has("previewable") ? this.attributes.get("previewable") :
|
9541
|
+
return this.attributes.has("previewable") ? this.attributes.get("previewable") : _De.previewablePattern.test(this.getContentType());
|
9472
9542
|
}
|
9473
9543
|
getType() {
|
9474
9544
|
return this.hasContent() ? "content" : this.isPreviewable() ? "preview" : "file";
|
@@ -9553,17 +9623,17 @@
|
|
9553
9623
|
preload(t2, e2) {
|
9554
9624
|
if (t2 && t2 !== this.getPreviewURL()) {
|
9555
9625
|
this.preloadingURL = t2;
|
9556
|
-
return new
|
9626
|
+
return new Le(t2).then((i2) => {
|
9557
9627
|
let { width: n2, height: r2 } = i2;
|
9558
9628
|
return this.getWidth() && this.getHeight() || this.setAttributes({ width: n2, height: r2 }), this.preloadingURL = null, this.setPreviewURL(t2), null == e2 ? void 0 : e2();
|
9559
9629
|
}).catch(() => (this.preloadingURL = null, null == e2 ? void 0 : e2()));
|
9560
9630
|
}
|
9561
9631
|
}
|
9562
9632
|
};
|
9563
|
-
|
9564
|
-
var
|
9633
|
+
Re(De, "previewablePattern", /^image(\/(gif|png|webp|jpe?g)|$)/);
|
9634
|
+
var we = class _we extends Se {
|
9565
9635
|
static fromJSON(t2) {
|
9566
|
-
return new this(
|
9636
|
+
return new this(De.fromJSON(t2.attachment), t2.attributes);
|
9567
9637
|
}
|
9568
9638
|
constructor(t2) {
|
9569
9639
|
super(...arguments), this.attachment = t2, this.length = 1, this.ensureAttachmentExclusivelyHasAttribute("href"), this.attachment.hasContent() || this.removeProhibitedAttributes();
|
@@ -9572,7 +9642,7 @@
|
|
9572
9642
|
this.hasAttribute(t2) && (this.attachment.hasAttribute(t2) || this.attachment.setAttributes(this.attributes.slice([t2])), this.attributes = this.attributes.remove(t2));
|
9573
9643
|
}
|
9574
9644
|
removeProhibitedAttributes() {
|
9575
|
-
const t2 = this.attributes.slice(
|
9645
|
+
const t2 = this.attributes.slice(_we.permittedAttributes);
|
9576
9646
|
t2.isEqualTo(this.attributes) || (this.attributes = t2);
|
9577
9647
|
}
|
9578
9648
|
getValue() {
|
@@ -9602,8 +9672,8 @@
|
|
9602
9672
|
return JSON.stringify(this.toString());
|
9603
9673
|
}
|
9604
9674
|
};
|
9605
|
-
|
9606
|
-
var
|
9675
|
+
Re(we, "permittedAttributes", ["caption", "presentation"]), Se.registerType("attachment", we);
|
9676
|
+
var Te = class extends Se {
|
9607
9677
|
static fromJSON(t2) {
|
9608
9678
|
return new this(t2.string, t2.attributes);
|
9609
9679
|
}
|
@@ -9638,8 +9708,8 @@
|
|
9638
9708
|
return t2.length > 15 && (t2 = t2.slice(0, 14) + "\u2026"), JSON.stringify(t2.toString());
|
9639
9709
|
}
|
9640
9710
|
};
|
9641
|
-
|
9642
|
-
var
|
9711
|
+
Se.registerType("string", Te);
|
9712
|
+
var Be = class extends nt {
|
9643
9713
|
static box(t2) {
|
9644
9714
|
return t2 instanceof this ? t2 : new this(t2);
|
9645
9715
|
}
|
@@ -9697,8 +9767,8 @@
|
|
9697
9767
|
return new this.constructor(o2);
|
9698
9768
|
}
|
9699
9769
|
splitObjectsAtRange(t2) {
|
9700
|
-
let e2, [i2, n2, r2] = this.splitObjectAtPosition(
|
9701
|
-
return [i2, e2] = new this.constructor(i2).splitObjectAtPosition(
|
9770
|
+
let e2, [i2, n2, r2] = this.splitObjectAtPosition(Pe(t2));
|
9771
|
+
return [i2, e2] = new this.constructor(i2).splitObjectAtPosition(Ie(t2) + r2), [i2, n2, e2 - 1];
|
9702
9772
|
}
|
9703
9773
|
getObjectAtPosition(t2) {
|
9704
9774
|
const { index: e2 } = this.findIndexAndOffsetAtPosition(t2);
|
@@ -9766,13 +9836,13 @@
|
|
9766
9836
|
return this.toArray();
|
9767
9837
|
}
|
9768
9838
|
isEqualTo(t2) {
|
9769
|
-
return super.isEqualTo(...arguments) ||
|
9839
|
+
return super.isEqualTo(...arguments) || Fe(this.objects, null == t2 ? void 0 : t2.objects);
|
9770
9840
|
}
|
9771
9841
|
contentsForInspection() {
|
9772
9842
|
return { objects: "[".concat(this.objects.map((t2) => t2.inspect()).join(", "), "]") };
|
9773
9843
|
}
|
9774
9844
|
};
|
9775
|
-
var
|
9845
|
+
var Fe = function(t2) {
|
9776
9846
|
let e2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [];
|
9777
9847
|
if (t2.length !== e2.length)
|
9778
9848
|
return false;
|
@@ -9783,23 +9853,23 @@
|
|
9783
9853
|
}
|
9784
9854
|
return i2;
|
9785
9855
|
};
|
9786
|
-
var
|
9787
|
-
var
|
9788
|
-
var
|
9856
|
+
var Pe = (t2) => t2[0];
|
9857
|
+
var Ie = (t2) => t2[1];
|
9858
|
+
var Ne = class extends nt {
|
9789
9859
|
static textForAttachmentWithAttributes(t2, e2) {
|
9790
|
-
return new this([new
|
9860
|
+
return new this([new we(t2, e2)]);
|
9791
9861
|
}
|
9792
9862
|
static textForStringWithAttributes(t2, e2) {
|
9793
|
-
return new this([new
|
9863
|
+
return new this([new Te(t2, e2)]);
|
9794
9864
|
}
|
9795
9865
|
static fromJSON(t2) {
|
9796
|
-
return new this(Array.from(t2).map((t3) =>
|
9866
|
+
return new this(Array.from(t2).map((t3) => Se.fromJSON(t3)));
|
9797
9867
|
}
|
9798
9868
|
constructor() {
|
9799
9869
|
let t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [];
|
9800
9870
|
super(...arguments);
|
9801
9871
|
const e2 = t2.filter((t3) => !t3.isEmpty());
|
9802
|
-
this.pieceList = new
|
9872
|
+
this.pieceList = new Be(e2);
|
9803
9873
|
}
|
9804
9874
|
copy() {
|
9805
9875
|
return this.copyWithPieceList(this.pieceList);
|
@@ -9952,12 +10022,12 @@
|
|
9952
10022
|
return "rtl" === this.getDirection();
|
9953
10023
|
}
|
9954
10024
|
};
|
9955
|
-
var
|
10025
|
+
var Oe = class _Oe extends nt {
|
9956
10026
|
static fromJSON(t2) {
|
9957
|
-
return new this(
|
10027
|
+
return new this(Ne.fromJSON(t2.text), t2.attributes, t2.htmlAttributes);
|
9958
10028
|
}
|
9959
10029
|
constructor(t2, e2, i2) {
|
9960
|
-
super(...arguments), this.text =
|
10030
|
+
super(...arguments), this.text = Me(t2 || new Ne()), this.attributes = e2 || [], this.htmlAttributes = i2 || {};
|
9961
10031
|
}
|
9962
10032
|
isEmpty() {
|
9963
10033
|
return this.text.isBlockBreak();
|
@@ -9966,13 +10036,13 @@
|
|
9966
10036
|
return !!super.isEqualTo(t2) || this.text.isEqualTo(null == t2 ? void 0 : t2.text) && rt(this.attributes, null == t2 ? void 0 : t2.attributes) && St(this.htmlAttributes, null == t2 ? void 0 : t2.htmlAttributes);
|
9967
10037
|
}
|
9968
10038
|
copyWithText(t2) {
|
9969
|
-
return new
|
10039
|
+
return new _Oe(t2, this.attributes, this.htmlAttributes);
|
9970
10040
|
}
|
9971
10041
|
copyWithoutText() {
|
9972
10042
|
return this.copyWithText(null);
|
9973
10043
|
}
|
9974
10044
|
copyWithAttributes(t2) {
|
9975
|
-
return new
|
10045
|
+
return new _Oe(this.text, t2, this.htmlAttributes);
|
9976
10046
|
}
|
9977
10047
|
copyWithoutAttributes() {
|
9978
10048
|
return this.copyWithAttributes(null);
|
@@ -9982,22 +10052,22 @@
|
|
9982
10052
|
return e2 ? this.copyWithText(e2) : this.copyWithText(this.text.copyUsingObjectMap(t2));
|
9983
10053
|
}
|
9984
10054
|
addAttribute(t2) {
|
9985
|
-
const e2 = this.attributes.concat(
|
10055
|
+
const e2 = this.attributes.concat(He(t2));
|
9986
10056
|
return this.copyWithAttributes(e2);
|
9987
10057
|
}
|
9988
10058
|
addHTMLAttribute(t2, e2) {
|
9989
10059
|
const i2 = Object.assign({}, this.htmlAttributes, { [t2]: e2 });
|
9990
|
-
return new
|
10060
|
+
return new _Oe(this.text, this.attributes, i2);
|
9991
10061
|
}
|
9992
10062
|
removeAttribute(t2) {
|
9993
|
-
const { listAttribute: e2 } = gt(t2), i2 =
|
10063
|
+
const { listAttribute: e2 } = gt(t2), i2 = _e(_e(this.attributes, t2), e2);
|
9994
10064
|
return this.copyWithAttributes(i2);
|
9995
10065
|
}
|
9996
10066
|
removeLastAttribute() {
|
9997
10067
|
return this.removeAttribute(this.getLastAttribute());
|
9998
10068
|
}
|
9999
10069
|
getLastAttribute() {
|
10000
|
-
return
|
10070
|
+
return ze(this.attributes);
|
10001
10071
|
}
|
10002
10072
|
getAttributes() {
|
10003
10073
|
return this.attributes.slice(0);
|
@@ -10015,7 +10085,7 @@
|
|
10015
10085
|
return this.getAttributeLevel() > 0;
|
10016
10086
|
}
|
10017
10087
|
getLastNestableAttribute() {
|
10018
|
-
return
|
10088
|
+
return ze(this.getNestableAttributes());
|
10019
10089
|
}
|
10020
10090
|
getNestableAttributes() {
|
10021
10091
|
return this.attributes.filter((t2) => gt(t2).nestable);
|
@@ -10030,7 +10100,7 @@
|
|
10030
10100
|
increaseNestingLevel() {
|
10031
10101
|
const t2 = this.getLastNestableAttribute();
|
10032
10102
|
if (t2) {
|
10033
|
-
const e2 = this.attributes.lastIndexOf(t2), i2 = ot(this.attributes, e2 + 1, 0, ...
|
10103
|
+
const e2 = this.attributes.lastIndexOf(t2), i2 = ot(this.attributes, e2 + 1, 0, ...He(t2));
|
10034
10104
|
return this.copyWithAttributes(i2);
|
10035
10105
|
}
|
10036
10106
|
return this;
|
@@ -10085,7 +10155,7 @@
|
|
10085
10155
|
return !this.hasAttributes() && !t2.hasAttributes() && this.getDirection() === t2.getDirection();
|
10086
10156
|
}
|
10087
10157
|
consolidateWith(t2) {
|
10088
|
-
const e2 =
|
10158
|
+
const e2 = Ne.textForStringWithAttributes("\n"), i2 = this.getTextWithoutBlockBreak().appendText(e2);
|
10089
10159
|
return this.copyWithText(i2.appendText(t2.text));
|
10090
10160
|
}
|
10091
10161
|
splitAtOffset(t2) {
|
@@ -10096,7 +10166,7 @@
|
|
10096
10166
|
return this.text.getLength() - 1;
|
10097
10167
|
}
|
10098
10168
|
getTextWithoutBlockBreak() {
|
10099
|
-
return
|
10169
|
+
return qe(this.text) ? this.text.getTextAtRange([0, this.getBlockBreakPosition()]) : this.text.copy();
|
10100
10170
|
}
|
10101
10171
|
canBeGrouped(t2) {
|
10102
10172
|
return this.attributes[t2];
|
@@ -10115,47 +10185,47 @@
|
|
10115
10185
|
})().includes(i2[e2 + 1])) && (this.getDirection() === t2.getDirection() || t2.isEmpty());
|
10116
10186
|
}
|
10117
10187
|
};
|
10118
|
-
var
|
10119
|
-
return t2 =
|
10188
|
+
var Me = function(t2) {
|
10189
|
+
return t2 = je(t2), t2 = Ue(t2);
|
10120
10190
|
};
|
10121
|
-
var
|
10191
|
+
var je = function(t2) {
|
10122
10192
|
let e2 = false;
|
10123
10193
|
const i2 = t2.getPieces();
|
10124
10194
|
let n2 = i2.slice(0, i2.length - 1);
|
10125
10195
|
const r2 = i2[i2.length - 1];
|
10126
|
-
return r2 ? (n2 = n2.map((t3) => t3.isBlockBreak() ? (e2 = true,
|
10196
|
+
return r2 ? (n2 = n2.map((t3) => t3.isBlockBreak() ? (e2 = true, Ve(t3)) : t3), e2 ? new Ne([...n2, r2]) : t2) : t2;
|
10127
10197
|
};
|
10128
|
-
var
|
10129
|
-
var
|
10130
|
-
return
|
10198
|
+
var We = Ne.textForStringWithAttributes("\n", { blockBreak: true });
|
10199
|
+
var Ue = function(t2) {
|
10200
|
+
return qe(t2) ? t2 : t2.appendText(We);
|
10131
10201
|
};
|
10132
|
-
var
|
10202
|
+
var qe = function(t2) {
|
10133
10203
|
const e2 = t2.getLength();
|
10134
10204
|
if (0 === e2)
|
10135
10205
|
return false;
|
10136
10206
|
return t2.getTextAtRange([e2 - 1, e2]).isBlockBreak();
|
10137
10207
|
};
|
10138
|
-
var
|
10139
|
-
var
|
10208
|
+
var Ve = (t2) => t2.copyWithoutAttribute("blockBreak");
|
10209
|
+
var He = function(t2) {
|
10140
10210
|
const { listAttribute: e2 } = gt(t2);
|
10141
10211
|
return e2 ? [e2, t2] : [t2];
|
10142
10212
|
};
|
10143
|
-
var
|
10144
|
-
var
|
10213
|
+
var ze = (t2) => t2.slice(-1)[0];
|
10214
|
+
var _e = function(t2, e2) {
|
10145
10215
|
const i2 = t2.lastIndexOf(e2);
|
10146
10216
|
return -1 === i2 ? t2 : ot(t2, i2, 1);
|
10147
10217
|
};
|
10148
|
-
var
|
10218
|
+
var Je = class extends nt {
|
10149
10219
|
static fromJSON(t2) {
|
10150
|
-
return new this(Array.from(t2).map((t3) =>
|
10220
|
+
return new this(Array.from(t2).map((t3) => Oe.fromJSON(t3)));
|
10151
10221
|
}
|
10152
10222
|
static fromString(t2, e2) {
|
10153
|
-
const i2 =
|
10154
|
-
return new this([new
|
10223
|
+
const i2 = Ne.textForStringWithAttributes(t2, e2);
|
10224
|
+
return new this([new Oe(i2)]);
|
10155
10225
|
}
|
10156
10226
|
constructor() {
|
10157
10227
|
let t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [];
|
10158
|
-
super(...arguments), 0 === t2.length && (t2 = [new
|
10228
|
+
super(...arguments), 0 === t2.length && (t2 = [new Oe()]), this.blockList = Be.box(t2);
|
10159
10229
|
}
|
10160
10230
|
isEmpty() {
|
10161
10231
|
const t2 = this.getBlockAtIndex(0);
|
@@ -10282,7 +10352,7 @@
|
|
10282
10352
|
let e2;
|
10283
10353
|
t2 = Lt(t2);
|
10284
10354
|
const [i2] = t2, { offset: n2 } = this.locationFromPosition(i2), r2 = this.removeTextAtRange(t2);
|
10285
|
-
return 0 === n2 && (e2 = [new
|
10355
|
+
return 0 === n2 && (e2 = [new Oe()]), new this.constructor(r2.blockList.insertSplittableListAtPosition(new Be(e2), i2));
|
10286
10356
|
}
|
10287
10357
|
applyBlockAttributeAtRange(t2, e2, i2) {
|
10288
10358
|
const n2 = this.expandRangeToLineBreaksAndSplitBlocks(i2);
|
@@ -10424,7 +10494,7 @@
|
|
10424
10494
|
const e3 = [], i2 = [];
|
10425
10495
|
return this.eachBlockAtRange(t2, function(t3, n2) {
|
10426
10496
|
if (n2[0] !== n2[1])
|
10427
|
-
return e3.push(t3.text.getCommonAttributesAtRange(n2)), i2.push(
|
10497
|
+
return e3.push(t3.text.getCommonAttributesAtRange(n2)), i2.push(Ke(t3));
|
10428
10498
|
}), zt.fromCommonAttributesOfObjects(e3).merge(zt.fromCommonAttributesOfObjects(i2)).toObject();
|
10429
10499
|
}
|
10430
10500
|
}
|
@@ -10433,7 +10503,7 @@
|
|
10433
10503
|
const { index: n2, offset: r2 } = this.locationFromPosition(t2), o2 = this.getBlockAtIndex(n2);
|
10434
10504
|
if (!o2)
|
10435
10505
|
return {};
|
10436
|
-
const s2 =
|
10506
|
+
const s2 = Ke(o2), a2 = o2.text.getAttributesAtPosition(r2), l2 = o2.text.getAttributesAtPosition(r2 - 1), c2 = Object.keys(W).filter((t3) => W[t3].inheritable);
|
10437
10507
|
for (e2 in l2)
|
10438
10508
|
i2 = l2[e2], (i2 === a2[e2] || c2.includes(e2)) && (s2[e2] = i2);
|
10439
10509
|
return s2;
|
@@ -10563,84 +10633,17 @@
|
|
10563
10633
|
return JSON.stringify(this.blockList.toArray().map((t2) => JSON.parse(t2.text.toConsole())));
|
10564
10634
|
}
|
10565
10635
|
};
|
10566
|
-
var
|
10636
|
+
var Ke = function(t2) {
|
10567
10637
|
const e2 = {}, i2 = t2.getLastAttribute();
|
10568
10638
|
return i2 && (e2[i2] = true), e2;
|
10569
10639
|
};
|
10570
|
-
var He = "style href src width height language class".split(" ");
|
10571
|
-
var ze = "javascript:".split(" ");
|
10572
|
-
var _e = "script iframe form noscript".split(" ");
|
10573
|
-
var Je = class extends H {
|
10574
|
-
static sanitize(t2, e2) {
|
10575
|
-
const i2 = new this(t2, e2);
|
10576
|
-
return i2.sanitize(), i2;
|
10577
|
-
}
|
10578
|
-
constructor(t2) {
|
10579
|
-
let { allowedAttributes: e2, forbiddenProtocols: i2, forbiddenElements: n2 } = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
10580
|
-
super(...arguments), this.allowedAttributes = e2 || He, this.forbiddenProtocols = i2 || ze, this.forbiddenElements = n2 || _e, this.body = Ke(t2);
|
10581
|
-
}
|
10582
|
-
sanitize() {
|
10583
|
-
return this.sanitizeElements(), this.normalizeListElementNesting();
|
10584
|
-
}
|
10585
|
-
getHTML() {
|
10586
|
-
return this.body.innerHTML;
|
10587
|
-
}
|
10588
|
-
getBody() {
|
10589
|
-
return this.body;
|
10590
|
-
}
|
10591
|
-
sanitizeElements() {
|
10592
|
-
const t2 = R(this.body), e2 = [];
|
10593
|
-
for (; t2.nextNode(); ) {
|
10594
|
-
const i2 = t2.currentNode;
|
10595
|
-
switch (i2.nodeType) {
|
10596
|
-
case Node.ELEMENT_NODE:
|
10597
|
-
this.elementIsRemovable(i2) ? e2.push(i2) : this.sanitizeElement(i2);
|
10598
|
-
break;
|
10599
|
-
case Node.COMMENT_NODE:
|
10600
|
-
e2.push(i2);
|
10601
|
-
}
|
10602
|
-
}
|
10603
|
-
return e2.forEach((t3) => k(t3)), this.body;
|
10604
|
-
}
|
10605
|
-
sanitizeElement(t2) {
|
10606
|
-
return t2.hasAttribute("href") && this.forbiddenProtocols.includes(t2.protocol) && t2.removeAttribute("href"), Array.from(t2.attributes).forEach((e2) => {
|
10607
|
-
let { name: i2 } = e2;
|
10608
|
-
this.allowedAttributes.includes(i2) || 0 === i2.indexOf("data-trix") || t2.removeAttribute(i2);
|
10609
|
-
}), t2;
|
10610
|
-
}
|
10611
|
-
normalizeListElementNesting() {
|
10612
|
-
return Array.from(this.body.querySelectorAll("ul,ol")).forEach((t2) => {
|
10613
|
-
const e2 = t2.previousElementSibling;
|
10614
|
-
e2 && "li" === E(e2) && e2.appendChild(t2);
|
10615
|
-
}), this.body;
|
10616
|
-
}
|
10617
|
-
elementIsRemovable(t2) {
|
10618
|
-
if ((null == t2 ? void 0 : t2.nodeType) === Node.ELEMENT_NODE)
|
10619
|
-
return this.elementIsForbidden(t2) || this.elementIsntSerializable(t2);
|
10620
|
-
}
|
10621
|
-
elementIsForbidden(t2) {
|
10622
|
-
return this.forbiddenElements.includes(E(t2));
|
10623
|
-
}
|
10624
|
-
elementIsntSerializable(t2) {
|
10625
|
-
return "false" === t2.getAttribute("data-trix-serialize") && !I(t2);
|
10626
|
-
}
|
10627
|
-
};
|
10628
|
-
var Ke = function() {
|
10629
|
-
let t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "";
|
10630
|
-
t2 = t2.replace(/<\/html[^>]*>[^]*$/i, "</html>");
|
10631
|
-
const e2 = document.implementation.createHTMLDocument("");
|
10632
|
-
return e2.documentElement.innerHTML = t2, Array.from(e2.head.querySelectorAll("style")).forEach((t3) => {
|
10633
|
-
e2.body.appendChild(t3);
|
10634
|
-
}), e2.body;
|
10635
|
-
};
|
10636
10640
|
var Ge = function(t2) {
|
10637
10641
|
let e2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
10638
10642
|
return { string: t2 = Wt(t2), attributes: e2, type: "string" };
|
10639
10643
|
};
|
10640
10644
|
var $e = (t2, e2) => {
|
10641
10645
|
try {
|
10642
|
-
|
10643
|
-
return "text/html" === i2.contentType && i2.content && (i2.content = Je.sanitize(i2.content).getHTML()), i2;
|
10646
|
+
return JSON.parse(t2.getAttribute("data-trix-".concat(e2)));
|
10644
10647
|
} catch (t3) {
|
10645
10648
|
return {};
|
10646
10649
|
}
|
@@ -10655,16 +10658,14 @@
|
|
10655
10658
|
super(...arguments), this.html = t2, this.referenceElement = e2, this.blocks = [], this.blockElements = [], this.processedElements = [];
|
10656
10659
|
}
|
10657
10660
|
getDocument() {
|
10658
|
-
return
|
10661
|
+
return Je.fromJSON(this.blocks);
|
10659
10662
|
}
|
10660
10663
|
parse() {
|
10661
10664
|
try {
|
10662
|
-
this.createHiddenContainer();
|
10663
|
-
const t2 =
|
10664
|
-
|
10665
|
-
|
10666
|
-
for (; e2.nextNode(); )
|
10667
|
-
this.processNode(e2.currentNode);
|
10665
|
+
this.createHiddenContainer(), se.setHTML(this.containerElement, this.html);
|
10666
|
+
const t2 = R(this.containerElement, { usingFilter: ti });
|
10667
|
+
for (; t2.nextNode(); )
|
10668
|
+
this.processNode(t2.currentNode);
|
10668
10669
|
return this.translateBlockElementMarginsToNewlines();
|
10669
10670
|
} finally {
|
10670
10671
|
this.removeHiddenContainer();
|
@@ -10913,7 +10914,7 @@
|
|
10913
10914
|
var ai = new RegExp("<!--block-->", "g");
|
10914
10915
|
var li = { "application/json": function(t2) {
|
10915
10916
|
let e2;
|
10916
|
-
if (t2 instanceof
|
10917
|
+
if (t2 instanceof Je)
|
10917
10918
|
e2 = t2;
|
10918
10919
|
else {
|
10919
10920
|
if (!(t2 instanceof HTMLElement))
|
@@ -10923,8 +10924,8 @@
|
|
10923
10924
|
return e2.toSerializableDocument().toJSONString();
|
10924
10925
|
}, "text/html": function(t2) {
|
10925
10926
|
let e2;
|
10926
|
-
if (t2 instanceof
|
10927
|
-
e2 =
|
10927
|
+
if (t2 instanceof Je)
|
10928
|
+
e2 = ve.render(t2);
|
10928
10929
|
else {
|
10929
10930
|
if (!(t2 instanceof HTMLElement))
|
10930
10931
|
throw new Error("unserializable object");
|
@@ -11013,7 +11014,7 @@
|
|
11013
11014
|
};
|
11014
11015
|
var gi = class extends H {
|
11015
11016
|
constructor() {
|
11016
|
-
super(...arguments), this.document = new
|
11017
|
+
super(...arguments), this.document = new Je(), this.attachments = [], this.currentAttributes = {}, this.revision = 0;
|
11017
11018
|
}
|
11018
11019
|
setDocument(t2) {
|
11019
11020
|
var e2, i2;
|
@@ -11026,7 +11027,7 @@
|
|
11026
11027
|
loadSnapshot(t2) {
|
11027
11028
|
var e2, i2, n2, r2;
|
11028
11029
|
let { document: o2, selectedRange: s2 } = t2;
|
11029
|
-
return null === (e2 = this.delegate) || void 0 === e2 || null === (i2 = e2.compositionWillLoadSnapshot) || void 0 === i2 || i2.call(e2), this.setDocument(null != o2 ? o2 : new
|
11030
|
+
return null === (e2 = this.delegate) || void 0 === e2 || null === (i2 = e2.compositionWillLoadSnapshot) || void 0 === i2 || i2.call(e2), this.setDocument(null != o2 ? o2 : new Je()), this.setSelection(null != s2 ? s2 : [0, 0]), null === (n2 = this.delegate) || void 0 === n2 || null === (r2 = n2.compositionDidLoadSnapshot) || void 0 === r2 ? void 0 : r2.call(n2);
|
11030
11031
|
}
|
11031
11032
|
insertText(t2) {
|
11032
11033
|
let { updatePosition: e2 } = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : { updatePosition: true };
|
@@ -11036,19 +11037,19 @@
|
|
11036
11037
|
return e2 && this.setSelection(r2), this.notifyDelegateOfInsertionAtRange([n2, r2]);
|
11037
11038
|
}
|
11038
11039
|
insertBlock() {
|
11039
|
-
let t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : new
|
11040
|
-
const e2 = new
|
11040
|
+
let t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : new Oe();
|
11041
|
+
const e2 = new Je([t2]);
|
11041
11042
|
return this.insertDocument(e2);
|
11042
11043
|
}
|
11043
11044
|
insertDocument() {
|
11044
|
-
let t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : new
|
11045
|
+
let t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : new Je();
|
11045
11046
|
const e2 = this.getSelectedRange();
|
11046
11047
|
this.setDocument(this.document.insertDocumentAtRange(t2, e2));
|
11047
11048
|
const i2 = e2[0], n2 = i2 + t2.getLength();
|
11048
11049
|
return this.setSelection(n2), this.notifyDelegateOfInsertionAtRange([i2, n2]);
|
11049
11050
|
}
|
11050
11051
|
insertString(t2, e2) {
|
11051
|
-
const i2 = this.getCurrentTextAttributes(), n2 =
|
11052
|
+
const i2 = this.getCurrentTextAttributes(), n2 = Ne.textForStringWithAttributes(t2, i2);
|
11052
11053
|
return this.insertText(n2, e2);
|
11053
11054
|
}
|
11054
11055
|
insertBlockBreak() {
|
@@ -11062,7 +11063,7 @@
|
|
11062
11063
|
if (t2.shouldDecreaseListLevel())
|
11063
11064
|
return this.decreaseListLevel(), this.setSelection(t2.startPosition);
|
11064
11065
|
if (t2.shouldPrependListItem()) {
|
11065
|
-
const e2 = new
|
11066
|
+
const e2 = new Je([t2.block.copyWithoutText()]);
|
11066
11067
|
return this.insertDocument(e2);
|
11067
11068
|
}
|
11068
11069
|
return t2.shouldInsertBlockBreak() ? this.insertBlockBreak() : t2.shouldRemoveLastBlockAttribute() ? this.removeLastBlockAttribute() : t2.shouldBreakFormattedBlock() ? this.breakFormattedBlock(t2) : this.insertString("\n");
|
@@ -11085,7 +11086,7 @@
|
|
11085
11086
|
return Array.from(t2).forEach((t3) => {
|
11086
11087
|
var i2;
|
11087
11088
|
if (null !== (i2 = this.delegate) && void 0 !== i2 && i2.compositionShouldAcceptFile(t3)) {
|
11088
|
-
const i3 =
|
11089
|
+
const i3 = De.attachmentForFile(t3);
|
11089
11090
|
e2.push(i3);
|
11090
11091
|
}
|
11091
11092
|
}), this.insertAttachments(e2);
|
@@ -11094,12 +11095,12 @@
|
|
11094
11095
|
return this.insertAttachments([t2]);
|
11095
11096
|
}
|
11096
11097
|
insertAttachments(t2) {
|
11097
|
-
let e2 = new
|
11098
|
+
let e2 = new Ne();
|
11098
11099
|
return Array.from(t2).forEach((t3) => {
|
11099
11100
|
var n2;
|
11100
11101
|
const r2 = t3.getType(), o2 = null === (n2 = i[r2]) || void 0 === n2 ? void 0 : n2.presentation, s2 = this.getCurrentTextAttributes();
|
11101
11102
|
o2 && (s2.presentation = o2);
|
11102
|
-
const a2 =
|
11103
|
+
const a2 = Ne.textForAttachmentWithAttributes(t3, s2);
|
11103
11104
|
e2 = e2.appendText(a2);
|
11104
11105
|
}), this.insertText(e2);
|
11105
11106
|
}
|
@@ -11193,7 +11194,7 @@
|
|
11193
11194
|
if (n2 !== r2)
|
11194
11195
|
return this.setDocument(this.document.addAttributeAtRange(t2, e2, i2));
|
11195
11196
|
if ("href" === t2) {
|
11196
|
-
const t3 =
|
11197
|
+
const t3 = Ne.textForStringWithAttributes(e2, { href: e2 });
|
11197
11198
|
return this.insertText(t3);
|
11198
11199
|
}
|
11199
11200
|
}
|
@@ -11455,7 +11456,7 @@
|
|
11455
11456
|
const { block: i2 } = t2;
|
11456
11457
|
let n2 = t2.startPosition, r2 = [n2 - 1, n2];
|
11457
11458
|
i2.getBlockBreakPosition() === t2.startLocation.offset ? (i2.breaksOnReturn() && "\n" === t2.nextCharacter ? n2 += 1 : e2 = e2.removeTextAtRange(r2), r2 = [n2, n2]) : "\n" === t2.nextCharacter ? "\n" === t2.previousCharacter ? r2 = [n2 - 1, n2 + 1] : (r2 = [n2, n2 + 1], n2 += 1) : t2.startLocation.offset - 1 != 0 && (n2 += 1);
|
11458
|
-
const o2 = new
|
11459
|
+
const o2 = new Je([i2.removeLastAttribute().copyWithoutText()]);
|
11459
11460
|
return this.setDocument(e2.insertDocumentAtRange(o2, r2)), this.setSelection(n2);
|
11460
11461
|
}
|
11461
11462
|
getPreviousBlock() {
|
@@ -11577,7 +11578,7 @@
|
|
11577
11578
|
}
|
11578
11579
|
loadJSON(t2) {
|
11579
11580
|
let { document: e2, selectedRange: i2 } = t2;
|
11580
|
-
return e2 =
|
11581
|
+
return e2 = Je.fromJSON(e2), this.loadSnapshot({ document: e2, selectedRange: i2 });
|
11581
11582
|
}
|
11582
11583
|
loadSnapshot(t2) {
|
11583
11584
|
return this.undoManager = new mi(this.composition), this.composition.loadSnapshot(t2);
|
@@ -11919,8 +11920,8 @@
|
|
11919
11920
|
}
|
11920
11921
|
};
|
11921
11922
|
Li.proxyMethod("locationMapper.findLocationFromContainerAndOffset"), Li.proxyMethod("locationMapper.findContainerAndOffsetFromLocation"), Li.proxyMethod("locationMapper.findNodeAndOffsetFromLocation"), Li.proxyMethod("pointMapper.createDOMRangeFromPoint"), Li.proxyMethod("pointMapper.getClientRectsForDOMRange");
|
11922
|
-
var Di = Object.freeze({ __proto__: null, Attachment:
|
11923
|
-
var wi = Object.freeze({ __proto__: null, ObjectView: ee, AttachmentView:
|
11923
|
+
var Di = Object.freeze({ __proto__: null, Attachment: De, AttachmentManager: hi, AttachmentPiece: we, Block: Oe, Composition: gi, Document: Je, Editor: xi, HTMLParser: Xe, HTMLSanitizer: se, LineBreakInsertion: di, LocationMapper: yi, ManagedAttachment: ui, Piece: Se, PointMapper: Si, SelectionManager: Li, SplittableList: Be, StringPiece: Te, Text: Ne, UndoManager: mi });
|
11924
|
+
var wi = Object.freeze({ __proto__: null, ObjectView: ee, AttachmentView: ce, BlockView: be, DocumentView: ve, PieceView: ge, PreviewableAttachmentView: de, TextView: me });
|
11924
11925
|
var { lang: Ti, css: Bi, keyNames: Fi } = V;
|
11925
11926
|
var Pi = function(t2) {
|
11926
11927
|
return function() {
|
@@ -11931,12 +11932,12 @@
|
|
11931
11932
|
var Ii = class extends H {
|
11932
11933
|
constructor(t2, e2, i2) {
|
11933
11934
|
let n2 = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
|
11934
|
-
super(...arguments),
|
11935
|
+
super(...arguments), Re(this, "makeElementMutable", Pi(() => ({ do: () => {
|
11935
11936
|
this.element.dataset.trixMutable = true;
|
11936
|
-
}, undo: () => delete this.element.dataset.trixMutable }))),
|
11937
|
+
}, undo: () => delete this.element.dataset.trixMutable }))), Re(this, "addToolbar", Pi(() => {
|
11937
11938
|
const t3 = S({ tagName: "div", className: Bi.attachmentToolbar, data: { trixMutable: true }, childNodes: S({ tagName: "div", className: "trix-button-row", childNodes: S({ tagName: "span", className: "trix-button-group trix-button-group--actions", childNodes: S({ tagName: "button", className: "trix-button trix-button--remove", textContent: Ti.remove, attributes: { title: Ti.remove }, data: { trixAction: "remove" } }) }) }) });
|
11938
11939
|
return this.attachment.isPreviewable() && t3.appendChild(S({ tagName: "div", className: Bi.attachmentMetadataContainer, childNodes: S({ tagName: "span", className: Bi.attachmentMetadata, childNodes: [S({ tagName: "span", className: Bi.attachmentName, textContent: this.attachment.getFilename(), attributes: { title: this.attachment.getFilename() } }), S({ tagName: "span", className: Bi.attachmentSize, textContent: this.attachment.getFormattedFilesize() })] }) })), f("click", { onElement: t3, withCallback: this.didClickToolbar }), f("click", { onElement: t3, matchingSelector: "[data-trix-action]", withCallback: this.didClickActionButton }), b("trix-attachment-before-toolbar", { onElement: this.element, attributes: { toolbar: t3, attachment: this.attachment } }), { do: () => this.element.appendChild(t3), undo: () => k(t3) };
|
11939
|
-
})),
|
11940
|
+
})), Re(this, "installCaptionEditor", Pi(() => {
|
11940
11941
|
const t3 = S({ tagName: "textarea", className: Bi.attachmentCaptionEditor, attributes: { placeholder: Ti.captionPlaceholder }, data: { trixMutable: true } });
|
11941
11942
|
t3.value = this.attachmentPiece.getCaption();
|
11942
11943
|
const e3 = t3.cloneNode();
|
@@ -11999,7 +12000,7 @@
|
|
11999
12000
|
};
|
12000
12001
|
var Ni = class extends H {
|
12001
12002
|
constructor(t2, i2) {
|
12002
|
-
super(...arguments), this.didFocus = this.didFocus.bind(this), this.didBlur = this.didBlur.bind(this), this.didClickAttachment = this.didClickAttachment.bind(this), this.element = t2, this.composition = i2, this.documentView = new
|
12003
|
+
super(...arguments), this.didFocus = this.didFocus.bind(this), this.didBlur = this.didBlur.bind(this), this.didClickAttachment = this.didClickAttachment.bind(this), this.element = t2, this.composition = i2, this.documentView = new ve(this.composition.document, { element: this.element }), f("focus", { onElement: this.element, withCallback: this.didFocus }), f("blur", { onElement: this.element, withCallback: this.didBlur }), f("click", { onElement: this.element, matchingSelector: "a[contenteditable=false]", preventDefault: true }), f("mousedown", { onElement: this.element, matchingSelector: e, withCallback: this.didClickAttachment }), f("click", { onElement: this.element, matchingSelector: "a".concat(e), preventDefault: true });
|
12003
12004
|
}
|
12004
12005
|
didFocus(t2) {
|
12005
12006
|
var e2;
|
@@ -12298,7 +12299,7 @@
|
|
12298
12299
|
}
|
12299
12300
|
};
|
12300
12301
|
var Gi;
|
12301
|
-
|
12302
|
+
Re(Ki, "events", {});
|
12302
12303
|
var { browser: $i, keyNames: Xi } = V;
|
12303
12304
|
var Yi = 0;
|
12304
12305
|
var Qi = class extends Ki {
|
@@ -12377,7 +12378,7 @@
|
|
12377
12378
|
}(t2))
|
12378
12379
|
return;
|
12379
12380
|
const i2 = null === (e2 = this.responder) || void 0 === e2 ? void 0 : e2.getSelectedDocument().toSerializableDocument();
|
12380
|
-
return t2.setData("application/x-trix-document", JSON.stringify(i2)), t2.setData("text/html",
|
12381
|
+
return t2.setData("application/x-trix-document", JSON.stringify(i2)), t2.setData("text/html", ve.render(i2).innerHTML), t2.setData("text/plain", i2.toString().replace(/\n$/, "")), true;
|
12381
12382
|
}
|
12382
12383
|
canAcceptDataTransfer(t2) {
|
12383
12384
|
const e2 = {};
|
@@ -12393,7 +12394,7 @@
|
|
12393
12394
|
});
|
12394
12395
|
}
|
12395
12396
|
};
|
12396
|
-
|
12397
|
+
Re(Qi, "events", { keydown(t2) {
|
12397
12398
|
this.isComposing() || this.resetInputSummary(), this.inputSummary.didInput = true;
|
12398
12399
|
const e2 = Xi[t2.keyCode];
|
12399
12400
|
if (e2) {
|
@@ -12459,7 +12460,7 @@
|
|
12459
12460
|
null === (s2 = this.delegate) || void 0 === s2 || s2.inputControllerWillMoveText(), null === (a2 = this.responder) || void 0 === a2 || a2.moveTextFromRange(this.draggedRange), this.draggedRange = null, this.requestRender();
|
12460
12461
|
} else if (r2) {
|
12461
12462
|
var l2;
|
12462
|
-
const t3 =
|
12463
|
+
const t3 = Je.fromJSONString(r2);
|
12463
12464
|
null === (l2 = this.responder) || void 0 === l2 || l2.insertDocument(t3), this.requestRender();
|
12464
12465
|
}
|
12465
12466
|
this.draggedRange = null, this.draggingPoint = null;
|
@@ -12508,7 +12509,7 @@
|
|
12508
12509
|
this.inputSummary.didInput = true;
|
12509
12510
|
}, input(t2) {
|
12510
12511
|
return this.inputSummary.didInput = true, t2.stopPropagation();
|
12511
|
-
} }),
|
12512
|
+
} }), Re(Qi, "keys", { backspace(t2) {
|
12512
12513
|
var e2;
|
12513
12514
|
return null === (e2 = this.delegate) || void 0 === e2 || e2.inputControllerWillPerformTyping(), this.deleteInDirection("backward", t2);
|
12514
12515
|
}, delete(t2) {
|
@@ -12675,7 +12676,7 @@
|
|
12675
12676
|
const n2 = () => {
|
12676
12677
|
var e3;
|
12677
12678
|
return null === (e3 = this.responder) || void 0 === e3 ? void 0 : e3.deleteInDirection(t2);
|
12678
|
-
}, r2 = this.getTargetDOMRange({ minLength: 2 });
|
12679
|
+
}, r2 = this.getTargetDOMRange({ minLength: this.composing ? 1 : 2 });
|
12679
12680
|
return r2 ? this.withTargetDOMRange(r2, n2) : n2();
|
12680
12681
|
}
|
12681
12682
|
withTargetDOMRange(t2, e2) {
|
@@ -12703,10 +12704,10 @@
|
|
12703
12704
|
return i2;
|
12704
12705
|
}
|
12705
12706
|
};
|
12706
|
-
|
12707
|
+
Re(on, "events", { keydown(t2) {
|
12707
12708
|
if (kt(t2)) {
|
12708
12709
|
var e2;
|
12709
|
-
const i2 =
|
12710
|
+
const i2 = hn(t2);
|
12710
12711
|
null !== (e2 = this.delegate) && void 0 !== e2 && e2.inputControllerDidReceiveKeyboardCommand(i2) && t2.preventDefault();
|
12711
12712
|
} else {
|
12712
12713
|
let e3 = t2.key;
|
@@ -12719,7 +12720,7 @@
|
|
12719
12720
|
var e2;
|
12720
12721
|
let i2;
|
12721
12722
|
const n2 = null === (e2 = t2.clipboardData) || void 0 === e2 ? void 0 : e2.getData("URL");
|
12722
|
-
return
|
12723
|
+
return cn(t2) ? (t2.preventDefault(), this.attachFiles(t2.clipboardData.files)) : un(t2) ? (t2.preventDefault(), i2 = { type: "text/plain", string: t2.clipboardData.getData("text/plain") }, null === (r2 = this.delegate) || void 0 === r2 || r2.inputControllerWillPaste(i2), null === (o2 = this.responder) || void 0 === o2 || o2.insertString(i2.string), this.render(), null === (s2 = this.delegate) || void 0 === s2 ? void 0 : s2.inputControllerDidPaste(i2)) : n2 ? (t2.preventDefault(), i2 = { type: "text/html", html: this.createLinkHTML(n2) }, null === (a2 = this.delegate) || void 0 === a2 || a2.inputControllerWillPaste(i2), null === (l2 = this.responder) || void 0 === l2 || l2.insertHTML(i2.html), this.render(), null === (c2 = this.delegate) || void 0 === c2 ? void 0 : c2.inputControllerDidPaste(i2)) : void 0;
|
12723
12724
|
var r2, o2, s2, a2, l2, c2;
|
12724
12725
|
}, beforeinput(t2) {
|
12725
12726
|
const e2 = this.constructor.inputTypes[t2.inputType];
|
@@ -12728,13 +12729,13 @@
|
|
12728
12729
|
Pt.reset();
|
12729
12730
|
}, dragstart(t2) {
|
12730
12731
|
var e2, i2;
|
12731
|
-
null !== (e2 = this.responder) && void 0 !== e2 && e2.selectionContainsAttachments() && (t2.dataTransfer.setData("application/x-trix-dragging", true), this.dragging = { range: null === (i2 = this.responder) || void 0 === i2 ? void 0 : i2.getSelectedRange(), point:
|
12732
|
+
null !== (e2 = this.responder) && void 0 !== e2 && e2.selectionContainsAttachments() && (t2.dataTransfer.setData("application/x-trix-dragging", true), this.dragging = { range: null === (i2 = this.responder) || void 0 === i2 ? void 0 : i2.getSelectedRange(), point: dn(t2) });
|
12732
12733
|
}, dragenter(t2) {
|
12733
12734
|
an(t2) && t2.preventDefault();
|
12734
12735
|
}, dragover(t2) {
|
12735
12736
|
if (this.dragging) {
|
12736
12737
|
t2.preventDefault();
|
12737
|
-
const i2 =
|
12738
|
+
const i2 = dn(t2);
|
12738
12739
|
var e2;
|
12739
12740
|
if (!St(i2, this.dragging.point))
|
12740
12741
|
return this.dragging.point = i2, null === (e2 = this.responder) || void 0 === e2 ? void 0 : e2.setLocationRangeFromPointRange(i2);
|
@@ -12747,7 +12748,7 @@
|
|
12747
12748
|
if (an(t2)) {
|
12748
12749
|
var n2;
|
12749
12750
|
t2.preventDefault();
|
12750
|
-
const e3 =
|
12751
|
+
const e3 = dn(t2);
|
12751
12752
|
return null === (n2 = this.responder) || void 0 === n2 || n2.setLocationRangeFromPointRange(e3), this.attachFiles(t2.dataTransfer.files);
|
12752
12753
|
}
|
12753
12754
|
}, dragend() {
|
@@ -12755,7 +12756,7 @@
|
|
12755
12756
|
this.dragging && (null === (t2 = this.responder) || void 0 === t2 || t2.setSelectedRange(this.dragging.range), this.dragging = null);
|
12756
12757
|
}, compositionend(t2) {
|
12757
12758
|
this.composing && (this.composing = false, a.recentAndroid || this.scheduleRender());
|
12758
|
-
} }),
|
12759
|
+
} }), Re(on, "keys", { ArrowLeft() {
|
12759
12760
|
var t2, e2;
|
12760
12761
|
if (null !== (t2 = this.responder) && void 0 !== t2 && t2.shouldManageMovingCursorInDirection("backward"))
|
12761
12762
|
return this.event.preventDefault(), null === (e2 = this.responder) || void 0 === e2 ? void 0 : e2.moveCursorInDirection("backward");
|
@@ -12775,7 +12776,7 @@
|
|
12775
12776
|
var t2, e2;
|
12776
12777
|
if (null !== (t2 = this.responder) && void 0 !== t2 && t2.canDecreaseNestingLevel())
|
12777
12778
|
return this.event.preventDefault(), null === (e2 = this.responder) || void 0 === e2 || e2.decreaseNestingLevel(), this.render();
|
12778
|
-
} }),
|
12779
|
+
} }), Re(on, "inputTypes", { deleteByComposition() {
|
12779
12780
|
return this.deleteInDirection("backward", { recordUndoEntry: false });
|
12780
12781
|
}, deleteByCut() {
|
12781
12782
|
return this.deleteInDirection("backward");
|
@@ -12876,46 +12877,45 @@
|
|
12876
12877
|
return null === (e3 = this.responder) || void 0 === e3 ? void 0 : e3.moveTextFromRange(t2);
|
12877
12878
|
});
|
12878
12879
|
}, insertFromPaste() {
|
12879
|
-
|
12880
|
-
|
12881
|
-
|
12882
|
-
|
12883
|
-
|
12884
|
-
|
12885
|
-
|
12886
|
-
|
12887
|
-
|
12888
|
-
return null === (t4 = this.responder) || void 0 === t4 ? void 0 : t4.insertHTML(i2.html);
|
12880
|
+
const { dataTransfer: t2 } = this.event, e2 = { dataTransfer: t2 }, i2 = t2.getData("URL"), n2 = t2.getData("text/html");
|
12881
|
+
if (i2) {
|
12882
|
+
var r2;
|
12883
|
+
let n3;
|
12884
|
+
this.event.preventDefault(), e2.type = "text/html";
|
12885
|
+
const o3 = t2.getData("public.url-name");
|
12886
|
+
n3 = o3 ? qt(o3).trim() : i2, e2.html = this.createLinkHTML(i2, n3), null === (r2 = this.delegate) || void 0 === r2 || r2.inputControllerWillPaste(e2), this.withTargetDOMRange(function() {
|
12887
|
+
var t3;
|
12888
|
+
return null === (t3 = this.responder) || void 0 === t3 ? void 0 : t3.insertHTML(e2.html);
|
12889
12889
|
}), this.afterRender = () => {
|
12890
|
-
var
|
12891
|
-
return null === (
|
12890
|
+
var t3;
|
12891
|
+
return null === (t3 = this.delegate) || void 0 === t3 ? void 0 : t3.inputControllerDidPaste(e2);
|
12892
12892
|
};
|
12893
|
-
} else if (Ct(
|
12894
|
-
var
|
12895
|
-
|
12893
|
+
} else if (Ct(t2)) {
|
12894
|
+
var o2;
|
12895
|
+
e2.type = "text/plain", e2.string = t2.getData("text/plain"), null === (o2 = this.delegate) || void 0 === o2 || o2.inputControllerWillPaste(e2), this.withTargetDOMRange(function() {
|
12896
12896
|
var t3;
|
12897
|
-
return null === (t3 = this.responder) || void 0 === t3 ? void 0 : t3.insertString(
|
12897
|
+
return null === (t3 = this.responder) || void 0 === t3 ? void 0 : t3.insertString(e2.string);
|
12898
12898
|
}), this.afterRender = () => {
|
12899
12899
|
var t3;
|
12900
|
-
return null === (t3 = this.delegate) || void 0 === t3 ? void 0 : t3.inputControllerDidPaste(
|
12900
|
+
return null === (t3 = this.delegate) || void 0 === t3 ? void 0 : t3.inputControllerDidPaste(e2);
|
12901
12901
|
};
|
12902
|
-
} else if (
|
12903
|
-
var
|
12904
|
-
|
12902
|
+
} else if (ln(this.event)) {
|
12903
|
+
var s2;
|
12904
|
+
e2.type = "File", e2.file = t2.files[0], null === (s2 = this.delegate) || void 0 === s2 || s2.inputControllerWillPaste(e2), this.withTargetDOMRange(function() {
|
12905
12905
|
var t3;
|
12906
|
-
return null === (t3 = this.responder) || void 0 === t3 ? void 0 : t3.
|
12906
|
+
return null === (t3 = this.responder) || void 0 === t3 ? void 0 : t3.insertFile(e2.file);
|
12907
12907
|
}), this.afterRender = () => {
|
12908
12908
|
var t3;
|
12909
|
-
return null === (t3 = this.delegate) || void 0 === t3 ? void 0 : t3.inputControllerDidPaste(
|
12909
|
+
return null === (t3 = this.delegate) || void 0 === t3 ? void 0 : t3.inputControllerDidPaste(e2);
|
12910
12910
|
};
|
12911
|
-
} else if (
|
12912
|
-
var
|
12913
|
-
|
12911
|
+
} else if (n2) {
|
12912
|
+
var a2;
|
12913
|
+
this.event.preventDefault(), e2.type = "text/html", e2.html = n2, null === (a2 = this.delegate) || void 0 === a2 || a2.inputControllerWillPaste(e2), this.withTargetDOMRange(function() {
|
12914
12914
|
var t3;
|
12915
|
-
return null === (t3 = this.responder) || void 0 === t3 ? void 0 : t3.
|
12915
|
+
return null === (t3 = this.responder) || void 0 === t3 ? void 0 : t3.insertHTML(e2.html);
|
12916
12916
|
}), this.afterRender = () => {
|
12917
12917
|
var t3;
|
12918
|
-
return null === (t3 = this.delegate) || void 0 === t3 ? void 0 : t3.inputControllerDidPaste(
|
12918
|
+
return null === (t3 = this.delegate) || void 0 === t3 ? void 0 : t3.inputControllerDidPaste(e2);
|
12919
12919
|
};
|
12920
12920
|
}
|
12921
12921
|
}, insertFromYank() {
|
@@ -12953,52 +12953,60 @@
|
|
12953
12953
|
var e2;
|
12954
12954
|
return Array.from((null === (e2 = t2.dataTransfer) || void 0 === e2 ? void 0 : e2.types) || []).includes("Files");
|
12955
12955
|
};
|
12956
|
-
var ln =
|
12957
|
-
|
12958
|
-
|
12959
|
-
|
12956
|
+
var ln = (t2) => {
|
12957
|
+
var e2;
|
12958
|
+
return (null === (e2 = t2.dataTransfer.files) || void 0 === e2 ? void 0 : e2[0]) && !cn(t2) && !((t3) => {
|
12959
|
+
let { dataTransfer: e3 } = t3;
|
12960
|
+
return e3.types.includes("Files") && e3.types.includes("text/html") && e3.getData("text/html").includes("urn:schemas-microsoft-com:office:office");
|
12961
|
+
})(t2);
|
12960
12962
|
};
|
12961
12963
|
var cn = function(t2) {
|
12964
|
+
const e2 = t2.clipboardData;
|
12965
|
+
if (e2) {
|
12966
|
+
return Array.from(e2.types).filter((t3) => t3.match(/file/i)).length === e2.types.length && e2.files.length >= 1;
|
12967
|
+
}
|
12968
|
+
};
|
12969
|
+
var un = function(t2) {
|
12962
12970
|
const e2 = t2.clipboardData;
|
12963
12971
|
if (e2)
|
12964
12972
|
return e2.types.includes("text/plain") && 1 === e2.types.length;
|
12965
12973
|
};
|
12966
|
-
var
|
12974
|
+
var hn = function(t2) {
|
12967
12975
|
const e2 = [];
|
12968
12976
|
return t2.altKey && e2.push("alt"), t2.shiftKey && e2.push("shift"), e2.push(t2.key), e2;
|
12969
12977
|
};
|
12970
|
-
var
|
12971
|
-
var
|
12972
|
-
var
|
12973
|
-
var
|
12974
|
-
var
|
12975
|
-
var
|
12976
|
-
var
|
12977
|
-
var
|
12978
|
-
var
|
12979
|
-
var
|
12980
|
-
var
|
12981
|
-
var
|
12978
|
+
var dn = (t2) => ({ x: t2.clientX, y: t2.clientY });
|
12979
|
+
var gn = "[data-trix-attribute]";
|
12980
|
+
var mn = "[data-trix-action]";
|
12981
|
+
var pn = "".concat(gn, ", ").concat(mn);
|
12982
|
+
var fn = "[data-trix-dialog]";
|
12983
|
+
var bn = "".concat(fn, "[data-trix-active]");
|
12984
|
+
var vn = "".concat(fn, " [data-trix-method]");
|
12985
|
+
var An = "".concat(fn, " [data-trix-input]");
|
12986
|
+
var xn = (t2, e2) => (e2 || (e2 = Cn(t2)), t2.querySelector("[data-trix-input][name='".concat(e2, "']")));
|
12987
|
+
var yn = (t2) => t2.getAttribute("data-trix-action");
|
12988
|
+
var Cn = (t2) => t2.getAttribute("data-trix-attribute") || t2.getAttribute("data-trix-dialog-attribute");
|
12989
|
+
var kn = class extends H {
|
12982
12990
|
constructor(t2) {
|
12983
|
-
super(t2), this.didClickActionButton = this.didClickActionButton.bind(this), this.didClickAttributeButton = this.didClickAttributeButton.bind(this), this.didClickDialogButton = this.didClickDialogButton.bind(this), this.didKeyDownDialogInput = this.didKeyDownDialogInput.bind(this), this.element = t2, this.attributes = {}, this.actions = {}, this.resetDialogInputs(), f("mousedown", { onElement: this.element, matchingSelector:
|
12991
|
+
super(t2), this.didClickActionButton = this.didClickActionButton.bind(this), this.didClickAttributeButton = this.didClickAttributeButton.bind(this), this.didClickDialogButton = this.didClickDialogButton.bind(this), this.didKeyDownDialogInput = this.didKeyDownDialogInput.bind(this), this.element = t2, this.attributes = {}, this.actions = {}, this.resetDialogInputs(), f("mousedown", { onElement: this.element, matchingSelector: mn, withCallback: this.didClickActionButton }), f("mousedown", { onElement: this.element, matchingSelector: gn, withCallback: this.didClickAttributeButton }), f("click", { onElement: this.element, matchingSelector: pn, preventDefault: true }), f("click", { onElement: this.element, matchingSelector: vn, withCallback: this.didClickDialogButton }), f("keydown", { onElement: this.element, matchingSelector: An, withCallback: this.didKeyDownDialogInput });
|
12984
12992
|
}
|
12985
12993
|
didClickActionButton(t2, e2) {
|
12986
12994
|
var i2;
|
12987
12995
|
null === (i2 = this.delegate) || void 0 === i2 || i2.toolbarDidClickButton(), t2.preventDefault();
|
12988
|
-
const n2 =
|
12996
|
+
const n2 = yn(e2);
|
12989
12997
|
return this.getDialog(n2) ? this.toggleDialog(n2) : null === (r2 = this.delegate) || void 0 === r2 ? void 0 : r2.toolbarDidInvokeAction(n2, e2);
|
12990
12998
|
var r2;
|
12991
12999
|
}
|
12992
13000
|
didClickAttributeButton(t2, e2) {
|
12993
13001
|
var i2;
|
12994
13002
|
null === (i2 = this.delegate) || void 0 === i2 || i2.toolbarDidClickButton(), t2.preventDefault();
|
12995
|
-
const n2 =
|
13003
|
+
const n2 = Cn(e2);
|
12996
13004
|
var r2;
|
12997
13005
|
this.getDialog(n2) ? this.toggleDialog(n2) : null === (r2 = this.delegate) || void 0 === r2 || r2.toolbarDidToggleAttribute(n2);
|
12998
13006
|
return this.refreshAttributeButtons();
|
12999
13007
|
}
|
13000
13008
|
didClickDialogButton(t2, e2) {
|
13001
|
-
const i2 = A(e2, { matchingSelector:
|
13009
|
+
const i2 = A(e2, { matchingSelector: fn });
|
13002
13010
|
return this[e2.getAttribute("data-trix-method")].call(this, i2);
|
13003
13011
|
}
|
13004
13012
|
didKeyDownDialogInput(t2, e2) {
|
@@ -13019,7 +13027,7 @@
|
|
13019
13027
|
});
|
13020
13028
|
}
|
13021
13029
|
eachActionButton(t2) {
|
13022
|
-
return Array.from(this.element.querySelectorAll(
|
13030
|
+
return Array.from(this.element.querySelectorAll(mn)).map((e2) => t2(e2, yn(e2)));
|
13023
13031
|
}
|
13024
13032
|
updateAttributes(t2) {
|
13025
13033
|
return this.attributes = t2, this.refreshAttributeButtons();
|
@@ -13028,7 +13036,7 @@
|
|
13028
13036
|
return this.eachAttributeButton((t2, e2) => (t2.disabled = false === this.attributes[e2], this.attributes[e2] || this.dialogIsVisible(e2) ? (t2.setAttribute("data-trix-active", ""), t2.classList.add("trix-active")) : (t2.removeAttribute("data-trix-active"), t2.classList.remove("trix-active"))));
|
13029
13037
|
}
|
13030
13038
|
eachAttributeButton(t2) {
|
13031
|
-
return Array.from(this.element.querySelectorAll(
|
13039
|
+
return Array.from(this.element.querySelectorAll(gn)).map((e2) => t2(e2, Cn(e2)));
|
13032
13040
|
}
|
13033
13041
|
applyKeyboardCommand(t2) {
|
13034
13042
|
const e2 = JSON.stringify(t2.sort());
|
@@ -13054,31 +13062,31 @@
|
|
13054
13062
|
n2.setAttribute("data-trix-active", ""), n2.classList.add("trix-active"), Array.from(n2.querySelectorAll("input[disabled]")).forEach((t3) => {
|
13055
13063
|
t3.removeAttribute("disabled");
|
13056
13064
|
});
|
13057
|
-
const r2 =
|
13065
|
+
const r2 = Cn(n2);
|
13058
13066
|
if (r2) {
|
13059
|
-
const e3 =
|
13067
|
+
const e3 = xn(n2, t2);
|
13060
13068
|
e3 && (e3.value = this.attributes[r2] || "", e3.select());
|
13061
13069
|
}
|
13062
13070
|
return null === (i2 = this.delegate) || void 0 === i2 ? void 0 : i2.toolbarDidShowDialog(t2);
|
13063
13071
|
}
|
13064
13072
|
setAttribute(t2) {
|
13065
|
-
const e2 =
|
13073
|
+
const e2 = Cn(t2), i2 = xn(t2, e2);
|
13066
13074
|
return i2.willValidate && !i2.checkValidity() ? (i2.setAttribute("data-trix-validate", ""), i2.classList.add("trix-validate"), i2.focus()) : (null === (n2 = this.delegate) || void 0 === n2 || n2.toolbarDidUpdateAttribute(e2, i2.value), this.hideDialog());
|
13067
13075
|
var n2;
|
13068
13076
|
}
|
13069
13077
|
removeAttribute(t2) {
|
13070
13078
|
var e2;
|
13071
|
-
const i2 =
|
13079
|
+
const i2 = Cn(t2);
|
13072
13080
|
return null === (e2 = this.delegate) || void 0 === e2 || e2.toolbarDidRemoveAttribute(i2), this.hideDialog();
|
13073
13081
|
}
|
13074
13082
|
hideDialog() {
|
13075
|
-
const t2 = this.element.querySelector(
|
13083
|
+
const t2 = this.element.querySelector(bn);
|
13076
13084
|
var e2;
|
13077
13085
|
if (t2)
|
13078
13086
|
return t2.removeAttribute("data-trix-active"), t2.classList.remove("trix-active"), this.resetDialogInputs(), null === (e2 = this.delegate) || void 0 === e2 ? void 0 : e2.toolbarDidHideDialog(((t3) => t3.getAttribute("data-trix-dialog"))(t2));
|
13079
13087
|
}
|
13080
13088
|
resetDialogInputs() {
|
13081
|
-
Array.from(this.element.querySelectorAll(
|
13089
|
+
Array.from(this.element.querySelectorAll(An)).forEach((t2) => {
|
13082
13090
|
t2.setAttribute("disabled", "disabled"), t2.removeAttribute("data-trix-validate"), t2.classList.remove("trix-validate");
|
13083
13091
|
});
|
13084
13092
|
}
|
@@ -13086,10 +13094,10 @@
|
|
13086
13094
|
return this.element.querySelector("[data-trix-dialog=".concat(t2, "]"));
|
13087
13095
|
}
|
13088
13096
|
};
|
13089
|
-
var
|
13097
|
+
var Rn = class extends Oi {
|
13090
13098
|
constructor(t2) {
|
13091
13099
|
let { editorElement: e2, document: i2, html: n2 } = t2;
|
13092
|
-
super(...arguments), this.editorElement = e2, this.selectionManager = new Li(this.editorElement), this.selectionManager.delegate = this, this.composition = new gi(), this.composition.delegate = this, this.attachmentManager = new hi(this.composition.getAttachments()), this.attachmentManager.delegate = this, this.inputController = 2 === M.getLevel() ? new on(this.editorElement) : new Qi(this.editorElement), this.inputController.delegate = this, this.inputController.responder = this.composition, this.compositionController = new Ni(this.editorElement, this.composition), this.compositionController.delegate = this, this.toolbarController = new
|
13100
|
+
super(...arguments), this.editorElement = e2, this.selectionManager = new Li(this.editorElement), this.selectionManager.delegate = this, this.composition = new gi(), this.composition.delegate = this, this.attachmentManager = new hi(this.composition.getAttachments()), this.attachmentManager.delegate = this, this.inputController = 2 === M.getLevel() ? new on(this.editorElement) : new Qi(this.editorElement), this.inputController.delegate = this, this.inputController.responder = this.composition, this.compositionController = new Ni(this.editorElement, this.composition), this.compositionController.delegate = this, this.toolbarController = new kn(this.editorElement.toolbarElement), this.toolbarController.delegate = this, this.editor = new xi(this.composition, this.selectionManager, this.editorElement), i2 ? this.editor.loadDocument(i2) : this.editor.loadHTML(n2);
|
13093
13101
|
}
|
13094
13102
|
registerSelectionManager() {
|
13095
13103
|
return Pt.registerSelectionManager(this.selectionManager);
|
@@ -13366,7 +13374,7 @@
|
|
13366
13374
|
return this.constructor.actions;
|
13367
13375
|
}
|
13368
13376
|
};
|
13369
|
-
|
13377
|
+
Re(Rn, "actions", { undo: { test() {
|
13370
13378
|
return this.editor.canUndo();
|
13371
13379
|
}, perform() {
|
13372
13380
|
return this.editor.undo();
|
@@ -13386,33 +13394,33 @@
|
|
13386
13394
|
return this.editor.decreaseNestingLevel() && this.render();
|
13387
13395
|
} }, attachFiles: { test: () => true, perform() {
|
13388
13396
|
return M.pickFiles(this.editor.insertFiles);
|
13389
|
-
} } }),
|
13390
|
-
var
|
13391
|
-
var
|
13392
|
-
var
|
13397
|
+
} } }), Rn.proxyMethod("getSelectionManager().setLocationRange"), Rn.proxyMethod("getSelectionManager().getLocationRange");
|
13398
|
+
var En = Object.freeze({ __proto__: null, AttachmentEditorController: Ii, CompositionController: Ni, Controller: Oi, EditorController: Rn, InputController: Ki, Level0InputController: Qi, Level2InputController: on, ToolbarController: kn });
|
13399
|
+
var Sn = Object.freeze({ __proto__: null, MutationObserver: Ui, SelectionChangeObserver: Ft });
|
13400
|
+
var Ln = Object.freeze({ __proto__: null, FileVerificationOperation: Vi, ImagePreloadOperation: Le });
|
13393
13401
|
bt("trix-toolbar", "%t {\n display: block;\n}\n\n%t {\n white-space: nowrap;\n}\n\n%t [data-trix-dialog] {\n display: none;\n}\n\n%t [data-trix-dialog][data-trix-active] {\n display: block;\n}\n\n%t [data-trix-dialog] [data-trix-validate]:invalid {\n background-color: #ffdddd;\n}");
|
13394
|
-
var
|
13402
|
+
var Dn = class extends HTMLElement {
|
13395
13403
|
connectedCallback() {
|
13396
13404
|
"" === this.innerHTML && (this.innerHTML = U.getDefaultHTML());
|
13397
13405
|
}
|
13398
13406
|
};
|
13399
|
-
var
|
13400
|
-
var
|
13407
|
+
var wn = 0;
|
13408
|
+
var Tn = function(t2) {
|
13401
13409
|
if (!t2.hasAttribute("contenteditable"))
|
13402
13410
|
return t2.setAttribute("contenteditable", ""), function(t3) {
|
13403
13411
|
let e2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
13404
13412
|
return e2.times = 1, f(t3, e2);
|
13405
|
-
}("focus", { onElement: t2, withCallback: () =>
|
13406
|
-
};
|
13407
|
-
var Tn = function(t2) {
|
13408
|
-
return Bn(t2), Fn(t2);
|
13413
|
+
}("focus", { onElement: t2, withCallback: () => Bn(t2) });
|
13409
13414
|
};
|
13410
13415
|
var Bn = function(t2) {
|
13416
|
+
return Fn(t2), Pn(t2);
|
13417
|
+
};
|
13418
|
+
var Fn = function(t2) {
|
13411
13419
|
var e2, i2;
|
13412
13420
|
if (null !== (e2 = (i2 = document).queryCommandSupported) && void 0 !== e2 && e2.call(i2, "enableObjectResizing"))
|
13413
13421
|
return document.execCommand("enableObjectResizing", false, false), f("mscontrolselect", { onElement: t2, preventDefault: true });
|
13414
13422
|
};
|
13415
|
-
var
|
13423
|
+
var Pn = function(t2) {
|
13416
13424
|
var e2, i2;
|
13417
13425
|
if (null !== (e2 = (i2 = document).queryCommandSupported) && void 0 !== e2 && e2.call(i2, "DefaultParagraphSeparator")) {
|
13418
13426
|
const { tagName: t3 } = n.default;
|
@@ -13420,11 +13428,11 @@
|
|
13420
13428
|
return document.execCommand("DefaultParagraphSeparator", false, t3);
|
13421
13429
|
}
|
13422
13430
|
};
|
13423
|
-
var
|
13424
|
-
bt("trix-editor", "%t {\n display: block;\n}\n\n%t:empty:not(:focus)::before {\n content: attr(placeholder);\n color: graytext;\n cursor: text;\n pointer-events: none;\n white-space: pre-line;\n}\n\n%t a[contenteditable=false] {\n cursor: text;\n}\n\n%t img {\n max-width: 100%;\n height: auto;\n}\n\n%t ".concat(e, " figcaption textarea {\n resize: none;\n}\n\n%t ").concat(e, " figcaption textarea.trix-autoresize-clone {\n position: absolute;\n left: -9999px;\n max-height: 0px;\n}\n\n%t ").concat(e, " figcaption[data-trix-placeholder]:empty::before {\n content: attr(data-trix-placeholder);\n color: graytext;\n}\n\n%t [data-trix-cursor-target] {\n display: ").concat(
|
13425
|
-
var
|
13431
|
+
var In = a.forcesObjectResizing ? { display: "inline", width: "auto" } : { display: "inline-block", width: "1px" };
|
13432
|
+
bt("trix-editor", "%t {\n display: block;\n}\n\n%t:empty:not(:focus)::before {\n content: attr(placeholder);\n color: graytext;\n cursor: text;\n pointer-events: none;\n white-space: pre-line;\n}\n\n%t a[contenteditable=false] {\n cursor: text;\n}\n\n%t img {\n max-width: 100%;\n height: auto;\n}\n\n%t ".concat(e, " figcaption textarea {\n resize: none;\n}\n\n%t ").concat(e, " figcaption textarea.trix-autoresize-clone {\n position: absolute;\n left: -9999px;\n max-height: 0px;\n}\n\n%t ").concat(e, " figcaption[data-trix-placeholder]:empty::before {\n content: attr(data-trix-placeholder);\n color: graytext;\n}\n\n%t [data-trix-cursor-target] {\n display: ").concat(In.display, " !important;\n width: ").concat(In.width, " !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n}\n\n%t [data-trix-cursor-target=left] {\n vertical-align: top !important;\n margin-left: -1px !important;\n}\n\n%t [data-trix-cursor-target=right] {\n vertical-align: bottom !important;\n margin-right: -1px !important;\n}"));
|
13433
|
+
var Nn = class extends HTMLElement {
|
13426
13434
|
get trixId() {
|
13427
|
-
return this.hasAttribute("trix-id") ? this.getAttribute("trix-id") : (this.setAttribute("trix-id", ++
|
13435
|
+
return this.hasAttribute("trix-id") ? this.getAttribute("trix-id") : (this.setAttribute("trix-id", ++wn), this.trixId);
|
13428
13436
|
}
|
13429
13437
|
get labels() {
|
13430
13438
|
const t2 = [];
|
@@ -13482,7 +13490,7 @@
|
|
13482
13490
|
this.inputElement && (this.inputElement.value = t2);
|
13483
13491
|
}
|
13484
13492
|
connectedCallback() {
|
13485
|
-
this.hasAttribute("data-trix-internal") || (
|
13493
|
+
this.hasAttribute("data-trix-internal") || (Tn(this), function(t2) {
|
13486
13494
|
if (!t2.hasAttribute("role"))
|
13487
13495
|
t2.setAttribute("role", "textbox");
|
13488
13496
|
}(this), function(t2) {
|
@@ -13496,7 +13504,7 @@
|
|
13496
13504
|
return i2 ? t2.setAttribute("aria-label", i2) : t2.removeAttribute("aria-label");
|
13497
13505
|
};
|
13498
13506
|
e2(), f("focus", { onElement: t2, withCallback: e2 });
|
13499
|
-
}(this), this.editorController || (b("trix-before-initialize", { onElement: this }), this.editorController = new
|
13507
|
+
}(this), this.editorController || (b("trix-before-initialize", { onElement: this }), this.editorController = new Rn({ editorElement: this, html: this.defaultValue = this.value }), requestAnimationFrame(() => b("trix-initialize", { onElement: this }))), this.editorController.registerSelectionManager(), this.registerResetListener(), this.registerClickListener(), function(t2) {
|
13500
13508
|
if (!document.querySelector(":focus") && t2.hasAttribute("autofocus") && document.querySelector("[autofocus]") === t2)
|
13501
13509
|
t2.focus();
|
13502
13510
|
}(this));
|
@@ -13533,9 +13541,9 @@
|
|
13533
13541
|
this.value = this.defaultValue;
|
13534
13542
|
}
|
13535
13543
|
};
|
13536
|
-
var
|
13537
|
-
Object.assign(
|
13538
|
-
customElements.get("trix-toolbar") || customElements.define("trix-toolbar",
|
13544
|
+
var On = { VERSION: t, config: V, core: ci, models: Di, views: wi, controllers: En, observers: Sn, operations: Ln, elements: Object.freeze({ __proto__: null, TrixEditorElement: Nn, TrixToolbarElement: Dn }), filters: Object.freeze({ __proto__: null, Filter: bi, attachmentGalleryFilter: vi }) };
|
13545
|
+
Object.assign(On, Di), window.Trix = On, setTimeout(function() {
|
13546
|
+
customElements.get("trix-toolbar") || customElements.define("trix-toolbar", Dn), customElements.get("trix-editor") || customElements.define("trix-editor", Nn);
|
13539
13547
|
}, 0);
|
13540
13548
|
|
13541
13549
|
// node_modules/@rails/actiontext/app/assets/javascripts/actiontext.esm.js
|
@@ -14364,25 +14372,47 @@
|
|
14364
14372
|
}
|
14365
14373
|
start() {
|
14366
14374
|
this.directUpload.create(this.directUploadDidComplete.bind(this));
|
14375
|
+
this.dispatch("start");
|
14367
14376
|
}
|
14368
14377
|
directUploadWillStoreFileWithXHR(xhr) {
|
14369
14378
|
xhr.upload.addEventListener("progress", (event) => {
|
14370
14379
|
const progress = event.loaded / event.total * 100;
|
14371
14380
|
this.attachment.setUploadProgress(progress);
|
14381
|
+
if (progress) {
|
14382
|
+
this.dispatch("progress", {
|
14383
|
+
progress
|
14384
|
+
});
|
14385
|
+
}
|
14372
14386
|
});
|
14373
14387
|
}
|
14374
14388
|
directUploadDidComplete(error2, attributes) {
|
14375
14389
|
if (error2) {
|
14376
|
-
|
14390
|
+
this.dispatchError(error2);
|
14391
|
+
} else {
|
14392
|
+
this.attachment.setAttributes({
|
14393
|
+
sgid: attributes.attachable_sgid,
|
14394
|
+
url: this.createBlobUrl(attributes.signed_id, attributes.filename)
|
14395
|
+
});
|
14396
|
+
this.dispatch("end");
|
14377
14397
|
}
|
14378
|
-
this.attachment.setAttributes({
|
14379
|
-
sgid: attributes.attachable_sgid,
|
14380
|
-
url: this.createBlobUrl(attributes.signed_id, attributes.filename)
|
14381
|
-
});
|
14382
14398
|
}
|
14383
14399
|
createBlobUrl(signedId, filename) {
|
14384
14400
|
return this.blobUrlTemplate.replace(":signed_id", signedId).replace(":filename", encodeURIComponent(filename));
|
14385
14401
|
}
|
14402
|
+
dispatch(name, detail = {}) {
|
14403
|
+
detail.attachment = this.attachment;
|
14404
|
+
return dispatchEvent2(this.element, `direct-upload:${name}`, {
|
14405
|
+
detail
|
14406
|
+
});
|
14407
|
+
}
|
14408
|
+
dispatchError(error2) {
|
14409
|
+
const event = this.dispatch("error", {
|
14410
|
+
error: error2
|
14411
|
+
});
|
14412
|
+
if (!event.defaultPrevented) {
|
14413
|
+
alert(error2);
|
14414
|
+
}
|
14415
|
+
}
|
14386
14416
|
get directUploadUrl() {
|
14387
14417
|
return this.element.dataset.directUploadUrl;
|
14388
14418
|
}
|