melquibrito / source-code-editor-tinymce-plugin Goto Github PK
View Code? Open in Web Editor NEWTinymce advanced custom plugin for editing source code.
License: MIT License
Tinymce advanced custom plugin for editing source code.
License: MIT License
If you use the TinyMCE codesample plug-in alongside ace editor plug-in. Viewing the source code of HTML document with codesample inserted. When you save the HTML source from ace the code sample tags are reformatted.
Is there anyway resolve this ?
codesample before save
`
`after save
<pre class="language-markup"><code></code></pre> <div class="card-footer position-relative"><a class="collapse-link collapsed stretched-link" data-bs-toggle="collapse" href="#collapse-2">View example's code</a></div> <pre class="language-markup"><code></code></pre>
I have a page with 2 tinymce editors on it. And just installed your code editor plugin (which is very nice, BTW). If I try to use the code editor plugin on the first editor, when I click Save, it overwrites the contents of the second editor with the value instead of updating the first. It appears that tinymce.activeEditor is not always returning the editor that the plugin was called from. I hacked around it by passing the editor variable to displayToxEditorModal and setting the id of the editor as a data attribute on the modal, which I then read back in saveContent()... But I'm sure there's probably a cleaner way to do it.
function displayToxEditorModal(e, display = true) {
let el = document.getElementById('tox-codeeditor-wrap');
if (display) {
el.dataset.editor = e.id;
el.style.display = "flex";
el.focus();
document.body.classList.add('tox-codeeditor__disable-scroll');
} else {
e = e || tinymce.get(el.dataset.editor);
el.style.display = "none";
document.body.classList.remove('tox-codeeditor__disable-scroll');
e.focus();
}
}
function saveContent() {
let el = document.getElementById('tox-codeeditor-wrap');
let e = tinymce.get(el.dataset.editor);
e.focus();
e.undoManager.transact(function() {
e.setContent(aceEditor.getValue())
});
e.selection.setCursorLocation();
e.nodeChanged();
displayToxEditorModal(e,false);
}
If you re-arrange the themes so that Twilight is not first, the selector will have the first theme selected, but it always applies the Twilight theme, regardless.
Workaround for me was:
aceEditor.setTheme("ace/theme/"+themesPack[0]);
Hello thank you for this plugin. Makes editing the source to easier. By default plugin seems to be reverting to the Spanish language when it should be English ?
Regards
Paul
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.