[nextgen-editor] Update shortcode content using jQuery #91
Replies: 9 comments
-
You really can't manipulate the content like that via jQuery. As this uses CKEditor which uses a Virtual DOM. To do that kind of manipulation of the content you have to use CK5 API, we expose full access to the editor api via
I am not entirely sure how to do what you are trying to do but here is a quick example on how you can add a div with content
I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for the advice. I understand a little better how to work with the editor. Now I still need advice on how to get a shortcode position. |
Beta Was this translation helpful? Give feedback.
-
So I have already solved the position but now I have a problem with inserting the shortcode in the specified place (element).
My code:
inside method addItem: I just want to insert into the added elements (ul li) the code from the execute function... thank you very much for any advice |
Beta Was this translation helpful? Give feedback.
-
This is definitely in the super advanced zone :) Happy to see you are making good progress with it, unfortunately it really all comes down to the CK5 API which needs some digging and investigating. I will try and have a look to see If there's anything outstanding I can figure out to help you. |
Beta Was this translation helpful? Give feedback.
-
hey @danielkoptak , I'm unable to test your code because I'm missing some bits, however while I was looking at your code, I noticed you are trying to search for the element in the dom ( Shouldn't that be |
Beta Was this translation helpful? Give feedback.
-
hey @w00fz, the previous code turned out to be a bad choice. I currently chose access using the html snippet plugin. When I'm done I'll send the code of my solution, but now I'm working on how to use setData function without modifying the ckeditor code in any way...:
after inserting the content, the result in the editor changes to:
Is it possible to prevent this behavior? |
Beta Was this translation helpful? Give feedback.
-
and another question ... how can I customize decorators in nextgenEditor? |
Beta Was this translation helpful? Give feedback.
-
Isn't there really an easy solution to force ckeditor to insert html without any changes? function: I want the user to be able to edit a real preview of the page. But this is not possible when the editor is editing my code ... |
Beta Was this translation helpful? Give feedback.
-
This is a little beyond NextGen Editor, what you are trying to do is purely dependent on the CK5 editor API, and being so specific to your needs, it's hard for me to provide a fully working example for what you are trying to achieve. One thing I tried that might work for you is to create a view and model fragment out of your HTML snippet, and then insert it into the editor. Something like this: const viewFragment = nextgenEditor.editor.data.processor.toView(result);
const modelFragment = nextgenEditor.editor.data.toModel(viewFragment);
nextgenEditor.editor.model.insertContent(modelFragment); If this still does not help, maybe you could try inserting the snippet as HTML snippet, exactly like in your screenshot (second example), that way the user can edit and preview, and it will save as raw HTML. This will require you enable the HTML Snippets preview option, but it looks like you already have it that way: nextgenEditor.editor.execute('insertHtmlEmbed');
nextgenEditor.editor.execute('updateHtmlEmbed', result); If this does not help either, I would suggest trying the CK5 forums/chat where I'm sure more experienced people will be able to provide this level of support. Be aware that the next release of NextGen Editor (v1.1.0) is going to support multiple instances of the editor and so the API The new API exposed is going to be
|
Beta Was this translation helpful? Give feedback.
-
Hello,
is it possible to update the content (shotcode) of the editor through jQuery?
example:
when I click on span, the "addItem()" function is called, the color changes but a new div is not added. Probably it is necessary to force nextgenEditor to redraw the content, but I don't know how to do it, in case the documentation is available somewhere?
Thank you very much for any advice
Beta Was this translation helpful? Give feedback.
All reactions