frontendeditor_ckeditor 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/frontendeditor_ckeditor/version.rb +1 -1
- data/vendor/assets/javascripts/ckeditor/ckeditor_actions.coffee +1 -16
- data/vendor/assets/javascripts/ckeditor/plugins/sourcedialog/dialogs/sourcedialog.js +78 -0
- data/vendor/assets/javascripts/ckeditor/plugins/sourcedialog/icons/sourcedialog-rtl.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/sourcedialog/icons/sourcedialog.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/sourcedialog/lang/en.js +9 -0
- data/vendor/assets/javascripts/ckeditor/plugins/sourcedialog/plugin.js +26 -0
- data/vendor/assets/javascripts/ckeditor/plugins/sourcedialog/samples/sourcedialog.html +118 -0
- metadata +7 -1
@@ -5,7 +5,7 @@ Editor.active = ->
|
|
5
5
|
target.attr('contenteditable',true)
|
6
6
|
target.effect('highlight', duration: 5000)
|
7
7
|
for div in target
|
8
|
-
CKEDITOR.inline(div)
|
8
|
+
CKEDITOR.inline(div, extraPlugins: 'sourcedialog')
|
9
9
|
|
10
10
|
Editor.deactive = ->
|
11
11
|
$('.editable-long-text').attr('contenteditable', false)
|
@@ -20,18 +20,3 @@ Editor.commitAll = ->
|
|
20
20
|
model.id = dataset.id
|
21
21
|
model.set(dataset.attribute, editor.getData())
|
22
22
|
)
|
23
|
-
|
24
|
-
Editor.on('instanceCreated', ( event ) ->
|
25
|
-
editor = event.editor
|
26
|
-
element = editor.element
|
27
|
-
editor.on('configLoaded', () ->
|
28
|
-
editor.config.toolbarGroups = [
|
29
|
-
{ name: 'editing', groups: [ 'basicstyles', 'links' ] }
|
30
|
-
{ name: 'styles' }
|
31
|
-
'/'
|
32
|
-
{ name: 'undo' }
|
33
|
-
{ name: 'clipboard', groups: [ 'selection', 'clipboard' ] }
|
34
|
-
{ name: 'insert' }
|
35
|
-
]
|
36
|
-
)
|
37
|
-
)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.html or http://ckeditor.com/license
|
4
|
+
*/
|
5
|
+
|
6
|
+
CKEDITOR.dialog.add( 'sourcedialog', function( editor ) {
|
7
|
+
var size = CKEDITOR.document.getWindow().getViewPaneSize();
|
8
|
+
|
9
|
+
// Make it maximum 800px wide, but still fully visible in the viewport.
|
10
|
+
var width = Math.min( size.width - 70, 800);
|
11
|
+
|
12
|
+
// Make it use 2/3 of the viewport height.
|
13
|
+
var height = size.height / 1.5;
|
14
|
+
|
15
|
+
// Store old editor data to avoid unnecessary setData.
|
16
|
+
var oldData;
|
17
|
+
|
18
|
+
return {
|
19
|
+
title: editor.lang.sourcedialog.title,
|
20
|
+
minWidth: 100,
|
21
|
+
minHeight: 100,
|
22
|
+
|
23
|
+
onShow: function() {
|
24
|
+
this.setValueOf( 'main', 'data', oldData = editor.getData() );
|
25
|
+
},
|
26
|
+
|
27
|
+
onOk: (function() {
|
28
|
+
function setData( newData ) {
|
29
|
+
var that = this;
|
30
|
+
|
31
|
+
editor.setData( newData, function() {
|
32
|
+
that.hide();
|
33
|
+
|
34
|
+
// Ensure correct selection.
|
35
|
+
var range = editor.createRange();
|
36
|
+
range.moveToElementEditStart( editor.editable() );
|
37
|
+
range.select();
|
38
|
+
} );
|
39
|
+
}
|
40
|
+
|
41
|
+
return function( event ) {
|
42
|
+
// Remove CR from input data for reliable comparison with editor data.
|
43
|
+
var newData = this.getValueOf( 'main', 'data' ).replace( /\r/g, '' );
|
44
|
+
|
45
|
+
// Avoid unnecessary setData. Also preserve selection
|
46
|
+
// when user changed his mind and goes back to wysiwyg editing.
|
47
|
+
if ( newData === oldData )
|
48
|
+
return true;
|
49
|
+
|
50
|
+
// Set data asynchronously to avoid errors in IE.
|
51
|
+
CKEDITOR.env.ie ?
|
52
|
+
CKEDITOR.tools.setTimeout( setData, 0, this, newData )
|
53
|
+
:
|
54
|
+
setData.call( this, newData );
|
55
|
+
|
56
|
+
// Don't let the dialog close before setData is over.
|
57
|
+
return false;
|
58
|
+
};
|
59
|
+
})(),
|
60
|
+
|
61
|
+
contents: [{
|
62
|
+
id: 'main',
|
63
|
+
label: editor.lang.sourcedialog.title,
|
64
|
+
elements: [{
|
65
|
+
type: 'textarea',
|
66
|
+
type: 'textarea',
|
67
|
+
id: 'data',
|
68
|
+
dir: 'ltr',
|
69
|
+
inputStyle: 'cursor:auto;' +
|
70
|
+
'width:' + width + 'px;' +
|
71
|
+
'height:' + height + 'px;' +
|
72
|
+
'tab-size:4;' +
|
73
|
+
'text-align:left;',
|
74
|
+
'class': 'cke_source'
|
75
|
+
}]
|
76
|
+
}]
|
77
|
+
};
|
78
|
+
});
|
Binary file
|
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.html or http://ckeditor.com/license
|
4
|
+
*/
|
5
|
+
|
6
|
+
CKEDITOR.plugins.add( 'sourcedialog', {
|
7
|
+
lang: 'en', // %REMOVE_LINE_CORE%
|
8
|
+
icons: 'sourcedialog,sourcedialog-rtl', // %REMOVE_LINE_CORE%
|
9
|
+
|
10
|
+
init: function( editor ) {
|
11
|
+
// Register the "source" command, which simply opens the "source" dialog.
|
12
|
+
editor.addCommand( 'sourcedialog', new CKEDITOR.dialogCommand( 'sourcedialog' ) );
|
13
|
+
|
14
|
+
// Register the "source" dialog.
|
15
|
+
CKEDITOR.dialog.add( 'sourcedialog', this.path + 'dialogs/sourcedialog.js' );
|
16
|
+
|
17
|
+
// If the toolbar is available, create the "Source" button.
|
18
|
+
if ( editor.ui.addButton ) {
|
19
|
+
editor.ui.addButton( 'Sourcedialog', {
|
20
|
+
label: editor.lang.sourcedialog.toolbar,
|
21
|
+
command: 'sourcedialog',
|
22
|
+
toolbar: 'mode,10'
|
23
|
+
});
|
24
|
+
}
|
25
|
+
}
|
26
|
+
});
|
@@ -0,0 +1,118 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<!--
|
3
|
+
Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
|
4
|
+
For licensing, see LICENSE.html or http://ckeditor.com/license
|
5
|
+
-->
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>Raw HTML editing with dialog-based source editor — CKEditor Sample</title>
|
9
|
+
<meta charset="utf-8">
|
10
|
+
<script src="../../../ckeditor.js"></script>
|
11
|
+
<link rel="stylesheet" href="../../../samples/sample.css">
|
12
|
+
<meta name="ckeditor-sample-name" content="Raw HTML editing with dialog-based source editor">
|
13
|
+
<meta name="ckeditor-sample-group" content="Plugins">
|
14
|
+
<meta name="ckeditor-sample-description" content="Editing HTML content of both inline and framed editor instances.">
|
15
|
+
<meta name="ckeditor-sample-isnew" content="1">
|
16
|
+
<style>
|
17
|
+
|
18
|
+
#editable
|
19
|
+
{
|
20
|
+
padding: 10px;
|
21
|
+
float: left;
|
22
|
+
}
|
23
|
+
|
24
|
+
</style>
|
25
|
+
</head>
|
26
|
+
<body>
|
27
|
+
<h1 class="samples">
|
28
|
+
<a href="../../../samples/index.html">CKEditor Samples</a> » Raw HTML editing with dialog-based source editor
|
29
|
+
</h1>
|
30
|
+
<div class="description">
|
31
|
+
<p>
|
32
|
+
<strong>Sourcedialog</strong> plugin provides an easy way to edit raw HTML content
|
33
|
+
of an editor, similarly to what is possible with <strong>Sourcearea</strong>
|
34
|
+
plugin for framed instances but using dialogs. Thanks to that, it's also possible
|
35
|
+
to manipulate raw content of inline editor instances.
|
36
|
+
</p>
|
37
|
+
<p>
|
38
|
+
This plugin extends the toolbar with a button,
|
39
|
+
which opens a dialog window with a source code editor. It works with both framed
|
40
|
+
and inline instances. To enable this
|
41
|
+
plugin, basically add <code>extraPlugins: 'sourcedialog'</code> to editor's
|
42
|
+
config:
|
43
|
+
</p>
|
44
|
+
<pre class="samples">
|
45
|
+
// Inline editor.
|
46
|
+
CKEDITOR.inline( 'editable', {
|
47
|
+
<strong>extraPlugins: 'sourcedialog'</strong>
|
48
|
+
});
|
49
|
+
|
50
|
+
// Framed editor.
|
51
|
+
CKEDITOR.replace( 'textarea_id', {
|
52
|
+
<strong>extraPlugins: 'sourcedialog'</strong>,
|
53
|
+
removePlugins: 'sourcearea'
|
54
|
+
});
|
55
|
+
</pre>
|
56
|
+
<p>
|
57
|
+
Note that you may want to include <code>removePlugins: 'sourcearea'</code>
|
58
|
+
in your config when using <strong>Sourcedialog</strong> in framed instances.
|
59
|
+
This prevents feature redundancy.
|
60
|
+
</p>
|
61
|
+
<p>
|
62
|
+
Note that <code>editable</code> in the code above is the <code>id</code>
|
63
|
+
attribute of the <code><div></code> element to be converted into an inline instance.
|
64
|
+
</p>
|
65
|
+
<p>
|
66
|
+
Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
|
67
|
+
the <code><textarea></code> element to be replaced with CKEditor.
|
68
|
+
</p>
|
69
|
+
</div>
|
70
|
+
<div>
|
71
|
+
<label for="editor1">
|
72
|
+
Inline editor:
|
73
|
+
</label>
|
74
|
+
<div id="editor1" contenteditable="true" style="padding: 5px 20px;">
|
75
|
+
<p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>
|
76
|
+
</div>
|
77
|
+
</div>
|
78
|
+
<br>
|
79
|
+
<div>
|
80
|
+
<label for="editor2">
|
81
|
+
Framed editor:
|
82
|
+
</label>
|
83
|
+
<textarea cols="80" id="editor2" name="editor2" rows="10">
|
84
|
+
This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.
|
85
|
+
</textarea>
|
86
|
+
</div>
|
87
|
+
<script>
|
88
|
+
|
89
|
+
// We need to turn off the automatic editor creation first.
|
90
|
+
CKEDITOR.disableAutoInline = true;
|
91
|
+
|
92
|
+
var config = {
|
93
|
+
toolbarGroups: [
|
94
|
+
{ name: 'mode' },
|
95
|
+
{ name: 'basicstyles' },
|
96
|
+
{ name: 'links' }
|
97
|
+
],
|
98
|
+
extraPlugins: 'sourcedialog',
|
99
|
+
removePlugins: 'sourcearea'
|
100
|
+
}
|
101
|
+
|
102
|
+
CKEDITOR.inline( 'editor1', config );
|
103
|
+
CKEDITOR.replace( 'editor2', config );
|
104
|
+
|
105
|
+
</script>
|
106
|
+
<div id="footer">
|
107
|
+
<hr>
|
108
|
+
<p>
|
109
|
+
CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">
|
110
|
+
http://ckeditor.com</a>
|
111
|
+
</p>
|
112
|
+
<p id="copy">
|
113
|
+
Copyright © 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a>
|
114
|
+
- Frederico Knabben. All rights reserved.
|
115
|
+
</p>
|
116
|
+
</div>
|
117
|
+
</body>
|
118
|
+
</html>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frontendeditor_ckeditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -74,6 +74,12 @@ files:
|
|
74
74
|
- vendor/assets/stylesheets/ckeditor/skins/kama/dialog_opera.css
|
75
75
|
- vendor/assets/stylesheets/ckeditor/skins/kama/dialog_ie7.css
|
76
76
|
- vendor/assets/javascripts/ckeditor/ckeditor_actions.coffee
|
77
|
+
- vendor/assets/javascripts/ckeditor/plugins/sourcedialog/samples/sourcedialog.html
|
78
|
+
- vendor/assets/javascripts/ckeditor/plugins/sourcedialog/icons/sourcedialog.png
|
79
|
+
- vendor/assets/javascripts/ckeditor/plugins/sourcedialog/icons/sourcedialog-rtl.png
|
80
|
+
- vendor/assets/javascripts/ckeditor/plugins/sourcedialog/lang/en.js
|
81
|
+
- vendor/assets/javascripts/ckeditor/plugins/sourcedialog/plugin.js
|
82
|
+
- vendor/assets/javascripts/ckeditor/plugins/sourcedialog/dialogs/sourcedialog.js
|
77
83
|
- vendor/assets/javascripts/ckeditor/init_ckeditor.coffee
|
78
84
|
- Rakefile
|
79
85
|
- README.md
|