Для тех, кто спрашивал как применять JS код выше. Прописываем в условный init.php
Код |
---|
AddEventHandler("main", "OnBeforeProlog", function() { global $APPLICATION;
$APPLICATION->AddHeadString(<<<JS
<sc ript>
BX.addCustomEvent('OnEditorInitedBefore', function() {
var _this = this;
BX.addCustomEvent(this, 'OnGetParseRules', BX.proxy(function() {
_this.rules.tags.svg = {};
_this.rules.tags.g = {};
_this.rules.tags.path = {};
_this.rules.tags.use = {};
}, this));
});
</sc ript>
JS
, true);
});
|
В таком случае код будет применяться на всех страницах, включая страницы в админке.
P.S. Можно сделать по лучше, вынеся в более правильные обработчики
В условном init.php
Код |
---|
$eventManager->addEventHandler('fileman', 'OnBeforeHTMLEditorScriptRuns',
['Custom\EventHandlers', 'OnBeforeHTMLEditorScriptRunsHandler']); |
class
Код |
---|
<?php
namespace Custom;
class EventHandlers
{
public static function OnBeforeHTMLEditorScriptRunsHandler()
{
\CJSCore::RegisterExt('svg_editor', [
'js' => [
'/local/php_interface/editor.js',
],
]);
\CJSCore::Init(array('svg_editor'));
}
} |
editor.js
Код |
---|
BX.addCustomEvent('OnEditorInitedBefore', function(toolbar) { var _this = this;
// отучаю резать тэги
BX.addCustomEvent(this, 'OnGetParseRules', BX.proxy(function() {
_this.rules.tags.svg = {};
_this.rules.tags.g = {};
_this.rules.tags.path = {};
_this.rules.tags.use = {};
_this.rules.tags.symbol = {};
}, this));
}); |