Skip to content

Commit edfe035

Browse files
author
Alex Tharp
authored
Merge pull request #4 from cortex-cms/inline-data-fixes-and-ckeditor-upgrade-and-refactor
Inline Data Fixes + CKEditor Upgrade + Refactor
2 parents d495bbe + e0186ac commit edfe035

File tree

4 files changed

+43
-36
lines changed

4 files changed

+43
-36
lines changed

Diff for: bower.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"name": "content-snippets-edit",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"ignore": [
55
"**/.*",
66
"node_modules",
77
"components"
88
],
99
"dependencies": {
10-
"riot": "~2.3.18",
10+
"riot": "~3.0.7",
1111
"q": "~1.3.0",
1212
"qajax": "[email protected]:cb-talent-development/qajax#master",
1313
"underscore": "~1.8.3",
14-
"materialize": "~0.97.6",
14+
"materialize": "~0.97.8",
1515
"normalize-scss": "~3.0"
1616
},
1717
"resolutions": {

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "content-snippets-edit",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "A tool to enable in-page editing of elements with Cortex as a backend",
55
"author": "CB Content Enablement Product Team <[email protected]>",
66
"license": "Apache-2.0",

Diff for: src/app/main.js

+35-28
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
1-
(function(global) {
1+
(function (global) {
22
'use strict';
33

4-
$(function() {
5-
$('body').prepend( $('<toolbar></toolbar>') );
6-
$('body').append( $('<media-library></media-library>') );
7-
$('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'https://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100') );
8-
$('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'https://fonts.googleapis.com/icon?family=Material+Icons') );
9-
$('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', config.CONTENT_SNIPPETS_EDIT_CSS_URL) );
10-
$.getScript('https://cdn.ckeditor.com/4.5.10/standard/ckeditor.js', function() {
11-
global.CKEDITOR.config.autoParagraph = false;
12-
global.CKEDITOR.config.allowedContent = true;
13-
global.CKEDITOR.plugins.addExternal( 'media-selector', global.config.CKEDITOR_PLUGINS_URL + 'media-selector/', 'plugin.js' );
14-
global.CKEDITOR.plugins.addExternal( 'sourcedialog', global.config.CKEDITOR_PLUGINS_URL + 'sourcedialog/', 'plugin.js' );
15-
global.CKEDITOR.plugins.addExternal( 'codemirror', global.config.CKEDITOR_PLUGINS_URL + 'codemirror/', 'plugin.js' );
16-
global.CKEDITOR.config.extraPlugins = 'media-selector,sourcedialog';
17-
global.CKEDITOR.config.removePlugins = 'image,sourcearea';
18-
19-
var stores = {
20-
WebpageStore: new WebpageStore(),
21-
MediasStore: new MediasStore()
22-
};
23-
24-
_.each(stores, function(store) {
25-
RiotControl.addStore(store);
26-
});
4+
$(function () {
5+
var body = $('body'),
6+
head = $('head');
7+
8+
body.prepend($('<toolbar></toolbar>'));
9+
body.append($('<media-library></media-library>'));
10+
11+
head.append($('<link rel="stylesheet" type="text/css" />').attr('href', 'https://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100'));
12+
head.append($('<link rel="stylesheet" type="text/css" />').attr('href', 'https://fonts.googleapis.com/icon?family=Material+Icons'));
13+
head.append($('<link rel="stylesheet" type="text/css" />').attr('href', config.CONTENT_SNIPPETS_EDIT_CSS_URL));
14+
15+
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/js/materialize.min.js', function () {
16+
$.getScript('https://cdn.ckeditor.com/4.6.2/standard/ckeditor.js', function () {
17+
global.CKEDITOR.plugins.addExternal('media-selector', global.config.CKEDITOR_PLUGINS_URL + 'media-selector/', 'plugin.js');
18+
global.CKEDITOR.plugins.addExternal('sourcedialog', global.config.CKEDITOR_PLUGINS_URL + 'sourcedialog/', 'plugin.js');
19+
global.CKEDITOR.plugins.addExternal('codemirror', global.config.CKEDITOR_PLUGINS_URL + 'codemirror/', 'plugin.js');
2720

28-
global.stores = stores;
21+
global.CKEDITOR.config.allowedContent = true;
22+
global.CKEDITOR.config.extraPlugins = 'media-selector,sourcedialog';
23+
global.CKEDITOR.config.removePlugins = 'image,sourcearea';
2924

30-
riot.mount('snippet');
31-
riot.mount('media-library');
32-
riot.mount('toolbar');
25+
var stores = {
26+
WebpageStore: new WebpageStore(),
27+
MediasStore: new MediasStore()
28+
};
29+
30+
_.each(stores, function (store) {
31+
RiotControl.addStore(store);
32+
});
33+
34+
global.stores = stores;
35+
36+
riot.mount('snippet');
37+
riot.mount('media-library');
38+
riot.mount('toolbar');
39+
});
3340
});
3441
});
3542
}(this));

Diff for: src/app/tags/snippet.tag

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<snippet>
2-
<div class="editor" onblur="{ contentChanged }" contenteditable="true"><yield /></div>
2+
<div id="{ opts.id }" class="editor" onblur="{ contentChanged }" contenteditable="true"><yield /></div>
33

44
<script>
55
fluxableTag(this, RiotControl);
@@ -10,13 +10,13 @@
1010
return obj.document.name == opts.id;
1111
});
1212
if (typeof foundSnippet != "undefined") {
13-
self.getElementsByClassName('editor')[0].innerHTML = foundSnippet.document.body;
14-
self.update();
13+
CKEDITOR.instances[opts.id].setData(foundSnippet.document.body);
1514
}
1615
});
1716

1817
this.contentChanged = function(event) {
19-
RiotControl.trigger(constants.ACTIONS.SNIPPET_CHANGED, {name: opts.id, body: event.target.innerHTML});
18+
var body = CKEDITOR.instances[opts.id].getData();
19+
RiotControl.trigger(constants.ACTIONS.SNIPPET_CHANGED, {name: opts.id, body: body});
2020
}
2121
</script>
2222

0 commit comments

Comments
 (0)