- Added
Dom
.isTag
method
const editor = Jodit.make('#editor');
const a = editor.create.inside.element('a');
const br = document.createElement('br');
Jodit.modules.Dom.isTag(a, 'a') // true
Jodit.modules.Dom.isTag(br, 'br') // true
- Added
Helpers
.call
method
const f = Math.random();
Jodit.modules.Helpers.call(f > 0.5 ? Math.ceil : Math.floor, f);
- Added
Helpers
.position
method - Helper function to get an element's exact position
console.log(Jodit.modules.Helpers.position(editor.editor.querySelector('p')));
- In
link
plugin addedformTemplate
andformClassName
options #333
const editor = new Jodit(appendTestArea(), {
link: {
formTemplate: function() {
return '<form class="form_url"><input ref="url_input" type="url"><button>save</button></form>';
},
formClassName: "some_class"
}
});
- Added deprecated mechanism. Some methods will not be removed and only will be marked as deprecated until major release. #330
Added createAttributes
option #243
All elements which will be inserted in editor will be created with these attributes
const editor2 = Jodit.make('#editor', {
createAttributes: {
div: {
class: 'test'
},
ul: function (ul) {
ul.classList.add('ui-test');
}
}
});
const div2 = editor2.create.inside.div();
expect(div2.className).equals('test');
const ul = editor2.create.inside.element('ul');
expect(ul.className).equals('ui-test');
Fixed SPLIT_MODE
Added editHTMLDocumentMode
in order to allow the user to edit the entire document #241.
Also added iframeTitle
and iframeDoctype
options
const editor = Jodit.make('#editor', {
iframe: true,
iframeTitle: 'Hello world!',
iframeDoctype: '<!DOCTYPE html>',
editHTMLDocumentMode: true,
iframeStyle: ''
});
console.log(editor.value);
// <html dir="" class="jodit" lang="en" spellcheck="true" style="min-height: 113px;">
// <head>
// <title>Hello world!</title>
// </head>
// <body class="jodit_wysiwyg" style="outline:none">test test <a href="#">test</a></body>
// </html>
Fixed xdan#316 Fixed bug when Jodit was initialized inside iframe.
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);
const win = iframe.contentWindow;
const doc = win.document;
doc.open();
doc.write('<html><body><textarea id="editor"></textarea><' + 'script src="./build/jodit.js"><' + '/script></body></html>');
doc.close();
Jodit.make('#editor', {
ownerWindow: win,
ownerDocument: doc
});
Fixed bug with ProgressBar - it simple does not work(
Source plugin was separated on several classes. Now you can choose SourceEditor or make yourself (xdan#242)
Before
Jodit.make('#editor', {
useAceEditor: true
});
Now
Jodit.make('#editor', {
sourceEditor: 'area' || 'ace' // || 'mirror' in PRO
});
In PRO version you can choose mirrror&
- Added Async module for control asynchronous operations
const editor = new Jodit('#editor');
setTimeout(() => {
editor.selection.insertHTML('Hello!')
}, 1000);
editor.async.setTimeout(() => {
editor.selection.insertHTML('World!')
}, 1000);
editor.destruct();
After destruct first timeout will throw the error, but second will be cleared.
Added two methods setPanel and addPlace
<textarea id="editor"></textarea>
<textarea id="editor2"></textarea>
<textarea id="editor3"></textarea>
<div id="toolbar"></div>
const editor = new Jodit('#editor');
editor.setPanel('#toolbar');
//add id instance to editor
editor.addPlace('#editor2');
editor.addPlace('#editor3');
Added afterRemoveNode
event
const editor = new Jodit('#editor');
editor.events.on('afterRemoveNode', (node) => {
if (node.nodeName === 'IMG') {
fetch('delete.php', {image: node.src});
}
});
Before
Jodit.plugins.insertText = function (editor) {
editor.events.on('someEvent', function (text) {
editor.selection.insertHTMl('Hello ' + text);
});
};
Now
Jodit.plugins.add('insertText', function (editor) {
editor.events.on('someEvent', function (text) {
editor.selection.insertHTMl('Hello ' + text);
});
});
console.log(Jodit.plugins.get('insertText'));
Jodit.plugins.remove('insertText');
Inside plugin you can use several fields:
// emoji.js
class Emoji {
hasStyle = true; //
requires = ['autocomplete'];
init(editor) {
// this code will be execute only after autocomplete.init
}
}
Jodit.plugins.add('emoji', Emoji);
And inside you init code
Jodit.make('#editor', {
basePath: 'https://sitename.com/somepath/',
extraPlugins: ['emoji']
});
It will try to download
https://sitename.com/somepath/plugins/emoji/emoji.js
hasStyle = true;
means try download and include in page style file:
https://sitename.com/somepath/plugins/emoji/emoji.css
In plugins/example
folder you can find example.
extraPlugins option allows append in editor extra plugins from npm, bower etc.
In Build system was added gulp subsystem for build extra plugins.
You can make extra plugins like plugins/example
and after build,
this plugin will not be inside jodit.min.js
file. It will be in separate
folder (eg build/plugins/emoji/
).
Also in root you can find make.js
file for install your plugin
in build system.