Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #61 from ckeditor/t/37
Browse files Browse the repository at this point in the history
Other: Renamed "Image alternate text" to "Image text alternative" all across the code. Improved directory structure to have most important features in the top level of `src/`. Closes #37.

BREAKING CHANGES: The `src/imagealternatetext/imagealternatetext` module is now `src/imagetextalternative`. All other related classes and directories were renamed too.

BREAKING CHANGES: All the base image's util modules are now inside `src/image/`. The same applies to all other features. The main features are now directly in `src/`. Closes #33. Closes #26.
  • Loading branch information
Reinmar authored Feb 24, 2017
2 parents 6bb4069 + 8e8b36b commit e38675f
Show file tree
Hide file tree
Showing 39 changed files with 180 additions and 176 deletions.
4 changes: 2 additions & 2 deletions lang/contexts.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"image widget": "Label for the image widget.",
"Side image": "Label for the Side image option.",
"Full size image": "Label for the Full size image option.",
"Change alternate text": "Label for the Change alternate text button.",
"Alternate image text": "Label for the Alternate image text option."
"Change image text alternative": "Label for the Change image text alternative button.",
"Text alternative": "Label for the image text alternative input."
}
8 changes: 4 additions & 4 deletions src/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
*/

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ImageEngine from './imageengine';
import ImageEngine from './image/imageengine';
import Widget from './widget/widget';
import ImageAlternateText from './imagealternatetext/imagealternatetext';
import ImageTextAlternative from './imagetextalternative';

import '../theme/theme.scss';

/**
* The image plugin.
*
* Uses {@link module:image/imageengine~ImageEngine}.
* Uses {@link module:image/image/imageengine~ImageEngine}.
*
* @extends module:core/plugin~Plugin
*/
Expand All @@ -26,6 +26,6 @@ export default class Image extends Plugin {
* @inheritDoc
*/
static get requires() {
return [ ImageEngine, Widget, ImageAlternateText ];
return [ ImageEngine, Widget, ImageTextAlternative ];
}
}
2 changes: 1 addition & 1 deletion src/converters.js → src/image/converters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/**
* @module image/converters
* @module image/image/converters
*/

import ModelElement from '@ckeditor/ckeditor5-engine/src/model/element';
Expand Down
4 changes: 2 additions & 2 deletions src/imageengine.js → src/image/imageengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

/**
* @module image/imageengine
* @module image/image/imageengine
*/

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import buildModelConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildmodelconverter';
import WidgetEngine from './widget/widgetengine';
import WidgetEngine from '../widget/widgetengine';
import { viewToModelImage, modelToViewSelection, createImageAttributeConverter } from './converters';
import { toImageWidget } from './utils';
import ViewContainerElement from '@ckeditor/ckeditor5-engine/src/view/containerelement';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/**
* @module image/ui/imageballoonpanel
* @module image/image/ui/imageballoonpanel
*/

import throttle from '@ckeditor/ckeditor5-utils/src/lib/lodash/throttle';
Expand All @@ -19,22 +19,26 @@ const positions = {
// +-----------------+
// | Balloon |
// +-----------------+
south: ( targetRect, balloonRect ) => ( {
top: targetRect.bottom + arrowVOffset,
left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
name: 's'
} ),
south( targetRect, balloonRect ) {
return {
top: targetRect.bottom + arrowVOffset,
left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
name: 's'
};
},

// +-----------------+
// | Balloon |
// +-----------------+
// V
// [text range]
north: ( targetRect, balloonRect ) => ( {
top: targetRect.top - balloonRect.height - arrowVOffset,
left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
name: 'n'
} )
north( targetRect, balloonRect ) {
return {
top: targetRect.top - balloonRect.height - arrowVOffset,
left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
name: 'n'
};
}
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js → src/image/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/

/**
* @module image/utils
* @module image/image/utils
*/

import { widgetize, isWidget } from './widget/utils';
import { widgetize, isWidget } from '../widget/utils';
import ModelElement from '@ckeditor/ckeditor5-engine/src/model/element';

const imageSymbol = Symbol( 'isImage' );
Expand Down
26 changes: 0 additions & 26 deletions src/imagealternatetext/imagealternatetextengine.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/imagecaption/imagecaption.js → src/imagecaption.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

/**
* @module image/imagecaption/imagecaption
* @module image/imagecaption
*/

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ImageCaptionEngine from './imagecaptionengine';
import '../../theme/imagecaption/theme.scss';
import ImageCaptionEngine from './imagecaption/imagecaptionengine';
import '../theme/imagecaption/theme.scss';

/**
* The image caption plugin.
Expand Down
2 changes: 1 addition & 1 deletion src/imagecaption/imagecaptionengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import viewWriter from '@ckeditor/ckeditor5-engine/src/view/writer';
import ModelPosition from '@ckeditor/ckeditor5-engine/src/model/position';
import buildViewConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildviewconverter';
import ViewMatcher from '@ckeditor/ckeditor5-engine/src/view/matcher';
import { isImage, isImageWidget } from '../utils';
import { isImage, isImageWidget } from '../image/utils';
import { captionElementCreator, isCaption, getCaptionFromImage } from './utils';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/imagestyle/imagestyle.js → src/imagestyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/

/**
* @module image/imagestyle/imagestyle
* @module image/imagestyle
*/

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ImageStyleEngine from './imagestyleengine';
import ImageStyleEngine from './imagestyle/imagestyleengine';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/imagestyle/converters.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @module image/imagestyle/converters
*/

import { isImage } from '../utils';
import { isImage } from '../image/utils';

/**
* Returns converter for the `imageStyle` attribute. It can be used for adding, changing and removing the attribute.
Expand Down
2 changes: 1 addition & 1 deletion src/imagestyle/imagestylecommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import Command from '@ckeditor/ckeditor5-core/src/command/command';
import { isImage } from '../utils';
import { isImage } from '../image/utils';

/**
* The image style command. It is used to apply different image styles.
Expand Down
2 changes: 1 addition & 1 deletion src/imagestyle/imagestyleengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ImageStyleCommand from './imagestylecommand';
import ImageEngine from '../imageengine';
import ImageEngine from '../image/imageengine';
import { viewToModelStyleAttribute, modelToViewStyleAttribute } from './converters';
import fullSizeIcon from '@ckeditor/ckeditor5-core/theme/icons/object-center.svg';
import sideIcon from '@ckeditor/ckeditor5-core/theme/icons/object-right.svg';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
*/

/**
* @module image/imagealternatetext/imagealternatetext
* @module image/imagetextalternative
*/

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
import ImageAlternateTextEngine from './imagealternatetextengine';
import ImageTextAlternativeEngine from './imagetextalternative/imagetextalternativeengine';
import escPressHandler from '@ckeditor/ckeditor5-ui/src/bindings/escpresshandler';
import clickOutsideHandler from '@ckeditor/ckeditor5-ui/src/bindings/clickoutsidehandler';
import ImageToolbar from '../imagetoolbar';
import AlternateTextFormView from './ui/alternatetextformview';
import ImageBalloonPanel from '../ui/imageballoonpanelview';
import ImageToolbar from './imagetoolbar';
import TextAlternativeFormView from './imagetextalternative/ui/textalternativeformview';
import ImageBalloonPanel from './image/ui/imageballoonpanelview';

import alternateTextIcon from '@ckeditor/ckeditor5-core/theme/icons/input.svg';
import '../../theme/imagealternatetext/theme.scss';
import textAlternativeIcon from '@ckeditor/ckeditor5-core/theme/icons/input.svg';
import '../theme/imagetextalternative/theme.scss';

/**
* The image alternate text plugin.
* The image text alternative plugin.
*
* @extends module:core/plugin~Plugin
*/
export default class ImageAlternateText extends Plugin {
export default class ImageTextAlternative extends Plugin {
/**
* @inheritDoc
*/
static get requires() {
return [ ImageAlternateTextEngine ];
return [ ImageTextAlternativeEngine ];
}

/**
Expand All @@ -42,12 +42,12 @@ export default class ImageAlternateText extends Plugin {
const defaultImageToolbarConfig = this.editor.config.get( 'image.defaultToolbar' );

if ( defaultImageToolbarConfig ) {
defaultImageToolbarConfig.push( 'imageAlternateText' );
defaultImageToolbarConfig.push( 'imageTextAlternative' );
}

return this._createBalloonPanel().then( panel => {
/**
* Balloon panel containing alternate text change form.
* Balloon panel containing text alternative change form.
*
* @member {module:image/ui/imageballoonpanel~ImageBalloonPanelView} #baloonPanel
*/
Expand All @@ -56,29 +56,29 @@ export default class ImageAlternateText extends Plugin {
/**
* Form containing textarea and buttons, used to change `alt` text value.
*
* @member {module:image/imagealternatetext/ui/imagealternatetextformview~AlternateTextFormView} #form
* @member {module:image/imagetextalternative/ui/textalternativeformview~TextAlternativeFormView} #form
*/
this.form = panel.content.get( 0 );
} );
}

/**
* Creates button showing alternate text change balloon panel and registers it in
* Creates button showing text alternative change balloon panel and registers it in
* editor's {@link module:ui/componentfactory~ComponentFactory ComponentFactory}.
*
* @private
*/
_createButton() {
const editor = this.editor;
const command = editor.commands.get( 'imageAlternateText' );
const command = editor.commands.get( 'imageTextAlternative' );
const t = editor.t;

editor.ui.componentFactory.add( 'imageAlternateText', ( locale ) => {
editor.ui.componentFactory.add( 'imageTextAlternative', ( locale ) => {
const view = new ButtonView( locale );

view.set( {
label: t( 'Change alternate text' ),
icon: alternateTextIcon,
label: t( 'Change image text alternative' ),
icon: textAlternativeIcon,
tooltip: true
} );

Expand All @@ -94,20 +94,20 @@ export default class ImageAlternateText extends Plugin {
* Creates balloon panel.
*
* @private
* @return {Promise.<module:image/ui/imageballoonpanel~ImageBalloonPanelView>}
* @return {Promise.<module:image/image/ui/imageballoonpanel~ImageBalloonPanelView>}
*/
_createBalloonPanel() {
const editor = this.editor;

const panel = new ImageBalloonPanel( editor );
const form = new AlternateTextFormView( editor.locale );
const form = new TextAlternativeFormView( editor.locale );

this.listenTo( form, 'submit', () => {
editor.execute( 'imageAlternateText', { newValue: form.lebeledInput.inputView.element.value } );
editor.execute( 'imageTextAlternative', { newValue: form.lebeledInput.inputView.element.value } );
this._hideBalloonPanel();
} );

// If image toolbar is present - hide it when alternate text balloon is visible.
// If image toolbar is present - hide it when text alternative balloon is visible.
const imageToolbar = editor.plugins.get( ImageToolbar );

if ( imageToolbar ) {
Expand Down Expand Up @@ -152,7 +152,7 @@ export default class ImageAlternateText extends Plugin {
*/
_showBalloonPanel() {
const editor = this.editor;
const command = editor.commands.get( 'imageAlternateText' );
const command = editor.commands.get( 'imageTextAlternative' );
this.form.lebeledInput.value = command.value || '';
this.balloonPanel.attach();
this.form.lebeledInput.select();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
*/

/**
* @module image/imagelaternatetext/imagealternatetextcommand
* @module image/imagelaternatetext/imagetextalternativecommand
*/

import Command from '@ckeditor/ckeditor5-core/src/command/command';
import { isImage } from '../utils';
import { isImage } from '../image/utils';

/**
* The image alternate text command. It is used to change `alt` attribute on `image` elements.
* The image text alternative command. It is used to change `alt` attribute on `image` elements.
*
* @extends module:core/command/command~Command
*/
export default class ImageAlternateTextCommand extends Command {
export default class ImageTextAlternativeCommand extends Command {
/**
* @inheritDoc
*/
Expand Down
26 changes: 26 additions & 0 deletions src/imagetextalternative/imagetextalternativeengine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/

/**
* @module image/imagetextalternative/imagetextalternativeengine
*/

import ImageTextAlternativeCommand from './imagetextalternativecommand';
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';

/**
* The ImageTextAlternativeEngine plugin.
* Registers `imageTextAlternative` command.
*
* @extends module:core/plugin~Plugin
*/
export default class ImageTextAlternativeEngine extends Plugin {
/**
* @inheritDoc
*/
init() {
this.editor.commands.set( 'imageTextAlternative', new ImageTextAlternativeCommand( this.editor ) );
}
}
Loading

0 comments on commit e38675f

Please sign in to comment.