Skip to content

Commit 49a8125

Browse files
committed
some formatting
1 parent 77d8f65 commit 49a8125

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

js/src/bootstrap5/widget.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {actions} from './actions';
44
export class TiptapWidget {
55

66
/**
7+
* Initializes each widget in the given DOM context.
8+
*
79
* @param {HTMLElement} context - DOM context for initialization.
810
*/
911
static initialize(context) {
@@ -25,7 +27,7 @@ export class TiptapWidget {
2527
* @param {jQuery} elem - The jQuery element representing the Tiptap widget.
2628
* @param {Object} [opts={}] - Configuration options for the Tiptap widget.
2729
* @param {Array} opts.actions - An array of actions to be used in the editor.
28-
* @param {Array} opts.colors - An array of colors to be used in the editor.
30+
* @param {Array} opts.colors - An array of font colors to be used in the editor.
2931
* @param {string} opts.helpLink - A link to help resources related to the editor.
3032
*/
3133
constructor(elem, opts={}) {

src/yafowil/widget/tiptap/resources/bootstrap5/widget.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ var yafowil_tiptap = (function (exports, $, bootstrap) {
613613
let container = $('<div />')
614614
.addClass('btn-group me-2')
615615
.appendTo(this.controls);
616-
act.forEach(name => this.add_button(name, container));
616+
act.forEach(name => this.add_button(name, container));
617617
} else {
618618
this.add_button(act, this.controls);
619619
}
@@ -637,10 +637,10 @@ var yafowil_tiptap = (function (exports, $, bootstrap) {
637637
}
638638
}
639639
add_button(name, container) {
640-
let factory = actions[name],
641-
btn = new factory(this, this.editor, {
642-
container_elem: container
643-
});
640+
let factory = actions[name];
641+
let btn = new factory(this, this.editor, {
642+
container_elem: container
643+
});
644644
this.buttons[name] = btn;
645645
}
646646
parse_actions(acs) {

src/yafowil/widget/tiptap/resources/tiptap/tiptap.dist.bundle.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7916,16 +7916,17 @@ class CompositionViewDesc extends ViewDesc {
79167916
// some cases they will be split more often than would appear
79177917
// necessary.
79187918
class MarkViewDesc extends ViewDesc {
7919-
constructor(parent, mark, dom, contentDOM) {
7919+
constructor(parent, mark, dom, contentDOM, spec) {
79207920
super(parent, [], dom, contentDOM);
79217921
this.mark = mark;
7922+
this.spec = spec;
79227923
}
79237924
static create(parent, mark, inline, view) {
79247925
let custom = view.nodeViews[mark.type.name];
79257926
let spec = custom && custom(mark, view, inline);
79267927
if (!spec || !spec.dom)
79277928
spec = DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark, inline), null, mark.attrs);
7928-
return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom);
7929+
return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom, spec);
79297930
}
79307931
parseRule() {
79317932
if ((this.dirty & NODE_DIRTY) || this.mark.type.spec.reparseInView)
@@ -7957,6 +7958,11 @@ class MarkViewDesc extends ViewDesc {
79577958
copy.children = nodes;
79587959
return copy;
79597960
}
7961+
destroy() {
7962+
if (this.spec.destroy)
7963+
this.spec.destroy();
7964+
super.destroy();
7965+
}
79607966
}
79617967
// Node view descs are the main, most common type of view desc, and
79627968
// correspond to an actual node in the document. Unlike mark descs,
@@ -9677,14 +9683,17 @@ let _detachedDoc = null;
96779683
function detachedDoc() {
96789684
return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
96799685
}
9686+
let _policy = null;
96809687
function maybeWrapTrusted(html) {
96819688
let trustedTypes = window.trustedTypes;
96829689
if (!trustedTypes)
96839690
return html;
96849691
// With the require-trusted-types-for CSP, Chrome will block
96859692
// innerHTML, even on a detached document. This wraps the string in
96869693
// a way that makes the browser allow us to use its parser again.
9687-
return trustedTypes.createPolicy("detachedDocument", { createHTML: (s) => s }).createHTML(html);
9694+
if (!_policy)
9695+
_policy = trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
9696+
return _policy.createHTML(html);
96889697
}
96899698
function readHTML(html) {
96909699
let metas = /^(\s*<meta [^>]*>)*/.exec(html);

src/yafowil/widget/tiptap/resources/tiptap/tiptap.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5671,16 +5671,17 @@ var tiptap = (function (exports) {
56715671
}
56725672
}
56735673
class MarkViewDesc extends ViewDesc {
5674-
constructor(parent, mark, dom, contentDOM) {
5674+
constructor(parent, mark, dom, contentDOM, spec) {
56755675
super(parent, [], dom, contentDOM);
56765676
this.mark = mark;
5677+
this.spec = spec;
56775678
}
56785679
static create(parent, mark, inline, view) {
56795680
let custom = view.nodeViews[mark.type.name];
56805681
let spec = custom && custom(mark, view, inline);
56815682
if (!spec || !spec.dom)
56825683
spec = DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark, inline), null, mark.attrs);
5683-
return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom);
5684+
return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom, spec);
56845685
}
56855686
parseRule() {
56865687
if ((this.dirty & NODE_DIRTY) || this.mark.type.spec.reparseInView)
@@ -5711,6 +5712,11 @@ var tiptap = (function (exports) {
57115712
copy.children = nodes;
57125713
return copy;
57135714
}
5715+
destroy() {
5716+
if (this.spec.destroy)
5717+
this.spec.destroy();
5718+
super.destroy();
5719+
}
57145720
}
57155721
class NodeViewDesc extends ViewDesc {
57165722
constructor(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos) {
@@ -7269,11 +7275,14 @@ var tiptap = (function (exports) {
72697275
function detachedDoc() {
72707276
return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
72717277
}
7278+
let _policy = null;
72727279
function maybeWrapTrusted(html) {
72737280
let trustedTypes = window.trustedTypes;
72747281
if (!trustedTypes)
72757282
return html;
7276-
return trustedTypes.createPolicy("detachedDocument", { createHTML: (s) => s }).createHTML(html);
7283+
if (!_policy)
7284+
_policy = trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
7285+
return _policy.createHTML(html);
72777286
}
72787287
function readHTML(html) {
72797288
let metas = /^(\s*<meta [^>]*>)*/.exec(html);

src/yafowil/widget/tiptap/resources/tiptap/tiptap.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)