refinerycms-wymeditor 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +8 -0
  4. data/app/assets/javascripts/refinery/boot_wym.js.erb +19 -41
  5. data/app/assets/javascripts/refinery/wymeditor.js +9 -7
  6. data/app/assets/javascripts/wymeditor/GPL-license.txt +278 -0
  7. data/app/assets/javascripts/wymeditor/MIT-license.txt +20 -0
  8. data/app/assets/javascripts/wymeditor/README.txt +35 -0
  9. data/app/assets/javascripts/wymeditor/browsers/mozilla.js.erb +10 -11
  10. data/app/assets/javascripts/wymeditor/browsers/webkit.js.erb +17 -18
  11. data/app/assets/javascripts/wymeditor/classes.js.erb +3 -5
  12. data/app/assets/javascripts/wymeditor/functions.js.erb +8 -4
  13. data/app/assets/javascripts/wymeditor/init_interface.js +45 -0
  14. data/app/assets/javascripts/wymeditor/lang/de.js +13 -1
  15. data/app/assets/javascripts/wymeditor/lang/fr.js +1 -0
  16. data/app/assets/javascripts/wymeditor/lang/nl.js +55 -45
  17. data/app/assets/javascripts/wymeditor/lang/pl.js +12 -1
  18. data/app/assets/javascripts/wymeditor/lang/ru.js +1 -0
  19. data/app/assets/javascripts/wymeditor/lang/{zh_cn.js → zh-CN.js} +1 -1
  20. data/app/assets/javascripts/wymeditor/lang/zh-TW.js +47 -0
  21. data/app/assets/javascripts/wymeditor/prototypes.js.erb +6 -9
  22. data/app/assets/javascripts/wymeditor/setup.js.erb +36 -36
  23. data/app/assets/javascripts/wymeditor/skins/refinery/skin.js +1 -4
  24. data/app/assets/javascripts/wymeditor/validators.js.erb +3 -2
  25. data/app/assets/stylesheets/wymeditor/skins/refinery/skin.css.scss +9 -9
  26. data/app/assets/stylesheets/wymeditor/skins/refinery/wymiframe.css.scss +29 -29
  27. data/app/decorators/controllers/refinery/fast_controller_decorator.rb +5 -0
  28. data/app/decorators/models/refinery/page/friendly_id_options_decorator.rb +8 -0
  29. data/app/views/refinery/admin/dialogs/show.html.erb +19 -0
  30. data/app/views/refinery/wymiframe.html.erb +1 -1
  31. data/config/routes.rb +3 -0
  32. data/lib/generators/refinery/wymeditor/templates/config/initializers/refinery/wymeditor.rb.erb +5 -0
  33. data/lib/generators/refinery/wymeditor/wymeditor_generator.rb +10 -0
  34. data/lib/refinery/wymeditor/engine.rb +17 -12
  35. data/lib/refinerycms-wymeditor.rb +2 -0
  36. data/readme.md +44 -32
  37. data/refinerycms-wymeditor.gemspec +3 -1
  38. data/spec/controllers/refinery/fast_controller_spec.rb +12 -0
  39. data/spec/spec_helper.rb +30 -0
  40. metadata +49 -13
  41. data/.gitignore +0 -88
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ WYMeditor : what you see is What You Mean web-based editor
2
+ Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/
3
+ Dual licensed under the MIT (MIT-license.txt)
4
+ and GPL (GPL-license.txt) licenses.
5
+
6
+ For further information visit:
7
+ http://www.wymeditor.org/
8
+
9
+ File Name:
10
+ README
11
+ Readme file.
12
+
13
+ File Authors:
14
+ Jean-François Hovinne - http://www.hovinne.com/
15
+
16
+
17
+ README
18
+ ======
19
+
20
+ For WYMeditor to work, you'll need at least jQuery 1.1.3.x
21
+ jQuery is available at http://jquery.com/
22
+
23
+ WYMeditor is compatible with MSIE 6.0+,
24
+ Gecko-based browsers (e.g. Firefox 1.5+),
25
+ Opera 9.5+, Safari 3.0+, Google Chrome.
26
+
27
+ WYMeditor integration examples are available in the 'examples' directory.
28
+
29
+ For more information, please read the documentation, available at:
30
+ http://trac.wymeditor.org/trac/wiki
31
+
32
+ If you need help, feel free to create an account on the forum or subscribe
33
+ to the WYMeditor-user mailing-list, and ask your question.
34
+ http://forum.wymeditor.org/
35
+ http://lists.wymeditor.org/
@@ -267,22 +267,21 @@ WYMeditor.WymClassMozilla.prototype.openBlockTag = function(tag, attributes)
267
267
  {
268
268
  var attributes = this.validator.getValidTagAttributes(tag, attributes);
269
269
 
270
- // Handle Mozilla styled spans
271
- if(tag == 'span' && attributes.style) {
272
- var new_tag = this.getTagForStyle(attributes.style);
273
- if(new_tag){
274
- this._tag_stack.pop();
275
- var tag = new_tag;
276
- this._tag_stack.push(new_tag);
277
- attributes.style = '';
278
- } else {
279
- return;
270
+ // Handle Mozilla styled spans
271
+ if (tag === 'span' && attributes.style) {
272
+ var new_tag = this.getTagForStyle(attributes.style);
273
+ if (new_tag) {
274
+ tag = new_tag;
275
+ this._tag_stack.pop();
276
+ this._tag_stack.push(tag);
277
+ attributes.style = '';
278
+ }
280
279
  }
281
- }
282
280
 
283
281
  this.output += this.helper.tag(tag, attributes, true);
284
282
  };
285
283
 
284
+
286
285
  WYMeditor.WymClassMozilla.prototype.getTagForStyle = function(style) {
287
286
 
288
287
  if(/bold/.test(style)) return 'strong';
@@ -251,27 +251,26 @@ WYMeditor.WymClassSafari.prototype.keyup = function(e) {
251
251
 
252
252
  WYMeditor.WymClassSafari.prototype.openBlockTag = function(tag, attributes)
253
253
  {
254
- var attributes = this.validator.getValidTagAttributes(tag, attributes);
255
-
256
- // Handle Safari styled spans
257
- if(tag == 'span' && attributes.style) {
258
- if(new_tag = this.getTagForStyle(attributes.style)) {
259
- this._tag_stack.pop();
260
- var tag = new_tag;
261
- this._tag_stack.push(new_tag);
262
- attributes.style = '';
263
-
264
- //should fix #125 - also removed the xhtml() override
265
- if(typeof attributes['class'] == 'string') {
266
- attributes['class'] = attributes['class'].replace(/apple-style-span/gi, '');
267
- }
254
+ var attributes = this.validator.getValidTagAttributes(tag, attributes);
255
+
256
+ // Handle Safari styled spans
257
+ if(tag == 'span' && attributes.style) {
258
+ new_tag = this.getTagForStyle(attributes.style);
259
+ if(new_tag) {
260
+ this._tag_stack.pop();
261
+ var tag = new_tag;
262
+ this._tag_stack.push(new_tag);
263
+ attributes.style = '';
264
+
265
+ //should fix #125 - also removed the xhtml() override
266
+ if(typeof attributes['class'] == 'string') {
267
+ attributes['class'] = attributes['class'].replace(/apple-style-span/gi, '');
268
+ }
268
269
 
269
- } else {
270
- return;
270
+ }
271
271
  }
272
- }
273
272
 
274
- this.output += this.helper.tag(tag, attributes, true);
273
+ this.output += this.helper.tag(tag, attributes, true);
275
274
  };
276
275
 
277
276
  WYMeditor.WymClassSafari.prototype.getTagForStyle = function(style) {
@@ -636,9 +636,7 @@ WYMeditor.Lexer.prototype._invokeParser = function(content, is_match)
636
636
  }
637
637
  var current = this._mode.getCurrent();
638
638
  var handler = this._mode_handlers[current];
639
- var result;
640
- eval('result = this._parser.' + handler + '(content, is_match);');
641
- return result;
639
+ return this._parser[handler](content, is_match);
642
640
  };
643
641
 
644
642
  /**
@@ -1122,8 +1120,8 @@ WYMeditor.XhtmlSaxListener = function()
1122
1120
  "thead", "title", "tr", "tt", "ul", "var", "extends", "meter",
1123
1121
  "section", "article", "aside", "details", "header", "footer",
1124
1122
  "nav", "dialog", "figure", "figcaption", "address", "hgroup",
1125
- "mark", "time", "canvas", "audio", "video", "source", "output",
1126
- "progress", "ruby", "rt", "rp", "summary", "command"<%= ", #{Refinery::Wymeditor.whitelist_tags.keys.map{|k| %Q{"#{k}"}}.join(', ')}" if Refinery::Wymeditor.whitelist_tags.any? %>];
1123
+ "mark", "time", "canvas", "audio", "video", "output",
1124
+ "progress", "ruby", "rt", "rp", "summary", "command"];
1127
1125
 
1128
1126
 
1129
1127
  // Defines self-closing tags.
@@ -16,7 +16,7 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
16
16
  var selected = selected || wym.selected();
17
17
  var dialog = $("#"+wym._options.dialogId);
18
18
  var doc = $(dialog.find('iframe').contents());
19
- var dialogType = dialog.find('#wym_dialog_type').val();
19
+ var dialogType = dialog.find('#visual_editor_dialog_type').val();
20
20
  if (wym._selected_image) {
21
21
  var replaceable = $(wym._selected_image);
22
22
  } else {
@@ -27,7 +27,7 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
27
27
  dialog.find('input[type=text], textarea').first().focus();
28
28
 
29
29
  // init close_dialog when user clicks on cancel button
30
- doc.find('body').addClass('wym_iframe_body').find('#cancel_button').add(dialog.find('.close_dialog')).click(function(e){
30
+ doc.find('body').addClass('visual_editor_iframe_body').find('#cancel_button').add(dialog.find('.close_dialog')).click(function(e){
31
31
  wym.close_dialog(e, true);
32
32
  });
33
33
 
@@ -88,7 +88,11 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
88
88
  if(wym._selected_image) {
89
89
  imgDialog = $(wym._options.dialogImageSelector);
90
90
  img = $(wym._selected_image);
91
- size = ((img.attr(WYMeditor.REL) || doc.find('#existing_image_size_area li.selected a').attr('rel')) || "");
91
+ size = (
92
+ (img.attr(WYMeditor.REL)
93
+ || doc.find('#existing_image_size_area li.selected a').attr(WYMeditor.REL)
94
+ || doc.find('#existing_image_size_area li.selected a').attr('rel')) || ""
95
+ );
92
96
  src = img.attr(WYMeditor.SRC);
93
97
  if (size.length > 0) {
94
98
  src = src.replace('_' + size + '.', '.');
@@ -183,7 +187,7 @@ WYMeditor.editor.prototype.close_dialog = function(e, cancelled) {
183
187
  if ((span = $(this._doc.body).find('span#' + this._current_unique_stamp)).length > 0) {
184
188
  span.parent().html(span.parent().html().replace(new RegExp(["<span(.+?)", span.attr('id'), "(.+?)<\/span>"].join("")), span.html()));
185
189
  }
186
- // https://github.com/resolve/refinerycms/issues/888
190
+ // https://github.com/refinery/refinerycms/issues/888
187
191
  if (node = $(this._doc.body).find('#' + this._current_unique_stamp)) {
188
192
  node.attr("id", (node.attr('_id_before_replaceable') || ""));
189
193
  node.removeAttr("_id_before_replaceable");
@@ -0,0 +1,45 @@
1
+ this.visual_editor_init_interface_hook = (function(_this) {
2
+ return function() {
3
+ return $("textarea.wymeditor, textarea.visual_editor").each(function() {
4
+ var instance, next, prev, textarea;
5
+ textarea = $(this);
6
+ if ((instance = WYMeditor.INSTANCES[$((textarea.next(".visual_editor_box").find("iframe").attr("id") || "").split("_")).last().get(0)]) != null) {
7
+ if (((next = textarea.parent().next()) != null) && next.length > 0) {
8
+ next.find("input, textarea").keydown($.proxy(function(e) {
9
+ var shiftHeld;
10
+ shiftHeld = e.shiftKey;
11
+ if (shiftHeld && e.keyCode === $.ui.keyCode.TAB) {
12
+ this._iframe.contentWindow.focus();
13
+ return e.preventDefault();
14
+ }
15
+ }, instance)).keyup(function(e) {
16
+ var shiftHeld;
17
+ return shiftHeld = false;
18
+ });
19
+ }
20
+ if (((prev = textarea.parent().prev()) != null) && prev.length > 0) {
21
+ return prev.find("input, textarea").keydown($.proxy(function(e) {
22
+ if (e.keyCode === $.ui.keyCode.TAB) {
23
+ this._iframe.contentWindow.focus();
24
+ return e.preventDefault();
25
+ }
26
+ }, instance));
27
+ }
28
+ }
29
+ });
30
+ };
31
+ })(this);
32
+
33
+ this.visual_editor_update = (function(_this) {
34
+ return function() {
35
+ $.each(WYMeditor.INSTANCES, function(index, wym) {
36
+ wym.update();
37
+ });
38
+ }
39
+ })(this);
40
+
41
+ this.visual_editor_init = (function(_this) {
42
+ return function() {
43
+ return WYMEditor.init();
44
+ };
45
+ })(this);
@@ -1,6 +1,7 @@
1
1
  WYMeditor.STRINGS['de'] = {
2
2
  Apply_Style: 'Style',
3
3
  Strong: 'Fett',
4
+ Bold: 'Fett',
4
5
  Emphasis: 'Kursiv',
5
6
  Superscript: 'Hochstellen',
6
7
  Subscript: 'Tiefstellen',
@@ -41,5 +42,16 @@ WYMeditor.STRINGS['de'] = {
41
42
  Containers: 'Inhaltstyp',
42
43
  Classes: 'Klassen',
43
44
  Status: 'Status',
44
- Source_Code: 'Quellcode'
45
+ Source_Code: 'Quellcode',
46
+ Text_Align: 'Textausrichtung',
47
+ Image_Align: 'Bildausrichtung',
48
+ Font_Size: 'Schriftgröße',
49
+ Left: 'Links',
50
+ Right: 'Rechts',
51
+ Center: 'Zentriert',
52
+ Justify: 'Justify',
53
+ Small: 'Klein',
54
+ Normal: 'Normal',
55
+ Large: 'Groß',
56
+ Insert: 'Einfügen',
45
57
  };
@@ -31,6 +31,7 @@ WYMeditor.STRINGS['fr'] = {
31
31
  Summary: 'Résumé',
32
32
  Number_Of_Rows: 'Nombre de lignes',
33
33
  Number_Of_Cols: 'Nombre de colonnes',
34
+ Insert: 'Insérer',
34
35
  Submit: 'Envoyer',
35
36
  Cancel: 'Annuler',
36
37
  Choose: 'Choisir',
@@ -1,47 +1,57 @@
1
1
  WYMeditor.STRINGS['nl'] = {
2
- Strong: 'Sterk benadrukken',
3
- Bold: 'Vet',
4
- Emphasis: 'Benadrukken',
5
- Superscript: 'Bovenschrift',
6
- Subscript: 'Onderschrift',
7
- Ordered_List: 'Geordende lijst',
8
- Unordered_List: 'Ongeordende lijst',
9
- Indent: 'Inspringen',
10
- Outdent: 'Terugspringen',
11
- Undo: 'Ongedaan maken',
12
- Redo: 'Opnieuw uitvoeren',
13
- Link: 'Linken',
14
- Unlink: 'Ontlinken',
15
- Image: 'Afbeelding',
16
- Table: 'Tabel',
17
- HTML: 'HTML',
18
- Paragraph: 'Paragraaf',
19
- Heading_1: 'Kop 1',
20
- Heading_2: 'Kop 2',
21
- Heading_3: 'Kop 3',
22
- Heading_4: 'Kop 4',
23
- Heading_5: 'Kop 5',
24
- Heading_6: 'Kop 6',
25
- Preformatted: 'Voorgeformatteerd',
26
- Blockquote: 'Citaat',
27
- Table_Header: 'Tabel-kop',
28
- URL: 'URL',
29
- Title: 'Titel',
30
- Alternative_Text: 'Alternatieve tekst',
31
- Caption: 'Bijschrift',
32
- Summary: 'Summary',
33
- Number_Of_Rows: 'Aantal rijen',
34
- Number_Of_Cols: 'Aantal kolommen',
35
- Insert: 'Invoegen',
36
- Submit: 'Versturen',
37
- Cancel: 'Annuleren',
38
- Choose: 'Kiezen',
39
- Preview: 'Voorbeeld bekijken',
40
- Paste_From_Word: 'Plakken uit Word',
41
- Tools: 'Hulpmiddelen',
42
- Containers: 'Teksttypes',
43
- Classes: 'Klassen',
44
- Status: 'Status',
45
- Source_Code: 'Broncode',
46
- Css_Class: 'Gebruik CSS klasse'
2
+ Strong: 'Sterk benadrukken',
3
+ Bold: 'Vet',
4
+ Emphasis: 'Benadrukken',
5
+ Superscript: 'Bovenschrift',
6
+ Subscript: 'Onderschrift',
7
+ Ordered_List: 'Geordende lijst',
8
+ Unordered_List: 'Ongeordende lijst',
9
+ Indent: 'Inspringen',
10
+ Outdent: 'Terugspringen',
11
+ Undo: 'Ongedaan maken',
12
+ Redo: 'Opnieuw uitvoeren',
13
+ Link: 'Linken',
14
+ Unlink: 'Ontlinken',
15
+ Image: 'Afbeelding',
16
+ Table: 'Tabel',
17
+ HTML: 'HTML',
18
+ Paragraph: 'Paragraaf',
19
+ Heading_1: 'Kop 1',
20
+ Heading_2: 'Kop 2',
21
+ Heading_3: 'Kop 3',
22
+ Heading_4: 'Kop 4',
23
+ Heading_5: 'Kop 5',
24
+ Heading_6: 'Kop 6',
25
+ Preformatted: 'Voorgeformatteerd',
26
+ Blockquote: 'Citaat',
27
+ Table_Header: 'Tabel-kop',
28
+ URL: 'URL',
29
+ Title: 'Titel',
30
+ Alternative_Text: 'Alternatieve tekst',
31
+ Caption: 'Bijschrift',
32
+ Summary: 'Overzicht',
33
+ Number_Of_Rows: 'Aantal rijen',
34
+ Number_Of_Cols: 'Aantal kolommen',
35
+ Insert: 'Invoegen',
36
+ Submit: 'Versturen',
37
+ Cancel: 'Annuleren',
38
+ Choose: 'Kiezen',
39
+ Preview: 'Voorbeeld bekijken',
40
+ Paste_From_Word: 'Plakken uit Word',
41
+ Tools: 'Hulpmiddelen',
42
+ Containers: 'Teksttypes',
43
+ Classes: 'Klassen',
44
+ Status: 'Status',
45
+ Source_Code: 'Broncode',
46
+ Text_Align: 'Tekst uitlijnen',
47
+ Image_Align: 'Afbeelding uitlijnen',
48
+ Font_Size: 'Lettertype grootte',
49
+ Left: 'Links',
50
+ Right: 'Rechts',
51
+ Center: 'Midden',
52
+ Justify: 'Uitgevuld',
53
+ Small: 'Klein',
54
+ Normal: 'Normaal',
55
+ Large: 'Groot',
56
+ Apply_Style: 'Stijl'
47
57
  };
@@ -40,6 +40,17 @@ WYMeditor.STRINGS['pl'] = {
40
40
  Containers: 'Format',
41
41
  Classes: 'Styl',
42
42
  Status: 'Status',
43
- Source_Code: 'Kod źródłowy'
43
+ Source_Code: 'Kod źródłowy',
44
+ Apply_Style: 'Określ styl',
45
+ Text_Align: "Wyrównanie tekstu",
46
+ Left: "Do lewej",
47
+ Right: "Do prawej",
48
+ Center: "Do środka",
49
+ Justify: "Wyjustuj",
50
+ Image_Align: "Wyrównanie obrazka",
51
+ Font_Size: "Rozmiar teksru",
52
+ Small: "Mały",
53
+ Normal: "Normalny",
54
+ Large: "Duży"
44
55
  };
45
56
 
@@ -31,6 +31,7 @@ WYMeditor.STRINGS['ru'] = {
31
31
  Summary: 'Summary',
32
32
  Number_Of_Rows: 'Кол-во строк',
33
33
  Number_Of_Cols: 'Кол-во столбцов',
34
+ Insert: 'Вставить',
34
35
  Submit: 'Отправить',
35
36
  Cancel: 'Отмена',
36
37
  Choose: 'Выбор',
@@ -1,4 +1,4 @@
1
- WYMeditor.STRINGS['zh_cn'] = {
1
+ WYMeditor.STRINGS['zh-CN'] = {
2
2
  Strong: '加粗',
3
3
  Emphasis: '斜体',
4
4
  Superscript: '上标',
@@ -0,0 +1,47 @@
1
+ WYMeditor.STRINGS['zh-TW'] = {
2
+ Strong: '加粗',
3
+ Emphasis: '斜體',
4
+ Superscript: '上標',
5
+ Subscript: '下標',
6
+ Ordered_List: '排序列表',
7
+ Unordered_List: '無序列表',
8
+ Indent: '增加縮排',
9
+ Outdent: '減少縮排',
10
+ Undo: '撤消',
11
+ Redo: '重做',
12
+ Link: '鏈接',
13
+ Unlink: '取消鏈接',
14
+ Image: '圖片',
15
+ Table: '表格',
16
+ HTML: 'HTML 源代碼',
17
+ Paragraph: '段落',
18
+ Heading_1: '標題 1',
19
+ Heading_2: '標題 2',
20
+ Heading_3: '標題 3',
21
+ Heading_4: '標題 4',
22
+ Heading_5: '標題 5',
23
+ Heading_6: '標題 6',
24
+ Preformatted: '原始文本',
25
+ Blockquote: '引語',
26
+ Table_Header: '表頭',
27
+ URL: '地址',
28
+ Title: '提示文字',
29
+ Alternative_Text: '圖示文字',
30
+ Caption: '標題',
31
+ Summary: '總結',
32
+ Number_Of_Rows: '行數',
33
+ Number_Of_Cols: '列數',
34
+ Submit: '提交',
35
+ Cancel: '放棄',
36
+ Choose: '選擇',
37
+ Preview: '預覽',
38
+ Paste_From_Word: '從 Word 貼上純文字',
39
+ Tools: '工具',
40
+ Containers: '容器',
41
+ Classes: '預定義樣式',
42
+ Status: '狀態',
43
+ Source_Code: '源代碼',
44
+ Attachment: '附件',
45
+ NewParagraph: '新段落'
46
+ };
47
+