Matty999555 Posted June 27, 2010 Share Posted June 27, 2010 I found this great peice of code: http://wysiwygbbcode.codeplex.com/ I have added a few extra functions into but I can't work out how this one line works: myeditor.execCommand("CreateLink", false, mylink); heres the code so far: http://pastebin.com/Axe6emk9 Thanks EDIT: As it contains BBCode i screwed the page. Quote Link to comment Share on other sites More sharing options...
Matty999555 Posted June 27, 2010 Author Share Posted June 27, 2010 Fixed the Mail function: function doMail() { if (editorVisible) { ifm.contentWindow.focus(); var mylink = prompt("Enter an Email:", ""); var mylink = "mailto:" + mylink; if ((mylink != null) && (mylink != "")) { if (isIE) { //IE var range = ifm.contentWindow.document.selection.createRange(); if (range.text == '') { range.pasteHTML("<a href='" + mylink + "'>" + mylink + "</a>"); } else myeditor.execCommand("CreateLink", false, mylink); } else if (window.getSelection) { //FF var userSelection = ifm.contentWindow.getSelection().getRangeAt(0); if(userSelection.toString().length==0) myeditor.execCommand('inserthtml', false, "<a href='" + mylink + "'>" + mylink + "</a>"); else myeditor.execCommand("CreateLink", false, mylink); } else myeditor.execCommand("CreateLink", false, mylink); } } else { AddTag('[url=mailto:',']click here[/url]'); } } Quote Link to comment Share on other sites More sharing options...
Matty999555 Posted June 27, 2010 Author Share Posted June 27, 2010 Now works almost perfectly, todo: text-size quote Quote Link to comment Share on other sites More sharing options...
Matty999555 Posted June 27, 2010 Author Share Posted June 27, 2010 Fixed Text Size: function doSize() { if (editorVisible) { ifm.contentWindow.focus(); var mylink = prompt("Enter a text-size:", "14px"); if ((mylink != null) && (mylink != "")) { if (isIE) { //IE var range = ifm.contentWindow.document.selection.createRange(); if (range.text == '') { range.pasteHTML("<span style=\"font-size: " + mylink + ";\"></span>"); } else myeditor.execCommand('inserthtml', false, "<span style=\"font-size: " + mylink + ";\">" + range.text + "</span>"); } else if (window.getSelection) { //FF var userSelection = ifm.contentWindow.getSelection().getRangeAt(0); if(userSelection.toString().length==0) myeditor.execCommand('inserthtml', false, "<span style=\"font-size: " + mylink + ";\">" + userSelection.toString() + "</span>"); else myeditor.execCommand('inserthtml', false, "<span style=\"font-size: " + mylink + ";\">" + userSelection.toString() + "</span>"); } else myeditor.execCommand('inserthtml', false, "<span style=\"font-size: " + mylink + ";\">" + userSelection.toString() + "</span>"); } } else { AddTag('[size=]','[/size]'); } } Quote Link to comment Share on other sites More sharing options...
Matty999555 Posted June 27, 2010 Author Share Posted June 27, 2010 The Quote doesn't work while in wysiwyg mode function doQuote() { if (editorVisible) { ifm.contentWindow.focus(); if (isIE) { //IE var range = ifm.contentWindow.document.selection.createRange(); if (range.text == '') { range.pasteHTML("<blockquote></blockquote>"); } else myeditor.execCommand('inserthtml', false, "<blockquote>" + range.text + "</blockquote>"); } else if (window.getSelection) { //FF var userSelection = ifm.contentWindow.getSelection().getRangeAt(0); if(userSelection.toString().length==0) myeditor.execCommand('inserthtml', false, "<blockquote>" + userSelection.toString() + "</blockquote>"); else myeditor.execCommand('inserthtml', false, "<blockquote>" + userSelection.toString() + "</blockquote>"); } else myeditor.execCommand('inserthtml', false, "<blockquote>" + userSelection.toString() + "</blockquote>"); } else { AddTag('[quote]', '[/quote]'); } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.