|
|
|
@ -51,11 +51,10 @@ function applyMd(e, t) { |
|
|
|
|
box.selectionStart = selectionStart - startPattern.length; |
|
|
|
|
box.selectionEnd = selectionEnd + endPattern.length; |
|
|
|
|
|
|
|
|
|
if (document.execCommand) { |
|
|
|
|
document.execCommand('insertText', false, selectedText); |
|
|
|
|
} else { |
|
|
|
|
if (!document.execCommand || !document.execCommand('insertText', false, selectedText)) { |
|
|
|
|
box.value = initText.substr(0, initText.length - startPattern.length) + selectedText + finalText.substr(endPattern.length); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
box.selectionStart = selectionStart - startPattern.length; |
|
|
|
|
box.selectionEnd = box.selectionStart + selectedText.length; |
|
|
|
|
$(box).change(); |
|
|
|
@ -68,11 +67,10 @@ function applyMd(e, t) { |
|
|
|
|
apply pattern |
|
|
|
|
restore selection |
|
|
|
|
*/ |
|
|
|
|
if (document.execCommand) { |
|
|
|
|
document.execCommand('insertText', false, this.pattern.replace('{{text}}', selectedText)); |
|
|
|
|
} else { |
|
|
|
|
if (!document.execCommand || !document.execCommand('insertText', false, this.pattern.replace('{{text}}', selectedText))) { |
|
|
|
|
box.value = initText + this.pattern.replace('{{text}}', selectedText) + finalText; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
box.selectionStart = selectionStart + this.pattern.indexOf('{{text}}'); |
|
|
|
|
box.selectionEnd = box.selectionStart + selectedText.length; |
|
|
|
|
$(box).change(); |
|
|
|
|