Browse Source

#3708 - Quill - insert as plain text

RomanL 4 years ago
parent
commit
ad65d53bad

+ 9 - 0
inc/js/editor.quill.js

@@ -249,6 +249,14 @@ function bx_editor_init(oEditor, oParams){
             return true;
         }
     });
+    console.log(oParams.insert_as_plain_text);
+    if (oParams.insert_as_plain_text){
+        oEditor.clipboard.addMatcher (Node.ELEMENT_NODE, function (node, delta) {
+            var plaintext = $ (node).text ();
+            const Delta = Quill.import('delta')
+            return new Delta().insert (plaintext);
+        });
+    }
     
     oEditor.keyboard.bindings[13].unshift({
         key: 13,
@@ -267,6 +275,7 @@ function bx_editor_init(oEditor, oParams){
     
 function bx_editor_insert_html (sEditorId, sImgId, sHtml) 
 {
+    console.log(999);
     if ($('#' + sEditorId) &&  $('#' + sEditorId).attr('object_editor')){
         eval ('oEditor = ' + $('#' + sEditorId).attr('object_editor'));
         if (oEditor.getSelection())

+ 2 - 0
install/sql/system.sql

@@ -319,6 +319,8 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 
 (@iCategoryId, 'sys_live_updates_interval', '_adm_stg_cpt_option_sys_live_updates_interval', '10000', 'digit', '', '', '', '', 60),
 
+(@iCategoryId, 'sys_quill_insert_as_plain_text', '_adm_stg_cpt_option_sys_quill_insert_as_plain_text', '', 'checkbox', '', '', '', '', 65),
+
 (@iCategoryId, 'sys_quill_toolbar_mini', '_adm_stg_cpt_option_sys_quill_toolbar_mini', '[\'bold\',\'italic\',\'underline\',\'clean\',{\'list\':\'ordered\'}, {\'list\':\'bullet\'},{ \'align\':\'\'},{\'align\':\'center\'},{\'align\':\'right\'},\'blockquote\',\'link\',\'image\',\'embed\']', 'digit', '', '', '', '', 70),
 (@iCategoryId, 'sys_quill_toolbar_standard', '_adm_stg_cpt_option_sys_quill_toolbar_standard', '[\'bold\',\'italic\',\'underline\',\'clean\',{ \'header\': [1, 2, 3, 4, 5, 6, false] },{\'list\':\'ordered\'}, {\'list\':\'bullet\'},{\'indent\': \'-1\'},{\'indent\': \'+1\'},{ \'align\':\'\'},{\'align\':\'center\'},{\'align\':\'right\'},{\'align\':\'justify\'},\'blockquote\',\'link\',\'image\',\'embed\']', 'digit', '', '', '', '', 73),
 (@iCategoryId, 'sys_quill_toolbar_full', '_adm_stg_cpt_option_sys_quill_toolbar_full', '[{ \'header\': [1, 2, 3, 4, 5, 6, false] },\'bold\',\'italic\',\'underline\',\'clean\'],

+ 1 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1634,6 +1634,7 @@
     <string name="_adm_stg_cpt_option_template"><![CDATA[Default Template]]></string>
     <string name="_adm_stg_err_option_template"><![CDATA[Template cannot be empty and must have a valid name.]]></string>
     <string name="_adm_stg_cpt_option_use_like_operator"><![CDATA[Use operator LIKE for search (recommended for small content)]]></string>
+    <string name="_adm_stg_cpt_option_sys_quill_insert_as_plain_text"><![CDATA[Quill - paste as plain text]]></string>
     <string name="_adm_stg_cpt_option_sys_quill_toolbar_mini"><![CDATA[Quill buttons for mini editor]]></string>
     <string name="_adm_stg_cpt_option_sys_quill_toolbar_standard"><![CDATA[Quill buttons for standard editor]]></string>
     <string name="_adm_stg_cpt_option_sys_quill_toolbar_full"><![CDATA[Quill buttons for full editor]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1619,6 +1619,7 @@
 	<string name="_adm_stg_cpt_option_template"><![CDATA[Основная тема]]></string>
 	<string name="_adm_stg_err_option_template"><![CDATA[Тема не может быть пустой и должна иметь приемлемое название.]]></string>
     <string name="_adm_stg_cpt_option_use_like_operator"><![CDATA[Использовать для поиска оператор LIKE (рекомендуется для небольшого содержимого)]]></string>
+    <string name="_adm_stg_cpt_option_sys_quill_insert_as_plain_text"><![CDATA[Quill - вставлять как текст]]></string>
     <string name="_adm_stg_cpt_option_sys_quill_toolbar_mini"><![CDATA[Quill кнопки для мини редактора]]></string>
     <string name="_adm_stg_cpt_option_sys_quill_toolbar_standard"><![CDATA[Quill кнопки для стандартного редактора]]></string>
     <string name="_adm_stg_cpt_option_sys_quill_toolbar_full"><![CDATA[Quill buttons кнопки для полного редактора]]></string>

+ 2 - 0
template/scripts/BxBaseEditorQuill.php

@@ -26,6 +26,7 @@ class BxBaseEditorQuill extends BxDolEditor
             toolbar: {toolbar},
             root_url: '{bx_url_root}',
             query_params: {bx_var_query_params},
+            insert_as_plain_text: {insert_as_plain_text}
         }
         {bx_var_editor_name} = bx_editor_init({bx_var_editor_name}, oParams);";
    
@@ -119,6 +120,7 @@ class BxBaseEditorQuill extends BxDolEditor
             'bx_var_query_params' => isset($aAttrs['query_params']) ? json_encode($aAttrs['query_params']) : "''",
             'bx_var_form_id' => $aAttrs['form_id'],
             'toolbar' => $sToolbarItems ? '[' . $sToolbarItems . ']' : 'false',
+            'insert_as_plain_text' => getParam('sys_quill_insert_as_plain_text') == 'on' ? 'true' : 'false',
             'bx_var_css_additional_class' => $sToolbarItems ? '' : 'bx-form-input-html-quill-empty',
             'bx_var_element_name' => str_replace(['-', ' '], '_', $aAttrs['element_name']),
             'bx_var_editor_name' => $sEditorName,