scrivito_editors 1.13.0 → 1.14.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +6 -14
- data/app/assets/javascripts/scrivito_editors/string_editor.js +158 -155
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edde882877616fa1eb7d8fcf7dc8b7c66857099c11a854e27b9d5fcb8389f864
|
4
|
+
data.tar.gz: aba07a37cf676ba3d547789bc817c238a6de2cf8a28b2a5d92b2cdbb1bcba04f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6e5604538b714ece7c86c3de8a8d2b0f20fcd2d1fe3e4500d4102dc2726fdaed31467272b6a4d0ac77f30fe83041c53e39f1851db17dc9994801d8eb6983e90
|
7
|
+
data.tar.gz: a6d44761c8a5eaa1831dae061c37a2a64004c55702f6cd9aed39448fdeeb7a27d7837ae82a5b132540e9f4ee326d5277ce4ce89bebab47344e691128290498cd
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2009 -
|
1
|
+
Copyright (c) 2009 - 2018 Infopark AG (http://www.infopark.com)
|
2
2
|
|
3
3
|
This software can be used and modified under the LGPL-3.0. Please refer to
|
4
4
|
http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
|
data/README.md
CHANGED
@@ -2,25 +2,17 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/scrivito_editors.svg)](https://badge.fury.io/rb/scrivito_editors)
|
4
4
|
|
5
|
-
|
6
|
-
JavaScript editors based on the Scrivito SDK.
|
7
|
-
attributes in place and
|
8
|
-
widgets. A content browser comes with the gem, to add, update and delete
|
9
|
-
resources.
|
5
|
+
[Scrivito](http://scrivito.com/rails/documentation) Editors is a
|
6
|
+
collection of JavaScript editors based on the Scrivito SDK.
|
7
|
+
The editors let you edit CMS attributes in place and in property views of pages and widgets.
|
10
8
|
|
11
9
|
## Installation and Usage
|
12
10
|
|
13
|
-
Please
|
14
|
-
[latest installation and usage
|
15
|
-
|
16
|
-
|
17
|
-
## Changelog
|
18
|
-
|
19
|
-
{include:file:CHANGELOG.md}
|
20
|
-
|
11
|
+
Please refer to the
|
12
|
+
[latest installation and usage instructions](https://scrivito.com/editors).
|
21
13
|
|
22
14
|
## License
|
23
|
-
Copyright (c) 2009 -
|
15
|
+
Copyright (c) 2009 - 2018 Infopark AG (http://www.infopark.com)
|
24
16
|
|
25
17
|
This software can be used and modified under the LGPL-3.0. Please refer to
|
26
18
|
http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
|
@@ -1,165 +1,168 @@
|
|
1
|
-
|
2
|
-
var DOUBLE_CLICK_MS, activate, cleanUp, cmsFieldAndPastedContent, finishEditing, fixSelectionForFirefox, getCurrentContent, isNewlineAllowed, onBlur, onClick, onFocus, onInput, onKey, prepareForEditing, save;
|
3
|
-
|
4
|
-
onKey = function(event, proxy) {
|
5
|
-
var cmsField, key;
|
6
|
-
cmsField = proxy.jQueryElement();
|
7
|
-
key = event.keyCode || event.which;
|
8
|
-
switch (key) {
|
9
|
-
case 13:
|
10
|
-
if (!isNewlineAllowed(cmsField)) {
|
11
|
-
event.preventDefault();
|
12
|
-
return cmsField.blur();
|
13
|
-
}
|
14
|
-
break;
|
15
|
-
case 27:
|
16
|
-
event.stopPropagation();
|
17
|
-
return cmsField.blur();
|
18
|
-
}
|
19
|
-
};
|
1
|
+
// This file integrates contenteditable for string attributes.
|
20
2
|
|
21
|
-
|
22
|
-
return save(proxy);
|
23
|
-
};
|
3
|
+
'use strict';
|
24
4
|
|
25
|
-
|
26
|
-
|
27
|
-
|
5
|
+
function onKey(event, proxy) {
|
6
|
+
var cmsField = proxy.jQueryElement();
|
7
|
+
var key = event.keyCode || event.which;
|
28
8
|
|
29
|
-
|
30
|
-
|
31
|
-
|
9
|
+
switch (key) {
|
10
|
+
case 13:
|
11
|
+
// Enter
|
12
|
+
if (!isNewlineAllowed(cmsField)) {
|
13
|
+
event.preventDefault();
|
14
|
+
cmsField.blur();
|
15
|
+
}
|
16
|
+
break;
|
17
|
+
case 27:
|
18
|
+
// Esc
|
19
|
+
event.stopPropagation();
|
20
|
+
cmsField.blur();
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
function onInput(proxy) {
|
25
|
+
save(proxy);
|
26
|
+
}
|
27
|
+
|
28
|
+
function onFocus(proxy) {
|
29
|
+
prepareForEditing(proxy.jQueryElement());
|
30
|
+
}
|
31
|
+
|
32
|
+
function onClick(proxy) {
|
33
|
+
fixSelectionForFirefox(proxy.jQueryElement());
|
34
|
+
}
|
35
|
+
|
36
|
+
function onBlur(proxy) {
|
37
|
+
save(proxy).done(function () {
|
38
|
+
return proxy.trigger('scrivito_editors:blur');
|
39
|
+
});
|
32
40
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
});
|
37
|
-
finishEditing(proxy);
|
38
|
-
return prepareForEditing(proxy.jQueryElement());
|
39
|
-
};
|
40
|
-
|
41
|
-
save = function(proxy) {
|
42
|
-
var content;
|
43
|
-
content = getCurrentContent(proxy.jQueryElement());
|
44
|
-
return proxy.save(content).done(function() {
|
45
|
-
return proxy.trigger('scrivito_editors:save');
|
46
|
-
});
|
47
|
-
};
|
41
|
+
finishEditing(proxy);
|
42
|
+
prepareForEditing(proxy.jQueryElement());
|
43
|
+
}
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
45
|
+
function save(proxy) {
|
46
|
+
var content = getCurrentContent(proxy.jQueryElement());
|
47
|
+
return proxy.save(content).done(function () {
|
48
|
+
return proxy.trigger('scrivito_editors:save');
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
function getCurrentContent(cmsField) {
|
53
|
+
cleanUp(cmsField);
|
54
|
+
return cmsField[0].innerText.replace(/\r\n/g, '\n').replace(/\n+$/, '');
|
55
|
+
}
|
56
|
+
|
57
|
+
function cleanUp(cmsField) {
|
58
|
+
var siblings = cmsFieldAndPastedContent(cmsField);
|
59
|
+
var pasted = siblings.not(cmsField);
|
60
|
+
if (pasted.length > 0) {
|
61
|
+
pasted.remove();
|
62
|
+
cmsField.text(siblings.text());
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
function cmsFieldAndPastedContent(cmsField) {
|
67
|
+
var siblingsBefore = cmsField.data('scrivito_editors_siblings_before_edit');
|
68
|
+
var siblings = cmsField.siblings();
|
69
|
+
var needsReset = !siblingsBefore || siblings.filter(siblingsBefore).length < siblingsBefore.length;
|
70
|
+
if (needsReset) {
|
71
|
+
return cmsField.data('scrivito_editors_siblings_before_edit', siblings);
|
72
|
+
}
|
73
|
+
return cmsField.siblings().addBack().not(siblingsBefore);
|
74
|
+
}
|
75
|
+
|
76
|
+
function isNewlineAllowed(cmsField) {
|
77
|
+
if (cmsField.data('scrivitoEditorsMultiline') === true) {
|
78
|
+
return true;
|
79
|
+
}
|
80
|
+
if (cmsField.data('scrivitoEditorsMultiline') === false) {
|
81
|
+
return false;
|
82
|
+
}
|
83
|
+
return cmsField.css('white-space').match(/pre/);
|
84
|
+
}
|
85
|
+
|
86
|
+
function prepareForEditing(cmsField) {
|
87
|
+
if (isNewlineAllowed(cmsField) && !cmsField.data('scrivito_editors_prepared_for_editing')) {
|
88
|
+
cmsField.data('scrivito_editors_prepared_for_editing', true);
|
89
|
+
var html = cmsField.html();
|
90
|
+
var htmlNl2Br = html.replace(/\r?\n/g, '<br />');
|
91
|
+
if (html !== htmlNl2Br) {
|
92
|
+
cmsField.html(htmlNl2Br);
|
73
93
|
}
|
74
|
-
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
function finishEditing(proxy) {
|
98
|
+
var cmsField = proxy.jQueryElement();
|
99
|
+
cmsField.data('scrivito_editors_prepared_for_editing', false);
|
100
|
+
cmsField.text(proxy.content());
|
101
|
+
}
|
102
|
+
|
103
|
+
var DOUBLE_CLICK_MS = 300;
|
104
|
+
|
105
|
+
function fixSelectionForFirefox(cmsField) {
|
106
|
+
// see https://bugzilla.mozilla.org/show_bug.cgi?id=389348
|
107
|
+
var sel = document.getSelection();
|
108
|
+
if (!sel.anchorNode || !sel.focusNode) {
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
|
112
|
+
if (!cmsField.find(sel.anchorNode).addBack(sel.anchorNode).length || !cmsField.find(sel.focusNode).addBack(sel.focusNode).length) {
|
113
|
+
sel.selectAllChildren(cmsField[0]);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
function _activate(proxy) {
|
118
|
+
var cmsField = proxy.jQueryElement();
|
119
|
+
|
120
|
+
scrivito.editors.applyPlaceholder(cmsField);
|
121
|
+
|
122
|
+
cmsField.attr('contenteditable', 'true').blur(function () {
|
123
|
+
return onBlur(proxy);
|
124
|
+
}).click(function () {
|
125
|
+
return onClick(proxy);
|
126
|
+
}).focus(function () {
|
127
|
+
return onFocus(proxy);
|
128
|
+
}).keypress(function (event) {
|
129
|
+
return onKey(event, proxy);
|
130
|
+
}).keyup(function (event) {
|
131
|
+
return onKey(event, proxy);
|
132
|
+
});
|
75
133
|
|
76
|
-
|
77
|
-
|
78
|
-
return
|
79
|
-
}
|
80
|
-
if (cmsField.data('scrivitoEditorsMultiline') === false) {
|
81
|
-
return false;
|
82
|
-
}
|
83
|
-
return cmsField.css('white-space').match(/pre/);
|
84
|
-
};
|
85
|
-
|
86
|
-
prepareForEditing = function(cmsField) {
|
87
|
-
var html, htmlNl2Br;
|
88
|
-
if (isNewlineAllowed(cmsField) && !cmsField.data('scrivito_editors_prepared_for_editing')) {
|
89
|
-
cmsField.data('scrivito_editors_prepared_for_editing', true);
|
90
|
-
html = cmsField.html();
|
91
|
-
htmlNl2Br = html.replace(/\r?\n/g, '<br />');
|
92
|
-
if (html !== htmlNl2Br) {
|
93
|
-
return cmsField.html(htmlNl2Br);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
};
|
97
|
-
|
98
|
-
finishEditing = function(proxy) {
|
99
|
-
var cmsField;
|
100
|
-
cmsField = proxy.jQueryElement();
|
101
|
-
cmsField.data('scrivito_editors_prepared_for_editing', false);
|
102
|
-
return cmsField.text(proxy.content());
|
103
|
-
};
|
104
|
-
|
105
|
-
DOUBLE_CLICK_MS = 300;
|
106
|
-
|
107
|
-
fixSelectionForFirefox = function(cmsField) {
|
108
|
-
var sel;
|
109
|
-
sel = document.getSelection();
|
110
|
-
if (!sel.anchorNode || !sel.focusNode) {
|
111
|
-
return;
|
112
|
-
}
|
113
|
-
if (!cmsField.find(sel.anchorNode).addBack(sel.anchorNode).length || !cmsField.find(sel.focusNode).addBack(sel.focusNode).length) {
|
114
|
-
return sel.selectAllChildren(cmsField[0]);
|
115
|
-
}
|
116
|
-
};
|
117
|
-
|
118
|
-
activate = function(proxy) {
|
119
|
-
var cmsField;
|
120
|
-
cmsField = proxy.jQueryElement();
|
121
|
-
scrivito.editors.applyPlaceholder(cmsField);
|
122
|
-
cmsField.attr('contenteditable', true).blur(function() {
|
123
|
-
return onBlur(proxy);
|
124
|
-
}).click(function() {
|
125
|
-
return onClick(proxy);
|
126
|
-
}).focus(function() {
|
127
|
-
return onFocus(proxy);
|
128
|
-
}).keypress(function(event) {
|
129
|
-
return onKey(event, proxy);
|
130
|
-
}).keyup(function(event) {
|
131
|
-
return onKey(event, proxy);
|
132
|
-
});
|
133
|
-
if (cmsField.attr('data-scrivito-editors-autosave') !== 'false') {
|
134
|
-
cmsField.on('cut input keypress keyup paste', function() {
|
135
|
-
return onInput(proxy);
|
136
|
-
});
|
137
|
-
}
|
138
|
-
prepareForEditing(cmsField);
|
139
|
-
return cmsField.on('click', function(event) {
|
140
|
-
cmsField.attr('contenteditable', true);
|
141
|
-
cleanUp(cmsField);
|
142
|
-
if (!(event.timeStamp - cmsField.data('scrivito_editors_last_click') < DOUBLE_CLICK_MS)) {
|
143
|
-
event.preventDefault();
|
144
|
-
}
|
145
|
-
return cmsField.data('scrivito_editors_last_click', event.timeStamp);
|
134
|
+
if (cmsField.attr('data-scrivito-editors-autosave') !== 'false') {
|
135
|
+
cmsField.on('cut input keypress keyup paste', function () {
|
136
|
+
return onInput(proxy);
|
146
137
|
});
|
147
|
-
}
|
148
|
-
|
149
|
-
scrivito.editors.string_editor = {
|
150
|
-
can_edit: function(element) {
|
151
|
-
return $(element).is('[data-scrivito-field-type=string]');
|
152
|
-
},
|
153
|
-
activate: function(element) {
|
154
|
-
return activate(new scrivito.editors.DomContentProxy(element));
|
155
|
-
},
|
156
|
-
_activateWithProxy: function(proxy) {
|
157
|
-
return activate(proxy);
|
158
|
-
}
|
159
|
-
};
|
138
|
+
}
|
160
139
|
|
161
|
-
|
162
|
-
|
163
|
-
|
140
|
+
prepareForEditing(cmsField);
|
141
|
+
|
142
|
+
cmsField.on('click', function (event) {
|
143
|
+
cmsField.attr('contenteditable', 'true');
|
144
|
+
cleanUp(cmsField);
|
164
145
|
|
165
|
-
|
146
|
+
// Prevent editable link strings from being opened on click, but allow an enforcing double click
|
147
|
+
if (event.timeStamp - cmsField.data('scrivito_editors_last_click') >= DOUBLE_CLICK_MS) {
|
148
|
+
event.preventDefault();
|
149
|
+
}
|
150
|
+
cmsField.data('scrivito_editors_last_click', event.timeStamp);
|
151
|
+
});
|
152
|
+
}
|
153
|
+
|
154
|
+
scrivito.editors.string_editor = {
|
155
|
+
can_edit: function can_edit(element) {
|
156
|
+
return $(element).is('[data-scrivito-field-type=string]');
|
157
|
+
},
|
158
|
+
activate: function activate(element) {
|
159
|
+
_activate(new scrivito.editors.DomContentProxy(element));
|
160
|
+
},
|
161
|
+
_activateWithProxy: function _activateWithProxy(proxy) {
|
162
|
+
_activate(proxy);
|
163
|
+
}
|
164
|
+
};
|
165
|
+
|
166
|
+
scrivito.on('load', function () {
|
167
|
+
return scrivito.define_editor('string', scrivito.editors.string_editor);
|
168
|
+
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrivito_editors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scrivito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jquery-ui-rails
|
@@ -50,28 +50,28 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - '='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
53
|
+
version: 1.14.0.rc1
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - '='
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 1.
|
60
|
+
version: 1.14.0.rc1
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: scrivito_sdk
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - '='
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 1.
|
67
|
+
version: 1.14.0.rc1
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - '='
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.
|
74
|
+
version: 1.14.0.rc1
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: coffee-rails
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
331
|
version: '1.8'
|
332
332
|
requirements: []
|
333
333
|
rubyforge_project:
|
334
|
-
rubygems_version: 2.7.
|
334
|
+
rubygems_version: 2.7.7
|
335
335
|
signing_key:
|
336
336
|
specification_version: 4
|
337
337
|
summary: Scrivito Editors
|