New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to append child into editor div #1637
Comments
I think #1621 can help you, though it is hack. |
How do I use this ? Do I have to write all of this everytime I want to insert an element ? Or I can use it like a function |
This function can help you to create element. And then insert it. Just like this: editor.insertHtml = (type, attrs, content) => {
const wwSelection = editor.getSelection();
const node = createNode(type, attrs, content);
const newDoc = editor.wwEditor.schema.nodes.doc.create(null, node);
const { tr } = editor.wwEditor.view.state;
editor.wwEditor.view.dispatch(tr.replaceWith(wwSelection[0], wwSelection[1], newDoc));
}; |
Thanks! But I'm using CDN, no imports. WWE is unknown |
|
I figured out how to do it, thanks for your help |
@z-950 @2klm |
@z-950 @js87zz do you know how do I use this to create a 'a href ' element ? There is no 'link' object in the nodes list however, I can see in the editor config : I can't wait for an API or a command to be released since I'm working on a project for a customer and I have a short schedule |
I tried to add this in custom html renderers :
which works, but node.attrs doesnt so I cant add the " href='..' " part Does it work like so ? |
@2klm |
@2klm const attrs = {
linkUrl: // ...
linkText: // ...
};
editor.exec('addLink', attrs); |
Thanks! I didnt know about that command stuff. Is there a doc about commands ? |
I want to insert a div, p or a in the editor with appendChild but it is not working. I can appendChild on any element but not in the editor div. (# prosemirror)
let fileLink = document.createElement('p');
fileLink.textContent = "hello !";
document.getElementById('ProseMirrorId').appendChild(fileLink);
Nothing happens.
last code line works in browser console without appendChild, which means the selector is ok.
I'm in the wysiwyg view
editor.insertText works, I wonder if you could add another function like editor.insertElement or insertNode
The text was updated successfully, but these errors were encountered: