');
this.$placeholder.on('click', function () {
_this2.context.invoke('focus');
}).html(this.options.placeholder).prependTo(this.$editingArea);
this.update();
}
}, {
key: "destroy",
value: function destroy() {
this.$placeholder.remove();
}
}, {
key: "update",
value: function update() {
var isShow = !this.context.invoke('codeview.isActivated') && this.context.invoke('editor.isEmpty');
this.$placeholder.toggle(isShow);
}
}]);
return Placeholder;
}();
// CONCATENATED MODULE: ./src/js/base/module/Buttons.js
function Buttons_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function Buttons_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function Buttons_createClass(Constructor, protoProps, staticProps) { if (protoProps) Buttons_defineProperties(Constructor.prototype, protoProps); if (staticProps) Buttons_defineProperties(Constructor, staticProps); return Constructor; }
var Buttons_Buttons = /*#__PURE__*/function () {
function Buttons(context) {
Buttons_classCallCheck(this, Buttons);
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
this.context = context;
this.$toolbar = context.layoutInfo.toolbar;
this.options = context.options;
this.lang = this.options.langInfo;
this.invertedKeyMap = func.invertObject(this.options.keyMap[env.isMac ? 'mac' : 'pc']);
}
Buttons_createClass(Buttons, [{
key: "representShortcut",
value: function representShortcut(editorMethod) {
var shortcut = this.invertedKeyMap[editorMethod];
if (!this.options.shortcuts || !shortcut) {
return '';
}
if (env.isMac) {
shortcut = shortcut.replace('CMD', '⌘').replace('SHIFT', '⇧');
}
shortcut = shortcut.replace('BACKSLASH', '\\').replace('SLASH', '/').replace('LEFTBRACKET', '[').replace('RIGHTBRACKET', ']');
return ' (' + shortcut + ')';
}
}, {
key: "button",
value: function button(o) {
if (!this.options.tooltip && o.tooltip) {
delete o.tooltip;
}
o.container = this.options.container;
return this.ui.button(o);
}
}, {
key: "initialize",
value: function initialize() {
this.addToolbarButtons();
this.addImagePopoverButtons();
this.addLinkPopoverButtons();
this.addTablePopoverButtons();
this.fontInstalledMap = {};
}
}, {
key: "destroy",
value: function destroy() {
delete this.fontInstalledMap;
}
}, {
key: "isFontInstalled",
value: function isFontInstalled(name) {
if (!Object.prototype.hasOwnProperty.call(this.fontInstalledMap, name)) {
this.fontInstalledMap[name] = env.isFontInstalled(name) || lists.contains(this.options.fontNamesIgnoreCheck, name);
}
return this.fontInstalledMap[name];
}
}, {
key: "isFontDeservedToAdd",
value: function isFontDeservedToAdd(name) {
name = name.toLowerCase();
return name !== '' && this.isFontInstalled(name) && env.genericFontFamilies.indexOf(name) === -1;
}
}, {
key: "colorPalette",
value: function colorPalette(className, tooltip, backColor, foreColor) {
var _this = this;
return this.ui.buttonGroup({
className: 'note-color ' + className,
children: [this.button({
className: 'note-current-color-button',
contents: this.ui.icon(this.options.icons.font + ' note-recent-color'),
tooltip: tooltip,
click: function click(e) {
var $button = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.currentTarget);
if (backColor && foreColor) {
_this.context.invoke('editor.color', {
backColor: $button.attr('data-backColor'),
foreColor: $button.attr('data-foreColor')
});
} else if (backColor) {
_this.context.invoke('editor.color', {
backColor: $button.attr('data-backColor')
});
} else if (foreColor) {
_this.context.invoke('editor.color', {
foreColor: $button.attr('data-foreColor')
});
}
},
callback: function callback($button) {
var $recentColor = $button.find('.note-recent-color');
if (backColor) {
$recentColor.css('background-color', _this.options.colorButton.backColor);
$button.attr('data-backColor', _this.options.colorButton.backColor);
}
if (foreColor) {
$recentColor.css('color', _this.options.colorButton.foreColor);
$button.attr('data-foreColor', _this.options.colorButton.foreColor);
} else {
$recentColor.css('color', 'transparent');
}
}
}), this.button({
className: 'dropdown-toggle',
contents: this.ui.dropdownButtonContents('', this.options),
tooltip: this.lang.color.more,
data: {
toggle: 'dropdown'
}
}), this.ui.dropdown({
items: (backColor ? ['
', '
' + this.lang.color.background + '
', '
', '', '
', '
', '
', '', '', '
', '
', '
'].join('') : '') + (foreColor ? ['
', '
' + this.lang.color.foreground + '
', '
', '', '
', '
', '
', '', '', '
', // Fix missing Div, Commented to find easily if it's wrong
'
', '
'].join('') : ''),
callback: function callback($dropdown) {
$dropdown.find('.note-holder').each(function (idx, item) {
var $holder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item);
$holder.append(_this.ui.palette({
colors: _this.options.colors,
colorsName: _this.options.colorsName,
eventName: $holder.data('event'),
container: _this.options.container,
tooltip: _this.options.tooltip
}).render());
});
/* TODO: do we have to record recent custom colors within cookies? */
var customColors = [['#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF']];
$dropdown.find('.note-holder-custom').each(function (idx, item) {
var $holder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item);
$holder.append(_this.ui.palette({
colors: customColors,
colorsName: customColors,
eventName: $holder.data('event'),
container: _this.options.container,
tooltip: _this.options.tooltip
}).render());
});
$dropdown.find('input[type=color]').each(function (idx, item) {
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item).change(function () {
var $chip = $dropdown.find('#' + external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this).data('event')).find('.note-color-btn').first();
var color = this.value.toUpperCase();
$chip.css('background-color', color).attr('aria-label', color).attr('data-value', color).attr('data-original-title', color);
$chip.click();
});
});
},
click: function click(event) {
event.stopPropagation();
var $parent = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('.' + className).find('.note-dropdown-menu');
var $button = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target);
var eventName = $button.data('event');
var value = $button.attr('data-value');
if (eventName === 'openPalette') {
var $picker = $parent.find('#' + value);
var $palette = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()($parent.find('#' + $picker.data('event')).find('.note-color-row')[0]); // Shift palette chips
var $chip = $palette.find('.note-color-btn').last().detach(); // Set chip attributes
var color = $picker.val();
$chip.css('background-color', color).attr('aria-label', color).attr('data-value', color).attr('data-original-title', color);
$palette.prepend($chip);
$picker.click();
} else {
if (lists.contains(['backColor', 'foreColor'], eventName)) {
var key = eventName === 'backColor' ? 'background-color' : 'color';
var $color = $button.closest('.note-color').find('.note-recent-color');
var $currentButton = $button.closest('.note-color').find('.note-current-color-button');
$color.css(key, value);
$currentButton.attr('data-' + eventName, value);
}
_this.context.invoke('editor.' + eventName, value);
}
}
})]
}).render();
}
}, {
key: "addToolbarButtons",
value: function addToolbarButtons() {
var _this2 = this;
this.context.memo('button.style', function () {
return _this2.ui.buttonGroup([_this2.button({
className: 'dropdown-toggle',
contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.magic), _this2.options),
tooltip: _this2.lang.style.style,
data: {
toggle: 'dropdown'
}
}), _this2.ui.dropdown({
className: 'dropdown-style',
items: _this2.options.styleTags,
title: _this2.lang.style.style,
template: function template(item) {
// TBD: need to be simplified
if (typeof item === 'string') {
item = {
tag: item,
title: Object.prototype.hasOwnProperty.call(_this2.lang.style, item) ? _this2.lang.style[item] : item
};
}
var tag = item.tag;
var title = item.title;
var style = item.style ? ' style="' + item.style + '" ' : '';
var className = item.className ? ' class="' + item.className + '"' : '';
return '<' + tag + style + className + '>' + title + '' + tag + '>';
},
click: _this2.context.createInvokeHandler('editor.formatBlock')
})]).render();
});
var _loop = function _loop(styleIdx, styleLen) {
var item = _this2.options.styleTags[styleIdx];
_this2.context.memo('button.style.' + item, function () {
return _this2.button({
className: 'note-btn-style-' + item,
contents: '
' + item.toUpperCase() + '
',
tooltip: _this2.lang.style[item],
click: _this2.context.createInvokeHandler('editor.formatBlock')
}).render();
});
};
for (var styleIdx = 0, styleLen = this.options.styleTags.length; styleIdx < styleLen; styleIdx++) {
_loop(styleIdx, styleLen);
}
this.context.memo('button.bold', function () {
return _this2.button({
className: 'note-btn-bold',
contents: _this2.ui.icon(_this2.options.icons.bold),
tooltip: _this2.lang.font.bold + _this2.representShortcut('bold'),
click: _this2.context.createInvokeHandlerAndUpdateState('editor.bold')
}).render();
});
this.context.memo('button.italic', function () {
return _this2.button({
className: 'note-btn-italic',
contents: _this2.ui.icon(_this2.options.icons.italic),
tooltip: _this2.lang.font.italic + _this2.representShortcut('italic'),
click: _this2.context.createInvokeHandlerAndUpdateState('editor.italic')
}).render();
});
this.context.memo('button.underline', function () {
return _this2.button({
className: 'note-btn-underline',
contents: _this2.ui.icon(_this2.options.icons.underline),
tooltip: _this2.lang.font.underline + _this2.representShortcut('underline'),
click: _this2.context.createInvokeHandlerAndUpdateState('editor.underline')
}).render();
});
this.context.memo('button.clear', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.eraser),
tooltip: _this2.lang.font.clear + _this2.representShortcut('removeFormat'),
click: _this2.context.createInvokeHandler('editor.removeFormat')
}).render();
});
this.context.memo('button.strikethrough', function () {
return _this2.button({
className: 'note-btn-strikethrough',
contents: _this2.ui.icon(_this2.options.icons.strikethrough),
tooltip: _this2.lang.font.strikethrough + _this2.representShortcut('strikethrough'),
click: _this2.context.createInvokeHandlerAndUpdateState('editor.strikethrough')
}).render();
});
this.context.memo('button.superscript', function () {
return _this2.button({
className: 'note-btn-superscript',
contents: _this2.ui.icon(_this2.options.icons.superscript),
tooltip: _this2.lang.font.superscript,
click: _this2.context.createInvokeHandlerAndUpdateState('editor.superscript')
}).render();
});
this.context.memo('button.subscript', function () {
return _this2.button({
className: 'note-btn-subscript',
contents: _this2.ui.icon(_this2.options.icons.subscript),
tooltip: _this2.lang.font.subscript,
click: _this2.context.createInvokeHandlerAndUpdateState('editor.subscript')
}).render();
});
this.context.memo('button.fontname', function () {
var styleInfo = _this2.context.invoke('editor.currentStyle');
if (_this2.options.addDefaultFonts) {
// Add 'default' fonts into the fontnames array if not exist
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(styleInfo['font-family'].split(','), function (idx, fontname) {
fontname = fontname.trim().replace(/['"]+/g, '');
if (_this2.isFontDeservedToAdd(fontname)) {
if (_this2.options.fontNames.indexOf(fontname) === -1) {
_this2.options.fontNames.push(fontname);
}
}
});
}
return _this2.ui.buttonGroup([_this2.button({
className: 'dropdown-toggle',
contents: _this2.ui.dropdownButtonContents('
', _this2.options),
tooltip: _this2.lang.font.name,
data: {
toggle: 'dropdown'
}
}), _this2.ui.dropdownCheck({
className: 'dropdown-fontname',
checkClassName: _this2.options.icons.menuCheck,
items: _this2.options.fontNames.filter(_this2.isFontInstalled.bind(_this2)),
title: _this2.lang.font.name,
template: function template(item) {
return '
' + item + '';
},
click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontName')
})]).render();
});
this.context.memo('button.fontsize', function () {
return _this2.ui.buttonGroup([_this2.button({
className: 'dropdown-toggle',
contents: _this2.ui.dropdownButtonContents('
', _this2.options),
tooltip: _this2.lang.font.size,
data: {
toggle: 'dropdown'
}
}), _this2.ui.dropdownCheck({
className: 'dropdown-fontsize',
checkClassName: _this2.options.icons.menuCheck,
items: _this2.options.fontSizes,
title: _this2.lang.font.size,
click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontSize')
})]).render();
});
this.context.memo('button.fontsizeunit', function () {
return _this2.ui.buttonGroup([_this2.button({
className: 'dropdown-toggle',
contents: _this2.ui.dropdownButtonContents('
', _this2.options),
tooltip: _this2.lang.font.sizeunit,
data: {
toggle: 'dropdown'
}
}), _this2.ui.dropdownCheck({
className: 'dropdown-fontsizeunit',
checkClassName: _this2.options.icons.menuCheck,
items: _this2.options.fontSizeUnits,
title: _this2.lang.font.sizeunit,
click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontSizeUnit')
})]).render();
});
this.context.memo('button.color', function () {
return _this2.colorPalette('note-color-all', _this2.lang.color.recent, true, true);
});
this.context.memo('button.forecolor', function () {
return _this2.colorPalette('note-color-fore', _this2.lang.color.foreground, false, true);
});
this.context.memo('button.backcolor', function () {
return _this2.colorPalette('note-color-back', _this2.lang.color.background, true, false);
});
this.context.memo('button.ul', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.unorderedlist),
tooltip: _this2.lang.lists.unordered + _this2.representShortcut('insertUnorderedList'),
click: _this2.context.createInvokeHandler('editor.insertUnorderedList')
}).render();
});
this.context.memo('button.ol', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.orderedlist),
tooltip: _this2.lang.lists.ordered + _this2.representShortcut('insertOrderedList'),
click: _this2.context.createInvokeHandler('editor.insertOrderedList')
}).render();
});
var justifyLeft = this.button({
contents: this.ui.icon(this.options.icons.alignLeft),
tooltip: this.lang.paragraph.left + this.representShortcut('justifyLeft'),
click: this.context.createInvokeHandler('editor.justifyLeft')
});
var justifyCenter = this.button({
contents: this.ui.icon(this.options.icons.alignCenter),
tooltip: this.lang.paragraph.center + this.representShortcut('justifyCenter'),
click: this.context.createInvokeHandler('editor.justifyCenter')
});
var justifyRight = this.button({
contents: this.ui.icon(this.options.icons.alignRight),
tooltip: this.lang.paragraph.right + this.representShortcut('justifyRight'),
click: this.context.createInvokeHandler('editor.justifyRight')
});
var justifyFull = this.button({
contents: this.ui.icon(this.options.icons.alignJustify),
tooltip: this.lang.paragraph.justify + this.representShortcut('justifyFull'),
click: this.context.createInvokeHandler('editor.justifyFull')
});
var outdent = this.button({
contents: this.ui.icon(this.options.icons.outdent),
tooltip: this.lang.paragraph.outdent + this.representShortcut('outdent'),
click: this.context.createInvokeHandler('editor.outdent')
});
var indent = this.button({
contents: this.ui.icon(this.options.icons.indent),
tooltip: this.lang.paragraph.indent + this.representShortcut('indent'),
click: this.context.createInvokeHandler('editor.indent')
});
this.context.memo('button.justifyLeft', func.invoke(justifyLeft, 'render'));
this.context.memo('button.justifyCenter', func.invoke(justifyCenter, 'render'));
this.context.memo('button.justifyRight', func.invoke(justifyRight, 'render'));
this.context.memo('button.justifyFull', func.invoke(justifyFull, 'render'));
this.context.memo('button.outdent', func.invoke(outdent, 'render'));
this.context.memo('button.indent', func.invoke(indent, 'render'));
this.context.memo('button.paragraph', function () {
return _this2.ui.buttonGroup([_this2.button({
className: 'dropdown-toggle',
contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.alignLeft), _this2.options),
tooltip: _this2.lang.paragraph.paragraph,
data: {
toggle: 'dropdown'
}
}), _this2.ui.dropdown([_this2.ui.buttonGroup({
className: 'note-align',
children: [justifyLeft, justifyCenter, justifyRight, justifyFull]
}), _this2.ui.buttonGroup({
className: 'note-list',
children: [outdent, indent]
})])]).render();
});
this.context.memo('button.height', function () {
return _this2.ui.buttonGroup([_this2.button({
className: 'dropdown-toggle',
contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.textHeight), _this2.options),
tooltip: _this2.lang.font.height,
data: {
toggle: 'dropdown'
}
}), _this2.ui.dropdownCheck({
items: _this2.options.lineHeights,
checkClassName: _this2.options.icons.menuCheck,
className: 'dropdown-line-height',
title: _this2.lang.font.height,
click: _this2.context.createInvokeHandler('editor.lineHeight')
})]).render();
});
this.context.memo('button.table', function () {
return _this2.ui.buttonGroup([_this2.button({
className: 'dropdown-toggle',
contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.table), _this2.options),
tooltip: _this2.lang.table.table,
data: {
toggle: 'dropdown'
}
}), _this2.ui.dropdown({
title: _this2.lang.table.table,
className: 'note-table',
items: ['
', '
1 x 1
'].join('')
})], {
callback: function callback($node) {
var $catcher = $node.find('.note-dimension-picker-mousecatcher');
$catcher.css({
width: _this2.options.insertTableMaxSize.col + 'em',
height: _this2.options.insertTableMaxSize.row + 'em'
}).mousedown(_this2.context.createInvokeHandler('editor.insertTable')).on('mousemove', _this2.tableMoveHandler.bind(_this2));
}
}).render();
});
this.context.memo('button.link', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.link),
tooltip: _this2.lang.link.link + _this2.representShortcut('linkDialog.show'),
click: _this2.context.createInvokeHandler('linkDialog.show')
}).render();
});
this.context.memo('button.picture', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.picture),
tooltip: _this2.lang.image.image,
click: _this2.context.createInvokeHandler('imageDialog.show')
}).render();
});
this.context.memo('button.video', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.video),
tooltip: _this2.lang.video.video,
click: _this2.context.createInvokeHandler('videoDialog.show')
}).render();
});
this.context.memo('button.hr', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.minus),
tooltip: _this2.lang.hr.insert + _this2.representShortcut('insertHorizontalRule'),
click: _this2.context.createInvokeHandler('editor.insertHorizontalRule')
}).render();
});
this.context.memo('button.fullscreen', function () {
return _this2.button({
className: 'btn-fullscreen note-codeview-keep',
contents: _this2.ui.icon(_this2.options.icons.arrowsAlt),
tooltip: _this2.lang.options.fullscreen,
click: _this2.context.createInvokeHandler('fullscreen.toggle')
}).render();
});
this.context.memo('button.codeview', function () {
return _this2.button({
className: 'btn-codeview note-codeview-keep',
contents: _this2.ui.icon(_this2.options.icons.code),
tooltip: _this2.lang.options.codeview,
click: _this2.context.createInvokeHandler('codeview.toggle')
}).render();
});
this.context.memo('button.redo', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.redo),
tooltip: _this2.lang.history.redo + _this2.representShortcut('redo'),
click: _this2.context.createInvokeHandler('editor.redo')
}).render();
});
this.context.memo('button.undo', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.undo),
tooltip: _this2.lang.history.undo + _this2.representShortcut('undo'),
click: _this2.context.createInvokeHandler('editor.undo')
}).render();
});
this.context.memo('button.help', function () {
return _this2.button({
contents: _this2.ui.icon(_this2.options.icons.question),
tooltip: _this2.lang.options.help,
click: _this2.context.createInvokeHandler('helpDialog.show')
}).render();
});
}
/**
* image: [
* ['imageResize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']],
* ['float', ['floatLeft', 'floatRight', 'floatNone']],
* ['remove', ['removeMedia']],
* ],
*/
}, {
key: "addImagePopoverButtons",
value: function addImagePopoverButtons() {
var _this3 = this;
// Image Size Buttons
this.context.memo('button.resizeFull', function () {
return _this3.button({
contents: '
100%',
tooltip: _this3.lang.image.resizeFull,
click: _this3.context.createInvokeHandler('editor.resize', '1')
}).render();
});
this.context.memo('button.resizeHalf', function () {
return _this3.button({
contents: '
50%',
tooltip: _this3.lang.image.resizeHalf,
click: _this3.context.createInvokeHandler('editor.resize', '0.5')
}).render();
});
this.context.memo('button.resizeQuarter', function () {
return _this3.button({
contents: '
25%',
tooltip: _this3.lang.image.resizeQuarter,
click: _this3.context.createInvokeHandler('editor.resize', '0.25')
}).render();
});
this.context.memo('button.resizeNone', function () {
return _this3.button({
contents: _this3.ui.icon(_this3.options.icons.rollback),
tooltip: _this3.lang.image.resizeNone,
click: _this3.context.createInvokeHandler('editor.resize', '0')
}).render();
}); // Float Buttons
this.context.memo('button.floatLeft', function () {
return _this3.button({
contents: _this3.ui.icon(_this3.options.icons.floatLeft),
tooltip: _this3.lang.image.floatLeft,
click: _this3.context.createInvokeHandler('editor.floatMe', 'left')
}).render();
});
this.context.memo('button.floatRight', function () {
return _this3.button({
contents: _this3.ui.icon(_this3.options.icons.floatRight),
tooltip: _this3.lang.image.floatRight,
click: _this3.context.createInvokeHandler('editor.floatMe', 'right')
}).render();
});
this.context.memo('button.floatNone', function () {
return _this3.button({
contents: _this3.ui.icon(_this3.options.icons.rollback),
tooltip: _this3.lang.image.floatNone,
click: _this3.context.createInvokeHandler('editor.floatMe', 'none')
}).render();
}); // Remove Buttons
this.context.memo('button.removeMedia', function () {
return _this3.button({
contents: _this3.ui.icon(_this3.options.icons.trash),
tooltip: _this3.lang.image.remove,
click: _this3.context.createInvokeHandler('editor.removeMedia')
}).render();
});
}
}, {
key: "addLinkPopoverButtons",
value: function addLinkPopoverButtons() {
var _this4 = this;
this.context.memo('button.linkDialogShow', function () {
return _this4.button({
contents: _this4.ui.icon(_this4.options.icons.link),
tooltip: _this4.lang.link.edit,
click: _this4.context.createInvokeHandler('linkDialog.show')
}).render();
});
this.context.memo('button.unlink', function () {
return _this4.button({
contents: _this4.ui.icon(_this4.options.icons.unlink),
tooltip: _this4.lang.link.unlink,
click: _this4.context.createInvokeHandler('editor.unlink')
}).render();
});
}
/**
* table : [
* ['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']],
* ['delete', ['deleteRow', 'deleteCol', 'deleteTable']]
* ],
*/
}, {
key: "addTablePopoverButtons",
value: function addTablePopoverButtons() {
var _this5 = this;
this.context.memo('button.addRowUp', function () {
return _this5.button({
className: 'btn-md',
contents: _this5.ui.icon(_this5.options.icons.rowAbove),
tooltip: _this5.lang.table.addRowAbove,
click: _this5.context.createInvokeHandler('editor.addRow', 'top')
}).render();
});
this.context.memo('button.addRowDown', function () {
return _this5.button({
className: 'btn-md',
contents: _this5.ui.icon(_this5.options.icons.rowBelow),
tooltip: _this5.lang.table.addRowBelow,
click: _this5.context.createInvokeHandler('editor.addRow', 'bottom')
}).render();
});
this.context.memo('button.addColLeft', function () {
return _this5.button({
className: 'btn-md',
contents: _this5.ui.icon(_this5.options.icons.colBefore),
tooltip: _this5.lang.table.addColLeft,
click: _this5.context.createInvokeHandler('editor.addCol', 'left')
}).render();
});
this.context.memo('button.addColRight', function () {
return _this5.button({
className: 'btn-md',
contents: _this5.ui.icon(_this5.options.icons.colAfter),
tooltip: _this5.lang.table.addColRight,
click: _this5.context.createInvokeHandler('editor.addCol', 'right')
}).render();
});
this.context.memo('button.deleteRow', function () {
return _this5.button({
className: 'btn-md',
contents: _this5.ui.icon(_this5.options.icons.rowRemove),
tooltip: _this5.lang.table.delRow,
click: _this5.context.createInvokeHandler('editor.deleteRow')
}).render();
});
this.context.memo('button.deleteCol', function () {
return _this5.button({
className: 'btn-md',
contents: _this5.ui.icon(_this5.options.icons.colRemove),
tooltip: _this5.lang.table.delCol,
click: _this5.context.createInvokeHandler('editor.deleteCol')
}).render();
});
this.context.memo('button.deleteTable', function () {
return _this5.button({
className: 'btn-md',
contents: _this5.ui.icon(_this5.options.icons.trash),
tooltip: _this5.lang.table.delTable,
click: _this5.context.createInvokeHandler('editor.deleteTable')
}).render();
});
}
}, {
key: "build",
value: function build($container, groups) {
for (var groupIdx = 0, groupLen = groups.length; groupIdx < groupLen; groupIdx++) {
var group = groups[groupIdx];
var groupName = Array.isArray(group) ? group[0] : group;
var buttons = Array.isArray(group) ? group.length === 1 ? [group[0]] : group[1] : [group];
var $group = this.ui.buttonGroup({
className: 'note-' + groupName
}).render();
for (var idx = 0, len = buttons.length; idx < len; idx++) {
var btn = this.context.memo('button.' + buttons[idx]);
if (btn) {
$group.append(typeof btn === 'function' ? btn(this.context) : btn);
}
}
$group.appendTo($container);
}
}
/**
* @param {jQuery} [$container]
*/
}, {
key: "updateCurrentStyle",
value: function updateCurrentStyle($container) {
var _this6 = this;
var $cont = $container || this.$toolbar;
var styleInfo = this.context.invoke('editor.currentStyle');
this.updateBtnStates($cont, {
'.note-btn-bold': function noteBtnBold() {
return styleInfo['font-bold'] === 'bold';
},
'.note-btn-italic': function noteBtnItalic() {
return styleInfo['font-italic'] === 'italic';
},
'.note-btn-underline': function noteBtnUnderline() {
return styleInfo['font-underline'] === 'underline';
},
'.note-btn-subscript': function noteBtnSubscript() {
return styleInfo['font-subscript'] === 'subscript';
},
'.note-btn-superscript': function noteBtnSuperscript() {
return styleInfo['font-superscript'] === 'superscript';
},
'.note-btn-strikethrough': function noteBtnStrikethrough() {
return styleInfo['font-strikethrough'] === 'strikethrough';
}
});
if (styleInfo['font-family']) {
var fontNames = styleInfo['font-family'].split(',').map(function (name) {
return name.replace(/[\'\"]/g, '').replace(/\s+$/, '').replace(/^\s+/, '');
});
var fontName = lists.find(fontNames, this.isFontInstalled.bind(this));
$cont.find('.dropdown-fontname a').each(function (idx, item) {
var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); // always compare string to avoid creating another func.
var isChecked = $item.data('value') + '' === fontName + '';
$item.toggleClass('checked', isChecked);
});
$cont.find('.note-current-fontname').text(fontName).css('font-family', fontName);
}
if (styleInfo['font-size']) {
var fontSize = styleInfo['font-size'];
$cont.find('.dropdown-fontsize a').each(function (idx, item) {
var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); // always compare with string to avoid creating another func.
var isChecked = $item.data('value') + '' === fontSize + '';
$item.toggleClass('checked', isChecked);
});
$cont.find('.note-current-fontsize').text(fontSize);
var fontSizeUnit = styleInfo['font-size-unit'];
$cont.find('.dropdown-fontsizeunit a').each(function (idx, item) {
var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item);
var isChecked = $item.data('value') + '' === fontSizeUnit + '';
$item.toggleClass('checked', isChecked);
});
$cont.find('.note-current-fontsizeunit').text(fontSizeUnit);
}
if (styleInfo['line-height']) {
var lineHeight = styleInfo['line-height'];
$cont.find('.dropdown-line-height li a').each(function (idx, item) {
// always compare with string to avoid creating another func.
var isChecked = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item).data('value') + '' === lineHeight + '';
_this6.className = isChecked ? 'checked' : '';
});
}
}
}, {
key: "updateBtnStates",
value: function updateBtnStates($container, infos) {
var _this7 = this;
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(infos, function (selector, pred) {
_this7.ui.toggleBtnActive($container.find(selector), pred());
});
}
}, {
key: "tableMoveHandler",
value: function tableMoveHandler(event) {
var PX_PER_EM = 18;
var $picker = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target.parentNode); // target is mousecatcher
var $dimensionDisplay = $picker.next();
var $catcher = $picker.find('.note-dimension-picker-mousecatcher');
var $highlighted = $picker.find('.note-dimension-picker-highlighted');
var $unhighlighted = $picker.find('.note-dimension-picker-unhighlighted');
var posOffset; // HTML5 with jQuery - e.offsetX is undefined in Firefox
if (event.offsetX === undefined) {
var posCatcher = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target).offset();
posOffset = {
x: event.pageX - posCatcher.left,
y: event.pageY - posCatcher.top
};
} else {
posOffset = {
x: event.offsetX,
y: event.offsetY
};
}
var dim = {
c: Math.ceil(posOffset.x / PX_PER_EM) || 1,
r: Math.ceil(posOffset.y / PX_PER_EM) || 1
};
$highlighted.css({
width: dim.c + 'em',
height: dim.r + 'em'
});
$catcher.data('value', dim.c + 'x' + dim.r);
if (dim.c > 3 && dim.c < this.options.insertTableMaxSize.col) {
$unhighlighted.css({
width: dim.c + 1 + 'em'
});
}
if (dim.r > 3 && dim.r < this.options.insertTableMaxSize.row) {
$unhighlighted.css({
height: dim.r + 1 + 'em'
});
}
$dimensionDisplay.html(dim.c + ' x ' + dim.r);
}
}]);
return Buttons;
}();
// CONCATENATED MODULE: ./src/js/base/module/Toolbar.js
function Toolbar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function Toolbar_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function Toolbar_createClass(Constructor, protoProps, staticProps) { if (protoProps) Toolbar_defineProperties(Constructor.prototype, protoProps); if (staticProps) Toolbar_defineProperties(Constructor, staticProps); return Constructor; }
var Toolbar_Toolbar = /*#__PURE__*/function () {
function Toolbar(context) {
Toolbar_classCallCheck(this, Toolbar);
this.context = context;
this.$window = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(window);
this.$document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document);
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
this.$note = context.layoutInfo.note;
this.$editor = context.layoutInfo.editor;
this.$toolbar = context.layoutInfo.toolbar;
this.$editable = context.layoutInfo.editable;
this.$statusbar = context.layoutInfo.statusbar;
this.options = context.options;
this.isFollowing = false;
this.followScroll = this.followScroll.bind(this);
}
Toolbar_createClass(Toolbar, [{
key: "shouldInitialize",
value: function shouldInitialize() {
return !this.options.airMode;
}
}, {
key: "initialize",
value: function initialize() {
var _this = this;
this.options.toolbar = this.options.toolbar || [];
if (!this.options.toolbar.length) {
this.$toolbar.hide();
} else {
this.context.invoke('buttons.build', this.$toolbar, this.options.toolbar);
}
if (this.options.toolbarContainer) {
this.$toolbar.appendTo(this.options.toolbarContainer);
}
this.changeContainer(false);
this.$note.on('summernote.keyup summernote.mouseup summernote.change', function () {
_this.context.invoke('buttons.updateCurrentStyle');
});
this.context.invoke('buttons.updateCurrentStyle');
if (this.options.followingToolbar) {
this.$window.on('scroll resize', this.followScroll);
}
}
}, {
key: "destroy",
value: function destroy() {
this.$toolbar.children().remove();
if (this.options.followingToolbar) {
this.$window.off('scroll resize', this.followScroll);
}
}
}, {
key: "followScroll",
value: function followScroll() {
if (this.$editor.hasClass('fullscreen')) {
return false;
}
var editorHeight = this.$editor.outerHeight();
var editorWidth = this.$editor.width();
var toolbarHeight = this.$toolbar.height();
var statusbarHeight = this.$statusbar.height(); // check if the web app is currently using another static bar
var otherBarHeight = 0;
if (this.options.otherStaticBar) {
otherBarHeight = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.otherStaticBar).outerHeight();
}
var currentOffset = this.$document.scrollTop();
var editorOffsetTop = this.$editor.offset().top;
var editorOffsetBottom = editorOffsetTop + editorHeight;
var activateOffset = editorOffsetTop - otherBarHeight;
var deactivateOffsetBottom = editorOffsetBottom - otherBarHeight - toolbarHeight - statusbarHeight;
if (!this.isFollowing && currentOffset > activateOffset && currentOffset < deactivateOffsetBottom - toolbarHeight) {
this.isFollowing = true;
this.$editable.css({
marginTop: this.$toolbar.outerHeight()
});
this.$toolbar.css({
position: 'fixed',
top: otherBarHeight,
width: editorWidth,
zIndex: 1000
});
} else if (this.isFollowing && (currentOffset < activateOffset || currentOffset > deactivateOffsetBottom)) {
this.isFollowing = false;
this.$toolbar.css({
position: 'relative',
top: 0,
width: '100%',
zIndex: 'auto'
});
this.$editable.css({
marginTop: ''
});
}
}
}, {
key: "changeContainer",
value: function changeContainer(isFullscreen) {
if (isFullscreen) {
this.$toolbar.prependTo(this.$editor);
} else {
if (this.options.toolbarContainer) {
this.$toolbar.appendTo(this.options.toolbarContainer);
}
}
if (this.options.followingToolbar) {
this.followScroll();
}
}
}, {
key: "updateFullscreen",
value: function updateFullscreen(isFullscreen) {
this.ui.toggleBtnActive(this.$toolbar.find('.btn-fullscreen'), isFullscreen);
this.changeContainer(isFullscreen);
}
}, {
key: "updateCodeview",
value: function updateCodeview(isCodeview) {
this.ui.toggleBtnActive(this.$toolbar.find('.btn-codeview'), isCodeview);
if (isCodeview) {
this.deactivate();
} else {
this.activate();
}
}
}, {
key: "activate",
value: function activate(isIncludeCodeview) {
var $btn = this.$toolbar.find('button');
if (!isIncludeCodeview) {
$btn = $btn.not('.note-codeview-keep');
}
this.ui.toggleBtn($btn, true);
}
}, {
key: "deactivate",
value: function deactivate(isIncludeCodeview) {
var $btn = this.$toolbar.find('button');
if (!isIncludeCodeview) {
$btn = $btn.not('.note-codeview-keep');
}
this.ui.toggleBtn($btn, false);
}
}]);
return Toolbar;
}();
// CONCATENATED MODULE: ./src/js/base/module/LinkDialog.js
function LinkDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function LinkDialog_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function LinkDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) LinkDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) LinkDialog_defineProperties(Constructor, staticProps); return Constructor; }
var LinkDialog_LinkDialog = /*#__PURE__*/function () {
function LinkDialog(context) {
LinkDialog_classCallCheck(this, LinkDialog);
this.context = context;
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body);
this.$editor = context.layoutInfo.editor;
this.options = context.options;
this.lang = this.options.langInfo;
context.memo('help.linkDialog.show', this.options.langInfo.help['linkDialog.show']);
}
LinkDialog_createClass(LinkDialog, [{
key: "initialize",
value: function initialize() {
var $container = this.options.dialogsInBody ? this.$body : this.options.container;
var body = ['
', ""), ""), '
', '
', ""), ""), '
', !this.options.disableLinkTarget ? external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('
').append(this.ui.checkbox({
className: 'sn-checkbox-open-in-new-window',
text: this.lang.link.openInNewWindow,
checked: true
}).render()).html() : '', external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('
').append(this.ui.checkbox({
className: 'sn-checkbox-use-protocol',
text: this.lang.link.useProtocol,
checked: true
}).render()).html()].join('');
var buttonClass = 'btn btn-primary note-btn note-btn-primary note-link-btn';
var footer = "
");
this.$dialog = this.ui.dialog({
className: 'link-dialog',
title: this.lang.link.insert,
fade: this.options.dialogsFade,
body: body,
footer: footer
}).render().appendTo($container);
}
}, {
key: "destroy",
value: function destroy() {
this.ui.hideDialog(this.$dialog);
this.$dialog.remove();
}
}, {
key: "bindEnterKey",
value: function bindEnterKey($input, $btn) {
$input.on('keypress', function (event) {
if (event.keyCode === core_key.code.ENTER) {
event.preventDefault();
$btn.trigger('click');
}
});
}
/**
* toggle update button
*/
}, {
key: "toggleLinkBtn",
value: function toggleLinkBtn($linkBtn, $linkText, $linkUrl) {
this.ui.toggleBtn($linkBtn, $linkText.val() && $linkUrl.val());
}
/**
* Show link dialog and set event handlers on dialog controls.
*
* @param {Object} linkInfo
* @return {Promise}
*/
}, {
key: "showLinkDialog",
value: function showLinkDialog(linkInfo) {
var _this = this;
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) {
var $linkText = _this.$dialog.find('.note-link-text');
var $linkUrl = _this.$dialog.find('.note-link-url');
var $linkBtn = _this.$dialog.find('.note-link-btn');
var $openInNewWindow = _this.$dialog.find('.sn-checkbox-open-in-new-window input[type=checkbox]');
var $useProtocol = _this.$dialog.find('.sn-checkbox-use-protocol input[type=checkbox]');
_this.ui.onDialogShown(_this.$dialog, function () {
_this.context.triggerEvent('dialog.shown'); // If no url was given and given text is valid URL then copy that into URL Field
if (!linkInfo.url && func.isValidUrl(linkInfo.text)) {
linkInfo.url = linkInfo.text;
}
$linkText.on('input paste propertychange', function () {
// If linktext was modified by input events,
// cloning text from linkUrl will be stopped.
linkInfo.text = $linkText.val();
_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);
}).val(linkInfo.text);
$linkUrl.on('input paste propertychange', function () {
// Display same text on `Text to display` as default
// when linktext has no text
if (!linkInfo.text) {
$linkText.val($linkUrl.val());
}
_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);
}).val(linkInfo.url);
if (!env.isSupportTouch) {
$linkUrl.trigger('focus');
}
_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);
_this.bindEnterKey($linkUrl, $linkBtn);
_this.bindEnterKey($linkText, $linkBtn);
var isNewWindowChecked = linkInfo.isNewWindow !== undefined ? linkInfo.isNewWindow : _this.context.options.linkTargetBlank;
$openInNewWindow.prop('checked', isNewWindowChecked);
var useProtocolChecked = linkInfo.url ? false : _this.context.options.useProtocol;
$useProtocol.prop('checked', useProtocolChecked);
$linkBtn.one('click', function (event) {
event.preventDefault();
deferred.resolve({
range: linkInfo.range,
url: $linkUrl.val(),
text: $linkText.val(),
isNewWindow: $openInNewWindow.is(':checked'),
checkProtocol: $useProtocol.is(':checked')
});
_this.ui.hideDialog(_this.$dialog);
});
});
_this.ui.onDialogHidden(_this.$dialog, function () {
// detach events
$linkText.off();
$linkUrl.off();
$linkBtn.off();
if (deferred.state() === 'pending') {
deferred.reject();
}
});
_this.ui.showDialog(_this.$dialog);
}).promise();
}
/**
* @param {Object} layoutInfo
*/
}, {
key: "show",
value: function show() {
var _this2 = this;
var linkInfo = this.context.invoke('editor.getLinkInfo');
this.context.invoke('editor.saveRange');
this.showLinkDialog(linkInfo).then(function (linkInfo) {
_this2.context.invoke('editor.restoreRange');
_this2.context.invoke('editor.createLink', linkInfo);
}).fail(function () {
_this2.context.invoke('editor.restoreRange');
});
}
}]);
return LinkDialog;
}();
// CONCATENATED MODULE: ./src/js/base/module/LinkPopover.js
function LinkPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function LinkPopover_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function LinkPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) LinkPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) LinkPopover_defineProperties(Constructor, staticProps); return Constructor; }
var LinkPopover_LinkPopover = /*#__PURE__*/function () {
function LinkPopover(context) {
var _this = this;
LinkPopover_classCallCheck(this, LinkPopover);
this.context = context;
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
this.options = context.options;
this.events = {
'summernote.keyup summernote.mouseup summernote.change summernote.scroll': function summernoteKeyupSummernoteMouseupSummernoteChangeSummernoteScroll() {
_this.update();
},
'summernote.disable summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteDialogShownSummernoteBlur() {
_this.hide();
}
};
}
LinkPopover_createClass(LinkPopover, [{
key: "shouldInitialize",
value: function shouldInitialize() {
return !lists.isEmpty(this.options.popover.link);
}
}, {
key: "initialize",
value: function initialize() {
this.$popover = this.ui.popover({
className: 'note-link-popover',
callback: function callback($node) {
var $content = $node.find('.popover-content,.note-popover-content');
$content.prepend('
');
}
}).render().appendTo(this.options.container);
var $content = this.$popover.find('.popover-content,.note-popover-content');
this.context.invoke('buttons.build', $content, this.options.popover.link);
this.$popover.on('mousedown', function (e) {
e.preventDefault();
});
}
}, {
key: "destroy",
value: function destroy() {
this.$popover.remove();
}
}, {
key: "update",
value: function update() {
// Prevent focusing on editable when invoke('code') is executed
if (!this.context.invoke('editor.hasFocus')) {
this.hide();
return;
}
var rng = this.context.invoke('editor.getLastRange');
if (rng.isCollapsed() && rng.isOnAnchor()) {
var anchor = dom.ancestor(rng.sc, dom.isAnchor);
var href = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).attr('href');
this.$popover.find('a').attr('href', href).text(href);
var pos = dom.posFromPlaceholder(anchor);
var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset();
pos.top -= containerOffset.top;
pos.left -= containerOffset.left;
this.$popover.css({
display: 'block',
left: pos.left,
top: pos.top
});
} else {
this.hide();
}
}
}, {
key: "hide",
value: function hide() {
this.$popover.hide();
}
}]);
return LinkPopover;
}();
// CONCATENATED MODULE: ./src/js/base/module/ImageDialog.js
function ImageDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function ImageDialog_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function ImageDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) ImageDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) ImageDialog_defineProperties(Constructor, staticProps); return Constructor; }
var ImageDialog_ImageDialog = /*#__PURE__*/function () {
function ImageDialog(context) {
ImageDialog_classCallCheck(this, ImageDialog);
this.context = context;
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body);
this.$editor = context.layoutInfo.editor;
this.options = context.options;
this.lang = this.options.langInfo;
}
ImageDialog_createClass(ImageDialog, [{
key: "initialize",
value: function initialize() {
var imageLimitation = '';
if (this.options.maximumImageFileSize) {
var unit = Math.floor(Math.log(this.options.maximumImageFileSize) / Math.log(1024));
var readableSize = (this.options.maximumImageFileSize / Math.pow(1024, unit)).toFixed(2) * 1 + ' ' + ' KMGTP'[unit] + 'B';
imageLimitation = "
".concat(this.lang.image.maximumFileSize + ' : ' + readableSize, "");
}
var $container = this.options.dialogsInBody ? this.$body : this.options.container;
var body = ['
', '', '', imageLimitation, '
', '
', '', '', '
'].join('');
var buttonClass = 'btn btn-primary note-btn note-btn-primary note-image-btn';
var footer = "
");
this.$dialog = this.ui.dialog({
title: this.lang.image.insert,
fade: this.options.dialogsFade,
body: body,
footer: footer
}).render().appendTo($container);
}
}, {
key: "destroy",
value: function destroy() {
this.ui.hideDialog(this.$dialog);
this.$dialog.remove();
}
}, {
key: "bindEnterKey",
value: function bindEnterKey($input, $btn) {
$input.on('keypress', function (event) {
if (event.keyCode === core_key.code.ENTER) {
event.preventDefault();
$btn.trigger('click');
}
});
}
}, {
key: "show",
value: function show() {
var _this = this;
this.context.invoke('editor.saveRange');
this.showImageDialog().then(function (data) {
// [workaround] hide dialog before restore range for IE range focus
_this.ui.hideDialog(_this.$dialog);
_this.context.invoke('editor.restoreRange');
if (typeof data === 'string') {
// image url
// If onImageLinkInsert set,
if (_this.options.callbacks.onImageLinkInsert) {
_this.context.triggerEvent('image.link.insert', data);
} else {
_this.context.invoke('editor.insertImage', data);
}
} else {
// array of files
_this.context.invoke('editor.insertImagesOrCallback', data);
}
}).fail(function () {
_this.context.invoke('editor.restoreRange');
});
}
/**
* show image dialog
*
* @param {jQuery} $dialog
* @return {Promise}
*/
}, {
key: "showImageDialog",
value: function showImageDialog() {
var _this2 = this;
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) {
var $imageInput = _this2.$dialog.find('.note-image-input');
var $imageUrl = _this2.$dialog.find('.note-image-url');
var $imageBtn = _this2.$dialog.find('.note-image-btn');
_this2.ui.onDialogShown(_this2.$dialog, function () {
_this2.context.triggerEvent('dialog.shown'); // Cloning imageInput to clear element.
$imageInput.replaceWith($imageInput.clone().on('change', function (event) {
deferred.resolve(event.target.files || event.target.value);
}).val(''));
$imageUrl.on('input paste propertychange', function () {
_this2.ui.toggleBtn($imageBtn, $imageUrl.val());
}).val('');
if (!env.isSupportTouch) {
$imageUrl.trigger('focus');
}
$imageBtn.click(function (event) {
event.preventDefault();
deferred.resolve($imageUrl.val());
});
_this2.bindEnterKey($imageUrl, $imageBtn);
});
_this2.ui.onDialogHidden(_this2.$dialog, function () {
$imageInput.off();
$imageUrl.off();
$imageBtn.off();
if (deferred.state() === 'pending') {
deferred.reject();
}
});
_this2.ui.showDialog(_this2.$dialog);
});
}
}]);
return ImageDialog;
}();
// CONCATENATED MODULE: ./src/js/base/module/ImagePopover.js
function ImagePopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function ImagePopover_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function ImagePopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) ImagePopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) ImagePopover_defineProperties(Constructor, staticProps); return Constructor; }
/**
* Image popover module
* mouse events that show/hide popover will be handled by Handle.js.
* Handle.js will receive the events and invoke 'imagePopover.update'.
*/
var ImagePopover_ImagePopover = /*#__PURE__*/function () {
function ImagePopover(context) {
var _this = this;
ImagePopover_classCallCheck(this, ImagePopover);
this.context = context;
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
this.editable = context.layoutInfo.editable[0];
this.options = context.options;
this.events = {
'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() {
_this.hide();
}
};
}
ImagePopover_createClass(ImagePopover, [{
key: "shouldInitialize",
value: function shouldInitialize() {
return !lists.isEmpty(this.options.popover.image);
}
}, {
key: "initialize",
value: function initialize() {
this.$popover = this.ui.popover({
className: 'note-image-popover'
}).render().appendTo(this.options.container);
var $content = this.$popover.find('.popover-content,.note-popover-content');
this.context.invoke('buttons.build', $content, this.options.popover.image);
this.$popover.on('mousedown', function (e) {
e.preventDefault();
});
}
}, {
key: "destroy",
value: function destroy() {
this.$popover.remove();
}
}, {
key: "update",
value: function update(target, event) {
if (dom.isImg(target)) {
var position = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(target).offset();
var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset();
var pos = {};
if (this.options.popatmouse) {
pos.left = event.pageX - 20;
pos.top = event.pageY;
} else {
pos = position;
}
pos.top -= containerOffset.top;
pos.left -= containerOffset.left;
this.$popover.css({
display: 'block',
left: pos.left,
top: pos.top
});
} else {
this.hide();
}
}
}, {
key: "hide",
value: function hide() {
this.$popover.hide();
}
}]);
return ImagePopover;
}();
// CONCATENATED MODULE: ./src/js/base/module/TablePopover.js
function TablePopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function TablePopover_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function TablePopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) TablePopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) TablePopover_defineProperties(Constructor, staticProps); return Constructor; }
var TablePopover_TablePopover = /*#__PURE__*/function () {
function TablePopover(context) {
var _this = this;
TablePopover_classCallCheck(this, TablePopover);
this.context = context;
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
this.options = context.options;
this.events = {
'summernote.mousedown': function summernoteMousedown(we, e) {
_this.update(e.target);
},
'summernote.keyup summernote.scroll summernote.change': function summernoteKeyupSummernoteScrollSummernoteChange() {
_this.update();
},
'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() {
_this.hide();
}
};
}
TablePopover_createClass(TablePopover, [{
key: "shouldInitialize",
value: function shouldInitialize() {
return !lists.isEmpty(this.options.popover.table);
}
}, {
key: "initialize",
value: function initialize() {
this.$popover = this.ui.popover({
className: 'note-table-popover'
}).render().appendTo(this.options.container);
var $content = this.$popover.find('.popover-content,.note-popover-content');
this.context.invoke('buttons.build', $content, this.options.popover.table); // [workaround] Disable Firefox's default table editor
if (env.isFF) {
document.execCommand('enableInlineTableEditing', false, false);
}
this.$popover.on('mousedown', function (e) {
e.preventDefault();
});
}
}, {
key: "destroy",
value: function destroy() {
this.$popover.remove();
}
}, {
key: "update",
value: function update(target) {
if (this.context.isDisabled()) {
return false;
}
var isCell = dom.isCell(target);
if (isCell) {
var pos = dom.posFromPlaceholder(target);
var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset();
pos.top -= containerOffset.top;
pos.left -= containerOffset.left;
this.$popover.css({
display: 'block',
left: pos.left,
top: pos.top
});
} else {
this.hide();
}
return isCell;
}
}, {
key: "hide",
value: function hide() {
this.$popover.hide();
}
}]);
return TablePopover;
}();
// CONCATENATED MODULE: ./src/js/base/module/VideoDialog.js
function VideoDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function VideoDialog_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function VideoDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) VideoDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) VideoDialog_defineProperties(Constructor, staticProps); return Constructor; }
var VideoDialog_VideoDialog = /*#__PURE__*/function () {
function VideoDialog(context) {
VideoDialog_classCallCheck(this, VideoDialog);
this.context = context;
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body);
this.$editor = context.layoutInfo.editor;
this.options = context.options;
this.lang = this.options.langInfo;
}
VideoDialog_createClass(VideoDialog, [{
key: "initialize",
value: function initialize() {
var $container = this.options.dialogsInBody ? this.$body : this.options.container;
var body = ['
', ""), ""), '
'].join('');
var buttonClass = 'btn btn-primary note-btn note-btn-primary note-video-btn';
var footer = "
");
this.$dialog = this.ui.dialog({
title: this.lang.video.insert,
fade: this.options.dialogsFade,
body: body,
footer: footer
}).render().appendTo($container);
}
}, {
key: "destroy",
value: function destroy() {
this.ui.hideDialog(this.$dialog);
this.$dialog.remove();
}
}, {
key: "bindEnterKey",
value: function bindEnterKey($input, $btn) {
$input.on('keypress', function (event) {
if (event.keyCode === core_key.code.ENTER) {
event.preventDefault();
$btn.trigger('click');
}
});
}
}, {
key: "createVideoNode",
value: function createVideoNode(url) {
// video url patterns(youtube, instagram, vimeo, dailymotion, youku, mp4, ogg, webm)
var ytRegExp = /\/\/(?:(?:www|m)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w|-]{11})(?:(?:[\?&]t=)(\S+))?$/;
var ytRegExpForStart = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/;
var ytMatch = url.match(ytRegExp);
var igRegExp = /(?:www\.|\/\/)instagram\.com\/p\/(.[a-zA-Z0-9_-]*)/;
var igMatch = url.match(igRegExp);
var vRegExp = /\/\/vine\.co\/v\/([a-zA-Z0-9]+)/;
var vMatch = url.match(vRegExp);
var vimRegExp = /\/\/(player\.)?vimeo\.com\/([a-z]*\/)*(\d+)[?]?.*/;
var vimMatch = url.match(vimRegExp);
var dmRegExp = /.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/;
var dmMatch = url.match(dmRegExp);
var youkuRegExp = /\/\/v\.youku\.com\/v_show\/id_(\w+)=*\.html/;
var youkuMatch = url.match(youkuRegExp);
var qqRegExp = /\/\/v\.qq\.com.*?vid=(.+)/;
var qqMatch = url.match(qqRegExp);
var qqRegExp2 = /\/\/v\.qq\.com\/x?\/?(page|cover).*?\/([^\/]+)\.html\??.*/;
var qqMatch2 = url.match(qqRegExp2);
var mp4RegExp = /^.+.(mp4|m4v)$/;
var mp4Match = url.match(mp4RegExp);
var oggRegExp = /^.+.(ogg|ogv)$/;
var oggMatch = url.match(oggRegExp);
var webmRegExp = /^.+.(webm)$/;
var webmMatch = url.match(webmRegExp);
var fbRegExp = /(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/;
var fbMatch = url.match(fbRegExp);
var $video;
if (ytMatch && ytMatch[1].length === 11) {
var youtubeId = ytMatch[1];
var start = 0;
if (typeof ytMatch[2] !== 'undefined') {
var ytMatchForStart = ytMatch[2].match(ytRegExpForStart);
if (ytMatchForStart) {
for (var n = [3600, 60, 1], i = 0, r = n.length; i < r; i++) {
start += typeof ytMatchForStart[i + 1] !== 'undefined' ? n[i] * parseInt(ytMatchForStart[i + 1], 10) : 0;
}
}
}
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('