You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the default value in the editor is only iframe, the iframe disappears when the editor is selected
`import { InputRule } from '@milkdown/prose/inputrules'
import { $node, $inputRule, $remark } from "@milkdown/utils"
import directive from 'remark-directive';
Initial checklist
Affected packages and versions
Link to runnable example
No response
Steps to reproduce
If the default value in the editor is only iframe, the iframe disappears when the editor is selected
`import { InputRule } from '@milkdown/prose/inputrules'
import { $node, $inputRule, $remark } from "@milkdown/utils"
import directive from 'remark-directive';
const remarkPluginId = "iframe"
const remarkDirective = $remark(remarkPluginId, () => directive)
const iframeNode = $node('iframe', () => ({
group: 'block',
atom: true,
isolating: true,
marks: '',
selectable: true,
draggable: true,
defining: true,
attrs: {
src: { default: null },
},
parseDOM: [{
tag: 'iframe',
getAttrs: (dom) => ({
src: dom.getAttribute('src'),
}),
}],
toDOM: (node) => [
'iframe',
{ ...node.attrs, 'contenteditable': false },
0,
],
parseMarkdown: {
match: (node) => {
return node.type === 'leafDirective' && node.name === 'iframe'
},
runner: (state, node, type) => {
state.addNode(type, { src: node.attributes.src });
},
},
toMarkdown: {
match: (node) => node.type.name === 'iframe',
runner: (state, node) => {
state.addNode('leafDirective', undefined, undefined, {
name: 'iframe',
attributes: { src: node.attrs.src },
});
},
}
}))
const iframeInputRule = $inputRule((ctx) => new InputRule(/::iframe{src="(?[^"]+)?"?}/, (state, match, start, end) => {
const [okay, src = ''] = match;
const { tr } = state;
}))
export default [iframeInputRule, iframeNode, remarkDirective]`
Expected behavior
The editor is selected, and the contents of the editor are not affected
Actual behavior
The editor is selected, but the iframe is deleted
Runtime
Chrome
OS
macOS
Build and bundle tools
Vite
The text was updated successfully, but these errors were encountered: