Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow text and HTML values #5

Open
dennisverspuij opened this issue May 6, 2014 · 0 comments
Open

Allow text and HTML values #5

dennisverspuij opened this issue May 6, 2014 · 0 comments

Comments

@dennisverspuij
Copy link

Hello, please consider the patch below to control whether a string is inserted as either text or HTML.
To indicate a string is HTML formatted you must provide a property html with value that evaluates to true in the strinsert_strings configuration object, like done in the additional example.
This implementation also transparently works around the issue that CKEditor richcombo values does not like HTML entities in its values as confirmed in https://dev.ckeditor.com/ticket/11701.

Index: plugin.js
===================================================================
--- plugin.js   (revision 25)
+++ plugin.js   (working copy)
@@ -27,6 +27,7 @@
            {'name': 'Name', 'value': '*|VALUE|*'},
            {'name': 'Group 1'},
            {'name': 'Another name', 'value': 'totally_different', 'label': 'Good looking'},
+           {'name': 'Some HTML', 'html': true, 'value': '<strong>Some &lt;HTML&gt;</strong>'},
        ];

 /**
@@ -89,7 +90,7 @@
                        if (!string.label) {
                            string.label = string.name;
                        }
-                       this.add(string.value, string.name, string.label);
+                       this.add(""+i, string.name, string.label);
                    }
                }
            },
@@ -98,7 +99,8 @@
            {
                editor.focus();
                editor.fire( 'saveSnapshot' );
-               editor.insertHtml(value);
+               var string = strings[value];
+               editor[string.html ? 'insertHtml' : 'insertText'](string.value);
                editor.fire( 'saveSnapshot' );
            },

@dennisverspuij dennisverspuij changed the title Allow HTML values Allow text and HTML values May 6, 2014
@57u 57u assigned 57u and unassigned 57u May 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants