Commit cbdf4e4b by DenSakh

Merge branch '2694_iframe_remove_button' into tiptap

# Conflicts:
#	src/QEditor.jsx
parents ce97b7dc a5f0c2db
import { Node, mergeAttributes } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
const Iframe = Node.create({ const Iframe = Node.create({
name: 'iframe', name: 'iframe',
group: 'block', group: 'block',
selectable: false, selectable: false,
draggable: true, draggable: true,
atom: true, atom: true,
addAttributes() { addAttributes() {
return { return {
"src": { src: {
default: null default: null
}, },
"frameborder": { frameborder: {
default: 0, default: 0
}, },
"allowfullscreen": { allowfullscreen: {
default: true, default: true,
parseHTML: () => { parseHTML: () => {
console.log(this) console.log(this)
},
},
} }
}, }
}
},
parseHTML() { parseHTML() {
return [ return [
{ {
tag: 'iframe', tag: 'iframe'
}, }
] ]
}, },
renderHTML({ HTMLAttributes }) { renderHTML({ HTMLAttributes }) {
return ['iframe', mergeAttributes(HTMLAttributes)]; return ['iframe', mergeAttributes(HTMLAttributes)]
}, },
addNodeView() { addNodeView() {
return ({ editor, node, ...a }) => { return ({ editor, node, ...a }) => {
const container = document.createElement('div')
const iframe = document.createElement('iframe')
iframe.src = node.attrs.src
iframe.allowfullscreen = node.attrs.allowfullscreen
iframe.classList.add('customIframe')
// div.className = 'aspect-w-16 aspect-h-9' + (editor.isEditable ? ' cursor-pointer' : ''); const closeBtn = document.createElement('button')
const iframe = document.createElement('iframe'); closeBtn.textContent = 'X'
if (editor.isEditable) { closeBtn.classList.add('closeBtn')
iframe.className = 'pointer-events-none'; closeBtn.addEventListener('click', function () {
} container.remove()
})
iframe.src = node.attrs.src; // if (editor.isEditable) {
iframe.frameBorder = node.attrs.frameborder; // container.classList.add('pointer-events-none');
iframe.allowfullscreen = node.attrs.allowfullscreen; // }
iframe.style = 'width:1280px;height:auto;aspect-ratio: 16 / 9;';
// div.append(video); container.append(closeBtn, iframe)
return {
dom: iframe, return {
} dom: container
} }
}, }
},
addCommands() { addCommands() {
return { return {
setIframe: (options) => ({ tr, dispatch }) => { setIframe:
const { selection } = tr (options) =>
const node = this.type.create(options) ({ tr, dispatch }) => {
// const { selection } = tr
if (dispatch) { const node = this.type.create(options)
tr.replaceRangeWith(selection.from, selection.to, node)
}
return true if (dispatch) {
}, tr.replaceRangeWith(selection.from, selection.to, node)
}
return true
} }
}, }
}); }
})
export default Iframe; export default Iframe
...@@ -1045,4 +1045,25 @@ body{ ...@@ -1045,4 +1045,25 @@ body{
.qseparator{ .qseparator{
width: 16px; width: 16px;
} }
.closeBtn {
position: relative;
display: flex;
justify-content: end;
border-radius: 50%;
border: none;
background-color: #2677e3;
color: #fff;
font-size: 0.5rem;
padding: 4px 6px;
top: 10px;
cursor: pointer;
right: 8px;
}
.customIframe {
width:1280px;
height:auto;
aspect-ratio: 16 / 9;
}
} }
import React, { Fragment } from 'react'
export default function IframeCustomModal({ embedContent, setEmbedContent }) {
return (
<Fragment>
<textarea
style={{ width: '100%', height: '100%' }}
rows={18}
value={embedContent}
placeholder='<iframe></iframe>'
onInput={(e) => setEmbedContent(e.target.value)}
/>
</Fragment>
)
}
import React, { Fragment } from 'react'
export default function IframeModal({ embedContent, setEmbedContent }) {
return (
<Fragment>
<input
type='text'
value={embedContent}
placeholder='https://'
onInput={(e) => setEmbedContent(e.target.value)}
/>
<ul className='atma-editor-soc-video'>
<li className='youtube' />
<li className='vimeo' />
{/* <li className={'vk'}/> */}
<li className='ok' />
<li className='rutube' />
</ul>
</Fragment>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment