From 8290cc11ee585f556052091dfaa931433daf3ee0 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Fri, 2 Jan 2015 16:40:46 +0100 Subject: [PATCH 1/7] new: [web_bootstrap_markdown] Initial release for new text form widget with markdown syntaxe --- web_bootstrap_markdown/README.rst | 44 +++++++++++++ web_bootstrap_markdown/__init__.py | 0 web_bootstrap_markdown/__openerp__.py | 17 ++++++ .../static/src/css/bootstrap-markdown.min.css | 1 + .../static/src/css/main.css | 26 ++++++++ .../static/src/js/web_bootstrap_markdown.js | 61 +++++++++++++++++++ .../static/src/xml/bootstrap_markdown.xml | 38 ++++++++++++ .../views/web_bootstrap_markdown.xml | 18 ++++++ 8 files changed, 205 insertions(+) create mode 100644 web_bootstrap_markdown/README.rst create mode 100644 web_bootstrap_markdown/__init__.py create mode 100644 web_bootstrap_markdown/__openerp__.py create mode 100644 web_bootstrap_markdown/static/src/css/bootstrap-markdown.min.css create mode 100644 web_bootstrap_markdown/static/src/css/main.css create mode 100644 web_bootstrap_markdown/static/src/js/web_bootstrap_markdown.js create mode 100644 web_bootstrap_markdown/static/src/xml/bootstrap_markdown.xml create mode 100644 web_bootstrap_markdown/views/web_bootstrap_markdown.xml diff --git a/web_bootstrap_markdown/README.rst b/web_bootstrap_markdown/README.rst new file mode 100644 index 00000000..879034fc --- /dev/null +++ b/web_bootstrap_markdown/README.rst @@ -0,0 +1,44 @@ +============================== +Add new text field form widget +============================== + +Description +----------- + +This modules add a new widget for text field in form view on Odoo: + +- In readonly mode, it use marked to parse and render to html markdown syntaxe. +- In write mode, use [bootstrap-markdown][1] + +[1]: http://www.codingdrama.com/bootstrap-markdown/ "bootstrap-markdown" + +Requirements +------------ + +Was tested on openerp trunk, 8.0 branch. + +Example +------- + +Your XML form view definition should contain:: + + ... + + ... + +Note / Todo +----------- + +- Improve user experience with Odoo specific syntaxe +- Improve user experience with Github specific syntaxe +- Add a working parsed field in tree view +- Add ir.attachment support +- Add images support (with drag'n'drop) +- ... + +Thanks to +--------- + +- Nicolas JEUDY + +If you have questions, please email one of them, or report issue on github diff --git a/web_bootstrap_markdown/__init__.py b/web_bootstrap_markdown/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/web_bootstrap_markdown/__openerp__.py b/web_bootstrap_markdown/__openerp__.py new file mode 100644 index 00000000..a4c064e9 --- /dev/null +++ b/web_bootstrap_markdown/__openerp__.py @@ -0,0 +1,17 @@ +{ + 'name': 'web_bootstrap_markdown', + 'version': '1.0', + 'author': 'Sudokeys', + 'maintainer': 'Sudokeys', + 'category': '', + 'license': 'AGPL-3', + 'depends': ['base'], + 'website': 'http://www.sudokey.com', + 'data': ['views/web_bootstrap_markdown.xml',], + "qweb": ["static/src/xml/bootstrap_markdown.xml", + ], + 'demo': [], + 'installable': True, + 'auto_install': False, + 'application': False +} diff --git a/web_bootstrap_markdown/static/src/css/bootstrap-markdown.min.css b/web_bootstrap_markdown/static/src/css/bootstrap-markdown.min.css new file mode 100644 index 00000000..388b2f5f --- /dev/null +++ b/web_bootstrap_markdown/static/src/css/bootstrap-markdown.min.css @@ -0,0 +1 @@ +.md-editor{display:block;border:1px solid #ddd}.md-editor .md-footer,.md-editor>.md-header{display:block;padding:6px 4px;background:#f5f5f5}.md-editor>.md-header{margin:0}.md-editor>.md-preview{background:#fff;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;min-height:10px;overflow:auto}.md-editor>textarea{font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:14px;outline:0;margin:0;display:block;padding:0;width:100%;border:0;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;border-radius:0;box-shadow:none;background:#eee}.md-editor>textarea:focus{box-shadow:none;background:#fff}.md-editor.active{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.md-editor .md-controls{float:right;padding:3px}.md-editor .md-controls .md-control{right:5px;color:#bebebe;padding:3px 3px 3px 10px}.md-editor .md-controls .md-control:hover{color:#333}.md-editor.md-fullscreen-mode{width:100%;height:100%;position:fixed;top:0;left:0;z-index:99999;padding:60px 30px 15px;background:#fff!important;border:0!important}.md-editor.md-fullscreen-mode .md-footer{display:none}.md-editor.md-fullscreen-mode .md-input,.md-editor.md-fullscreen-mode .md-preview{margin:0 auto!important;height:100%!important;font-size:20px!important;padding:20px!important;color:#999;line-height:1.6em!important;resize:none!important;box-shadow:none!important;background:#fff!important;border:0!important}.md-editor.md-fullscreen-mode .md-preview{color:#333;overflow:auto}.md-editor.md-fullscreen-mode .md-input:focus,.md-editor.md-fullscreen-mode .md-input:hover{color:#333;background:#fff!important}.md-editor.md-fullscreen-mode .md-header{background:0 0;text-align:center;position:fixed;width:100%;top:20px}.md-editor.md-fullscreen-mode .btn-group{float:none}.md-editor.md-fullscreen-mode .btn{border:0;background:0 0;color:#b3b3b3}.md-editor.md-fullscreen-mode .btn.active,.md-editor.md-fullscreen-mode .btn:active,.md-editor.md-fullscreen-mode .btn:focus,.md-editor.md-fullscreen-mode .btn:hover{box-shadow:none;color:#333}.md-editor.md-fullscreen-mode .md-fullscreen-controls{position:absolute;top:20px;right:20px;text-align:right;z-index:1002;display:block}.md-editor.md-fullscreen-mode .md-fullscreen-controls a{color:#b3b3b3;clear:right;margin:10px;width:30px;height:30px;text-align:center}.md-editor.md-fullscreen-mode .md-fullscreen-controls a:hover{color:#333;text-decoration:none}.md-editor.md-fullscreen-mode .md-editor{height:100%!important;position:relative}.md-editor .md-fullscreen-controls{display:none}.md-nooverflow{overflow:hidden;position:fixed;width:100%} \ No newline at end of file diff --git a/web_bootstrap_markdown/static/src/css/main.css b/web_bootstrap_markdown/static/src/css/main.css new file mode 100644 index 00000000..9efd2c1f --- /dev/null +++ b/web_bootstrap_markdown/static/src/css/main.css @@ -0,0 +1,26 @@ +.openerp .oe_form .oe_form_field_markdown .oe_form_text_content { + text-overflow: ellipsis; + display: inline-block; + white-space: pre-wrap; + overflow-x: hidden; + width: 100%; + background-color: #eee; + padding: 10px; +} + +.oe_form_text_markdown pre { + background-color: #333; + padding: 10px; +} + +.md-editor.md-fullscreen-mode .md-input, .md-editor.md-fullscreen-mode .md-preview { + font-size: 13px!important; +} + +.md-editor.md-fullscreen-mode { + margin-top: 50px; +} + +.md-editor.md-fullscreen-mode .md-header { + top: 70px; +} diff --git a/web_bootstrap_markdown/static/src/js/web_bootstrap_markdown.js b/web_bootstrap_markdown/static/src/js/web_bootstrap_markdown.js new file mode 100644 index 00000000..2ad03c3c --- /dev/null +++ b/web_bootstrap_markdown/static/src/js/web_bootstrap_markdown.js @@ -0,0 +1,61 @@ +openerp.web_bootstrap_markdown = function (oe) { + + var _lt = oe.web._lt; + + oe.web.form.widgets.add('bootstrap_markdown', 'openerp.web_bootstrap_markdown.FieldTextMarkDown'); + + oe.web_bootstrap_markdown.FieldTextMarkDown = oe.web.form.AbstractField.extend( + oe.web.form.ReinitializeFieldMixin, + { + + template: 'FieldMarkDown', + display_name: _lt('MarkDown'), + widget_class: 'oe_form_field_bootstrap_markdown', + events: { + 'change input': 'store_dom_value' + }, + + init: function (field_manager, node) { + this._super(field_manager, node); + this.$txt = false; + + this.old_value = null; + }, + + initialize_content: function () { + // Gets called at each redraw of widget + // - switching between read-only mode and edit mode + // - BUT NOT when switching to next object. + this.$txt = this.$el.find('textarea[name="' + this.name + '"]'); + if (!this.get('effective_readonly')) { + this.$txt.markdown({autofocus: false, savable: false}); + } + this.old_value = null; // will trigger a redraw + }, + + render_value: function () { + // Gets called at each redraw/save of widget + // - switching between read-only mode and edit mode + // - when switching to next object. + + var show_value = this.format_value(this.get('value'), ''); + if (!this.get("effective_readonly")) { + this.$txt.val(show_value); + this.$el.trigger('resize'); + } else { + // avoids loading markitup... + marked.setOptions({ + highlight: function (code) { + return hljs.highlightAuto(code).value; + } + }); + this.$el.find('span[class="oe_form_text_content"]').html(marked(show_value)); + } + }, + + format_value: function (val, def) { + return oe.web.format_value(val, this, def); + } + } + ); +}; diff --git a/web_bootstrap_markdown/static/src/xml/bootstrap_markdown.xml b/web_bootstrap_markdown/static/src/xml/bootstrap_markdown.xml new file mode 100644 index 00000000..347e955a --- /dev/null +++ b/web_bootstrap_markdown/static/src/xml/bootstrap_markdown.xml @@ -0,0 +1,38 @@ + + + + + + +
+ + + + + + + +
+
+ + +
+
+
+ +
diff --git a/web_bootstrap_markdown/views/web_bootstrap_markdown.xml b/web_bootstrap_markdown/views/web_bootstrap_markdown.xml new file mode 100644 index 00000000..5cea7654 --- /dev/null +++ b/web_bootstrap_markdown/views/web_bootstrap_markdown.xml @@ -0,0 +1,18 @@ + + + + + + + From bb49d2dd83299b0c9be97354bc1a54e381256e92 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Fri, 2 Jan 2015 16:44:47 +0100 Subject: [PATCH 2/7] fix:[web_bootstrap_markdown] add depend 'web' module --- web_bootstrap_markdown/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_bootstrap_markdown/__openerp__.py b/web_bootstrap_markdown/__openerp__.py index a4c064e9..42627cd0 100644 --- a/web_bootstrap_markdown/__openerp__.py +++ b/web_bootstrap_markdown/__openerp__.py @@ -5,7 +5,7 @@ 'maintainer': 'Sudokeys', 'category': '', 'license': 'AGPL-3', - 'depends': ['base'], + 'depends': ['base','web'], 'website': 'http://www.sudokey.com', 'data': ['views/web_bootstrap_markdown.xml',], "qweb": ["static/src/xml/bootstrap_markdown.xml", From c5641d76438c1d98924a340ae93d26e36d514628 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Fri, 2 Jan 2015 17:43:58 +0100 Subject: [PATCH 3/7] fix: rename module to web_widget_text_markdown --- .../views/web_bootstrap_markdown.xml | 18 ------------------ .../README.rst | 0 .../__init__.py | 0 .../__openerp__.py | 4 ++-- .../static/src/css/bootstrap-markdown.min.css | 0 .../static/src/css/main.css | 0 .../static/src/js/web_widget_text_markdown.js | 6 +++--- .../static/src/xml/bootstrap_markdown.xml | 0 web_widget_text_markdown/views/main.xml | 18 ++++++++++++++++++ 9 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 web_bootstrap_markdown/views/web_bootstrap_markdown.xml rename {web_bootstrap_markdown => web_widget_text_markdown}/README.rst (100%) rename {web_bootstrap_markdown => web_widget_text_markdown}/__init__.py (100%) rename {web_bootstrap_markdown => web_widget_text_markdown}/__openerp__.py (80%) rename {web_bootstrap_markdown => web_widget_text_markdown}/static/src/css/bootstrap-markdown.min.css (100%) rename {web_bootstrap_markdown => web_widget_text_markdown}/static/src/css/main.css (100%) rename web_bootstrap_markdown/static/src/js/web_bootstrap_markdown.js => web_widget_text_markdown/static/src/js/web_widget_text_markdown.js (89%) rename {web_bootstrap_markdown => web_widget_text_markdown}/static/src/xml/bootstrap_markdown.xml (100%) create mode 100644 web_widget_text_markdown/views/main.xml diff --git a/web_bootstrap_markdown/views/web_bootstrap_markdown.xml b/web_bootstrap_markdown/views/web_bootstrap_markdown.xml deleted file mode 100644 index 5cea7654..00000000 --- a/web_bootstrap_markdown/views/web_bootstrap_markdown.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/web_bootstrap_markdown/README.rst b/web_widget_text_markdown/README.rst similarity index 100% rename from web_bootstrap_markdown/README.rst rename to web_widget_text_markdown/README.rst diff --git a/web_bootstrap_markdown/__init__.py b/web_widget_text_markdown/__init__.py similarity index 100% rename from web_bootstrap_markdown/__init__.py rename to web_widget_text_markdown/__init__.py diff --git a/web_bootstrap_markdown/__openerp__.py b/web_widget_text_markdown/__openerp__.py similarity index 80% rename from web_bootstrap_markdown/__openerp__.py rename to web_widget_text_markdown/__openerp__.py index 42627cd0..ac8245fc 100644 --- a/web_bootstrap_markdown/__openerp__.py +++ b/web_widget_text_markdown/__openerp__.py @@ -1,5 +1,5 @@ { - 'name': 'web_bootstrap_markdown', + 'name': 'web_widget_text_markdown', 'version': '1.0', 'author': 'Sudokeys', 'maintainer': 'Sudokeys', @@ -7,7 +7,7 @@ 'license': 'AGPL-3', 'depends': ['base','web'], 'website': 'http://www.sudokey.com', - 'data': ['views/web_bootstrap_markdown.xml',], + 'data': ['views/main.xml',], "qweb": ["static/src/xml/bootstrap_markdown.xml", ], 'demo': [], diff --git a/web_bootstrap_markdown/static/src/css/bootstrap-markdown.min.css b/web_widget_text_markdown/static/src/css/bootstrap-markdown.min.css similarity index 100% rename from web_bootstrap_markdown/static/src/css/bootstrap-markdown.min.css rename to web_widget_text_markdown/static/src/css/bootstrap-markdown.min.css diff --git a/web_bootstrap_markdown/static/src/css/main.css b/web_widget_text_markdown/static/src/css/main.css similarity index 100% rename from web_bootstrap_markdown/static/src/css/main.css rename to web_widget_text_markdown/static/src/css/main.css diff --git a/web_bootstrap_markdown/static/src/js/web_bootstrap_markdown.js b/web_widget_text_markdown/static/src/js/web_widget_text_markdown.js similarity index 89% rename from web_bootstrap_markdown/static/src/js/web_bootstrap_markdown.js rename to web_widget_text_markdown/static/src/js/web_widget_text_markdown.js index 2ad03c3c..210c51d4 100644 --- a/web_bootstrap_markdown/static/src/js/web_bootstrap_markdown.js +++ b/web_widget_text_markdown/static/src/js/web_widget_text_markdown.js @@ -1,10 +1,10 @@ -openerp.web_bootstrap_markdown = function (oe) { +openerp.web_widget_text_markdown = function (oe) { var _lt = oe.web._lt; - oe.web.form.widgets.add('bootstrap_markdown', 'openerp.web_bootstrap_markdown.FieldTextMarkDown'); + oe.web.form.widgets.add('bootstrap_markdown', 'openerp.web_widget_text_markdown.FieldTextMarkDown'); - oe.web_bootstrap_markdown.FieldTextMarkDown = oe.web.form.AbstractField.extend( + oe.web_widget_text_markdown.FieldTextMarkDown = oe.web.form.AbstractField.extend( oe.web.form.ReinitializeFieldMixin, { diff --git a/web_bootstrap_markdown/static/src/xml/bootstrap_markdown.xml b/web_widget_text_markdown/static/src/xml/bootstrap_markdown.xml similarity index 100% rename from web_bootstrap_markdown/static/src/xml/bootstrap_markdown.xml rename to web_widget_text_markdown/static/src/xml/bootstrap_markdown.xml diff --git a/web_widget_text_markdown/views/main.xml b/web_widget_text_markdown/views/main.xml new file mode 100644 index 00000000..e8a8ab26 --- /dev/null +++ b/web_widget_text_markdown/views/main.xml @@ -0,0 +1,18 @@ + + + + + + + From c58efe6af2d33e045d9c45a4972a6762d9cd3260 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Fri, 2 Jan 2015 23:51:41 +0100 Subject: [PATCH 4/7] fix: fixes small @typo, and put AGPL in __openerp__.py --- web_widget_text_markdown/README.rst | 8 ++++---- web_widget_text_markdown/__openerp__.py | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/web_widget_text_markdown/README.rst b/web_widget_text_markdown/README.rst index 879034fc..37b30835 100644 --- a/web_widget_text_markdown/README.rst +++ b/web_widget_text_markdown/README.rst @@ -7,7 +7,7 @@ Description This modules add a new widget for text field in form view on Odoo: -- In readonly mode, it use marked to parse and render to html markdown syntaxe. +- In readonly mode, it uses marked to parse and render to html markdown syntax. - In write mode, use [bootstrap-markdown][1] [1]: http://www.codingdrama.com/bootstrap-markdown/ "bootstrap-markdown" @@ -23,14 +23,14 @@ Example Your XML form view definition should contain:: ... - + ... Note / Todo ----------- -- Improve user experience with Odoo specific syntaxe -- Improve user experience with Github specific syntaxe +- Improve user experience with Odoo specific syntax +- Improve user experience with Github specific syntax - Add a working parsed field in tree view - Add ir.attachment support - Add images support (with drag'n'drop) diff --git a/web_widget_text_markdown/__openerp__.py b/web_widget_text_markdown/__openerp__.py index ac8245fc..d3ad525b 100644 --- a/web_widget_text_markdown/__openerp__.py +++ b/web_widget_text_markdown/__openerp__.py @@ -1,3 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 Sudokeys () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + { 'name': 'web_widget_text_markdown', 'version': '1.0', @@ -5,9 +25,9 @@ 'maintainer': 'Sudokeys', 'category': '', 'license': 'AGPL-3', - 'depends': ['base','web'], + 'depends': ['base', 'web'], 'website': 'http://www.sudokey.com', - 'data': ['views/main.xml',], + 'data': ['views/main.xml', ], "qweb": ["static/src/xml/bootstrap_markdown.xml", ], 'demo': [], From e4c521f6ce1f4588f06d57cd471a372aa39b4a10 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Sat, 3 Jan 2015 17:37:12 +0100 Subject: [PATCH 5/7] fix: missing static/lib folder for obscur reason ... --- .../bootstrap-markdown/bootstrap-markdown.js | 1344 +++++++++++++++++ .../static/lib/highlight/CHANGES.md | 1049 +++++++++++++ .../static/lib/highlight/LICENSE | 24 + .../static/lib/highlight/README.md | 101 ++ .../static/lib/highlight/README.ru.md | 101 ++ .../static/lib/highlight/highlight.min.js | 2 + .../static/lib/highlight/styles/arta.css | 140 ++ .../static/lib/highlight/styles/ascetic.css | 52 + .../highlight/styles/atelier-dune.dark.css | 95 ++ .../highlight/styles/atelier-dune.light.css | 95 ++ .../highlight/styles/atelier-forest.dark.css | 95 ++ .../highlight/styles/atelier-forest.light.css | 95 ++ .../highlight/styles/atelier-heath.dark.css | 95 ++ .../highlight/styles/atelier-heath.light.css | 95 ++ .../styles/atelier-lakeside.dark.css | 95 ++ .../styles/atelier-lakeside.light.css | 95 ++ .../highlight/styles/atelier-seaside.dark.css | 95 ++ .../styles/atelier-seaside.light.css | 95 ++ .../lib/highlight/styles/brown_paper.css | 104 ++ .../lib/highlight/styles/brown_papersq.png | Bin 0 -> 18198 bytes .../lib/highlight/styles/codepen-embed.css | 108 ++ .../lib/highlight/styles/color-brewer.css | 168 +++ .../static/lib/highlight/styles/dark.css | 104 ++ .../static/lib/highlight/styles/default.css | 152 ++ .../static/lib/highlight/styles/docco.css | 135 ++ .../static/lib/highlight/styles/far.css | 111 ++ .../lib/highlight/styles/foundation.css | 136 ++ .../static/lib/highlight/styles/github.css | 124 ++ .../lib/highlight/styles/googlecode.css | 147 ++ .../static/lib/highlight/styles/hybrid.css | 170 +++ .../static/lib/highlight/styles/idea.css | 125 ++ .../static/lib/highlight/styles/ir_black.css | 109 ++ .../lib/highlight/styles/kimbie.dark.css | 96 ++ .../lib/highlight/styles/kimbie.light.css | 96 ++ .../static/lib/highlight/styles/magula.css | 121 ++ .../static/lib/highlight/styles/mono-blue.css | 69 + .../static/lib/highlight/styles/monokai.css | 127 ++ .../lib/highlight/styles/monokai_sublime.css | 154 ++ .../static/lib/highlight/styles/obsidian.css | 153 ++ .../lib/highlight/styles/paraiso.dark.css | 95 ++ .../lib/highlight/styles/paraiso.light.css | 95 ++ .../static/lib/highlight/styles/pojoaque.css | 107 ++ .../static/lib/highlight/styles/pojoaque.jpg | Bin 0 -> 1186 bytes .../lib/highlight/styles/railscasts.css | 187 +++ .../static/lib/highlight/styles/rainbow.css | 108 ++ .../lib/highlight/styles/school_book.css | 112 ++ .../lib/highlight/styles/school_book.png | Bin 0 -> 486 bytes .../lib/highlight/styles/solarized_dark.css | 108 ++ .../lib/highlight/styles/solarized_light.css | 108 ++ .../static/lib/highlight/styles/sunburst.css | 164 ++ .../highlight/styles/tomorrow-night-blue.css | 95 ++ .../styles/tomorrow-night-bright.css | 94 ++ .../styles/tomorrow-night-eighties.css | 94 ++ .../lib/highlight/styles/tomorrow-night.css | 95 ++ .../static/lib/highlight/styles/tomorrow.css | 92 ++ .../static/lib/highlight/styles/vs.css | 93 ++ .../static/lib/highlight/styles/xcode.css | 158 ++ .../static/lib/highlight/styles/zenburn.css | 118 ++ .../static/lib/marked/marked.js | 1272 ++++++++++++++++ 59 files changed, 9467 insertions(+) create mode 100644 web_widget_text_markdown/static/lib/bootstrap-markdown/bootstrap-markdown.js create mode 100644 web_widget_text_markdown/static/lib/highlight/CHANGES.md create mode 100644 web_widget_text_markdown/static/lib/highlight/LICENSE create mode 100644 web_widget_text_markdown/static/lib/highlight/README.md create mode 100644 web_widget_text_markdown/static/lib/highlight/README.ru.md create mode 100644 web_widget_text_markdown/static/lib/highlight/highlight.min.js create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/arta.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/ascetic.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-dune.dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-dune.light.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-forest.dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-forest.light.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-heath.dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-heath.light.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-lakeside.dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-lakeside.light.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-seaside.dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/atelier-seaside.light.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/brown_paper.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/brown_papersq.png create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/codepen-embed.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/color-brewer.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/default.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/docco.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/far.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/foundation.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/github.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/googlecode.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/hybrid.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/idea.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/ir_black.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/kimbie.dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/kimbie.light.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/magula.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/mono-blue.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/monokai.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/monokai_sublime.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/obsidian.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/paraiso.dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/paraiso.light.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/pojoaque.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/pojoaque.jpg create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/railscasts.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/rainbow.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/school_book.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/school_book.png create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/solarized_dark.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/solarized_light.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/sunburst.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/tomorrow-night-blue.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/tomorrow-night-bright.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/tomorrow-night-eighties.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/tomorrow-night.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/tomorrow.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/vs.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/xcode.css create mode 100644 web_widget_text_markdown/static/lib/highlight/styles/zenburn.css create mode 100644 web_widget_text_markdown/static/lib/marked/marked.js diff --git a/web_widget_text_markdown/static/lib/bootstrap-markdown/bootstrap-markdown.js b/web_widget_text_markdown/static/lib/bootstrap-markdown/bootstrap-markdown.js new file mode 100644 index 00000000..66ad62f1 --- /dev/null +++ b/web_widget_text_markdown/static/lib/bootstrap-markdown/bootstrap-markdown.js @@ -0,0 +1,1344 @@ +/* =================================================== + * bootstrap-markdown.js v2.7.0 + * http://github.com/toopay/bootstrap-markdown + * =================================================== + * Copyright 2013-2014 Taufan Aditya + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + +!function ($) { + + "use strict"; // jshint ;_; + + + /* MARKDOWN CLASS DEFINITION + * ========================== */ + + var Markdown = function (element, options) { + // Class Properties + this.$ns = 'bootstrap-markdown' + this.$element = $(element) + this.$editable = {el:null, type:null,attrKeys:[], attrValues:[], content:null} + this.$options = $.extend(true, {}, $.fn.markdown.defaults, options, this.$element.data(), this.$element.data('options')) + this.$oldContent = null + this.$isPreview = false + this.$isFullscreen = false + this.$editor = null + this.$textarea = null + this.$handler = [] + this.$callback = [] + this.$nextTab = [] + + this.showEditor() + } + + Markdown.prototype = { + + constructor: Markdown + + , __alterButtons: function(name,alter) { + var handler = this.$handler, isAll = (name == 'all'),that = this + + $.each(handler,function(k,v) { + var halt = true + if (isAll) { + halt = false + } else { + halt = v.indexOf(name) < 0 + } + + if (halt == false) { + alter(that.$editor.find('button[data-handler="'+v+'"]')) + } + }) + } + + , __buildButtons: function(buttonsArray, container) { + var i, + ns = this.$ns, + handler = this.$handler, + callback = this.$callback + + for (i=0;i', { + 'class': 'btn-group' + }) + + for (z=0;z'); + buttonContainer.text(' ' + this.__localize(btnText)).addClass('btn-default btn-sm').addClass(btnClass); + if(btnClass.match(/btn\-(primary|success|info|warning|danger|link)/)){ + buttonContainer.removeClass('btn-default'); + } + buttonContainer.attr({ + 'type': 'button', + 'title': this.__localize(button.title) + hotkeyCaption, + 'tabindex': tabIndex, + 'data-provider': ns, + 'data-handler': buttonHandler, + 'data-hotkey': hotkey + }); + if (button.toggle == true){ + buttonContainer.attr('data-toggle', 'button'); + } + buttonIconContainer = $(''); + buttonIconContainer.addClass(buttonIcon); + buttonIconContainer.prependTo(buttonContainer); + + // Attach the button object + btnGroupContainer.append(buttonContainer); + + // Register handler and callback + handler.push(buttonHandler); + callback.push(button.callback); + } + + // Attach the button group into container dom + container.append(btnGroupContainer); + } + } + + return container; + } + , __setListener: function() { + // Set size and resizable Properties + var hasRows = typeof this.$textarea.attr('rows') != 'undefined', + maxRows = this.$textarea.val().split("\n").length > 5 ? this.$textarea.val().split("\n").length : '5', + rowsVal = hasRows ? this.$textarea.attr('rows') : maxRows + + this.$textarea.attr('rows',rowsVal) + if (this.$options.resize) { + this.$textarea.css('resize',this.$options.resize) + } + + this.$textarea + .on('focus', $.proxy(this.focus, this)) + .on('keypress', $.proxy(this.keypress, this)) + .on('keyup', $.proxy(this.keyup, this)) + .on('change', $.proxy(this.change, this)) + + if (this.eventSupported('keydown')) { + this.$textarea.on('keydown', $.proxy(this.keydown, this)) + } + + // Re-attach markdown data + this.$textarea.data('markdown',this) + } + + , __handle: function(e) { + var target = $(e.currentTarget), + handler = this.$handler, + callback = this.$callback, + handlerName = target.attr('data-handler'), + callbackIndex = handler.indexOf(handlerName), + callbackHandler = callback[callbackIndex] + + // Trigger the focusin + $(e.currentTarget).focus() + + callbackHandler(this) + + // Trigger onChange for each button handle + this.change(this); + + // Unless it was the save handler, + // focusin the textarea + if (handlerName.indexOf('cmdSave') < 0) { + this.$textarea.focus() + } + + e.preventDefault() + } + + , __localize: function(string) { + var messages = $.fn.markdown.messages, + language = this.$options.language + if ( + typeof messages !== 'undefined' && + typeof messages[language] !== 'undefined' && + typeof messages[language][string] !== 'undefined' + ) { + return messages[language][string]; + } + return string; + } + + , __getIcon: function(src) { + return typeof src == 'object' ? src[this.$options.iconlibrary] : src; + } + + , setFullscreen: function(mode) { + var $editor = this.$editor, + $textarea = this.$textarea + + if (mode === true) { + $editor.addClass('md-fullscreen-mode') + $('body').addClass('md-nooverflow') + this.$options.onFullscreen(this) + } else { + $editor.removeClass('md-fullscreen-mode') + $('body').removeClass('md-nooverflow') + } + + this.$isFullscreen = mode; + $textarea.focus() + } + + , showEditor: function() { + var instance = this, + textarea, + ns = this.$ns, + container = this.$element, + originalHeigth = container.css('height'), + originalWidth = container.css('width'), + editable = this.$editable, + handler = this.$handler, + callback = this.$callback, + options = this.$options, + editor = $( '
', { + 'class': 'md-editor', + click: function() { + instance.focus() + } + }) + + // Prepare the editor + if (this.$editor == null) { + // Create the panel + var editorHeader = $('
', { + 'class': 'md-header btn-toolbar' + }) + + // Merge the main & additional button groups together + var allBtnGroups = [] + if (options.buttons.length > 0) allBtnGroups = allBtnGroups.concat(options.buttons[0]) + if (options.additionalButtons.length > 0) allBtnGroups = allBtnGroups.concat(options.additionalButtons[0]) + + // Reduce and/or reorder the button groups + if (options.reorderButtonGroups.length > 0) { + allBtnGroups = allBtnGroups + .filter(function(btnGroup) { + return options.reorderButtonGroups.indexOf(btnGroup.name) > -1 + }) + .sort(function(a, b) { + if (options.reorderButtonGroups.indexOf(a.name) < options.reorderButtonGroups.indexOf(b.name)) return -1 + if (options.reorderButtonGroups.indexOf(a.name) > options.reorderButtonGroups.indexOf(b.name)) return 1 + return 0 + }) + } + + // Build the buttons + if (allBtnGroups.length > 0) { + editorHeader = this.__buildButtons([allBtnGroups], editorHeader) + } + + if (options.fullscreen.enable) { + editorHeader.append('
').on('click', '.md-control-fullscreen', function(e) { + e.preventDefault(); + instance.setFullscreen(true) + }) + } + + editor.append(editorHeader) + + // Wrap the textarea + if (container.is('textarea')) { + container.before(editor) + textarea = container + textarea.addClass('md-input') + editor.append(textarea) + } else { + var rawContent = (typeof toMarkdown == 'function') ? toMarkdown(container.html()) : container.html(), + currentContent = $.trim(rawContent) + + // This is some arbitrary content that could be edited + textarea = $('