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. Link to comment https://forums.phpfreaks.com/topic/205982-jitbit-wyswyg-bbcode-editor/ 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]'); } } Link to comment https://forums.phpfreaks.com/topic/205982-jitbit-wyswyg-bbcode-editor/#findComment-1077831 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 Link to comment https://forums.phpfreaks.com/topic/205982-jitbit-wyswyg-bbcode-editor/#findComment-1077832 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]'); } } Link to comment https://forums.phpfreaks.com/topic/205982-jitbit-wyswyg-bbcode-editor/#findComment-1077834 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]'); } } Link to comment https://forums.phpfreaks.com/topic/205982-jitbit-wyswyg-bbcode-editor/#findComment-1077840 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.