Skip to content

Commit

Permalink
Update image popover with new icons
Browse files Browse the repository at this point in the history
  • Loading branch information
lqez committed Dec 6, 2018
1 parent 93f8459 commit 94c2393
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 20 deletions.
1 change: 1 addition & 0 deletions lang/summernote-ko-KR.js
Expand Up @@ -19,6 +19,7 @@
resizeFull: '100% 크기로 변경',
resizeHalf: '50% 크기로 변경',
resizeQuarter: '25% 크기로 변경',
resizeNone: '원본 크기',
floatLeft: '왼쪽 정렬',
floatRight: '오른쪽 정렬',
floatNone: '정렬하지 않음',
Expand Down
12 changes: 12 additions & 0 deletions src/icons/float-left.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/icons/float-none.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/icons/float-right.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/icons/rollback.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 17 additions & 10 deletions src/js/base/module/Buttons.js
Expand Up @@ -617,56 +617,63 @@ export default class Buttons {
}

/**
* image : [
* ['imagesize', ['imageSize100', 'imageSize50', 'imageSize25']],
* ['float', ['floatLeft', 'floatRight', 'floatNone' ]],
* ['remove', ['removeMedia']]
* image: [
* ['imageResize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']],
* ['float', ['floatLeft', 'floatRight', 'floatNone']],
* ['remove', ['removeMedia']],
* ],
*/
addImagePopoverButtons() {
// Image Size Buttons
this.context.memo('button.imageSize100', () => {
this.context.memo('button.resizeFull', () => {
return this.button({
contents: '<span class="note-fontsize-10">100%</span>',
tooltip: this.lang.image.resizeFull,
click: this.context.createInvokeHandler('editor.resize', '1'),
}).render();
});
this.context.memo('button.imageSize50', () => {
this.context.memo('button.resizeHalf', () => {
return this.button({
contents: '<span class="note-fontsize-10">50%</span>',
tooltip: this.lang.image.resizeHalf,
click: this.context.createInvokeHandler('editor.resize', '0.5'),
}).render();
});
this.context.memo('button.imageSize25', () => {
this.context.memo('button.resizeQuarter', () => {
return this.button({
contents: '<span class="note-fontsize-10">25%</span>',
tooltip: this.lang.image.resizeQuarter,
click: this.context.createInvokeHandler('editor.resize', '0.25'),
}).render();
});
this.context.memo('button.resizeNone', () => {
return this.button({
contents: this.ui.icon(this.options.icons.rollback),
tooltip: this.lang.image.resizeNone,
click: this.context.createInvokeHandler('editor.resize', '0'),
}).render();
});

// Float Buttons
this.context.memo('button.floatLeft', () => {
return this.button({
contents: this.ui.icon(this.options.icons.alignLeft),
contents: this.ui.icon(this.options.icons.floatLeft),
tooltip: this.lang.image.floatLeft,
click: this.context.createInvokeHandler('editor.floatMe', 'left'),
}).render();
});

this.context.memo('button.floatRight', () => {
return this.button({
contents: this.ui.icon(this.options.icons.alignRight),
contents: this.ui.icon(this.options.icons.floatRight),
tooltip: this.lang.image.floatRight,
click: this.context.createInvokeHandler('editor.floatMe', 'right'),
}).render();
});

this.context.memo('button.floatNone', () => {
return this.button({
contents: this.ui.icon(this.options.icons.alignJustify),
contents: this.ui.icon(this.options.icons.rollback),
tooltip: this.lang.image.floatNone,
click: this.context.createInvokeHandler('editor.floatMe', 'none'),
}).render();
Expand Down
15 changes: 10 additions & 5 deletions src/js/base/module/Editor.js
Expand Up @@ -304,7 +304,7 @@ export default class Editor {
const $target = $(this.restoreTarget());
$target.toggleClass('note-float-left', value === 'left');
$target.toggleClass('note-float-right', value === 'right');
$target.css('float', value);
$target.css('float', (value === 'none' ? '' : value));
});

/**
Expand All @@ -313,10 +313,15 @@ export default class Editor {
*/
this.resize = this.wrapCommand((value) => {
const $target = $(this.restoreTarget());
$target.css({
width: value * 100 + '%',
height: '',
});
value = parseFloat(value);
if (value === 0) {
$target.css('width', '');
} else {
$target.css({
width: value * 100 + '%',
height: '',
});
}
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/js/base/settings.js
Expand Up @@ -80,7 +80,7 @@ $.summernote = $.extend($.summernote, {
popatmouse: true,
popover: {
image: [
['imagesize', ['imageSize100', 'imageSize50', 'imageSize25']],
['resize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']],
['float', ['floatLeft', 'floatRight', 'floatNone']],
['remove', ['removeMedia']],
],
Expand Down Expand Up @@ -288,6 +288,8 @@ $.summernote = $.extend($.summernote, {
'close': 'note-icon-close',
'code': 'note-icon-code',
'eraser': 'note-icon-eraser',
'floatLeft': 'note-icon-float-left',
'floatRight': 'note-icon-float-right',
'font': 'note-icon-font',
'frame': 'note-icon-frame',
'italic': 'note-icon-italic',
Expand All @@ -301,6 +303,7 @@ $.summernote = $.extend($.summernote, {
'picture': 'note-icon-picture',
'question': 'note-icon-question',
'redo': 'note-icon-redo',
'rollback': 'note-icon-rollback',
'square': 'note-icon-square',
'strikethrough': 'note-icon-strikethrough',
'subscript': 'note-icon-subscript',
Expand Down
9 changes: 5 additions & 4 deletions src/js/base/summernote-en-US.js
Expand Up @@ -21,12 +21,13 @@ $.extend($.summernote.lang, {
image: {
image: 'Picture',
insert: 'Insert Image',
resizeFull: 'Resize Full',
resizeHalf: 'Resize Half',
resizeQuarter: 'Resize Quarter',
resizeFull: 'Resize full',
resizeHalf: 'Resize half',
resizeQuarter: 'Resize quarter',
resizeNone: 'Original size',
floatLeft: 'Float Left',
floatRight: 'Float Right',
floatNone: 'Float None',
floatNone: 'Remove float',
shapeRounded: 'Shape: Rounded',
shapeCircle: 'Shape: Circle',
shapeThumbnail: 'Shape: Thumbnail',
Expand Down

0 comments on commit 94c2393

Please sign in to comment.