Skip to content

Commit

Permalink
Fixes #906 | Implement feature sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Castelain committed Dec 7, 2018
1 parent 0951940 commit 1ab0230
Show file tree
Hide file tree
Showing 17 changed files with 362 additions and 18 deletions.
23 changes: 21 additions & 2 deletions src/ui/react/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1>Alloy Editor demo</h1>

<div class="ae-placeholder" contenteditable="true" data-placeholder="Write here the description" id="description"></div>

<div id="editable" contenteditable="true" data-placeholder="Write here the content">
<div id="editable1" contenteditable="true" data-placeholder="Write here the content">
<p><strong>Apollo 11</strong> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p>

<p>Armstrong spent about <s>three and a half</s> two and a half hours outside the spacecraft, Aldrin slightly less; and together they collected 47.5 pounds (21.5&nbsp;kg) of lunar material for return to Earth. A third member of the mission, <a href="http://en.wikipedia.org/wiki/Michael_Collins_(astronaut)">Michael Collins</a>, piloted the <a href="http://en.wikipedia.org/wiki/Apollo_Command/Service_Module">command</a> spacecraft alone in lunar orbit until Armstrong and Aldrin returned to it for the trip back to Earth.</p>
Expand Down Expand Up @@ -81,10 +81,29 @@ <h2>Technical details <a id="tech-details" name="tech-details"></a></h2>
<p style="text-align: right;"><small>Source: <a href="http://en.wikipedia.org/wiki/Apollo_11">Wikipedia.org</a></small></p>
</div>

<h3>Full toolbar demo</h3>

<div id="editable2" contenteditable="true" placeholder="Write some content here too">
<p>Bacon ipsum dolor amet salami cow beef chuck pastrami prosciutto. Ground round landjaeger pancetta, cupim capicola turkey pastrami jowl pork shank chuck flank kevin. Sausage pastrami doner short loin burgdoggen spare ribs. Drumstick picanha pastrami ham hock ground round porchetta. Meatball hamburger cow turducken, flank jowl biltong kielbasa t-bone. Chicken tongue doner, picanha salami pork belly filet mignon brisket strip steak landjaeger venison.</p>

<p>Porchetta <strong>tenderloin doner</strong>, swine landjaeger chicken pork chop. Fatback ground round pork chop, ham hock andouille drumstick hamburger kielbasa brisket burgdoggen ribeye frankfurter. Beef ribs ham ball tip bacon chuck doner. Short ribs leberkas chuck sirloin tongue beef, andouille boudin. Short loin burgdoggen spare ribs jowl meatball.</p>

<blockquote>Ground round chicken meatball ham hock.</blockquote>

<p>Corned beef jowl biltong alcatra, picanha hamburger kevin cow venison shank chicken. Boudin tenderloin doner, leberkas venison alcatra ribeye brisket tail flank beef ribs pork. Chicken tenderloin cupim, doner flank alcatra meatball sirloin bacon jowl kielbasa t-bone. Beef ribs tail flank, biltong pork belly sausage porchetta doner tri-tip. Salami ball tip ribeye kevin short ribs pork capicola. Flank drumstick prosciutto bresaola corned beef short ribs meatball boudin.</p>

<p>Tri-tip shankle bacon landjaeger, flank hamburger picanha sausage tenderloin tongue pork chop meatball short ribs chicken. Shankle cupim shank ball tip turkey boudin biltong tongue ham hock short ribs pig pork chop. Pork chop ground round shankle jerky pork beef ribs biltong kielbasa. Meatloaf tri-tip ball tip venison, shoulder landjaeger short loin hamburger spare ribs pig strip steak. Pancetta meatball jowl tri-tip, bresaola doner pig shank corned beef venison pastrami shoulder.</p>

<p>Pork jowl drumstick t-bone tail, turkey rump kielbasa kevin ham hock. Meatball picanha chuck pork chop bacon ham flank spare ribs tri-tip sirloin pork. Tongue biltong cow, ham sausage corned beef kevin tenderloin <strong>alcatra capicola shank picanha</strong>. Ribeye beef ribs burgdoggen, shoulder ham cow cupim turkey sausage strip steak tongue chuck pork chop chicken pastrami. Corned beef tongue porchetta, jowl bresaola pork meatball frankfurter sirloin prosciutto shoulder pig drumstick.</p>
</div>

<script>
var editor1 = AlloyEditor.editable('description');
var editor2 = AlloyEditor.editable('editable');
var editor2 = AlloyEditor.editable('editable1');
var editor3 = AlloyEditor.editable('headline');
var editor4 = AlloyEditor.editable('editable2', {
mode: 'full'
});
</script>

<div id="footer">
Expand Down
16 changes: 15 additions & 1 deletion src/ui/react/src/adapter/alloy-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,24 @@
validator: AlloyEditor.Lang.isString,
value: 'ae_uicore,ae_selectionregion,ae_selectionkeystrokes,ae_imagealignment,ae_addimages,ae_placeholder,' +
'ae_tabletools,ae_tableresize,ae_autolink,ae_embed,ae_autolist,ae_dragresize,' +
'ae_uibridge,ae_richcombobridge,ae_panelmenubuttonbridge,ae_menubridge,ae_menubuttonbridge,ae_buttonbridge',
'ae_uibridge,ae_richcombobridge,ae_panelmenubuttonbridge,ae_menubridge,ae_menubuttonbridge,ae_buttonbridge,font,colorbutton',
writeOnce: true
},

/**
* Specifies the "mode" for alloy editor
* @memberof Core
* @instance
* @property mode
* @default 'simple'
* @writeOnce
* @type {String}
*/
mode: {
validator: AlloyEditor.Lang.isString,
value: 'simple'
},

/**
* Retrieves the native CKEditor instance. Having this, the developer may use the full API of CKEditor.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
}
}

.ae-container-dropdown-xsmall {
width: $container-dropdown-xsmall-width-multiplier * $container-dropdown-base-width !important;
}

.ae-container-dropdown-small {
width: $container-dropdown-small-width-multiplier * $container-dropdown-base-width !important;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$container-dropdown-base-width: $base-width;
$container-dropdown-xsmall-width-multiplier: 1.5;
$container-dropdown-small-width-multiplier: 2;
$container-dropdown-medium-width-multiplier: 4;
$container-dropdown-width-multiplier: 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
}
}

.ae-container-column {
align-items: inherit;
flex-direction: column;
}

.ae-container-link-edit-browse {
display: inherit;
}
Expand All @@ -46,4 +51,12 @@
top: 0;
transform: translateY(0);
}
}

.ae-row {
display: flex;

&:not(:first-child) {
margin-top: 8px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $dropdown-toggle-min-width: $base-width;

$dropdown-padding: 4px;
$dropdown-top: $base-height + $base-padding;
$dropdown-zindex: 0;
$dropdown-zindex: 1;

/** DROPDOWN-LISTBOX **/
$dropdown-listbox-margin: 0;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.ae-separator {
height: 24px;
margin-right: 10px;
position: relative;

&::after {
border-right: 1px solid white;
content: '';
height: 12px;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
}
Empty file.
1 change: 1 addition & 0 deletions src/ui/react/src/assets/sass/skin/default/structure.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
@import "components/ae-button-bridge/structure";
@import "components/ae-dropdown/structure";
@import "components/ae-camera/structure";
@import "components/ae-separator/structure";
}
31 changes: 29 additions & 2 deletions src/ui/react/src/components/base/toolbar-buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@
* @class ToolbarButtons
*/
var ToolbarButtons = {
/**
* Analayses the current selection and returns the buttons or button groups to be rendered.
*
* @instance
* @method getToolbarButtonGroups
* @param {Array} buttons The buttons could be shown, prior to the state filtering.
* @param {Object} additionalProps Additional props that should be passed down to the buttons.
* @return {Array} An Array which contains the buttons or button groups that should be rendered.
*/
getToolbarButtonGroups: function(buttons, additionalProps) {
var instance = this;

if (AlloyEditor.Lang.isFunction(buttons)) {
buttons = buttons.call(this) || [];
}


return buttons.reduce(function(list, button) {
if (Array.isArray(button)) {
list.push(instance.getToolbarButtons(button, additionalProps));
return list;
} else {
return instance.getToolbarButtons(buttons, additionalProps);
}
}, []);
},

/**
* Analyzes the current selection and the buttons exclusive mode value to figure out which
* buttons should be present in a given state.
Expand Down Expand Up @@ -45,10 +72,10 @@
return button;
})
)
.map(function(button) {
.map(function(button, index) {
var props = this.mergeExclusiveProps({
editor: this.props.editor,
key: button.key,
key: button.key !== 'separator' ? button.key : `${button.key}-${index}`,
tabKey: button.key,
tabIndex: (this.props.trigger && this.props.trigger.props.tabKey === button.key) ? 0 : -1,
trigger: this.props.trigger
Expand Down
13 changes: 7 additions & 6 deletions src/ui/react/src/components/buttons/button-command-list-item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@
* @return {Object} The content which should be rendered.
*/
render: function() {
var iconClassName = `ae-icon-${this.props.icon}`;

return (
<button aria-label={this.props.description} className={this._getClassName()} onClick={this.execCommand} tabIndex={this.props.tabIndex}>{this.props.description}</button>
<button aria-label={this.props.description} className={this._getClassName()} onClick={this.execCommand} tabIndex={this.props.tabIndex}>
{this.props.icon && (<span className={iconClassName}></span>)}
{this.props.description}
</button>
);
},

Expand All @@ -68,11 +73,7 @@
* @return {String} The class name of the Widget.
*/
_getClassName: function() {
var className = 'ae-toolbar-element';

if (this.props.icon) {
className += ' ae-icon-' + this.props.icon;
}
var className = 'ae-container ae-toolbar-element';

return className;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
items = commands.map(function(item) {
return (
<li key={item.command} role="option">
<AlloyEditor.ButtonCommandListItem command={item.command} description={typeof item.label === 'string' ? item.label : item.label()} editor={editor} />
<AlloyEditor.ButtonCommandListItem command={item.command} description={typeof item.label === 'string' ? item.label : item.label()} icon={item.icon} editor={editor} />
</li>
);
});
Expand Down
162 changes: 162 additions & 0 deletions src/ui/react/src/components/buttons/button-paragraph-align.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
(function () {
'use strict';

/**
* The ButtonParagraphAlign class provides functionality to work with table rows.
*
* @class ButtonParagraphAlign
*/
var ButtonParagraphAlign = createReactClass({
// Allows validating props being passed to the component.
propTypes: {
/**
* List of the commands the button is able to handle.
*
* @instance
* @memberof ButtonParagraphAlign
* @property {Array} commands
*/
commands: PropTypes.arrayOf(PropTypes.object),

/**
* The editor instance where the component is being used.
*
* @instance
* @memberof ButtonParagraphAlign
* @property {Object} editor
*/
editor: PropTypes.object.isRequired,

/**
* Indicates whether the styles list is expanded or not.
*
* @instance
* @memberof ButtonParagraphAlign
* @property {Boolean} expanded
*/
expanded: PropTypes.bool,

/**
* The label that should be used for accessibility purposes.
*
* @instance
* @memberof ButtonParagraphAlign
* @property {String} label
*/
label: PropTypes.string,

/**
* The tabIndex of the button in its toolbar current state. A value other than -1
* means that the button has focus and is the active element.
*
* @instance
* @memberof ButtonParagraphAlign
* @property {Number} tabIndex
*/
tabIndex: PropTypes.number,

/**
* Callback provided by the button host to notify when the styles list has been expanded.
*
* @instance
* @memberof ButtonParagraphAlign
* @property {Function} toggleDropdown
*/
toggleDropdown: PropTypes.func
},

// Lifecycle. Provides static properties to the widget.
statics: {
/**
* The name which will be used as an alias of the button in the configuration.
*
* @default paragraphAlign
* @memberof ButtonParagraphAlign
* @property {String} key
* @static
*/
key: 'paragraphAlign'
},

/**
* Lifecycle. Renders the UI of the button.
*
* @instance
* @memberof ButtonParagraphAlign
* @method render
* @return {Object} The content which should be rendered.
*/
render: function() {
var activeAlignment = AlloyEditor.Strings.alignLeft;

var buttonCommandsList;
var buttonCommandsListId;

if (this.props.expanded) {
buttonCommandsListId = ButtonParagraphAlign.key + 'List';
buttonCommandsList = <AlloyEditor.ButtonCommandsList commands={this._getCommands()} editor={this.props.editor} listId={buttonCommandsListId} inlineIcons={false} onDismiss={this.props.toggleDropdown} />
}

var editor = this.props.editor.get('nativeEditor');

var activeCommand = this._getCommands().filter(
alignment => {
var command = editor.getCommand(alignment.command);

return command ? command.state === CKEDITOR.TRISTATE_ON : false;
}
).pop();

var iconClassName = `ae-icon-${activeCommand.icon}`;

return (
<div className="ae-container-dropdown ae-container-dropdown-xsmall ae-has-dropdown">
<button aria-expanded={this.props.expanded} aria-label={activeCommand.label} aria-owns={buttonCommandsListId} className="ae-toolbar-element" onClick={this.props.toggleDropdown} role="combobox" tabIndex={this.props.tabIndex} title={AlloyEditor.Strings.row}>
<div className="ae-container">
<span className={iconClassName}></span>
<span className="ae-icon-arrow"></span>
</div>
</button>
{buttonCommandsList}
</div>
);
},

/**
* Returns a list of commands. If a list of commands was passed
* as property `commands`, it will take a precedence over the default ones.
*
* @instance
* @memberof ButtonParagraphAlign
* @method _getCommands
* @protected
* @return {Array} The list of available commands.
*/
_getCommands: function () {
return this.props.commands || [
{
command: 'justifyleft',
icon: 'align-left',
label: AlloyEditor.Strings.alignLeft
},
{
command: 'justifycenter',
icon: 'align-center',
label: AlloyEditor.Strings.alignCenter
},
{
command: 'justifyright',
icon: 'align-right',
label: AlloyEditor.Strings.alignRight
},
{
command: 'justifyblock',
icon: 'align-justified',
label: AlloyEditor.Strings.alignJustify
}
];
}
});

AlloyEditor.Buttons[ButtonParagraphAlign.key] = AlloyEditor.ButtonParagraphAlign = ButtonParagraphAlign;
}());
Loading

0 comments on commit 1ab0230

Please sign in to comment.