/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/web/hugerte/plugins/code/plugin.js
88 строк
2 KB
Raj Mohan R
AC-14602::Migrate from TinyMCE to Hugerte.org|Downgrade HugeRTE Version
21 май 2025, 15:04
21 май 2025, 15:04
9fba4c4
Код
Авторство
О чём код?
/** * HugeRTE version 1.0.4 (2024-10-28) * Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc. * Copyright (c) 2024 HugeRTE contributors * Licensed under the MIT license (https://github.com/hugerte/hugerte/blob/main/LICENSE.TXT) */ (function () { 'use strict'; var global = hugerte.util.Tools.resolve('hugerte.PluginManager'); const setContent = (editor, html) => { editor.focus(); editor.undoManager.transact(() => { editor.setContent(html); }); editor.selection.setCursorLocation(); editor.nodeChanged(); }; const getContent = editor => { return editor.getContent({ source_view: true }); }; const open = editor => { const editorContent = getContent(editor); editor.windowManager.open({ title: 'Source Code', size: 'large', body: { type: 'panel', items: [{ type: 'textarea', name: 'code' }] }, buttons: [ { type: 'cancel', name: 'cancel', text: 'Cancel' }, { type: 'submit', name: 'save', text: 'Save', primary: true } ], initialData: { code: editorContent }, onSubmit: api => { setContent(editor, api.getData().code); api.close(); } }); }; const register$1 = editor => { editor.addCommand('mceCodeEditor', () => { open(editor); }); }; const register = editor => { const onAction = () => editor.execCommand('mceCodeEditor'); editor.ui.registry.addButton('code', { icon: 'sourcecode', tooltip: 'Source code', onAction }); editor.ui.registry.addMenuItem('code', { icon: 'sourcecode', text: 'Source code', onAction }); }; var Plugin = () => { global.add('code', editor => { register$1(editor); register(editor); return {}; }); }; Plugin(); })();