Skip to content

Commit

Permalink
feat: add defaultText into includeUI options (refs nhn#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
aligator committed May 11, 2020
1 parent e6a2188 commit 0ca5e84
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/js/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,11 @@ export default {
fontSize,
fontStyle,
fontWeight,
underline
underline,
defaultText
} = this.ui.text;
const fontFamily = 'Noto Sans';

this.addText('Double Click', {
this.addText(defaultText, {
position: pos.originPosition,
styles: {fill, fontSize, fontFamily, fontStyle, fontWeight, underline}
}).then(() => {
Expand Down
1 change: 1 addition & 0 deletions src/js/imageEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const {
* @param {string} options.includeUI.uiSize.width - width of ui
* @param {string} options.includeUI.uiSize.height - height of ui
* @param {string} [options.includeUI.menuBarPosition=bottom] - Menu bar position('top', 'bottom', 'left', 'right')
* @param {string} [options.includeUI.defaultText="Double Click"] - Text used when adding new texts in the ui
* @param {number} options.cssMaxWidth - Canvas css-max-width
* @param {number} options.cssMaxHeight - Canvas css-max-height
* @param {Object} [options.selectionStyle] - selection style
Expand Down
4 changes: 3 additions & 1 deletion src/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ class Ui {
width: '100%',
height: '100%'
},
menuBarPosition: 'bottom'
menuBarPosition: 'bottom',
defaultText: 'Double Click'
}, options);
}

Expand Down Expand Up @@ -226,6 +227,7 @@ class Ui {
this[menuName] = new SubComponentClass(this._subMenuElement, {
locale: this._locale,
makeSvgIcon: this.theme.makeMenSvgIconSet.bind(this.theme),
defaultText: this.options.defaultText,
menuBarPosition: this.options.menuBarPosition,
usageStatistics: this.options.usageStatistics
});
Expand Down
24 changes: 21 additions & 3 deletions src/js/ui/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {defaultTextRangeValus} from '../consts';
* @ignore
*/
export default class Text extends Submenu {
constructor(subMenuElement, {locale, makeSvgIcon, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, defaultText, makeSvgIcon, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'text',
Expand All @@ -35,7 +35,8 @@ export default class Text extends Submenu {
textRange: new Range({
slider: this.selector('.tie-text-range'),
input: this.selector('.tie-text-range-value')
}, defaultTextRangeValus)
}, defaultTextRangeValus),
defaultText
};
}

Expand Down Expand Up @@ -126,6 +127,22 @@ export default class Text extends Submenu {
this._els.textRange.value = value;
}

/**
* Get default text
* @returns {string} - text size
*/
get defaultText() {
return this._els.defaultText;
}

/**
* Set default text
* @param {Number} value - text size
*/
set defaultText(value) {
this._els.defaultText = value;
}

/**
* get font style
* @returns {string} - font style
Expand All @@ -151,10 +168,11 @@ export default class Text extends Submenu {
}

setTextStyleStateOnAction(textStyle = {}) {
const {fill, fontSize, fontStyle, fontWeight, textDecoration, textAlign} = textStyle;
const {fill, fontSize, fontStyle, fontWeight, textDecoration, textAlign, defaultText} = textStyle;

this.textColor = fill;
this.fontSize = fontSize;
this.defaultText = defaultText;
this.setEffactState('italic', fontStyle);
this.setEffactState('bold', fontWeight);
this.setEffactState('underline', textDecoration);
Expand Down

0 comments on commit 0ca5e84

Please sign in to comment.