xmt_froala 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/xmt_froala.js +31 -0
- data/app/assets/stylesheets/xmt_froala.css +17 -0
- data/app/controllers/xmt_froala/application_controller.rb +5 -0
- data/app/controllers/xmt_froala/assets_controller.rb +94 -0
- data/app/models/xmt_froala/asset_uploader.rb +107 -0
- data/app/models/xmt_froala/file_uploader.rb +10 -0
- data/app/models/xmt_froala/flash_uploader.rb +10 -0
- data/app/models/xmt_froala/image_uploader.rb +10 -0
- data/app/models/xmt_froala/media_uploader.rb +10 -0
- data/config/routes.rb +6 -0
- data/lib/generators/xmt_froala/install/USAGE +10 -0
- data/lib/generators/xmt_froala/install/install_generator.rb +23 -0
- data/lib/generators/xmt_froala/install/templates/application.js +17 -0
- data/lib/generators/xmt_froala/install/templates/xmt_froala.rb +29 -0
- data/lib/generators/xmt_froala/migration/USAGE +14 -0
- data/lib/generators/xmt_froala/migration/migration_generator.rb +36 -0
- data/lib/generators/xmt_froala/migration/templates/migration/migration.rb +18 -0
- data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/asset.rb +14 -0
- data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/file.rb +3 -0
- data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/flash.rb +3 -0
- data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/image.rb +3 -0
- data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/media.rb +3 -0
- data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/asset.rb +27 -0
- data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/file.rb +3 -0
- data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/flash.rb +3 -0
- data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/image.rb +3 -0
- data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/media.rb +3 -0
- data/lib/tasks/xmt_froala_tasks.rake +9 -0
- data/lib/xmt_froala.rb +65 -0
- data/lib/xmt_froala/active_record.rb +14 -0
- data/lib/xmt_froala/engine.rb +32 -0
- data/lib/xmt_froala/formtastic.rb +12 -0
- data/lib/xmt_froala/helper.rb +105 -0
- data/lib/xmt_froala/simple_form.rb +11 -0
- data/lib/xmt_froala/version.rb +3 -0
- data/vendor/assets/javascripts/xmt_froala/froala_editor.js +0 -0
- data/vendor/assets/javascripts/xmt_froala/languages/ar.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/bs.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/cs.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/da.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/de.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/en_ca.js +262 -0
- data/vendor/assets/javascripts/xmt_froala/languages/en_gb.js +262 -0
- data/vendor/assets/javascripts/xmt_froala/languages/es.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/et.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/fa.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/fi.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/fr.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/he.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/hr.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/hu.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/id.js +319 -0
- data/vendor/assets/javascripts/xmt_froala/languages/it.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/ja.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/ko.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/me.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/nb.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/nl.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/pl.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/pt_br.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/pt_pt.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/ro.js +319 -0
- data/vendor/assets/javascripts/xmt_froala/languages/ru.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/sk.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/sr.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/sv.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/th.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/tr.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/uk.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/languages/vi.js +258 -0
- data/vendor/assets/javascripts/xmt_froala/languages/zh_cn.js +320 -0
- data/vendor/assets/javascripts/xmt_froala/languages/zh_tw.js +318 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/align.js +139 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/align.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/char_counter.js +154 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/char_counter.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/code_beautifier.js +3270 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/code_beautifier.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/code_view.js +393 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/code_view.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/colors.js +492 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/colors.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/draggable.js +459 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/draggable.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/emoticons.js +509 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/emoticons.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/entities.js +121 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/entities.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/file.js +736 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/file.min.js +239 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/font_family.js +182 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/font_family.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/font_size.js +118 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/font_size.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/forms.js +430 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/forms.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/fullscreen.js +274 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/fullscreen.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/help.js +216 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/help.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/image.js +3323 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/image.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/image_manager.js +1056 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/image_manager.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/inline_style.js +94 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/inline_style.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/line_breaker.js +537 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/line_breaker.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/link.js +1157 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/link.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/lists.js +462 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/lists.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_format.js +290 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_format.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_style.js +144 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_style.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/plain_paste.js +96 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/print.js +137 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/print.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/quick_format.js +89 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/quick_insert.js +478 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/quick_insert.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/quote.js +141 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/quote.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/save.js +189 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/save.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/special_characters.js +781 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/special_characters.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/table.js +4194 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/table.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/url.js +194 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/url.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/video.js +2342 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/video.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/word_paste.js +1403 -0
- data/vendor/assets/javascripts/xmt_froala/plugins/word_paste.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/third_party/embedly.js +543 -0
- data/vendor/assets/javascripts/xmt_froala/third_party/embedly.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/third_party/image_aviary.js +163 -0
- data/vendor/assets/javascripts/xmt_froala/third_party/image_aviary.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/third_party/spell_checker.js +222 -0
- data/vendor/assets/javascripts/xmt_froala/third_party/spell_checker.min.js +7 -0
- data/vendor/assets/javascripts/xmt_froala/xmt_froala.js +15172 -0
- data/vendor/assets/stylesheets/xmt_froala/css/font-awesome.css +2546 -0
- data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.pkgd.css +2902 -0
- data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.pkgd.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/froala_style.css +413 -0
- data/vendor/assets/stylesheets/xmt_froala/css/froala_style.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/char_counter.css +57 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/char_counter.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/code_view.css +112 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/code_view.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/colors.css +155 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/colors.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/draggable.css +43 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/draggable.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/emoticons.css +42 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/emoticons.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/file.css +146 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/file.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/fullscreen.css +28 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/fullscreen.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/help.css +52 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/help.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/image.css +244 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/image.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/image_manager.css +266 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/image_manager.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/line_breaker.css +37 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/line_breaker.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/quick_insert.css +70 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/quick_insert.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/special_characters.css +51 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/special_characters.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/table.css +181 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/table.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/video.css +231 -0
- data/vendor/assets/stylesheets/xmt_froala/css/plugins/video.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/themes/dark.css +1281 -0
- data/vendor/assets/stylesheets/xmt_froala/css/themes/dark.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/themes/gray.css +1281 -0
- data/vendor/assets/stylesheets/xmt_froala/css/themes/gray.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/themes/red.css +1281 -0
- data/vendor/assets/stylesheets/xmt_froala/css/themes/red.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/themes/royal.css +1281 -0
- data/vendor/assets/stylesheets/xmt_froala/css/themes/royal.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/third_party/embedly.css +64 -0
- data/vendor/assets/stylesheets/xmt_froala/css/third_party/embedly.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/third_party/spell_checker.css +72 -0
- data/vendor/assets/stylesheets/xmt_froala/css/third_party/spell_checker.min.css +7 -0
- data/vendor/assets/stylesheets/xmt_froala/css/xmt_froala.css +1423 -0
- data/vendor/assets/stylesheets/xmt_froala/fonts/FontAwesome.otf +0 -0
- data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.svg +2671 -0
- data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.woff2 +0 -0
- metadata +273 -0
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2018 Froala Labs
|
5
|
+
*/
|
6
|
+
|
7
|
+
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=function(e,a){return a===undefined&&(a="undefined"!=typeof window?require("jquery"):require("jquery")(e)),t(a)}:t(window.jQuery)}(function(i){i.extend(i.FE.DEFAULTS,{paragraphStyles:{"fr-text-gray":"Gray","fr-text-bordered":"Bordered","fr-text-spaced":"Spaced","fr-text-uppercase":"Uppercase"},paragraphMultipleStyles:!0}),i.FE.PLUGINS.paragraphStyle=function(o){return{_init:function(){},apply:function(e,a,t){void 0===a&&(a=o.opts.paragraphStyles),void 0===t&&(t=o.opts.paragraphMultipleStyles);var r="";t||((r=Object.keys(a)).splice(r.indexOf(e),1),r=r.join(" ")),o.selection.save(),o.html.wrap(!0,!0,!0,!0),o.selection.restore();var n=o.selection.blocks();o.selection.save();for(var s=i(n[0]).hasClass(e),l=0;l<n.length;l++)i(n[l]).removeClass(r).toggleClass(e,!s),i(n[l]).hasClass("fr-temp-div")&&i(n[l]).removeClass("fr-temp-div"),""===i(n[l]).attr("class")&&i(n[l]).removeAttr("class");o.html.unwrap(),o.selection.restore()},refreshOnShow:function(e,a){var t=o.selection.blocks();if(t.length){var r=i(t[0]);a.find(".fr-command").each(function(){var e=i(this).data("param1"),a=r.hasClass(e);i(this).toggleClass("fr-active",a).attr("aria-selected",a)})}}}},i.FE.RegisterCommand("paragraphStyle",{type:"dropdown",html:function(){var e='<ul class="fr-dropdown-list" role="presentation">',a=this.opts.paragraphStyles;for(var t in a)a.hasOwnProperty(t)&&(e+='<li role="presentation"><a class="fr-command '+t+'" tabIndex="-1" role="option" data-cmd="paragraphStyle" data-param1="'+t+'" title="'+this.language.translate(a[t])+'">'+this.language.translate(a[t])+"</a></li>");return e+="</ul>"},title:"Paragraph Style",callback:function(e,a){this.paragraphStyle.apply(a)},refreshOnShow:function(e,a){this.paragraphStyle.refreshOnShow(e,a)},plugin:"paragraphStyle"}),i.FE.DefineIcon("paragraphStyle",{NAME:"magic"})});
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2018 Froala Labs
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function (factory) {
|
8
|
+
if (typeof define === 'function' && define.amd) {
|
9
|
+
// AMD. Register as an anonymous module.
|
10
|
+
define(['jquery'], factory);
|
11
|
+
} else if (typeof module === 'object' && module.exports) {
|
12
|
+
// Node/CommonJS
|
13
|
+
module.exports = function( root, jQuery ) {
|
14
|
+
if ( jQuery === undefined ) {
|
15
|
+
// require('jQuery') returns a factory that requires window to
|
16
|
+
// build a jQuery instance, we normalize how we use modules
|
17
|
+
// that require this pattern but the window provided is a noop
|
18
|
+
// if it's defined (how jquery works)
|
19
|
+
if ( typeof window !== 'undefined' ) {
|
20
|
+
jQuery = require('jquery');
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
jQuery = require('jquery')(root);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return factory(jQuery);
|
27
|
+
};
|
28
|
+
} else {
|
29
|
+
// Browser globals
|
30
|
+
factory(window.jQuery);
|
31
|
+
}
|
32
|
+
}(function ($) {
|
33
|
+
|
34
|
+
$.FE.PLUGINS.plainPaste = function (editor) {
|
35
|
+
|
36
|
+
function show () {
|
37
|
+
var html_overlay = '<div class="ke-overlay"></div>';
|
38
|
+
var html_text_header = '<div class="ke-text-hrader"><span class="ke-text-left">文本无格式粘贴</span><span class="ke-text-right"><i class="fa fa-times ke-remove fa-1x" aria-hidden="true"></i></span></div>';
|
39
|
+
var html_text_content = '<div class="ke-text-content"><textarea class="ke-text-textarea"></textarea></div>';
|
40
|
+
var html_text_footer = '<div class="ke-text-footer"><button class="ke-remove remove">取消</button><button class="ke-submit submit">确认</button></div>';
|
41
|
+
var html_text = '<div class="html_text">'+html_text_header+html_text_content+html_text_footer+'</div>';
|
42
|
+
$("body").append(html_overlay+html_text);
|
43
|
+
_hide();
|
44
|
+
_pasteText()
|
45
|
+
}
|
46
|
+
|
47
|
+
/*
|
48
|
+
* Hide the image manager.
|
49
|
+
*/
|
50
|
+
function _hide () {
|
51
|
+
$(".ke-remove").click(function () {
|
52
|
+
$(".ke-overlay").remove();
|
53
|
+
$(".html_text").remove();
|
54
|
+
});
|
55
|
+
}
|
56
|
+
|
57
|
+
function _pasteText(){
|
58
|
+
$(".ke-submit").click(function () {
|
59
|
+
var Text = $(".ke-text-textarea").val();
|
60
|
+
html = _escape(Text);
|
61
|
+
html = html.replace(/ {2}/g, ' ');
|
62
|
+
html = html.replace(/^/, '<p>').replace(/$/, '</p>').replace(/\n/g, '</p><p>');
|
63
|
+
editor.html.insert(html);
|
64
|
+
$(".ke-overlay").remove();
|
65
|
+
$(".html_text").remove();
|
66
|
+
});
|
67
|
+
}
|
68
|
+
|
69
|
+
function _escape(val) {
|
70
|
+
return val.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
71
|
+
}
|
72
|
+
|
73
|
+
return {
|
74
|
+
require: ['text'],
|
75
|
+
show: show,
|
76
|
+
hide: _hide
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
$.FE.RegisterCommand('plainPaste', {
|
81
|
+
title: 'Clipboard',
|
82
|
+
undo: false,
|
83
|
+
focus: false,
|
84
|
+
modal: true,
|
85
|
+
callback: function () {
|
86
|
+
this.plainPaste.show();
|
87
|
+
},
|
88
|
+
plugin: 'plainPaste'
|
89
|
+
})
|
90
|
+
|
91
|
+
// Add the font size icon.
|
92
|
+
$.FE.DefineIcon('plainPaste', {
|
93
|
+
NAME: 'clipboard'
|
94
|
+
});
|
95
|
+
|
96
|
+
}));
|
@@ -0,0 +1,137 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2018 Froala Labs
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function (factory) {
|
8
|
+
if (typeof define === 'function' && define.amd) {
|
9
|
+
// AMD. Register as an anonymous module.
|
10
|
+
define(['jquery'], factory);
|
11
|
+
} else if (typeof module === 'object' && module.exports) {
|
12
|
+
// Node/CommonJS
|
13
|
+
module.exports = function( root, jQuery ) {
|
14
|
+
if ( jQuery === undefined ) {
|
15
|
+
// require('jQuery') returns a factory that requires window to
|
16
|
+
// build a jQuery instance, we normalize how we use modules
|
17
|
+
// that require this pattern but the window provided is a noop
|
18
|
+
// if it's defined (how jquery works)
|
19
|
+
if ( typeof window !== 'undefined' ) {
|
20
|
+
jQuery = require('jquery');
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
jQuery = require('jquery')(root);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return factory(jQuery);
|
27
|
+
};
|
28
|
+
} else {
|
29
|
+
// Browser globals
|
30
|
+
factory(window.jQuery);
|
31
|
+
}
|
32
|
+
}(function ($) {
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
$.FE.PLUGINS.print = function (editor) {
|
37
|
+
function run () {
|
38
|
+
|
39
|
+
// Get editor content for printing.
|
40
|
+
var contents = editor.$el.html();
|
41
|
+
|
42
|
+
// Get or create the iframe for printing.
|
43
|
+
var print_iframe = null;
|
44
|
+
|
45
|
+
if (editor.shared.print_iframe) {
|
46
|
+
print_iframe = editor.shared.print_iframe;
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
print_iframe = document.createElement('iframe');
|
50
|
+
print_iframe.name = 'fr-print';
|
51
|
+
print_iframe.style.position = 'fixed';
|
52
|
+
print_iframe.style.top = '0';
|
53
|
+
print_iframe.style.left = '-9999px';
|
54
|
+
print_iframe.style.height = '100%';
|
55
|
+
print_iframe.style.width = '0';
|
56
|
+
print_iframe.style.overflow = 'hidden';
|
57
|
+
print_iframe.style['z-index'] = '2147483647';
|
58
|
+
print_iframe.style.tabIndex = '-1';
|
59
|
+
document.body.appendChild(print_iframe);
|
60
|
+
|
61
|
+
// Iframe ready.
|
62
|
+
print_iframe.onload = function () {
|
63
|
+
setTimeout(function () {
|
64
|
+
|
65
|
+
// Focus iframe window.
|
66
|
+
editor.events.disableBlur();
|
67
|
+
window.frames['fr-print'].focus();
|
68
|
+
|
69
|
+
// Open printing window.
|
70
|
+
window.frames['fr-print'].print();
|
71
|
+
|
72
|
+
// Refocus editor's window.
|
73
|
+
editor.$win.get(0).focus();
|
74
|
+
|
75
|
+
// Focus editor.
|
76
|
+
editor.events.disableBlur();
|
77
|
+
editor.events.focus();
|
78
|
+
}, 0);
|
79
|
+
};
|
80
|
+
|
81
|
+
// Remove editor on shared destroy.
|
82
|
+
editor.events.on('shared.destroy', function () {
|
83
|
+
print_iframe.remove();
|
84
|
+
});
|
85
|
+
|
86
|
+
editor.shared.print_iframe = print_iframe;
|
87
|
+
}
|
88
|
+
|
89
|
+
// Build printing document.
|
90
|
+
var frame_doc = print_iframe.contentWindow;
|
91
|
+
frame_doc.document.open();
|
92
|
+
frame_doc.document.write('<!DOCTYPE html><html><head><title>' + document.title + '</title>');
|
93
|
+
|
94
|
+
// Add styles.
|
95
|
+
Array.prototype.forEach.call(document.querySelectorAll('style'), function (style_el) {
|
96
|
+
style_el = style_el.cloneNode(true);
|
97
|
+
frame_doc.document.write(style_el.outerHTML);
|
98
|
+
});
|
99
|
+
|
100
|
+
// Add css links.
|
101
|
+
var style_elements = document.querySelectorAll('link[rel=stylesheet]');
|
102
|
+
|
103
|
+
Array.prototype.forEach.call(style_elements, function (link_el) {
|
104
|
+
var new_link_el = document.createElement('link');
|
105
|
+
new_link_el.rel = link_el.rel;
|
106
|
+
new_link_el.href = link_el.href;
|
107
|
+
new_link_el.media = 'print';
|
108
|
+
new_link_el.type = 'text/css';
|
109
|
+
new_link_el.media = 'all';
|
110
|
+
frame_doc.document.write(new_link_el.outerHTML);
|
111
|
+
});
|
112
|
+
|
113
|
+
frame_doc.document.write('</head><body style="text-align: ' + (editor.opts.direction == 'rtl' ? 'right' : 'left') + '; direction: ' + editor.opts.direction + ';"><div class="fr-view">');
|
114
|
+
|
115
|
+
// Add editor contents.
|
116
|
+
frame_doc.document.write(contents);
|
117
|
+
frame_doc.document.write('</div></body></html>');
|
118
|
+
frame_doc.document.close();
|
119
|
+
}
|
120
|
+
|
121
|
+
return {
|
122
|
+
run: run
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
$.FE.DefineIcon('print', { NAME: 'print' });
|
127
|
+
$.FE.RegisterCommand('print', {
|
128
|
+
title: 'Print',
|
129
|
+
undo: false,
|
130
|
+
focus: false,
|
131
|
+
plugin: 'print',
|
132
|
+
callback: function () {
|
133
|
+
this.print.run();
|
134
|
+
}
|
135
|
+
});
|
136
|
+
|
137
|
+
}));
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2018 Froala Labs
|
5
|
+
*/
|
6
|
+
|
7
|
+
!function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(e,t){return t===undefined&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),n(t)}:n(window.jQuery)}(function(e){e.FE.PLUGINS.print=function(i){return{run:function(){var e=i.$el.html(),t=null;i.shared.print_iframe?t=i.shared.print_iframe:((t=document.createElement("iframe")).name="fr-print",t.style.position="fixed",t.style.top="0",t.style.left="-9999px",t.style.height="100%",t.style.width="0",t.style.overflow="hidden",t.style["z-index"]="2147483647",t.style.tabIndex="-1",document.body.appendChild(t),t.onload=function(){setTimeout(function(){i.events.disableBlur(),window.frames["fr-print"].focus(),window.frames["fr-print"].print(),i.$win.get(0).focus(),i.events.disableBlur(),i.events.focus()},0)},i.events.on("shared.destroy",function(){t.remove()}),i.shared.print_iframe=t);var n=t.contentWindow;n.document.open(),n.document.write("<!DOCTYPE html><html><head><title>"+document.title+"</title>"),Array.prototype.forEach.call(document.querySelectorAll("style"),function(e){e=e.cloneNode(!0),n.document.write(e.outerHTML)});var r=document.querySelectorAll("link[rel=stylesheet]");Array.prototype.forEach.call(r,function(e){var t=document.createElement("link");t.rel=e.rel,t.href=e.href,t.media="print",t.type="text/css",t.media="all",n.document.write(t.outerHTML)}),n.document.write('</head><body style="text-align: '+("rtl"==i.opts.direction?"right":"left")+"; direction: "+i.opts.direction+';"><div class="fr-view">'),n.document.write(e),n.document.write("</div></body></html>"),n.document.close()}}},e.FE.DefineIcon("print",{NAME:"print"}),e.FE.RegisterCommand("print",{title:"Print",undo:!1,focus:!1,plugin:"print",callback:function(){this.print.run()}})});
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2018 Froala Labs
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function (factory) {
|
8
|
+
if (typeof define === 'function' && define.amd) {
|
9
|
+
// AMD. Register as an anonymous module.
|
10
|
+
define(['jquery'], factory);
|
11
|
+
} else if (typeof module === 'object' && module.exports) {
|
12
|
+
// Node/CommonJS
|
13
|
+
module.exports = function( root, jQuery ) {
|
14
|
+
if ( jQuery === undefined ) {
|
15
|
+
// require('jQuery') returns a factory that requires window to
|
16
|
+
// build a jQuery instance, we normalize how we use modules
|
17
|
+
// that require this pattern but the window provided is a noop
|
18
|
+
// if it's defined (how jquery works)
|
19
|
+
if ( typeof window !== 'undefined' ) {
|
20
|
+
jQuery = require('jquery');
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
jQuery = require('jquery')(root);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return factory(jQuery);
|
27
|
+
};
|
28
|
+
} else {
|
29
|
+
// Browser globals
|
30
|
+
factory(window.jQuery);
|
31
|
+
}
|
32
|
+
}(function ($) {
|
33
|
+
|
34
|
+
$.FE.PLUGINS.quickFormat = function (editor) {
|
35
|
+
|
36
|
+
function show () {
|
37
|
+
var html = editor.html.get();
|
38
|
+
var result=html.replace(/style="[^"]+"/ig,"");//把'is'替换为空字符串
|
39
|
+
result=result.replace(/<p><br><\/p>/ig,"");//把'is'替换为空字符串
|
40
|
+
result=result.replace(/<p ><br><\/p>/ig,"");//把'is'替换为空字符串
|
41
|
+
|
42
|
+
var html_arr = result.split("</p><p>");
|
43
|
+
var html_text='';
|
44
|
+
for(var i=0;i< html_arr.length;i++){
|
45
|
+
if (i==0){
|
46
|
+
var text = html_arr[0].replace('<p>',"");
|
47
|
+
html_text += '<p style="text-indent:2em;">'+text+'</p>';
|
48
|
+
}else if(i==html_arr.length-1){
|
49
|
+
var text_ = html_arr[i].replace('</p>',"");
|
50
|
+
html_text += '<p style="text-indent:2em;">'+text_+'</p>';
|
51
|
+
}else if(html_arr[i].indexOf("img") > 0 ){
|
52
|
+
html_text +='<p>'+html_arr[i]+'</p>';
|
53
|
+
}else if(html_arr[i].indexOf("video") > 0 ){
|
54
|
+
html_text +='<p>'+html_arr[i]+'</p>';
|
55
|
+
}else {
|
56
|
+
html_text += '<p style="text-indent:2em;">' + html_arr[i] + '</p>';
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
if(html_text){
|
61
|
+
editor.html.set('');
|
62
|
+
editor.html.insert(html_text);
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
return {
|
68
|
+
require: ['text'],
|
69
|
+
show: show,
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
$.FE.RegisterCommand('quickFormat', {
|
74
|
+
title: 'quickFormat',
|
75
|
+
undo: false,
|
76
|
+
focus: false,
|
77
|
+
modal: true,
|
78
|
+
callback: function () {
|
79
|
+
this.quickFormat.show();
|
80
|
+
},
|
81
|
+
plugin: 'quickFormat'
|
82
|
+
})
|
83
|
+
|
84
|
+
// Add the font size icon.
|
85
|
+
$.FE.DefineIcon('quickFormat', {
|
86
|
+
NAME: 'pencil-square-o'
|
87
|
+
});
|
88
|
+
|
89
|
+
}));
|
@@ -0,0 +1,478 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2018 Froala Labs
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function (factory) {
|
8
|
+
if (typeof define === 'function' && define.amd) {
|
9
|
+
// AMD. Register as an anonymous module.
|
10
|
+
define(['jquery'], factory);
|
11
|
+
} else if (typeof module === 'object' && module.exports) {
|
12
|
+
// Node/CommonJS
|
13
|
+
module.exports = function( root, jQuery ) {
|
14
|
+
if ( jQuery === undefined ) {
|
15
|
+
// require('jQuery') returns a factory that requires window to
|
16
|
+
// build a jQuery instance, we normalize how we use modules
|
17
|
+
// that require this pattern but the window provided is a noop
|
18
|
+
// if it's defined (how jquery works)
|
19
|
+
if ( typeof window !== 'undefined' ) {
|
20
|
+
jQuery = require('jquery');
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
jQuery = require('jquery')(root);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return factory(jQuery);
|
27
|
+
};
|
28
|
+
} else {
|
29
|
+
// Browser globals
|
30
|
+
factory(window.jQuery);
|
31
|
+
}
|
32
|
+
}(function ($) {
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
// Extend defaults.
|
37
|
+
$.extend($.FE.DEFAULTS, {
|
38
|
+
quickInsertButtons: ['image', 'video', 'embedly', 'table', 'ul', 'ol', 'hr'],
|
39
|
+
quickInsertTags: ['p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'blockquote']
|
40
|
+
});
|
41
|
+
|
42
|
+
$.FE.QUICK_INSERT_BUTTONS = {}
|
43
|
+
|
44
|
+
$.FE.DefineIcon('quickInsert', {
|
45
|
+
PATH: '<path d="M22,16.75 L16.75,16.75 L16.75,22 L15.25,22.000 L15.25,16.75 L10,16.75 L10,15.25 L15.25,15.25 L15.25,10 L16.75,10 L16.75,15.25 L22,15.25 L22,16.75 Z"/>',
|
46
|
+
template: 'svg'
|
47
|
+
});
|
48
|
+
|
49
|
+
$.FE.RegisterQuickInsertButton = function (name, data) {
|
50
|
+
$.FE.QUICK_INSERT_BUTTONS[name] = $.extend({
|
51
|
+
undo: true
|
52
|
+
}, data);
|
53
|
+
}
|
54
|
+
|
55
|
+
$.FE.RegisterQuickInsertButton('image', {
|
56
|
+
icon: 'insertImage',
|
57
|
+
requiredPlugin: 'image',
|
58
|
+
title: 'Insert Image',
|
59
|
+
undo: false,
|
60
|
+
callback: function () {
|
61
|
+
var editor = this;
|
62
|
+
|
63
|
+
if (!editor.shared.$qi_image_input) {
|
64
|
+
editor.shared.$qi_image_input = $('<input accept="image/*" name="quickInsertImage' + this.id + '" style="display: none;" type="file">');
|
65
|
+
$('body:first').append(editor.shared.$qi_image_input);
|
66
|
+
|
67
|
+
editor.events.$on(editor.shared.$qi_image_input, 'change', function () {
|
68
|
+
var inst = $(this).data('inst');
|
69
|
+
|
70
|
+
if (this.files) {
|
71
|
+
inst.quickInsert.hide();
|
72
|
+
inst.image.upload(this.files);
|
73
|
+
}
|
74
|
+
|
75
|
+
// Chrome fix.
|
76
|
+
$(this).val('');
|
77
|
+
}, true);
|
78
|
+
}
|
79
|
+
|
80
|
+
editor.$qi_image_input = editor.shared.$qi_image_input;
|
81
|
+
|
82
|
+
if (editor.helpers.isMobile()) editor.selection.save();
|
83
|
+
editor.events.disableBlur();
|
84
|
+
editor.$qi_image_input.data('inst', editor).trigger('click');
|
85
|
+
}
|
86
|
+
})
|
87
|
+
|
88
|
+
$.FE.RegisterQuickInsertButton('video', {
|
89
|
+
icon: 'insertVideo',
|
90
|
+
requiredPlugin: 'video',
|
91
|
+
title: 'Insert Video',
|
92
|
+
undo: false,
|
93
|
+
callback: function () {
|
94
|
+
var res = prompt(this.language.translate('Paste the URL of the video you want to insert.'));
|
95
|
+
|
96
|
+
if (res) {
|
97
|
+
this.video.insertByURL(res);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
})
|
101
|
+
|
102
|
+
$.FE.RegisterQuickInsertButton('embedly', {
|
103
|
+
icon: 'embedly',
|
104
|
+
requiredPlugin: 'embedly',
|
105
|
+
title: 'Embed URL',
|
106
|
+
undo: false,
|
107
|
+
callback: function () {
|
108
|
+
var res = prompt(this.language.translate('Paste the URL of any web content you want to insert.'));
|
109
|
+
|
110
|
+
if (res) {
|
111
|
+
this.embedly.add(res);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
})
|
115
|
+
|
116
|
+
$.FE.RegisterQuickInsertButton('table', {
|
117
|
+
icon: 'insertTable',
|
118
|
+
requiredPlugin: 'table',
|
119
|
+
title: 'Insert Table',
|
120
|
+
callback: function () {
|
121
|
+
this.table.insert(2, 2);
|
122
|
+
}
|
123
|
+
})
|
124
|
+
|
125
|
+
$.FE.RegisterQuickInsertButton('ol', {
|
126
|
+
icon: 'formatOL',
|
127
|
+
requiredPlugin: 'lists',
|
128
|
+
title: 'Ordered List',
|
129
|
+
callback: function () {
|
130
|
+
this.lists.format('OL');
|
131
|
+
}
|
132
|
+
})
|
133
|
+
|
134
|
+
$.FE.RegisterQuickInsertButton('ul', {
|
135
|
+
icon: 'formatUL',
|
136
|
+
requiredPlugin: 'lists',
|
137
|
+
title: 'Unordered List',
|
138
|
+
callback: function () {
|
139
|
+
this.lists.format('UL');
|
140
|
+
}
|
141
|
+
})
|
142
|
+
|
143
|
+
$.FE.RegisterQuickInsertButton('hr', {
|
144
|
+
icon: 'insertHR',
|
145
|
+
title: 'Insert Horizontal Line',
|
146
|
+
callback: function () {
|
147
|
+
this.commands.insertHR();
|
148
|
+
}
|
149
|
+
})
|
150
|
+
|
151
|
+
$.FE.PLUGINS.quickInsert = function (editor) {
|
152
|
+
var $quick_insert;
|
153
|
+
|
154
|
+
/*
|
155
|
+
* Set the quick insert button left and top.
|
156
|
+
*/
|
157
|
+
function _place($tag) {
|
158
|
+
|
159
|
+
// Quick insert's possition.
|
160
|
+
var qiTop;
|
161
|
+
var qiLeft;
|
162
|
+
var qiTagAlign;
|
163
|
+
|
164
|
+
qiTop = $tag.offset().top - editor.$box.offset().top;
|
165
|
+
qiLeft = 0 - $quick_insert.outerWidth();
|
166
|
+
|
167
|
+
if (editor.opts.enter != $.FE.ENTER_BR) {
|
168
|
+
qiTagAlign = ($quick_insert.outerHeight() - $tag.outerHeight()) / 2;
|
169
|
+
}
|
170
|
+
|
171
|
+
// Enter key is BR. Insert an empty SPAN to get line height.
|
172
|
+
else {
|
173
|
+
$('<span>' + $.FE.INVISIBLE_SPACE + '</span>').insertAfter($tag)
|
174
|
+
qiTagAlign = ($quick_insert.outerHeight() - $tag.next().outerHeight()) / 2;
|
175
|
+
$tag.next().remove()
|
176
|
+
}
|
177
|
+
|
178
|
+
if (editor.opts.iframe) {
|
179
|
+
qiTop += editor.$iframe.offset().top - editor.helpers.scrollTop();
|
180
|
+
}
|
181
|
+
|
182
|
+
// Reposition QI helper if visible.
|
183
|
+
if ($quick_insert.hasClass('fr-on')) {
|
184
|
+
if (qiTop >= 0) {
|
185
|
+
$helper.css('top', qiTop - qiTagAlign);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
// Set quick insert's top and left.
|
190
|
+
if (qiTop >= 0 && qiTop - qiTagAlign <= editor.$box.outerHeight() - $tag.outerHeight()) {
|
191
|
+
if ($quick_insert.hasClass('fr-hidden')) {
|
192
|
+
if ($quick_insert.hasClass('fr-on')) _showQIHelper();
|
193
|
+
$quick_insert.removeClass('fr-hidden');
|
194
|
+
}
|
195
|
+
|
196
|
+
$quick_insert.css('top', qiTop - qiTagAlign);
|
197
|
+
}
|
198
|
+
else if ($quick_insert.hasClass('fr-visible')) {
|
199
|
+
$quick_insert.addClass('fr-hidden');
|
200
|
+
_hideHelper();
|
201
|
+
}
|
202
|
+
|
203
|
+
$quick_insert.css('left', qiLeft);
|
204
|
+
}
|
205
|
+
|
206
|
+
/*
|
207
|
+
* Show quick insert.
|
208
|
+
* Compute top, left, width and show the quick insert.
|
209
|
+
*/
|
210
|
+
function _show($tag) {
|
211
|
+
if (!$quick_insert) _initquickInsert();
|
212
|
+
|
213
|
+
// Hide the quick insert helper if visible.
|
214
|
+
if ($quick_insert.hasClass('fr-on')) {
|
215
|
+
_hideHelper();
|
216
|
+
}
|
217
|
+
|
218
|
+
editor.$box.append($quick_insert);
|
219
|
+
|
220
|
+
// Quick insert's possition.
|
221
|
+
_place($tag);
|
222
|
+
|
223
|
+
$quick_insert.data('tag', $tag);
|
224
|
+
|
225
|
+
// Show the quick insert.
|
226
|
+
$quick_insert.addClass('fr-visible');
|
227
|
+
}
|
228
|
+
|
229
|
+
/*
|
230
|
+
* Check the tag where the cursor is.
|
231
|
+
*/
|
232
|
+
function _checkTag() {
|
233
|
+
// If editor has focus.
|
234
|
+
if (editor.core.hasFocus()) {
|
235
|
+
var tag = editor.selection.element();
|
236
|
+
|
237
|
+
// Get block tag if Enter key is not BR.
|
238
|
+
if (editor.opts.enter != $.FE.ENTER_BR && !editor.node.isBlock(tag)) {
|
239
|
+
tag = editor.node.blockParent(tag);
|
240
|
+
}
|
241
|
+
|
242
|
+
if (editor.opts.enter == $.FE.ENTER_BR && !editor.node.isBlock(tag)) {
|
243
|
+
var deep_tag = editor.node.deepestParent(tag);
|
244
|
+
|
245
|
+
if (deep_tag) tag = deep_tag;
|
246
|
+
}
|
247
|
+
|
248
|
+
var _enterInBR = function () {
|
249
|
+
return (editor.opts.enter != $.FE.ENTER_BR && editor.node.isEmpty(tag) && editor.node.isElement(tag.parentNode) && editor.opts.quickInsertTags.indexOf(tag.tagName.toLowerCase()) >= 0);
|
250
|
+
}
|
251
|
+
|
252
|
+
var _enterInP = function () {
|
253
|
+
return (
|
254
|
+
editor.opts.enter == $.FE.ENTER_BR &&
|
255
|
+
((tag.tagName == 'BR' && (!tag.previousSibling || tag.previousSibling.tagName == 'BR' || editor.node.isBlock(tag.previousSibling))) ||
|
256
|
+
(editor.node.isEmpty(tag) && (!tag.previousSibling || tag.previousSibling.tagName == 'BR' || editor.node.isBlock(tag.previousSibling)) && (!tag.nextSibling || tag.nextSibling.tagName == 'BR' || editor.node.isBlock(tag.nextSibling))))
|
257
|
+
);
|
258
|
+
}
|
259
|
+
|
260
|
+
if (tag && (_enterInBR() || _enterInP())) {
|
261
|
+
// If the quick insert is not repositioned, just close the helper.
|
262
|
+
if ($quick_insert && $quick_insert.data('tag').is($(tag)) && $quick_insert.hasClass('fr-on')) {
|
263
|
+
_hideHelper();
|
264
|
+
}
|
265
|
+
|
266
|
+
// If selection is collapsed.
|
267
|
+
else if (editor.selection.isCollapsed()) {
|
268
|
+
_show($(tag));
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
// Quick insert should not be visible.
|
273
|
+
else {
|
274
|
+
hide();
|
275
|
+
}
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
/*
|
280
|
+
* Hide quick insert.
|
281
|
+
*/
|
282
|
+
function hide() {
|
283
|
+
if ($quick_insert) {
|
284
|
+
// Hide the quick insert helper if visible.
|
285
|
+
if ($quick_insert.hasClass('fr-on')) {
|
286
|
+
_hideHelper();
|
287
|
+
}
|
288
|
+
|
289
|
+
// Hide the quick insert.
|
290
|
+
$quick_insert.removeClass('fr-visible fr-on');
|
291
|
+
$quick_insert.css('left', -9999).css('top', -9999);
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
/*
|
296
|
+
* Show the quick insert helper.
|
297
|
+
*/
|
298
|
+
var $helper;
|
299
|
+
|
300
|
+
function _showQIHelper(e) {
|
301
|
+
if (e) e.preventDefault();
|
302
|
+
|
303
|
+
// Hide helper.
|
304
|
+
if ($quick_insert.hasClass('fr-on') && !$quick_insert.hasClass('fr-hidden')) {
|
305
|
+
_hideHelper();
|
306
|
+
}
|
307
|
+
|
308
|
+
else {
|
309
|
+
if (!editor.shared.$qi_helper) {
|
310
|
+
var btns = editor.opts.quickInsertButtons;
|
311
|
+
var btns_html = '<div class="fr-qi-helper">';
|
312
|
+
var idx = 0;
|
313
|
+
|
314
|
+
for (var i = 0; i < btns.length; i++) {
|
315
|
+
var info = $.FE.QUICK_INSERT_BUTTONS[btns[i]];
|
316
|
+
|
317
|
+
if (info) {
|
318
|
+
if (!info.requiredPlugin || ($.FE.PLUGINS[info.requiredPlugin] && editor.opts.pluginsEnabled.indexOf(info.requiredPlugin) >= 0)) {
|
319
|
+
btns_html += '<a class="fr-btn fr-floating-btn" role="button" title="' + editor.language.translate(info.title) + '" tabIndex="-1" data-cmd="' + btns[i] + '" style="transition-delay: ' + (0.025 * (idx++)) + 's;">' + editor.icon.create(info.icon) + '</a>';
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
btns_html += '</div>';
|
325
|
+
editor.shared.$qi_helper = $(btns_html);
|
326
|
+
|
327
|
+
// Quick insert helper tooltip.
|
328
|
+
editor.tooltip.bind(editor.shared.$qi_helper, '> a.fr-btn');
|
329
|
+
|
330
|
+
editor.events.$on(editor.shared.$qi_helper, 'mousedown', function (e) {
|
331
|
+
e.preventDefault();
|
332
|
+
}, true);
|
333
|
+
}
|
334
|
+
|
335
|
+
$helper = editor.shared.$qi_helper;
|
336
|
+
$helper.appendTo(editor.$box);
|
337
|
+
|
338
|
+
// Show the quick insert helper.
|
339
|
+
setTimeout(function () {
|
340
|
+
$helper.css('top', parseFloat($quick_insert.css('top')));
|
341
|
+
$helper.css('left', parseFloat($quick_insert.css('left')) + $quick_insert.outerWidth());
|
342
|
+
$helper.find('a').addClass('fr-size-1')
|
343
|
+
$quick_insert.addClass('fr-on');
|
344
|
+
}, 10);
|
345
|
+
}
|
346
|
+
}
|
347
|
+
|
348
|
+
/*
|
349
|
+
* Hides the quick insert helper and places the cursor.
|
350
|
+
*/
|
351
|
+
function _hideHelper() {
|
352
|
+
var $helper = editor.$box.find('.fr-qi-helper');
|
353
|
+
|
354
|
+
if ($helper.length) {
|
355
|
+
$helper.find('a').removeClass('fr-size-1');
|
356
|
+
$helper.css('left', -9999);
|
357
|
+
|
358
|
+
if (!$quick_insert.hasClass('fr-hidden')) $quick_insert.removeClass('fr-on');
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
362
|
+
/*
|
363
|
+
* Initialize the quick insert.
|
364
|
+
*/
|
365
|
+
function _initquickInsert() {
|
366
|
+
if (!editor.shared.$quick_insert) {
|
367
|
+
// Append quick insert HTML to editor wrapper.
|
368
|
+
editor.shared.$quick_insert = $('<div class="fr-quick-insert"><a class="fr-floating-btn" role="button" tabIndex="-1" title="' + editor.language.translate('Quick Insert') + '">' + editor.icon.create('quickInsert') + '</a></div>');
|
369
|
+
}
|
370
|
+
|
371
|
+
$quick_insert = editor.shared.$quick_insert;
|
372
|
+
|
373
|
+
// Quick Insert tooltip.
|
374
|
+
editor.tooltip.bind(editor.$box, '.fr-quick-insert > a.fr-floating-btn');
|
375
|
+
|
376
|
+
// Editor destroy.
|
377
|
+
editor.events.on('destroy', function () {
|
378
|
+
$quick_insert.removeClass('fr-on').appendTo($('body:first')).css('left', -9999).css('top', -9999);
|
379
|
+
|
380
|
+
if ($helper) {
|
381
|
+
_hideHelper();
|
382
|
+
$helper.appendTo($('body:first'));
|
383
|
+
}
|
384
|
+
}, true);
|
385
|
+
|
386
|
+
editor.events.on('shared.destroy', function () {
|
387
|
+
$quick_insert.html('').removeData().remove();
|
388
|
+
$quick_insert = null;
|
389
|
+
|
390
|
+
if ($helper) {
|
391
|
+
$helper.html('').removeData().remove();
|
392
|
+
$helper = null;
|
393
|
+
}
|
394
|
+
}, true);
|
395
|
+
|
396
|
+
// Hide before a command is executed.
|
397
|
+
editor.events.on('commands.before', hide);
|
398
|
+
|
399
|
+
// Check if the quick insert should be shown after a command has been executed.
|
400
|
+
editor.events.on('commands.after', function () {
|
401
|
+
if (!editor.popups.areVisible()) {
|
402
|
+
_checkTag();
|
403
|
+
}
|
404
|
+
});
|
405
|
+
|
406
|
+
// User clicks on the quick insert.
|
407
|
+
editor.events.bindClick(editor.$box, '.fr-quick-insert > a', _showQIHelper);
|
408
|
+
|
409
|
+
// User clicks on a button from the quick insert helper.
|
410
|
+
editor.events.bindClick(editor.$box, '.fr-qi-helper > a.fr-btn', function (e) {
|
411
|
+
var cmd = $(e.currentTarget).data('cmd');
|
412
|
+
|
413
|
+
// Trigger commands.before.
|
414
|
+
if (editor.events.trigger('quickInsert.commands.before', [cmd]) === false) {
|
415
|
+
return false;
|
416
|
+
}
|
417
|
+
|
418
|
+
$.FE.QUICK_INSERT_BUTTONS[cmd].callback.apply(editor, [e.currentTarget]);
|
419
|
+
|
420
|
+
if ($.FE.QUICK_INSERT_BUTTONS[cmd].undo) {
|
421
|
+
editor.undo.saveStep();
|
422
|
+
}
|
423
|
+
|
424
|
+
// Trigger commands.after.
|
425
|
+
editor.events.trigger('quickInsert.commands.after', [cmd]);
|
426
|
+
|
427
|
+
editor.quickInsert.hide();
|
428
|
+
});
|
429
|
+
|
430
|
+
// Scroll in editor wrapper. Quick insert buttons should scroll along
|
431
|
+
editor.events.$on(editor.$wp, 'scroll', function () {
|
432
|
+
if ($quick_insert.hasClass('fr-visible')) {
|
433
|
+
_place($quick_insert.data('tag'));
|
434
|
+
}
|
435
|
+
});
|
436
|
+
}
|
437
|
+
|
438
|
+
/*
|
439
|
+
* Tear up.
|
440
|
+
*/
|
441
|
+
function _init() {
|
442
|
+
if (!editor.$wp) return false;
|
443
|
+
|
444
|
+
if (editor.opts.iframe) {
|
445
|
+
editor.$el.parent('html').find('head').append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">');
|
446
|
+
}
|
447
|
+
|
448
|
+
// Hide the quick insert if user click on an image.
|
449
|
+
editor.popups.onShow('image.edit', hide);
|
450
|
+
|
451
|
+
// Check tag where cursor is to see if the quick insert needs to be shown.
|
452
|
+
editor.events.on('mouseup', _checkTag);
|
453
|
+
|
454
|
+
if (editor.helpers.isMobile()) {
|
455
|
+
editor.events.$on($(editor.o_doc), 'selectionchange', _checkTag);
|
456
|
+
}
|
457
|
+
|
458
|
+
// Hide the quick insert when editor loses focus.
|
459
|
+
editor.events.on('blur', hide);
|
460
|
+
|
461
|
+
// Check if the quick insert should be shown after a key was pressed.
|
462
|
+
editor.events.on('keyup', _checkTag);
|
463
|
+
|
464
|
+
// Hide quick insert on keydown.
|
465
|
+
editor.events.on('keydown', function () {
|
466
|
+
setTimeout(function () {
|
467
|
+
_checkTag();
|
468
|
+
}, 0);
|
469
|
+
});
|
470
|
+
}
|
471
|
+
|
472
|
+
return {
|
473
|
+
_init: _init,
|
474
|
+
hide: hide
|
475
|
+
}
|
476
|
+
};
|
477
|
+
|
478
|
+
}));
|