suneditor
Advanced tools
Comparing version 1.6.0 to 1.6.1
{ | ||
"name": "suneditor", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Pure JavaScript based WYSIWYG web editor", | ||
@@ -5,0 +5,0 @@ "main": "src/suneditor.js", |
{ | ||
"name": "suneditor", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Pure JavaScript based WYSIWYG web editor", | ||
@@ -5,0 +5,0 @@ "main": "src/suneditor.js", |
@@ -51,3 +51,3 @@ /* | ||
/** add event listeners */ | ||
context.image.modal.getElementsByClassName('sun-editor-tab-button')[0].addEventListener('click', this.openTab); | ||
context.image.modal.getElementsByClassName('sun-editor-tab-button')[0].addEventListener('click', this.openTab.bind(_this)); | ||
context.image.modal.getElementsByClassName("btn-primary")[0].addEventListener('click', this.submit_dialog.bind(_this)); | ||
@@ -150,2 +150,3 @@ resize_img_div.getElementsByClassName('sun-editor-img-controller')[0].addEventListener('mousedown', this.onMouseDown_image_ctrl.bind(_this, 'l')); | ||
var i, tabcontent, tablinks; | ||
var tabName = targetElement.getAttribute('data-tab-link'); | ||
var contentClassName = 'sun-editor-id-tab-content'; | ||
@@ -166,5 +167,12 @@ | ||
// Show the current tab, and add an "active" class to the button that opened the tab | ||
document.getElementsByClassName(contentClassName + '-' + targetElement.getAttribute('data-tab-link'))[0].style.display = 'block'; | ||
this.context.image.modal.getElementsByClassName(contentClassName + '-' + tabName)[0].style.display = 'block'; | ||
SUNEDITOR.dom.addClass(targetElement, 'active'); | ||
// focus | ||
if (tabName === 'image') { | ||
this.context.image.focusElement.focus(); | ||
} else if (tabName === 'url') { | ||
this.context.image.imgLink.focus(); | ||
} | ||
return false; | ||
@@ -255,2 +263,3 @@ }, | ||
link.setAttribute('data-image-link', 'image'); | ||
link.addEventListener('click', function (e) { e.preventDefault(); }); | ||
@@ -343,3 +352,3 @@ imgTag.setAttribute('data-image-link', imgLinkValue); | ||
this.insertNode(container); | ||
this.insertNode(container, this.getLineElement(this.getSelectionNode())); | ||
this.appendP(container); | ||
@@ -431,3 +440,3 @@ }, | ||
this.context.image.imageY.disabled = true; | ||
SUNEDITOR.plugin.image.openTab('init'); | ||
SUNEDITOR.plugin.image.openTab.call(this, 'init'); | ||
}, | ||
@@ -470,3 +479,3 @@ | ||
_call_controller_imageResize: function (targetElement) { | ||
call_controller_imageResize: function (targetElement) { | ||
/** ie,firefox image resize handle : false*/ | ||
@@ -473,0 +482,0 @@ targetElement.setAttribute('unselectable', 'on'); |
@@ -79,3 +79,3 @@ /* | ||
if (this.context.link._linkAnchor === null) { | ||
if (!this.context.dialog.updateModal) { | ||
var oA = document.createElement("A"); | ||
@@ -87,2 +87,3 @@ oA.href = url; | ||
this.insertNode(oA); | ||
this.setRange(oA.childNodes[0], 0, oA.childNodes[0], oA.textContent.length); | ||
} else { | ||
@@ -92,2 +93,3 @@ this.context.link._linkAnchor.href = url; | ||
this.context.link._linkAnchor.target = (this.context.link.linkNewWindowCheck.checked ? "_blank" : ""); | ||
this.setRange(this.context.link._linkAnchor.childNodes[0], 0, this.context.link._linkAnchor.childNodes[0], this.context.link._linkAnchor.textContent.length); | ||
} | ||
@@ -104,2 +106,3 @@ | ||
this.closeLoading(); | ||
this.focus(); | ||
} | ||
@@ -163,3 +166,3 @@ | ||
this.context.link.linkNewWindowCheck.checked = (/_blank/i.test(this.context.link._linkAnchor.target) ? true : false); | ||
SUNEDITOR.plugin.dialog.openDialog.call(this, 'link'); | ||
SUNEDITOR.plugin.dialog.openDialog.call(this, 'link', true); | ||
} | ||
@@ -166,0 +169,0 @@ else { |
@@ -55,5 +55,5 @@ /* | ||
var pNode = this.getLineElement(this._variable.selectionNode); | ||
pNode.appendChild(oHr); | ||
this.appendP(oHr); | ||
this.insertNode(oHr, this.getLineElement(this.getSelectionNode())); | ||
var oP = this.appendP(oHr); | ||
this.setRange(oP, 0, oP, 0); | ||
}, | ||
@@ -60,0 +60,0 @@ |
@@ -52,12 +52,12 @@ "undefined"===typeof window.SUNEDITOR&&(window.SUNEDITOR={},SUNEDITOR.plugin={}); | ||
null!==g.nextElementSibling&&g.nextElementSibling===b?/dialog/.test(f)&&c.callModule("dialog",e,null,function(){SUNEDITOR.plugin.dialog.openDialog.call(c,e,g.getAttribute("data-option"))}):c.callModule("submenu",e,g,function(){c.submenuOn(g)});else{if(e)switch(f=g.getAttribute("data-value"),e){case "codeView":c.toggleFrame();d.toggleClass(g,"on");break;case "fullScreen":c.toggleFullScreen(g);d.toggleClass(g,"on");break;case "indent":case "outdent":c.indent(c._variable.selectionNode,e);break;case "redo":case "undo":case "removeFormat":c.execCommand(e, | ||
!1,null);break;case "preview":c.preview();break;case "print":a.element.wysiwygWindow.print();break;default:c.execCommand(e,!1,f),d.toggleClass(g,"on")}c.submenuOff()}},onMouseUp_wysiwyg:function(a){a.stopPropagation();c._setSelectionNode();var b=a.target;c.submenuOff();/^HTML$/i.test(b.nodeName)?(a.preventDefault(),c.focus()):/^IMG$/i.test(b.nodeName)?c.callModule("dialog","image",null,function(){SUNEDITOR.plugin.image._call_controller_imageResize.call(c,b)}):f._findButtonEffectTag()},onKeyDown_wysiwyg:function(b){c._setSelectionNode(); | ||
var g=b.keyCode,e=b.shiftKey,v=b.ctrlKey||b.metaKey,k=b.altKey;b.stopPropagation();if(v&&!/^(?:16|17|18)$/.test(g)){var m;if(m=!(e&&83!==g))(m=f._shortcutKeyCode[g])?(c.execCommand(m[0],!1,null),d.toggleClass(c.commandMap[m[1]],"on"),m=!0):m=!1;if(m){b.preventDefault();return}}switch(g){case 8:if(/^P$/i.test(c._variable.selectionNode.tagName)&&null===c._variable.selectionNode.previousSibling)return b.preventDefault(),!1;break;case 9:if(b.preventDefault(),!v&&!k){for(b=c._variable.selectionNode||c.getSelection().anchorNode;!/^TD$/i.test(b.tagName)&& | ||
!/^BODY$/i.test(b.tagName);)b=b.parentNode;if(b&&/^TD$/i.test(b.tagName)){g=d.getParentNode(b,"table");g=d.getListChildren(g,d.isCell);b=e?d.prevIdx(g,b):d.nextIdx(g,b);b!==g.length||e||(b=0);-1===b&&e&&(b=g.length-1);e=g[b];if(!e)return!1;b=c.createRange();b.setStart(e,0);b.setEnd(e,0);e=c.getSelection();0<e.rangeCount&&e.removeAllRanges();e.addRange(b)}else e||(b=a.element.wysiwygWindow.document.createTextNode(Array(c._variable.tabSize+1).join("\u00a0")),c.insertNode(b,null),e=c.getSelection(), | ||
g=c.createRange(),g.setStart(b,c._variable.tabSize),g.setEnd(b,c._variable.tabSize),0<e.rangeCount&&e.removeAllRanges(),e.addRange(g))}}},onKeyUp_wysiwyg:function(a){c._setSelectionNode();f._directionKeyKeyCode.test(a.keyCode)&&f._findButtonEffectTag()},onScroll_wysiwyg:function(){c.controllersOff()},onDrop_wysiwyg:function(a){var b=a.dataTransfer.files;if(0===b.length)return!0;a.stopPropagation();a.preventDefault();c.focus();c.callModule("dialog","image",null,function(){c.context.image.imgInputFile.files= | ||
b;SUNEDITOR.plugin.image.onRender_imgInput.call(c);c.context.image.imgInputFile.files=null})},onMouseDown_resizeBar:function(b){function d(){a.element.resizeBackground.style.display="none";document.removeEventListener("mousemove",f.resize_editor);document.removeEventListener("mouseup",d)}b.stopPropagation();c._variable.resizeClientY=b.clientY;a.element.resizeBackground.style.display="block";document.addEventListener("mousemove",f.resize_editor);document.addEventListener("mouseup",d)},resize_editor:function(b){var d= | ||
b.clientY-c._variable.resizeClientY;a.element.editorArea.style.height=a.element.editorArea.offsetHeight+d+"px";c._variable.editorHeight=a.element.editorArea.offsetHeight+d;c._variable.resizeClientY=b.clientY}};a.tool.bar.addEventListener("touchstart",f.touchstart_toolbar);a.tool.bar.addEventListener("touchmove",f.touchmove_toolbar);a.tool.bar.addEventListener("touchend",f.onClick_toolbar);a.tool.bar.addEventListener("click",f.onClick_toolbar);a.element.wysiwygWindow.addEventListener("mouseup",f.onMouseUp_wysiwyg); | ||
a.element.wysiwygWindow.addEventListener("keydown",f.onKeyDown_wysiwyg);a.element.wysiwygWindow.addEventListener("keyup",f.onKeyUp_wysiwyg);a.element.wysiwygWindow.addEventListener("scroll",f.onScroll_wysiwyg);a.element.wysiwygWindow.addEventListener("drop",f.onDrop_wysiwyg);a.element.resizebar.addEventListener("mousedown",f.onMouseDown_resizeBar);window.addEventListener("resize",f.resize_window);return{save:function(){a.element.textElement.innerHTML=c._variable.wysiwygActive?a.element.wysiwygWindow.document.body.innerHTML: | ||
a.element.code.value},getContent:function(){var b="";return 0===a.element.wysiwygWindow.document.body.innerText.trim().length?b:b=c._variable.wysiwygActive?a.element.wysiwygWindow.document.body.innerHTML:a.element.code.value},setContent:function(b){b=A(b);c._variable.wysiwygActive?a.element.wysiwygWindow.document.body.innerHTML=b:a.element.code.value=b},appendContent:function(b){if(c._variable.wysiwygActive){var d=document.createElement("P");d.innerHTML=b;a.element.wysiwygWindow.document.body.appendChild(d)}else a.element.code.value+= | ||
b},disabled:function(){a.tool.cover.style.display="block";a.element.wysiwygWindow.document.body.setAttribute("contenteditable",!1)},enabled:function(){a.tool.cover.style.display="none";a.element.wysiwygWindow.document.body.setAttribute("contenteditable",!0)},show:function(){var b=a.element.topArea.style;b.cssText=c._variable.originCssText;"none"===b.display&&(b.display="block")},hide:function(){a.element.topArea.style.display="none"},destroy:function(){a.element.topArea.parentNode.removeChild(a.element.topArea); | ||
a.element.textElement.style.display="";this.destroy=this.hide=this.show=this.enabled=this.disabled=this.appendContent=this.setContent=this.getContent=this.save=null}}};SUNEDITOR.lang=SUNEDITOR.lang||SUNEDITOR.defaultLang;SUNEDITOR.create=function(a,d){var e=document.getElementById(a);if(null===e)throw Error('[SUNEDITOR.create.fail] The element for that id was not found (ID:"'+a+'")');var c=C(e,d);if(document.getElementById(c.constructed._top.id))throw Error('[SUNEDITOR.create.fail] The ID of the suneditor you are trying to create already exists (ID:"'+ | ||
!1,null);break;case "preview":c.preview();break;case "print":a.element.wysiwygWindow.print();break;default:c.execCommand(e,!1,f),d.toggleClass(g,"on")}c.submenuOff()}},onMouseUp_wysiwyg:function(a){a.stopPropagation();c._setSelectionNode();var b=a.target;c.submenuOff();/^HTML$/i.test(b.nodeName)?(a.preventDefault(),c.focus()):/^IMG$/i.test(b.nodeName)?(a.preventDefault(),c.callModule("dialog","image",null,function(){SUNEDITOR.plugin.image.call_controller_imageResize.call(c,b)})):f._findButtonEffectTag()}, | ||
onKeyDown_wysiwyg:function(b){c._setSelectionNode();var g=b.keyCode,e=b.shiftKey,v=b.ctrlKey||b.metaKey,k=b.altKey;b.stopPropagation();if(v&&!/^(?:16|17|18)$/.test(g)){var m;if(m=!(e&&83!==g))(m=f._shortcutKeyCode[g])?(c.execCommand(m[0],!1,null),d.toggleClass(c.commandMap[m[1]],"on"),m=!0):m=!1;if(m){b.preventDefault();return}}switch(g){case 8:if(/^P$/i.test(c._variable.selectionNode.tagName)&&null===c._variable.selectionNode.previousSibling)return b.preventDefault(),!1;break;case 9:if(b.preventDefault(), | ||
!v&&!k){for(b=c._variable.selectionNode||c.getSelection().anchorNode;!/^TD$/i.test(b.tagName)&&!/^BODY$/i.test(b.tagName);)b=b.parentNode;if(b&&/^TD$/i.test(b.tagName)){g=d.getParentNode(b,"table");g=d.getListChildren(g,d.isCell);b=e?d.prevIdx(g,b):d.nextIdx(g,b);b!==g.length||e||(b=0);-1===b&&e&&(b=g.length-1);e=g[b];if(!e)return!1;b=c.createRange();b.setStart(e,0);b.setEnd(e,0);e=c.getSelection();0<e.rangeCount&&e.removeAllRanges();e.addRange(b)}else e||(b=a.element.wysiwygWindow.document.createTextNode(Array(c._variable.tabSize+ | ||
1).join("\u00a0")),c.insertNode(b,null),e=c.getSelection(),g=c.createRange(),g.setStart(b,c._variable.tabSize),g.setEnd(b,c._variable.tabSize),0<e.rangeCount&&e.removeAllRanges(),e.addRange(g))}}},onKeyUp_wysiwyg:function(a){c._setSelectionNode();f._directionKeyKeyCode.test(a.keyCode)&&f._findButtonEffectTag()},onScroll_wysiwyg:function(){c.controllersOff()},onDrop_wysiwyg:function(a){var b=a.dataTransfer.files;if(0===b.length)return!0;a.stopPropagation();a.preventDefault();c.focus();c.callModule("dialog", | ||
"image",null,function(){c.context.image.imgInputFile.files=b;SUNEDITOR.plugin.image.onRender_imgInput.call(c);c.context.image.imgInputFile.files=null})},onMouseDown_resizeBar:function(b){function d(){a.element.resizeBackground.style.display="none";document.removeEventListener("mousemove",f.resize_editor);document.removeEventListener("mouseup",d)}b.stopPropagation();c._variable.resizeClientY=b.clientY;a.element.resizeBackground.style.display="block";document.addEventListener("mousemove",f.resize_editor); | ||
document.addEventListener("mouseup",d)},resize_editor:function(b){var d=b.clientY-c._variable.resizeClientY;a.element.editorArea.style.height=a.element.editorArea.offsetHeight+d+"px";c._variable.editorHeight=a.element.editorArea.offsetHeight+d;c._variable.resizeClientY=b.clientY}};a.tool.bar.addEventListener("touchstart",f.touchstart_toolbar);a.tool.bar.addEventListener("touchmove",f.touchmove_toolbar);a.tool.bar.addEventListener("touchend",f.onClick_toolbar);a.tool.bar.addEventListener("click",f.onClick_toolbar); | ||
a.element.wysiwygWindow.addEventListener("mouseup",f.onMouseUp_wysiwyg);a.element.wysiwygWindow.addEventListener("keydown",f.onKeyDown_wysiwyg);a.element.wysiwygWindow.addEventListener("keyup",f.onKeyUp_wysiwyg);a.element.wysiwygWindow.addEventListener("scroll",f.onScroll_wysiwyg);a.element.wysiwygWindow.addEventListener("drop",f.onDrop_wysiwyg);a.element.resizebar.addEventListener("mousedown",f.onMouseDown_resizeBar);window.addEventListener("resize",f.resize_window);return{save:function(){a.element.textElement.innerHTML= | ||
c._variable.wysiwygActive?a.element.wysiwygWindow.document.body.innerHTML:a.element.code.value},getContent:function(){var b="";return 0===a.element.wysiwygWindow.document.body.innerText.trim().length?b:b=c._variable.wysiwygActive?a.element.wysiwygWindow.document.body.innerHTML:a.element.code.value},setContent:function(b){b=A(b);c._variable.wysiwygActive?a.element.wysiwygWindow.document.body.innerHTML=b:a.element.code.value=b},appendContent:function(b){if(c._variable.wysiwygActive){var d=document.createElement("P"); | ||
d.innerHTML=b;a.element.wysiwygWindow.document.body.appendChild(d)}else a.element.code.value+=b},disabled:function(){a.tool.cover.style.display="block";a.element.wysiwygWindow.document.body.setAttribute("contenteditable",!1)},enabled:function(){a.tool.cover.style.display="none";a.element.wysiwygWindow.document.body.setAttribute("contenteditable",!0)},show:function(){var b=a.element.topArea.style;b.cssText=c._variable.originCssText;"none"===b.display&&(b.display="block")},hide:function(){a.element.topArea.style.display= | ||
"none"},destroy:function(){a.element.topArea.parentNode.removeChild(a.element.topArea);a.element.textElement.style.display="";this.destroy=this.hide=this.show=this.enabled=this.disabled=this.appendContent=this.setContent=this.getContent=this.save=null}}};SUNEDITOR.lang=SUNEDITOR.lang||SUNEDITOR.defaultLang;SUNEDITOR.create=function(a,d){var e=document.getElementById(a);if(null===e)throw Error('[SUNEDITOR.create.fail] The element for that id was not found (ID:"'+a+'")');var c=C(e,d);if(document.getElementById(c.constructed._top.id))throw Error('[SUNEDITOR.create.fail] The ID of the suneditor you are trying to create already exists (ID:"'+ | ||
c.constructed._top.id+'")');e.style.display="none";"object"===typeof e.nextElementSibling?e.parentNode.insertBefore(c.constructed._top,e.nextElementSibling):e.parentNode.appendChild(c.constructed._top);var f=c.constructed;c=c.options;e={element:{textElement:e,topArea:f._top,relative:f._relative,resizebar:f._resizeBar,editorArea:f._editorArea,wysiwygWindow:f._editorArea.getElementsByClassName("sun-editor-id-wysiwyg")[0].contentWindow,wysiwygElement:f._editorArea.getElementsByClassName("sun-editor-id-wysiwyg")[0], | ||
@@ -64,0 +64,0 @@ code:f._editorArea.getElementsByClassName("sun-editor-id-code")[0],loading:f._loading,resizeBackground:f._resizeBack},tool:{bar:f._toolBar,cover:f._toolBar.getElementsByClassName("sun-editor-id-toolbar-cover")[0],bold:f._toolBar.getElementsByClassName("sun-editor-id-bold")[0],underline:f._toolBar.getElementsByClassName("sun-editor-id-underline")[0],italic:f._toolBar.getElementsByClassName("sun-editor-id-italic")[0],strike:f._toolBar.getElementsByClassName("sun-editor-id-strike")[0],font:f._toolBar.getElementsByClassName("sun-editor-font-family")[0], |
Sorry, the diff of this file is too big to display
2010479
34310