diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100644 new mode 100755 index cbdcf88..9e6276e --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,55 +1,191 @@ -markItUp! 1.1.9 +# Changelog +All notable changes to **markItUp!** will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). + +## [Unreleased] + +### Changed + +- Changelog is now based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) + +### Fixed + +- Fixed invalid meta in bower.json + +## [1.1.15] - 2018-08-16 + +### Added + +- Allow Custom tags to button name +- Added HTTP method config for AJAX preview request +- Added support for jQuery 2 and 3 +- Added MIT license +- Added bower.json + +### Changed + +- markItUpRemove function is now idempotent + +### Fixed + +- avoid global namespace pollution +- Never use empty href in links + +## [1.1.14] - 2013-02-04 + +### Changed + +- Compatibility patch for jQuery 1.9+ +- Click on menu bubbles up so it could be reused (michilehr) + +### Fixed + +- Fixed default selection after using a tag having either openBlockWith or closeBlockWith (r3c) + +## [1.1.13] - 2012-08-30 + +### Added + +- Added ability to render preview in a DOM element (ytjohn & jaysalvat) +- Added the previewHandler option to allow complete control over preview (lecterror) +- Added `$(elm).markItUp('insert', { })` and `$(elm).markItUp('remove');` +- Added package.json + +### Changed + +- Updated events to use namespace (JoyceBabu) +- Updated the demo + +### Fixed + +- Fixed Ctrl+Enter syntax error (UltCombo) + +## [1.1.12] - 2011-08-11 + +### Changed + +- Enhanced the trailing space management + +### Fixed + +- Fixed the insertion on empty selection + +## [1.1.11] - 2011-07-19 + +### Added + +- Enabled parsing the markup in javascript (amroth) +- Added multiline support (alevchuk) +- Added quotes to attribute selectors +- Added metakey support for Mac users (michal-krause) + +### Changed + +- Updated with jQuery 1.6.2 + +### Fixed + +- Tried to fix the endless IE caret position bug + +## [1.1.10] - 2011-02-20 + +### Changed -CHANGE LOG -markItUp! 1.1.10 2011-02-20 - Improved: Ajax property 'dataType' set to 'text' - Improved: Ajax property 'global' set to 'false' + +### Fixed + - Fixed: Ctrl+click selection problem -markItUp! 1.1.9 2010-11-04 +## [1.1.9] - 2010-11-04 + +### Changed + - Improved: Selection accuracy in Internet Explorer - Improved: Replace focusin() by bind('focusin') to solve some backward compatibility issues (Nick B. C.) - Cosmetic: Add new logo - Cosmetic: Remove jQuery library and use CDN -markItUp! 1.1.8 2010-08-27 +## [1.1.8] - 2010-08-27 + +### Changed + - Improved: Some skin PNG have been optimized (lukescammell) -- Fixed: Opera 10 selection bug (Marius G.) -- Fixed: Accessibility issue with the background default color in the default skin - Improved: Avoid giving the preview focus each time autorefresh kicks in. It still gets the focus when the preview button is pressed (DrSlump) - Improved: In pop-up mode the preview is closed when the page containing the editor is unloaded (DrSlump) - Improved: Press TAB jump right inside the textarea (Yakir) -markItUp! 1.1.7 2010-04-06 +### Fixed + +- Fixed: Opera 10 selection bug (Marius G.) +- Fixed: Accessibility issue with the background default color in the default skin + +## [1.1.7] - 2010-04-06 + +### Fixed + - Fixed: Empty lines are removed at insertion on Webkit - Fixed: Focus lost when shortcut is used on FF - Fixed: var missing before $$ in markItUpRemove() -markItUp! 1.1.6 2010-01-12 +## 1.1.6.1 - 2010-03-02 + +### Added + +- Git is used for versioning and tagging + +## 1.1.6 - 2010-01-12 + +### Changed + - Improved: Ajax requests are now asynchronous + +### Fixed + - Fixed: Double empty line problem with preview and parsers - Fixed: IE8 now close the preview properly -markItUp! 1.1.5 2009-05-01 +## 1.1.5 - 2009-05-01 + +### Changed + - Modified: http://drupal.org/project/wysiwyg compatibility - Modified: Alt/Ctrl/Alt+Tab are now disabled -markItUp! 1.1.4 2008-12-03 +## 1.1.4 - 2008-12-03 + +### Fixed + - Fixed: Extra quote deleted line 95 -markItUp! 1.1.3 2008-09-12 +## 1.1.3 - 2008-09-12 + +### Fixed + - Fixed: IE7 preview problem -markItUp! 1.1.2 2008-07-17 +## 1.1.2 - 2008-07-17 + +### Fixed + - Fixed: Quick fix for Opera 9.5 caret position problem after insertion -markItUp! 1.1.1 2008-06-02 -- Fixed: Key events status are passed to callbacks properly +## 1.1.1 - 2008-06-02 + +### Changed + - Improved: ScrollPosition is kept in the preview when its refreshed -markItUp! 1.1.0 2008-05-04 -- Modified: Textarea's id is no more moved to the main container -- Modified: NameSpace Span become a Div to remain strict +### Fixed + +- Fixed: Key events status are passed to callbacks properly + +## 1.1.0 - 2008-05-04 + +### Added + - Added: Relative path to the script is computed - Added: Relative path to the script passed to callbacks - Added: Global instance ID property @@ -57,14 +193,20 @@ markItUp! 1.1.0 2008-05-04 - Added: Resize handle is now optional with resizeHandle property - Added: Property previewInWindow is added and accept window parameter - Added: Property previewPosition is added + +### Changed + +- Modified: Textarea's id is no more moved to the main container +- Modified: NameSpace Span become a Div to remain strict - Modified: Resize handle is no more displayed in Safari to avoid repetition with the native handle - Modified: Property previewIframeRefresh become previewAutorefresh - Modified: Built-in Html Preview call a template file - Improved: Autorefreshing is now apply for preview in window too - Improved: Cancel button in prompt window cancel now the whole insertion process - Improved: Cleaner markItUp! code added to the DOM -- Removed: Depreciated preview properties as previewBaseUrl, previewCharset, previewCssPath, previewBodyId, previewBodyClassName -- Removed: Property previewIframe not longer exists + +### Fixed + - Fixed: "Magic markups" works with line feeds - Fixed: Key events are initialized after insertion - Fixed: Internet Explorer line feed offset bug @@ -73,19 +215,56 @@ markItUp! 1.1.0 2008-05-04 - Fixed: Ctrl+click works and doesn't open the page in a new tab anymore - Fixed: Minor Css modifications -markItUp! 1.0.3 2008-04-04 +### Removed + +- Removed: Depreciated preview properties as previewBaseUrl, previewCharset, previewCssPath, previewBodyId, previewBodyClassName +- Removed: Property previewIframe not longer exists + +## 1.0.3 - 2008-04-04 + +### Added + +- Added: Property scrollPosition is passed to callbacks functions + +### Fixed + - Fixed: IE7 Preview empty baseurl problem - Fixed: IE7 external targeted insertion -- Added: Property scrollPosition is passed to callbacks functions -markItUp! 1.0.2 2008-03-31 +## 1.0.2 - 2008-03-31 + +### Changed + +- Improved: Code minified + +### Fixed + - Fixed: IE7 Html preview problems - Fixed: Selection is kept if nothing is inserted -- Improved: Code minified -markItUp! 1.0.1 2008-03-21 -- Removed: Global PlaceHolder +## 1.0.1 - 2008-03-21 + +### Changed + - Modified: Property previewCharset is setted to "utf-8" by default -markItUp! 1.0.0 2008-03-01 +### Removed + +- Removed: Global PlaceHolder + +## 1.0.0 - 2008-03-01 + +### Added + - First public release + +[Unreleased]: https://github.com/markitup/1.x/compare/1.1.15...HEAD +[1.1.15]: https://github.com/markitup/1.x/compare/1.1.14...1.1.15 +[1.1.14]: https://github.com/markitup/1.x/compare/1.1.13...1.1.14 +[1.1.13]: https://github.com/markitup/1.x/compare/1.1.12...1.1.13 +[1.1.12]: https://github.com/markitup/1.x/compare/1.1.11...1.1.12 +[1.1.11]: https://github.com/markitup/1.x/compare/1.1.10...1.1.11 +[1.1.10]: https://github.com/markitup/1.x/compare/1.1.9...1.1.10 +[1.1.9]: https://github.com/markitup/1.x/compare/1.1.8...1.1.9 +[1.1.8]: https://github.com/markitup/1.x/compare/1.1.7...1.1.8 +[1.1.7]: https://github.com/markitup/1.x/compare/1.1.6.1...1.1.7 diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..f0fd20a --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..3a12468 --- /dev/null +++ b/bower.json @@ -0,0 +1,16 @@ +{ + "name": "markitup", + "version": "1.1.15", + "main": [ "markitup/jquery.markitup.js" ], + "ignore": [ + "markitup/templates/*", + "node_modules", + "bower_components", + "test", + "tests", + "vendor" + ], + "dependencies": { + "jquery": ">=1.4.2" + } +} diff --git a/images/body.png b/images/body.png old mode 100644 new mode 100755 diff --git a/images/jaysalvat.png b/images/jaysalvat.png old mode 100644 new mode 100755 diff --git a/images/markitup.png b/images/markitup.png old mode 100644 new mode 100755 diff --git a/images/style.css b/images/style.css old mode 100644 new mode 100755 diff --git a/index.html b/index.html old mode 100644 new mode 100755 index 38fc339..5651d28 --- a/index.html +++ b/index.html @@ -1,36 +1,49 @@ - - + + - -markItUp! Universal markup editor - - - - - - - - - - - + + markItUp! Universal markup editor + + + + + + + + + + + +

markItUp!

+

By Jay Salvat

+

Downloads, examples and documentation at http://markitup.jaysalvat.com.

+

Click this link to insert content from anywhere in the page or this one to remove markItUp!

+ +

Support the project : Donate | Contact

+ -

markItUp!

-

By Jay Salvat

-

Downloads, examples and documentation at http://markitup.jaysalvat.com.

-

Click this link to insert content from anywhere in the page or this one to remove markItUp!

-

- -

-

Support the projet : Donate | Contact

diff --git a/markitup/jquery.markitup.js b/markitup/jquery.markitup.js old mode 100644 new mode 100755 index 8c69b78..68d131d --- a/markitup/jquery.markitup.js +++ b/markitup/jquery.markitup.js @@ -3,7 +3,7 @@ // v 1.1.x // Dual licensed under the MIT and GPL licenses. // ---------------------------------------------------------------------------- -// Copyright (C) 2007-2010 Jay Salvat +// Copyright (C) 2007-2012 Jay Salvat // http://markitup.jaysalvat.com/ // ---------------------------------------------------------------------------- // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,18 +26,26 @@ // ---------------------------------------------------------------------------- (function($) { $.fn.markItUp = function(settings, extraSettings) { - var options, ctrlKey, shiftKey, altKey; - ctrlKey = shiftKey = altKey = false; - + var method, params, options, ctrlKey, shiftKey, altKey; ctrlKey = shiftKey = altKey = false; + + if (typeof settings == 'string') { + method = settings; + params = extraSettings; + } + options = { id: '', nameSpace: '', root: '', + previewHandler: false, previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes' + previewInElement: '', previewAutoRefresh: true, previewPosition: 'after', previewTemplatePath: '~/templates/preview.html', + previewParser: false, previewParserPath: '', previewParserVar: 'data', + previewParserAjaxType: 'POST', resizeHandle: true, beforeInsert: '', afterInsert: '', @@ -52,13 +60,42 @@ // compute markItUp! path if (!options.root) { $('script').each(function(a, tag) { - miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/); + var miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/); if (miuScript !== null) { options.root = miuScript[1]; } }); } + // Quick patch to keep compatibility with jQuery 1.9 + var uaMatch = function(ua) { + ua = ua.toLowerCase(); + + var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || + /(webkit)[ \/]([\w.]+)/.exec(ua) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || + /(msie) ([\w.]+)/.exec(ua) || + ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || + []; + + return { + browser: match[ 1 ] || "", + version: match[ 2 ] || "0" + }; + }; + var matched = uaMatch( navigator.userAgent ); + var browser = {}; + + if (matched.browser) { + browser[matched.browser] = true; + browser.version = matched.version; + } + if (browser.chrome) { + browser.webkit = true; + } else if (browser.webkit) { + browser.safari = true; + } + return this.each(function() { var $$, textarea, levels, scrollPosition, caretPosition, caretOffset, clicked, hash, header, footer, previewWindow, template, iFrame, abort; @@ -72,6 +109,20 @@ options.previewParserPath = localize(options.previewParserPath); options.previewTemplatePath = localize(options.previewTemplatePath); + if (method) { + switch(method) { + case 'remove': + remove(); + break; + case 'insert': + markup(params); + break; + default: + $.error('Method ' + method + ' does not exist on jQuery.markItUp'); + } + return; + } + // apply the computed path to ~/ function localize(data, inText) { if (inText) { @@ -105,29 +156,29 @@ footer = $('
').insertAfter($$); // add the resize handle after textarea - if (options.resizeHandle === true && $.browser.safari !== true) { + if (options.resizeHandle === true && browser.safari !== true) { resizeHandle = $('
') .insertAfter($$) - .bind("mousedown", function(e) { + .bind("mousedown.markItUp", function(e) { var h = $$.height(), y = e.clientY, mouseMove, mouseUp; mouseMove = function(e) { $$.css("height", Math.max(20, e.clientY+h-y)+"px"); return false; }; mouseUp = function(e) { - $("html").unbind("mousemove", mouseMove).unbind("mouseup", mouseUp); + $("html").unbind("mousemove.markItUp", mouseMove).unbind("mouseup.markItUp", mouseUp); return false; }; - $("html").bind("mousemove", mouseMove).bind("mouseup", mouseUp); + $("html").bind("mousemove.markItUp", mouseMove).bind("mouseup.markItUp", mouseUp); }); footer.append(resizeHandle); } // listen key events - $$.keydown(keyPressed).keyup(keyPressed); + $$.bind('keydown.markItUp', keyPressed).bind('keyup', keyPressed); // bind an event to catch external calls - $$.bind("insertion", function(e, settings) { + $$.bind("insertion.markItUp", function(e, settings) { if (settings.target !== false) { get(); } @@ -137,9 +188,13 @@ }); // remember the last focus - $$.focus(function() { + $$.bind('focus.markItUp', function() { $.markItUp.focused = this; }); + + if (options.previewInElement) { + refreshPreview(); + } } // recursively build header with dropMenus from markupset @@ -148,7 +203,7 @@ $('li:hover > ul', ul).css('display', 'block'); $.each(markupSet, function() { var button = this, t = '', title, li, j; - title = (button.key) ? (button.name||'')+' [Ctrl+'+button.key+']' : (button.name||''); + button.title ? title = (button.key) ? (button.title||'')+' [Ctrl+'+button.key+']' : (button.title||'') : title = (button.key) ? (button.name||'')+' [Ctrl+'+button.key+']' : (button.name||''); key = (button.key) ? 'accesskey="'+button.key+'"' : ''; if (button.separator) { li = $('
  • '+(button.separator||'')+'
  • ').appendTo(ul); @@ -157,29 +212,28 @@ for (j = levels.length -1; j >= 0; j--) { t += levels[j]+"-"; } - li = $('
  • '+(button.name||'')+'
  • ') - .bind("contextmenu", function() { // prevent contextmenu on mac and allow ctrl+click + li = $('
  • '+(button.name||'')+'
  • ') + .bind("contextmenu.markItUp", function() { // prevent contextmenu on mac and allow ctrl+click return false; - }).click(function() { - return false; - }).bind("focusin", function(){ + }).bind('click.markItUp', function(e) { + e.preventDefault(); + }).bind("focusin.markItUp", function(){ $$.focus(); - }).mousedown(function() { + }).bind('mouseup', function(e) { if (button.call) { - eval(button.call)(); + eval(button.call)(e); // Pass the mouseup event to custom delegate } setTimeout(function() { markup(button) },1); return false; - }).hover(function() { + }).bind('mouseenter.markItUp', function() { $('> ul', this).show(); $(document).one('click', function() { // close dropmenu if click outside $('ul ul', header).hide(); } ); - }, function() { + }).bind('mouseleave.markItUp', function() { $('> ul', this).hide(); - } - ).appendTo(ul); + }).appendTo(ul); if (button.dropMenu) { levels.push(i); $(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu)); @@ -233,27 +287,49 @@ // build block to insert function build(string) { - var openWith = prepare(clicked.openWith); - var placeHolder = prepare(clicked.placeHolder); - var replaceWith = prepare(clicked.replaceWith); - var closeWith = prepare(clicked.closeWith); + var openWith = prepare(clicked.openWith); + var placeHolder = prepare(clicked.placeHolder); + var replaceWith = prepare(clicked.replaceWith); + var closeWith = prepare(clicked.closeWith); + var openBlockWith = prepare(clicked.openBlockWith); + var closeBlockWith = prepare(clicked.closeBlockWith); + var multiline = clicked.multiline; + if (replaceWith !== "") { block = openWith + replaceWith + closeWith; } else if (selection === '' && placeHolder !== '') { block = openWith + placeHolder + closeWith; } else { - string = string || selection; - if (string.match(/ $/)) { - block = openWith + string.replace(/ $/, '') + closeWith + ' '; - } else { - block = openWith + string + closeWith; + string = string || selection; + + var lines = [string], blocks = []; + + if (multiline === true) { + lines = string.split(/\r?\n/); + } + + for (var l = 0; l < lines.length; l++) { + line = lines[l]; + var trailingSpaces; + if (trailingSpaces = line.match(/ *$/)) { + blocks.push(openWith + line.replace(/ *$/g, '') + closeWith + trailingSpaces); + } else { + blocks.push(openWith + line + closeWith); + } } + + block = blocks.join("\n"); } + + block = openBlockWith + block + closeBlockWith; + return { block:block, + openBlockWith:openBlockWith, openWith:openWith, replaceWith:replaceWith, placeHolder:placeHolder, - closeWith:closeWith + closeWith:closeWith, + closeBlockWith:closeBlockWith }; } @@ -262,7 +338,6 @@ var len, j, n, i; hash = clicked = button; get(); - $.extend(hash, { line:"", root:options.root, textarea:textarea, @@ -276,12 +351,12 @@ // callbacks before insertion prepare(options.beforeInsert); prepare(clicked.beforeInsert); - if (ctrlKey === true && shiftKey === true) { + if ((ctrlKey === true && shiftKey === true) || button.multiline === true) { prepare(clicked.beforeMultiInsert); } $.extend(hash, { line:1 }); - - if (ctrlKey === true && shiftKey === true) { + + if ((ctrlKey === true && shiftKey === true)) { lines = selection.split(/\r?\n/); for (j = 0, n = lines.length, i = 0; i < n; i++) { if ($.trim(lines[i]) !== '') { @@ -291,9 +366,10 @@ lines[i] = ""; } } + string = { block:lines.join('\n')}; start = caretPosition; - len = string.block.length + (($.browser.opera) ? n-1 : 0); + len = string.block.length + ((browser.opera) ? n-1 : 0); } else if (ctrlKey === true) { string = build(selection); start = caretPosition + string.openWith.length; @@ -314,8 +390,8 @@ if ((selection === '' && string.replaceWith === '')) { caretOffset += fixOperaBug(string.block); - start = caretPosition + string.openWith.length; - len = string.block.length - string.openWith.length - string.closeWith.length; + start = caretPosition + string.openBlockWith.length + string.openWith.length; + len = string.block.length - string.openBlockWith.length - string.openWith.length - string.closeWith.length - string.closeBlockWith.length; caretOffset = $$.val().substring(caretPosition, $$.val().length).length; caretOffset -= fixOperaBug($$.val().substring(0, caretPosition)); @@ -333,7 +409,7 @@ $.extend(hash, { line:'', selection:selection }); // callbacks after insertion - if (ctrlKey === true && shiftKey === true) { + if ((ctrlKey === true && shiftKey === true) || button.multiline === true) { prepare(clicked.afterMultiInsert); } prepare(clicked.afterInsert); @@ -343,6 +419,9 @@ if (previewWindow && options.previewAutoRefresh) { refreshPreview(); } + + // Triggers an input event to allow other scripts to react. + textarea.dispatchEvent(new Event('input')); // reinit keyevent shiftKey = altKey = ctrlKey = abort = false; @@ -350,15 +429,15 @@ // Substract linefeed in Opera function fixOperaBug(string) { - if ($.browser.opera) { + if (browser.opera) { return string.length - string.replace(/\n*/g, '').length; } return 0; } // Substract linefeed in IE function fixIeBug(string) { - if ($.browser.msie) { - return string.length - string.replace(/\r/g, '').length; + if (browser.msie) { + return string.length - string.replace(/\r*/g, '').length; } return 0; } @@ -377,7 +456,7 @@ function set(start, len) { if (textarea.createTextRange){ // quick fix to make it work on Opera 9.5 - if ($.browser.opera && $.browser.version >= 9.5 && len == 0) { + if (browser.opera && browser.version >= 9.5 && len == 0) { return false; } range = textarea.createTextRange(); @@ -398,21 +477,21 @@ scrollPosition = textarea.scrollTop; if (document.selection) { - selection = document.selection; - if ($.browser.msie) { // ie - var range = selection.createRange(); - var stored_range = range.duplicate(); - stored_range.moveToElementText(textarea); - stored_range.setEndPoint('EndToEnd', range); - var s = stored_range.text.length - range.text.length; - - caretPosition = s - (textarea.value.substr(0, s).length - textarea.value.substr(0, s).replace(/\r/g, '').length); - selection = range.text; + selection = document.selection.createRange().text; + if (browser.msie) { // ie + var range = document.selection.createRange(), rangeCopy = range.duplicate(); + rangeCopy.moveToElementText(textarea); + caretPosition = -1; + while(rangeCopy.inRange(range)) { + rangeCopy.moveStart('character'); + caretPosition ++; + } } else { // opera caretPosition = textarea.selectionStart; } } else { // gecko & webkit caretPosition = textarea.selectionStart; + selection = textarea.value.substring(caretPosition, textarea.selectionEnd); } return selection; @@ -420,7 +499,11 @@ // open preview window function preview() { - if (!previewWindow || previewWindow.closed) { + if (typeof options.previewHandler === 'function') { + previewWindow = true; + } else if (options.previewInElement) { + previewWindow = $(options.previewInElement); + } else if (!previewWindow || previewWindow.closed) { if (options.previewInWindow) { previewWindow = window.open('', 'preview', options.previewInWindow); $(window).unload(function() { @@ -456,15 +539,21 @@ renderPreview(); } - function renderPreview() { + function renderPreview() { var phtml; - if (options.previewParserPath !== '') { + var parsedData = $$.val(); + if (options.previewParser && typeof options.previewParser === 'function') { + parsedData = options.previewParser(parsedData); + } + if (options.previewHandler && typeof options.previewHandler === 'function') { + options.previewHandler(parsedData); + } else if (options.previewParserPath !== '') { $.ajax({ - type: 'POST', + type: options.previewParserAjaxType, dataType: 'text', global: false, url: options.previewParserPath, - data: options.previewParserVar+'='+encodeURIComponent($$.val()), + data: options.previewParserVar+'='+encodeURIComponent(parsedData), success: function(data) { writeInPreview( localize(data, 1) ); } @@ -476,7 +565,7 @@ dataType: 'text', global: false, success: function(data) { - writeInPreview( localize(data, 1).replace(//g, $$.val()) ); + writeInPreview( localize(data, 1).replace(//g, parsedData) ); } }); } @@ -485,7 +574,9 @@ } function writeInPreview(data) { - if (previewWindow.document) { + if (options.previewInElement) { + $(options.previewInElement).html(data); + } else if (previewWindow && previewWindow.document) { try { sp = previewWindow.document.documentElement.scrollTop } catch(e) { @@ -502,15 +593,15 @@ function keyPressed(e) { shiftKey = e.shiftKey; altKey = e.altKey; - ctrlKey = (!(e.altKey && e.ctrlKey)) ? e.ctrlKey : false; + ctrlKey = (!(e.altKey && e.ctrlKey)) ? (e.ctrlKey || e.metaKey) : false; if (e.type === 'keydown') { if (ctrlKey === true) { - li = $("a[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li'); + li = $('a[accesskey="'+((e.keyCode == 13) ? '\\n' : String.fromCharCode(e.keyCode))+'"]', header).parent('li'); if (li.length !== 0) { ctrlKey = false; setTimeout(function() { - li.triggerHandler('mousedown'); + li.triggerHandler('mouseup'); },1); return false; } @@ -547,14 +638,25 @@ } } + function remove() { + $$.unbind(".markItUp").removeClass('markItUpEditor'); + $$.parent('div').parent('div.markItUp').parent('div').replaceWith($$); + + var relativeRef = $$.parent('div').parent('div.markItUp').parent('div'); + if (relativeRef.length) { + relativeRef.replaceWith($$); + } + + $$.data('markItUp', null); + } + init(); }); }; $.fn.markItUpRemove = function() { return this.each(function() { - var $$ = $(this).unbind().removeClass('markItUpEditor'); - $$.parent('div').parent('div.markItUp').parent('div').replaceWith($$); + $(this).markItUp('remove'); } ); }; diff --git a/markitup/sets/default/images/bold.png b/markitup/sets/default/images/bold.png old mode 100644 new mode 100755 diff --git a/markitup/sets/default/images/clean.png b/markitup/sets/default/images/clean.png old mode 100644 new mode 100755 diff --git a/markitup/sets/default/images/image.png b/markitup/sets/default/images/image.png old mode 100644 new mode 100755 diff --git a/markitup/sets/default/images/italic.png b/markitup/sets/default/images/italic.png old mode 100644 new mode 100755 diff --git a/markitup/sets/default/images/link.png b/markitup/sets/default/images/link.png old mode 100644 new mode 100755 diff --git a/markitup/sets/default/images/list-bullet.png b/markitup/sets/default/images/list-bullet.png new file mode 100755 index 0000000..4a8672b Binary files /dev/null and b/markitup/sets/default/images/list-bullet.png differ diff --git a/markitup/sets/default/images/list-numeric.png b/markitup/sets/default/images/list-numeric.png new file mode 100755 index 0000000..33b0b8d Binary files /dev/null and b/markitup/sets/default/images/list-numeric.png differ diff --git a/markitup/sets/default/images/picture.png b/markitup/sets/default/images/picture.png old mode 100644 new mode 100755 diff --git a/markitup/sets/default/images/preview.png b/markitup/sets/default/images/preview.png old mode 100644 new mode 100755 diff --git a/markitup/sets/default/images/stroke.png b/markitup/sets/default/images/stroke.png old mode 100644 new mode 100755 diff --git a/markitup/sets/default/set.js b/markitup/sets/default/set.js old mode 100644 new mode 100755 index f3e08ff..b7fdf81 --- a/markitup/sets/default/set.js +++ b/markitup/sets/default/set.js @@ -1,27 +1,30 @@ -// ---------------------------------------------------------------------------- -// markItUp! -// ---------------------------------------------------------------------------- -// Copyright (C) 2008 Jay Salvat -// http://markitup.jaysalvat.com/ -// ---------------------------------------------------------------------------- -// Html tags -// http://en.wikipedia.org/wiki/html -// ---------------------------------------------------------------------------- -// Basic set. Feel free to add more tags -// ---------------------------------------------------------------------------- -mySettings = { - onShiftEnter: {keepDefault:false, replaceWith:'
    \n'}, - onCtrlEnter: {keepDefault:false, openWith:'\n

    ', closeWith:'

    '}, - onTab: {keepDefault:false, replaceWith:' '}, - markupSet: [ - {name:'Bold', key:'B', openWith:'(!(|!|)!)', closeWith:'(!(|!|)!)' }, - {name:'Italic', key:'I', openWith:'(!(|!|)!)', closeWith:'(!(|!|)!)' }, - {name:'Stroke through', key:'S', openWith:'', closeWith:'' }, - {separator:'---------------' }, - {name:'Picture', key:'P', replaceWith:'[![Alternative text]!]' }, - {name:'Link', key:'L', openWith:'', closeWith:'', placeHolder:'Your text to link...' }, - {separator:'---------------' }, - {name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } }, - {name:'Preview', className:'preview', call:'preview'} - ] -} \ No newline at end of file +// ---------------------------------------------------------------------------- +// markItUp! +// ---------------------------------------------------------------------------- +// Copyright (C) 2011 Jay Salvat +// http://markitup.jaysalvat.com/ +// ---------------------------------------------------------------------------- +// Html tags +// http://en.wikipedia.org/wiki/html +// ---------------------------------------------------------------------------- +// Basic set. Feel free to add more tags +// ---------------------------------------------------------------------------- +var mySettings = { + onShiftEnter: {keepDefault:false, replaceWith:'
    \n'}, + onCtrlEnter: {keepDefault:false, openWith:'\n

    ', closeWith:'

    '}, + onTab: {keepDefault:false, replaceWith:' '}, + markupSet: [ + {name:'Bold', key:'B', openWith:'(!(|!|)!)', closeWith:'(!(|!|)!)' }, + {name:'Italic', key:'I', openWith:'(!(|!|)!)', closeWith:'(!(|!|)!)' }, + {name:'Stroke through', key:'S', openWith:'', closeWith:'' }, + {separator:'---------------' }, + {name:'Bulleted List', openWith:'
  • ', closeWith:'
  • ', multiline:true, openBlockWith:''}, + {name:'Numeric List', openWith:'
  • ', closeWith:'
  • ', multiline:true, openBlockWith:'
      \n', closeBlockWith:'\n
    '}, + {separator:'---------------' }, + {name:'Picture', key:'P', replaceWith:'[![Alternative text]!]' }, + {name:'Link', key:'L', openWith:'', closeWith:'', placeHolder:'Your text to link...' }, + {separator:'---------------' }, + {name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } }, + {name:'Preview', className:'preview', call:'preview'} + ] +} diff --git a/markitup/sets/default/style.css b/markitup/sets/default/style.css old mode 100644 new mode 100755 index 0794ab1..b1d20d6 --- a/markitup/sets/default/style.css +++ b/markitup/sets/default/style.css @@ -13,15 +13,22 @@ } .markItUp .markItUpButton4 a { - background-image:url(images/picture.png); + background-image:url(images/list-bullet.png); } .markItUp .markItUpButton5 a { - background-image:url(images/link.png); + background-image:url(images/list-numeric.png); } .markItUp .markItUpButton6 a { + background-image:url(images/picture.png); +} +.markItUp .markItUpButton7 a { + background-image:url(images/link.png); +} + +.markItUp .markItUpButton8 a { background-image:url(images/clean.png); } .markItUp .preview a { background-image:url(images/preview.png); -} \ No newline at end of file +} diff --git a/markitup/skins/markitup/images/bg-container.png b/markitup/skins/markitup/images/bg-container.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor-bbcode.png b/markitup/skins/markitup/images/bg-editor-bbcode.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor-dotclear.png b/markitup/skins/markitup/images/bg-editor-dotclear.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor-html.png b/markitup/skins/markitup/images/bg-editor-html.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor-json.png b/markitup/skins/markitup/images/bg-editor-json.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor-markdown.png b/markitup/skins/markitup/images/bg-editor-markdown.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor-textile.png b/markitup/skins/markitup/images/bg-editor-textile.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor-wiki.png b/markitup/skins/markitup/images/bg-editor-wiki.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor-xml.png b/markitup/skins/markitup/images/bg-editor-xml.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/bg-editor.png b/markitup/skins/markitup/images/bg-editor.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/handle.png b/markitup/skins/markitup/images/handle.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/menu.png b/markitup/skins/markitup/images/menu.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/images/submenu.png b/markitup/skins/markitup/images/submenu.png old mode 100644 new mode 100755 diff --git a/markitup/skins/markitup/style.css b/markitup/skins/markitup/style.css old mode 100644 new mode 100755 diff --git a/markitup/skins/simple/images/handle.png b/markitup/skins/simple/images/handle.png old mode 100644 new mode 100755 diff --git a/markitup/skins/simple/images/menu.png b/markitup/skins/simple/images/menu.png old mode 100644 new mode 100755 diff --git a/markitup/skins/simple/images/submenu.png b/markitup/skins/simple/images/submenu.png old mode 100644 new mode 100755 diff --git a/markitup/skins/simple/style.css b/markitup/skins/simple/style.css old mode 100644 new mode 100755 diff --git a/markitup/templates/preview.css b/markitup/templates/preview.css old mode 100644 new mode 100755 diff --git a/markitup/templates/preview.html b/markitup/templates/preview.html old mode 100644 new mode 100755 diff --git a/package.json b/package.json new file mode 100644 index 0000000..c747721 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "markItUp! ", + "title": "markItUp! universal markup jQuery editor", + "description": "markItUp! is a JavaScript plugin built on the jQuery library. It allows you to turn any textarea into a markup editor. Html, Textile, Wiki Syntax, Markdown, BBcode or even your own Markup system can be easily implemented.", + "version": "1.1.0", + "homepage": "http://markitup.jaysalvat.com/", + "author": { + "name": "Jay Salvat", + "email": "", + "url": "http://jaysalvat.com" + }, + "repository": { + "type": "git", + "url": "https://github.com/markitup/1.x" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/MIT" + }, + { + "type": "GPL", + "url": "http://www.opensource.org/licenses/GPL-2.0" + } + ], + "keywords": [ "jquery", "markup", "editor", "markdown", "wiki", "bbcode", "html", "textile" ] +}