RomanL 5 лет назад
Родитель
Сommit
a1799d0be4

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

@@ -1,94 +0,0 @@
-/**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup    UnaCore UNA Core
- * @{
- */
-
-function bx_editor_insert_html (sEditorId, sImgId, sHtml) {
-    
-    var eEditor = 'object' == typeof(quill) ? quill.get(sEditorId) : undefined;
-    if ('undefined' == typeof(eEditor))
-        return;
-
-    if (eEditor.dom && eEditor.dom.doc && eEditor.dom.doc.getElementById(sImgId))
-        return;
-
-    eEditor.execCommand('mceInsertContent', false, sHtml);
-}
-
-function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) {
-
-    if ('undefined' == typeof(sClasses))
-        sClasses = '';
-    
-    bx_editor_insert_html(sEditorId, sImgId, '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />')
-}
-
-function bx_editor_on_init (sEditorId)
-{
-    if (typeof glOnInitEditor !== 'undefined' && glOnInitEditor instanceof Array) {
-        for (var i = 0; i < glOnInitEditor.length; i++)
-            if (typeof glOnInitEditor[i] === "function")
-                glOnInitEditor[i](sEditorId);
-    }
-}
-
-function bx_editor_on_space_enter (sEditorId)
-{
-    // TODO:
-}
-
-function bx_editor_remove_img (aEditorIds, aMarkers) {
-    if ('object' != typeof(quill))
-        return;
-
-    var aEditors = [];
-    for (var i = 0; i < aEditorIds.length; i++)
-        aEditors.push(quill.get(aEditorIds[i]));
-
-    for (var j = 0; j < aEditors.length; j++) {
-        var eEditor = aEditors[j];
-        if (typeof(eEditor) != 'object' || null === eEditor || typeof(eEditor.dom) != 'object' || typeof(eEditor.dom.doc) != 'object') 
-        	continue;
-
-        // delete images in html editor
-        for (var k = 0; k < aMarkers.length; k++) {
-            var jFiles = $(eEditor.dom.doc).find(aMarkers[k]);
-            jFiles.each(function () { 
-                eEditor.execCommand('mceRemoveNode', false, this); 
-            });
-        }
-    }
-}
-
-function bx_editor_get_htmleditable (sEditorSelector)
-{
-    if (!$(sEditorSelector).size())
-        return false;
-
-    var sId = $(sEditorSelector).attr('id');
-    
-    var eEditor = 'object' == typeof(quill) ? quill.get(sId) : undefined;
-    if ('undefined' == typeof(eEditor) || !eEditor.dom)
-        return false;
-
-    return $(eEditor.dom.doc).find('body').get(0);
-}
-
-function bx_editor_remove_all (oElement) 
-{
-    if ('undefined' == typeof(oElement))
-        oElement = window;
-    oElement = $(oElement);
-
-    if ('undefined' == typeof(quill) || !quill.editors.length)
-        return;
-    $.each(quill.editors, function () {
-        if ($(this.getElement()).parents().filter(oElement).length)
-            this.remove();
-    });
-}
-
-/** @} */

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
plugins_public/quill/image-resize.min.js


+ 17 - 14
plugins_public/quill/quill.custom.css

@@ -1,42 +1,45 @@
+.bx-form-input-html-quill{
+    z-index: 1;
+}
+.ql-picker-options{
+    z-index: 2 !important;
+}
 .ql-editor{
     background: #fff;
 }    
-.ql-container{
-    height: 150px;
-}
-.ql-container.ql-snow{
+.bx-artificer .ql-container.ql-snow{
     border-radius: 0 0 0.375rem 0.375rem;
 }
-.ql-toolbar{
+.bx-artificer .ql-toolbar{
     border-radius: 0.375rem 0.375rem 0 0;
 }
-.ql-editor{
+.bx-artificer .ql-editor{
     border-radius: 0 0 0.375rem 0.375rem;
 }
 @media (prefers-color-scheme: dark) {
-	.ql-stroke{
+	.bx-artificer .ql-stroke{
 		stroke: rgb(209, 213, 219) !important;
 	}
-	.ql-fill{
+	.bx-artificer .ql-fill{
 		fill: rgb(209, 213, 219) !important;
 	}
-	.ql-picker{
+	.bx-artificer .ql-picker{
 		color: rgb(209, 213, 219) !important;
 	}
-	.ql-toolbar{
+	.bx-artificer .ql-toolbar{
         border-color: rgba(55,65,81,1) !important;
 	}
-    .ql-container.ql-snow{
+    .bx-artificer .ql-container.ql-snow{
         border-color: rgba(55,65,81,1) !important;
     }
-	.ql-editor{
+	.bx-artificer .ql-editor{
 		background: rgb(17, 24, 39);
 		color: rgb(209, 213, 219);
 	}
-	.ql-editor.ql-blank::before{
+	.bx-artificer .ql-editor.ql-blank::before{
 	    color: rgba(255,255,255,0.6);
 	}
-    .ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-options{
+    .bx-artificer .ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-options{
         background: rgb(17, 24, 39);
 		color: rgb(209, 213, 219);
     }

+ 21 - 0
plugins_public/quill/quill.custom.js

@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+function bx_editor_insert_html (sEditorId, sImgId, sHtml) {
+    quill_bx_posts_text.container.firstChild.innerHTML += sHtml;
+}
+
+function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) {
+
+    if ('undefined' == typeof(sClasses))
+        sClasses = '';
+    
+    bx_editor_insert_html(sEditorId, sImgId, '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />')
+}
+
+/** @} */

+ 38 - 13
template/scripts/BxBaseEditorQuill.php

@@ -23,33 +23,53 @@ class BxBaseEditorQuill extends BxDolEditor
                   languages: ['javascript', 'php', 'html', 'css']
                 });
     
-                $( "{bx_var_selector}" ).after( "<div id='editor_{bx_var_editor_name}' class='bx-def-font-inputs bx-form-input-textarea bx-form-input-html'>" + $( "{bx_var_selector}" ).val() + "</div>" );
-                $( "{bx_var_selector}" ).hide();
+                $( "{bx_var_selector}" ).after( "<div id='{bx_var_editor_name}' class='bx-def-font-inputs bx-form-input-textarea bx-form-input-html bx-form-input-html-quill'>" + $( "{bx_var_selector}" ).val() + "</div>" );
+                /*$( "{bx_var_selector}" ).hide();*/
                 
                 if (typeof bQuillRegistred === 'undefined') {
                     Quill.register("modules/imageUploader", ImageUploader); 
-                    bQuillRegistred = true;
+                    bQuillRegistred = true; 
                 }
+                var Embed = Quill.import('blots/embed');
+                class ProcLink extends Embed {
+                    static create(value) {
+                        let node = super.create(value);
+                        // give it some margin
+                        node.setAttribute('href', value.id);
+                        node.innerHTML = '@' + value.value;
+                        return node;
+                    }
+                }
+                ProcLink.blotName = 'proc-link'; 
+                ProcLink.className = 'proc-link';
+                ProcLink.tagName = 'a';                
+                Quill.register({
+                    'formats/proc-link': ProcLink
+                });
                 
-                var quill_{bx_var_editor_name} = new Quill('#editor_{bx_var_editor_name}', {
+                {bx_var_editor_name} = new Quill('#{bx_var_editor_name}', {
                      theme: '{bx_var_skin}',
                      modules: {
                         syntax: true, 
+                        imageResize: {},
                         toolbar: [{toolbar}],
                         mention: {
-                           // allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
+                            allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
                             mentionDenotationChars: ["@"],
+                            showDenotationChar: false,
+                            blotName: 'proc-link',
                             source: function (searchTerm, renderList, mentionChar) {
                               $.getJSON('{bx_url_root}searchExtended.php?action=get_authors&', { term: searchTerm}, function(data){
                                 renderList(data, searchTerm);
                               });
                             },
                             renderItem: function(item, searchTerm){
-                                item.value = '<a href="' + item.url + '" target="_blank" >' + item.label + '</a>';
-                                return '<a href="' + item.url + '" target="_blank" >@' + item.label + '</a>';
+                              item.id = item.url;
+                              item.value = item.label;
+                              return '@' + item.value;
                             },
                             onSelect: function(item, insertItem){
-                                insertItem(item)
+                                insertItem(item, false)
                             }
                         },
                         imageUploader: {
@@ -77,8 +97,8 @@ class BxBaseEditorQuill extends BxDolEditor
                     }
                 });
                 
-                quill_{bx_var_editor_name}.on('text-change', function(delta, oldDelta, source) {
-                    $('{bx_var_selector}').val(quill_{bx_var_editor_name}.container.firstChild.innerHTML);
+                {bx_var_editor_name}.on('text-change', function(delta, oldDelta, source) {
+                    $('{bx_var_selector}').val({bx_var_editor_name}.container.firstChild.innerHTML);
                 });
     EOS;
    
@@ -146,6 +166,9 @@ class BxBaseEditorQuill extends BxDolEditor
         	'path' => $this->_oTemplate->getCssPath($sCss),
         	'url' => $this->_oTemplate->getCssUrl($sCss)
         ));
+        
+        $sEditorName = 'quill_' . str_replace(['-', ' '], '_', $aAttrs['form_id'] . '_' . $aAttrs['element_name']);
+        
         // initialize editor
         $sInitEditor = $this->_replaceMarkers(self::$CONF_COMMON, array(
             'bx_var_custom_init' => $sCustomInit,
@@ -153,7 +176,7 @@ class BxBaseEditorQuill extends BxDolEditor
             'bx_var_form_id' => $aAttrs['form_id'],
             'toolbar' => $sToolbarItems ? $sToolbarItems : "[]",
             'bx_var_element_name' => str_replace(['-', ' '], '_', $aAttrs['element_name']),
-            'bx_var_editor_name' => str_replace(['-', ' '], '_', $aAttrs['form_id'] . '_' . $aAttrs['element_name']),
+            'bx_var_editor_name' => $sEditorName,
             'bx_var_skin' => bx_js_string($this->_aObject['skin'], BX_ESCAPE_STR_APOS),
             'bx_url_root' => bx_js_string(BX_DOL_URL_ROOT, BX_ESCAPE_STR_APOS),
             'bx_var_css_path' => bx_js_string($aCss['url'], BX_ESCAPE_STR_APOS),
@@ -179,7 +202,6 @@ class BxBaseEditorQuill extends BxDolEditor
                     });
                 } else {
                 	setTimeout(function () {
-                     console.log(999);
                     	$sInitEditor
                     }, 10); // wait while html is rendered in case of dynamic adding html with tinymce
                 } 
@@ -191,6 +213,7 @@ class BxBaseEditorQuill extends BxDolEditor
 
             $sScript = "
             <script>
+                var " . $sEditorName . ";
                 $(document).ready(function () {
                     $sInitEditor
                 });
@@ -231,7 +254,9 @@ class BxBaseEditorQuill extends BxDolEditor
             $sJsPrefix . 'highlight/' . $sJsSuffix . 'highlight.min.js',
             $sJsPrefix . 'quill/' . $sJsSuffix . 'quill.min.js', 
             $sJsPrefix . 'quill/' . $sJsSuffix . 'quill.mention.js',  
-            $sJsPrefix . 'quill/' . $sJsSuffix . 'quill.imageUploader.min.js'
+            $sJsPrefix . 'quill/' . $sJsSuffix . 'quill.imageUploader.min.js',
+            $sJsPrefix . 'quill/' . $sJsSuffix . 'quill.custom.js', 
+            $sJsPrefix . 'quill/' . $sJsSuffix . 'image-resize.min.js', 
         );
 
         $aCss = array(

Некоторые файлы не были показаны из-за большого количества измененных файлов