99 <div class=
"device #class#" data-bx-preview-device-class=
"#class#" data-bx-preview-device-width=
"#width#" data-bx-preview-device-height=
"#height#">
230 $this->
id = $params[
'id'];
231 $this->url = $params[
'url'];
232 $this->previewUrl = isset($params[
'previewUrl']) ? $params[
'previewUrl'] :
'/bitrix/admin/fileman_block_editor.php?action=preview';
233 $this->saveFileUrl = isset($params[
'saveFileUrl']) ? $params[
'saveFileUrl'] :
'/bitrix/admin/fileman_block_editor.php?action=save_file';
234 $this->templateType = $params[
'templateType'];
235 $this->templateId = $params[
'templateId'];
236 $this->site = $params[
'site'];
237 $this->charset = $params[
'charset'];
238 $this->isTemplateMode = isset($params[
'isTemplateMode']) ? (bool) $params[
'isTemplateMode'] :
false;
239 $this->useLightTextEditor = isset($params[
'useLightTextEditor']) ? (bool) $params[
'useLightTextEditor'] :
false;
240 $this->isUserHavePhpAccess = isset($params[
'isUserHavePhpAccess']) ? (bool) $params[
'isUserHavePhpAccess'] :
false;
241 $this->ownResultId = isset($params[
'own_result_id']) ? $params[
'own_result_id'] :
true;
243 $this->componentFilter = isset($params[
'componentFilter']) ? $params[
'componentFilter'] : array();
246 $this->previewModes = array(
247 array(
'CLASS' =>
'phone',
'NAME' =>
Loc::getMessage(
'BLOCK_EDITOR_PREVIEW_MODE_PHONE'),
'WIDTH' => 320,
'HEIGHT' => 480),
248 array(
'CLASS' =>
'tablet',
'NAME' =>
Loc::getMessage(
'BLOCK_EDITOR_PREVIEW_MODE_TABLET'),
'WIDTH' => 768,
'HEIGHT' => 1024),
249 array(
'CLASS' =>
'desktop',
'NAME' =>
Loc::getMessage(
'BLOCK_EDITOR_PREVIEW_MODE_DESKTOP'),
'WIDTH' => 1024,
'HEIGHT' => 768),
253 'edit' => array(
'NAME' =>
Loc::getMessage(
'BLOCK_EDITOR_TABS_EDIT'),
'ACTIVE' =>
true),
254 'preview' => array(
'NAME' =>
Loc::getMessage(
'BLOCK_EDITOR_TABS_PREVIEW'),
'ACTIVE' =>
false),
270 if(!is_array($this->blocks))
272 $this->blocks = array();
275 foreach($this->blocks as $key => $block)
277 if(!isset($block[
'TYPE']))
279 $block[
'TYPE'] = $block[
'CODE'];
282 $block[
'IS_COMPONENT'] =
false;
283 $block[
'CLASS'] = $block[
'CODE'];
284 $this->blocks[$key] = $block;
287 $componentsNotAsBlocks = array();
288 if (!$this->useLightTextEditor)
291 foreach($componentList as $component)
293 if(!isset($this->componentsAsBlocks[$component[
'NAME']]))
295 $componentsNotAsBlocks[] = array(
296 'TYPE' =>
'component',
297 'IS_COMPONENT' =>
true,
298 'CODE' => $component[
'NAME'],
299 'NAME' => $component[
'TITLE'],
300 'DESC' => $component[
'TITLE'] .
".\n" . $component[
'DESCRIPTION'],
306 $interfaceName = $this->componentsAsBlocks[$component[
'NAME']][
'NAME'];
307 $this->blocks[] = array(
308 'TYPE' =>
'component',
309 'IS_COMPONENT' =>
false,
310 'CODE' => $component[
'NAME'],
311 'NAME' => $interfaceName ? $interfaceName : $component[
'TITLE'],
312 'DESC' => $component[
'DESCRIPTION'],
318 $this->blocks = array_merge($this->blocks, $componentsNotAsBlocks);
376 $resultList = array();
378 $resultList[] = array(
382 'HTML' =>
'<textarea style="width:600px; height: 400px;" data-bx-editor-tool-input="item"></textarea>',
385 $resultList[] = array(
389 'HTML' =>
'<input type="hidden" data-bx-editor-tool-input="item" value="">'
390 . \
Bitrix\Main\UI\FileInput::createInstance((array(
391 "id" =>
"BX_BLOCK_EDITOR_SRC_" . $this->
id,
392 "name" =>
"NEW_FILE_EDITOR[n#IND#]",
395 "fileDialog" =>
true,
400 $resultList[] = array(
407 $resultList[] = array(
414 \Bitrix\Main\Loader::includeModule(
'fileman');
417 <div
class=
"column" data-bx-editor-column=
"item">
418 <?
for ($columnNumber = 1; $columnNumber < 5; $columnNumber++):?>
419 <span data-bx-editor-column-number=
"<?=$columnNumber?>"
420 style=
"display: none;">
428 echo
'<div style="color: #bfbfbf; font-size: 17px; padding: 0 0; position: relative;">';
430 $editor = new \CHTMLEditor;
434 'minBodyWidth' => 350,
435 'normalBodyWidth' => 555,
436 'bAllowPhp' =>
false,
437 'limitPhpAccess' =>
false,
438 'showTaskbars' =>
false,
439 'showNodeNavi' =>
false,
440 'askBeforeUnloadPage' =>
true,
441 'useFileDialogs' => !IsModuleInstalled(
'intranet'),
444 'autoResize' =>
false,
445 'autoResizeOffset' => 40,
446 'saveOnBlur' =>
true,
447 'controlsMap' => array(
448 array(
'id' =>
'placeholder_selector',
'compact' =>
true,
'sort' => 60),
449 array(
'id' =>
'StyleSelector',
'compact' =>
true,
'sort' => 70),
450 array(
'id' =>
'Bold',
'compact' =>
true,
'sort' => 80),
451 array(
'id' =>
'Italic',
'compact' =>
true,
'sort' => 90),
452 array(
'id' =>
'Underline',
'compact' =>
true,
'sort' => 100),
453 array(
'id' =>
'Strikeout',
'compact' =>
true,
'sort' => 110),
454 array(
'id' =>
'RemoveFormat',
'compact' =>
true,
'sort' => 120),
455 array(
'id' =>
'Color',
'compact' =>
true,
'sort' => 130),
456 array(
'id' =>
'FontSelector',
'compact' =>
false,
'sort' => 135),
457 array(
'id' =>
'FontSize',
'compact' =>
false,
'sort' => 140),
459 array(
'id' =>
'OrderedList',
'compact' =>
true,
'sort' => 150),
460 array(
'id' =>
'UnorderedList',
'compact' =>
true,
'sort' => 160),
461 array(
'id' =>
'AlignList',
'compact' =>
false,
'sort' => 190),
463 array(
'id' =>
'InsertLink',
'compact' =>
true,
'sort' => 210),
471 array(
'id' =>
'RemoveFormat',
'compact' =>
false,
'sort' => 310),
472 array(
'id' =>
'Fullscreen',
'compact' =>
false,
'sort' => 320),
473 array(
'id' =>
'BbCode',
'compact' =>
true,
'sort' => 340),
474 array(
'id' =>
'More',
'compact' =>
true,
'sort' => 400)
476 'isCopilotEnabled' =>
false,
479 'name' =>
'BX_BLOCK_EDITOR_CONTENT_' . $this->
id,
480 'id' =>
'BX_BLOCK_EDITOR_CONTENT_' . $this->
id,
482 'arSmilesSet' => array(),
483 'arSmiles' => array(),
485 'fontSize' =>
'14px',
487 '.bx-spoiler {border:1px solid #cecece;background-color:#f6f6f6;padding: 8px 8px 8px 24px;color:#373737;border-radius:var(--ui-border-radius-sm, 2px);min-height:1em;margin: 0;}',
496 \CFileMan::AddHTMLEditorFrame(
497 'BX_BLOCK_EDITOR_CONTENT_' . $this->
id,
514 'componentFilter' => $this->componentFilter,
516 'hideTypeSelector' =>
true,
517 'minBodyWidth' =>
'420',
518 'normalBodyWidth' =>
'420',
523 $resultList[] = array(
527 'HTML' =>
'<input type="hidden" data-bx-editor-tool-input="item" value="">' . ob_get_clean()
532 <script type=
"text/template" id=
"template-social-item">
533 <table style=
"background-color: #E9E9E9;">
535 <td><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_ADDRESS')?></td>
537 <input
class=
"href" type=
"text" value=
"#href#">
538 <select
class=
"preset">
539 <option value=
""><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_SELECT')?></option>
540 <option value=
"http://#SERVER_NAME#/"><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_OURSITE')?></option>
541 <?
if (self::isAvailableRussian()):?>
542 <option value=
"http://vk.com/"><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_VK')?></option>
543 <option value=
"http://ok.ru/"><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_OK')?></option>
545 <option value=
"http://facebook.com/"><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_FACEBOOK')?></option>
546 <option value=
"http://instagram.com/"><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_INSTAGRAM')?></option>
547 <option value=
"http://twitter.com/"><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_TWITTER')?></option>
548 <option value=
"http://"><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_SITE')?></option>
549 <option value=
"mailto:"><?=
Loc::getMessage(
'BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_EMAIL')?></option>
556 <input
class=
"name" type=
"text" value=
"#name#">
557 <input
class=
"delete" type=
"button" value=
"<?=Loc::getMessage('BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_BTN_DELETE')?>">
563 <div
class=
"container"></div>
564 <input
class=
"add" type=
"button" value=
"<?=Loc::getMessage('BLOCK_EDITOR_TOOL_SOCIAL_CONTENT_BTN_ADD')?>">
566 $resultList[] = array(
568 'ID' =>
'social_content',
570 'HTML' =>
'<input type="hidden" data-bx-editor-tool-input="item" value="">' . ob_get_clean()
573 $resultList[] = array(
575 'ID' =>
'button_caption',
580 $resultList[] = array(
587 $resultList[] = array(
589 'ID' =>
'text-align',
594 $resultList[] = array(
598 'HTML' =>
'<input type="hidden" data-bx-editor-tool-input="item" id="block_editor_style_border">
599 <select id="block_editor_style_border_style">
600 <option value="">' .
Loc::getMessage(
'BLOCK_EDITOR_COMMON_NO') .
'</option>
601 <option value="solid">' .
Loc::getMessage(
'BLOCK_EDITOR_TOOL_BORDER_SOLID') .
'</option>
602 <option value="dashed">' .
Loc::getMessage(
'BLOCK_EDITOR_TOOL_BORDER_DASHED') .
'</option>
603 <option value="dotted">' .
Loc::getMessage(
'BLOCK_EDITOR_TOOL_BORDER_DOTTED') .
'</option>
605 <select id="block_editor_style_border_width" style="width: 80px; min-width: 80px;">
606 <option value="">' .
Loc::getMessage(
'BLOCK_EDITOR_COMMON_NO') .
'</option>
607 <option value="1px">1px</option>
608 <option value="2px">2px</option>
609 <option value="3px">3px</option>
610 <option value="4px">4px</option>
611 <option value="5px">5px</option>
612 <option value="6px">6px</option>
613 <option value="7px">7px</option>
615 <input id="block_editor_style_border_color" type="hidden" class="bx-editor-color-picker">
616 <span class="bx-editor-color-picker-view"></span>
617 <span class="bx-editor-color-picker-text">' .
Loc::getMessage(
'BLOCK_EDITOR_TOOLS_COLOR') .
'</span>
621 $resultList[] = array(
623 'ID' =>
'background-color',
628 $resultList[] = array(
630 'ID' =>
'border-radius',
635 $resultList[] = array(
642 $resultList[] = array(
644 'ID' =>
'font-family',
649 $resultList[] = array(
656 $resultList[] = array(
658 'ID' =>
'text-decoration',
663 $resultList[] = array(
670 $resultList[] = array(
672 'ID' =>
'imagetextalign',
680 $resultList[] = array(
682 'ID' =>
'imagetextpart',
694 $resultList[] = array(
701 $resultList[] = array(
703 'ID' =>
'margin-top',
708 $resultList[] = array(
710 'ID' =>
'margin-bottom',
715 $resultList[] = array(
717 'ID' =>
'groupimage-view',
728 $resultList[] = array(
730 'ID' =>
'column-count',
735 $resultList[] = array(
748 $resultList[] = array(
761 $resultList[] = array(
763 'ID' =>
'bx-stylist-bgcolor',
768 $resultList[] = array(
770 'ID' =>
'bx-stylist-padding-top',
775 $resultList[] = array(
777 'ID' =>
'bx-stylist-padding-bottom',
782 $resultList[] = array(
784 'ID' =>
'bx-stylist-text-color',
789 $resultList[] = array(
791 'ID' =>
'bx-stylist-text-font-family',
796 $resultList[] = array(
798 'ID' =>
'bx-stylist-text-font-size',
803 $resultList[] = array(
805 'ID' =>
'bx-stylist-text-font-weight',
810 $resultList[] = array(
812 'ID' =>
'bx-stylist-text-line-height',
817 $resultList[] = array(
819 'ID' =>
'bx-stylist-text-text-align',
824 $resultList[] = array(
826 'ID' =>
'bx-stylist-a-color',
831 $resultList[] = array(
833 'ID' =>
'bx-stylist-a-font-weight',
838 $resultList[] = array(
840 'ID' =>
'bx-stylist-a-text-decoration',
845 for($i = 1; $i <= 4; $i++)
847 $resultList[] = array(
849 'ID' =>
'bx-stylist-h' . $i .
'-color',
854 $resultList[] = array(
856 'ID' =>
'bx-stylist-h' . $i .
'-font-size',
857 'NAME' =>
'H' . $i .
' ' .
Loc::getMessage(
'BLOCK_EDITOR_TOOL_FONT_SIZE'),
861 $resultList[] = array(
863 'ID' =>
'bx-stylist-h' . $i .
'-font-weight',
864 'NAME' =>
'H' . $i .
' ' .
Loc::getMessage(
'BLOCK_EDITOR_TOOL_FONT_WEIGHT'),
868 $resultList[] = array(
870 'ID' =>
'bx-stylist-h' . $i .
'-line-height',
871 'NAME' =>
'H' . $i .
' ' .
Loc::getMessage(
'BLOCK_EDITOR_TOOL_LINE_HEIGHT'),
875 $resultList[] = array(
877 'ID' =>
'bx-stylist-h' . $i .
'-text-align',
878 'NAME' =>
'H' . $i .
' ' .
Loc::getMessage(
'BLOCK_EDITOR_TOOL_TEXT_ALIGN'),
922 foreach(array_chunk($this->blocks, static::BLOCK_COUNT_PER_PAGE) as $blocksPerPage)
925 foreach($blocksPerPage as $block)
927 $blocksForPage .= $this->
getUI(
'block', array(
928 'type_class' => htmlspecialcharsbx($block[
'IS_COMPONENT'] ?
'component' :
'blockcomponent'),
929 'code_class' => htmlspecialcharsbx(str_replace(array(
':',
'.'), array(
'-',
'-'), $block[
'CODE'])),
930 'type' => htmlspecialcharsbx($block[
'TYPE']),
931 'code' => htmlspecialcharsbx($block[
'CODE']),
932 'name' => htmlspecialcharsbx($block[
'NAME']),
933 'desc' => htmlspecialcharsbx($block[
'DESC']),
937 $blocks .= $this->
getUI(
'block_page', array(
'blocks' => $blocksForPage));
940 foreach($this->tools as $tool)
943 'group' => htmlspecialcharsbx($tool[
'GROUP']),
944 'id' => htmlspecialcharsbx($tool[
'ID']),
945 'name' => htmlspecialcharsbx($tool[
'NAME']),
946 'html' => $tool[
'HTML'],
950 foreach($this->previewModes as $mode)
952 $devices .= $this->
getUI(
'device', array(
953 'MESS_NAME' => mb_strtoupper(htmlspecialcharsbx($mode[
'NAME'])),
954 'class' => htmlspecialcharsbx($mode[
'CLASS']),
955 'width' => htmlspecialcharsbx($mode[
'WIDTH']),
956 'height' => htmlspecialcharsbx($mode[
'HEIGHT']),
961 if(!$this->ownResultId)
963 $this->ownResultId =
'bx-block-editor-result-' . htmlspecialcharsbx($this->
id);
964 $textArea =
'<textarea name="' . htmlspecialcharsbx($this->
id) .
'" id="' . htmlspecialcharsbx($this->ownResultId)
965 .
'" style="width:800px;height:900px; display: none;"></textarea>';
968 foreach($this->tabs as $tabCode => $tab)
970 if(!isset($this->uiPatterns[
'panel-' . $tabCode]))
976 'code' => htmlspecialcharsbx($tabCode),
977 'name' => htmlspecialcharsbx($tab[
'NAME']),
978 'tab_active' => ($tab[
'ACTIVE'] ? $this->
getUI(
'tab_active', array()) :
'')
981 $panel = $this->
getUI(
'panel-' . $tabCode, array(
982 'id' => htmlspecialcharsbx($this->
id),
985 'devices' => $devices,
986 'nav-display' => count($this->blocks) <= static::BLOCK_COUNT_PER_PAGE ?
'bx-block-hide' :
'',
990 'MESS_TOOL_CONTENT' =>
Loc::getMessage(
'BLOCK_EDITOR_UI_TOOL_CONTENT'),
992 'MESS_TOOL_SETTINGS' =>
Loc::getMessage(
'BLOCK_EDITOR_UI_TOOL_SETTINGS'),
995 'MESS_TOOL_SAVE_TITLE' =>
Loc::getMessage(
'BLOCK_EDITOR_UI_TOOL_SAVE_TITLE'),
997 'MESS_TOOL_CANCEL_TITLE' =>
Loc::getMessage(
'BLOCK_EDITOR_UI_TOOL_CANCEL_TITLE'),
1000 $panels .= $this->
getUI(
'panel', array(
1001 'code' => htmlspecialcharsbx($tabCode),
1002 'panel_hidden' => (!$tab[
'ACTIVE'] ? $this->
getUI(
'panel_hidden', array()) :
''),
1007 return $this->
getUI(
'main', array(
1008 'TEXTAREA' => $textArea,
1009 'id' => htmlspecialcharsbx($this->
id),
1011 'panels' => $panels,
1014 'MESS_BTN_HTML_COPY' =>
Loc::getMessage(
'BLOCK_EDITOR_UI_BTN_HTML_COPY'),
1025 \CJSCore::RegisterExt(
'block_editor', array(
1027 '/bitrix/js/main/core/core_dragdrop.js',
1028 '/bitrix/js/fileman/block_editor/dialog.js',
1029 '/bitrix/js/fileman/block_editor/helper.js',
1030 '/bitrix/js/fileman/block_editor/editor.js',
1032 'css' =>
'/bitrix/js/fileman/block_editor/dialog.css',
1033 'rel' => [
'ui.design-tokens',
'ui.fonts.opensans'],
1034 'lang' =>
'/bitrix/modules/fileman/lang/' . LANGUAGE_ID .
'/js_block_editor.php',
1036 \CJSCore::Init(array(
"block_editor",
"color_picker",
"clipboard"));
1038 static $isBlockEditorManagerInited =
false;
1039 $editorBlockTypeListByCode = array();
1040 if(!$isBlockEditorManagerInited)
1042 foreach($this->blocks as $block)
1044 $editorBlockTypeListByCode[$block[
'CODE']] = $block;
1048 $jsCreateParams = array(
1050 'url' => $this->url,
1051 'previewUrl' => $this->previewUrl,
1052 'saveFileUrl' => $this->saveFileUrl,
1053 'templateType' => $this->templateType,
1054 'templateId' => $this->templateId,
1055 'isTemplateMode' => $this->isTemplateMode,
1056 'site' => $this->site,
1057 'charset' => $this->charset
1062 if(!$isBlockEditorManagerInited)
1064 $result .=
'BX.BlockEditorManager.setBlockList(' . \CUtil::PhpToJSObject($editorBlockTypeListByCode) .
");\n";
1067 $result .=
"var blockEditorParams = " . \CUtil::PhpToJSObject($jsCreateParams) .
";\n";
1068 $result .=
"blockEditorParams['context'] = BX('bx-block-editor-container-" . htmlspecialcharsbx($this->
id) .
"');\n";
1069 $result .=
"blockEditorParams['iframe'] = BX('bx-block-editor-iframe-" . htmlspecialcharsbx($this->
id) .
"');\n";
1070 $result .=
"blockEditorParams['resultNode'] = BX('" . htmlspecialcharsbx($this->ownResultId) .
"');\n";
1071 $result .=
"BX.BlockEditorManager.create(blockEditorParams);\n";
1073 $result =
"\n" .
'<script type="text/javascript">BX.ready(function(){' .
"\n" . $result .
'})</script>' .
"\n";
1077 $isBlockEditorManagerInited =
true;
1091 $phpList = \PHPParser::ParseFile($html);
1092 foreach($phpList as $php)
1094 $phpFormatted = htmlspecialcharsbx(str_replace([
"\r",
"\n"],
"", $php[2]));
1095 $id =
'bx_block_php_' . mt_rand();
1096 $surrogate =
'<span id="' .
$id .
'" ' . self::BLOCK_PHP_ATTR .
'="' . ($phpFormatted) .
'" class="bxhtmled-surrogate" title=""></span>';
1097 $html = str_replace($php[2], $surrogate, $html);
1106 $charsetPlaceholder =
'#CHARSET#';
1107 $html = static::replaceCharset($html, $charsetPlaceholder);
1108 $html = str_replace($charsetPlaceholder, HtmlFilter::encode(
$charset), $html);
1249 if(!is_array($list))
1254 if(isset($list[
'@']))
1259 if(isset($list[
'*']))
1261 $componentList = array();
1262 foreach($list[
'*'] as $componentName => $componentData)
1264 $componentData[
'TREE_PATH'] = array($path);
1265 $componentList[$componentName] = $componentData;
1267 return $componentList;
1270 if(isset($list[
'#']))
1272 foreach($list[
'#'] as $key => $item)
1274 $resultItem = static::getComponentListPlain($item);
1275 if(is_array($resultItem) && is_array($path))
1277 foreach($resultItem as $componentName => $componentData)
1279 if(!isset($componentData[
'TREE_PATH']))
1281 $componentData[
'TREE_PATH'] = array();
1283 $resultItem[$componentName][
'TREE_PATH'] = array_merge(array($path), $componentData[
'TREE_PATH']);
1287 $result = array_merge($result, $resultItem);