Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
EZP-28030: Alloy editor add support for more builtin buttons (#905)
Browse files Browse the repository at this point in the history
* Add buttons to the text.js configuration

* Add numbered list to Rich Text

* Regnerate js files
  • Loading branch information
Plopix authored and andrerom committed Oct 10, 2017
1 parent f1117aa commit 47de3d3
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 5 deletions.
55 changes: 54 additions & 1 deletion Resources/public/js/alloyeditor/buttons/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ YUI.add('ez-alloyeditor-button-list', function (Y) {

var AlloyEditor = Y.eZ.AlloyEditor,
React = Y.eZ.React,
ButtonList;
ButtonList, ButtonListIndexed;

/**
* The ButtonList component represents a button to add an unordered list (ul).
Expand Down Expand Up @@ -66,5 +66,58 @@ YUI.add('ez-alloyeditor-button-list', function (Y) {
},
});

/**
* The ButtonListIndexed component represents a button to add an ordered list (ol).
*
* @uses AlloyEditor.ButtonCommand
* @uses AlloyEditor.ButtonStateClasses
*
* @class eZ.AlloyEditor.ButtonList
*/
ButtonListIndexed = React.createClass({displayName: "ButtonListIndexed",
mixins: [
AlloyEditor.ButtonCommand,
AlloyEditor.ButtonStateClasses,
],

statics: {
key: 'ezlistindexed'
},

getDefaultProps: function () {
return {
command: 'eZAddContent',
modifiesSelection: true,
};
},

/**
* Executes the eZAppendContent command to add an unordered list containing
* an empty list item.
*
* @method _addList
* @protected
*/
_addList: function () {
this.execCommand({
tagName: 'ol',
content: '<li></li>',
focusElement: 'li',
});
},

render: function () {
var css = "ae-button ez-ae-labeled-button" + this.getStateClasses();

return (
React.createElement("button", {className: css, onClick: this._addList, tabIndex: this.props.tabIndex},
React.createElement("span", {className: "ez-ae-icon ae-icon-numbered-list"}),
React.createElement("p", {className: "ez-ae-label"}, Y.eZ.trans('list', {}, 'onlineeditor'))
)
);
},
});

AlloyEditor.Buttons[ButtonList.key] = AlloyEditor.ButtonList = ButtonList;
AlloyEditor.Buttons[ButtonListIndexed.key] = AlloyEditor.ButtonListIndexed = ButtonListIndexed;
});
55 changes: 54 additions & 1 deletion Resources/public/js/alloyeditor/buttons/list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ YUI.add('ez-alloyeditor-button-list', function (Y) {

var AlloyEditor = Y.eZ.AlloyEditor,
React = Y.eZ.React,
ButtonList;
ButtonList, ButtonListIndexed;

/**
* The ButtonList component represents a button to add an unordered list (ul).
Expand Down Expand Up @@ -61,5 +61,58 @@ YUI.add('ez-alloyeditor-button-list', function (Y) {
},
});

/**
* The ButtonListIndexed component represents a button to add an ordered list (ol).
*
* @uses AlloyEditor.ButtonCommand
* @uses AlloyEditor.ButtonStateClasses
*
* @class eZ.AlloyEditor.ButtonList
*/
ButtonListIndexed = React.createClass({
mixins: [
AlloyEditor.ButtonCommand,
AlloyEditor.ButtonStateClasses,
],

statics: {
key: 'ezlistindexed'
},

getDefaultProps: function () {
return {
command: 'eZAddContent',
modifiesSelection: true,
};
},

/**
* Executes the eZAppendContent command to add an unordered list containing
* an empty list item.
*
* @method _addList
* @protected
*/
_addList: function () {
this.execCommand({
tagName: 'ol',
content: '<li></li>',
focusElement: 'li',
});
},

render: function () {
var css = "ae-button ez-ae-labeled-button" + this.getStateClasses();

return (
<button className={css} onClick={this._addList} tabIndex={this.props.tabIndex}>
<span className="ez-ae-icon ae-icon-numbered-list"></span>
<p className="ez-ae-label">{Y.eZ.trans('list', {}, 'onlineeditor')}</p>
</button>
);
},
});

AlloyEditor.Buttons[ButtonList.key] = AlloyEditor.ButtonList = ButtonList;
AlloyEditor.Buttons[ButtonListIndexed.key] = AlloyEditor.ButtonListIndexed = ButtonListIndexed;
});
3 changes: 1 addition & 2 deletions Resources/public/js/alloyeditor/toolbars/config/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ YUI.add('ez-alloyeditor-toolbar-config-text', function (Y) {
*/
Y.eZ.AlloyEditorToolbarConfig.Text = {
name: 'text',
buttons: ['bold', 'italic', 'underline', 'link'],
buttons: ['bold', 'italic', 'underline', 'subscript', 'superscript', 'quote', 'strike', 'link'],
test: AlloyEditor.SelectionTest.text
};
});

2 changes: 1 addition & 1 deletion Resources/public/js/views/fields/ez-richtext-editview.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ YUI.add('ez-richtext-editview', function (Y) {
tabIndex: 1
},
ezadd: {
buttons: ['ezheading', 'ezparagraph', 'ezlist', 'ezimage', 'ezembed', 'eztable'],
buttons: ['ezheading', 'ezparagraph', 'ezlist', 'ezlistindexed', 'ezimage', 'ezembed', 'eztable'],
tabIndex: 2,
},
};
Expand Down

0 comments on commit 47de3d3

Please # to comment.