scrivito_editors 1.7.0 → 1.8.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e4ceb5ac52b3b08920347efe1efbcde1797daa4
4
- data.tar.gz: 20c0661ed2a8bfadacb392dffede44a25ceff6cd
3
+ metadata.gz: 1d1a39587b189bd3d8d4b56ae481dfb8171f5975
4
+ data.tar.gz: 6acd8d01478898f158ae6304c888b443263eea63
5
5
  SHA512:
6
- metadata.gz: 2b956fba03f5d543a7a9ccbe7f4adc821a344ffa6287811aa29bb252d27c0c11256e35cb24989ef9861d075aaa5057b5920783267aad900988c7a32ee54cadbc
7
- data.tar.gz: f8c4dc91b7ac8bbdcbb415b809fcd2c0c0a06e274dcab90b08e49acb70c66a2ed16ef0352337ce3688db5621df3a28f98fdf02363623d5c598b5342511327105
6
+ metadata.gz: d23c0f408683624d4561914ec634c622b03fae68626e0b2a6c15c5338cf3ea28ff24d0df921ebcc6c811de1cb99a79dde15dc144f88e39ed58fddda588a7c1ef
7
+ data.tar.gz: 4133d4194188406228af5b0d55c3ab881bcc2b0899aec8e7033d0a1d2c3788bacd69c9a08c3bdbd8afadbc54e6114e2bfd7a834cdee9f20e368052ff3288f02b
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
4
+
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
6
+
7
+ scrivito.editors.ControllerContentProxy = (function () {
8
+ function ControllerContentProxy(domNode, controller) {
9
+ _classCallCheck(this, ControllerContentProxy);
10
+
11
+ this.domNode = domNode;
12
+ this.controller = controller;
13
+ }
14
+
15
+ _createClass(ControllerContentProxy, [{
16
+ key: 'content',
17
+ value: function content() {
18
+ return this.controller.content;
19
+ }
20
+ }, {
21
+ key: 'idFromPath',
22
+ value: function idFromPath(path) {
23
+ if (path.match(/^objid:/)) {
24
+ return path.replace(/^objid:/, '');
25
+ }
26
+ }
27
+ }, {
28
+ key: 'jQueryElement',
29
+ value: function jQueryElement() {
30
+ return $(this.domNode);
31
+ }
32
+ }, {
33
+ key: 'pathForId',
34
+ value: function pathForId(id) {
35
+ return 'objid:' + id;
36
+ }
37
+ }, {
38
+ key: 'save',
39
+ value: function save(content) {
40
+ this.controller.content = content;
41
+ var promise = { done: function done(callback) {
42
+ callback();return promise;
43
+ } };
44
+ return promise;
45
+ }
46
+ }, {
47
+ key: 'trigger',
48
+ value: function trigger(event) {
49
+ // ignore
50
+ }
51
+ }]);
52
+
53
+ return ControllerContentProxy;
54
+ })();
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
4
+
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+
7
+ scrivito.editors.HtmlEditor = (function () {
8
+ _createClass(HtmlEditor, null, [{
9
+ key: "canEdit",
10
+ value: function canEdit(_ref) {
11
+ var type = _ref.type;
12
+
13
+ return type == "html";
14
+ }
15
+ }]);
16
+
17
+ function HtmlEditor(_ref2) {
18
+ var controller = _ref2.controller;
19
+
20
+ _classCallCheck(this, HtmlEditor);
21
+
22
+ this.controller = controller;
23
+ }
24
+
25
+ _createClass(HtmlEditor, [{
26
+ key: "editorWillBeActivated",
27
+ value: function editorWillBeActivated() {
28
+ this.controller.setDomMode('Replace');
29
+ }
30
+ }, {
31
+ key: "editorWillBeDeactivated",
32
+ value: function editorWillBeDeactivated() {
33
+ // empty
34
+ }
35
+ }, {
36
+ key: "editorDomWasMounted",
37
+ value: function editorDomWasMounted(domNode) {
38
+ scrivito.editors._applyPlaceholderToElement(domNode);
39
+ $(domNode).html(this.controller.content);
40
+ var editorProxy = new scrivito.editors.ControllerContentProxy(domNode, this.controller);
41
+ scrivito.editors.medium_editor._activateWithProxy(editorProxy);
42
+ }
43
+ }]);
44
+
45
+ return HtmlEditor;
46
+ })();
47
+
48
+ if (scrivito.registerEditor) {
49
+ scrivito.registerEditor(scrivito.editors.HtmlEditor);
50
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
4
+
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+
7
+ scrivito.editors.ReferenceEditor = (function () {
8
+ _createClass(ReferenceEditor, null, [{
9
+ key: "canEdit",
10
+ value: function canEdit(_ref) {
11
+ var type = _ref.type;
12
+
13
+ return type == "reference";
14
+ }
15
+ }]);
16
+
17
+ function ReferenceEditor(_ref2) {
18
+ var controller = _ref2.controller;
19
+
20
+ _classCallCheck(this, ReferenceEditor);
21
+
22
+ this.controller = controller;
23
+ }
24
+
25
+ _createClass(ReferenceEditor, [{
26
+ key: "editorWillBeActivated",
27
+ value: function editorWillBeActivated() {
28
+ // empty
29
+ }
30
+ }, {
31
+ key: "editorWillBeDeactivated",
32
+ value: function editorWillBeDeactivated() {
33
+ // empty
34
+ }
35
+ }, {
36
+ key: "onClick",
37
+ value: function onClick(_ref3) {
38
+ var _this = this;
39
+
40
+ var event = _ref3.event;
41
+
42
+ scrivito.content_browser.open({
43
+ selection: this._currentSelection(),
44
+ selection_mode: 'single'
45
+ }).done(function (ids) {
46
+ return _this._saveContentBrowserSelection(ids);
47
+ });
48
+ }
49
+ }, {
50
+ key: "_currentSelection",
51
+ value: function _currentSelection() {
52
+ return this.controller.content ? [this.controller.content.id] : [];
53
+ }
54
+ }, {
55
+ key: "_saveContentBrowserSelection",
56
+ value: function _saveContentBrowserSelection(ids) {
57
+ this.controller.content = ids[0] || null;
58
+ }
59
+ }]);
60
+
61
+ return ReferenceEditor;
62
+ })();
63
+
64
+ if (scrivito.registerEditor) {
65
+ scrivito.registerEditor(scrivito.editors.ReferenceEditor);
66
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
4
+
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+
7
+ scrivito.editors.StringEditor = (function () {
8
+ _createClass(StringEditor, null, [{
9
+ key: "canEdit",
10
+ value: function canEdit(_ref) {
11
+ var type = _ref.type;
12
+ var tag = _ref.tag;
13
+
14
+ return type == "string";
15
+ }
16
+ }]);
17
+
18
+ function StringEditor(_ref2) {
19
+ var attributeInfo = _ref2.attributeInfo;
20
+ var controller = _ref2.controller;
21
+
22
+ _classCallCheck(this, StringEditor);
23
+
24
+ this.attributeInfo = attributeInfo;
25
+ this.controller = controller;
26
+ }
27
+
28
+ _createClass(StringEditor, [{
29
+ key: "editorWillBeActivated",
30
+ value: function editorWillBeActivated() {
31
+ this.controller.setDomMode('Replace');
32
+ }
33
+ }, {
34
+ key: "editorWillBeDeactivated",
35
+ value: function editorWillBeDeactivated() {}
36
+ }, {
37
+ key: "editorDomWasMounted",
38
+ value: function editorDomWasMounted(domNode) {
39
+ scrivito.editors._applyPlaceholderToElement(domNode);
40
+ $(domNode).text(this.controller.content);
41
+ var editorProxy = new scrivito.editors.ControllerContentProxy(domNode, this.controller);
42
+ scrivito.editors.string_editor._activateWithProxy(editorProxy);
43
+ }
44
+ }, {
45
+ key: "onClick",
46
+ value: function onClick() {}
47
+ }]);
48
+
49
+ return StringEditor;
50
+ })();
51
+
52
+ if (scrivito.registerEditor) {
53
+ scrivito.registerEditor(scrivito.editors.StringEditor);
54
+ }
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
4
+
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
6
+
7
+ scrivito.editors.DomContentProxy = (function () {
8
+ function DomContentProxy(domNode) {
9
+ _classCallCheck(this, DomContentProxy);
10
+
11
+ this.domNode = domNode;
12
+ }
13
+
14
+ _createClass(DomContentProxy, [{
15
+ key: 'content',
16
+ value: function content() {
17
+ return this.jQueryElement().scrivito('content');
18
+ }
19
+ }, {
20
+ key: 'idFromPath',
21
+ value: function idFromPath(path) {
22
+ return scrivito.id_from_path(path);
23
+ }
24
+ }, {
25
+ key: 'jQueryElement',
26
+ value: function jQueryElement() {
27
+ return $(this.domNode);
28
+ }
29
+ }, {
30
+ key: 'pathForId',
31
+ value: function pathForId(id) {
32
+ return scrivito.path_for_id(id);
33
+ }
34
+ }, {
35
+ key: 'save',
36
+ value: function save(content) {
37
+ return this.jQueryElement().scrivito('save', content);
38
+ }
39
+ }, {
40
+ key: 'trigger',
41
+ value: function trigger(event) {
42
+ return this.jQueryElement().trigger(event);
43
+ }
44
+ }]);
45
+
46
+ return DomContentProxy;
47
+ })();
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ scrivito.editors._applyPlaceholderToElement = function _applyPlaceholderToElement(domNode) {
4
+ var cmsField = $(domNode);
5
+ if (cmsField.not('[data-scrivito-editors-placeholder]')) {
6
+ cmsField.attr('data-scrivito-editors-placeholder', 'Click to edit');
7
+ }
8
+ };
@@ -3,6 +3,7 @@
3
3
 
4
4
  ScrivitoAnchor = MediumEditor.extensions.anchor.extend({
5
5
  name: 'scrivito_anchor',
6
+ proxy: null,
6
7
  contentDefault: '<i class="scrivito_customer_icon sci_link"></i>',
7
8
  handleClick: function(event) {
8
9
  var firstTextElement, linkElement, linkValue, selectedParent, selectionRange;
@@ -27,7 +28,7 @@
27
28
  return form.find('.medium-editor-toolbar-browse').on('click', (function(_this) {
28
29
  return function() {
29
30
  var cmsField, id, selection;
30
- selection = (id = scrivito.id_from_path(input.val())) ? [id] : [];
31
+ selection = (id = _this.proxy.idFromPath(input.val())) ? [id] : [];
31
32
  cmsField = $(_this.base.origElements);
32
33
  scrivito.content_browser.open({
33
34
  filter: cmsField.data('scrivitoEditorsFilter'),
@@ -38,7 +39,7 @@
38
39
  return input.focus();
39
40
  }).done(function(selection) {
40
41
  if (selection.length) {
41
- return input.val(scrivito.path_for_id(selection[0]));
42
+ return input.val(_this.proxy.pathForId(selection[0]));
42
43
  } else {
43
44
  return input.val('');
44
45
  }
@@ -85,12 +86,14 @@
85
86
  }
86
87
  };
87
88
 
88
- activate = function(element) {
89
- var cmsField;
90
- cmsField = $(element);
91
- return new MediumEditor(cmsField, editorOptions()).subscribe('editableInput', function() {
92
- return cmsField.scrivito('save', cmsField.html());
89
+ activate = function(proxy) {
90
+ var cmsField, mediumEditor, scrivitoAnchorExtension;
91
+ cmsField = proxy.jQueryElement();
92
+ mediumEditor = new MediumEditor(cmsField, editorOptions()).subscribe('editableInput', function() {
93
+ return proxy.save(cmsField.html());
93
94
  });
95
+ scrivitoAnchorExtension = mediumEditor.getExtensionByName('scrivito_anchor');
96
+ return scrivitoAnchorExtension != null ? scrivitoAnchorExtension.proxy = proxy : void 0;
94
97
  };
95
98
 
96
99
  scrivito.editors.medium_editor = {
@@ -98,11 +101,14 @@
98
101
  return $(element).is('[data-scrivito-field-type=html]');
99
102
  },
100
103
  activate: function(element) {
101
- return activate(element);
104
+ return activate(new scrivito.editors.DomContentProxy(element));
102
105
  },
103
106
  default_options: defaultOptions,
104
107
  options: function() {
105
108
  return {};
109
+ },
110
+ _activateWithProxy: function(proxy) {
111
+ return activate(proxy);
106
112
  }
107
113
  };
108
114
 
@@ -1,9 +1,9 @@
1
1
  (function() {
2
2
  var DOUBLE_CLICK_MS, activate, cleanUp, cmsFieldAndPastedContent, finishEditing, getCurrentContent, isNewlineAllowed, onBlur, onFocus, onInput, onKey, prepareForEditing, save;
3
3
 
4
- onKey = function(event) {
4
+ onKey = function(event, proxy) {
5
5
  var cmsField, key;
6
- cmsField = $(event.currentTarget);
6
+ cmsField = proxy.jQueryElement();
7
7
  key = event.keyCode || event.which;
8
8
  switch (key) {
9
9
  case 13:
@@ -18,32 +18,26 @@
18
18
  }
19
19
  };
20
20
 
21
- onInput = function(event) {
22
- var cmsField;
23
- cmsField = $(event.currentTarget);
24
- return save(cmsField);
21
+ onInput = function(proxy) {
22
+ return save(proxy);
25
23
  };
26
24
 
27
- onFocus = function(event) {
28
- var cmsField;
29
- cmsField = $(event.currentTarget);
30
- return prepareForEditing(cmsField);
25
+ onFocus = function(proxy) {
26
+ return prepareForEditing(proxy.jQueryElement());
31
27
  };
32
28
 
33
- onBlur = function(event) {
34
- var cmsField;
35
- cmsField = $(event.currentTarget);
36
- save(cmsField).done(function() {
37
- return cmsField.trigger('scrivito_editors:blur');
29
+ onBlur = function(proxy) {
30
+ save(proxy).done(function() {
31
+ return proxy.trigger('scrivito_editors:blur');
38
32
  });
39
- return finishEditing(cmsField);
33
+ return finishEditing(proxy);
40
34
  };
41
35
 
42
- save = function(cmsField) {
36
+ save = function(proxy) {
43
37
  var content;
44
- content = getCurrentContent(cmsField);
45
- return cmsField.scrivito('save', content).done(function() {
46
- return cmsField.trigger('scrivito_editors:save');
38
+ content = getCurrentContent(proxy.jQueryElement());
39
+ return proxy.save(content).done(function() {
40
+ return proxy.trigger('scrivito_editors:save');
47
41
  });
48
42
  };
49
43
 
@@ -55,6 +49,9 @@
55
49
  clone.find('br').replaceWith('\n');
56
50
  content = clone.text();
57
51
  clone.remove();
52
+ if (!isNewlineAllowed(cmsField)) {
53
+ content = content.replace(/\n$/, '');
54
+ }
58
55
  return content;
59
56
  };
60
57
 
@@ -102,19 +99,31 @@
102
99
  }
103
100
  };
104
101
 
105
- finishEditing = function(cmsField) {
102
+ finishEditing = function(proxy) {
103
+ var cmsField;
104
+ cmsField = proxy.jQueryElement();
106
105
  cmsField.data('scrivito_editors_prepared_for_editing', false);
107
- return cmsField.text(cmsField.scrivito('content'));
106
+ return cmsField.text(proxy.content());
108
107
  };
109
108
 
110
109
  DOUBLE_CLICK_MS = 300;
111
110
 
112
- activate = function(element) {
111
+ activate = function(proxy) {
113
112
  var cmsField;
114
- cmsField = $(element);
115
- cmsField.attr('contenteditable', true).blur(onBlur).focus(onFocus).keypress(onKey).keyup(onKey);
113
+ cmsField = proxy.jQueryElement();
114
+ cmsField.attr('contenteditable', true).blur(function() {
115
+ return onBlur(proxy);
116
+ }).focus(function() {
117
+ return onFocus(proxy);
118
+ }).keypress(function(event) {
119
+ return onKey(event, proxy);
120
+ }).keyup(function(event) {
121
+ return onKey(event, proxy);
122
+ });
116
123
  if (cmsField.attr('data-scrivito-editors-autosave') !== 'false') {
117
- cmsField.on('cut input keypress keyup paste', onInput);
124
+ cmsField.on('cut input keypress keyup paste', function() {
125
+ return onInput(proxy);
126
+ });
118
127
  }
119
128
  prepareForEditing(cmsField);
120
129
  return cmsField.on('click', function(event) {
@@ -132,7 +141,10 @@
132
141
  return $(element).is('[data-scrivito-field-type=string]');
133
142
  },
134
143
  activate: function(element) {
135
- return activate(element);
144
+ return activate(new scrivito.editors.DomContentProxy(element));
145
+ },
146
+ _activateWithProxy: function(proxy) {
147
+ return activate(proxy);
136
148
  }
137
149
  };
138
150
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_editors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
@@ -50,28 +50,28 @@ dependencies:
50
50
  requirements:
51
51
  - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: 1.7.0
53
+ version: 1.8.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.7.0
60
+ version: 1.8.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.7.0
67
+ version: 1.8.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.7.0
74
+ version: 1.8.0.rc1
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: coffee-rails
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -184,13 +184,19 @@ files:
184
184
  - app/assets/fonts/editing_icons-webfont.woff
185
185
  - app/assets/javascripts/scrivito_editors.js
186
186
  - app/assets/javascripts/scrivito_editors/binary_editor.js
187
+ - app/assets/javascripts/scrivito_editors/controller_api/controller_content_proxy.js
188
+ - app/assets/javascripts/scrivito_editors/controller_api/html_editor.js
189
+ - app/assets/javascripts/scrivito_editors/controller_api/reference_editor.js
190
+ - app/assets/javascripts/scrivito_editors/controller_api/string_editor.js
187
191
  - app/assets/javascripts/scrivito_editors/date_editor.js
188
192
  - app/assets/javascripts/scrivito_editors/default_editor.js
189
193
  - app/assets/javascripts/scrivito_editors/dependencies/jquery_ui.js.erb
194
+ - app/assets/javascripts/scrivito_editors/dom_content_proxy.js
190
195
  - app/assets/javascripts/scrivito_editors/enum_editor.js
191
196
  - app/assets/javascripts/scrivito_editors/filter_context.js
192
197
  - app/assets/javascripts/scrivito_editors/helpers/button_container.js
193
198
  - app/assets/javascripts/scrivito_editors/helpers/imgly_assets.js.erb
199
+ - app/assets/javascripts/scrivito_editors/helpers/placeholder_helper.js
194
200
  - app/assets/javascripts/scrivito_editors/html_editor.js
195
201
  - app/assets/javascripts/scrivito_editors/image_editor.js
196
202
  - app/assets/javascripts/scrivito_editors/link_editor.js