mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Improved iframe embed interaction within editor
This commit is contained in:
parent
20f37292a1
commit
8b4f112462
4
TODO
4
TODO
@ -7,7 +7,6 @@
|
|||||||
### In-Progress
|
### In-Progress
|
||||||
|
|
||||||
- Tables
|
- Tables
|
||||||
- Iframe/Media
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
@ -33,8 +32,9 @@
|
|||||||
- Clear formatting, If no selection range, clear the formatting of parent block.
|
- Clear formatting, If no selection range, clear the formatting of parent block.
|
||||||
- If no marks, clear the block type if text type?
|
- If no marks, clear the block type if text type?
|
||||||
- Remove links button? (Action already in place if link href is empty).
|
- Remove links button? (Action already in place if link href is empty).
|
||||||
- Links - Limit target attribute options and validate URL.
|
- Links - Validate URL.
|
||||||
- Links - Integrate entity picker.
|
- Links - Integrate entity picker.
|
||||||
|
- iFrame - Parse iframe HTML & auto-convert youtube/vimeo urls to embeds.
|
||||||
|
|
||||||
### Notes
|
### Notes
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ function iframeButtonItem() {
|
|||||||
title: "Embed Content",
|
title: "Embed Content",
|
||||||
run: onPress,
|
run: onPress,
|
||||||
enable: state => true,
|
enable: state => true,
|
||||||
|
active: state => (state.selection.node || {type: ''}).type === schema.nodes.iframe,
|
||||||
icon: icons.iframe,
|
icon: icons.iframe,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
26
resources/js/editor/node-views/IframeView.js
Normal file
26
resources/js/editor/node-views/IframeView.js
Normal 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;
|
@ -1,7 +1,9 @@
|
|||||||
import ImageView from "./ImageView";
|
import ImageView from "./ImageView";
|
||||||
|
import IframeView from "./IframeView";
|
||||||
|
|
||||||
const views = {
|
const views = {
|
||||||
image: (node, view, getPos) => new ImageView(node, view, getPos),
|
image: (node, view, getPos) => new ImageView(node, view, getPos),
|
||||||
|
iframe: (node, view, getPos) => new IframeView(node, view, getPos),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default views;
|
export default views;
|
@ -517,7 +517,7 @@ img.ProseMirror-separator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ProseMirror-imagewrap {
|
.ProseMirror-imagewrap, .ProseMirror-iframewrap {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
font-size: 0;
|
font-size: 0;
|
||||||
@ -532,6 +532,10 @@ img.ProseMirror-separator {
|
|||||||
outline: 4px solid #000;
|
outline: 4px solid #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ProseMirror .ProseMirror-iframewrap iframe {
|
||||||
|
pointer-events: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
.ProseMirror-dragdummy {
|
.ProseMirror-dragdummy {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user