Просмотр исходного кода

#4059 Quill: Duplated field in a form.

roman.lesnikov@gmail.com 4 лет назад
Родитель
Сommit
4d6f120417

+ 1 - 1
inc/js/editor.quill.js

@@ -160,7 +160,7 @@ function bx_editor_init(oEditor, oParams){
                 let node = super.create(value);
                 if (value.source && value.inlinecode){
                     node.setAttribute('source', value.source);
-                    node.innerHTML = value.inlinecode;
+                    node.innerHTML = value.inlinecode + " ";
                     return node;
                 }
                 return node;

+ 2 - 2
modules/boonex/timeline/classes/BxTimelineFormPost.php

@@ -145,7 +145,7 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
         return parent::update($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
     }
 
-    public function addHtmlEditor($iViewMode, &$aInput)
+    public function addHtmlEditor($iViewMode, &$aInput, $sUniq)
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
 
@@ -162,7 +162,7 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
         if(!$this->_oModule->_oConfig->isEditorToolbar())
         	$oEditor->setCustomToolbarButtons('');
 
-        $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode, ['form_id' => $this->aFormAttrs['id'], 'element_name' => $aInput['name'], 'query_params' => $this->getHtmlEditorQueryParams($aInput)]);
+        $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name=' . $aInput['name'] . ']', $iViewMode, $this->_bDynamicMode, ['form_id' => $this->aFormAttrs['id'], 'element_name' => $aInput['name'], 'query_params' => $this->getHtmlEditorQueryParams($aInput), 'uniq' => $sUniq]);
 
         return true;
     }

+ 5 - 3
template/scripts/BxBaseEditorQuill.php

@@ -95,7 +95,7 @@ class BxBaseEditorQuill extends BxDolEditor
             $sToolbarItems = $this->_sButtonsCustom;
         }
         
-        $sEditorName = 'quill_' . str_replace(['-', ' '], '_', $aAttrs['form_id'] . '_' . $aAttrs['element_name']);
+        $sEditorName = 'quill_' . str_replace(['-', ' '], '_', $aAttrs['form_id'] . '_' . $aAttrs['element_name'] . '_' . $aAttrs['uniq']);
         $this->_oTemplate->addJsTranslation([
             '_sys_txt_quill_tooltip_bold',
             '_sys_txt_quill_tooltip_italic',
@@ -123,7 +123,7 @@ class BxBaseEditorQuill extends BxDolEditor
         // initialize editor
         $sInitEditor = $this->_replaceMarkers(self::$CONF_COMMON, array(
             'bx_var_custom_init' => $sCustomInit,
-            'bx_var_selector' => bx_js_string($sSelector, BX_ESCAPE_STR_APOS),
+            'bx_var_selector' => bx_js_string($sSelector. '.' . $aAttrs['uniq'], BX_ESCAPE_STR_APOS),
             'bx_var_query_params' => isset($aAttrs['query_params']) ? json_encode($aAttrs['query_params']) : "''",
             'bx_var_form_id' => $aAttrs['form_id'],
             'toolbar' => $sToolbarItems ? '[' . $sToolbarItems . ']' : 'false',
@@ -145,7 +145,9 @@ class BxBaseEditorQuill extends BxDolEditor
         if ($bDynamicMode) {
             list($aJs, $aCss) = $this->_getJsCss(true);
 
-            $sScript = "var " . $sEditorName . "; " . $this->_oTemplate->addJsPreloaded($aJs, $sInitCallBack, "typeof bQuillEditorInited === 'undefined'", $sInitEditor);
+            $sScript = "var " . $sEditorName . ";"; 
+            $sScript .= $this->_oTemplate->addJsPreloaded($aJs, $sInitCallBack, "typeof bQuillEditorInited === 'undefined'", $sInitEditor.';console.log(6);');
+           
             $sScript = $this->_oTemplate->_wrapInTagJsCode($sScript);
             $sScript = $this->_oTemplate->addCss($aCss, true) . $sScript;
 

+ 7 - 4
template/scripts/BxBaseFormView.php

@@ -1326,9 +1326,12 @@ BLAH;
     {
         $aAttrs = $this->_genInputTextareaAttrs($aInput);
 
+        $sUniq = genRndPwd(10, false);
+        
         $sClassAdd = "bx-def-font-inputs bx-form-input-{$aInput['type']}";
-        if(isset($aInput['html']) && $aInput['html'] && $this->addHtmlEditor($aInput['html'], $aInput))
-              $sClassAdd .= ' bx-form-input-html';
+        if(isset($aInput['html']) && $aInput['html'] && $this->addHtmlEditor($aInput['html'], $aInput, $sUniq)){
+            $sClassAdd .= ' bx-form-input-html ' . $sUniq;
+        }
 
         $sValue = isset($aInput['value']) ? bx_process_output((isset($aInput['html']) && $aInput['html']) || (isset($aInput['code']) && $aInput['code']) ? $aInput['value'] : strip_tags($aInput['value']), BX_DATA_TEXT, array('no_process_macros')) : '';
 
@@ -1356,13 +1359,13 @@ BLAH;
 		return BxDolEditor::getObjectInstance(false, $this->oTemplate) !== false;
     }
 
-    function addHtmlEditor($iViewMode, &$aInput)
+    function addHtmlEditor($iViewMode, &$aInput, $sUniq)
     {
         $oEditor = BxDolEditor::getObjectInstance(false, $this->oTemplate);
         if (!$oEditor)
             return false;
 
-        $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode, ['form_id' => $this->aFormAttrs['id'], 'element_name' => $aInput['name'], 'query_params' => $this->getHtmlEditorQueryParams($aInput)]);
+        $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name=' . $aInput['name'] . ']', $iViewMode, $this->_bDynamicMode, ['form_id' => $this->aFormAttrs['id'], 'element_name' => $aInput['name'], 'query_params' => $this->getHtmlEditorQueryParams($aInput), 'uniq' => $sUniq]);
 
         return true;
     }