Skip to content

Commit cd24527

Browse files
committed
Fix saving of inline data (properly retrieve protected tags like 'script'), upgrade CKEditor and refactor main.js
1 parent d495bbe commit cd24527

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

Diff for: bower.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
"ignore": [
55
"**/.*",
66
"node_modules",

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

+13-8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
'use strict';
33

44
$(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;
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://cdn.ckeditor.com/4.6.2/standard/ckeditor.js', function() {
1316
global.CKEDITOR.plugins.addExternal( 'media-selector', global.config.CKEDITOR_PLUGINS_URL + 'media-selector/', 'plugin.js' );
1417
global.CKEDITOR.plugins.addExternal( 'sourcedialog', global.config.CKEDITOR_PLUGINS_URL + 'sourcedialog/', 'plugin.js' );
1518
global.CKEDITOR.plugins.addExternal( 'codemirror', global.config.CKEDITOR_PLUGINS_URL + 'codemirror/', 'plugin.js' );
19+
20+
global.CKEDITOR.config.allowedContent = true;
1621
global.CKEDITOR.config.extraPlugins = 'media-selector,sourcedialog';
1722
global.CKEDITOR.config.removePlugins = 'image,sourcearea';
1823

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

+3-2
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);
@@ -16,7 +16,8 @@
1616
});
1717

1818
this.contentChanged = function(event) {
19-
RiotControl.trigger(constants.ACTIONS.SNIPPET_CHANGED, {name: opts.id, body: event.target.innerHTML});
19+
var body = CKEDITOR.instances[event.target.id].getData();
20+
RiotControl.trigger(constants.ACTIONS.SNIPPET_CHANGED, {name: opts.id, body: body});
2021
}
2122
</script>
2223

0 commit comments

Comments
 (0)