Skip to content

Instantly share code, notes, and snippets.

ezrichtext:
alloy_editor:
extra_plugins: [random, smiley]
const ezParagraphConfig = new window.eZ.ezAlloyEditor.ezParagraphConfig({ customStyles: this.customStylesConfigurations });
const ezCustomStyleConfig = new window.eZ.ezAlloyEditor.ezCustomStyleConfig({ customStyles: this.customStylesConfigurations });
const pluginButtons = ['random'];
ezCustomStyleConfig.buttons = ezCustomStyleConfig.buttons.concat(pluginButtons);
ezParagraphConfig.buttons = ezParagraphConfig.buttons.concat(pluginButtons);
eZConfigManager.replace({
eZConfig,
entryName: 'ezplatform-admin-ui-alloyeditor-js',
itemToReplace: path.resolve(__dirname, '../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js'),
newItem: path.resolve(__dirname, '../public/js/base-rich-text.js'),
});
$ cp \
vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js \
src/ExtendedAdminUIBundle/Resources/public/js/base-rich-text.js
eZConfigManager.add({
eZConfig,
entryName: 'ezplatform-admin-ui-alloyeditor-js',
newItems: [
path.resolve(__dirname, '../public/js/alloyeditor/buttons/random.js'),
path.resolve(__dirname, '../public/js/alloyeditor/plugins/random.js'),
]
});
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import AlloyEditor from 'alloyeditor';
import EzButton from '../../../../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/public/js/alloyeditor/src/base/ez-button.js';
export default class BtnRandom extends EzButton {
static get key() {
return 'random';
}
$ yarn encore dev
const path = require('path');
module.exports = (eZConfig, eZConfigManager) => {
eZConfigManager.add({
eZConfig,
entryName: 'ezplatform-admin-ui-alloyeditor-js',
newItems: [
path.resolve(__dirname, '../public/js/alloyeditor/plugins/random.js'),
]
});
ezrichtext:
alloy_editor:
extra_plugins: [random]
(function(global) {
if (CKEDITOR.plugins.get('random')) {
return;
}
const InsertRandomNumber = {
exec: function(editor) {
const number = Math.floor(Math.random() * 1000) + 100;
editor.focus();
editor.insertText(' ' + number);