|
1 |
| -var noWrapNodes = "p > img,p > video, p > figure"; |
| 1 | +var noWrapNodes = "p > img, p > video, p > figure, p > iframe"; |
2 | 2 | var wrapNodes = ['B','I','SPAN', 'TABLE', 'P', 'H1', 'H2', 'H3', 'H4'];
|
3 | 3 |
|
4 | 4 | function fixWrapper(doc){
|
@@ -99,6 +99,30 @@ let tinyMceOptions = {
|
99 | 99 | selector: "textarea.html",
|
100 | 100 | body_class: "container",
|
101 | 101 | init_instance_callback : make_wysiwyg,
|
| 102 | + paste_preprocess: (editor, args) => { |
| 103 | + if (args.content.startsWith('http')) { |
| 104 | + let url = args.content; |
| 105 | + args.content = ''; |
| 106 | + getOembed(url, 800, 600, true).then(response => { |
| 107 | + if (response && response.html) { |
| 108 | + editor.insertContent( '<div class="iframe" data-url="' + url + '" data-component-iframe>' + response.html.replace('<iframe ','<iframe class="align-center" ') + '</div>' ); |
| 109 | + let arr = editor.contentDocument.getElementsByTagName('script'); |
| 110 | + |
| 111 | + for (let n = 0; n < arr.length; n++) { |
| 112 | + let script = arr[n]; |
| 113 | + if (!script.hasAttribute("type")) continue;//process only new scripts that have the tinymce attribute |
| 114 | + let newScript = editor.contentDocument.createElement("script"); |
| 115 | + newScript.src = script.src; |
| 116 | + script.replaceWith(newScript); |
| 117 | + } |
| 118 | + } else { |
| 119 | + editor.insertContent(url); |
| 120 | + } |
| 121 | + }).catch(error => { |
| 122 | + //editor.insertContent(url); |
| 123 | + }); |
| 124 | + } |
| 125 | + }, |
102 | 126 | setup: function (editor) {
|
103 | 127 | //set changes to false to avoid saving unchanged revisions if text is not changed
|
104 | 128 | let has_changes = document.getElementById(editor.id)?.parentNode.querySelector(".has_changes");
|
|
0 commit comments