Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // chrome fix
- // when creating a new line after the link,
- // the first letter of new line is appended to link
- if (jQuery.browser.webkit) {
- editor.on('contentDom', function() {
- this.document.on('keydown', function(event) {
- if (event.data.getKey() === 13 /* enter */) {
- var selection = editor.getSelection(),
- range,
- parent;
- if (!selection) {
- return;
- }
- // insert <span> </span> right after the link
- // cursor moves to next line
- // remove span element
- range = selection.getRanges()[0];
- parent = range.endContainer.getParent();
- var before = range.checkStartOfBlock(),
- after = range.checkEndOfBlock();
- if ((parent.is('a') && range.collapsed) ||
- (range.endContainer.type === 1 && range.endContainer.is('a'))) {
- if (isInside(range.endContainer, 'li')) {
- return;
- }
- editor.insertHtml('<span> </span>');
- setTimeout(function() {
- if (after && parent && parent.getNext()) {
- parent.getNext().remove();
- }
- }, 100);
- }
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement