vue_crud 0.1.9.6 → 0.1.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/vue_crud/froala_generator.rb +12 -0
- data/lib/generators/vue_crud/sortable.rb +10 -0
- data/lib/generators/vue_crud/templates/assets/images/froala_editor/color_picker.png +0 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/froala_editor.js +11089 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/languages/en_gb.js +178 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/languages/zh_cn.js +234 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/languages/zh_tw.js +234 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/align.js +119 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/char_counter.js +150 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/code_beautifier.js +3271 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/code_view.js +311 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/colors.js +350 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/draggable.js +379 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/emoticons.js +347 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/entities.js +113 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/file.js +609 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/font_family.js +178 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/font_size.js +116 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/forms.js +415 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/fullscreen.js +209 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/image.js +2401 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/image_manager.js +921 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/inline_style.js +86 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/line_breaker.js +435 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/link.js +997 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/lists.js +382 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/paragraph_format.js +293 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/paragraph_style.js +139 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/quick_insert.js +342 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/quote.js +138 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/save.js +176 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/table.js +3123 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/url.js +113 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/video.js +1135 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/sortable.js +1249 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/froala_editor.scss +1008 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/froala_style.scss +273 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/char_counter.scss +46 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/code_view.scss +102 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/colors.scss +129 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/draggable.scss +32 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/emoticons.scss +27 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/file.scss +135 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/fullscreen.scss +28 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/image.scss +233 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/image_manager.scss +370 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/line_breaker.scss +26 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/quick_insert.scss +56 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/table.scss +156 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/video.scss +136 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/themes/dark.scss +1087 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/themes/gray.scss +1087 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/themes/red.scss +1087 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/themes/royal.scss +1087 -0
- data/lib/generators/vue_crud/templates/vue_crud.html +54 -71
- data/lib/vue_crud/version.rb +1 -1
- data/vendor/assets/javascripts/vue_crud.js +212 -59
- metadata +56 -2
data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/inline_style.js
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.3.3 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2016 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
|
+
factory(jQuery);
|
27
|
+
return jQuery;
|
28
|
+
};
|
29
|
+
} else {
|
30
|
+
// Browser globals
|
31
|
+
factory(jQuery);
|
32
|
+
}
|
33
|
+
}(function ($) {
|
34
|
+
|
35
|
+
'use strict';
|
36
|
+
|
37
|
+
$.extend($.FE.DEFAULTS, {
|
38
|
+
inlineStyles: {
|
39
|
+
'Big Red': 'font-size: 20px; color: red;',
|
40
|
+
'Small Blue': 'font-size: 14px; color: blue;'
|
41
|
+
}
|
42
|
+
})
|
43
|
+
|
44
|
+
$.FE.PLUGINS.inlineStyle = function (editor) {
|
45
|
+
function apply (val) {
|
46
|
+
if (editor.selection.text() !== '') {
|
47
|
+
editor.html.insert($.FE.START_MARKER + '<span style="' + val + '">' + editor.selection.text() + '</span>' + $.FE.END_MARKER);
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
editor.html.insert('<span style="' + val + '">' + $.FE.INVISIBLE_SPACE + $.FE.MARKERS + '</span>');
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
return {
|
55
|
+
apply: apply
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
// Register the inline style command.
|
60
|
+
$.FE.RegisterCommand('inlineStyle', {
|
61
|
+
type: 'dropdown',
|
62
|
+
html: function () {
|
63
|
+
var c = '<ul class="fr-dropdown-list">';
|
64
|
+
var options = this.opts.inlineStyles;
|
65
|
+
for (var val in options) {
|
66
|
+
if (options.hasOwnProperty(val)) {
|
67
|
+
c += '<li><span style="' + options[val] + '"><a class="fr-command" data-cmd="inlineStyle" data-param1="' + options[val] + '" title="' + this.language.translate(val) + '">' + this.language.translate(val) + '</a></span></li>';
|
68
|
+
}
|
69
|
+
}
|
70
|
+
c += '</ul>';
|
71
|
+
|
72
|
+
return c;
|
73
|
+
},
|
74
|
+
title: 'Inline Style',
|
75
|
+
callback: function (cmd, val) {
|
76
|
+
this.inlineStyle.apply(val);
|
77
|
+
},
|
78
|
+
plugin: 'inlineStyle'
|
79
|
+
})
|
80
|
+
|
81
|
+
// Add the font size icon.
|
82
|
+
$.FE.DefineIcon('inlineStyle', {
|
83
|
+
NAME: 'paint-brush'
|
84
|
+
});
|
85
|
+
|
86
|
+
}));
|
data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/line_breaker.js
ADDED
@@ -0,0 +1,435 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.3.3 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2016 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
|
+
factory(jQuery);
|
27
|
+
return jQuery;
|
28
|
+
};
|
29
|
+
} else {
|
30
|
+
// Browser globals
|
31
|
+
factory(jQuery);
|
32
|
+
}
|
33
|
+
}(function ($) {
|
34
|
+
|
35
|
+
'use strict';
|
36
|
+
|
37
|
+
// Extend defaults.
|
38
|
+
$.extend($.FE.DEFAULTS, {
|
39
|
+
lineBreakerTags: ['table', 'hr', 'form', 'dl', 'span.fr-video'],
|
40
|
+
lineBreakerOffset: 15
|
41
|
+
});
|
42
|
+
|
43
|
+
$.FE.PLUGINS.lineBreaker = function (editor) {
|
44
|
+
var $line_breaker;
|
45
|
+
var mouseDownFlag;
|
46
|
+
var mouseMoveTimer;
|
47
|
+
|
48
|
+
/*
|
49
|
+
* Show line breaker.
|
50
|
+
* Compute top, left, width and show the line breaker.
|
51
|
+
* tag1 and tag2 are the tags between which the line breaker must be showed.
|
52
|
+
* If tag1 is null then tag2 is the first tag in the editor.
|
53
|
+
* If tag2 is null then tag1 is the last tag in the editor.
|
54
|
+
*/
|
55
|
+
function _show ($tag1, $tag2) {
|
56
|
+
// Line breaker's possition and width.
|
57
|
+
var breakerTop;
|
58
|
+
var breakerLeft;
|
59
|
+
var breakerWidth;
|
60
|
+
var parent_tag;
|
61
|
+
var parent_top;
|
62
|
+
var parent_bottom;
|
63
|
+
var tag_top;
|
64
|
+
var tag_bottom;
|
65
|
+
|
66
|
+
// Mouse is over the first tag in the editor. Show line breaker above tag2.
|
67
|
+
if ($tag1 == null) {
|
68
|
+
// Compute line breaker's possition and width.
|
69
|
+
parent_tag = $tag2.parent();
|
70
|
+
parent_top = parent_tag.offset().top;
|
71
|
+
tag_top = $tag2.offset().top;
|
72
|
+
|
73
|
+
breakerTop = tag_top - Math.min((tag_top - parent_top) / 2, editor.opts.lineBreakerOffset);
|
74
|
+
breakerWidth = parent_tag.outerWidth();
|
75
|
+
breakerLeft = parent_tag.offset().left;
|
76
|
+
|
77
|
+
// Mouse is over the last tag in the editor. Show line breaker below tag1.
|
78
|
+
} else if ($tag2 == null) {
|
79
|
+
// Compute line breaker's possition and width.
|
80
|
+
parent_tag = $tag1.parent();
|
81
|
+
parent_bottom = parent_tag.offset().top + parent_tag.outerHeight();
|
82
|
+
tag_bottom = $tag1.offset().top + $tag1.outerHeight();
|
83
|
+
|
84
|
+
breakerTop = tag_bottom + Math.min((parent_bottom - tag_bottom) / 2, editor.opts.lineBreakerOffset);
|
85
|
+
breakerWidth = parent_tag.outerWidth();
|
86
|
+
breakerLeft = parent_tag.offset().left;
|
87
|
+
|
88
|
+
// Mouse is between the 2 tags.
|
89
|
+
} else {
|
90
|
+
// Compute line breaker's possition and width.
|
91
|
+
parent_tag = $tag1.parent();
|
92
|
+
var tag1_bottom = $tag1.offset().top + $tag1.height();
|
93
|
+
var tag2_top = $tag2.offset().top;
|
94
|
+
|
95
|
+
// Tags may be on the same line, so there is no need for line breaker.
|
96
|
+
if (tag1_bottom > tag2_top) {
|
97
|
+
return false;
|
98
|
+
}
|
99
|
+
|
100
|
+
breakerTop = (tag1_bottom + tag2_top) / 2;
|
101
|
+
breakerWidth = parent_tag.outerWidth();
|
102
|
+
breakerLeft = parent_tag.offset().left;
|
103
|
+
}
|
104
|
+
|
105
|
+
if (editor.opts.iframe) {
|
106
|
+
breakerLeft += editor.$iframe.offset().left - $(editor.o_win).scrollLeft();
|
107
|
+
breakerTop += editor.$iframe.offset().top - $(editor.o_win).scrollTop();
|
108
|
+
}
|
109
|
+
|
110
|
+
editor.$box.append($line_breaker);
|
111
|
+
|
112
|
+
// Set line breaker's top, left and width.
|
113
|
+
$line_breaker.css('top', breakerTop - editor.win.pageYOffset);
|
114
|
+
$line_breaker.css('left', breakerLeft - editor.win.pageXOffset);
|
115
|
+
$line_breaker.css('width', breakerWidth);
|
116
|
+
|
117
|
+
$line_breaker.data('tag1', $tag1);
|
118
|
+
$line_breaker.data('tag2', $tag2);
|
119
|
+
|
120
|
+
// Show the line breaker.
|
121
|
+
$line_breaker.addClass('fr-visible').data('instance', editor);
|
122
|
+
}
|
123
|
+
|
124
|
+
/*
|
125
|
+
* Check tag siblings.
|
126
|
+
* The line breaker hould appear if there is no sibling or if the sibling is also in the line breaker tags list.
|
127
|
+
*/
|
128
|
+
function _checkTagSiblings ($tag, mouseY) {
|
129
|
+
// Tag's Y top and bottom coordinate.
|
130
|
+
var tag_top = $tag.offset().top;
|
131
|
+
var tag_bottom = $tag.offset().top + $tag.outerHeight();
|
132
|
+
var $sibling;
|
133
|
+
var tag;
|
134
|
+
|
135
|
+
// Only if the mouse is close enough to the bottom or top edges.
|
136
|
+
if (Math.abs(tag_bottom - mouseY) <= editor.opts.lineBreakerOffset ||
|
137
|
+
Math.abs(mouseY - tag_top) <= editor.opts.lineBreakerOffset) {
|
138
|
+
|
139
|
+
// Mouse is near bottom check for next sibling.
|
140
|
+
if (Math.abs(tag_bottom - mouseY) < Math.abs(mouseY - tag_top)) {
|
141
|
+
tag = $tag.get(0);
|
142
|
+
|
143
|
+
var next_node = tag.nextSibling;
|
144
|
+
while (next_node && next_node.nodeType == Node.TEXT_NODE && next_node.textContent.length === 0) {
|
145
|
+
next_node = next_node.nextSibling;
|
146
|
+
}
|
147
|
+
|
148
|
+
// Tag has next sibling.
|
149
|
+
if (next_node) {
|
150
|
+
$sibling = _checkTag(next_node);
|
151
|
+
|
152
|
+
// Sibling is in the line breaker tags list.
|
153
|
+
if ($sibling) {
|
154
|
+
// Show line breaker.
|
155
|
+
_show($tag, $sibling);
|
156
|
+
return true;
|
157
|
+
}
|
158
|
+
|
159
|
+
// No next sibling.
|
160
|
+
} else {
|
161
|
+
// Show line breaker
|
162
|
+
_show($tag, null);
|
163
|
+
return true;
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
// Mouse is near top check for prev sibling.
|
168
|
+
else {
|
169
|
+
tag = $tag.get(0);
|
170
|
+
|
171
|
+
// No prev sibling.
|
172
|
+
if (!tag.previousSibling) {
|
173
|
+
// Show line breaker
|
174
|
+
_show(null, $tag);
|
175
|
+
return true;
|
176
|
+
|
177
|
+
// Tag has prev sibling.
|
178
|
+
} else {
|
179
|
+
$sibling = _checkTag(tag.previousSibling);
|
180
|
+
|
181
|
+
// Sibling is in the line breaker tags list.
|
182
|
+
if ($sibling) {
|
183
|
+
// Show line breaker.
|
184
|
+
_show($sibling, $tag);
|
185
|
+
return true;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
$line_breaker.removeClass('fr-visible').removeData('instance');
|
192
|
+
}
|
193
|
+
|
194
|
+
/*
|
195
|
+
* Check if tag is in the line breaker list and in the editor as well.
|
196
|
+
* Returns the tag from the line breaker list or false if the tag is not in the list.
|
197
|
+
*/
|
198
|
+
function _checkTag (tag) {
|
199
|
+
if (tag) {
|
200
|
+
var $tag = $(tag);
|
201
|
+
|
202
|
+
// Make sure tag is inside the editor.
|
203
|
+
if (editor.$el.find($tag).length === 0) return null;
|
204
|
+
|
205
|
+
// Tag is in the line breaker tags list.
|
206
|
+
if (tag.nodeType != Node.TEXT_NODE && $tag.is(editor.opts.lineBreakerTags.join(','))) {
|
207
|
+
return $tag;
|
208
|
+
}
|
209
|
+
|
210
|
+
// Tag's parent is in the line breaker tags list.
|
211
|
+
else if ($tag.parents(editor.opts.lineBreakerTags.join(',')).length > 0) {
|
212
|
+
tag = $tag.parents(editor.opts.lineBreakerTags.join(',')).get(0);
|
213
|
+
|
214
|
+
return $(tag);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
return null;
|
219
|
+
}
|
220
|
+
|
221
|
+
/*
|
222
|
+
* Get the tag under the mouse cursor.
|
223
|
+
*/
|
224
|
+
function _tagUnder (e) {
|
225
|
+
mouseMoveTimer = null;
|
226
|
+
|
227
|
+
// The tag for which the line breaker should be showed.
|
228
|
+
var $tag = null;
|
229
|
+
|
230
|
+
// The tag under the mouse cursor.
|
231
|
+
var tag_under = editor.doc.elementFromPoint(e.pageX - editor.win.pageXOffset, e.pageY - editor.win.pageYOffset);
|
232
|
+
var i;
|
233
|
+
var tag_above;
|
234
|
+
var tag_below;
|
235
|
+
|
236
|
+
// Tag is the editor element. Look for closest tag above and bellow.
|
237
|
+
if (tag_under && (tag_under.tagName == 'HTML' || tag_under.tagName == 'BODY' || editor.node.isElement(tag_under))) {
|
238
|
+
// Look 1px up and 1 down until a tag is found or the line breaker offset is reached.
|
239
|
+
for (i = 1; i <= editor.opts.lineBreakerOffset; i++) {
|
240
|
+
// Look for tag above.
|
241
|
+
tag_above = editor.doc.elementFromPoint(e.pageX - editor.win.pageXOffset, e.pageY - editor.win.pageYOffset - i);
|
242
|
+
|
243
|
+
// We found a tag above.
|
244
|
+
if (tag_above && !editor.node.isElement(tag_above) && tag_above != editor.$wp.get(0) && $(tag_above).parents(editor.$wp).length) {
|
245
|
+
$tag = _checkTag(tag_above);
|
246
|
+
break;
|
247
|
+
}
|
248
|
+
|
249
|
+
// Look for tag below.
|
250
|
+
tag_below = editor.doc.elementFromPoint(e.pageX - editor.win.pageXOffset, e.pageY - editor.win.pageYOffset + i);
|
251
|
+
|
252
|
+
// We found a tag bellow.
|
253
|
+
if (tag_below && !editor.node.isElement(tag_below) && tag_below != editor.$wp.get(0) && $(tag_below).parents(editor.$wp).length) {
|
254
|
+
$tag = _checkTag(tag_below);
|
255
|
+
break;
|
256
|
+
}
|
257
|
+
}
|
258
|
+
|
259
|
+
// Tag is not the editor element.
|
260
|
+
} else {
|
261
|
+
// Check if the tag is in the line breaker list.
|
262
|
+
$tag = _checkTag(tag_under);
|
263
|
+
}
|
264
|
+
|
265
|
+
// Check tag siblings.
|
266
|
+
if ($tag) {
|
267
|
+
_checkTagSiblings($tag, e.pageY);
|
268
|
+
}
|
269
|
+
else if (editor.core.sameInstance($line_breaker)) {
|
270
|
+
$line_breaker.removeClass('fr-visible').removeData('instance');
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
/*
|
275
|
+
* Set mouse timer to improve performance.
|
276
|
+
*/
|
277
|
+
function _mouseTimer (e) {
|
278
|
+
if ($line_breaker.hasClass('fr-visible') && !editor.core.sameInstance($line_breaker)) return false;
|
279
|
+
|
280
|
+
if (editor.popups.areVisible() || editor.$el.get(0).querySelectorAll('.fr-selected-cell').length) {
|
281
|
+
$line_breaker.removeClass('fr-visible');
|
282
|
+
return true;
|
283
|
+
}
|
284
|
+
|
285
|
+
if (mouseDownFlag === false) {
|
286
|
+
if (mouseMoveTimer) {
|
287
|
+
clearTimeout(mouseMoveTimer);
|
288
|
+
}
|
289
|
+
|
290
|
+
mouseMoveTimer = setTimeout(_tagUnder, 30, e);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
/*
|
295
|
+
* Hide line breaker and prevent timer from showing it again.
|
296
|
+
*/
|
297
|
+
function _hide () {
|
298
|
+
if (mouseMoveTimer) {
|
299
|
+
clearTimeout(mouseMoveTimer);
|
300
|
+
}
|
301
|
+
|
302
|
+
if ($line_breaker.hasClass('fr-visible')) {
|
303
|
+
$line_breaker.removeClass('fr-visible').removeData('instance');
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
/*
|
308
|
+
* Notify that mouse is down and prevent line breaker from showing.
|
309
|
+
* This may happen either for selection or for drag.
|
310
|
+
*/
|
311
|
+
function _mouseDown () {
|
312
|
+
mouseDownFlag = true;
|
313
|
+
_hide();
|
314
|
+
}
|
315
|
+
|
316
|
+
/*
|
317
|
+
* Notify that mouse is no longer pressed.
|
318
|
+
*/
|
319
|
+
function _mouseUp () {
|
320
|
+
mouseDownFlag = false;
|
321
|
+
}
|
322
|
+
|
323
|
+
/*
|
324
|
+
* Add new line between the tags.
|
325
|
+
*/
|
326
|
+
function _doLineBreak (e) {
|
327
|
+
if (!editor.core.sameInstance($line_breaker)) return true;
|
328
|
+
|
329
|
+
e.preventDefault();
|
330
|
+
|
331
|
+
// Hide the line breaker.
|
332
|
+
$line_breaker.removeClass('fr-visible').removeData('instance');
|
333
|
+
|
334
|
+
// Tags between which that line break needs to be done.
|
335
|
+
var $tag1 = $line_breaker.data('tag1');
|
336
|
+
var $tag2 = $line_breaker.data('tag2');
|
337
|
+
|
338
|
+
// P, DIV or none.
|
339
|
+
var default_tag = editor.html.defaultTag();
|
340
|
+
|
341
|
+
// The line break needs to be done before the first element in the editor.
|
342
|
+
if ($tag1 == null) {
|
343
|
+
// If the tag is in a TD tag then just add <br> no matter what the default_tag is.
|
344
|
+
if (default_tag && $tag2.parent().get(0).tagName != 'TD') {
|
345
|
+
$tag2.before('<' + default_tag + '>' + $.FE.MARKERS + '<br></' + default_tag + '>')
|
346
|
+
}
|
347
|
+
else {
|
348
|
+
$tag2.before($.FE.MARKERS + '<br>');
|
349
|
+
}
|
350
|
+
|
351
|
+
// The line break needs to be done either after the last element in the editor or between the 2 tags.
|
352
|
+
// Either way the line break is after the first tag.
|
353
|
+
} else {
|
354
|
+
// If the tag is in a TD tag then just add <br> no matter what the default_tag is.
|
355
|
+
if (default_tag && $tag1.parent().get(0).tagName != 'TD' && $tag1.parents(default_tag).length === 0) {
|
356
|
+
$tag1.after('<' + default_tag + '>' + $.FE.MARKERS + '<br></' + default_tag + '>')
|
357
|
+
}
|
358
|
+
else {
|
359
|
+
$tag1.after($.FE.MARKERS + '<br>');
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
// Cursor is now at the beginning of the new line.
|
364
|
+
editor.selection.restore();
|
365
|
+
}
|
366
|
+
|
367
|
+
/*
|
368
|
+
* Initialize the line breaker.
|
369
|
+
*/
|
370
|
+
function _initLineBreaker () {
|
371
|
+
// Append line breaker HTML to editor wrapper.
|
372
|
+
if (!editor.shared.$line_breaker) {
|
373
|
+
editor.shared.$line_breaker = $('<div class="fr-line-breaker"><a class="fr-floating-btn" role="button" tabindex="-1" title="' + editor.language.translate('Break') + '"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect x="21" y="11" width="2" height="8"/><rect x="14" y="17" width="7" height="2"/><path d="M14.000,14.000 L14.000,22.013 L9.000,18.031 L14.000,14.000 Z"/></svg></a></div>');
|
374
|
+
}
|
375
|
+
|
376
|
+
$line_breaker = editor.shared.$line_breaker;
|
377
|
+
|
378
|
+
// Editor shared destroy.
|
379
|
+
editor.events.on('shared.destroy', function () {
|
380
|
+
$line_breaker.html('').removeData().remove();
|
381
|
+
$line_breaker = null;
|
382
|
+
}, true);
|
383
|
+
|
384
|
+
// Editor destroy.
|
385
|
+
editor.events.on('destroy', function () {
|
386
|
+
$line_breaker.removeData('instance').removeClass('fr-visible').appendTo('body');
|
387
|
+
clearTimeout(mouseMoveTimer);
|
388
|
+
}, true)
|
389
|
+
|
390
|
+
editor.events.$on($line_breaker, 'mouseleave', _hide, true);
|
391
|
+
|
392
|
+
editor.events.$on($line_breaker, 'mousemove', function (e) {
|
393
|
+
e.stopPropagation();
|
394
|
+
}, true)
|
395
|
+
|
396
|
+
// Add new line break.
|
397
|
+
editor.events.$on($line_breaker, 'mousedown', 'a', function (e) {
|
398
|
+
e.stopPropagation();
|
399
|
+
}, true);
|
400
|
+
editor.events.$on($line_breaker, 'click', 'a', _doLineBreak, true);
|
401
|
+
}
|
402
|
+
|
403
|
+
/*
|
404
|
+
* Tear up.
|
405
|
+
*/
|
406
|
+
function _init () {
|
407
|
+
if (!editor.$wp) return false;
|
408
|
+
|
409
|
+
_initLineBreaker();
|
410
|
+
|
411
|
+
// Remember if mouse is clicked so the line breaker does not appear.
|
412
|
+
mouseDownFlag = false;
|
413
|
+
|
414
|
+
// Check tags under the mouse to see if the line breaker needs to be shown.
|
415
|
+
editor.events.$on(editor.$win, 'mousemove', _mouseTimer);
|
416
|
+
|
417
|
+
// Hide the line breaker if the page is scrolled.
|
418
|
+
editor.events.$on($(editor.win), 'scroll', _hide);
|
419
|
+
|
420
|
+
// Hide the line breaker on cell edit.
|
421
|
+
editor.events.on('popups.show.table.edit', _hide);
|
422
|
+
|
423
|
+
// Prevent line breaker from showing while selecting text or dragging images.
|
424
|
+
editor.events.$on($(editor.win), 'mousedown', _mouseDown);
|
425
|
+
|
426
|
+
// Mouse is not pressed anymore, line breaker may be shown.
|
427
|
+
editor.events.$on($(editor.win), 'mouseup', _mouseUp);
|
428
|
+
}
|
429
|
+
|
430
|
+
return {
|
431
|
+
_init: _init
|
432
|
+
}
|
433
|
+
};
|
434
|
+
|
435
|
+
}));
|