1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Improved iframe embed interaction within editor

This commit is contained in:
Dan Brown
2022-01-20 13:55:44 +00:00
parent 20f37292a1
commit 8b4f112462
5 changed files with 36 additions and 3 deletions

View File

@ -107,6 +107,7 @@ function iframeButtonItem() {
title: "Embed Content",
run: onPress,
enable: state => true,
active: state => (state.selection.node || {type: ''}).type === schema.nodes.iframe,
icon: icons.iframe,
});
}

View File

@ -0,0 +1,26 @@
class IframeView {
/**
* @param {PmNode} node
* @param {PmView} view
* @param {(function(): number)} getPos
*/
constructor(node, view, getPos) {
this.dom = document.createElement('div');
this.dom.classList.add('ProseMirror-iframewrap');
this.iframe = document.createElement("iframe");
for (const [key, value] of Object.entries(node.attrs)) {
if (value) {
this.iframe.setAttribute(key, value);
}
}
this.dom.appendChild(this.iframe);
}
stopEvent() {
return false;
}
}
export default IframeView;

View File

@ -1,7 +1,9 @@
import ImageView from "./ImageView";
import IframeView from "./IframeView";
const views = {
image: (node, view, getPos) => new ImageView(node, view, getPos),
iframe: (node, view, getPos) => new IframeView(node, view, getPos),
};
export default views;