| 1 |
/*! |
| 2 |
* |
| 3 |
* Super simple wysiwyg editor v0.8.18 |
| 4 |
* https://summernote.org |
| 5 |
* |
| 6 |
* |
| 7 |
* Copyright 2013- Alan Hong. and other contributors |
| 8 |
* summernote may be freely distributed under the MIT license. |
| 9 |
* |
| 10 |
* Date: 2020-05-20T18:09Z |
| 11 |
* |
| 12 |
*/ |
| 13 |
(function webpackUniversalModuleDefinition(root, factory) { |
| 14 |
if(typeof exports === 'object' && typeof module === 'object') |
| 15 |
module.exports = factory(require("jquery")); |
| 16 |
else if(typeof define === 'function' && define.amd) |
| 17 |
define(["jquery"], factory); |
| 18 |
else { |
| 19 |
var a = typeof exports === 'object' ? factory(require("jquery")) : factory(root["jQuery"]); |
| 20 |
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; |
| 21 |
} |
| 22 |
})(window, function(__WEBPACK_EXTERNAL_MODULE__0__) { |
| 23 |
return /******/ (function(modules) { // webpackBootstrap |
| 24 |
/******/ // The module cache |
| 25 |
/******/ var installedModules = {}; |
| 26 |
/******/ |
| 27 |
/******/ // The require function |
| 28 |
/******/ function __webpack_require__(moduleId) { |
| 29 |
/******/ |
| 30 |
/******/ // Check if module is in cache |
| 31 |
/******/ if(installedModules[moduleId]) { |
| 32 |
/******/ return installedModules[moduleId].exports; |
| 33 |
/******/ } |
| 34 |
/******/ // Create a new module (and put it into the cache) |
| 35 |
/******/ var module = installedModules[moduleId] = { |
| 36 |
/******/ i: moduleId, |
| 37 |
/******/ l: false, |
| 38 |
/******/ exports: {} |
| 39 |
/******/ }; |
| 40 |
/******/ |
| 41 |
/******/ // Execute the module function |
| 42 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
| 43 |
/******/ |
| 44 |
/******/ // Flag the module as loaded |
| 45 |
/******/ module.l = true; |
| 46 |
/******/ |
| 47 |
/******/ // Return the exports of the module |
| 48 |
/******/ return module.exports; |
| 49 |
/******/ } |
| 50 |
/******/ |
| 51 |
/******/ |
| 52 |
/******/ // expose the modules object (__webpack_modules__) |
| 53 |
/******/ __webpack_require__.m = modules; |
| 54 |
/******/ |
| 55 |
/******/ // expose the module cache |
| 56 |
/******/ __webpack_require__.c = installedModules; |
| 57 |
/******/ |
| 58 |
/******/ // define getter function for harmony exports |
| 59 |
/******/ __webpack_require__.d = function(exports, name, getter) { |
| 60 |
/******/ if(!__webpack_require__.o(exports, name)) { |
| 61 |
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
| 62 |
/******/ } |
| 63 |
/******/ }; |
| 64 |
/******/ |
| 65 |
/******/ // define __esModule on exports |
| 66 |
/******/ __webpack_require__.r = function(exports) { |
| 67 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 68 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 69 |
/******/ } |
| 70 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 71 |
/******/ }; |
| 72 |
/******/ |
| 73 |
/******/ // create a fake namespace object |
| 74 |
/******/ // mode & 1: value is a module id, require it |
| 75 |
/******/ // mode & 2: merge all properties of value into the ns |
| 76 |
/******/ // mode & 4: return value when already ns object |
| 77 |
/******/ // mode & 8|1: behave like require |
| 78 |
/******/ __webpack_require__.t = function(value, mode) { |
| 79 |
/******/ if(mode & 1) value = __webpack_require__(value); |
| 80 |
/******/ if(mode & 8) return value; |
| 81 |
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
| 82 |
/******/ var ns = Object.create(null); |
| 83 |
/******/ __webpack_require__.r(ns); |
| 84 |
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
| 85 |
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
| 86 |
/******/ return ns; |
| 87 |
/******/ }; |
| 88 |
/******/ |
| 89 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 90 |
/******/ __webpack_require__.n = function(module) { |
| 91 |
/******/ var getter = module && module.__esModule ? |
| 92 |
/******/ function getDefault() { return module['default']; } : |
| 93 |
/******/ function getModuleExports() { return module; }; |
| 94 |
/******/ __webpack_require__.d(getter, 'a', getter); |
| 95 |
/******/ return getter; |
| 96 |
/******/ }; |
| 97 |
/******/ |
| 98 |
/******/ // Object.prototype.hasOwnProperty.call |
| 99 |
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
| 100 |
/******/ |
| 101 |
/******/ // __webpack_public_path__ |
| 102 |
/******/ __webpack_require__.p = ""; |
| 103 |
/******/ |
| 104 |
/******/ |
| 105 |
/******/ // Load entry module and return exports |
| 106 |
/******/ return __webpack_require__(__webpack_require__.s = 52); |
| 107 |
/******/ }) |
| 108 |
/************************************************************************/ |
| 109 |
/******/ ({ |
| 110 |
|
| 111 |
/***/ 0: |
| 112 |
/***/ (function(module, exports) { |
| 113 |
|
| 114 |
module.exports = __WEBPACK_EXTERNAL_MODULE__0__; |
| 115 |
|
| 116 |
/***/ }), |
| 117 |
|
| 118 |
/***/ 1: |
| 119 |
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
| 120 |
|
| 121 |
"use strict"; |
| 122 |
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); |
| 123 |
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); |
| 124 |
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } |
| 125 |
|
| 126 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 127 |
|
| 128 |
function _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); } } |
| 129 |
|
| 130 |
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
var Renderer = /*#__PURE__*/function () { |
| 135 |
function Renderer(markup, children, options, callback) { |
| 136 |
_classCallCheck(this, Renderer); |
| 137 |
|
| 138 |
this.markup = markup; |
| 139 |
this.children = children; |
| 140 |
this.options = options; |
| 141 |
this.callback = callback; |
| 142 |
} |
| 143 |
|
| 144 |
_createClass(Renderer, [{ |
| 145 |
key: "render", |
| 146 |
value: function render($parent) { |
| 147 |
var $node = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this.markup); |
| 148 |
|
| 149 |
if (this.options && this.options.contents) { |
| 150 |
$node.html(this.options.contents); |
| 151 |
} |
| 152 |
|
| 153 |
if (this.options && this.options.className) { |
| 154 |
$node.addClass(this.options.className); |
| 155 |
} |
| 156 |
|
| 157 |
if (this.options && this.options.data) { |
| 158 |
jquery__WEBPACK_IMPORTED_MODULE_0___default.a.each(this.options.data, function (k, v) { |
| 159 |
$node.attr('data-' + k, v); |
| 160 |
}); |
| 161 |
} |
| 162 |
|
| 163 |
if (this.options && this.options.click) { |
| 164 |
$node.on('click', this.options.click); |
| 165 |
} |
| 166 |
|
| 167 |
if (this.children) { |
| 168 |
var $container = $node.find('.note-children-container'); |
| 169 |
this.children.forEach(function (child) { |
| 170 |
child.render($container.length ? $container : $node); |
| 171 |
}); |
| 172 |
} |
| 173 |
|
| 174 |
if (this.callback) { |
| 175 |
this.callback($node, this.options); |
| 176 |
} |
| 177 |
|
| 178 |
if (this.options && this.options.callback) { |
| 179 |
this.options.callback($node); |
| 180 |
} |
| 181 |
|
| 182 |
if ($parent) { |
| 183 |
$parent.append($node); |
| 184 |
} |
| 185 |
|
| 186 |
return $node; |
| 187 |
} |
| 188 |
}]); |
| 189 |
|
| 190 |
return Renderer; |
| 191 |
}(); |
| 192 |
|
| 193 |
/* harmony default export */ __webpack_exports__["a"] = ({ |
| 194 |
create: function create(markup, callback) { |
| 195 |
return function () { |
| 196 |
var options = _typeof(arguments[1]) === 'object' ? arguments[1] : arguments[0]; |
| 197 |
var children = Array.isArray(arguments[0]) ? arguments[0] : []; |
| 198 |
|
| 199 |
if (options && options.children) { |
| 200 |
children = options.children; |
| 201 |
} |
| 202 |
|
| 203 |
return new Renderer(markup, children, options, callback); |
| 204 |
}; |
| 205 |
} |
| 206 |
}); |
| 207 |
|
| 208 |
/***/ }), |
| 209 |
|
| 210 |
/***/ 2: |
| 211 |
/***/ (function(module, exports) { |
| 212 |
|
| 213 |
/* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {/* globals __webpack_amd_options__ */ |
| 214 |
module.exports = __webpack_amd_options__; |
| 215 |
|
| 216 |
/* WEBPACK VAR INJECTION */}.call(this, {})) |
| 217 |
|
| 218 |
/***/ }), |
| 219 |
|
| 220 |
/***/ 3: |
| 221 |
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
| 222 |
|
| 223 |
"use strict"; |
| 224 |
|
| 225 |
// EXTERNAL MODULE: external {"root":"jQuery","commonjs2":"jquery","commonjs":"jquery","amd":"jquery"} |
| 226 |
var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_ = __webpack_require__(0); |
| 227 |
var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default = /*#__PURE__*/__webpack_require__.n(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_); |
| 228 |
|
| 229 |
// CONCATENATED MODULE: ./src/js/base/summernote-en-US.js |
| 230 |
|
| 231 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote || { |
| 232 |
lang: {} |
| 233 |
}; |
| 234 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.lang, { |
| 235 |
'en-US': { |
| 236 |
font: { |
| 237 |
bold: 'Bold', |
| 238 |
italic: 'Italic', |
| 239 |
underline: 'Underline', |
| 240 |
clear: 'Remove Font Style', |
| 241 |
height: 'Line Height', |
| 242 |
name: 'Font Family', |
| 243 |
strikethrough: 'Strikethrough', |
| 244 |
subscript: 'Subscript', |
| 245 |
superscript: 'Superscript', |
| 246 |
size: 'Font Size', |
| 247 |
sizeunit: 'Font Size Unit' |
| 248 |
}, |
| 249 |
image: { |
| 250 |
image: 'Picture', |
| 251 |
insert: 'Insert Image', |
| 252 |
resizeFull: 'Resize full', |
| 253 |
resizeHalf: 'Resize half', |
| 254 |
resizeQuarter: 'Resize quarter', |
| 255 |
resizeNone: 'Original size', |
| 256 |
floatLeft: 'Float Left', |
| 257 |
floatRight: 'Float Right', |
| 258 |
floatNone: 'Remove float', |
| 259 |
shapeRounded: 'Shape: Rounded', |
| 260 |
shapeCircle: 'Shape: Circle', |
| 261 |
shapeThumbnail: 'Shape: Thumbnail', |
| 262 |
shapeNone: 'Shape: None', |
| 263 |
dragImageHere: 'Drag image or text here', |
| 264 |
dropImage: 'Drop image or Text', |
| 265 |
selectFromFiles: 'Select from files', |
| 266 |
maximumFileSize: 'Maximum file size', |
| 267 |
maximumFileSizeError: 'Maximum file size exceeded.', |
| 268 |
url: 'Image URL', |
| 269 |
remove: 'Remove Image', |
| 270 |
original: 'Original' |
| 271 |
}, |
| 272 |
video: { |
| 273 |
video: 'Video', |
| 274 |
videoLink: 'Video Link', |
| 275 |
insert: 'Insert Video', |
| 276 |
url: 'Video URL', |
| 277 |
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion or Youku)' |
| 278 |
}, |
| 279 |
link: { |
| 280 |
link: 'Link', |
| 281 |
insert: 'Insert Link', |
| 282 |
unlink: 'Unlink', |
| 283 |
edit: 'Edit', |
| 284 |
textToDisplay: 'Text to display', |
| 285 |
url: 'To what URL should this link go?', |
| 286 |
openInNewWindow: 'Open in new window', |
| 287 |
useProtocol: 'Use default protocol' |
| 288 |
}, |
| 289 |
table: { |
| 290 |
table: 'Table', |
| 291 |
addRowAbove: 'Add row above', |
| 292 |
addRowBelow: 'Add row below', |
| 293 |
addColLeft: 'Add column left', |
| 294 |
addColRight: 'Add column right', |
| 295 |
delRow: 'Delete row', |
| 296 |
delCol: 'Delete column', |
| 297 |
delTable: 'Delete table' |
| 298 |
}, |
| 299 |
hr: { |
| 300 |
insert: 'Insert Horizontal Rule' |
| 301 |
}, |
| 302 |
style: { |
| 303 |
style: 'Style', |
| 304 |
p: 'Normal', |
| 305 |
blockquote: 'Quote', |
| 306 |
pre: 'Code', |
| 307 |
h1: 'Header 1', |
| 308 |
h2: 'Header 2', |
| 309 |
h3: 'Header 3', |
| 310 |
h4: 'Header 4', |
| 311 |
h5: 'Header 5', |
| 312 |
h6: 'Header 6' |
| 313 |
}, |
| 314 |
lists: { |
| 315 |
unordered: 'Unordered list', |
| 316 |
ordered: 'Ordered list' |
| 317 |
}, |
| 318 |
options: { |
| 319 |
help: 'Help', |
| 320 |
fullscreen: 'Full Screen', |
| 321 |
codeview: 'Code View' |
| 322 |
}, |
| 323 |
paragraph: { |
| 324 |
paragraph: 'Paragraph', |
| 325 |
outdent: 'Outdent', |
| 326 |
indent: 'Indent', |
| 327 |
left: 'Align left', |
| 328 |
center: 'Align center', |
| 329 |
right: 'Align right', |
| 330 |
justify: 'Justify full' |
| 331 |
}, |
| 332 |
color: { |
| 333 |
recent: 'Recent Color', |
| 334 |
more: 'More Color', |
| 335 |
background: 'Background Color', |
| 336 |
foreground: 'Text Color', |
| 337 |
transparent: 'Transparent', |
| 338 |
setTransparent: 'Set transparent', |
| 339 |
reset: 'Reset', |
| 340 |
resetToDefault: 'Reset to default', |
| 341 |
cpSelect: 'Select' |
| 342 |
}, |
| 343 |
shortcut: { |
| 344 |
shortcuts: 'Keyboard shortcuts', |
| 345 |
close: 'Close', |
| 346 |
textFormatting: 'Text formatting', |
| 347 |
action: 'Action', |
| 348 |
paragraphFormatting: 'Paragraph formatting', |
| 349 |
documentStyle: 'Document Style', |
| 350 |
extraKeys: 'Extra keys' |
| 351 |
}, |
| 352 |
help: { |
| 353 |
'escape': 'Escape', |
| 354 |
'insertParagraph': 'Insert Paragraph', |
| 355 |
'undo': 'Undo the last command', |
| 356 |
'redo': 'Redo the last command', |
| 357 |
'tab': 'Tab', |
| 358 |
'untab': 'Untab', |
| 359 |
'bold': 'Set a bold style', |
| 360 |
'italic': 'Set a italic style', |
| 361 |
'underline': 'Set a underline style', |
| 362 |
'strikethrough': 'Set a strikethrough style', |
| 363 |
'removeFormat': 'Clean a style', |
| 364 |
'justifyLeft': 'Set left align', |
| 365 |
'justifyCenter': 'Set center align', |
| 366 |
'justifyRight': 'Set right align', |
| 367 |
'justifyFull': 'Set full align', |
| 368 |
'insertUnorderedList': 'Toggle unordered list', |
| 369 |
'insertOrderedList': 'Toggle ordered list', |
| 370 |
'outdent': 'Outdent on current paragraph', |
| 371 |
'indent': 'Indent on current paragraph', |
| 372 |
'formatPara': 'Change current block\'s format as a paragraph(P tag)', |
| 373 |
'formatH1': 'Change current block\'s format as H1', |
| 374 |
'formatH2': 'Change current block\'s format as H2', |
| 375 |
'formatH3': 'Change current block\'s format as H3', |
| 376 |
'formatH4': 'Change current block\'s format as H4', |
| 377 |
'formatH5': 'Change current block\'s format as H5', |
| 378 |
'formatH6': 'Change current block\'s format as H6', |
| 379 |
'insertHorizontalRule': 'Insert horizontal rule', |
| 380 |
'linkDialog.show': 'Show Link Dialog' |
| 381 |
}, |
| 382 |
history: { |
| 383 |
undo: 'Undo', |
| 384 |
redo: 'Redo' |
| 385 |
}, |
| 386 |
specialChar: { |
| 387 |
specialChar: 'SPECIAL CHARACTERS', |
| 388 |
select: 'Select Special characters' |
| 389 |
}, |
| 390 |
output: { |
| 391 |
noSelection: 'No Selection Made!' |
| 392 |
} |
| 393 |
} |
| 394 |
}); |
| 395 |
// CONCATENATED MODULE: ./src/js/base/core/env.js |
| 396 |
|
| 397 |
var isSupportAmd = typeof define === 'function' && __webpack_require__(2); // eslint-disable-line |
| 398 |
|
| 399 |
/** |
| 400 |
* returns whether font is installed or not. |
| 401 |
* |
| 402 |
* @param {String} fontName |
| 403 |
* @return {Boolean} |
| 404 |
*/ |
| 405 |
|
| 406 |
var genericFontFamilies = ['sans-serif', 'serif', 'monospace', 'cursive', 'fantasy']; |
| 407 |
|
| 408 |
function validFontName(fontName) { |
| 409 |
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.inArray(fontName.toLowerCase(), genericFontFamilies) === -1 ? "'".concat(fontName, "'") : fontName; |
| 410 |
} |
| 411 |
|
| 412 |
function env_isFontInstalled(fontName) { |
| 413 |
var testFontName = fontName === 'Comic Sans MS' ? 'Courier New' : 'Comic Sans MS'; |
| 414 |
var testText = 'mmmmmmmmmmwwwww'; |
| 415 |
var testSize = '200px'; |
| 416 |
var canvas = document.createElement('canvas'); |
| 417 |
var context = canvas.getContext('2d'); |
| 418 |
context.font = testSize + " '" + testFontName + "'"; |
| 419 |
var originalWidth = context.measureText(testText).width; |
| 420 |
context.font = testSize + ' ' + validFontName(fontName) + ', "' + testFontName + '"'; |
| 421 |
var width = context.measureText(testText).width; |
| 422 |
return originalWidth !== width; |
| 423 |
} |
| 424 |
|
| 425 |
var userAgent = navigator.userAgent; |
| 426 |
var isMSIE = /MSIE|Trident/i.test(userAgent); |
| 427 |
var browserVersion; |
| 428 |
|
| 429 |
if (isMSIE) { |
| 430 |
var matches = /MSIE (\d+[.]\d+)/.exec(userAgent); |
| 431 |
|
| 432 |
if (matches) { |
| 433 |
browserVersion = parseFloat(matches[1]); |
| 434 |
} |
| 435 |
|
| 436 |
matches = /Trident\/.*rv:([0-9]{1,}[.0-9]{0,})/.exec(userAgent); |
| 437 |
|
| 438 |
if (matches) { |
| 439 |
browserVersion = parseFloat(matches[1]); |
| 440 |
} |
| 441 |
} |
| 442 |
|
| 443 |
var isEdge = /Edge\/\d+/.test(userAgent); |
| 444 |
var isSupportTouch = 'ontouchstart' in window || navigator.MaxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; // [workaround] IE doesn't have input events for contentEditable |
| 445 |
// - see: https://goo.gl/4bfIvA |
| 446 |
|
| 447 |
var inputEventName = isMSIE ? 'DOMCharacterDataModified DOMSubtreeModified DOMNodeInserted' : 'input'; |
| 448 |
/** |
| 449 |
* @class core.env |
| 450 |
* |
| 451 |
* Object which check platform and agent |
| 452 |
* |
| 453 |
* @singleton |
| 454 |
* @alternateClassName env |
| 455 |
*/ |
| 456 |
|
| 457 |
/* harmony default export */ var env = ({ |
| 458 |
isMac: navigator.appVersion.indexOf('Mac') > -1, |
| 459 |
isMSIE: isMSIE, |
| 460 |
isEdge: isEdge, |
| 461 |
isFF: !isEdge && /firefox/i.test(userAgent), |
| 462 |
isPhantom: /PhantomJS/i.test(userAgent), |
| 463 |
isWebkit: !isEdge && /webkit/i.test(userAgent), |
| 464 |
isChrome: !isEdge && /chrome/i.test(userAgent), |
| 465 |
isSafari: !isEdge && /safari/i.test(userAgent) && !/chrome/i.test(userAgent), |
| 466 |
browserVersion: browserVersion, |
| 467 |
jqueryVersion: parseFloat(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.fn.jquery), |
| 468 |
isSupportAmd: isSupportAmd, |
| 469 |
isSupportTouch: isSupportTouch, |
| 470 |
isFontInstalled: env_isFontInstalled, |
| 471 |
isW3CRangeSupport: !!document.createRange, |
| 472 |
inputEventName: inputEventName, |
| 473 |
genericFontFamilies: genericFontFamilies, |
| 474 |
validFontName: validFontName |
| 475 |
}); |
| 476 |
// CONCATENATED MODULE: ./src/js/base/core/func.js |
| 477 |
|
| 478 |
/** |
| 479 |
* @class core.func |
| 480 |
* |
| 481 |
* func utils (for high-order func's arg) |
| 482 |
* |
| 483 |
* @singleton |
| 484 |
* @alternateClassName func |
| 485 |
*/ |
| 486 |
|
| 487 |
function eq(itemA) { |
| 488 |
return function (itemB) { |
| 489 |
return itemA === itemB; |
| 490 |
}; |
| 491 |
} |
| 492 |
|
| 493 |
function eq2(itemA, itemB) { |
| 494 |
return itemA === itemB; |
| 495 |
} |
| 496 |
|
| 497 |
function peq2(propName) { |
| 498 |
return function (itemA, itemB) { |
| 499 |
return itemA[propName] === itemB[propName]; |
| 500 |
}; |
| 501 |
} |
| 502 |
|
| 503 |
function ok() { |
| 504 |
return true; |
| 505 |
} |
| 506 |
|
| 507 |
function fail() { |
| 508 |
return false; |
| 509 |
} |
| 510 |
|
| 511 |
function not(f) { |
| 512 |
return function () { |
| 513 |
return !f.apply(f, arguments); |
| 514 |
}; |
| 515 |
} |
| 516 |
|
| 517 |
function and(fA, fB) { |
| 518 |
return function (item) { |
| 519 |
return fA(item) && fB(item); |
| 520 |
}; |
| 521 |
} |
| 522 |
|
| 523 |
function func_self(a) { |
| 524 |
return a; |
| 525 |
} |
| 526 |
|
| 527 |
function func_invoke(obj, method) { |
| 528 |
return function () { |
| 529 |
return obj[method].apply(obj, arguments); |
| 530 |
}; |
| 531 |
} |
| 532 |
|
| 533 |
var idCounter = 0; |
| 534 |
/** |
| 535 |
* reset globally-unique id |
| 536 |
* |
| 537 |
*/ |
| 538 |
|
| 539 |
function resetUniqueId() { |
| 540 |
idCounter = 0; |
| 541 |
} |
| 542 |
/** |
| 543 |
* generate a globally-unique id |
| 544 |
* |
| 545 |
* @param {String} [prefix] |
| 546 |
*/ |
| 547 |
|
| 548 |
|
| 549 |
function uniqueId(prefix) { |
| 550 |
var id = ++idCounter + ''; |
| 551 |
return prefix ? prefix + id : id; |
| 552 |
} |
| 553 |
/** |
| 554 |
* returns bnd (bounds) from rect |
| 555 |
* |
| 556 |
* - IE Compatibility Issue: http://goo.gl/sRLOAo |
| 557 |
* - Scroll Issue: http://goo.gl/sNjUc |
| 558 |
* |
| 559 |
* @param {Rect} rect |
| 560 |
* @return {Object} bounds |
| 561 |
* @return {Number} bounds.top |
| 562 |
* @return {Number} bounds.left |
| 563 |
* @return {Number} bounds.width |
| 564 |
* @return {Number} bounds.height |
| 565 |
*/ |
| 566 |
|
| 567 |
|
| 568 |
function rect2bnd(rect) { |
| 569 |
var $document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document); |
| 570 |
return { |
| 571 |
top: rect.top + $document.scrollTop(), |
| 572 |
left: rect.left + $document.scrollLeft(), |
| 573 |
width: rect.right - rect.left, |
| 574 |
height: rect.bottom - rect.top |
| 575 |
}; |
| 576 |
} |
| 577 |
/** |
| 578 |
* returns a copy of the object where the keys have become the values and the values the keys. |
| 579 |
* @param {Object} obj |
| 580 |
* @return {Object} |
| 581 |
*/ |
| 582 |
|
| 583 |
|
| 584 |
function invertObject(obj) { |
| 585 |
var inverted = {}; |
| 586 |
|
| 587 |
for (var key in obj) { |
| 588 |
if (Object.prototype.hasOwnProperty.call(obj, key)) { |
| 589 |
inverted[obj[key]] = key; |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
return inverted; |
| 594 |
} |
| 595 |
/** |
| 596 |
* @param {String} namespace |
| 597 |
* @param {String} [prefix] |
| 598 |
* @return {String} |
| 599 |
*/ |
| 600 |
|
| 601 |
|
| 602 |
function namespaceToCamel(namespace, prefix) { |
| 603 |
prefix = prefix || ''; |
| 604 |
return prefix + namespace.split('.').map(function (name) { |
| 605 |
return name.substring(0, 1).toUpperCase() + name.substring(1); |
| 606 |
}).join(''); |
| 607 |
} |
| 608 |
/** |
| 609 |
* Returns a function, that, as long as it continues to be invoked, will not |
| 610 |
* be triggered. The function will be called after it stops being called for |
| 611 |
* N milliseconds. If `immediate` is passed, trigger the function on the |
| 612 |
* leading edge, instead of the trailing. |
| 613 |
* @param {Function} func |
| 614 |
* @param {Number} wait |
| 615 |
* @param {Boolean} immediate |
| 616 |
* @return {Function} |
| 617 |
*/ |
| 618 |
|
| 619 |
|
| 620 |
function debounce(func, wait, immediate) { |
| 621 |
var timeout; |
| 622 |
return function () { |
| 623 |
var context = this; |
| 624 |
var args = arguments; |
| 625 |
|
| 626 |
var later = function later() { |
| 627 |
timeout = null; |
| 628 |
|
| 629 |
if (!immediate) { |
| 630 |
func.apply(context, args); |
| 631 |
} |
| 632 |
}; |
| 633 |
|
| 634 |
var callNow = immediate && !timeout; |
| 635 |
clearTimeout(timeout); |
| 636 |
timeout = setTimeout(later, wait); |
| 637 |
|
| 638 |
if (callNow) { |
| 639 |
func.apply(context, args); |
| 640 |
} |
| 641 |
}; |
| 642 |
} |
| 643 |
/** |
| 644 |
* |
| 645 |
* @param {String} url |
| 646 |
* @return {Boolean} |
| 647 |
*/ |
| 648 |
|
| 649 |
|
| 650 |
function isValidUrl(url) { |
| 651 |
var expression = /[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi; |
| 652 |
return expression.test(url); |
| 653 |
} |
| 654 |
|
| 655 |
/* harmony default export */ var func = ({ |
| 656 |
eq: eq, |
| 657 |
eq2: eq2, |
| 658 |
peq2: peq2, |
| 659 |
ok: ok, |
| 660 |
fail: fail, |
| 661 |
self: func_self, |
| 662 |
not: not, |
| 663 |
and: and, |
| 664 |
invoke: func_invoke, |
| 665 |
resetUniqueId: resetUniqueId, |
| 666 |
uniqueId: uniqueId, |
| 667 |
rect2bnd: rect2bnd, |
| 668 |
invertObject: invertObject, |
| 669 |
namespaceToCamel: namespaceToCamel, |
| 670 |
debounce: debounce, |
| 671 |
isValidUrl: isValidUrl |
| 672 |
}); |
| 673 |
// CONCATENATED MODULE: ./src/js/base/core/lists.js |
| 674 |
|
| 675 |
/** |
| 676 |
* returns the first item of an array. |
| 677 |
* |
| 678 |
* @param {Array} array |
| 679 |
*/ |
| 680 |
|
| 681 |
function lists_head(array) { |
| 682 |
return array[0]; |
| 683 |
} |
| 684 |
/** |
| 685 |
* returns the last item of an array. |
| 686 |
* |
| 687 |
* @param {Array} array |
| 688 |
*/ |
| 689 |
|
| 690 |
|
| 691 |
function lists_last(array) { |
| 692 |
return array[array.length - 1]; |
| 693 |
} |
| 694 |
/** |
| 695 |
* returns everything but the last entry of the array. |
| 696 |
* |
| 697 |
* @param {Array} array |
| 698 |
*/ |
| 699 |
|
| 700 |
|
| 701 |
function initial(array) { |
| 702 |
return array.slice(0, array.length - 1); |
| 703 |
} |
| 704 |
/** |
| 705 |
* returns the rest of the items in an array. |
| 706 |
* |
| 707 |
* @param {Array} array |
| 708 |
*/ |
| 709 |
|
| 710 |
|
| 711 |
function tail(array) { |
| 712 |
return array.slice(1); |
| 713 |
} |
| 714 |
/** |
| 715 |
* returns item of array |
| 716 |
*/ |
| 717 |
|
| 718 |
|
| 719 |
function find(array, pred) { |
| 720 |
for (var idx = 0, len = array.length; idx < len; idx++) { |
| 721 |
var item = array[idx]; |
| 722 |
|
| 723 |
if (pred(item)) { |
| 724 |
return item; |
| 725 |
} |
| 726 |
} |
| 727 |
} |
| 728 |
/** |
| 729 |
* returns true if all of the values in the array pass the predicate truth test. |
| 730 |
*/ |
| 731 |
|
| 732 |
|
| 733 |
function lists_all(array, pred) { |
| 734 |
for (var idx = 0, len = array.length; idx < len; idx++) { |
| 735 |
if (!pred(array[idx])) { |
| 736 |
return false; |
| 737 |
} |
| 738 |
} |
| 739 |
|
| 740 |
return true; |
| 741 |
} |
| 742 |
/** |
| 743 |
* returns true if the value is present in the list. |
| 744 |
*/ |
| 745 |
|
| 746 |
|
| 747 |
function contains(array, item) { |
| 748 |
if (array && array.length && item) { |
| 749 |
if (array.indexOf) { |
| 750 |
return array.indexOf(item) !== -1; |
| 751 |
} else if (array.contains) { |
| 752 |
// `DOMTokenList` doesn't implement `.indexOf`, but it implements `.contains` |
| 753 |
return array.contains(item); |
| 754 |
} |
| 755 |
} |
| 756 |
|
| 757 |
return false; |
| 758 |
} |
| 759 |
/** |
| 760 |
* get sum from a list |
| 761 |
* |
| 762 |
* @param {Array} array - array |
| 763 |
* @param {Function} fn - iterator |
| 764 |
*/ |
| 765 |
|
| 766 |
|
| 767 |
function sum(array, fn) { |
| 768 |
fn = fn || func.self; |
| 769 |
return array.reduce(function (memo, v) { |
| 770 |
return memo + fn(v); |
| 771 |
}, 0); |
| 772 |
} |
| 773 |
/** |
| 774 |
* returns a copy of the collection with array type. |
| 775 |
* @param {Collection} collection - collection eg) node.childNodes, ... |
| 776 |
*/ |
| 777 |
|
| 778 |
|
| 779 |
function from(collection) { |
| 780 |
var result = []; |
| 781 |
var length = collection.length; |
| 782 |
var idx = -1; |
| 783 |
|
| 784 |
while (++idx < length) { |
| 785 |
result[idx] = collection[idx]; |
| 786 |
} |
| 787 |
|
| 788 |
return result; |
| 789 |
} |
| 790 |
/** |
| 791 |
* returns whether list is empty or not |
| 792 |
*/ |
| 793 |
|
| 794 |
|
| 795 |
function lists_isEmpty(array) { |
| 796 |
return !array || !array.length; |
| 797 |
} |
| 798 |
/** |
| 799 |
* cluster elements by predicate function. |
| 800 |
* |
| 801 |
* @param {Array} array - array |
| 802 |
* @param {Function} fn - predicate function for cluster rule |
| 803 |
* @param {Array[]} |
| 804 |
*/ |
| 805 |
|
| 806 |
|
| 807 |
function clusterBy(array, fn) { |
| 808 |
if (!array.length) { |
| 809 |
return []; |
| 810 |
} |
| 811 |
|
| 812 |
var aTail = tail(array); |
| 813 |
return aTail.reduce(function (memo, v) { |
| 814 |
var aLast = lists_last(memo); |
| 815 |
|
| 816 |
if (fn(lists_last(aLast), v)) { |
| 817 |
aLast[aLast.length] = v; |
| 818 |
} else { |
| 819 |
memo[memo.length] = [v]; |
| 820 |
} |
| 821 |
|
| 822 |
return memo; |
| 823 |
}, [[lists_head(array)]]); |
| 824 |
} |
| 825 |
/** |
| 826 |
* returns a copy of the array with all false values removed |
| 827 |
* |
| 828 |
* @param {Array} array - array |
| 829 |
* @param {Function} fn - predicate function for cluster rule |
| 830 |
*/ |
| 831 |
|
| 832 |
|
| 833 |
function compact(array) { |
| 834 |
var aResult = []; |
| 835 |
|
| 836 |
for (var idx = 0, len = array.length; idx < len; idx++) { |
| 837 |
if (array[idx]) { |
| 838 |
aResult.push(array[idx]); |
| 839 |
} |
| 840 |
} |
| 841 |
|
| 842 |
return aResult; |
| 843 |
} |
| 844 |
/** |
| 845 |
* produces a duplicate-free version of the array |
| 846 |
* |
| 847 |
* @param {Array} array |
| 848 |
*/ |
| 849 |
|
| 850 |
|
| 851 |
function unique(array) { |
| 852 |
var results = []; |
| 853 |
|
| 854 |
for (var idx = 0, len = array.length; idx < len; idx++) { |
| 855 |
if (!contains(results, array[idx])) { |
| 856 |
results.push(array[idx]); |
| 857 |
} |
| 858 |
} |
| 859 |
|
| 860 |
return results; |
| 861 |
} |
| 862 |
/** |
| 863 |
* returns next item. |
| 864 |
* @param {Array} array |
| 865 |
*/ |
| 866 |
|
| 867 |
|
| 868 |
function lists_next(array, item) { |
| 869 |
if (array && array.length && item) { |
| 870 |
var idx = array.indexOf(item); |
| 871 |
return idx === -1 ? null : array[idx + 1]; |
| 872 |
} |
| 873 |
|
| 874 |
return null; |
| 875 |
} |
| 876 |
/** |
| 877 |
* returns prev item. |
| 878 |
* @param {Array} array |
| 879 |
*/ |
| 880 |
|
| 881 |
|
| 882 |
function prev(array, item) { |
| 883 |
if (array && array.length && item) { |
| 884 |
var idx = array.indexOf(item); |
| 885 |
return idx === -1 ? null : array[idx - 1]; |
| 886 |
} |
| 887 |
|
| 888 |
return null; |
| 889 |
} |
| 890 |
/** |
| 891 |
* @class core.list |
| 892 |
* |
| 893 |
* list utils |
| 894 |
* |
| 895 |
* @singleton |
| 896 |
* @alternateClassName list |
| 897 |
*/ |
| 898 |
|
| 899 |
|
| 900 |
/* harmony default export */ var lists = ({ |
| 901 |
head: lists_head, |
| 902 |
last: lists_last, |
| 903 |
initial: initial, |
| 904 |
tail: tail, |
| 905 |
prev: prev, |
| 906 |
next: lists_next, |
| 907 |
find: find, |
| 908 |
contains: contains, |
| 909 |
all: lists_all, |
| 910 |
sum: sum, |
| 911 |
from: from, |
| 912 |
isEmpty: lists_isEmpty, |
| 913 |
clusterBy: clusterBy, |
| 914 |
compact: compact, |
| 915 |
unique: unique |
| 916 |
}); |
| 917 |
// CONCATENATED MODULE: ./src/js/base/core/dom.js |
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
var NBSP_CHAR = String.fromCharCode(160); |
| 923 |
var ZERO_WIDTH_NBSP_CHAR = "\uFEFF"; |
| 924 |
/** |
| 925 |
* @method isEditable |
| 926 |
* |
| 927 |
* returns whether node is `note-editable` or not. |
| 928 |
* |
| 929 |
* @param {Node} node |
| 930 |
* @return {Boolean} |
| 931 |
*/ |
| 932 |
|
| 933 |
function isEditable(node) { |
| 934 |
return node && external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).hasClass('note-editable'); |
| 935 |
} |
| 936 |
/** |
| 937 |
* @method isControlSizing |
| 938 |
* |
| 939 |
* returns whether node is `note-control-sizing` or not. |
| 940 |
* |
| 941 |
* @param {Node} node |
| 942 |
* @return {Boolean} |
| 943 |
*/ |
| 944 |
|
| 945 |
|
| 946 |
function isControlSizing(node) { |
| 947 |
return node && external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).hasClass('note-control-sizing'); |
| 948 |
} |
| 949 |
/** |
| 950 |
* @method makePredByNodeName |
| 951 |
* |
| 952 |
* returns predicate which judge whether nodeName is same |
| 953 |
* |
| 954 |
* @param {String} nodeName |
| 955 |
* @return {Function} |
| 956 |
*/ |
| 957 |
|
| 958 |
|
| 959 |
function makePredByNodeName(nodeName) { |
| 960 |
nodeName = nodeName.toUpperCase(); |
| 961 |
return function (node) { |
| 962 |
return node && node.nodeName.toUpperCase() === nodeName; |
| 963 |
}; |
| 964 |
} |
| 965 |
/** |
| 966 |
* @method isText |
| 967 |
* |
| 968 |
* |
| 969 |
* |
| 970 |
* @param {Node} node |
| 971 |
* @return {Boolean} true if node's type is text(3) |
| 972 |
*/ |
| 973 |
|
| 974 |
|
| 975 |
function isText(node) { |
| 976 |
return node && node.nodeType === 3; |
| 977 |
} |
| 978 |
/** |
| 979 |
* @method isElement |
| 980 |
* |
| 981 |
* |
| 982 |
* |
| 983 |
* @param {Node} node |
| 984 |
* @return {Boolean} true if node's type is element(1) |
| 985 |
*/ |
| 986 |
|
| 987 |
|
| 988 |
function isElement(node) { |
| 989 |
return node && node.nodeType === 1; |
| 990 |
} |
| 991 |
/** |
| 992 |
* ex) br, col, embed, hr, img, input, ... |
| 993 |
* @see http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements |
| 994 |
*/ |
| 995 |
|
| 996 |
|
| 997 |
function isVoid(node) { |
| 998 |
return node && /^BR|^IMG|^HR|^IFRAME|^BUTTON|^INPUT|^AUDIO|^VIDEO|^EMBED/.test(node.nodeName.toUpperCase()); |
| 999 |
} |
| 1000 |
|
| 1001 |
function isPara(node) { |
| 1002 |
if (isEditable(node)) { |
| 1003 |
return false; |
| 1004 |
} // Chrome(v31.0), FF(v25.0.1) use DIV for paragraph |
| 1005 |
|
| 1006 |
|
| 1007 |
return node && /^DIV|^P|^LI|^H[1-7]/.test(node.nodeName.toUpperCase()); |
| 1008 |
} |
| 1009 |
|
| 1010 |
function isHeading(node) { |
| 1011 |
return node && /^H[1-7]/.test(node.nodeName.toUpperCase()); |
| 1012 |
} |
| 1013 |
|
| 1014 |
var isPre = makePredByNodeName('PRE'); |
| 1015 |
var isLi = makePredByNodeName('LI'); |
| 1016 |
|
| 1017 |
function isPurePara(node) { |
| 1018 |
return isPara(node) && !isLi(node); |
| 1019 |
} |
| 1020 |
|
| 1021 |
var isTable = makePredByNodeName('TABLE'); |
| 1022 |
var isData = makePredByNodeName('DATA'); |
| 1023 |
|
| 1024 |
function dom_isInline(node) { |
| 1025 |
return !isBodyContainer(node) && !isList(node) && !isHr(node) && !isPara(node) && !isTable(node) && !isBlockquote(node) && !isData(node); |
| 1026 |
} |
| 1027 |
|
| 1028 |
function isList(node) { |
| 1029 |
return node && /^UL|^OL/.test(node.nodeName.toUpperCase()); |
| 1030 |
} |
| 1031 |
|
| 1032 |
var isHr = makePredByNodeName('HR'); |
| 1033 |
|
| 1034 |
function dom_isCell(node) { |
| 1035 |
return node && /^TD|^TH/.test(node.nodeName.toUpperCase()); |
| 1036 |
} |
| 1037 |
|
| 1038 |
var isBlockquote = makePredByNodeName('BLOCKQUOTE'); |
| 1039 |
|
| 1040 |
function isBodyContainer(node) { |
| 1041 |
return dom_isCell(node) || isBlockquote(node) || isEditable(node); |
| 1042 |
} |
| 1043 |
|
| 1044 |
var isAnchor = makePredByNodeName('A'); |
| 1045 |
|
| 1046 |
function isParaInline(node) { |
| 1047 |
return dom_isInline(node) && !!dom_ancestor(node, isPara); |
| 1048 |
} |
| 1049 |
|
| 1050 |
function isBodyInline(node) { |
| 1051 |
return dom_isInline(node) && !dom_ancestor(node, isPara); |
| 1052 |
} |
| 1053 |
|
| 1054 |
var isBody = makePredByNodeName('BODY'); |
| 1055 |
/** |
| 1056 |
* returns whether nodeB is closest sibling of nodeA |
| 1057 |
* |
| 1058 |
* @param {Node} nodeA |
| 1059 |
* @param {Node} nodeB |
| 1060 |
* @return {Boolean} |
| 1061 |
*/ |
| 1062 |
|
| 1063 |
function isClosestSibling(nodeA, nodeB) { |
| 1064 |
return nodeA.nextSibling === nodeB || nodeA.previousSibling === nodeB; |
| 1065 |
} |
| 1066 |
/** |
| 1067 |
* returns array of closest siblings with node |
| 1068 |
* |
| 1069 |
* @param {Node} node |
| 1070 |
* @param {function} [pred] - predicate function |
| 1071 |
* @return {Node[]} |
| 1072 |
*/ |
| 1073 |
|
| 1074 |
|
| 1075 |
function withClosestSiblings(node, pred) { |
| 1076 |
pred = pred || func.ok; |
| 1077 |
var siblings = []; |
| 1078 |
|
| 1079 |
if (node.previousSibling && pred(node.previousSibling)) { |
| 1080 |
siblings.push(node.previousSibling); |
| 1081 |
} |
| 1082 |
|
| 1083 |
siblings.push(node); |
| 1084 |
|
| 1085 |
if (node.nextSibling && pred(node.nextSibling)) { |
| 1086 |
siblings.push(node.nextSibling); |
| 1087 |
} |
| 1088 |
|
| 1089 |
return siblings; |
| 1090 |
} |
| 1091 |
/** |
| 1092 |
* blank HTML for cursor position |
| 1093 |
* - [workaround] old IE only works with |
| 1094 |
* - [workaround] IE11 and other browser works with bogus br |
| 1095 |
*/ |
| 1096 |
|
| 1097 |
|
| 1098 |
var blankHTML = env.isMSIE && env.browserVersion < 11 ? ' ' : '<br>'; |
| 1099 |
/** |
| 1100 |
* @method nodeLength |
| 1101 |
* |
| 1102 |
* returns #text's text size or element's childNodes size |
| 1103 |
* |
| 1104 |
* @param {Node} node |
| 1105 |
*/ |
| 1106 |
|
| 1107 |
function nodeLength(node) { |
| 1108 |
if (isText(node)) { |
| 1109 |
return node.nodeValue.length; |
| 1110 |
} |
| 1111 |
|
| 1112 |
if (node) { |
| 1113 |
return node.childNodes.length; |
| 1114 |
} |
| 1115 |
|
| 1116 |
return 0; |
| 1117 |
} |
| 1118 |
/** |
| 1119 |
* returns whether deepest child node is empty or not. |
| 1120 |
* |
| 1121 |
* @param {Node} node |
| 1122 |
* @return {Boolean} |
| 1123 |
*/ |
| 1124 |
|
| 1125 |
|
| 1126 |
function deepestChildIsEmpty(node) { |
| 1127 |
do { |
| 1128 |
if (node.firstElementChild === null || node.firstElementChild.innerHTML === '') break; |
| 1129 |
} while (node = node.firstElementChild); |
| 1130 |
|
| 1131 |
return dom_isEmpty(node); |
| 1132 |
} |
| 1133 |
/** |
| 1134 |
* returns whether node is empty or not. |
| 1135 |
* |
| 1136 |
* @param {Node} node |
| 1137 |
* @return {Boolean} |
| 1138 |
*/ |
| 1139 |
|
| 1140 |
|
| 1141 |
function dom_isEmpty(node) { |
| 1142 |
var len = nodeLength(node); |
| 1143 |
|
| 1144 |
if (len === 0) { |
| 1145 |
return true; |
| 1146 |
} else if (!isText(node) && len === 1 && node.innerHTML === blankHTML) { |
| 1147 |
// ex) <p><br></p>, <span><br></span> |
| 1148 |
return true; |
| 1149 |
} else if (lists.all(node.childNodes, isText) && node.innerHTML === '') { |
| 1150 |
// ex) <p></p>, <span></span> |
| 1151 |
return true; |
| 1152 |
} |
| 1153 |
|
| 1154 |
return false; |
| 1155 |
} |
| 1156 |
/** |
| 1157 |
* padding blankHTML if node is empty (for cursor position) |
| 1158 |
*/ |
| 1159 |
|
| 1160 |
|
| 1161 |
function paddingBlankHTML(node) { |
| 1162 |
if (!isVoid(node) && !nodeLength(node)) { |
| 1163 |
node.innerHTML = blankHTML; |
| 1164 |
} |
| 1165 |
} |
| 1166 |
/** |
| 1167 |
* find nearest ancestor predicate hit |
| 1168 |
* |
| 1169 |
* @param {Node} node |
| 1170 |
* @param {Function} pred - predicate function |
| 1171 |
*/ |
| 1172 |
|
| 1173 |
|
| 1174 |
function dom_ancestor(node, pred) { |
| 1175 |
while (node) { |
| 1176 |
if (pred(node)) { |
| 1177 |
return node; |
| 1178 |
} |
| 1179 |
|
| 1180 |
if (isEditable(node)) { |
| 1181 |
break; |
| 1182 |
} |
| 1183 |
|
| 1184 |
node = node.parentNode; |
| 1185 |
} |
| 1186 |
|
| 1187 |
return null; |
| 1188 |
} |
| 1189 |
/** |
| 1190 |
* find nearest ancestor only single child blood line and predicate hit |
| 1191 |
* |
| 1192 |
* @param {Node} node |
| 1193 |
* @param {Function} pred - predicate function |
| 1194 |
*/ |
| 1195 |
|
| 1196 |
|
| 1197 |
function singleChildAncestor(node, pred) { |
| 1198 |
node = node.parentNode; |
| 1199 |
|
| 1200 |
while (node) { |
| 1201 |
if (nodeLength(node) !== 1) { |
| 1202 |
break; |
| 1203 |
} |
| 1204 |
|
| 1205 |
if (pred(node)) { |
| 1206 |
return node; |
| 1207 |
} |
| 1208 |
|
| 1209 |
if (isEditable(node)) { |
| 1210 |
break; |
| 1211 |
} |
| 1212 |
|
| 1213 |
node = node.parentNode; |
| 1214 |
} |
| 1215 |
|
| 1216 |
return null; |
| 1217 |
} |
| 1218 |
/** |
| 1219 |
* returns new array of ancestor nodes (until predicate hit). |
| 1220 |
* |
| 1221 |
* @param {Node} node |
| 1222 |
* @param {Function} [optional] pred - predicate function |
| 1223 |
*/ |
| 1224 |
|
| 1225 |
|
| 1226 |
function listAncestor(node, pred) { |
| 1227 |
pred = pred || func.fail; |
| 1228 |
var ancestors = []; |
| 1229 |
dom_ancestor(node, function (el) { |
| 1230 |
if (!isEditable(el)) { |
| 1231 |
ancestors.push(el); |
| 1232 |
} |
| 1233 |
|
| 1234 |
return pred(el); |
| 1235 |
}); |
| 1236 |
return ancestors; |
| 1237 |
} |
| 1238 |
/** |
| 1239 |
* find farthest ancestor predicate hit |
| 1240 |
*/ |
| 1241 |
|
| 1242 |
|
| 1243 |
function lastAncestor(node, pred) { |
| 1244 |
var ancestors = listAncestor(node); |
| 1245 |
return lists.last(ancestors.filter(pred)); |
| 1246 |
} |
| 1247 |
/** |
| 1248 |
* returns common ancestor node between two nodes. |
| 1249 |
* |
| 1250 |
* @param {Node} nodeA |
| 1251 |
* @param {Node} nodeB |
| 1252 |
*/ |
| 1253 |
|
| 1254 |
|
| 1255 |
function dom_commonAncestor(nodeA, nodeB) { |
| 1256 |
var ancestors = listAncestor(nodeA); |
| 1257 |
|
| 1258 |
for (var n = nodeB; n; n = n.parentNode) { |
| 1259 |
if (ancestors.indexOf(n) > -1) return n; |
| 1260 |
} |
| 1261 |
|
| 1262 |
return null; // difference document area |
| 1263 |
} |
| 1264 |
/** |
| 1265 |
* listing all previous siblings (until predicate hit). |
| 1266 |
* |
| 1267 |
* @param {Node} node |
| 1268 |
* @param {Function} [optional] pred - predicate function |
| 1269 |
*/ |
| 1270 |
|
| 1271 |
|
| 1272 |
function listPrev(node, pred) { |
| 1273 |
pred = pred || func.fail; |
| 1274 |
var nodes = []; |
| 1275 |
|
| 1276 |
while (node) { |
| 1277 |
if (pred(node)) { |
| 1278 |
break; |
| 1279 |
} |
| 1280 |
|
| 1281 |
nodes.push(node); |
| 1282 |
node = node.previousSibling; |
| 1283 |
} |
| 1284 |
|
| 1285 |
return nodes; |
| 1286 |
} |
| 1287 |
/** |
| 1288 |
* listing next siblings (until predicate hit). |
| 1289 |
* |
| 1290 |
* @param {Node} node |
| 1291 |
* @param {Function} [pred] - predicate function |
| 1292 |
*/ |
| 1293 |
|
| 1294 |
|
| 1295 |
function listNext(node, pred) { |
| 1296 |
pred = pred || func.fail; |
| 1297 |
var nodes = []; |
| 1298 |
|
| 1299 |
while (node) { |
| 1300 |
if (pred(node)) { |
| 1301 |
break; |
| 1302 |
} |
| 1303 |
|
| 1304 |
nodes.push(node); |
| 1305 |
node = node.nextSibling; |
| 1306 |
} |
| 1307 |
|
| 1308 |
return nodes; |
| 1309 |
} |
| 1310 |
/** |
| 1311 |
* listing descendant nodes |
| 1312 |
* |
| 1313 |
* @param {Node} node |
| 1314 |
* @param {Function} [pred] - predicate function |
| 1315 |
*/ |
| 1316 |
|
| 1317 |
|
| 1318 |
function listDescendant(node, pred) { |
| 1319 |
var descendants = []; |
| 1320 |
pred = pred || func.ok; // start DFS(depth first search) with node |
| 1321 |
|
| 1322 |
(function fnWalk(current) { |
| 1323 |
if (node !== current && pred(current)) { |
| 1324 |
descendants.push(current); |
| 1325 |
} |
| 1326 |
|
| 1327 |
for (var idx = 0, len = current.childNodes.length; idx < len; idx++) { |
| 1328 |
fnWalk(current.childNodes[idx]); |
| 1329 |
} |
| 1330 |
})(node); |
| 1331 |
|
| 1332 |
return descendants; |
| 1333 |
} |
| 1334 |
/** |
| 1335 |
* wrap node with new tag. |
| 1336 |
* |
| 1337 |
* @param {Node} node |
| 1338 |
* @param {Node} tagName of wrapper |
| 1339 |
* @return {Node} - wrapper |
| 1340 |
*/ |
| 1341 |
|
| 1342 |
|
| 1343 |
function wrap(node, wrapperName) { |
| 1344 |
var parent = node.parentNode; |
| 1345 |
var wrapper = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<' + wrapperName + '>')[0]; |
| 1346 |
parent.insertBefore(wrapper, node); |
| 1347 |
wrapper.appendChild(node); |
| 1348 |
return wrapper; |
| 1349 |
} |
| 1350 |
/** |
| 1351 |
* insert node after preceding |
| 1352 |
* |
| 1353 |
* @param {Node} node |
| 1354 |
* @param {Node} preceding - predicate function |
| 1355 |
*/ |
| 1356 |
|
| 1357 |
|
| 1358 |
function insertAfter(node, preceding) { |
| 1359 |
var next = preceding.nextSibling; |
| 1360 |
var parent = preceding.parentNode; |
| 1361 |
|
| 1362 |
if (next) { |
| 1363 |
parent.insertBefore(node, next); |
| 1364 |
} else { |
| 1365 |
parent.appendChild(node); |
| 1366 |
} |
| 1367 |
|
| 1368 |
return node; |
| 1369 |
} |
| 1370 |
/** |
| 1371 |
* append elements. |
| 1372 |
* |
| 1373 |
* @param {Node} node |
| 1374 |
* @param {Collection} aChild |
| 1375 |
*/ |
| 1376 |
|
| 1377 |
|
| 1378 |
function appendChildNodes(node, aChild) { |
| 1379 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(aChild, function (idx, child) { |
| 1380 |
node.appendChild(child); |
| 1381 |
}); |
| 1382 |
return node; |
| 1383 |
} |
| 1384 |
/** |
| 1385 |
* returns whether boundaryPoint is left edge or not. |
| 1386 |
* |
| 1387 |
* @param {BoundaryPoint} point |
| 1388 |
* @return {Boolean} |
| 1389 |
*/ |
| 1390 |
|
| 1391 |
|
| 1392 |
function isLeftEdgePoint(point) { |
| 1393 |
return point.offset === 0; |
| 1394 |
} |
| 1395 |
/** |
| 1396 |
* returns whether boundaryPoint is right edge or not. |
| 1397 |
* |
| 1398 |
* @param {BoundaryPoint} point |
| 1399 |
* @return {Boolean} |
| 1400 |
*/ |
| 1401 |
|
| 1402 |
|
| 1403 |
function isRightEdgePoint(point) { |
| 1404 |
return point.offset === nodeLength(point.node); |
| 1405 |
} |
| 1406 |
/** |
| 1407 |
* returns whether boundaryPoint is edge or not. |
| 1408 |
* |
| 1409 |
* @param {BoundaryPoint} point |
| 1410 |
* @return {Boolean} |
| 1411 |
*/ |
| 1412 |
|
| 1413 |
|
| 1414 |
function isEdgePoint(point) { |
| 1415 |
return isLeftEdgePoint(point) || isRightEdgePoint(point); |
| 1416 |
} |
| 1417 |
/** |
| 1418 |
* returns whether node is left edge of ancestor or not. |
| 1419 |
* |
| 1420 |
* @param {Node} node |
| 1421 |
* @param {Node} ancestor |
| 1422 |
* @return {Boolean} |
| 1423 |
*/ |
| 1424 |
|
| 1425 |
|
| 1426 |
function dom_isLeftEdgeOf(node, ancestor) { |
| 1427 |
while (node && node !== ancestor) { |
| 1428 |
if (dom_position(node) !== 0) { |
| 1429 |
return false; |
| 1430 |
} |
| 1431 |
|
| 1432 |
node = node.parentNode; |
| 1433 |
} |
| 1434 |
|
| 1435 |
return true; |
| 1436 |
} |
| 1437 |
/** |
| 1438 |
* returns whether node is right edge of ancestor or not. |
| 1439 |
* |
| 1440 |
* @param {Node} node |
| 1441 |
* @param {Node} ancestor |
| 1442 |
* @return {Boolean} |
| 1443 |
*/ |
| 1444 |
|
| 1445 |
|
| 1446 |
function isRightEdgeOf(node, ancestor) { |
| 1447 |
if (!ancestor) { |
| 1448 |
return false; |
| 1449 |
} |
| 1450 |
|
| 1451 |
while (node && node !== ancestor) { |
| 1452 |
if (dom_position(node) !== nodeLength(node.parentNode) - 1) { |
| 1453 |
return false; |
| 1454 |
} |
| 1455 |
|
| 1456 |
node = node.parentNode; |
| 1457 |
} |
| 1458 |
|
| 1459 |
return true; |
| 1460 |
} |
| 1461 |
/** |
| 1462 |
* returns whether point is left edge of ancestor or not. |
| 1463 |
* @param {BoundaryPoint} point |
| 1464 |
* @param {Node} ancestor |
| 1465 |
* @return {Boolean} |
| 1466 |
*/ |
| 1467 |
|
| 1468 |
|
| 1469 |
function isLeftEdgePointOf(point, ancestor) { |
| 1470 |
return isLeftEdgePoint(point) && dom_isLeftEdgeOf(point.node, ancestor); |
| 1471 |
} |
| 1472 |
/** |
| 1473 |
* returns whether point is right edge of ancestor or not. |
| 1474 |
* @param {BoundaryPoint} point |
| 1475 |
* @param {Node} ancestor |
| 1476 |
* @return {Boolean} |
| 1477 |
*/ |
| 1478 |
|
| 1479 |
|
| 1480 |
function isRightEdgePointOf(point, ancestor) { |
| 1481 |
return isRightEdgePoint(point) && isRightEdgeOf(point.node, ancestor); |
| 1482 |
} |
| 1483 |
/** |
| 1484 |
* returns offset from parent. |
| 1485 |
* |
| 1486 |
* @param {Node} node |
| 1487 |
*/ |
| 1488 |
|
| 1489 |
|
| 1490 |
function dom_position(node) { |
| 1491 |
var offset = 0; |
| 1492 |
|
| 1493 |
while (node = node.previousSibling) { |
| 1494 |
offset += 1; |
| 1495 |
} |
| 1496 |
|
| 1497 |
return offset; |
| 1498 |
} |
| 1499 |
|
| 1500 |
function hasChildren(node) { |
| 1501 |
return !!(node && node.childNodes && node.childNodes.length); |
| 1502 |
} |
| 1503 |
/** |
| 1504 |
* returns previous boundaryPoint |
| 1505 |
* |
| 1506 |
* @param {BoundaryPoint} point |
| 1507 |
* @param {Boolean} isSkipInnerOffset |
| 1508 |
* @return {BoundaryPoint} |
| 1509 |
*/ |
| 1510 |
|
| 1511 |
|
| 1512 |
function dom_prevPoint(point, isSkipInnerOffset) { |
| 1513 |
var node; |
| 1514 |
var offset; |
| 1515 |
|
| 1516 |
if (point.offset === 0) { |
| 1517 |
if (isEditable(point.node)) { |
| 1518 |
return null; |
| 1519 |
} |
| 1520 |
|
| 1521 |
node = point.node.parentNode; |
| 1522 |
offset = dom_position(point.node); |
| 1523 |
} else if (hasChildren(point.node)) { |
| 1524 |
node = point.node.childNodes[point.offset - 1]; |
| 1525 |
offset = nodeLength(node); |
| 1526 |
} else { |
| 1527 |
node = point.node; |
| 1528 |
offset = isSkipInnerOffset ? 0 : point.offset - 1; |
| 1529 |
} |
| 1530 |
|
| 1531 |
return { |
| 1532 |
node: node, |
| 1533 |
offset: offset |
| 1534 |
}; |
| 1535 |
} |
| 1536 |
/** |
| 1537 |
* returns next boundaryPoint |
| 1538 |
* |
| 1539 |
* @param {BoundaryPoint} point |
| 1540 |
* @param {Boolean} isSkipInnerOffset |
| 1541 |
* @return {BoundaryPoint} |
| 1542 |
*/ |
| 1543 |
|
| 1544 |
|
| 1545 |
function dom_nextPoint(point, isSkipInnerOffset) { |
| 1546 |
var node, offset; |
| 1547 |
|
| 1548 |
if (nodeLength(point.node) === point.offset) { |
| 1549 |
if (isEditable(point.node)) { |
| 1550 |
return null; |
| 1551 |
} |
| 1552 |
|
| 1553 |
var nextTextNode = getNextTextNode(point.node); |
| 1554 |
|
| 1555 |
if (nextTextNode) { |
| 1556 |
node = nextTextNode; |
| 1557 |
offset = 0; |
| 1558 |
} else { |
| 1559 |
node = point.node.parentNode; |
| 1560 |
offset = dom_position(point.node) + 1; |
| 1561 |
} |
| 1562 |
} else if (hasChildren(point.node)) { |
| 1563 |
node = point.node.childNodes[point.offset]; |
| 1564 |
offset = 0; |
| 1565 |
} else { |
| 1566 |
node = point.node; |
| 1567 |
offset = isSkipInnerOffset ? nodeLength(point.node) : point.offset + 1; |
| 1568 |
} |
| 1569 |
|
| 1570 |
return { |
| 1571 |
node: node, |
| 1572 |
offset: offset |
| 1573 |
}; |
| 1574 |
} |
| 1575 |
/** |
| 1576 |
* returns next boundaryPoint with empty node |
| 1577 |
* |
| 1578 |
* @param {BoundaryPoint} point |
| 1579 |
* @param {Boolean} isSkipInnerOffset |
| 1580 |
* @return {BoundaryPoint} |
| 1581 |
*/ |
| 1582 |
|
| 1583 |
|
| 1584 |
function nextPointWithEmptyNode(point, isSkipInnerOffset) { |
| 1585 |
var node, offset; // if node is empty string node, return current node's sibling. |
| 1586 |
|
| 1587 |
if (dom_isEmpty(point.node)) { |
| 1588 |
node = point.node.nextSibling; |
| 1589 |
offset = 0; |
| 1590 |
return { |
| 1591 |
node: node, |
| 1592 |
offset: offset |
| 1593 |
}; |
| 1594 |
} |
| 1595 |
|
| 1596 |
if (nodeLength(point.node) === point.offset) { |
| 1597 |
if (isEditable(point.node)) { |
| 1598 |
return null; |
| 1599 |
} |
| 1600 |
|
| 1601 |
var nextTextNode = getNextTextNode(point.node); |
| 1602 |
|
| 1603 |
if (nextTextNode) { |
| 1604 |
node = nextTextNode; |
| 1605 |
offset = 0; |
| 1606 |
} else { |
| 1607 |
node = point.node.parentNode; |
| 1608 |
offset = dom_position(point.node) + 1; |
| 1609 |
} // if next node is editable, return current node's sibling node. |
| 1610 |
|
| 1611 |
|
| 1612 |
if (isEditable(node)) { |
| 1613 |
node = point.node.nextSibling; |
| 1614 |
offset = 0; |
| 1615 |
} |
| 1616 |
} else if (hasChildren(point.node)) { |
| 1617 |
node = point.node.childNodes[point.offset]; |
| 1618 |
offset = 0; |
| 1619 |
|
| 1620 |
if (dom_isEmpty(node)) { |
| 1621 |
return null; |
| 1622 |
} |
| 1623 |
} else { |
| 1624 |
node = point.node; |
| 1625 |
offset = isSkipInnerOffset ? nodeLength(point.node) : point.offset + 1; |
| 1626 |
|
| 1627 |
if (dom_isEmpty(node)) { |
| 1628 |
return null; |
| 1629 |
} |
| 1630 |
} |
| 1631 |
|
| 1632 |
return { |
| 1633 |
node: node, |
| 1634 |
offset: offset |
| 1635 |
}; |
| 1636 |
} |
| 1637 |
/* |
| 1638 |
* returns the next Text node index or 0 if not found. |
| 1639 |
*/ |
| 1640 |
|
| 1641 |
|
| 1642 |
function getNextTextNode(actual) { |
| 1643 |
if (!actual.nextSibling) return undefined; |
| 1644 |
if (actual.parent !== actual.nextSibling.parent) return undefined; |
| 1645 |
if (isText(actual.nextSibling)) return actual.nextSibling; |
| 1646 |
return getNextTextNode(actual.nextSibling); |
| 1647 |
} |
| 1648 |
/** |
| 1649 |
* returns whether pointA and pointB is same or not. |
| 1650 |
* |
| 1651 |
* @param {BoundaryPoint} pointA |
| 1652 |
* @param {BoundaryPoint} pointB |
| 1653 |
* @return {Boolean} |
| 1654 |
*/ |
| 1655 |
|
| 1656 |
|
| 1657 |
function isSamePoint(pointA, pointB) { |
| 1658 |
return pointA.node === pointB.node && pointA.offset === pointB.offset; |
| 1659 |
} |
| 1660 |
/** |
| 1661 |
* returns whether point is visible (can set cursor) or not. |
| 1662 |
* |
| 1663 |
* @param {BoundaryPoint} point |
| 1664 |
* @return {Boolean} |
| 1665 |
*/ |
| 1666 |
|
| 1667 |
|
| 1668 |
function isVisiblePoint(point) { |
| 1669 |
if (isText(point.node) || !hasChildren(point.node) || dom_isEmpty(point.node)) { |
| 1670 |
return true; |
| 1671 |
} |
| 1672 |
|
| 1673 |
var leftNode = point.node.childNodes[point.offset - 1]; |
| 1674 |
var rightNode = point.node.childNodes[point.offset]; |
| 1675 |
|
| 1676 |
if ((!leftNode || isVoid(leftNode)) && (!rightNode || isVoid(rightNode))) { |
| 1677 |
return true; |
| 1678 |
} |
| 1679 |
|
| 1680 |
return false; |
| 1681 |
} |
| 1682 |
/** |
| 1683 |
* @method prevPointUtil |
| 1684 |
* |
| 1685 |
* @param {BoundaryPoint} point |
| 1686 |
* @param {Function} pred |
| 1687 |
* @return {BoundaryPoint} |
| 1688 |
*/ |
| 1689 |
|
| 1690 |
|
| 1691 |
function prevPointUntil(point, pred) { |
| 1692 |
while (point) { |
| 1693 |
if (pred(point)) { |
| 1694 |
return point; |
| 1695 |
} |
| 1696 |
|
| 1697 |
point = dom_prevPoint(point); |
| 1698 |
} |
| 1699 |
|
| 1700 |
return null; |
| 1701 |
} |
| 1702 |
/** |
| 1703 |
* @method nextPointUntil |
| 1704 |
* |
| 1705 |
* @param {BoundaryPoint} point |
| 1706 |
* @param {Function} pred |
| 1707 |
* @return {BoundaryPoint} |
| 1708 |
*/ |
| 1709 |
|
| 1710 |
|
| 1711 |
function nextPointUntil(point, pred) { |
| 1712 |
while (point) { |
| 1713 |
if (pred(point)) { |
| 1714 |
return point; |
| 1715 |
} |
| 1716 |
|
| 1717 |
point = dom_nextPoint(point); |
| 1718 |
} |
| 1719 |
|
| 1720 |
return null; |
| 1721 |
} |
| 1722 |
/** |
| 1723 |
* returns whether point has character or not. |
| 1724 |
* |
| 1725 |
* @param {Point} point |
| 1726 |
* @return {Boolean} |
| 1727 |
*/ |
| 1728 |
|
| 1729 |
|
| 1730 |
function isCharPoint(point) { |
| 1731 |
if (!isText(point.node)) { |
| 1732 |
return false; |
| 1733 |
} |
| 1734 |
|
| 1735 |
var ch = point.node.nodeValue.charAt(point.offset - 1); |
| 1736 |
return ch && ch !== ' ' && ch !== NBSP_CHAR; |
| 1737 |
} |
| 1738 |
/** |
| 1739 |
* returns whether point has space or not. |
| 1740 |
* |
| 1741 |
* @param {Point} point |
| 1742 |
* @return {Boolean} |
| 1743 |
*/ |
| 1744 |
|
| 1745 |
|
| 1746 |
function isSpacePoint(point) { |
| 1747 |
if (!isText(point.node)) { |
| 1748 |
return false; |
| 1749 |
} |
| 1750 |
|
| 1751 |
var ch = point.node.nodeValue.charAt(point.offset - 1); |
| 1752 |
return ch === ' ' || ch === NBSP_CHAR; |
| 1753 |
} |
| 1754 |
/** |
| 1755 |
* @method walkPoint |
| 1756 |
* |
| 1757 |
* @param {BoundaryPoint} startPoint |
| 1758 |
* @param {BoundaryPoint} endPoint |
| 1759 |
* @param {Function} handler |
| 1760 |
* @param {Boolean} isSkipInnerOffset |
| 1761 |
*/ |
| 1762 |
|
| 1763 |
|
| 1764 |
function walkPoint(startPoint, endPoint, handler, isSkipInnerOffset) { |
| 1765 |
var point = startPoint; |
| 1766 |
|
| 1767 |
while (point) { |
| 1768 |
handler(point); |
| 1769 |
|
| 1770 |
if (isSamePoint(point, endPoint)) { |
| 1771 |
break; |
| 1772 |
} |
| 1773 |
|
| 1774 |
var isSkipOffset = isSkipInnerOffset && startPoint.node !== point.node && endPoint.node !== point.node; |
| 1775 |
point = nextPointWithEmptyNode(point, isSkipOffset); |
| 1776 |
} |
| 1777 |
} |
| 1778 |
/** |
| 1779 |
* @method makeOffsetPath |
| 1780 |
* |
| 1781 |
* return offsetPath(array of offset) from ancestor |
| 1782 |
* |
| 1783 |
* @param {Node} ancestor - ancestor node |
| 1784 |
* @param {Node} node |
| 1785 |
*/ |
| 1786 |
|
| 1787 |
|
| 1788 |
function makeOffsetPath(ancestor, node) { |
| 1789 |
var ancestors = listAncestor(node, func.eq(ancestor)); |
| 1790 |
return ancestors.map(dom_position).reverse(); |
| 1791 |
} |
| 1792 |
/** |
| 1793 |
* @method fromOffsetPath |
| 1794 |
* |
| 1795 |
* return element from offsetPath(array of offset) |
| 1796 |
* |
| 1797 |
* @param {Node} ancestor - ancestor node |
| 1798 |
* @param {array} offsets - offsetPath |
| 1799 |
*/ |
| 1800 |
|
| 1801 |
|
| 1802 |
function fromOffsetPath(ancestor, offsets) { |
| 1803 |
var current = ancestor; |
| 1804 |
|
| 1805 |
for (var i = 0, len = offsets.length; i < len; i++) { |
| 1806 |
if (current.childNodes.length <= offsets[i]) { |
| 1807 |
current = current.childNodes[current.childNodes.length - 1]; |
| 1808 |
} else { |
| 1809 |
current = current.childNodes[offsets[i]]; |
| 1810 |
} |
| 1811 |
} |
| 1812 |
|
| 1813 |
return current; |
| 1814 |
} |
| 1815 |
/** |
| 1816 |
* @method splitNode |
| 1817 |
* |
| 1818 |
* split element or #text |
| 1819 |
* |
| 1820 |
* @param {BoundaryPoint} point |
| 1821 |
* @param {Object} [options] |
| 1822 |
* @param {Boolean} [options.isSkipPaddingBlankHTML] - default: false |
| 1823 |
* @param {Boolean} [options.isNotSplitEdgePoint] - default: false |
| 1824 |
* @param {Boolean} [options.isDiscardEmptySplits] - default: false |
| 1825 |
* @return {Node} right node of boundaryPoint |
| 1826 |
*/ |
| 1827 |
|
| 1828 |
|
| 1829 |
function splitNode(point, options) { |
| 1830 |
var isSkipPaddingBlankHTML = options && options.isSkipPaddingBlankHTML; |
| 1831 |
var isNotSplitEdgePoint = options && options.isNotSplitEdgePoint; |
| 1832 |
var isDiscardEmptySplits = options && options.isDiscardEmptySplits; |
| 1833 |
|
| 1834 |
if (isDiscardEmptySplits) { |
| 1835 |
isSkipPaddingBlankHTML = true; |
| 1836 |
} // edge case |
| 1837 |
|
| 1838 |
|
| 1839 |
if (isEdgePoint(point) && (isText(point.node) || isNotSplitEdgePoint)) { |
| 1840 |
if (isLeftEdgePoint(point)) { |
| 1841 |
return point.node; |
| 1842 |
} else if (isRightEdgePoint(point)) { |
| 1843 |
return point.node.nextSibling; |
| 1844 |
} |
| 1845 |
} // split #text |
| 1846 |
|
| 1847 |
|
| 1848 |
if (isText(point.node)) { |
| 1849 |
return point.node.splitText(point.offset); |
| 1850 |
} else { |
| 1851 |
var childNode = point.node.childNodes[point.offset]; |
| 1852 |
var clone = insertAfter(point.node.cloneNode(false), point.node); |
| 1853 |
appendChildNodes(clone, listNext(childNode)); |
| 1854 |
|
| 1855 |
if (!isSkipPaddingBlankHTML) { |
| 1856 |
paddingBlankHTML(point.node); |
| 1857 |
paddingBlankHTML(clone); |
| 1858 |
} |
| 1859 |
|
| 1860 |
if (isDiscardEmptySplits) { |
| 1861 |
if (dom_isEmpty(point.node)) { |
| 1862 |
remove(point.node); |
| 1863 |
} |
| 1864 |
|
| 1865 |
if (dom_isEmpty(clone)) { |
| 1866 |
remove(clone); |
| 1867 |
return point.node.nextSibling; |
| 1868 |
} |
| 1869 |
} |
| 1870 |
|
| 1871 |
return clone; |
| 1872 |
} |
| 1873 |
} |
| 1874 |
/** |
| 1875 |
* @method splitTree |
| 1876 |
* |
| 1877 |
* split tree by point |
| 1878 |
* |
| 1879 |
* @param {Node} root - split root |
| 1880 |
* @param {BoundaryPoint} point |
| 1881 |
* @param {Object} [options] |
| 1882 |
* @param {Boolean} [options.isSkipPaddingBlankHTML] - default: false |
| 1883 |
* @param {Boolean} [options.isNotSplitEdgePoint] - default: false |
| 1884 |
* @return {Node} right node of boundaryPoint |
| 1885 |
*/ |
| 1886 |
|
| 1887 |
|
| 1888 |
function splitTree(root, point, options) { |
| 1889 |
// ex) [#text, <span>, <p>] |
| 1890 |
var ancestors = listAncestor(point.node, func.eq(root)); |
| 1891 |
|
| 1892 |
if (!ancestors.length) { |
| 1893 |
return null; |
| 1894 |
} else if (ancestors.length === 1) { |
| 1895 |
return splitNode(point, options); |
| 1896 |
} |
| 1897 |
|
| 1898 |
return ancestors.reduce(function (node, parent) { |
| 1899 |
if (node === point.node) { |
| 1900 |
node = splitNode(point, options); |
| 1901 |
} |
| 1902 |
|
| 1903 |
return splitNode({ |
| 1904 |
node: parent, |
| 1905 |
offset: node ? dom_position(node) : nodeLength(parent) |
| 1906 |
}, options); |
| 1907 |
}); |
| 1908 |
} |
| 1909 |
/** |
| 1910 |
* split point |
| 1911 |
* |
| 1912 |
* @param {Point} point |
| 1913 |
* @param {Boolean} isInline |
| 1914 |
* @return {Object} |
| 1915 |
*/ |
| 1916 |
|
| 1917 |
|
| 1918 |
function splitPoint(point, isInline) { |
| 1919 |
// find splitRoot, container |
| 1920 |
// - inline: splitRoot is a child of paragraph |
| 1921 |
// - block: splitRoot is a child of bodyContainer |
| 1922 |
var pred = isInline ? isPara : isBodyContainer; |
| 1923 |
var ancestors = listAncestor(point.node, pred); |
| 1924 |
var topAncestor = lists.last(ancestors) || point.node; |
| 1925 |
var splitRoot, container; |
| 1926 |
|
| 1927 |
if (pred(topAncestor)) { |
| 1928 |
splitRoot = ancestors[ancestors.length - 2]; |
| 1929 |
container = topAncestor; |
| 1930 |
} else { |
| 1931 |
splitRoot = topAncestor; |
| 1932 |
container = splitRoot.parentNode; |
| 1933 |
} // if splitRoot is exists, split with splitTree |
| 1934 |
|
| 1935 |
|
| 1936 |
var pivot = splitRoot && splitTree(splitRoot, point, { |
| 1937 |
isSkipPaddingBlankHTML: isInline, |
| 1938 |
isNotSplitEdgePoint: isInline |
| 1939 |
}); // if container is point.node, find pivot with point.offset |
| 1940 |
|
| 1941 |
if (!pivot && container === point.node) { |
| 1942 |
pivot = point.node.childNodes[point.offset]; |
| 1943 |
} |
| 1944 |
|
| 1945 |
return { |
| 1946 |
rightNode: pivot, |
| 1947 |
container: container |
| 1948 |
}; |
| 1949 |
} |
| 1950 |
|
| 1951 |
function dom_create(nodeName) { |
| 1952 |
return document.createElement(nodeName); |
| 1953 |
} |
| 1954 |
|
| 1955 |
function createText(text) { |
| 1956 |
return document.createTextNode(text); |
| 1957 |
} |
| 1958 |
/** |
| 1959 |
* @method remove |
| 1960 |
* |
| 1961 |
* remove node, (isRemoveChild: remove child or not) |
| 1962 |
* |
| 1963 |
* @param {Node} node |
| 1964 |
* @param {Boolean} isRemoveChild |
| 1965 |
*/ |
| 1966 |
|
| 1967 |
|
| 1968 |
function remove(node, isRemoveChild) { |
| 1969 |
if (!node || !node.parentNode) { |
| 1970 |
return; |
| 1971 |
} |
| 1972 |
|
| 1973 |
if (node.removeNode) { |
| 1974 |
return node.removeNode(isRemoveChild); |
| 1975 |
} |
| 1976 |
|
| 1977 |
var parent = node.parentNode; |
| 1978 |
|
| 1979 |
if (!isRemoveChild) { |
| 1980 |
var nodes = []; |
| 1981 |
|
| 1982 |
for (var i = 0, len = node.childNodes.length; i < len; i++) { |
| 1983 |
nodes.push(node.childNodes[i]); |
| 1984 |
} |
| 1985 |
|
| 1986 |
for (var _i = 0, _len = nodes.length; _i < _len; _i++) { |
| 1987 |
parent.insertBefore(nodes[_i], node); |
| 1988 |
} |
| 1989 |
} |
| 1990 |
|
| 1991 |
parent.removeChild(node); |
| 1992 |
} |
| 1993 |
/** |
| 1994 |
* @method removeWhile |
| 1995 |
* |
| 1996 |
* @param {Node} node |
| 1997 |
* @param {Function} pred |
| 1998 |
*/ |
| 1999 |
|
| 2000 |
|
| 2001 |
function removeWhile(node, pred) { |
| 2002 |
while (node) { |
| 2003 |
if (isEditable(node) || !pred(node)) { |
| 2004 |
break; |
| 2005 |
} |
| 2006 |
|
| 2007 |
var parent = node.parentNode; |
| 2008 |
remove(node); |
| 2009 |
node = parent; |
| 2010 |
} |
| 2011 |
} |
| 2012 |
/** |
| 2013 |
* @method replace |
| 2014 |
* |
| 2015 |
* replace node with provided nodeName |
| 2016 |
* |
| 2017 |
* @param {Node} node |
| 2018 |
* @param {String} nodeName |
| 2019 |
* @return {Node} - new node |
| 2020 |
*/ |
| 2021 |
|
| 2022 |
|
| 2023 |
function dom_replace(node, nodeName) { |
| 2024 |
if (node.nodeName.toUpperCase() === nodeName.toUpperCase()) { |
| 2025 |
return node; |
| 2026 |
} |
| 2027 |
|
| 2028 |
var newNode = dom_create(nodeName); |
| 2029 |
|
| 2030 |
if (node.style.cssText) { |
| 2031 |
newNode.style.cssText = node.style.cssText; |
| 2032 |
} |
| 2033 |
|
| 2034 |
appendChildNodes(newNode, lists.from(node.childNodes)); |
| 2035 |
insertAfter(newNode, node); |
| 2036 |
remove(node); |
| 2037 |
return newNode; |
| 2038 |
} |
| 2039 |
|
| 2040 |
var isTextarea = makePredByNodeName('TEXTAREA'); |
| 2041 |
/** |
| 2042 |
* @param {jQuery} $node |
| 2043 |
* @param {Boolean} [stripLinebreaks] - default: false |
| 2044 |
*/ |
| 2045 |
|
| 2046 |
function dom_value($node, stripLinebreaks) { |
| 2047 |
var val = isTextarea($node[0]) ? $node.val() : $node.html(); |
| 2048 |
|
| 2049 |
if (stripLinebreaks) { |
| 2050 |
return val.replace(/[\n\r]/g, ''); |
| 2051 |
} |
| 2052 |
|
| 2053 |
return val; |
| 2054 |
} |
| 2055 |
/** |
| 2056 |
* @method html |
| 2057 |
* |
| 2058 |
* get the HTML contents of node |
| 2059 |
* |
| 2060 |
* @param {jQuery} $node |
| 2061 |
* @param {Boolean} [isNewlineOnBlock] |
| 2062 |
*/ |
| 2063 |
|
| 2064 |
|
| 2065 |
function dom_html($node, isNewlineOnBlock) { |
| 2066 |
var markup = dom_value($node); |
| 2067 |
|
| 2068 |
if (isNewlineOnBlock) { |
| 2069 |
var regexTag = /<(\/?)(\b(?!!)[^>\s]*)(.*?)(\s*\/?>)/g; |
| 2070 |
markup = markup.replace(regexTag, function (match, endSlash, name) { |
| 2071 |
name = name.toUpperCase(); |
| 2072 |
var isEndOfInlineContainer = /^DIV|^TD|^TH|^P|^LI|^H[1-7]/.test(name) && !!endSlash; |
| 2073 |
var isBlockNode = /^BLOCKQUOTE|^TABLE|^TBODY|^TR|^HR|^UL|^OL/.test(name); |
| 2074 |
return match + (isEndOfInlineContainer || isBlockNode ? '\n' : ''); |
| 2075 |
}); |
| 2076 |
markup = markup.trim(); |
| 2077 |
} |
| 2078 |
|
| 2079 |
return markup; |
| 2080 |
} |
| 2081 |
|
| 2082 |
function posFromPlaceholder(placeholder) { |
| 2083 |
var $placeholder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(placeholder); |
| 2084 |
var pos = $placeholder.offset(); |
| 2085 |
var height = $placeholder.outerHeight(true); // include margin |
| 2086 |
|
| 2087 |
return { |
| 2088 |
left: pos.left, |
| 2089 |
top: pos.top + height |
| 2090 |
}; |
| 2091 |
} |
| 2092 |
|
| 2093 |
function attachEvents($node, events) { |
| 2094 |
Object.keys(events).forEach(function (key) { |
| 2095 |
$node.on(key, events[key]); |
| 2096 |
}); |
| 2097 |
} |
| 2098 |
|
| 2099 |
function detachEvents($node, events) { |
| 2100 |
Object.keys(events).forEach(function (key) { |
| 2101 |
$node.off(key, events[key]); |
| 2102 |
}); |
| 2103 |
} |
| 2104 |
/** |
| 2105 |
* @method isCustomStyleTag |
| 2106 |
* |
| 2107 |
* assert if a node contains a "note-styletag" class, |
| 2108 |
* which implies that's a custom-made style tag node |
| 2109 |
* |
| 2110 |
* @param {Node} an HTML DOM node |
| 2111 |
*/ |
| 2112 |
|
| 2113 |
|
| 2114 |
function isCustomStyleTag(node) { |
| 2115 |
return node && !isText(node) && lists.contains(node.classList, 'note-styletag'); |
| 2116 |
} |
| 2117 |
|
| 2118 |
/* harmony default export */ var dom = ({ |
| 2119 |
/** @property {String} NBSP_CHAR */ |
| 2120 |
NBSP_CHAR: NBSP_CHAR, |
| 2121 |
|
| 2122 |
/** @property {String} ZERO_WIDTH_NBSP_CHAR */ |
| 2123 |
ZERO_WIDTH_NBSP_CHAR: ZERO_WIDTH_NBSP_CHAR, |
| 2124 |
|
| 2125 |
/** @property {String} blank */ |
| 2126 |
blank: blankHTML, |
| 2127 |
|
| 2128 |
/** @property {String} emptyPara */ |
| 2129 |
emptyPara: "<p>".concat(blankHTML, "</p>"), |
| 2130 |
makePredByNodeName: makePredByNodeName, |
| 2131 |
isEditable: isEditable, |
| 2132 |
isControlSizing: isControlSizing, |
| 2133 |
isText: isText, |
| 2134 |
isElement: isElement, |
| 2135 |
isVoid: isVoid, |
| 2136 |
isPara: isPara, |
| 2137 |
isPurePara: isPurePara, |
| 2138 |
isHeading: isHeading, |
| 2139 |
isInline: dom_isInline, |
| 2140 |
isBlock: func.not(dom_isInline), |
| 2141 |
isBodyInline: isBodyInline, |
| 2142 |
isBody: isBody, |
| 2143 |
isParaInline: isParaInline, |
| 2144 |
isPre: isPre, |
| 2145 |
isList: isList, |
| 2146 |
isTable: isTable, |
| 2147 |
isData: isData, |
| 2148 |
isCell: dom_isCell, |
| 2149 |
isBlockquote: isBlockquote, |
| 2150 |
isBodyContainer: isBodyContainer, |
| 2151 |
isAnchor: isAnchor, |
| 2152 |
isDiv: makePredByNodeName('DIV'), |
| 2153 |
isLi: isLi, |
| 2154 |
isBR: makePredByNodeName('BR'), |
| 2155 |
isSpan: makePredByNodeName('SPAN'), |
| 2156 |
isB: makePredByNodeName('B'), |
| 2157 |
isU: makePredByNodeName('U'), |
| 2158 |
isS: makePredByNodeName('S'), |
| 2159 |
isI: makePredByNodeName('I'), |
| 2160 |
isImg: makePredByNodeName('IMG'), |
| 2161 |
isTextarea: isTextarea, |
| 2162 |
deepestChildIsEmpty: deepestChildIsEmpty, |
| 2163 |
isEmpty: dom_isEmpty, |
| 2164 |
isEmptyAnchor: func.and(isAnchor, dom_isEmpty), |
| 2165 |
isClosestSibling: isClosestSibling, |
| 2166 |
withClosestSiblings: withClosestSiblings, |
| 2167 |
nodeLength: nodeLength, |
| 2168 |
isLeftEdgePoint: isLeftEdgePoint, |
| 2169 |
isRightEdgePoint: isRightEdgePoint, |
| 2170 |
isEdgePoint: isEdgePoint, |
| 2171 |
isLeftEdgeOf: dom_isLeftEdgeOf, |
| 2172 |
isRightEdgeOf: isRightEdgeOf, |
| 2173 |
isLeftEdgePointOf: isLeftEdgePointOf, |
| 2174 |
isRightEdgePointOf: isRightEdgePointOf, |
| 2175 |
prevPoint: dom_prevPoint, |
| 2176 |
nextPoint: dom_nextPoint, |
| 2177 |
nextPointWithEmptyNode: nextPointWithEmptyNode, |
| 2178 |
isSamePoint: isSamePoint, |
| 2179 |
isVisiblePoint: isVisiblePoint, |
| 2180 |
prevPointUntil: prevPointUntil, |
| 2181 |
nextPointUntil: nextPointUntil, |
| 2182 |
isCharPoint: isCharPoint, |
| 2183 |
isSpacePoint: isSpacePoint, |
| 2184 |
walkPoint: walkPoint, |
| 2185 |
ancestor: dom_ancestor, |
| 2186 |
singleChildAncestor: singleChildAncestor, |
| 2187 |
listAncestor: listAncestor, |
| 2188 |
lastAncestor: lastAncestor, |
| 2189 |
listNext: listNext, |
| 2190 |
listPrev: listPrev, |
| 2191 |
listDescendant: listDescendant, |
| 2192 |
commonAncestor: dom_commonAncestor, |
| 2193 |
wrap: wrap, |
| 2194 |
insertAfter: insertAfter, |
| 2195 |
appendChildNodes: appendChildNodes, |
| 2196 |
position: dom_position, |
| 2197 |
hasChildren: hasChildren, |
| 2198 |
makeOffsetPath: makeOffsetPath, |
| 2199 |
fromOffsetPath: fromOffsetPath, |
| 2200 |
splitTree: splitTree, |
| 2201 |
splitPoint: splitPoint, |
| 2202 |
create: dom_create, |
| 2203 |
createText: createText, |
| 2204 |
remove: remove, |
| 2205 |
removeWhile: removeWhile, |
| 2206 |
replace: dom_replace, |
| 2207 |
html: dom_html, |
| 2208 |
value: dom_value, |
| 2209 |
posFromPlaceholder: posFromPlaceholder, |
| 2210 |
attachEvents: attachEvents, |
| 2211 |
detachEvents: detachEvents, |
| 2212 |
isCustomStyleTag: isCustomStyleTag |
| 2213 |
}); |
| 2214 |
// CONCATENATED MODULE: ./src/js/base/Context.js |
| 2215 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 2216 |
|
| 2217 |
function _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); } } |
| 2218 |
|
| 2219 |
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } |
| 2220 |
|
| 2221 |
|
| 2222 |
|
| 2223 |
|
| 2224 |
|
| 2225 |
|
| 2226 |
var Context_Context = /*#__PURE__*/function () { |
| 2227 |
/** |
| 2228 |
* @param {jQuery} $note |
| 2229 |
* @param {Object} options |
| 2230 |
*/ |
| 2231 |
function Context($note, options) { |
| 2232 |
_classCallCheck(this, Context); |
| 2233 |
|
| 2234 |
this.$note = $note; |
| 2235 |
this.memos = {}; |
| 2236 |
this.modules = {}; |
| 2237 |
this.layoutInfo = {}; |
| 2238 |
this.options = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(true, {}, options); // init ui with options |
| 2239 |
|
| 2240 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui_template(this.options); |
| 2241 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 2242 |
this.initialize(); |
| 2243 |
} |
| 2244 |
/** |
| 2245 |
* create layout and initialize modules and other resources |
| 2246 |
*/ |
| 2247 |
|
| 2248 |
|
| 2249 |
_createClass(Context, [{ |
| 2250 |
key: "initialize", |
| 2251 |
value: function initialize() { |
| 2252 |
this.layoutInfo = this.ui.createLayout(this.$note); |
| 2253 |
|
| 2254 |
this._initialize(); |
| 2255 |
|
| 2256 |
this.$note.hide(); |
| 2257 |
return this; |
| 2258 |
} |
| 2259 |
/** |
| 2260 |
* destroy modules and other resources and remove layout |
| 2261 |
*/ |
| 2262 |
|
| 2263 |
}, { |
| 2264 |
key: "destroy", |
| 2265 |
value: function destroy() { |
| 2266 |
this._destroy(); |
| 2267 |
|
| 2268 |
this.$note.removeData('summernote'); |
| 2269 |
this.ui.removeLayout(this.$note, this.layoutInfo); |
| 2270 |
} |
| 2271 |
/** |
| 2272 |
* destory modules and other resources and initialize it again |
| 2273 |
*/ |
| 2274 |
|
| 2275 |
}, { |
| 2276 |
key: "reset", |
| 2277 |
value: function reset() { |
| 2278 |
var disabled = this.isDisabled(); |
| 2279 |
this.code(dom.emptyPara); |
| 2280 |
|
| 2281 |
this._destroy(); |
| 2282 |
|
| 2283 |
this._initialize(); |
| 2284 |
|
| 2285 |
if (disabled) { |
| 2286 |
this.disable(); |
| 2287 |
} |
| 2288 |
} |
| 2289 |
}, { |
| 2290 |
key: "_initialize", |
| 2291 |
value: function _initialize() { |
| 2292 |
var _this = this; |
| 2293 |
|
| 2294 |
// set own id |
| 2295 |
this.options.id = func.uniqueId(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.now()); // set default container for tooltips, popovers, and dialogs |
| 2296 |
|
| 2297 |
this.options.container = this.options.container || this.layoutInfo.editor; // add optional buttons |
| 2298 |
|
| 2299 |
var buttons = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend({}, this.options.buttons); |
| 2300 |
Object.keys(buttons).forEach(function (key) { |
| 2301 |
_this.memo('button.' + key, buttons[key]); |
| 2302 |
}); |
| 2303 |
var modules = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend({}, this.options.modules, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.plugins || {}); // add and initialize modules |
| 2304 |
|
| 2305 |
Object.keys(modules).forEach(function (key) { |
| 2306 |
_this.module(key, modules[key], true); |
| 2307 |
}); |
| 2308 |
Object.keys(this.modules).forEach(function (key) { |
| 2309 |
_this.initializeModule(key); |
| 2310 |
}); |
| 2311 |
} |
| 2312 |
}, { |
| 2313 |
key: "_destroy", |
| 2314 |
value: function _destroy() { |
| 2315 |
var _this2 = this; |
| 2316 |
|
| 2317 |
// destroy modules with reversed order |
| 2318 |
Object.keys(this.modules).reverse().forEach(function (key) { |
| 2319 |
_this2.removeModule(key); |
| 2320 |
}); |
| 2321 |
Object.keys(this.memos).forEach(function (key) { |
| 2322 |
_this2.removeMemo(key); |
| 2323 |
}); // trigger custom onDestroy callback |
| 2324 |
|
| 2325 |
this.triggerEvent('destroy', this); |
| 2326 |
} |
| 2327 |
}, { |
| 2328 |
key: "code", |
| 2329 |
value: function code(html) { |
| 2330 |
var isActivated = this.invoke('codeview.isActivated'); |
| 2331 |
|
| 2332 |
if (html === undefined) { |
| 2333 |
this.invoke('codeview.sync'); |
| 2334 |
return isActivated ? this.layoutInfo.codable.val() : this.layoutInfo.editable.html(); |
| 2335 |
} else { |
| 2336 |
if (isActivated) { |
| 2337 |
this.invoke('codeview.sync', html); |
| 2338 |
} else { |
| 2339 |
this.layoutInfo.editable.html(html); |
| 2340 |
} |
| 2341 |
|
| 2342 |
this.$note.val(html); |
| 2343 |
this.triggerEvent('change', html, this.layoutInfo.editable); |
| 2344 |
} |
| 2345 |
} |
| 2346 |
}, { |
| 2347 |
key: "isDisabled", |
| 2348 |
value: function isDisabled() { |
| 2349 |
return this.layoutInfo.editable.attr('contenteditable') === 'false'; |
| 2350 |
} |
| 2351 |
}, { |
| 2352 |
key: "enable", |
| 2353 |
value: function enable() { |
| 2354 |
this.layoutInfo.editable.attr('contenteditable', true); |
| 2355 |
this.invoke('toolbar.activate', true); |
| 2356 |
this.triggerEvent('disable', false); |
| 2357 |
this.options.editing = true; |
| 2358 |
} |
| 2359 |
}, { |
| 2360 |
key: "disable", |
| 2361 |
value: function disable() { |
| 2362 |
// close codeview if codeview is opend |
| 2363 |
if (this.invoke('codeview.isActivated')) { |
| 2364 |
this.invoke('codeview.deactivate'); |
| 2365 |
} |
| 2366 |
|
| 2367 |
this.layoutInfo.editable.attr('contenteditable', false); |
| 2368 |
this.options.editing = false; |
| 2369 |
this.invoke('toolbar.deactivate', true); |
| 2370 |
this.triggerEvent('disable', true); |
| 2371 |
} |
| 2372 |
}, { |
| 2373 |
key: "triggerEvent", |
| 2374 |
value: function triggerEvent() { |
| 2375 |
var namespace = lists.head(arguments); |
| 2376 |
var args = lists.tail(lists.from(arguments)); |
| 2377 |
var callback = this.options.callbacks[func.namespaceToCamel(namespace, 'on')]; |
| 2378 |
|
| 2379 |
if (callback) { |
| 2380 |
callback.apply(this.$note[0], args); |
| 2381 |
} |
| 2382 |
|
| 2383 |
this.$note.trigger('summernote.' + namespace, args); |
| 2384 |
} |
| 2385 |
}, { |
| 2386 |
key: "initializeModule", |
| 2387 |
value: function initializeModule(key) { |
| 2388 |
var module = this.modules[key]; |
| 2389 |
module.shouldInitialize = module.shouldInitialize || func.ok; |
| 2390 |
|
| 2391 |
if (!module.shouldInitialize()) { |
| 2392 |
return; |
| 2393 |
} // initialize module |
| 2394 |
|
| 2395 |
|
| 2396 |
if (module.initialize) { |
| 2397 |
module.initialize(); |
| 2398 |
} // attach events |
| 2399 |
|
| 2400 |
|
| 2401 |
if (module.events) { |
| 2402 |
dom.attachEvents(this.$note, module.events); |
| 2403 |
} |
| 2404 |
} |
| 2405 |
}, { |
| 2406 |
key: "module", |
| 2407 |
value: function module(key, ModuleClass, withoutIntialize) { |
| 2408 |
if (arguments.length === 1) { |
| 2409 |
return this.modules[key]; |
| 2410 |
} |
| 2411 |
|
| 2412 |
this.modules[key] = new ModuleClass(this); |
| 2413 |
|
| 2414 |
if (!withoutIntialize) { |
| 2415 |
this.initializeModule(key); |
| 2416 |
} |
| 2417 |
} |
| 2418 |
}, { |
| 2419 |
key: "removeModule", |
| 2420 |
value: function removeModule(key) { |
| 2421 |
var module = this.modules[key]; |
| 2422 |
|
| 2423 |
if (module.shouldInitialize()) { |
| 2424 |
if (module.events) { |
| 2425 |
dom.detachEvents(this.$note, module.events); |
| 2426 |
} |
| 2427 |
|
| 2428 |
if (module.destroy) { |
| 2429 |
module.destroy(); |
| 2430 |
} |
| 2431 |
} |
| 2432 |
|
| 2433 |
delete this.modules[key]; |
| 2434 |
} |
| 2435 |
}, { |
| 2436 |
key: "memo", |
| 2437 |
value: function memo(key, obj) { |
| 2438 |
if (arguments.length === 1) { |
| 2439 |
return this.memos[key]; |
| 2440 |
} |
| 2441 |
|
| 2442 |
this.memos[key] = obj; |
| 2443 |
} |
| 2444 |
}, { |
| 2445 |
key: "removeMemo", |
| 2446 |
value: function removeMemo(key) { |
| 2447 |
if (this.memos[key] && this.memos[key].destroy) { |
| 2448 |
this.memos[key].destroy(); |
| 2449 |
} |
| 2450 |
|
| 2451 |
delete this.memos[key]; |
| 2452 |
} |
| 2453 |
/** |
| 2454 |
* Some buttons need to change their visual style immediately once they get pressed |
| 2455 |
*/ |
| 2456 |
|
| 2457 |
}, { |
| 2458 |
key: "createInvokeHandlerAndUpdateState", |
| 2459 |
value: function createInvokeHandlerAndUpdateState(namespace, value) { |
| 2460 |
var _this3 = this; |
| 2461 |
|
| 2462 |
return function (event) { |
| 2463 |
_this3.createInvokeHandler(namespace, value)(event); |
| 2464 |
|
| 2465 |
_this3.invoke('buttons.updateCurrentStyle'); |
| 2466 |
}; |
| 2467 |
} |
| 2468 |
}, { |
| 2469 |
key: "createInvokeHandler", |
| 2470 |
value: function createInvokeHandler(namespace, value) { |
| 2471 |
var _this4 = this; |
| 2472 |
|
| 2473 |
return function (event) { |
| 2474 |
event.preventDefault(); |
| 2475 |
var $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target); |
| 2476 |
|
| 2477 |
_this4.invoke(namespace, value || $target.closest('[data-value]').data('value'), $target); |
| 2478 |
}; |
| 2479 |
} |
| 2480 |
}, { |
| 2481 |
key: "invoke", |
| 2482 |
value: function invoke() { |
| 2483 |
var namespace = lists.head(arguments); |
| 2484 |
var args = lists.tail(lists.from(arguments)); |
| 2485 |
var splits = namespace.split('.'); |
| 2486 |
var hasSeparator = splits.length > 1; |
| 2487 |
var moduleName = hasSeparator && lists.head(splits); |
| 2488 |
var methodName = hasSeparator ? lists.last(splits) : lists.head(splits); |
| 2489 |
var module = this.modules[moduleName || 'editor']; |
| 2490 |
|
| 2491 |
if (!moduleName && this[methodName]) { |
| 2492 |
return this[methodName].apply(this, args); |
| 2493 |
} else if (module && module[methodName] && module.shouldInitialize()) { |
| 2494 |
return module[methodName].apply(module, args); |
| 2495 |
} |
| 2496 |
} |
| 2497 |
}]); |
| 2498 |
|
| 2499 |
return Context; |
| 2500 |
}(); |
| 2501 |
|
| 2502 |
|
| 2503 |
// CONCATENATED MODULE: ./src/js/summernote.js |
| 2504 |
|
| 2505 |
|
| 2506 |
|
| 2507 |
|
| 2508 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.fn.extend({ |
| 2509 |
/** |
| 2510 |
* Summernote API |
| 2511 |
* |
| 2512 |
* @param {Object|String} |
| 2513 |
* @return {this} |
| 2514 |
*/ |
| 2515 |
summernote: function summernote() { |
| 2516 |
var type = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.type(lists.head(arguments)); |
| 2517 |
var isExternalAPICalled = type === 'string'; |
| 2518 |
var hasInitOptions = type === 'object'; |
| 2519 |
var options = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend({}, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.options, hasInitOptions ? lists.head(arguments) : {}); // Update options |
| 2520 |
|
| 2521 |
options.langInfo = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(true, {}, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.lang['en-US'], external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.lang[options.lang]); |
| 2522 |
options.icons = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(true, {}, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.options.icons, options.icons); |
| 2523 |
options.tooltip = options.tooltip === 'auto' ? !env.isSupportTouch : options.tooltip; |
| 2524 |
this.each(function (idx, note) { |
| 2525 |
var $note = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(note); |
| 2526 |
|
| 2527 |
if (!$note.data('summernote')) { |
| 2528 |
var context = new Context_Context($note, options); |
| 2529 |
$note.data('summernote', context); |
| 2530 |
$note.data('summernote').triggerEvent('init', context.layoutInfo); |
| 2531 |
} |
| 2532 |
}); |
| 2533 |
var $note = this.first(); |
| 2534 |
|
| 2535 |
if ($note.length) { |
| 2536 |
var context = $note.data('summernote'); |
| 2537 |
|
| 2538 |
if (isExternalAPICalled) { |
| 2539 |
return context.invoke.apply(context, lists.from(arguments)); |
| 2540 |
} else if (options.focus) { |
| 2541 |
context.invoke('editor.focus'); |
| 2542 |
} |
| 2543 |
} |
| 2544 |
|
| 2545 |
return this; |
| 2546 |
} |
| 2547 |
}); |
| 2548 |
// CONCATENATED MODULE: ./src/js/base/core/range.js |
| 2549 |
function range_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 2550 |
|
| 2551 |
function range_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); } } |
| 2552 |
|
| 2553 |
function range_createClass(Constructor, protoProps, staticProps) { if (protoProps) range_defineProperties(Constructor.prototype, protoProps); if (staticProps) range_defineProperties(Constructor, staticProps); return Constructor; } |
| 2554 |
|
| 2555 |
|
| 2556 |
|
| 2557 |
|
| 2558 |
|
| 2559 |
|
| 2560 |
/** |
| 2561 |
* return boundaryPoint from TextRange, inspired by Andy Na's HuskyRange.js |
| 2562 |
* |
| 2563 |
* @param {TextRange} textRange |
| 2564 |
* @param {Boolean} isStart |
| 2565 |
* @return {BoundaryPoint} |
| 2566 |
* |
| 2567 |
* @see http://msdn.microsoft.com/en-us/library/ie/ms535872(v=vs.85).aspx |
| 2568 |
*/ |
| 2569 |
|
| 2570 |
function textRangeToPoint(textRange, isStart) { |
| 2571 |
var container = textRange.parentElement(); |
| 2572 |
var offset; |
| 2573 |
var tester = document.body.createTextRange(); |
| 2574 |
var prevContainer; |
| 2575 |
var childNodes = lists.from(container.childNodes); |
| 2576 |
|
| 2577 |
for (offset = 0; offset < childNodes.length; offset++) { |
| 2578 |
if (dom.isText(childNodes[offset])) { |
| 2579 |
continue; |
| 2580 |
} |
| 2581 |
|
| 2582 |
tester.moveToElementText(childNodes[offset]); |
| 2583 |
|
| 2584 |
if (tester.compareEndPoints('StartToStart', textRange) >= 0) { |
| 2585 |
break; |
| 2586 |
} |
| 2587 |
|
| 2588 |
prevContainer = childNodes[offset]; |
| 2589 |
} |
| 2590 |
|
| 2591 |
if (offset !== 0 && dom.isText(childNodes[offset - 1])) { |
| 2592 |
var textRangeStart = document.body.createTextRange(); |
| 2593 |
var curTextNode = null; |
| 2594 |
textRangeStart.moveToElementText(prevContainer || container); |
| 2595 |
textRangeStart.collapse(!prevContainer); |
| 2596 |
curTextNode = prevContainer ? prevContainer.nextSibling : container.firstChild; |
| 2597 |
var pointTester = textRange.duplicate(); |
| 2598 |
pointTester.setEndPoint('StartToStart', textRangeStart); |
| 2599 |
var textCount = pointTester.text.replace(/[\r\n]/g, '').length; |
| 2600 |
|
| 2601 |
while (textCount > curTextNode.nodeValue.length && curTextNode.nextSibling) { |
| 2602 |
textCount -= curTextNode.nodeValue.length; |
| 2603 |
curTextNode = curTextNode.nextSibling; |
| 2604 |
} // [workaround] enforce IE to re-reference curTextNode, hack |
| 2605 |
|
| 2606 |
|
| 2607 |
var dummy = curTextNode.nodeValue; // eslint-disable-line |
| 2608 |
|
| 2609 |
if (isStart && curTextNode.nextSibling && dom.isText(curTextNode.nextSibling) && textCount === curTextNode.nodeValue.length) { |
| 2610 |
textCount -= curTextNode.nodeValue.length; |
| 2611 |
curTextNode = curTextNode.nextSibling; |
| 2612 |
} |
| 2613 |
|
| 2614 |
container = curTextNode; |
| 2615 |
offset = textCount; |
| 2616 |
} |
| 2617 |
|
| 2618 |
return { |
| 2619 |
cont: container, |
| 2620 |
offset: offset |
| 2621 |
}; |
| 2622 |
} |
| 2623 |
/** |
| 2624 |
* return TextRange from boundary point (inspired by google closure-library) |
| 2625 |
* @param {BoundaryPoint} point |
| 2626 |
* @return {TextRange} |
| 2627 |
*/ |
| 2628 |
|
| 2629 |
|
| 2630 |
function pointToTextRange(point) { |
| 2631 |
var textRangeInfo = function textRangeInfo(container, offset) { |
| 2632 |
var node, isCollapseToStart; |
| 2633 |
|
| 2634 |
if (dom.isText(container)) { |
| 2635 |
var prevTextNodes = dom.listPrev(container, func.not(dom.isText)); |
| 2636 |
var prevContainer = lists.last(prevTextNodes).previousSibling; |
| 2637 |
node = prevContainer || container.parentNode; |
| 2638 |
offset += lists.sum(lists.tail(prevTextNodes), dom.nodeLength); |
| 2639 |
isCollapseToStart = !prevContainer; |
| 2640 |
} else { |
| 2641 |
node = container.childNodes[offset] || container; |
| 2642 |
|
| 2643 |
if (dom.isText(node)) { |
| 2644 |
return textRangeInfo(node, 0); |
| 2645 |
} |
| 2646 |
|
| 2647 |
offset = 0; |
| 2648 |
isCollapseToStart = false; |
| 2649 |
} |
| 2650 |
|
| 2651 |
return { |
| 2652 |
node: node, |
| 2653 |
collapseToStart: isCollapseToStart, |
| 2654 |
offset: offset |
| 2655 |
}; |
| 2656 |
}; |
| 2657 |
|
| 2658 |
var textRange = document.body.createTextRange(); |
| 2659 |
var info = textRangeInfo(point.node, point.offset); |
| 2660 |
textRange.moveToElementText(info.node); |
| 2661 |
textRange.collapse(info.collapseToStart); |
| 2662 |
textRange.moveStart('character', info.offset); |
| 2663 |
return textRange; |
| 2664 |
} |
| 2665 |
/** |
| 2666 |
* Wrapped Range |
| 2667 |
* |
| 2668 |
* @constructor |
| 2669 |
* @param {Node} sc - start container |
| 2670 |
* @param {Number} so - start offset |
| 2671 |
* @param {Node} ec - end container |
| 2672 |
* @param {Number} eo - end offset |
| 2673 |
*/ |
| 2674 |
|
| 2675 |
|
| 2676 |
var range_WrappedRange = /*#__PURE__*/function () { |
| 2677 |
function WrappedRange(sc, so, ec, eo) { |
| 2678 |
range_classCallCheck(this, WrappedRange); |
| 2679 |
|
| 2680 |
this.sc = sc; |
| 2681 |
this.so = so; |
| 2682 |
this.ec = ec; |
| 2683 |
this.eo = eo; // isOnEditable: judge whether range is on editable or not |
| 2684 |
|
| 2685 |
this.isOnEditable = this.makeIsOn(dom.isEditable); // isOnList: judge whether range is on list node or not |
| 2686 |
|
| 2687 |
this.isOnList = this.makeIsOn(dom.isList); // isOnAnchor: judge whether range is on anchor node or not |
| 2688 |
|
| 2689 |
this.isOnAnchor = this.makeIsOn(dom.isAnchor); // isOnCell: judge whether range is on cell node or not |
| 2690 |
|
| 2691 |
this.isOnCell = this.makeIsOn(dom.isCell); // isOnData: judge whether range is on data node or not |
| 2692 |
|
| 2693 |
this.isOnData = this.makeIsOn(dom.isData); |
| 2694 |
} // nativeRange: get nativeRange from sc, so, ec, eo |
| 2695 |
|
| 2696 |
|
| 2697 |
range_createClass(WrappedRange, [{ |
| 2698 |
key: "nativeRange", |
| 2699 |
value: function nativeRange() { |
| 2700 |
if (env.isW3CRangeSupport) { |
| 2701 |
var w3cRange = document.createRange(); |
| 2702 |
w3cRange.setStart(this.sc, this.so); |
| 2703 |
w3cRange.setEnd(this.ec, this.eo); |
| 2704 |
return w3cRange; |
| 2705 |
} else { |
| 2706 |
var textRange = pointToTextRange({ |
| 2707 |
node: this.sc, |
| 2708 |
offset: this.so |
| 2709 |
}); |
| 2710 |
textRange.setEndPoint('EndToEnd', pointToTextRange({ |
| 2711 |
node: this.ec, |
| 2712 |
offset: this.eo |
| 2713 |
})); |
| 2714 |
return textRange; |
| 2715 |
} |
| 2716 |
} |
| 2717 |
}, { |
| 2718 |
key: "getPoints", |
| 2719 |
value: function getPoints() { |
| 2720 |
return { |
| 2721 |
sc: this.sc, |
| 2722 |
so: this.so, |
| 2723 |
ec: this.ec, |
| 2724 |
eo: this.eo |
| 2725 |
}; |
| 2726 |
} |
| 2727 |
}, { |
| 2728 |
key: "getStartPoint", |
| 2729 |
value: function getStartPoint() { |
| 2730 |
return { |
| 2731 |
node: this.sc, |
| 2732 |
offset: this.so |
| 2733 |
}; |
| 2734 |
} |
| 2735 |
}, { |
| 2736 |
key: "getEndPoint", |
| 2737 |
value: function getEndPoint() { |
| 2738 |
return { |
| 2739 |
node: this.ec, |
| 2740 |
offset: this.eo |
| 2741 |
}; |
| 2742 |
} |
| 2743 |
/** |
| 2744 |
* select update visible range |
| 2745 |
*/ |
| 2746 |
|
| 2747 |
}, { |
| 2748 |
key: "select", |
| 2749 |
value: function select() { |
| 2750 |
var nativeRng = this.nativeRange(); |
| 2751 |
|
| 2752 |
if (env.isW3CRangeSupport) { |
| 2753 |
var selection = document.getSelection(); |
| 2754 |
|
| 2755 |
if (selection.rangeCount > 0) { |
| 2756 |
selection.removeAllRanges(); |
| 2757 |
} |
| 2758 |
|
| 2759 |
selection.addRange(nativeRng); |
| 2760 |
} else { |
| 2761 |
nativeRng.select(); |
| 2762 |
} |
| 2763 |
|
| 2764 |
return this; |
| 2765 |
} |
| 2766 |
/** |
| 2767 |
* Moves the scrollbar to start container(sc) of current range |
| 2768 |
* |
| 2769 |
* @return {WrappedRange} |
| 2770 |
*/ |
| 2771 |
|
| 2772 |
}, { |
| 2773 |
key: "scrollIntoView", |
| 2774 |
value: function scrollIntoView(container) { |
| 2775 |
var height = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(container).height(); |
| 2776 |
|
| 2777 |
if (container.scrollTop + height < this.sc.offsetTop) { |
| 2778 |
container.scrollTop += Math.abs(container.scrollTop + height - this.sc.offsetTop); |
| 2779 |
} |
| 2780 |
|
| 2781 |
return this; |
| 2782 |
} |
| 2783 |
/** |
| 2784 |
* @return {WrappedRange} |
| 2785 |
*/ |
| 2786 |
|
| 2787 |
}, { |
| 2788 |
key: "normalize", |
| 2789 |
value: function normalize() { |
| 2790 |
/** |
| 2791 |
* @param {BoundaryPoint} point |
| 2792 |
* @param {Boolean} isLeftToRight - true: prefer to choose right node |
| 2793 |
* - false: prefer to choose left node |
| 2794 |
* @return {BoundaryPoint} |
| 2795 |
*/ |
| 2796 |
var getVisiblePoint = function getVisiblePoint(point, isLeftToRight) { |
| 2797 |
if (!point) { |
| 2798 |
return point; |
| 2799 |
} // Just use the given point [XXX:Adhoc] |
| 2800 |
// - case 01. if the point is on the middle of the node |
| 2801 |
// - case 02. if the point is on the right edge and prefer to choose left node |
| 2802 |
// - case 03. if the point is on the left edge and prefer to choose right node |
| 2803 |
// - case 04. if the point is on the right edge and prefer to choose right node but the node is void |
| 2804 |
// - case 05. if the point is on the left edge and prefer to choose left node but the node is void |
| 2805 |
// - case 06. if the point is on the block node and there is no children |
| 2806 |
|
| 2807 |
|
| 2808 |
if (dom.isVisiblePoint(point)) { |
| 2809 |
if (!dom.isEdgePoint(point) || dom.isRightEdgePoint(point) && !isLeftToRight || dom.isLeftEdgePoint(point) && isLeftToRight || dom.isRightEdgePoint(point) && isLeftToRight && dom.isVoid(point.node.nextSibling) || dom.isLeftEdgePoint(point) && !isLeftToRight && dom.isVoid(point.node.previousSibling) || dom.isBlock(point.node) && dom.isEmpty(point.node)) { |
| 2810 |
return point; |
| 2811 |
} |
| 2812 |
} // point on block's edge |
| 2813 |
|
| 2814 |
|
| 2815 |
var block = dom.ancestor(point.node, dom.isBlock); |
| 2816 |
var hasRightNode = false; |
| 2817 |
|
| 2818 |
if (!hasRightNode) { |
| 2819 |
var prevPoint = dom.prevPoint(point) || { |
| 2820 |
node: null |
| 2821 |
}; |
| 2822 |
hasRightNode = (dom.isLeftEdgePointOf(point, block) || dom.isVoid(prevPoint.node)) && !isLeftToRight; |
| 2823 |
} |
| 2824 |
|
| 2825 |
var hasLeftNode = false; |
| 2826 |
|
| 2827 |
if (!hasLeftNode) { |
| 2828 |
var _nextPoint = dom.nextPoint(point) || { |
| 2829 |
node: null |
| 2830 |
}; |
| 2831 |
|
| 2832 |
hasLeftNode = (dom.isRightEdgePointOf(point, block) || dom.isVoid(_nextPoint.node)) && isLeftToRight; |
| 2833 |
} |
| 2834 |
|
| 2835 |
if (hasRightNode || hasLeftNode) { |
| 2836 |
// returns point already on visible point |
| 2837 |
if (dom.isVisiblePoint(point)) { |
| 2838 |
return point; |
| 2839 |
} // reverse direction |
| 2840 |
|
| 2841 |
|
| 2842 |
isLeftToRight = !isLeftToRight; |
| 2843 |
} |
| 2844 |
|
| 2845 |
var nextPoint = isLeftToRight ? dom.nextPointUntil(dom.nextPoint(point), dom.isVisiblePoint) : dom.prevPointUntil(dom.prevPoint(point), dom.isVisiblePoint); |
| 2846 |
return nextPoint || point; |
| 2847 |
}; |
| 2848 |
|
| 2849 |
var endPoint = getVisiblePoint(this.getEndPoint(), false); |
| 2850 |
var startPoint = this.isCollapsed() ? endPoint : getVisiblePoint(this.getStartPoint(), true); |
| 2851 |
return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset); |
| 2852 |
} |
| 2853 |
/** |
| 2854 |
* returns matched nodes on range |
| 2855 |
* |
| 2856 |
* @param {Function} [pred] - predicate function |
| 2857 |
* @param {Object} [options] |
| 2858 |
* @param {Boolean} [options.includeAncestor] |
| 2859 |
* @param {Boolean} [options.fullyContains] |
| 2860 |
* @return {Node[]} |
| 2861 |
*/ |
| 2862 |
|
| 2863 |
}, { |
| 2864 |
key: "nodes", |
| 2865 |
value: function nodes(pred, options) { |
| 2866 |
pred = pred || func.ok; |
| 2867 |
var includeAncestor = options && options.includeAncestor; |
| 2868 |
var fullyContains = options && options.fullyContains; // TODO compare points and sort |
| 2869 |
|
| 2870 |
var startPoint = this.getStartPoint(); |
| 2871 |
var endPoint = this.getEndPoint(); |
| 2872 |
var nodes = []; |
| 2873 |
var leftEdgeNodes = []; |
| 2874 |
dom.walkPoint(startPoint, endPoint, function (point) { |
| 2875 |
if (dom.isEditable(point.node)) { |
| 2876 |
return; |
| 2877 |
} |
| 2878 |
|
| 2879 |
var node; |
| 2880 |
|
| 2881 |
if (fullyContains) { |
| 2882 |
if (dom.isLeftEdgePoint(point)) { |
| 2883 |
leftEdgeNodes.push(point.node); |
| 2884 |
} |
| 2885 |
|
| 2886 |
if (dom.isRightEdgePoint(point) && lists.contains(leftEdgeNodes, point.node)) { |
| 2887 |
node = point.node; |
| 2888 |
} |
| 2889 |
} else if (includeAncestor) { |
| 2890 |
node = dom.ancestor(point.node, pred); |
| 2891 |
} else { |
| 2892 |
node = point.node; |
| 2893 |
} |
| 2894 |
|
| 2895 |
if (node && pred(node)) { |
| 2896 |
nodes.push(node); |
| 2897 |
} |
| 2898 |
}, true); |
| 2899 |
return lists.unique(nodes); |
| 2900 |
} |
| 2901 |
/** |
| 2902 |
* returns commonAncestor of range |
| 2903 |
* @return {Element} - commonAncestor |
| 2904 |
*/ |
| 2905 |
|
| 2906 |
}, { |
| 2907 |
key: "commonAncestor", |
| 2908 |
value: function commonAncestor() { |
| 2909 |
return dom.commonAncestor(this.sc, this.ec); |
| 2910 |
} |
| 2911 |
/** |
| 2912 |
* returns expanded range by pred |
| 2913 |
* |
| 2914 |
* @param {Function} pred - predicate function |
| 2915 |
* @return {WrappedRange} |
| 2916 |
*/ |
| 2917 |
|
| 2918 |
}, { |
| 2919 |
key: "expand", |
| 2920 |
value: function expand(pred) { |
| 2921 |
var startAncestor = dom.ancestor(this.sc, pred); |
| 2922 |
var endAncestor = dom.ancestor(this.ec, pred); |
| 2923 |
|
| 2924 |
if (!startAncestor && !endAncestor) { |
| 2925 |
return new WrappedRange(this.sc, this.so, this.ec, this.eo); |
| 2926 |
} |
| 2927 |
|
| 2928 |
var boundaryPoints = this.getPoints(); |
| 2929 |
|
| 2930 |
if (startAncestor) { |
| 2931 |
boundaryPoints.sc = startAncestor; |
| 2932 |
boundaryPoints.so = 0; |
| 2933 |
} |
| 2934 |
|
| 2935 |
if (endAncestor) { |
| 2936 |
boundaryPoints.ec = endAncestor; |
| 2937 |
boundaryPoints.eo = dom.nodeLength(endAncestor); |
| 2938 |
} |
| 2939 |
|
| 2940 |
return new WrappedRange(boundaryPoints.sc, boundaryPoints.so, boundaryPoints.ec, boundaryPoints.eo); |
| 2941 |
} |
| 2942 |
/** |
| 2943 |
* @param {Boolean} isCollapseToStart |
| 2944 |
* @return {WrappedRange} |
| 2945 |
*/ |
| 2946 |
|
| 2947 |
}, { |
| 2948 |
key: "collapse", |
| 2949 |
value: function collapse(isCollapseToStart) { |
| 2950 |
if (isCollapseToStart) { |
| 2951 |
return new WrappedRange(this.sc, this.so, this.sc, this.so); |
| 2952 |
} else { |
| 2953 |
return new WrappedRange(this.ec, this.eo, this.ec, this.eo); |
| 2954 |
} |
| 2955 |
} |
| 2956 |
/** |
| 2957 |
* splitText on range |
| 2958 |
*/ |
| 2959 |
|
| 2960 |
}, { |
| 2961 |
key: "splitText", |
| 2962 |
value: function splitText() { |
| 2963 |
var isSameContainer = this.sc === this.ec; |
| 2964 |
var boundaryPoints = this.getPoints(); |
| 2965 |
|
| 2966 |
if (dom.isText(this.ec) && !dom.isEdgePoint(this.getEndPoint())) { |
| 2967 |
this.ec.splitText(this.eo); |
| 2968 |
} |
| 2969 |
|
| 2970 |
if (dom.isText(this.sc) && !dom.isEdgePoint(this.getStartPoint())) { |
| 2971 |
boundaryPoints.sc = this.sc.splitText(this.so); |
| 2972 |
boundaryPoints.so = 0; |
| 2973 |
|
| 2974 |
if (isSameContainer) { |
| 2975 |
boundaryPoints.ec = boundaryPoints.sc; |
| 2976 |
boundaryPoints.eo = this.eo - this.so; |
| 2977 |
} |
| 2978 |
} |
| 2979 |
|
| 2980 |
return new WrappedRange(boundaryPoints.sc, boundaryPoints.so, boundaryPoints.ec, boundaryPoints.eo); |
| 2981 |
} |
| 2982 |
/** |
| 2983 |
* delete contents on range |
| 2984 |
* @return {WrappedRange} |
| 2985 |
*/ |
| 2986 |
|
| 2987 |
}, { |
| 2988 |
key: "deleteContents", |
| 2989 |
value: function deleteContents() { |
| 2990 |
if (this.isCollapsed()) { |
| 2991 |
return this; |
| 2992 |
} |
| 2993 |
|
| 2994 |
var rng = this.splitText(); |
| 2995 |
var nodes = rng.nodes(null, { |
| 2996 |
fullyContains: true |
| 2997 |
}); // find new cursor point |
| 2998 |
|
| 2999 |
var point = dom.prevPointUntil(rng.getStartPoint(), function (point) { |
| 3000 |
return !lists.contains(nodes, point.node); |
| 3001 |
}); |
| 3002 |
var emptyParents = []; |
| 3003 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(nodes, function (idx, node) { |
| 3004 |
// find empty parents |
| 3005 |
var parent = node.parentNode; |
| 3006 |
|
| 3007 |
if (point.node !== parent && dom.nodeLength(parent) === 1) { |
| 3008 |
emptyParents.push(parent); |
| 3009 |
} |
| 3010 |
|
| 3011 |
dom.remove(node, false); |
| 3012 |
}); // remove empty parents |
| 3013 |
|
| 3014 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(emptyParents, function (idx, node) { |
| 3015 |
dom.remove(node, false); |
| 3016 |
}); |
| 3017 |
return new WrappedRange(point.node, point.offset, point.node, point.offset).normalize(); |
| 3018 |
} |
| 3019 |
/** |
| 3020 |
* makeIsOn: return isOn(pred) function |
| 3021 |
*/ |
| 3022 |
|
| 3023 |
}, { |
| 3024 |
key: "makeIsOn", |
| 3025 |
value: function makeIsOn(pred) { |
| 3026 |
return function () { |
| 3027 |
var ancestor = dom.ancestor(this.sc, pred); |
| 3028 |
return !!ancestor && ancestor === dom.ancestor(this.ec, pred); |
| 3029 |
}; |
| 3030 |
} |
| 3031 |
/** |
| 3032 |
* @param {Function} pred |
| 3033 |
* @return {Boolean} |
| 3034 |
*/ |
| 3035 |
|
| 3036 |
}, { |
| 3037 |
key: "isLeftEdgeOf", |
| 3038 |
value: function isLeftEdgeOf(pred) { |
| 3039 |
if (!dom.isLeftEdgePoint(this.getStartPoint())) { |
| 3040 |
return false; |
| 3041 |
} |
| 3042 |
|
| 3043 |
var node = dom.ancestor(this.sc, pred); |
| 3044 |
return node && dom.isLeftEdgeOf(this.sc, node); |
| 3045 |
} |
| 3046 |
/** |
| 3047 |
* returns whether range was collapsed or not |
| 3048 |
*/ |
| 3049 |
|
| 3050 |
}, { |
| 3051 |
key: "isCollapsed", |
| 3052 |
value: function isCollapsed() { |
| 3053 |
return this.sc === this.ec && this.so === this.eo; |
| 3054 |
} |
| 3055 |
/** |
| 3056 |
* wrap inline nodes which children of body with paragraph |
| 3057 |
* |
| 3058 |
* @return {WrappedRange} |
| 3059 |
*/ |
| 3060 |
|
| 3061 |
}, { |
| 3062 |
key: "wrapBodyInlineWithPara", |
| 3063 |
value: function wrapBodyInlineWithPara() { |
| 3064 |
if (dom.isBodyContainer(this.sc) && dom.isEmpty(this.sc)) { |
| 3065 |
this.sc.innerHTML = dom.emptyPara; |
| 3066 |
return new WrappedRange(this.sc.firstChild, 0, this.sc.firstChild, 0); |
| 3067 |
} |
| 3068 |
/** |
| 3069 |
* [workaround] firefox often create range on not visible point. so normalize here. |
| 3070 |
* - firefox: |<p>text</p>| |
| 3071 |
* - chrome: <p>|text|</p> |
| 3072 |
*/ |
| 3073 |
|
| 3074 |
|
| 3075 |
var rng = this.normalize(); |
| 3076 |
|
| 3077 |
if (dom.isParaInline(this.sc) || dom.isPara(this.sc)) { |
| 3078 |
return rng; |
| 3079 |
} // find inline top ancestor |
| 3080 |
|
| 3081 |
|
| 3082 |
var topAncestor; |
| 3083 |
|
| 3084 |
if (dom.isInline(rng.sc)) { |
| 3085 |
var ancestors = dom.listAncestor(rng.sc, func.not(dom.isInline)); |
| 3086 |
topAncestor = lists.last(ancestors); |
| 3087 |
|
| 3088 |
if (!dom.isInline(topAncestor)) { |
| 3089 |
topAncestor = ancestors[ancestors.length - 2] || rng.sc.childNodes[rng.so]; |
| 3090 |
} |
| 3091 |
} else { |
| 3092 |
topAncestor = rng.sc.childNodes[rng.so > 0 ? rng.so - 1 : 0]; |
| 3093 |
} |
| 3094 |
|
| 3095 |
if (topAncestor) { |
| 3096 |
// siblings not in paragraph |
| 3097 |
var inlineSiblings = dom.listPrev(topAncestor, dom.isParaInline).reverse(); |
| 3098 |
inlineSiblings = inlineSiblings.concat(dom.listNext(topAncestor.nextSibling, dom.isParaInline)); // wrap with paragraph |
| 3099 |
|
| 3100 |
if (inlineSiblings.length) { |
| 3101 |
var para = dom.wrap(lists.head(inlineSiblings), 'p'); |
| 3102 |
dom.appendChildNodes(para, lists.tail(inlineSiblings)); |
| 3103 |
} |
| 3104 |
} |
| 3105 |
|
| 3106 |
return this.normalize(); |
| 3107 |
} |
| 3108 |
/** |
| 3109 |
* insert node at current cursor |
| 3110 |
* |
| 3111 |
* @param {Node} node |
| 3112 |
* @return {Node} |
| 3113 |
*/ |
| 3114 |
|
| 3115 |
}, { |
| 3116 |
key: "insertNode", |
| 3117 |
value: function insertNode(node) { |
| 3118 |
var rng = this; |
| 3119 |
|
| 3120 |
if (dom.isText(node) || dom.isInline(node)) { |
| 3121 |
rng = this.wrapBodyInlineWithPara().deleteContents(); |
| 3122 |
} |
| 3123 |
|
| 3124 |
var info = dom.splitPoint(rng.getStartPoint(), dom.isInline(node)); |
| 3125 |
|
| 3126 |
if (info.rightNode) { |
| 3127 |
info.rightNode.parentNode.insertBefore(node, info.rightNode); |
| 3128 |
|
| 3129 |
if (dom.isEmpty(info.rightNode) && dom.isPara(node)) { |
| 3130 |
info.rightNode.parentNode.removeChild(info.rightNode); |
| 3131 |
} |
| 3132 |
} else { |
| 3133 |
info.container.appendChild(node); |
| 3134 |
} |
| 3135 |
|
| 3136 |
return node; |
| 3137 |
} |
| 3138 |
/** |
| 3139 |
* insert html at current cursor |
| 3140 |
*/ |
| 3141 |
|
| 3142 |
}, { |
| 3143 |
key: "pasteHTML", |
| 3144 |
value: function pasteHTML(markup) { |
| 3145 |
markup = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.trim(markup); |
| 3146 |
var contentsContainer = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div></div>').html(markup)[0]; |
| 3147 |
var childNodes = lists.from(contentsContainer.childNodes); // const rng = this.wrapBodyInlineWithPara().deleteContents(); |
| 3148 |
|
| 3149 |
var rng = this; |
| 3150 |
var reversed = false; |
| 3151 |
|
| 3152 |
if (rng.so >= 0) { |
| 3153 |
childNodes = childNodes.reverse(); |
| 3154 |
reversed = true; |
| 3155 |
} |
| 3156 |
|
| 3157 |
childNodes = childNodes.map(function (childNode) { |
| 3158 |
return rng.insertNode(childNode); |
| 3159 |
}); |
| 3160 |
|
| 3161 |
if (reversed) { |
| 3162 |
childNodes = childNodes.reverse(); |
| 3163 |
} |
| 3164 |
|
| 3165 |
return childNodes; |
| 3166 |
} |
| 3167 |
/** |
| 3168 |
* returns text in range |
| 3169 |
* |
| 3170 |
* @return {String} |
| 3171 |
*/ |
| 3172 |
|
| 3173 |
}, { |
| 3174 |
key: "toString", |
| 3175 |
value: function toString() { |
| 3176 |
var nativeRng = this.nativeRange(); |
| 3177 |
return env.isW3CRangeSupport ? nativeRng.toString() : nativeRng.text; |
| 3178 |
} |
| 3179 |
/** |
| 3180 |
* returns range for word before cursor |
| 3181 |
* |
| 3182 |
* @param {Boolean} [findAfter] - find after cursor, default: false |
| 3183 |
* @return {WrappedRange} |
| 3184 |
*/ |
| 3185 |
|
| 3186 |
}, { |
| 3187 |
key: "getWordRange", |
| 3188 |
value: function getWordRange(findAfter) { |
| 3189 |
var endPoint = this.getEndPoint(); |
| 3190 |
|
| 3191 |
if (!dom.isCharPoint(endPoint)) { |
| 3192 |
return this; |
| 3193 |
} |
| 3194 |
|
| 3195 |
var startPoint = dom.prevPointUntil(endPoint, function (point) { |
| 3196 |
return !dom.isCharPoint(point); |
| 3197 |
}); |
| 3198 |
|
| 3199 |
if (findAfter) { |
| 3200 |
endPoint = dom.nextPointUntil(endPoint, function (point) { |
| 3201 |
return !dom.isCharPoint(point); |
| 3202 |
}); |
| 3203 |
} |
| 3204 |
|
| 3205 |
return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset); |
| 3206 |
} |
| 3207 |
/** |
| 3208 |
* returns range for words before cursor |
| 3209 |
* |
| 3210 |
* @param {Boolean} [findAfter] - find after cursor, default: false |
| 3211 |
* @return {WrappedRange} |
| 3212 |
*/ |
| 3213 |
|
| 3214 |
}, { |
| 3215 |
key: "getWordsRange", |
| 3216 |
value: function getWordsRange(findAfter) { |
| 3217 |
var endPoint = this.getEndPoint(); |
| 3218 |
|
| 3219 |
var isNotTextPoint = function isNotTextPoint(point) { |
| 3220 |
return !dom.isCharPoint(point) && !dom.isSpacePoint(point); |
| 3221 |
}; |
| 3222 |
|
| 3223 |
if (isNotTextPoint(endPoint)) { |
| 3224 |
return this; |
| 3225 |
} |
| 3226 |
|
| 3227 |
var startPoint = dom.prevPointUntil(endPoint, isNotTextPoint); |
| 3228 |
|
| 3229 |
if (findAfter) { |
| 3230 |
endPoint = dom.nextPointUntil(endPoint, isNotTextPoint); |
| 3231 |
} |
| 3232 |
|
| 3233 |
return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset); |
| 3234 |
} |
| 3235 |
/** |
| 3236 |
* returns range for words before cursor that match with a Regex |
| 3237 |
* |
| 3238 |
* example: |
| 3239 |
* range: 'hi @Peter Pan' |
| 3240 |
* regex: '/@[a-z ]+/i' |
| 3241 |
* return range: '@Peter Pan' |
| 3242 |
* |
| 3243 |
* @param {RegExp} [regex] |
| 3244 |
* @return {WrappedRange|null} |
| 3245 |
*/ |
| 3246 |
|
| 3247 |
}, { |
| 3248 |
key: "getWordsMatchRange", |
| 3249 |
value: function getWordsMatchRange(regex) { |
| 3250 |
var endPoint = this.getEndPoint(); |
| 3251 |
var startPoint = dom.prevPointUntil(endPoint, function (point) { |
| 3252 |
if (!dom.isCharPoint(point) && !dom.isSpacePoint(point)) { |
| 3253 |
return true; |
| 3254 |
} |
| 3255 |
|
| 3256 |
var rng = new WrappedRange(point.node, point.offset, endPoint.node, endPoint.offset); |
| 3257 |
var result = regex.exec(rng.toString()); |
| 3258 |
return result && result.index === 0; |
| 3259 |
}); |
| 3260 |
var rng = new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset); |
| 3261 |
var text = rng.toString(); |
| 3262 |
var result = regex.exec(text); |
| 3263 |
|
| 3264 |
if (result && result[0].length === text.length) { |
| 3265 |
return rng; |
| 3266 |
} else { |
| 3267 |
return null; |
| 3268 |
} |
| 3269 |
} |
| 3270 |
/** |
| 3271 |
* create offsetPath bookmark |
| 3272 |
* |
| 3273 |
* @param {Node} editable |
| 3274 |
*/ |
| 3275 |
|
| 3276 |
}, { |
| 3277 |
key: "bookmark", |
| 3278 |
value: function bookmark(editable) { |
| 3279 |
return { |
| 3280 |
s: { |
| 3281 |
path: dom.makeOffsetPath(editable, this.sc), |
| 3282 |
offset: this.so |
| 3283 |
}, |
| 3284 |
e: { |
| 3285 |
path: dom.makeOffsetPath(editable, this.ec), |
| 3286 |
offset: this.eo |
| 3287 |
} |
| 3288 |
}; |
| 3289 |
} |
| 3290 |
/** |
| 3291 |
* create offsetPath bookmark base on paragraph |
| 3292 |
* |
| 3293 |
* @param {Node[]} paras |
| 3294 |
*/ |
| 3295 |
|
| 3296 |
}, { |
| 3297 |
key: "paraBookmark", |
| 3298 |
value: function paraBookmark(paras) { |
| 3299 |
return { |
| 3300 |
s: { |
| 3301 |
path: lists.tail(dom.makeOffsetPath(lists.head(paras), this.sc)), |
| 3302 |
offset: this.so |
| 3303 |
}, |
| 3304 |
e: { |
| 3305 |
path: lists.tail(dom.makeOffsetPath(lists.last(paras), this.ec)), |
| 3306 |
offset: this.eo |
| 3307 |
} |
| 3308 |
}; |
| 3309 |
} |
| 3310 |
/** |
| 3311 |
* getClientRects |
| 3312 |
* @return {Rect[]} |
| 3313 |
*/ |
| 3314 |
|
| 3315 |
}, { |
| 3316 |
key: "getClientRects", |
| 3317 |
value: function getClientRects() { |
| 3318 |
var nativeRng = this.nativeRange(); |
| 3319 |
return nativeRng.getClientRects(); |
| 3320 |
} |
| 3321 |
}]); |
| 3322 |
|
| 3323 |
return WrappedRange; |
| 3324 |
}(); |
| 3325 |
/** |
| 3326 |
* Data structure |
| 3327 |
* * BoundaryPoint: a point of dom tree |
| 3328 |
* * BoundaryPoints: two boundaryPoints corresponding to the start and the end of the Range |
| 3329 |
* |
| 3330 |
* See to http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Position |
| 3331 |
*/ |
| 3332 |
|
| 3333 |
|
| 3334 |
/* harmony default export */ var range = ({ |
| 3335 |
/** |
| 3336 |
* create Range Object From arguments or Browser Selection |
| 3337 |
* |
| 3338 |
* @param {Node} sc - start container |
| 3339 |
* @param {Number} so - start offset |
| 3340 |
* @param {Node} ec - end container |
| 3341 |
* @param {Number} eo - end offset |
| 3342 |
* @return {WrappedRange} |
| 3343 |
*/ |
| 3344 |
create: function create(sc, so, ec, eo) { |
| 3345 |
if (arguments.length === 4) { |
| 3346 |
return new range_WrappedRange(sc, so, ec, eo); |
| 3347 |
} else if (arguments.length === 2) { |
| 3348 |
// collapsed |
| 3349 |
ec = sc; |
| 3350 |
eo = so; |
| 3351 |
return new range_WrappedRange(sc, so, ec, eo); |
| 3352 |
} else { |
| 3353 |
var wrappedRange = this.createFromSelection(); |
| 3354 |
|
| 3355 |
if (!wrappedRange && arguments.length === 1) { |
| 3356 |
var bodyElement = arguments[0]; |
| 3357 |
|
| 3358 |
if (dom.isEditable(bodyElement)) { |
| 3359 |
bodyElement = bodyElement.lastChild; |
| 3360 |
} |
| 3361 |
|
| 3362 |
return this.createFromBodyElement(bodyElement, dom.emptyPara === arguments[0].innerHTML); |
| 3363 |
} |
| 3364 |
|
| 3365 |
return wrappedRange; |
| 3366 |
} |
| 3367 |
}, |
| 3368 |
createFromBodyElement: function createFromBodyElement(bodyElement) { |
| 3369 |
var isCollapseToStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 3370 |
var wrappedRange = this.createFromNode(bodyElement); |
| 3371 |
return wrappedRange.collapse(isCollapseToStart); |
| 3372 |
}, |
| 3373 |
createFromSelection: function createFromSelection() { |
| 3374 |
var sc, so, ec, eo; |
| 3375 |
|
| 3376 |
if (env.isW3CRangeSupport) { |
| 3377 |
var selection = document.getSelection(); |
| 3378 |
|
| 3379 |
if (!selection || selection.rangeCount === 0) { |
| 3380 |
return null; |
| 3381 |
} else if (dom.isBody(selection.anchorNode)) { |
| 3382 |
// Firefox: returns entire body as range on initialization. |
| 3383 |
// We won't never need it. |
| 3384 |
return null; |
| 3385 |
} |
| 3386 |
|
| 3387 |
var nativeRng = selection.getRangeAt(0); |
| 3388 |
sc = nativeRng.startContainer; |
| 3389 |
so = nativeRng.startOffset; |
| 3390 |
ec = nativeRng.endContainer; |
| 3391 |
eo = nativeRng.endOffset; |
| 3392 |
} else { |
| 3393 |
// IE8: TextRange |
| 3394 |
var textRange = document.selection.createRange(); |
| 3395 |
var textRangeEnd = textRange.duplicate(); |
| 3396 |
textRangeEnd.collapse(false); |
| 3397 |
var textRangeStart = textRange; |
| 3398 |
textRangeStart.collapse(true); |
| 3399 |
var startPoint = textRangeToPoint(textRangeStart, true); |
| 3400 |
var endPoint = textRangeToPoint(textRangeEnd, false); // same visible point case: range was collapsed. |
| 3401 |
|
| 3402 |
if (dom.isText(startPoint.node) && dom.isLeftEdgePoint(startPoint) && dom.isTextNode(endPoint.node) && dom.isRightEdgePoint(endPoint) && endPoint.node.nextSibling === startPoint.node) { |
| 3403 |
startPoint = endPoint; |
| 3404 |
} |
| 3405 |
|
| 3406 |
sc = startPoint.cont; |
| 3407 |
so = startPoint.offset; |
| 3408 |
ec = endPoint.cont; |
| 3409 |
eo = endPoint.offset; |
| 3410 |
} |
| 3411 |
|
| 3412 |
return new range_WrappedRange(sc, so, ec, eo); |
| 3413 |
}, |
| 3414 |
|
| 3415 |
/** |
| 3416 |
* @method |
| 3417 |
* |
| 3418 |
* create WrappedRange from node |
| 3419 |
* |
| 3420 |
* @param {Node} node |
| 3421 |
* @return {WrappedRange} |
| 3422 |
*/ |
| 3423 |
createFromNode: function createFromNode(node) { |
| 3424 |
var sc = node; |
| 3425 |
var so = 0; |
| 3426 |
var ec = node; |
| 3427 |
var eo = dom.nodeLength(ec); // browsers can't target a picture or void node |
| 3428 |
|
| 3429 |
if (dom.isVoid(sc)) { |
| 3430 |
so = dom.listPrev(sc).length - 1; |
| 3431 |
sc = sc.parentNode; |
| 3432 |
} |
| 3433 |
|
| 3434 |
if (dom.isBR(ec)) { |
| 3435 |
eo = dom.listPrev(ec).length - 1; |
| 3436 |
ec = ec.parentNode; |
| 3437 |
} else if (dom.isVoid(ec)) { |
| 3438 |
eo = dom.listPrev(ec).length; |
| 3439 |
ec = ec.parentNode; |
| 3440 |
} |
| 3441 |
|
| 3442 |
return this.create(sc, so, ec, eo); |
| 3443 |
}, |
| 3444 |
|
| 3445 |
/** |
| 3446 |
* create WrappedRange from node after position |
| 3447 |
* |
| 3448 |
* @param {Node} node |
| 3449 |
* @return {WrappedRange} |
| 3450 |
*/ |
| 3451 |
createFromNodeBefore: function createFromNodeBefore(node) { |
| 3452 |
return this.createFromNode(node).collapse(true); |
| 3453 |
}, |
| 3454 |
|
| 3455 |
/** |
| 3456 |
* create WrappedRange from node after position |
| 3457 |
* |
| 3458 |
* @param {Node} node |
| 3459 |
* @return {WrappedRange} |
| 3460 |
*/ |
| 3461 |
createFromNodeAfter: function createFromNodeAfter(node) { |
| 3462 |
return this.createFromNode(node).collapse(); |
| 3463 |
}, |
| 3464 |
|
| 3465 |
/** |
| 3466 |
* @method |
| 3467 |
* |
| 3468 |
* create WrappedRange from bookmark |
| 3469 |
* |
| 3470 |
* @param {Node} editable |
| 3471 |
* @param {Object} bookmark |
| 3472 |
* @return {WrappedRange} |
| 3473 |
*/ |
| 3474 |
createFromBookmark: function createFromBookmark(editable, bookmark) { |
| 3475 |
var sc = dom.fromOffsetPath(editable, bookmark.s.path); |
| 3476 |
var so = bookmark.s.offset; |
| 3477 |
var ec = dom.fromOffsetPath(editable, bookmark.e.path); |
| 3478 |
var eo = bookmark.e.offset; |
| 3479 |
return new range_WrappedRange(sc, so, ec, eo); |
| 3480 |
}, |
| 3481 |
|
| 3482 |
/** |
| 3483 |
* @method |
| 3484 |
* |
| 3485 |
* create WrappedRange from paraBookmark |
| 3486 |
* |
| 3487 |
* @param {Object} bookmark |
| 3488 |
* @param {Node[]} paras |
| 3489 |
* @return {WrappedRange} |
| 3490 |
*/ |
| 3491 |
createFromParaBookmark: function createFromParaBookmark(bookmark, paras) { |
| 3492 |
var so = bookmark.s.offset; |
| 3493 |
var eo = bookmark.e.offset; |
| 3494 |
var sc = dom.fromOffsetPath(lists.head(paras), bookmark.s.path); |
| 3495 |
var ec = dom.fromOffsetPath(lists.last(paras), bookmark.e.path); |
| 3496 |
return new range_WrappedRange(sc, so, ec, eo); |
| 3497 |
} |
| 3498 |
}); |
| 3499 |
// CONCATENATED MODULE: ./src/js/base/core/key.js |
| 3500 |
|
| 3501 |
|
| 3502 |
var KEY_MAP = { |
| 3503 |
'BACKSPACE': 8, |
| 3504 |
'TAB': 9, |
| 3505 |
'ENTER': 13, |
| 3506 |
'ESCAPE': 27, |
| 3507 |
'SPACE': 32, |
| 3508 |
'DELETE': 46, |
| 3509 |
// Arrow |
| 3510 |
'LEFT': 37, |
| 3511 |
'UP': 38, |
| 3512 |
'RIGHT': 39, |
| 3513 |
'DOWN': 40, |
| 3514 |
// Number: 0-9 |
| 3515 |
'NUM0': 48, |
| 3516 |
'NUM1': 49, |
| 3517 |
'NUM2': 50, |
| 3518 |
'NUM3': 51, |
| 3519 |
'NUM4': 52, |
| 3520 |
'NUM5': 53, |
| 3521 |
'NUM6': 54, |
| 3522 |
'NUM7': 55, |
| 3523 |
'NUM8': 56, |
| 3524 |
// Alphabet: a-z |
| 3525 |
'B': 66, |
| 3526 |
'E': 69, |
| 3527 |
'I': 73, |
| 3528 |
'J': 74, |
| 3529 |
'K': 75, |
| 3530 |
'L': 76, |
| 3531 |
'R': 82, |
| 3532 |
'S': 83, |
| 3533 |
'U': 85, |
| 3534 |
'V': 86, |
| 3535 |
'Y': 89, |
| 3536 |
'Z': 90, |
| 3537 |
'SLASH': 191, |
| 3538 |
'LEFTBRACKET': 219, |
| 3539 |
'BACKSLASH': 220, |
| 3540 |
'RIGHTBRACKET': 221, |
| 3541 |
// Navigation |
| 3542 |
'HOME': 36, |
| 3543 |
'END': 35, |
| 3544 |
'PAGEUP': 33, |
| 3545 |
'PAGEDOWN': 34 |
| 3546 |
}; |
| 3547 |
/** |
| 3548 |
* @class core.key |
| 3549 |
* |
| 3550 |
* Object for keycodes. |
| 3551 |
* |
| 3552 |
* @singleton |
| 3553 |
* @alternateClassName key |
| 3554 |
*/ |
| 3555 |
|
| 3556 |
/* harmony default export */ var core_key = ({ |
| 3557 |
/** |
| 3558 |
* @method isEdit |
| 3559 |
* |
| 3560 |
* @param {Number} keyCode |
| 3561 |
* @return {Boolean} |
| 3562 |
*/ |
| 3563 |
isEdit: function isEdit(keyCode) { |
| 3564 |
return lists.contains([KEY_MAP.BACKSPACE, KEY_MAP.TAB, KEY_MAP.ENTER, KEY_MAP.SPACE, KEY_MAP.DELETE], keyCode); |
| 3565 |
}, |
| 3566 |
|
| 3567 |
/** |
| 3568 |
* @method isMove |
| 3569 |
* |
| 3570 |
* @param {Number} keyCode |
| 3571 |
* @return {Boolean} |
| 3572 |
*/ |
| 3573 |
isMove: function isMove(keyCode) { |
| 3574 |
return lists.contains([KEY_MAP.LEFT, KEY_MAP.UP, KEY_MAP.RIGHT, KEY_MAP.DOWN], keyCode); |
| 3575 |
}, |
| 3576 |
|
| 3577 |
/** |
| 3578 |
* @method isNavigation |
| 3579 |
* |
| 3580 |
* @param {Number} keyCode |
| 3581 |
* @return {Boolean} |
| 3582 |
*/ |
| 3583 |
isNavigation: function isNavigation(keyCode) { |
| 3584 |
return lists.contains([KEY_MAP.HOME, KEY_MAP.END, KEY_MAP.PAGEUP, KEY_MAP.PAGEDOWN], keyCode); |
| 3585 |
}, |
| 3586 |
|
| 3587 |
/** |
| 3588 |
* @property {Object} nameFromCode |
| 3589 |
* @property {String} nameFromCode.8 "BACKSPACE" |
| 3590 |
*/ |
| 3591 |
nameFromCode: func.invertObject(KEY_MAP), |
| 3592 |
code: KEY_MAP |
| 3593 |
}); |
| 3594 |
// CONCATENATED MODULE: ./src/js/base/core/async.js |
| 3595 |
|
| 3596 |
/** |
| 3597 |
* @method readFileAsDataURL |
| 3598 |
* |
| 3599 |
* read contents of file as representing URL |
| 3600 |
* |
| 3601 |
* @param {File} file |
| 3602 |
* @return {Promise} - then: dataUrl |
| 3603 |
*/ |
| 3604 |
|
| 3605 |
function readFileAsDataURL(file) { |
| 3606 |
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) { |
| 3607 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(new FileReader(), { |
| 3608 |
onload: function onload(e) { |
| 3609 |
var dataURL = e.target.result; |
| 3610 |
deferred.resolve(dataURL); |
| 3611 |
}, |
| 3612 |
onerror: function onerror(err) { |
| 3613 |
deferred.reject(err); |
| 3614 |
} |
| 3615 |
}).readAsDataURL(file); |
| 3616 |
}).promise(); |
| 3617 |
} |
| 3618 |
/** |
| 3619 |
* @method createImage |
| 3620 |
* |
| 3621 |
* create `<image>` from url string |
| 3622 |
* |
| 3623 |
* @param {String} url |
| 3624 |
* @return {Promise} - then: $image |
| 3625 |
*/ |
| 3626 |
|
| 3627 |
function createImage(url) { |
| 3628 |
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) { |
| 3629 |
var $img = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<img>'); |
| 3630 |
$img.one('load', function () { |
| 3631 |
$img.off('error abort'); |
| 3632 |
deferred.resolve($img); |
| 3633 |
}).one('error abort', function () { |
| 3634 |
$img.off('load').detach(); |
| 3635 |
deferred.reject($img); |
| 3636 |
}).css({ |
| 3637 |
display: 'none' |
| 3638 |
}).appendTo(document.body).attr('src', url); |
| 3639 |
}).promise(); |
| 3640 |
} |
| 3641 |
// CONCATENATED MODULE: ./src/js/base/editing/History.js |
| 3642 |
function History_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 3643 |
|
| 3644 |
function History_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); } } |
| 3645 |
|
| 3646 |
function History_createClass(Constructor, protoProps, staticProps) { if (protoProps) History_defineProperties(Constructor.prototype, protoProps); if (staticProps) History_defineProperties(Constructor, staticProps); return Constructor; } |
| 3647 |
|
| 3648 |
|
| 3649 |
|
| 3650 |
var History_History = /*#__PURE__*/function () { |
| 3651 |
function History(context) { |
| 3652 |
History_classCallCheck(this, History); |
| 3653 |
|
| 3654 |
this.stack = []; |
| 3655 |
this.stackOffset = -1; |
| 3656 |
this.context = context; |
| 3657 |
this.$editable = context.layoutInfo.editable; |
| 3658 |
this.editable = this.$editable[0]; |
| 3659 |
} |
| 3660 |
|
| 3661 |
History_createClass(History, [{ |
| 3662 |
key: "makeSnapshot", |
| 3663 |
value: function makeSnapshot() { |
| 3664 |
var rng = range.create(this.editable); |
| 3665 |
var emptyBookmark = { |
| 3666 |
s: { |
| 3667 |
path: [], |
| 3668 |
offset: 0 |
| 3669 |
}, |
| 3670 |
e: { |
| 3671 |
path: [], |
| 3672 |
offset: 0 |
| 3673 |
} |
| 3674 |
}; |
| 3675 |
return { |
| 3676 |
contents: this.$editable.html(), |
| 3677 |
bookmark: rng && rng.isOnEditable() ? rng.bookmark(this.editable) : emptyBookmark |
| 3678 |
}; |
| 3679 |
} |
| 3680 |
}, { |
| 3681 |
key: "applySnapshot", |
| 3682 |
value: function applySnapshot(snapshot) { |
| 3683 |
if (snapshot.contents !== null) { |
| 3684 |
this.$editable.html(snapshot.contents); |
| 3685 |
} |
| 3686 |
|
| 3687 |
if (snapshot.bookmark !== null) { |
| 3688 |
range.createFromBookmark(this.editable, snapshot.bookmark).select(); |
| 3689 |
} |
| 3690 |
} |
| 3691 |
/** |
| 3692 |
* @method rewind |
| 3693 |
* Rewinds the history stack back to the first snapshot taken. |
| 3694 |
* Leaves the stack intact, so that "Redo" can still be used. |
| 3695 |
*/ |
| 3696 |
|
| 3697 |
}, { |
| 3698 |
key: "rewind", |
| 3699 |
value: function rewind() { |
| 3700 |
// Create snap shot if not yet recorded |
| 3701 |
if (this.$editable.html() !== this.stack[this.stackOffset].contents) { |
| 3702 |
this.recordUndo(); |
| 3703 |
} // Return to the first available snapshot. |
| 3704 |
|
| 3705 |
|
| 3706 |
this.stackOffset = 0; // Apply that snapshot. |
| 3707 |
|
| 3708 |
this.applySnapshot(this.stack[this.stackOffset]); |
| 3709 |
} |
| 3710 |
/** |
| 3711 |
* @method commit |
| 3712 |
* Resets history stack, but keeps current editor's content. |
| 3713 |
*/ |
| 3714 |
|
| 3715 |
}, { |
| 3716 |
key: "commit", |
| 3717 |
value: function commit() { |
| 3718 |
// Clear the stack. |
| 3719 |
this.stack = []; // Restore stackOffset to its original value. |
| 3720 |
|
| 3721 |
this.stackOffset = -1; // Record our first snapshot (of nothing). |
| 3722 |
|
| 3723 |
this.recordUndo(); |
| 3724 |
} |
| 3725 |
/** |
| 3726 |
* @method reset |
| 3727 |
* Resets the history stack completely; reverting to an empty editor. |
| 3728 |
*/ |
| 3729 |
|
| 3730 |
}, { |
| 3731 |
key: "reset", |
| 3732 |
value: function reset() { |
| 3733 |
// Clear the stack. |
| 3734 |
this.stack = []; // Restore stackOffset to its original value. |
| 3735 |
|
| 3736 |
this.stackOffset = -1; // Clear the editable area. |
| 3737 |
|
| 3738 |
this.$editable.html(''); // Record our first snapshot (of nothing). |
| 3739 |
|
| 3740 |
this.recordUndo(); |
| 3741 |
} |
| 3742 |
/** |
| 3743 |
* undo |
| 3744 |
*/ |
| 3745 |
|
| 3746 |
}, { |
| 3747 |
key: "undo", |
| 3748 |
value: function undo() { |
| 3749 |
// Create snap shot if not yet recorded |
| 3750 |
if (this.$editable.html() !== this.stack[this.stackOffset].contents) { |
| 3751 |
this.recordUndo(); |
| 3752 |
} |
| 3753 |
|
| 3754 |
if (this.stackOffset > 0) { |
| 3755 |
this.stackOffset--; |
| 3756 |
this.applySnapshot(this.stack[this.stackOffset]); |
| 3757 |
} |
| 3758 |
} |
| 3759 |
/** |
| 3760 |
* redo |
| 3761 |
*/ |
| 3762 |
|
| 3763 |
}, { |
| 3764 |
key: "redo", |
| 3765 |
value: function redo() { |
| 3766 |
if (this.stack.length - 1 > this.stackOffset) { |
| 3767 |
this.stackOffset++; |
| 3768 |
this.applySnapshot(this.stack[this.stackOffset]); |
| 3769 |
} |
| 3770 |
} |
| 3771 |
/** |
| 3772 |
* recorded undo |
| 3773 |
*/ |
| 3774 |
|
| 3775 |
}, { |
| 3776 |
key: "recordUndo", |
| 3777 |
value: function recordUndo() { |
| 3778 |
this.stackOffset++; // Wash out stack after stackOffset |
| 3779 |
|
| 3780 |
if (this.stack.length > this.stackOffset) { |
| 3781 |
this.stack = this.stack.slice(0, this.stackOffset); |
| 3782 |
} // Create new snapshot and push it to the end |
| 3783 |
|
| 3784 |
|
| 3785 |
this.stack.push(this.makeSnapshot()); // If the stack size reachs to the limit, then slice it |
| 3786 |
|
| 3787 |
if (this.stack.length > this.context.options.historyLimit) { |
| 3788 |
this.stack.shift(); |
| 3789 |
this.stackOffset -= 1; |
| 3790 |
} |
| 3791 |
} |
| 3792 |
}]); |
| 3793 |
|
| 3794 |
return History; |
| 3795 |
}(); |
| 3796 |
|
| 3797 |
|
| 3798 |
// CONCATENATED MODULE: ./src/js/base/editing/Style.js |
| 3799 |
function Style_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 3800 |
|
| 3801 |
function Style_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); } } |
| 3802 |
|
| 3803 |
function Style_createClass(Constructor, protoProps, staticProps) { if (protoProps) Style_defineProperties(Constructor.prototype, protoProps); if (staticProps) Style_defineProperties(Constructor, staticProps); return Constructor; } |
| 3804 |
|
| 3805 |
|
| 3806 |
|
| 3807 |
|
| 3808 |
|
| 3809 |
|
| 3810 |
|
| 3811 |
var Style_Style = /*#__PURE__*/function () { |
| 3812 |
function Style() { |
| 3813 |
Style_classCallCheck(this, Style); |
| 3814 |
} |
| 3815 |
|
| 3816 |
Style_createClass(Style, [{ |
| 3817 |
key: "jQueryCSS", |
| 3818 |
|
| 3819 |
/** |
| 3820 |
* @method jQueryCSS |
| 3821 |
* |
| 3822 |
* [workaround] for old jQuery |
| 3823 |
* passing an array of style properties to .css() |
| 3824 |
* will result in an object of property-value pairs. |
| 3825 |
* (compability with version < 1.9) |
| 3826 |
* |
| 3827 |
* @private |
| 3828 |
* @param {jQuery} $obj |
| 3829 |
* @param {Array} propertyNames - An array of one or more CSS properties. |
| 3830 |
* @return {Object} |
| 3831 |
*/ |
| 3832 |
value: function jQueryCSS($obj, propertyNames) { |
| 3833 |
if (env.jqueryVersion < 1.9) { |
| 3834 |
var result = {}; |
| 3835 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(propertyNames, function (idx, propertyName) { |
| 3836 |
result[propertyName] = $obj.css(propertyName); |
| 3837 |
}); |
| 3838 |
return result; |
| 3839 |
} |
| 3840 |
|
| 3841 |
return $obj.css(propertyNames); |
| 3842 |
} |
| 3843 |
/** |
| 3844 |
* returns style object from node |
| 3845 |
* |
| 3846 |
* @param {jQuery} $node |
| 3847 |
* @return {Object} |
| 3848 |
*/ |
| 3849 |
|
| 3850 |
}, { |
| 3851 |
key: "fromNode", |
| 3852 |
value: function fromNode($node) { |
| 3853 |
var properties = ['font-family', 'font-size', 'text-align', 'list-style-type', 'line-height']; |
| 3854 |
var styleInfo = this.jQueryCSS($node, properties) || {}; |
| 3855 |
var fontSize = $node[0].style.fontSize || styleInfo['font-size']; |
| 3856 |
styleInfo['font-size'] = parseInt(fontSize, 10); |
| 3857 |
styleInfo['font-size-unit'] = fontSize.match(/[a-z%]+$/); |
| 3858 |
return styleInfo; |
| 3859 |
} |
| 3860 |
/** |
| 3861 |
* paragraph level style |
| 3862 |
* |
| 3863 |
* @param {WrappedRange} rng |
| 3864 |
* @param {Object} styleInfo |
| 3865 |
*/ |
| 3866 |
|
| 3867 |
}, { |
| 3868 |
key: "stylePara", |
| 3869 |
value: function stylePara(rng, styleInfo) { |
| 3870 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(rng.nodes(dom.isPara, { |
| 3871 |
includeAncestor: true |
| 3872 |
}), function (idx, para) { |
| 3873 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(para).css(styleInfo); |
| 3874 |
}); |
| 3875 |
} |
| 3876 |
/** |
| 3877 |
* insert and returns styleNodes on range. |
| 3878 |
* |
| 3879 |
* @param {WrappedRange} rng |
| 3880 |
* @param {Object} [options] - options for styleNodes |
| 3881 |
* @param {String} [options.nodeName] - default: `SPAN` |
| 3882 |
* @param {Boolean} [options.expandClosestSibling] - default: `false` |
| 3883 |
* @param {Boolean} [options.onlyPartialContains] - default: `false` |
| 3884 |
* @return {Node[]} |
| 3885 |
*/ |
| 3886 |
|
| 3887 |
}, { |
| 3888 |
key: "styleNodes", |
| 3889 |
value: function styleNodes(rng, options) { |
| 3890 |
rng = rng.splitText(); |
| 3891 |
var nodeName = options && options.nodeName || 'SPAN'; |
| 3892 |
var expandClosestSibling = !!(options && options.expandClosestSibling); |
| 3893 |
var onlyPartialContains = !!(options && options.onlyPartialContains); |
| 3894 |
|
| 3895 |
if (rng.isCollapsed()) { |
| 3896 |
return [rng.insertNode(dom.create(nodeName))]; |
| 3897 |
} |
| 3898 |
|
| 3899 |
var pred = dom.makePredByNodeName(nodeName); |
| 3900 |
var nodes = rng.nodes(dom.isText, { |
| 3901 |
fullyContains: true |
| 3902 |
}).map(function (text) { |
| 3903 |
return dom.singleChildAncestor(text, pred) || dom.wrap(text, nodeName); |
| 3904 |
}); |
| 3905 |
|
| 3906 |
if (expandClosestSibling) { |
| 3907 |
if (onlyPartialContains) { |
| 3908 |
var nodesInRange = rng.nodes(); // compose with partial contains predication |
| 3909 |
|
| 3910 |
pred = func.and(pred, function (node) { |
| 3911 |
return lists.contains(nodesInRange, node); |
| 3912 |
}); |
| 3913 |
} |
| 3914 |
|
| 3915 |
return nodes.map(function (node) { |
| 3916 |
var siblings = dom.withClosestSiblings(node, pred); |
| 3917 |
var head = lists.head(siblings); |
| 3918 |
var tails = lists.tail(siblings); |
| 3919 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(tails, function (idx, elem) { |
| 3920 |
dom.appendChildNodes(head, elem.childNodes); |
| 3921 |
dom.remove(elem); |
| 3922 |
}); |
| 3923 |
return lists.head(siblings); |
| 3924 |
}); |
| 3925 |
} else { |
| 3926 |
return nodes; |
| 3927 |
} |
| 3928 |
} |
| 3929 |
/** |
| 3930 |
* get current style on cursor |
| 3931 |
* |
| 3932 |
* @param {WrappedRange} rng |
| 3933 |
* @return {Object} - object contains style properties. |
| 3934 |
*/ |
| 3935 |
|
| 3936 |
}, { |
| 3937 |
key: "current", |
| 3938 |
value: function current(rng) { |
| 3939 |
var $cont = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(!dom.isElement(rng.sc) ? rng.sc.parentNode : rng.sc); |
| 3940 |
var styleInfo = this.fromNode($cont); // document.queryCommandState for toggle state |
| 3941 |
// [workaround] prevent Firefox nsresult: "0x80004005 (NS_ERROR_FAILURE)" |
| 3942 |
|
| 3943 |
try { |
| 3944 |
styleInfo = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(styleInfo, { |
| 3945 |
'font-bold': document.queryCommandState('bold') ? 'bold' : 'normal', |
| 3946 |
'font-italic': document.queryCommandState('italic') ? 'italic' : 'normal', |
| 3947 |
'font-underline': document.queryCommandState('underline') ? 'underline' : 'normal', |
| 3948 |
'font-subscript': document.queryCommandState('subscript') ? 'subscript' : 'normal', |
| 3949 |
'font-superscript': document.queryCommandState('superscript') ? 'superscript' : 'normal', |
| 3950 |
'font-strikethrough': document.queryCommandState('strikethrough') ? 'strikethrough' : 'normal', |
| 3951 |
'font-family': document.queryCommandValue('fontname') || styleInfo['font-family'] |
| 3952 |
}); |
| 3953 |
} catch (e) {} // eslint-disable-next-line |
| 3954 |
// list-style-type to list-style(unordered, ordered) |
| 3955 |
|
| 3956 |
|
| 3957 |
if (!rng.isOnList()) { |
| 3958 |
styleInfo['list-style'] = 'none'; |
| 3959 |
} else { |
| 3960 |
var orderedTypes = ['circle', 'disc', 'disc-leading-zero', 'square']; |
| 3961 |
var isUnordered = orderedTypes.indexOf(styleInfo['list-style-type']) > -1; |
| 3962 |
styleInfo['list-style'] = isUnordered ? 'unordered' : 'ordered'; |
| 3963 |
} |
| 3964 |
|
| 3965 |
var para = dom.ancestor(rng.sc, dom.isPara); |
| 3966 |
|
| 3967 |
if (para && para.style['line-height']) { |
| 3968 |
styleInfo['line-height'] = para.style.lineHeight; |
| 3969 |
} else { |
| 3970 |
var lineHeight = parseInt(styleInfo['line-height'], 10) / parseInt(styleInfo['font-size'], 10); |
| 3971 |
styleInfo['line-height'] = lineHeight.toFixed(1); |
| 3972 |
} |
| 3973 |
|
| 3974 |
styleInfo.anchor = rng.isOnAnchor() && dom.ancestor(rng.sc, dom.isAnchor); |
| 3975 |
styleInfo.ancestors = dom.listAncestor(rng.sc, dom.isEditable); |
| 3976 |
styleInfo.range = rng; |
| 3977 |
return styleInfo; |
| 3978 |
} |
| 3979 |
}]); |
| 3980 |
|
| 3981 |
return Style; |
| 3982 |
}(); |
| 3983 |
|
| 3984 |
|
| 3985 |
// CONCATENATED MODULE: ./src/js/base/editing/Bullet.js |
| 3986 |
function Bullet_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 3987 |
|
| 3988 |
function Bullet_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); } } |
| 3989 |
|
| 3990 |
function Bullet_createClass(Constructor, protoProps, staticProps) { if (protoProps) Bullet_defineProperties(Constructor.prototype, protoProps); if (staticProps) Bullet_defineProperties(Constructor, staticProps); return Constructor; } |
| 3991 |
|
| 3992 |
|
| 3993 |
|
| 3994 |
|
| 3995 |
|
| 3996 |
|
| 3997 |
|
| 3998 |
var Bullet_Bullet = /*#__PURE__*/function () { |
| 3999 |
function Bullet() { |
| 4000 |
Bullet_classCallCheck(this, Bullet); |
| 4001 |
} |
| 4002 |
|
| 4003 |
Bullet_createClass(Bullet, [{ |
| 4004 |
key: "insertOrderedList", |
| 4005 |
|
| 4006 |
/** |
| 4007 |
* toggle ordered list |
| 4008 |
*/ |
| 4009 |
value: function insertOrderedList(editable) { |
| 4010 |
this.toggleList('OL', editable); |
| 4011 |
} |
| 4012 |
/** |
| 4013 |
* toggle unordered list |
| 4014 |
*/ |
| 4015 |
|
| 4016 |
}, { |
| 4017 |
key: "insertUnorderedList", |
| 4018 |
value: function insertUnorderedList(editable) { |
| 4019 |
this.toggleList('UL', editable); |
| 4020 |
} |
| 4021 |
/** |
| 4022 |
* indent |
| 4023 |
*/ |
| 4024 |
|
| 4025 |
}, { |
| 4026 |
key: "indent", |
| 4027 |
value: function indent(editable) { |
| 4028 |
var _this = this; |
| 4029 |
|
| 4030 |
var rng = range.create(editable).wrapBodyInlineWithPara(); |
| 4031 |
var paras = rng.nodes(dom.isPara, { |
| 4032 |
includeAncestor: true |
| 4033 |
}); |
| 4034 |
var clustereds = lists.clusterBy(paras, func.peq2('parentNode')); |
| 4035 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(clustereds, function (idx, paras) { |
| 4036 |
var head = lists.head(paras); |
| 4037 |
|
| 4038 |
if (dom.isLi(head)) { |
| 4039 |
var previousList = _this.findList(head.previousSibling); |
| 4040 |
|
| 4041 |
if (previousList) { |
| 4042 |
paras.map(function (para) { |
| 4043 |
return previousList.appendChild(para); |
| 4044 |
}); |
| 4045 |
} else { |
| 4046 |
_this.wrapList(paras, head.parentNode.nodeName); |
| 4047 |
|
| 4048 |
paras.map(function (para) { |
| 4049 |
return para.parentNode; |
| 4050 |
}).map(function (para) { |
| 4051 |
return _this.appendToPrevious(para); |
| 4052 |
}); |
| 4053 |
} |
| 4054 |
} else { |
| 4055 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(paras, function (idx, para) { |
| 4056 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(para).css('marginLeft', function (idx, val) { |
| 4057 |
return (parseInt(val, 10) || 0) + 25; |
| 4058 |
}); |
| 4059 |
}); |
| 4060 |
} |
| 4061 |
}); |
| 4062 |
rng.select(); |
| 4063 |
} |
| 4064 |
/** |
| 4065 |
* outdent |
| 4066 |
*/ |
| 4067 |
|
| 4068 |
}, { |
| 4069 |
key: "outdent", |
| 4070 |
value: function outdent(editable) { |
| 4071 |
var _this2 = this; |
| 4072 |
|
| 4073 |
var rng = range.create(editable).wrapBodyInlineWithPara(); |
| 4074 |
var paras = rng.nodes(dom.isPara, { |
| 4075 |
includeAncestor: true |
| 4076 |
}); |
| 4077 |
var clustereds = lists.clusterBy(paras, func.peq2('parentNode')); |
| 4078 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(clustereds, function (idx, paras) { |
| 4079 |
var head = lists.head(paras); |
| 4080 |
|
| 4081 |
if (dom.isLi(head)) { |
| 4082 |
_this2.releaseList([paras]); |
| 4083 |
} else { |
| 4084 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(paras, function (idx, para) { |
| 4085 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(para).css('marginLeft', function (idx, val) { |
| 4086 |
val = parseInt(val, 10) || 0; |
| 4087 |
return val > 25 ? val - 25 : ''; |
| 4088 |
}); |
| 4089 |
}); |
| 4090 |
} |
| 4091 |
}); |
| 4092 |
rng.select(); |
| 4093 |
} |
| 4094 |
/** |
| 4095 |
* toggle list |
| 4096 |
* |
| 4097 |
* @param {String} listName - OL or UL |
| 4098 |
*/ |
| 4099 |
|
| 4100 |
}, { |
| 4101 |
key: "toggleList", |
| 4102 |
value: function toggleList(listName, editable) { |
| 4103 |
var _this3 = this; |
| 4104 |
|
| 4105 |
var rng = range.create(editable).wrapBodyInlineWithPara(); |
| 4106 |
var paras = rng.nodes(dom.isPara, { |
| 4107 |
includeAncestor: true |
| 4108 |
}); |
| 4109 |
var bookmark = rng.paraBookmark(paras); |
| 4110 |
var clustereds = lists.clusterBy(paras, func.peq2('parentNode')); // paragraph to list |
| 4111 |
|
| 4112 |
if (lists.find(paras, dom.isPurePara)) { |
| 4113 |
var wrappedParas = []; |
| 4114 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(clustereds, function (idx, paras) { |
| 4115 |
wrappedParas = wrappedParas.concat(_this3.wrapList(paras, listName)); |
| 4116 |
}); |
| 4117 |
paras = wrappedParas; // list to paragraph or change list style |
| 4118 |
} else { |
| 4119 |
var diffLists = rng.nodes(dom.isList, { |
| 4120 |
includeAncestor: true |
| 4121 |
}).filter(function (listNode) { |
| 4122 |
return !external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.nodeName(listNode, listName); |
| 4123 |
}); |
| 4124 |
|
| 4125 |
if (diffLists.length) { |
| 4126 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(diffLists, function (idx, listNode) { |
| 4127 |
dom.replace(listNode, listName); |
| 4128 |
}); |
| 4129 |
} else { |
| 4130 |
paras = this.releaseList(clustereds, true); |
| 4131 |
} |
| 4132 |
} |
| 4133 |
|
| 4134 |
range.createFromParaBookmark(bookmark, paras).select(); |
| 4135 |
} |
| 4136 |
/** |
| 4137 |
* @param {Node[]} paras |
| 4138 |
* @param {String} listName |
| 4139 |
* @return {Node[]} |
| 4140 |
*/ |
| 4141 |
|
| 4142 |
}, { |
| 4143 |
key: "wrapList", |
| 4144 |
value: function wrapList(paras, listName) { |
| 4145 |
var head = lists.head(paras); |
| 4146 |
var last = lists.last(paras); |
| 4147 |
var prevList = dom.isList(head.previousSibling) && head.previousSibling; |
| 4148 |
var nextList = dom.isList(last.nextSibling) && last.nextSibling; |
| 4149 |
var listNode = prevList || dom.insertAfter(dom.create(listName || 'UL'), last); // P to LI |
| 4150 |
|
| 4151 |
paras = paras.map(function (para) { |
| 4152 |
return dom.isPurePara(para) ? dom.replace(para, 'LI') : para; |
| 4153 |
}); // append to list(<ul>, <ol>) |
| 4154 |
|
| 4155 |
dom.appendChildNodes(listNode, paras); |
| 4156 |
|
| 4157 |
if (nextList) { |
| 4158 |
dom.appendChildNodes(listNode, lists.from(nextList.childNodes)); |
| 4159 |
dom.remove(nextList); |
| 4160 |
} |
| 4161 |
|
| 4162 |
return paras; |
| 4163 |
} |
| 4164 |
/** |
| 4165 |
* @method releaseList |
| 4166 |
* |
| 4167 |
* @param {Array[]} clustereds |
| 4168 |
* @param {Boolean} isEscapseToBody |
| 4169 |
* @return {Node[]} |
| 4170 |
*/ |
| 4171 |
|
| 4172 |
}, { |
| 4173 |
key: "releaseList", |
| 4174 |
value: function releaseList(clustereds, isEscapseToBody) { |
| 4175 |
var _this4 = this; |
| 4176 |
|
| 4177 |
var releasedParas = []; |
| 4178 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(clustereds, function (idx, paras) { |
| 4179 |
var head = lists.head(paras); |
| 4180 |
var last = lists.last(paras); |
| 4181 |
var headList = isEscapseToBody ? dom.lastAncestor(head, dom.isList) : head.parentNode; |
| 4182 |
var parentItem = headList.parentNode; |
| 4183 |
|
| 4184 |
if (headList.parentNode.nodeName === 'LI') { |
| 4185 |
paras.map(function (para) { |
| 4186 |
var newList = _this4.findNextSiblings(para); |
| 4187 |
|
| 4188 |
if (parentItem.nextSibling) { |
| 4189 |
parentItem.parentNode.insertBefore(para, parentItem.nextSibling); |
| 4190 |
} else { |
| 4191 |
parentItem.parentNode.appendChild(para); |
| 4192 |
} |
| 4193 |
|
| 4194 |
if (newList.length) { |
| 4195 |
_this4.wrapList(newList, headList.nodeName); |
| 4196 |
|
| 4197 |
para.appendChild(newList[0].parentNode); |
| 4198 |
} |
| 4199 |
}); |
| 4200 |
|
| 4201 |
if (headList.children.length === 0) { |
| 4202 |
parentItem.removeChild(headList); |
| 4203 |
} |
| 4204 |
|
| 4205 |
if (parentItem.childNodes.length === 0) { |
| 4206 |
parentItem.parentNode.removeChild(parentItem); |
| 4207 |
} |
| 4208 |
} else { |
| 4209 |
var lastList = headList.childNodes.length > 1 ? dom.splitTree(headList, { |
| 4210 |
node: last.parentNode, |
| 4211 |
offset: dom.position(last) + 1 |
| 4212 |
}, { |
| 4213 |
isSkipPaddingBlankHTML: true |
| 4214 |
}) : null; |
| 4215 |
var middleList = dom.splitTree(headList, { |
| 4216 |
node: head.parentNode, |
| 4217 |
offset: dom.position(head) |
| 4218 |
}, { |
| 4219 |
isSkipPaddingBlankHTML: true |
| 4220 |
}); |
| 4221 |
paras = isEscapseToBody ? dom.listDescendant(middleList, dom.isLi) : lists.from(middleList.childNodes).filter(dom.isLi); // LI to P |
| 4222 |
|
| 4223 |
if (isEscapseToBody || !dom.isList(headList.parentNode)) { |
| 4224 |
paras = paras.map(function (para) { |
| 4225 |
return dom.replace(para, 'P'); |
| 4226 |
}); |
| 4227 |
} |
| 4228 |
|
| 4229 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(lists.from(paras).reverse(), function (idx, para) { |
| 4230 |
dom.insertAfter(para, headList); |
| 4231 |
}); // remove empty lists |
| 4232 |
|
| 4233 |
var rootLists = lists.compact([headList, middleList, lastList]); |
| 4234 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(rootLists, function (idx, rootList) { |
| 4235 |
var listNodes = [rootList].concat(dom.listDescendant(rootList, dom.isList)); |
| 4236 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(listNodes.reverse(), function (idx, listNode) { |
| 4237 |
if (!dom.nodeLength(listNode)) { |
| 4238 |
dom.remove(listNode, true); |
| 4239 |
} |
| 4240 |
}); |
| 4241 |
}); |
| 4242 |
} |
| 4243 |
|
| 4244 |
releasedParas = releasedParas.concat(paras); |
| 4245 |
}); |
| 4246 |
return releasedParas; |
| 4247 |
} |
| 4248 |
/** |
| 4249 |
* @method appendToPrevious |
| 4250 |
* |
| 4251 |
* Appends list to previous list item, if |
| 4252 |
* none exist it wraps the list in a new list item. |
| 4253 |
* |
| 4254 |
* @param {HTMLNode} ListItem |
| 4255 |
* @return {HTMLNode} |
| 4256 |
*/ |
| 4257 |
|
| 4258 |
}, { |
| 4259 |
key: "appendToPrevious", |
| 4260 |
value: function appendToPrevious(node) { |
| 4261 |
return node.previousSibling ? dom.appendChildNodes(node.previousSibling, [node]) : this.wrapList([node], 'LI'); |
| 4262 |
} |
| 4263 |
/** |
| 4264 |
* @method findList |
| 4265 |
* |
| 4266 |
* Finds an existing list in list item |
| 4267 |
* |
| 4268 |
* @param {HTMLNode} ListItem |
| 4269 |
* @return {Array[]} |
| 4270 |
*/ |
| 4271 |
|
| 4272 |
}, { |
| 4273 |
key: "findList", |
| 4274 |
value: function findList(node) { |
| 4275 |
return node ? lists.find(node.children, function (child) { |
| 4276 |
return ['OL', 'UL'].indexOf(child.nodeName) > -1; |
| 4277 |
}) : null; |
| 4278 |
} |
| 4279 |
/** |
| 4280 |
* @method findNextSiblings |
| 4281 |
* |
| 4282 |
* Finds all list item siblings that follow it |
| 4283 |
* |
| 4284 |
* @param {HTMLNode} ListItem |
| 4285 |
* @return {HTMLNode} |
| 4286 |
*/ |
| 4287 |
|
| 4288 |
}, { |
| 4289 |
key: "findNextSiblings", |
| 4290 |
value: function findNextSiblings(node) { |
| 4291 |
var siblings = []; |
| 4292 |
|
| 4293 |
while (node.nextSibling) { |
| 4294 |
siblings.push(node.nextSibling); |
| 4295 |
node = node.nextSibling; |
| 4296 |
} |
| 4297 |
|
| 4298 |
return siblings; |
| 4299 |
} |
| 4300 |
}]); |
| 4301 |
|
| 4302 |
return Bullet; |
| 4303 |
}(); |
| 4304 |
|
| 4305 |
|
| 4306 |
// CONCATENATED MODULE: ./src/js/base/editing/Typing.js |
| 4307 |
function Typing_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 4308 |
|
| 4309 |
function Typing_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); } } |
| 4310 |
|
| 4311 |
function Typing_createClass(Constructor, protoProps, staticProps) { if (protoProps) Typing_defineProperties(Constructor.prototype, protoProps); if (staticProps) Typing_defineProperties(Constructor, staticProps); return Constructor; } |
| 4312 |
|
| 4313 |
|
| 4314 |
|
| 4315 |
|
| 4316 |
|
| 4317 |
/** |
| 4318 |
* @class editing.Typing |
| 4319 |
* |
| 4320 |
* Typing |
| 4321 |
* |
| 4322 |
*/ |
| 4323 |
|
| 4324 |
var Typing_Typing = /*#__PURE__*/function () { |
| 4325 |
function Typing(context) { |
| 4326 |
Typing_classCallCheck(this, Typing); |
| 4327 |
|
| 4328 |
// a Bullet instance to toggle lists off |
| 4329 |
this.bullet = new Bullet_Bullet(); |
| 4330 |
this.options = context.options; |
| 4331 |
} |
| 4332 |
/** |
| 4333 |
* insert tab |
| 4334 |
* |
| 4335 |
* @param {WrappedRange} rng |
| 4336 |
* @param {Number} tabsize |
| 4337 |
*/ |
| 4338 |
|
| 4339 |
|
| 4340 |
Typing_createClass(Typing, [{ |
| 4341 |
key: "insertTab", |
| 4342 |
value: function insertTab(rng, tabsize) { |
| 4343 |
var tab = dom.createText(new Array(tabsize + 1).join(dom.NBSP_CHAR)); |
| 4344 |
rng = rng.deleteContents(); |
| 4345 |
rng.insertNode(tab, true); |
| 4346 |
rng = range.create(tab, tabsize); |
| 4347 |
rng.select(); |
| 4348 |
} |
| 4349 |
/** |
| 4350 |
* insert paragraph |
| 4351 |
* |
| 4352 |
* @param {jQuery} $editable |
| 4353 |
* @param {WrappedRange} rng Can be used in unit tests to "mock" the range |
| 4354 |
* |
| 4355 |
* blockquoteBreakingLevel |
| 4356 |
* 0 - No break, the new paragraph remains inside the quote |
| 4357 |
* 1 - Break the first blockquote in the ancestors list |
| 4358 |
* 2 - Break all blockquotes, so that the new paragraph is not quoted (this is the default) |
| 4359 |
*/ |
| 4360 |
|
| 4361 |
}, { |
| 4362 |
key: "insertParagraph", |
| 4363 |
value: function insertParagraph(editable, rng) { |
| 4364 |
rng = rng || range.create(editable); // deleteContents on range. |
| 4365 |
|
| 4366 |
rng = rng.deleteContents(); // Wrap range if it needs to be wrapped by paragraph |
| 4367 |
|
| 4368 |
rng = rng.wrapBodyInlineWithPara(); // finding paragraph |
| 4369 |
|
| 4370 |
var splitRoot = dom.ancestor(rng.sc, dom.isPara); |
| 4371 |
var nextPara; // on paragraph: split paragraph |
| 4372 |
|
| 4373 |
if (splitRoot) { |
| 4374 |
// if it is an empty line with li |
| 4375 |
if (dom.isLi(splitRoot) && (dom.isEmpty(splitRoot) || dom.deepestChildIsEmpty(splitRoot))) { |
| 4376 |
// toggle UL/OL and escape |
| 4377 |
this.bullet.toggleList(splitRoot.parentNode.nodeName); |
| 4378 |
return; |
| 4379 |
} else { |
| 4380 |
var blockquote = null; |
| 4381 |
|
| 4382 |
if (this.options.blockquoteBreakingLevel === 1) { |
| 4383 |
blockquote = dom.ancestor(splitRoot, dom.isBlockquote); |
| 4384 |
} else if (this.options.blockquoteBreakingLevel === 2) { |
| 4385 |
blockquote = dom.lastAncestor(splitRoot, dom.isBlockquote); |
| 4386 |
} |
| 4387 |
|
| 4388 |
if (blockquote) { |
| 4389 |
// We're inside a blockquote and options ask us to break it |
| 4390 |
nextPara = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(dom.emptyPara)[0]; // If the split is right before a <br>, remove it so that there's no "empty line" |
| 4391 |
// after the split in the new blockquote created |
| 4392 |
|
| 4393 |
if (dom.isRightEdgePoint(rng.getStartPoint()) && dom.isBR(rng.sc.nextSibling)) { |
| 4394 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(rng.sc.nextSibling).remove(); |
| 4395 |
} |
| 4396 |
|
| 4397 |
var split = dom.splitTree(blockquote, rng.getStartPoint(), { |
| 4398 |
isDiscardEmptySplits: true |
| 4399 |
}); |
| 4400 |
|
| 4401 |
if (split) { |
| 4402 |
split.parentNode.insertBefore(nextPara, split); |
| 4403 |
} else { |
| 4404 |
dom.insertAfter(nextPara, blockquote); // There's no split if we were at the end of the blockquote |
| 4405 |
} |
| 4406 |
} else { |
| 4407 |
nextPara = dom.splitTree(splitRoot, rng.getStartPoint()); // not a blockquote, just insert the paragraph |
| 4408 |
|
| 4409 |
var emptyAnchors = dom.listDescendant(splitRoot, dom.isEmptyAnchor); |
| 4410 |
emptyAnchors = emptyAnchors.concat(dom.listDescendant(nextPara, dom.isEmptyAnchor)); |
| 4411 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(emptyAnchors, function (idx, anchor) { |
| 4412 |
dom.remove(anchor); |
| 4413 |
}); // replace empty heading, pre or custom-made styleTag with P tag |
| 4414 |
|
| 4415 |
if ((dom.isHeading(nextPara) || dom.isPre(nextPara) || dom.isCustomStyleTag(nextPara)) && dom.isEmpty(nextPara)) { |
| 4416 |
nextPara = dom.replace(nextPara, 'p'); |
| 4417 |
} |
| 4418 |
} |
| 4419 |
} // no paragraph: insert empty paragraph |
| 4420 |
|
| 4421 |
} else { |
| 4422 |
var next = rng.sc.childNodes[rng.so]; |
| 4423 |
nextPara = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(dom.emptyPara)[0]; |
| 4424 |
|
| 4425 |
if (next) { |
| 4426 |
rng.sc.insertBefore(nextPara, next); |
| 4427 |
} else { |
| 4428 |
rng.sc.appendChild(nextPara); |
| 4429 |
} |
| 4430 |
} |
| 4431 |
|
| 4432 |
range.create(nextPara, 0).normalize().select().scrollIntoView(editable); |
| 4433 |
} |
| 4434 |
}]); |
| 4435 |
|
| 4436 |
return Typing; |
| 4437 |
}(); |
| 4438 |
|
| 4439 |
|
| 4440 |
// CONCATENATED MODULE: ./src/js/base/editing/Table.js |
| 4441 |
function Table_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 4442 |
|
| 4443 |
function Table_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); } } |
| 4444 |
|
| 4445 |
function Table_createClass(Constructor, protoProps, staticProps) { if (protoProps) Table_defineProperties(Constructor.prototype, protoProps); if (staticProps) Table_defineProperties(Constructor, staticProps); return Constructor; } |
| 4446 |
|
| 4447 |
|
| 4448 |
|
| 4449 |
|
| 4450 |
|
| 4451 |
/** |
| 4452 |
* @class Create a virtual table to create what actions to do in change. |
| 4453 |
* @param {object} startPoint Cell selected to apply change. |
| 4454 |
* @param {enum} where Where change will be applied Row or Col. Use enum: TableResultAction.where |
| 4455 |
* @param {enum} action Action to be applied. Use enum: TableResultAction.requestAction |
| 4456 |
* @param {object} domTable Dom element of table to make changes. |
| 4457 |
*/ |
| 4458 |
|
| 4459 |
var TableResultAction = function TableResultAction(startPoint, where, action, domTable) { |
| 4460 |
var _startPoint = { |
| 4461 |
'colPos': 0, |
| 4462 |
'rowPos': 0 |
| 4463 |
}; |
| 4464 |
var _virtualTable = []; |
| 4465 |
var _actionCellList = []; /// /////////////////////////////////////////// |
| 4466 |
// Private functions |
| 4467 |
/// /////////////////////////////////////////// |
| 4468 |
|
| 4469 |
/** |
| 4470 |
* Set the startPoint of action. |
| 4471 |
*/ |
| 4472 |
|
| 4473 |
function setStartPoint() { |
| 4474 |
if (!startPoint || !startPoint.tagName || startPoint.tagName.toLowerCase() !== 'td' && startPoint.tagName.toLowerCase() !== 'th') { |
| 4475 |
// Impossible to identify start Cell point |
| 4476 |
return; |
| 4477 |
} |
| 4478 |
|
| 4479 |
_startPoint.colPos = startPoint.cellIndex; |
| 4480 |
|
| 4481 |
if (!startPoint.parentElement || !startPoint.parentElement.tagName || startPoint.parentElement.tagName.toLowerCase() !== 'tr') { |
| 4482 |
// Impossible to identify start Row point |
| 4483 |
return; |
| 4484 |
} |
| 4485 |
|
| 4486 |
_startPoint.rowPos = startPoint.parentElement.rowIndex; |
| 4487 |
} |
| 4488 |
/** |
| 4489 |
* Define virtual table position info object. |
| 4490 |
* |
| 4491 |
* @param {int} rowIndex Index position in line of virtual table. |
| 4492 |
* @param {int} cellIndex Index position in column of virtual table. |
| 4493 |
* @param {object} baseRow Row affected by this position. |
| 4494 |
* @param {object} baseCell Cell affected by this position. |
| 4495 |
* @param {bool} isSpan Inform if it is an span cell/row. |
| 4496 |
*/ |
| 4497 |
|
| 4498 |
|
| 4499 |
function setVirtualTablePosition(rowIndex, cellIndex, baseRow, baseCell, isRowSpan, isColSpan, isVirtualCell) { |
| 4500 |
var objPosition = { |
| 4501 |
'baseRow': baseRow, |
| 4502 |
'baseCell': baseCell, |
| 4503 |
'isRowSpan': isRowSpan, |
| 4504 |
'isColSpan': isColSpan, |
| 4505 |
'isVirtual': isVirtualCell |
| 4506 |
}; |
| 4507 |
|
| 4508 |
if (!_virtualTable[rowIndex]) { |
| 4509 |
_virtualTable[rowIndex] = []; |
| 4510 |
} |
| 4511 |
|
| 4512 |
_virtualTable[rowIndex][cellIndex] = objPosition; |
| 4513 |
} |
| 4514 |
/** |
| 4515 |
* Create action cell object. |
| 4516 |
* |
| 4517 |
* @param {object} virtualTableCellObj Object of specific position on virtual table. |
| 4518 |
* @param {enum} resultAction Action to be applied in that item. |
| 4519 |
*/ |
| 4520 |
|
| 4521 |
|
| 4522 |
function getActionCell(virtualTableCellObj, resultAction, virtualRowPosition, virtualColPosition) { |
| 4523 |
return { |
| 4524 |
'baseCell': virtualTableCellObj.baseCell, |
| 4525 |
'action': resultAction, |
| 4526 |
'virtualTable': { |
| 4527 |
'rowIndex': virtualRowPosition, |
| 4528 |
'cellIndex': virtualColPosition |
| 4529 |
} |
| 4530 |
}; |
| 4531 |
} |
| 4532 |
/** |
| 4533 |
* Recover free index of row to append Cell. |
| 4534 |
* |
| 4535 |
* @param {int} rowIndex Index of row to find free space. |
| 4536 |
* @param {int} cellIndex Index of cell to find free space in table. |
| 4537 |
*/ |
| 4538 |
|
| 4539 |
|
| 4540 |
function recoverCellIndex(rowIndex, cellIndex) { |
| 4541 |
if (!_virtualTable[rowIndex]) { |
| 4542 |
return cellIndex; |
| 4543 |
} |
| 4544 |
|
| 4545 |
if (!_virtualTable[rowIndex][cellIndex]) { |
| 4546 |
return cellIndex; |
| 4547 |
} |
| 4548 |
|
| 4549 |
var newCellIndex = cellIndex; |
| 4550 |
|
| 4551 |
while (_virtualTable[rowIndex][newCellIndex]) { |
| 4552 |
newCellIndex++; |
| 4553 |
|
| 4554 |
if (!_virtualTable[rowIndex][newCellIndex]) { |
| 4555 |
return newCellIndex; |
| 4556 |
} |
| 4557 |
} |
| 4558 |
} |
| 4559 |
/** |
| 4560 |
* Recover info about row and cell and add information to virtual table. |
| 4561 |
* |
| 4562 |
* @param {object} row Row to recover information. |
| 4563 |
* @param {object} cell Cell to recover information. |
| 4564 |
*/ |
| 4565 |
|
| 4566 |
|
| 4567 |
function addCellInfoToVirtual(row, cell) { |
| 4568 |
var cellIndex = recoverCellIndex(row.rowIndex, cell.cellIndex); |
| 4569 |
var cellHasColspan = cell.colSpan > 1; |
| 4570 |
var cellHasRowspan = cell.rowSpan > 1; |
| 4571 |
var isThisSelectedCell = row.rowIndex === _startPoint.rowPos && cell.cellIndex === _startPoint.colPos; |
| 4572 |
setVirtualTablePosition(row.rowIndex, cellIndex, row, cell, cellHasRowspan, cellHasColspan, false); // Add span rows to virtual Table. |
| 4573 |
|
| 4574 |
var rowspanNumber = cell.attributes.rowSpan ? parseInt(cell.attributes.rowSpan.value, 10) : 0; |
| 4575 |
|
| 4576 |
if (rowspanNumber > 1) { |
| 4577 |
for (var rp = 1; rp < rowspanNumber; rp++) { |
| 4578 |
var rowspanIndex = row.rowIndex + rp; |
| 4579 |
adjustStartPoint(rowspanIndex, cellIndex, cell, isThisSelectedCell); |
| 4580 |
setVirtualTablePosition(rowspanIndex, cellIndex, row, cell, true, cellHasColspan, true); |
| 4581 |
} |
| 4582 |
} // Add span cols to virtual table. |
| 4583 |
|
| 4584 |
|
| 4585 |
var colspanNumber = cell.attributes.colSpan ? parseInt(cell.attributes.colSpan.value, 10) : 0; |
| 4586 |
|
| 4587 |
if (colspanNumber > 1) { |
| 4588 |
for (var cp = 1; cp < colspanNumber; cp++) { |
| 4589 |
var cellspanIndex = recoverCellIndex(row.rowIndex, cellIndex + cp); |
| 4590 |
adjustStartPoint(row.rowIndex, cellspanIndex, cell, isThisSelectedCell); |
| 4591 |
setVirtualTablePosition(row.rowIndex, cellspanIndex, row, cell, cellHasRowspan, true, true); |
| 4592 |
} |
| 4593 |
} |
| 4594 |
} |
| 4595 |
/** |
| 4596 |
* Process validation and adjust of start point if needed |
| 4597 |
* |
| 4598 |
* @param {int} rowIndex |
| 4599 |
* @param {int} cellIndex |
| 4600 |
* @param {object} cell |
| 4601 |
* @param {bool} isSelectedCell |
| 4602 |
*/ |
| 4603 |
|
| 4604 |
|
| 4605 |
function adjustStartPoint(rowIndex, cellIndex, cell, isSelectedCell) { |
| 4606 |
if (rowIndex === _startPoint.rowPos && _startPoint.colPos >= cell.cellIndex && cell.cellIndex <= cellIndex && !isSelectedCell) { |
| 4607 |
_startPoint.colPos++; |
| 4608 |
} |
| 4609 |
} |
| 4610 |
/** |
| 4611 |
* Create virtual table of cells with all cells, including span cells. |
| 4612 |
*/ |
| 4613 |
|
| 4614 |
|
| 4615 |
function createVirtualTable() { |
| 4616 |
var rows = domTable.rows; |
| 4617 |
|
| 4618 |
for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) { |
| 4619 |
var cells = rows[rowIndex].cells; |
| 4620 |
|
| 4621 |
for (var cellIndex = 0; cellIndex < cells.length; cellIndex++) { |
| 4622 |
addCellInfoToVirtual(rows[rowIndex], cells[cellIndex]); |
| 4623 |
} |
| 4624 |
} |
| 4625 |
} |
| 4626 |
/** |
| 4627 |
* Get action to be applied on the cell. |
| 4628 |
* |
| 4629 |
* @param {object} cell virtual table cell to apply action |
| 4630 |
*/ |
| 4631 |
|
| 4632 |
|
| 4633 |
function getDeleteResultActionToCell(cell) { |
| 4634 |
switch (where) { |
| 4635 |
case TableResultAction.where.Column: |
| 4636 |
if (cell.isColSpan) { |
| 4637 |
return TableResultAction.resultAction.SubtractSpanCount; |
| 4638 |
} |
| 4639 |
|
| 4640 |
break; |
| 4641 |
|
| 4642 |
case TableResultAction.where.Row: |
| 4643 |
if (!cell.isVirtual && cell.isRowSpan) { |
| 4644 |
return TableResultAction.resultAction.AddCell; |
| 4645 |
} else if (cell.isRowSpan) { |
| 4646 |
return TableResultAction.resultAction.SubtractSpanCount; |
| 4647 |
} |
| 4648 |
|
| 4649 |
break; |
| 4650 |
} |
| 4651 |
|
| 4652 |
return TableResultAction.resultAction.RemoveCell; |
| 4653 |
} |
| 4654 |
/** |
| 4655 |
* Get action to be applied on the cell. |
| 4656 |
* |
| 4657 |
* @param {object} cell virtual table cell to apply action |
| 4658 |
*/ |
| 4659 |
|
| 4660 |
|
| 4661 |
function getAddResultActionToCell(cell) { |
| 4662 |
switch (where) { |
| 4663 |
case TableResultAction.where.Column: |
| 4664 |
if (cell.isColSpan) { |
| 4665 |
return TableResultAction.resultAction.SumSpanCount; |
| 4666 |
} else if (cell.isRowSpan && cell.isVirtual) { |
| 4667 |
return TableResultAction.resultAction.Ignore; |
| 4668 |
} |
| 4669 |
|
| 4670 |
break; |
| 4671 |
|
| 4672 |
case TableResultAction.where.Row: |
| 4673 |
if (cell.isRowSpan) { |
| 4674 |
return TableResultAction.resultAction.SumSpanCount; |
| 4675 |
} else if (cell.isColSpan && cell.isVirtual) { |
| 4676 |
return TableResultAction.resultAction.Ignore; |
| 4677 |
} |
| 4678 |
|
| 4679 |
break; |
| 4680 |
} |
| 4681 |
|
| 4682 |
return TableResultAction.resultAction.AddCell; |
| 4683 |
} |
| 4684 |
|
| 4685 |
function init() { |
| 4686 |
setStartPoint(); |
| 4687 |
createVirtualTable(); |
| 4688 |
} /// /////////////////////////////////////////// |
| 4689 |
// Public functions |
| 4690 |
/// /////////////////////////////////////////// |
| 4691 |
|
| 4692 |
/** |
| 4693 |
* Recover array os what to do in table. |
| 4694 |
*/ |
| 4695 |
|
| 4696 |
|
| 4697 |
this.getActionList = function () { |
| 4698 |
var fixedRow = where === TableResultAction.where.Row ? _startPoint.rowPos : -1; |
| 4699 |
var fixedCol = where === TableResultAction.where.Column ? _startPoint.colPos : -1; |
| 4700 |
var actualPosition = 0; |
| 4701 |
var canContinue = true; |
| 4702 |
|
| 4703 |
while (canContinue) { |
| 4704 |
var rowPosition = fixedRow >= 0 ? fixedRow : actualPosition; |
| 4705 |
var colPosition = fixedCol >= 0 ? fixedCol : actualPosition; |
| 4706 |
var row = _virtualTable[rowPosition]; |
| 4707 |
|
| 4708 |
if (!row) { |
| 4709 |
canContinue = false; |
| 4710 |
return _actionCellList; |
| 4711 |
} |
| 4712 |
|
| 4713 |
var cell = row[colPosition]; |
| 4714 |
|
| 4715 |
if (!cell) { |
| 4716 |
canContinue = false; |
| 4717 |
return _actionCellList; |
| 4718 |
} // Define action to be applied in this cell |
| 4719 |
|
| 4720 |
|
| 4721 |
var resultAction = TableResultAction.resultAction.Ignore; |
| 4722 |
|
| 4723 |
switch (action) { |
| 4724 |
case TableResultAction.requestAction.Add: |
| 4725 |
resultAction = getAddResultActionToCell(cell); |
| 4726 |
break; |
| 4727 |
|
| 4728 |
case TableResultAction.requestAction.Delete: |
| 4729 |
resultAction = getDeleteResultActionToCell(cell); |
| 4730 |
break; |
| 4731 |
} |
| 4732 |
|
| 4733 |
_actionCellList.push(getActionCell(cell, resultAction, rowPosition, colPosition)); |
| 4734 |
|
| 4735 |
actualPosition++; |
| 4736 |
} |
| 4737 |
|
| 4738 |
return _actionCellList; |
| 4739 |
}; |
| 4740 |
|
| 4741 |
init(); |
| 4742 |
}; |
| 4743 |
/** |
| 4744 |
* |
| 4745 |
* Where action occours enum. |
| 4746 |
*/ |
| 4747 |
|
| 4748 |
|
| 4749 |
TableResultAction.where = { |
| 4750 |
'Row': 0, |
| 4751 |
'Column': 1 |
| 4752 |
}; |
| 4753 |
/** |
| 4754 |
* |
| 4755 |
* Requested action to apply enum. |
| 4756 |
*/ |
| 4757 |
|
| 4758 |
TableResultAction.requestAction = { |
| 4759 |
'Add': 0, |
| 4760 |
'Delete': 1 |
| 4761 |
}; |
| 4762 |
/** |
| 4763 |
* |
| 4764 |
* Result action to be executed enum. |
| 4765 |
*/ |
| 4766 |
|
| 4767 |
TableResultAction.resultAction = { |
| 4768 |
'Ignore': 0, |
| 4769 |
'SubtractSpanCount': 1, |
| 4770 |
'RemoveCell': 2, |
| 4771 |
'AddCell': 3, |
| 4772 |
'SumSpanCount': 4 |
| 4773 |
}; |
| 4774 |
/** |
| 4775 |
* |
| 4776 |
* @class editing.Table |
| 4777 |
* |
| 4778 |
* Table |
| 4779 |
* |
| 4780 |
*/ |
| 4781 |
|
| 4782 |
var Table_Table = /*#__PURE__*/function () { |
| 4783 |
function Table() { |
| 4784 |
Table_classCallCheck(this, Table); |
| 4785 |
} |
| 4786 |
|
| 4787 |
Table_createClass(Table, [{ |
| 4788 |
key: "tab", |
| 4789 |
|
| 4790 |
/** |
| 4791 |
* handle tab key |
| 4792 |
* |
| 4793 |
* @param {WrappedRange} rng |
| 4794 |
* @param {Boolean} isShift |
| 4795 |
*/ |
| 4796 |
value: function tab(rng, isShift) { |
| 4797 |
var cell = dom.ancestor(rng.commonAncestor(), dom.isCell); |
| 4798 |
var table = dom.ancestor(cell, dom.isTable); |
| 4799 |
var cells = dom.listDescendant(table, dom.isCell); |
| 4800 |
var nextCell = lists[isShift ? 'prev' : 'next'](cells, cell); |
| 4801 |
|
| 4802 |
if (nextCell) { |
| 4803 |
range.create(nextCell, 0).select(); |
| 4804 |
} |
| 4805 |
} |
| 4806 |
/** |
| 4807 |
* Add a new row |
| 4808 |
* |
| 4809 |
* @param {WrappedRange} rng |
| 4810 |
* @param {String} position (top/bottom) |
| 4811 |
* @return {Node} |
| 4812 |
*/ |
| 4813 |
|
| 4814 |
}, { |
| 4815 |
key: "addRow", |
| 4816 |
value: function addRow(rng, position) { |
| 4817 |
var cell = dom.ancestor(rng.commonAncestor(), dom.isCell); |
| 4818 |
var currentTr = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('tr'); |
| 4819 |
var trAttributes = this.recoverAttributes(currentTr); |
| 4820 |
var html = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<tr' + trAttributes + '></tr>'); |
| 4821 |
var vTable = new TableResultAction(cell, TableResultAction.where.Row, TableResultAction.requestAction.Add, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentTr).closest('table')[0]); |
| 4822 |
var actions = vTable.getActionList(); |
| 4823 |
|
| 4824 |
for (var idCell = 0; idCell < actions.length; idCell++) { |
| 4825 |
var currentCell = actions[idCell]; |
| 4826 |
var tdAttributes = this.recoverAttributes(currentCell.baseCell); |
| 4827 |
|
| 4828 |
switch (currentCell.action) { |
| 4829 |
case TableResultAction.resultAction.AddCell: |
| 4830 |
html.append('<td' + tdAttributes + '>' + dom.blank + '</td>'); |
| 4831 |
break; |
| 4832 |
|
| 4833 |
case TableResultAction.resultAction.SumSpanCount: |
| 4834 |
{ |
| 4835 |
if (position === 'top') { |
| 4836 |
var baseCellTr = currentCell.baseCell.parent; |
| 4837 |
var isTopFromRowSpan = (!baseCellTr ? 0 : currentCell.baseCell.closest('tr').rowIndex) <= currentTr[0].rowIndex; |
| 4838 |
|
| 4839 |
if (isTopFromRowSpan) { |
| 4840 |
var newTd = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div></div>').append(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<td' + tdAttributes + '>' + dom.blank + '</td>').removeAttr('rowspan')).html(); |
| 4841 |
html.append(newTd); |
| 4842 |
break; |
| 4843 |
} |
| 4844 |
} |
| 4845 |
|
| 4846 |
var rowspanNumber = parseInt(currentCell.baseCell.rowSpan, 10); |
| 4847 |
rowspanNumber++; |
| 4848 |
currentCell.baseCell.setAttribute('rowSpan', rowspanNumber); |
| 4849 |
} |
| 4850 |
break; |
| 4851 |
} |
| 4852 |
} |
| 4853 |
|
| 4854 |
if (position === 'top') { |
| 4855 |
currentTr.before(html); |
| 4856 |
} else { |
| 4857 |
var cellHasRowspan = cell.rowSpan > 1; |
| 4858 |
|
| 4859 |
if (cellHasRowspan) { |
| 4860 |
var lastTrIndex = currentTr[0].rowIndex + (cell.rowSpan - 2); |
| 4861 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentTr).parent().find('tr')[lastTrIndex]).after(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(html)); |
| 4862 |
return; |
| 4863 |
} |
| 4864 |
|
| 4865 |
currentTr.after(html); |
| 4866 |
} |
| 4867 |
} |
| 4868 |
/** |
| 4869 |
* Add a new col |
| 4870 |
* |
| 4871 |
* @param {WrappedRange} rng |
| 4872 |
* @param {String} position (left/right) |
| 4873 |
* @return {Node} |
| 4874 |
*/ |
| 4875 |
|
| 4876 |
}, { |
| 4877 |
key: "addCol", |
| 4878 |
value: function addCol(rng, position) { |
| 4879 |
var cell = dom.ancestor(rng.commonAncestor(), dom.isCell); |
| 4880 |
var row = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('tr'); |
| 4881 |
var rowsGroup = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(row).siblings(); |
| 4882 |
rowsGroup.push(row); |
| 4883 |
var vTable = new TableResultAction(cell, TableResultAction.where.Column, TableResultAction.requestAction.Add, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(row).closest('table')[0]); |
| 4884 |
var actions = vTable.getActionList(); |
| 4885 |
|
| 4886 |
for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) { |
| 4887 |
var currentCell = actions[actionIndex]; |
| 4888 |
var tdAttributes = this.recoverAttributes(currentCell.baseCell); |
| 4889 |
|
| 4890 |
switch (currentCell.action) { |
| 4891 |
case TableResultAction.resultAction.AddCell: |
| 4892 |
if (position === 'right') { |
| 4893 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentCell.baseCell).after('<td' + tdAttributes + '>' + dom.blank + '</td>'); |
| 4894 |
} else { |
| 4895 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentCell.baseCell).before('<td' + tdAttributes + '>' + dom.blank + '</td>'); |
| 4896 |
} |
| 4897 |
|
| 4898 |
break; |
| 4899 |
|
| 4900 |
case TableResultAction.resultAction.SumSpanCount: |
| 4901 |
if (position === 'right') { |
| 4902 |
var colspanNumber = parseInt(currentCell.baseCell.colSpan, 10); |
| 4903 |
colspanNumber++; |
| 4904 |
currentCell.baseCell.setAttribute('colSpan', colspanNumber); |
| 4905 |
} else { |
| 4906 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentCell.baseCell).before('<td' + tdAttributes + '>' + dom.blank + '</td>'); |
| 4907 |
} |
| 4908 |
|
| 4909 |
break; |
| 4910 |
} |
| 4911 |
} |
| 4912 |
} |
| 4913 |
/* |
| 4914 |
* Copy attributes from element. |
| 4915 |
* |
| 4916 |
* @param {object} Element to recover attributes. |
| 4917 |
* @return {string} Copied string elements. |
| 4918 |
*/ |
| 4919 |
|
| 4920 |
}, { |
| 4921 |
key: "recoverAttributes", |
| 4922 |
value: function recoverAttributes(el) { |
| 4923 |
var resultStr = ''; |
| 4924 |
|
| 4925 |
if (!el) { |
| 4926 |
return resultStr; |
| 4927 |
} |
| 4928 |
|
| 4929 |
var attrList = el.attributes || []; |
| 4930 |
|
| 4931 |
for (var i = 0; i < attrList.length; i++) { |
| 4932 |
if (attrList[i].name.toLowerCase() === 'id') { |
| 4933 |
continue; |
| 4934 |
} |
| 4935 |
|
| 4936 |
if (attrList[i].specified) { |
| 4937 |
resultStr += ' ' + attrList[i].name + '=\'' + attrList[i].value + '\''; |
| 4938 |
} |
| 4939 |
} |
| 4940 |
|
| 4941 |
return resultStr; |
| 4942 |
} |
| 4943 |
/** |
| 4944 |
* Delete current row |
| 4945 |
* |
| 4946 |
* @param {WrappedRange} rng |
| 4947 |
* @return {Node} |
| 4948 |
*/ |
| 4949 |
|
| 4950 |
}, { |
| 4951 |
key: "deleteRow", |
| 4952 |
value: function deleteRow(rng) { |
| 4953 |
var cell = dom.ancestor(rng.commonAncestor(), dom.isCell); |
| 4954 |
var row = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('tr'); |
| 4955 |
var cellPos = row.children('td, th').index(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell)); |
| 4956 |
var rowPos = row[0].rowIndex; |
| 4957 |
var vTable = new TableResultAction(cell, TableResultAction.where.Row, TableResultAction.requestAction.Delete, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(row).closest('table')[0]); |
| 4958 |
var actions = vTable.getActionList(); |
| 4959 |
|
| 4960 |
for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) { |
| 4961 |
if (!actions[actionIndex]) { |
| 4962 |
continue; |
| 4963 |
} |
| 4964 |
|
| 4965 |
var baseCell = actions[actionIndex].baseCell; |
| 4966 |
var virtualPosition = actions[actionIndex].virtualTable; |
| 4967 |
var hasRowspan = baseCell.rowSpan && baseCell.rowSpan > 1; |
| 4968 |
var rowspanNumber = hasRowspan ? parseInt(baseCell.rowSpan, 10) : 0; |
| 4969 |
|
| 4970 |
switch (actions[actionIndex].action) { |
| 4971 |
case TableResultAction.resultAction.Ignore: |
| 4972 |
continue; |
| 4973 |
|
| 4974 |
case TableResultAction.resultAction.AddCell: |
| 4975 |
{ |
| 4976 |
var nextRow = row.next('tr')[0]; |
| 4977 |
|
| 4978 |
if (!nextRow) { |
| 4979 |
continue; |
| 4980 |
} |
| 4981 |
|
| 4982 |
var cloneRow = row[0].cells[cellPos]; |
| 4983 |
|
| 4984 |
if (hasRowspan) { |
| 4985 |
if (rowspanNumber > 2) { |
| 4986 |
rowspanNumber--; |
| 4987 |
nextRow.insertBefore(cloneRow, nextRow.cells[cellPos]); |
| 4988 |
nextRow.cells[cellPos].setAttribute('rowSpan', rowspanNumber); |
| 4989 |
nextRow.cells[cellPos].innerHTML = ''; |
| 4990 |
} else if (rowspanNumber === 2) { |
| 4991 |
nextRow.insertBefore(cloneRow, nextRow.cells[cellPos]); |
| 4992 |
nextRow.cells[cellPos].removeAttribute('rowSpan'); |
| 4993 |
nextRow.cells[cellPos].innerHTML = ''; |
| 4994 |
} |
| 4995 |
} |
| 4996 |
} |
| 4997 |
continue; |
| 4998 |
|
| 4999 |
case TableResultAction.resultAction.SubtractSpanCount: |
| 5000 |
if (hasRowspan) { |
| 5001 |
if (rowspanNumber > 2) { |
| 5002 |
rowspanNumber--; |
| 5003 |
baseCell.setAttribute('rowSpan', rowspanNumber); |
| 5004 |
|
| 5005 |
if (virtualPosition.rowIndex !== rowPos && baseCell.cellIndex === cellPos) { |
| 5006 |
baseCell.innerHTML = ''; |
| 5007 |
} |
| 5008 |
} else if (rowspanNumber === 2) { |
| 5009 |
baseCell.removeAttribute('rowSpan'); |
| 5010 |
|
| 5011 |
if (virtualPosition.rowIndex !== rowPos && baseCell.cellIndex === cellPos) { |
| 5012 |
baseCell.innerHTML = ''; |
| 5013 |
} |
| 5014 |
} |
| 5015 |
} |
| 5016 |
|
| 5017 |
continue; |
| 5018 |
|
| 5019 |
case TableResultAction.resultAction.RemoveCell: |
| 5020 |
// Do not need remove cell because row will be deleted. |
| 5021 |
continue; |
| 5022 |
} |
| 5023 |
} |
| 5024 |
|
| 5025 |
row.remove(); |
| 5026 |
} |
| 5027 |
/** |
| 5028 |
* Delete current col |
| 5029 |
* |
| 5030 |
* @param {WrappedRange} rng |
| 5031 |
* @return {Node} |
| 5032 |
*/ |
| 5033 |
|
| 5034 |
}, { |
| 5035 |
key: "deleteCol", |
| 5036 |
value: function deleteCol(rng) { |
| 5037 |
var cell = dom.ancestor(rng.commonAncestor(), dom.isCell); |
| 5038 |
var row = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('tr'); |
| 5039 |
var cellPos = row.children('td, th').index(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell)); |
| 5040 |
var vTable = new TableResultAction(cell, TableResultAction.where.Column, TableResultAction.requestAction.Delete, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(row).closest('table')[0]); |
| 5041 |
var actions = vTable.getActionList(); |
| 5042 |
|
| 5043 |
for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) { |
| 5044 |
if (!actions[actionIndex]) { |
| 5045 |
continue; |
| 5046 |
} |
| 5047 |
|
| 5048 |
switch (actions[actionIndex].action) { |
| 5049 |
case TableResultAction.resultAction.Ignore: |
| 5050 |
continue; |
| 5051 |
|
| 5052 |
case TableResultAction.resultAction.SubtractSpanCount: |
| 5053 |
{ |
| 5054 |
var baseCell = actions[actionIndex].baseCell; |
| 5055 |
var hasColspan = baseCell.colSpan && baseCell.colSpan > 1; |
| 5056 |
|
| 5057 |
if (hasColspan) { |
| 5058 |
var colspanNumber = baseCell.colSpan ? parseInt(baseCell.colSpan, 10) : 0; |
| 5059 |
|
| 5060 |
if (colspanNumber > 2) { |
| 5061 |
colspanNumber--; |
| 5062 |
baseCell.setAttribute('colSpan', colspanNumber); |
| 5063 |
|
| 5064 |
if (baseCell.cellIndex === cellPos) { |
| 5065 |
baseCell.innerHTML = ''; |
| 5066 |
} |
| 5067 |
} else if (colspanNumber === 2) { |
| 5068 |
baseCell.removeAttribute('colSpan'); |
| 5069 |
|
| 5070 |
if (baseCell.cellIndex === cellPos) { |
| 5071 |
baseCell.innerHTML = ''; |
| 5072 |
} |
| 5073 |
} |
| 5074 |
} |
| 5075 |
} |
| 5076 |
continue; |
| 5077 |
|
| 5078 |
case TableResultAction.resultAction.RemoveCell: |
| 5079 |
dom.remove(actions[actionIndex].baseCell, true); |
| 5080 |
continue; |
| 5081 |
} |
| 5082 |
} |
| 5083 |
} |
| 5084 |
/** |
| 5085 |
* create empty table element |
| 5086 |
* |
| 5087 |
* @param {Number} rowCount |
| 5088 |
* @param {Number} colCount |
| 5089 |
* @return {Node} |
| 5090 |
*/ |
| 5091 |
|
| 5092 |
}, { |
| 5093 |
key: "createTable", |
| 5094 |
value: function createTable(colCount, rowCount, options) { |
| 5095 |
var tds = []; |
| 5096 |
var tdHTML; |
| 5097 |
|
| 5098 |
for (var idxCol = 0; idxCol < colCount; idxCol++) { |
| 5099 |
tds.push('<td>' + dom.blank + '</td>'); |
| 5100 |
} |
| 5101 |
|
| 5102 |
tdHTML = tds.join(''); |
| 5103 |
var trs = []; |
| 5104 |
var trHTML; |
| 5105 |
|
| 5106 |
for (var idxRow = 0; idxRow < rowCount; idxRow++) { |
| 5107 |
trs.push('<tr>' + tdHTML + '</tr>'); |
| 5108 |
} |
| 5109 |
|
| 5110 |
trHTML = trs.join(''); |
| 5111 |
var $table = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<table>' + trHTML + '</table>'); |
| 5112 |
|
| 5113 |
if (options && options.tableClassName) { |
| 5114 |
$table.addClass(options.tableClassName); |
| 5115 |
} |
| 5116 |
|
| 5117 |
return $table[0]; |
| 5118 |
} |
| 5119 |
/** |
| 5120 |
* Delete current table |
| 5121 |
* |
| 5122 |
* @param {WrappedRange} rng |
| 5123 |
* @return {Node} |
| 5124 |
*/ |
| 5125 |
|
| 5126 |
}, { |
| 5127 |
key: "deleteTable", |
| 5128 |
value: function deleteTable(rng) { |
| 5129 |
var cell = dom.ancestor(rng.commonAncestor(), dom.isCell); |
| 5130 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('table').remove(); |
| 5131 |
} |
| 5132 |
}]); |
| 5133 |
|
| 5134 |
return Table; |
| 5135 |
}(); |
| 5136 |
|
| 5137 |
|
| 5138 |
// CONCATENATED MODULE: ./src/js/base/module/Editor.js |
| 5139 |
function Editor_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 5140 |
|
| 5141 |
function Editor_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); } } |
| 5142 |
|
| 5143 |
function Editor_createClass(Constructor, protoProps, staticProps) { if (protoProps) Editor_defineProperties(Constructor.prototype, protoProps); if (staticProps) Editor_defineProperties(Constructor, staticProps); return Constructor; } |
| 5144 |
|
| 5145 |
|
| 5146 |
|
| 5147 |
|
| 5148 |
|
| 5149 |
|
| 5150 |
|
| 5151 |
|
| 5152 |
|
| 5153 |
|
| 5154 |
|
| 5155 |
|
| 5156 |
|
| 5157 |
|
| 5158 |
var KEY_BOGUS = 'bogus'; |
| 5159 |
/** |
| 5160 |
* @class Editor |
| 5161 |
*/ |
| 5162 |
|
| 5163 |
var Editor_Editor = /*#__PURE__*/function () { |
| 5164 |
function Editor(context) { |
| 5165 |
var _this = this; |
| 5166 |
|
| 5167 |
Editor_classCallCheck(this, Editor); |
| 5168 |
|
| 5169 |
this.context = context; |
| 5170 |
this.$note = context.layoutInfo.note; |
| 5171 |
this.$editor = context.layoutInfo.editor; |
| 5172 |
this.$editable = context.layoutInfo.editable; |
| 5173 |
this.options = context.options; |
| 5174 |
this.lang = this.options.langInfo; |
| 5175 |
this.editable = this.$editable[0]; |
| 5176 |
this.lastRange = null; |
| 5177 |
this.snapshot = null; |
| 5178 |
this.style = new Style_Style(); |
| 5179 |
this.table = new Table_Table(); |
| 5180 |
this.typing = new Typing_Typing(context); |
| 5181 |
this.bullet = new Bullet_Bullet(); |
| 5182 |
this.history = new History_History(context); |
| 5183 |
this.context.memo('help.escape', this.lang.help.escape); |
| 5184 |
this.context.memo('help.undo', this.lang.help.undo); |
| 5185 |
this.context.memo('help.redo', this.lang.help.redo); |
| 5186 |
this.context.memo('help.tab', this.lang.help.tab); |
| 5187 |
this.context.memo('help.untab', this.lang.help.untab); |
| 5188 |
this.context.memo('help.insertParagraph', this.lang.help.insertParagraph); |
| 5189 |
this.context.memo('help.insertOrderedList', this.lang.help.insertOrderedList); |
| 5190 |
this.context.memo('help.insertUnorderedList', this.lang.help.insertUnorderedList); |
| 5191 |
this.context.memo('help.indent', this.lang.help.indent); |
| 5192 |
this.context.memo('help.outdent', this.lang.help.outdent); |
| 5193 |
this.context.memo('help.formatPara', this.lang.help.formatPara); |
| 5194 |
this.context.memo('help.insertHorizontalRule', this.lang.help.insertHorizontalRule); |
| 5195 |
this.context.memo('help.fontName', this.lang.help.fontName); // native commands(with execCommand), generate function for execCommand |
| 5196 |
|
| 5197 |
var commands = ['bold', 'italic', 'underline', 'strikethrough', 'superscript', 'subscript', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'formatBlock', 'removeFormat', 'backColor']; |
| 5198 |
|
| 5199 |
for (var idx = 0, len = commands.length; idx < len; idx++) { |
| 5200 |
this[commands[idx]] = function (sCmd) { |
| 5201 |
return function (value) { |
| 5202 |
_this.beforeCommand(); |
| 5203 |
|
| 5204 |
document.execCommand(sCmd, false, value); |
| 5205 |
|
| 5206 |
_this.afterCommand(true); |
| 5207 |
}; |
| 5208 |
}(commands[idx]); |
| 5209 |
|
| 5210 |
this.context.memo('help.' + commands[idx], this.lang.help[commands[idx]]); |
| 5211 |
} |
| 5212 |
|
| 5213 |
this.fontName = this.wrapCommand(function (value) { |
| 5214 |
return _this.fontStyling('font-family', env.validFontName(value)); |
| 5215 |
}); |
| 5216 |
this.fontSize = this.wrapCommand(function (value) { |
| 5217 |
var unit = _this.currentStyle()['font-size-unit']; |
| 5218 |
|
| 5219 |
return _this.fontStyling('font-size', value + unit); |
| 5220 |
}); |
| 5221 |
this.fontSizeUnit = this.wrapCommand(function (value) { |
| 5222 |
var size = _this.currentStyle()['font-size']; |
| 5223 |
|
| 5224 |
return _this.fontStyling('font-size', size + value); |
| 5225 |
}); |
| 5226 |
|
| 5227 |
for (var _idx = 1; _idx <= 6; _idx++) { |
| 5228 |
this['formatH' + _idx] = function (idx) { |
| 5229 |
return function () { |
| 5230 |
_this.formatBlock('H' + idx); |
| 5231 |
}; |
| 5232 |
}(_idx); |
| 5233 |
|
| 5234 |
this.context.memo('help.formatH' + _idx, this.lang.help['formatH' + _idx]); |
| 5235 |
} |
| 5236 |
|
| 5237 |
this.insertParagraph = this.wrapCommand(function () { |
| 5238 |
_this.typing.insertParagraph(_this.editable); |
| 5239 |
}); |
| 5240 |
this.insertOrderedList = this.wrapCommand(function () { |
| 5241 |
_this.bullet.insertOrderedList(_this.editable); |
| 5242 |
}); |
| 5243 |
this.insertUnorderedList = this.wrapCommand(function () { |
| 5244 |
_this.bullet.insertUnorderedList(_this.editable); |
| 5245 |
}); |
| 5246 |
this.indent = this.wrapCommand(function () { |
| 5247 |
_this.bullet.indent(_this.editable); |
| 5248 |
}); |
| 5249 |
this.outdent = this.wrapCommand(function () { |
| 5250 |
_this.bullet.outdent(_this.editable); |
| 5251 |
}); |
| 5252 |
/** |
| 5253 |
* insertNode |
| 5254 |
* insert node |
| 5255 |
* @param {Node} node |
| 5256 |
*/ |
| 5257 |
|
| 5258 |
this.insertNode = this.wrapCommand(function (node) { |
| 5259 |
if (_this.isLimited(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).text().length)) { |
| 5260 |
return; |
| 5261 |
} |
| 5262 |
|
| 5263 |
var rng = _this.getLastRange(); |
| 5264 |
|
| 5265 |
rng.insertNode(node); |
| 5266 |
|
| 5267 |
_this.setLastRange(range.createFromNodeAfter(node).select()); |
| 5268 |
}); |
| 5269 |
/** |
| 5270 |
* insert text |
| 5271 |
* @param {String} text |
| 5272 |
*/ |
| 5273 |
|
| 5274 |
this.insertText = this.wrapCommand(function (text) { |
| 5275 |
if (_this.isLimited(text.length)) { |
| 5276 |
return; |
| 5277 |
} |
| 5278 |
|
| 5279 |
var rng = _this.getLastRange(); |
| 5280 |
|
| 5281 |
var textNode = rng.insertNode(dom.createText(text)); |
| 5282 |
|
| 5283 |
_this.setLastRange(range.create(textNode, dom.nodeLength(textNode)).select()); |
| 5284 |
}); |
| 5285 |
/** |
| 5286 |
* paste HTML |
| 5287 |
* @param {String} markup |
| 5288 |
*/ |
| 5289 |
|
| 5290 |
this.pasteHTML = this.wrapCommand(function (markup) { |
| 5291 |
if (_this.isLimited(markup.length)) { |
| 5292 |
return; |
| 5293 |
} |
| 5294 |
|
| 5295 |
markup = _this.context.invoke('codeview.purify', markup); |
| 5296 |
|
| 5297 |
var contents = _this.getLastRange().pasteHTML(markup); |
| 5298 |
|
| 5299 |
_this.setLastRange(range.createFromNodeAfter(lists.last(contents)).select()); |
| 5300 |
}); |
| 5301 |
/** |
| 5302 |
* formatBlock |
| 5303 |
* |
| 5304 |
* @param {String} tagName |
| 5305 |
*/ |
| 5306 |
|
| 5307 |
this.formatBlock = this.wrapCommand(function (tagName, $target) { |
| 5308 |
var onApplyCustomStyle = _this.options.callbacks.onApplyCustomStyle; |
| 5309 |
|
| 5310 |
if (onApplyCustomStyle) { |
| 5311 |
onApplyCustomStyle.call(_this, $target, _this.context, _this.onFormatBlock); |
| 5312 |
} else { |
| 5313 |
_this.onFormatBlock(tagName, $target); |
| 5314 |
} |
| 5315 |
}); |
| 5316 |
/** |
| 5317 |
* insert horizontal rule |
| 5318 |
*/ |
| 5319 |
|
| 5320 |
this.insertHorizontalRule = this.wrapCommand(function () { |
| 5321 |
var hrNode = _this.getLastRange().insertNode(dom.create('HR')); |
| 5322 |
|
| 5323 |
if (hrNode.nextSibling) { |
| 5324 |
_this.setLastRange(range.create(hrNode.nextSibling, 0).normalize().select()); |
| 5325 |
} |
| 5326 |
}); |
| 5327 |
/** |
| 5328 |
* lineHeight |
| 5329 |
* @param {String} value |
| 5330 |
*/ |
| 5331 |
|
| 5332 |
this.lineHeight = this.wrapCommand(function (value) { |
| 5333 |
_this.style.stylePara(_this.getLastRange(), { |
| 5334 |
lineHeight: value |
| 5335 |
}); |
| 5336 |
}); |
| 5337 |
/** |
| 5338 |
* create link (command) |
| 5339 |
* |
| 5340 |
* @param {Object} linkInfo |
| 5341 |
*/ |
| 5342 |
|
| 5343 |
this.createLink = this.wrapCommand(function (linkInfo) { |
| 5344 |
var linkUrl = linkInfo.url; |
| 5345 |
var linkText = linkInfo.text; |
| 5346 |
var isNewWindow = linkInfo.isNewWindow; |
| 5347 |
var checkProtocol = linkInfo.checkProtocol; |
| 5348 |
|
| 5349 |
var rng = linkInfo.range || _this.getLastRange(); |
| 5350 |
|
| 5351 |
var additionalTextLength = linkText.length - rng.toString().length; |
| 5352 |
|
| 5353 |
if (additionalTextLength > 0 && _this.isLimited(additionalTextLength)) { |
| 5354 |
return; |
| 5355 |
} |
| 5356 |
|
| 5357 |
var isTextChanged = rng.toString() !== linkText; // handle spaced urls from input |
| 5358 |
|
| 5359 |
if (typeof linkUrl === 'string') { |
| 5360 |
linkUrl = linkUrl.trim(); |
| 5361 |
} |
| 5362 |
|
| 5363 |
if (_this.options.onCreateLink) { |
| 5364 |
linkUrl = _this.options.onCreateLink(linkUrl); |
| 5365 |
} else if (checkProtocol) { |
| 5366 |
// if url doesn't have any protocol and not even a relative or a label, use http:// as default |
| 5367 |
linkUrl = /^([A-Za-z][A-Za-z0-9+-.]*\:|#|\/)/.test(linkUrl) ? linkUrl : _this.options.defaultProtocol + linkUrl; |
| 5368 |
} |
| 5369 |
|
| 5370 |
var anchors = []; |
| 5371 |
|
| 5372 |
if (isTextChanged) { |
| 5373 |
rng = rng.deleteContents(); |
| 5374 |
var anchor = rng.insertNode(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<A>' + linkText + '</A>')[0]); |
| 5375 |
anchors.push(anchor); |
| 5376 |
} else { |
| 5377 |
anchors = _this.style.styleNodes(rng, { |
| 5378 |
nodeName: 'A', |
| 5379 |
expandClosestSibling: true, |
| 5380 |
onlyPartialContains: true |
| 5381 |
}); |
| 5382 |
} |
| 5383 |
|
| 5384 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(anchors, function (idx, anchor) { |
| 5385 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).attr('href', linkUrl); |
| 5386 |
|
| 5387 |
if (isNewWindow) { |
| 5388 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).attr('target', '_blank'); |
| 5389 |
} else { |
| 5390 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).removeAttr('target'); |
| 5391 |
} |
| 5392 |
}); |
| 5393 |
|
| 5394 |
_this.setLastRange(_this.createRangeFromList(anchors).select()); |
| 5395 |
}); |
| 5396 |
/** |
| 5397 |
* setting color |
| 5398 |
* |
| 5399 |
* @param {Object} sObjColor color code |
| 5400 |
* @param {String} sObjColor.foreColor foreground color |
| 5401 |
* @param {String} sObjColor.backColor background color |
| 5402 |
*/ |
| 5403 |
|
| 5404 |
this.color = this.wrapCommand(function (colorInfo) { |
| 5405 |
var foreColor = colorInfo.foreColor; |
| 5406 |
var backColor = colorInfo.backColor; |
| 5407 |
|
| 5408 |
if (foreColor) { |
| 5409 |
document.execCommand('foreColor', false, foreColor); |
| 5410 |
} |
| 5411 |
|
| 5412 |
if (backColor) { |
| 5413 |
document.execCommand('backColor', false, backColor); |
| 5414 |
} |
| 5415 |
}); |
| 5416 |
/** |
| 5417 |
* Set foreground color |
| 5418 |
* |
| 5419 |
* @param {String} colorCode foreground color code |
| 5420 |
*/ |
| 5421 |
|
| 5422 |
this.foreColor = this.wrapCommand(function (colorInfo) { |
| 5423 |
document.execCommand('foreColor', false, colorInfo); |
| 5424 |
}); |
| 5425 |
/** |
| 5426 |
* insert Table |
| 5427 |
* |
| 5428 |
* @param {String} dimension of table (ex : "5x5") |
| 5429 |
*/ |
| 5430 |
|
| 5431 |
this.insertTable = this.wrapCommand(function (dim) { |
| 5432 |
var dimension = dim.split('x'); |
| 5433 |
|
| 5434 |
var rng = _this.getLastRange().deleteContents(); |
| 5435 |
|
| 5436 |
rng.insertNode(_this.table.createTable(dimension[0], dimension[1], _this.options)); |
| 5437 |
}); |
| 5438 |
/** |
| 5439 |
* remove media object and Figure Elements if media object is img with Figure. |
| 5440 |
*/ |
| 5441 |
|
| 5442 |
this.removeMedia = this.wrapCommand(function () { |
| 5443 |
var $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(_this.restoreTarget()).parent(); |
| 5444 |
|
| 5445 |
if ($target.closest('figure').length) { |
| 5446 |
$target.closest('figure').remove(); |
| 5447 |
} else { |
| 5448 |
$target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(_this.restoreTarget()).detach(); |
| 5449 |
} |
| 5450 |
|
| 5451 |
_this.context.triggerEvent('media.delete', $target, _this.$editable); |
| 5452 |
}); |
| 5453 |
/** |
| 5454 |
* float me |
| 5455 |
* |
| 5456 |
* @param {String} value |
| 5457 |
*/ |
| 5458 |
|
| 5459 |
this.floatMe = this.wrapCommand(function (value) { |
| 5460 |
var $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(_this.restoreTarget()); |
| 5461 |
$target.toggleClass('note-float-left', value === 'left'); |
| 5462 |
$target.toggleClass('note-float-right', value === 'right'); |
| 5463 |
$target.css('float', value === 'none' ? '' : value); |
| 5464 |
}); |
| 5465 |
/** |
| 5466 |
* resize overlay element |
| 5467 |
* @param {String} value |
| 5468 |
*/ |
| 5469 |
|
| 5470 |
this.resize = this.wrapCommand(function (value) { |
| 5471 |
var $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(_this.restoreTarget()); |
| 5472 |
value = parseFloat(value); |
| 5473 |
|
| 5474 |
if (value === 0) { |
| 5475 |
$target.css('width', ''); |
| 5476 |
} else { |
| 5477 |
$target.css({ |
| 5478 |
width: value * 100 + '%', |
| 5479 |
height: '' |
| 5480 |
}); |
| 5481 |
} |
| 5482 |
}); |
| 5483 |
} |
| 5484 |
|
| 5485 |
Editor_createClass(Editor, [{ |
| 5486 |
key: "initialize", |
| 5487 |
value: function initialize() { |
| 5488 |
var _this2 = this; |
| 5489 |
|
| 5490 |
// bind custom events |
| 5491 |
this.$editable.on('keydown', function (event) { |
| 5492 |
if (event.keyCode === core_key.code.ENTER) { |
| 5493 |
_this2.context.triggerEvent('enter', event); |
| 5494 |
} |
| 5495 |
|
| 5496 |
_this2.context.triggerEvent('keydown', event); // keep a snapshot to limit text on input event |
| 5497 |
|
| 5498 |
|
| 5499 |
_this2.snapshot = _this2.history.makeSnapshot(); |
| 5500 |
_this2.hasKeyShortCut = false; |
| 5501 |
|
| 5502 |
if (!event.isDefaultPrevented()) { |
| 5503 |
if (_this2.options.shortcuts) { |
| 5504 |
_this2.hasKeyShortCut = _this2.handleKeyMap(event); |
| 5505 |
} else { |
| 5506 |
_this2.preventDefaultEditableShortCuts(event); |
| 5507 |
} |
| 5508 |
} |
| 5509 |
|
| 5510 |
if (_this2.isLimited(1, event)) { |
| 5511 |
var lastRange = _this2.getLastRange(); |
| 5512 |
|
| 5513 |
if (lastRange.eo - lastRange.so === 0) { |
| 5514 |
return false; |
| 5515 |
} |
| 5516 |
} |
| 5517 |
|
| 5518 |
_this2.setLastRange(); // record undo in the key event except keyMap. |
| 5519 |
|
| 5520 |
|
| 5521 |
if (_this2.options.recordEveryKeystroke) { |
| 5522 |
if (_this2.hasKeyShortCut === false) { |
| 5523 |
_this2.history.recordUndo(); |
| 5524 |
} |
| 5525 |
} |
| 5526 |
}).on('keyup', function (event) { |
| 5527 |
_this2.setLastRange(); |
| 5528 |
|
| 5529 |
_this2.context.triggerEvent('keyup', event); |
| 5530 |
}).on('focus', function (event) { |
| 5531 |
_this2.setLastRange(); |
| 5532 |
|
| 5533 |
_this2.context.triggerEvent('focus', event); |
| 5534 |
}).on('blur', function (event) { |
| 5535 |
_this2.context.triggerEvent('blur', event); |
| 5536 |
}).on('mousedown', function (event) { |
| 5537 |
_this2.context.triggerEvent('mousedown', event); |
| 5538 |
}).on('mouseup', function (event) { |
| 5539 |
_this2.setLastRange(); |
| 5540 |
|
| 5541 |
_this2.history.recordUndo(); |
| 5542 |
|
| 5543 |
_this2.context.triggerEvent('mouseup', event); |
| 5544 |
}).on('scroll', function (event) { |
| 5545 |
_this2.context.triggerEvent('scroll', event); |
| 5546 |
}).on('paste', function (event) { |
| 5547 |
_this2.setLastRange(); |
| 5548 |
|
| 5549 |
_this2.context.triggerEvent('paste', event); |
| 5550 |
}).on('input', function () { |
| 5551 |
// To limit composition characters (e.g. Korean) |
| 5552 |
if (_this2.isLimited(0) && _this2.snapshot) { |
| 5553 |
_this2.history.applySnapshot(_this2.snapshot); |
| 5554 |
} |
| 5555 |
}); |
| 5556 |
this.$editable.attr('spellcheck', this.options.spellCheck); |
| 5557 |
this.$editable.attr('autocorrect', this.options.spellCheck); |
| 5558 |
|
| 5559 |
if (this.options.disableGrammar) { |
| 5560 |
this.$editable.attr('data-gramm', false); |
| 5561 |
} // init content before set event |
| 5562 |
|
| 5563 |
|
| 5564 |
this.$editable.html(dom.html(this.$note) || dom.emptyPara); |
| 5565 |
this.$editable.on(env.inputEventName, func.debounce(function () { |
| 5566 |
_this2.context.triggerEvent('change', _this2.$editable.html(), _this2.$editable); |
| 5567 |
}, 10)); |
| 5568 |
this.$editable.on('focusin', function (event) { |
| 5569 |
_this2.context.triggerEvent('focusin', event); |
| 5570 |
}).on('focusout', function (event) { |
| 5571 |
_this2.context.triggerEvent('focusout', event); |
| 5572 |
}); |
| 5573 |
|
| 5574 |
if (this.options.airMode) { |
| 5575 |
if (this.options.overrideContextMenu) { |
| 5576 |
this.$editor.on('contextmenu', function (event) { |
| 5577 |
_this2.context.triggerEvent('contextmenu', event); |
| 5578 |
|
| 5579 |
return false; |
| 5580 |
}); |
| 5581 |
} |
| 5582 |
} else { |
| 5583 |
if (this.options.width) { |
| 5584 |
this.$editor.outerWidth(this.options.width); |
| 5585 |
} |
| 5586 |
|
| 5587 |
if (this.options.height) { |
| 5588 |
this.$editable.outerHeight(this.options.height); |
| 5589 |
} |
| 5590 |
|
| 5591 |
if (this.options.maxHeight) { |
| 5592 |
this.$editable.css('max-height', this.options.maxHeight); |
| 5593 |
} |
| 5594 |
|
| 5595 |
if (this.options.minHeight) { |
| 5596 |
this.$editable.css('min-height', this.options.minHeight); |
| 5597 |
} |
| 5598 |
} |
| 5599 |
|
| 5600 |
this.history.recordUndo(); |
| 5601 |
this.setLastRange(); |
| 5602 |
} |
| 5603 |
}, { |
| 5604 |
key: "destroy", |
| 5605 |
value: function destroy() { |
| 5606 |
this.$editable.off(); |
| 5607 |
} |
| 5608 |
}, { |
| 5609 |
key: "handleKeyMap", |
| 5610 |
value: function handleKeyMap(event) { |
| 5611 |
var keyMap = this.options.keyMap[env.isMac ? 'mac' : 'pc']; |
| 5612 |
var keys = []; |
| 5613 |
|
| 5614 |
if (event.metaKey) { |
| 5615 |
keys.push('CMD'); |
| 5616 |
} |
| 5617 |
|
| 5618 |
if (event.ctrlKey && !event.altKey) { |
| 5619 |
keys.push('CTRL'); |
| 5620 |
} |
| 5621 |
|
| 5622 |
if (event.shiftKey) { |
| 5623 |
keys.push('SHIFT'); |
| 5624 |
} |
| 5625 |
|
| 5626 |
var keyName = core_key.nameFromCode[event.keyCode]; |
| 5627 |
|
| 5628 |
if (keyName) { |
| 5629 |
keys.push(keyName); |
| 5630 |
} |
| 5631 |
|
| 5632 |
var eventName = keyMap[keys.join('+')]; |
| 5633 |
|
| 5634 |
if (keyName === 'TAB' && !this.options.tabDisable) { |
| 5635 |
this.afterCommand(); |
| 5636 |
} else if (eventName) { |
| 5637 |
if (this.context.invoke(eventName) !== false) { |
| 5638 |
event.preventDefault(); // if keyMap action was invoked |
| 5639 |
|
| 5640 |
return true; |
| 5641 |
} |
| 5642 |
} else if (core_key.isEdit(event.keyCode)) { |
| 5643 |
this.afterCommand(); |
| 5644 |
} |
| 5645 |
|
| 5646 |
return false; |
| 5647 |
} |
| 5648 |
}, { |
| 5649 |
key: "preventDefaultEditableShortCuts", |
| 5650 |
value: function preventDefaultEditableShortCuts(event) { |
| 5651 |
// B(Bold, 66) / I(Italic, 73) / U(Underline, 85) |
| 5652 |
if ((event.ctrlKey || event.metaKey) && lists.contains([66, 73, 85], event.keyCode)) { |
| 5653 |
event.preventDefault(); |
| 5654 |
} |
| 5655 |
} |
| 5656 |
}, { |
| 5657 |
key: "isLimited", |
| 5658 |
value: function isLimited(pad, event) { |
| 5659 |
pad = pad || 0; |
| 5660 |
|
| 5661 |
if (typeof event !== 'undefined') { |
| 5662 |
if (core_key.isMove(event.keyCode) || core_key.isNavigation(event.keyCode) || event.ctrlKey || event.metaKey || lists.contains([core_key.code.BACKSPACE, core_key.code.DELETE], event.keyCode)) { |
| 5663 |
return false; |
| 5664 |
} |
| 5665 |
} |
| 5666 |
|
| 5667 |
if (this.options.maxTextLength > 0) { |
| 5668 |
if (this.$editable.text().length + pad > this.options.maxTextLength) { |
| 5669 |
return true; |
| 5670 |
} |
| 5671 |
} |
| 5672 |
|
| 5673 |
return false; |
| 5674 |
} |
| 5675 |
/** |
| 5676 |
* create range |
| 5677 |
* @return {WrappedRange} |
| 5678 |
*/ |
| 5679 |
|
| 5680 |
}, { |
| 5681 |
key: "createRange", |
| 5682 |
value: function createRange() { |
| 5683 |
this.focus(); |
| 5684 |
this.setLastRange(); |
| 5685 |
return this.getLastRange(); |
| 5686 |
} |
| 5687 |
/** |
| 5688 |
* create a new range from the list of elements |
| 5689 |
* |
| 5690 |
* @param {list} dom element list |
| 5691 |
* @return {WrappedRange} |
| 5692 |
*/ |
| 5693 |
|
| 5694 |
}, { |
| 5695 |
key: "createRangeFromList", |
| 5696 |
value: function createRangeFromList(lst) { |
| 5697 |
var startRange = range.createFromNodeBefore(lists.head(lst)); |
| 5698 |
var startPoint = startRange.getStartPoint(); |
| 5699 |
var endRange = range.createFromNodeAfter(lists.last(lst)); |
| 5700 |
var endPoint = endRange.getEndPoint(); |
| 5701 |
return range.create(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset); |
| 5702 |
} |
| 5703 |
/** |
| 5704 |
* set the last range |
| 5705 |
* |
| 5706 |
* if given rng is exist, set rng as the last range |
| 5707 |
* or create a new range at the end of the document |
| 5708 |
* |
| 5709 |
* @param {WrappedRange} rng |
| 5710 |
*/ |
| 5711 |
|
| 5712 |
}, { |
| 5713 |
key: "setLastRange", |
| 5714 |
value: function setLastRange(rng) { |
| 5715 |
if (rng) { |
| 5716 |
this.lastRange = rng; |
| 5717 |
} else { |
| 5718 |
this.lastRange = range.create(this.editable); |
| 5719 |
|
| 5720 |
if (external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.lastRange.sc).closest('.note-editable').length === 0) { |
| 5721 |
this.lastRange = range.createFromBodyElement(this.editable); |
| 5722 |
} |
| 5723 |
} |
| 5724 |
} |
| 5725 |
/** |
| 5726 |
* get the last range |
| 5727 |
* |
| 5728 |
* if there is a saved last range, return it |
| 5729 |
* or create a new range and return it |
| 5730 |
* |
| 5731 |
* @return {WrappedRange} |
| 5732 |
*/ |
| 5733 |
|
| 5734 |
}, { |
| 5735 |
key: "getLastRange", |
| 5736 |
value: function getLastRange() { |
| 5737 |
if (!this.lastRange) { |
| 5738 |
this.setLastRange(); |
| 5739 |
} |
| 5740 |
|
| 5741 |
return this.lastRange; |
| 5742 |
} |
| 5743 |
/** |
| 5744 |
* saveRange |
| 5745 |
* |
| 5746 |
* save current range |
| 5747 |
* |
| 5748 |
* @param {Boolean} [thenCollapse=false] |
| 5749 |
*/ |
| 5750 |
|
| 5751 |
}, { |
| 5752 |
key: "saveRange", |
| 5753 |
value: function saveRange(thenCollapse) { |
| 5754 |
if (thenCollapse) { |
| 5755 |
this.getLastRange().collapse().select(); |
| 5756 |
} |
| 5757 |
} |
| 5758 |
/** |
| 5759 |
* restoreRange |
| 5760 |
* |
| 5761 |
* restore lately range |
| 5762 |
*/ |
| 5763 |
|
| 5764 |
}, { |
| 5765 |
key: "restoreRange", |
| 5766 |
value: function restoreRange() { |
| 5767 |
if (this.lastRange) { |
| 5768 |
this.lastRange.select(); |
| 5769 |
this.focus(); |
| 5770 |
} |
| 5771 |
} |
| 5772 |
}, { |
| 5773 |
key: "saveTarget", |
| 5774 |
value: function saveTarget(node) { |
| 5775 |
this.$editable.data('target', node); |
| 5776 |
} |
| 5777 |
}, { |
| 5778 |
key: "clearTarget", |
| 5779 |
value: function clearTarget() { |
| 5780 |
this.$editable.removeData('target'); |
| 5781 |
} |
| 5782 |
}, { |
| 5783 |
key: "restoreTarget", |
| 5784 |
value: function restoreTarget() { |
| 5785 |
return this.$editable.data('target'); |
| 5786 |
} |
| 5787 |
/** |
| 5788 |
* currentStyle |
| 5789 |
* |
| 5790 |
* current style |
| 5791 |
* @return {Object|Boolean} unfocus |
| 5792 |
*/ |
| 5793 |
|
| 5794 |
}, { |
| 5795 |
key: "currentStyle", |
| 5796 |
value: function currentStyle() { |
| 5797 |
var rng = range.create(); |
| 5798 |
|
| 5799 |
if (rng) { |
| 5800 |
rng = rng.normalize(); |
| 5801 |
} |
| 5802 |
|
| 5803 |
return rng ? this.style.current(rng) : this.style.fromNode(this.$editable); |
| 5804 |
} |
| 5805 |
/** |
| 5806 |
* style from node |
| 5807 |
* |
| 5808 |
* @param {jQuery} $node |
| 5809 |
* @return {Object} |
| 5810 |
*/ |
| 5811 |
|
| 5812 |
}, { |
| 5813 |
key: "styleFromNode", |
| 5814 |
value: function styleFromNode($node) { |
| 5815 |
return this.style.fromNode($node); |
| 5816 |
} |
| 5817 |
/** |
| 5818 |
* undo |
| 5819 |
*/ |
| 5820 |
|
| 5821 |
}, { |
| 5822 |
key: "undo", |
| 5823 |
value: function undo() { |
| 5824 |
this.context.triggerEvent('before.command', this.$editable.html()); |
| 5825 |
this.history.undo(); |
| 5826 |
this.context.triggerEvent('change', this.$editable.html(), this.$editable); |
| 5827 |
} |
| 5828 |
/* |
| 5829 |
* commit |
| 5830 |
*/ |
| 5831 |
|
| 5832 |
}, { |
| 5833 |
key: "commit", |
| 5834 |
value: function commit() { |
| 5835 |
this.context.triggerEvent('before.command', this.$editable.html()); |
| 5836 |
this.history.commit(); |
| 5837 |
this.context.triggerEvent('change', this.$editable.html(), this.$editable); |
| 5838 |
} |
| 5839 |
/** |
| 5840 |
* redo |
| 5841 |
*/ |
| 5842 |
|
| 5843 |
}, { |
| 5844 |
key: "redo", |
| 5845 |
value: function redo() { |
| 5846 |
this.context.triggerEvent('before.command', this.$editable.html()); |
| 5847 |
this.history.redo(); |
| 5848 |
this.context.triggerEvent('change', this.$editable.html(), this.$editable); |
| 5849 |
} |
| 5850 |
/** |
| 5851 |
* before command |
| 5852 |
*/ |
| 5853 |
|
| 5854 |
}, { |
| 5855 |
key: "beforeCommand", |
| 5856 |
value: function beforeCommand() { |
| 5857 |
this.context.triggerEvent('before.command', this.$editable.html()); // Set styleWithCSS before run a command |
| 5858 |
|
| 5859 |
document.execCommand('styleWithCSS', false, this.options.styleWithCSS); // keep focus on editable before command execution |
| 5860 |
|
| 5861 |
this.focus(); |
| 5862 |
} |
| 5863 |
/** |
| 5864 |
* after command |
| 5865 |
* @param {Boolean} isPreventTrigger |
| 5866 |
*/ |
| 5867 |
|
| 5868 |
}, { |
| 5869 |
key: "afterCommand", |
| 5870 |
value: function afterCommand(isPreventTrigger) { |
| 5871 |
this.normalizeContent(); |
| 5872 |
this.history.recordUndo(); |
| 5873 |
|
| 5874 |
if (!isPreventTrigger) { |
| 5875 |
this.context.triggerEvent('change', this.$editable.html(), this.$editable); |
| 5876 |
} |
| 5877 |
} |
| 5878 |
/** |
| 5879 |
* handle tab key |
| 5880 |
*/ |
| 5881 |
|
| 5882 |
}, { |
| 5883 |
key: "tab", |
| 5884 |
value: function tab() { |
| 5885 |
var rng = this.getLastRange(); |
| 5886 |
|
| 5887 |
if (rng.isCollapsed() && rng.isOnCell()) { |
| 5888 |
this.table.tab(rng); |
| 5889 |
} else { |
| 5890 |
if (this.options.tabSize === 0) { |
| 5891 |
return false; |
| 5892 |
} |
| 5893 |
|
| 5894 |
if (!this.isLimited(this.options.tabSize)) { |
| 5895 |
this.beforeCommand(); |
| 5896 |
this.typing.insertTab(rng, this.options.tabSize); |
| 5897 |
this.afterCommand(); |
| 5898 |
} |
| 5899 |
} |
| 5900 |
} |
| 5901 |
/** |
| 5902 |
* handle shift+tab key |
| 5903 |
*/ |
| 5904 |
|
| 5905 |
}, { |
| 5906 |
key: "untab", |
| 5907 |
value: function untab() { |
| 5908 |
var rng = this.getLastRange(); |
| 5909 |
|
| 5910 |
if (rng.isCollapsed() && rng.isOnCell()) { |
| 5911 |
this.table.tab(rng, true); |
| 5912 |
} else { |
| 5913 |
if (this.options.tabSize === 0) { |
| 5914 |
return false; |
| 5915 |
} |
| 5916 |
} |
| 5917 |
} |
| 5918 |
/** |
| 5919 |
* run given function between beforeCommand and afterCommand |
| 5920 |
*/ |
| 5921 |
|
| 5922 |
}, { |
| 5923 |
key: "wrapCommand", |
| 5924 |
value: function wrapCommand(fn) { |
| 5925 |
return function () { |
| 5926 |
this.beforeCommand(); |
| 5927 |
fn.apply(this, arguments); |
| 5928 |
this.afterCommand(); |
| 5929 |
}; |
| 5930 |
} |
| 5931 |
/** |
| 5932 |
* insert image |
| 5933 |
* |
| 5934 |
* @param {String} src |
| 5935 |
* @param {String|Function} param |
| 5936 |
* @return {Promise} |
| 5937 |
*/ |
| 5938 |
|
| 5939 |
}, { |
| 5940 |
key: "insertImage", |
| 5941 |
value: function insertImage(src, param) { |
| 5942 |
var _this3 = this; |
| 5943 |
|
| 5944 |
return createImage(src, param).then(function ($image) { |
| 5945 |
_this3.beforeCommand(); |
| 5946 |
|
| 5947 |
if (typeof param === 'function') { |
| 5948 |
param($image); |
| 5949 |
} else { |
| 5950 |
if (typeof param === 'string') { |
| 5951 |
$image.attr('data-filename', param); |
| 5952 |
} |
| 5953 |
|
| 5954 |
$image.css('width', Math.min(_this3.$editable.width(), $image.width())); |
| 5955 |
} |
| 5956 |
|
| 5957 |
$image.show(); |
| 5958 |
|
| 5959 |
_this3.getLastRange().insertNode($image[0]); |
| 5960 |
|
| 5961 |
_this3.setLastRange(range.createFromNodeAfter($image[0]).select()); |
| 5962 |
|
| 5963 |
_this3.afterCommand(); |
| 5964 |
}).fail(function (e) { |
| 5965 |
_this3.context.triggerEvent('image.upload.error', e); |
| 5966 |
}); |
| 5967 |
} |
| 5968 |
/** |
| 5969 |
* insertImages |
| 5970 |
* @param {File[]} files |
| 5971 |
*/ |
| 5972 |
|
| 5973 |
}, { |
| 5974 |
key: "insertImagesAsDataURL", |
| 5975 |
value: function insertImagesAsDataURL(files) { |
| 5976 |
var _this4 = this; |
| 5977 |
|
| 5978 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(files, function (idx, file) { |
| 5979 |
var filename = file.name; |
| 5980 |
|
| 5981 |
if (_this4.options.maximumImageFileSize && _this4.options.maximumImageFileSize < file.size) { |
| 5982 |
_this4.context.triggerEvent('image.upload.error', _this4.lang.image.maximumFileSizeError); |
| 5983 |
} else { |
| 5984 |
readFileAsDataURL(file).then(function (dataURL) { |
| 5985 |
return _this4.insertImage(dataURL, filename); |
| 5986 |
}).fail(function () { |
| 5987 |
_this4.context.triggerEvent('image.upload.error'); |
| 5988 |
}); |
| 5989 |
} |
| 5990 |
}); |
| 5991 |
} |
| 5992 |
/** |
| 5993 |
* insertImagesOrCallback |
| 5994 |
* @param {File[]} files |
| 5995 |
*/ |
| 5996 |
|
| 5997 |
}, { |
| 5998 |
key: "insertImagesOrCallback", |
| 5999 |
value: function insertImagesOrCallback(files) { |
| 6000 |
var callbacks = this.options.callbacks; // If onImageUpload set, |
| 6001 |
|
| 6002 |
if (callbacks.onImageUpload) { |
| 6003 |
this.context.triggerEvent('image.upload', files); // else insert Image as dataURL |
| 6004 |
} else { |
| 6005 |
this.insertImagesAsDataURL(files); |
| 6006 |
} |
| 6007 |
} |
| 6008 |
/** |
| 6009 |
* return selected plain text |
| 6010 |
* @return {String} text |
| 6011 |
*/ |
| 6012 |
|
| 6013 |
}, { |
| 6014 |
key: "getSelectedText", |
| 6015 |
value: function getSelectedText() { |
| 6016 |
var rng = this.getLastRange(); // if range on anchor, expand range with anchor |
| 6017 |
|
| 6018 |
if (rng.isOnAnchor()) { |
| 6019 |
rng = range.createFromNode(dom.ancestor(rng.sc, dom.isAnchor)); |
| 6020 |
} |
| 6021 |
|
| 6022 |
return rng.toString(); |
| 6023 |
} |
| 6024 |
}, { |
| 6025 |
key: "onFormatBlock", |
| 6026 |
value: function onFormatBlock(tagName, $target) { |
| 6027 |
// [workaround] for MSIE, IE need `<` |
| 6028 |
document.execCommand('FormatBlock', false, env.isMSIE ? '<' + tagName + '>' : tagName); // support custom class |
| 6029 |
|
| 6030 |
if ($target && $target.length) { |
| 6031 |
// find the exact element has given tagName |
| 6032 |
if ($target[0].tagName.toUpperCase() !== tagName.toUpperCase()) { |
| 6033 |
$target = $target.find(tagName); |
| 6034 |
} |
| 6035 |
|
| 6036 |
if ($target && $target.length) { |
| 6037 |
var className = $target[0].className || ''; |
| 6038 |
|
| 6039 |
if (className) { |
| 6040 |
var currentRange = this.createRange(); |
| 6041 |
var $parent = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()([currentRange.sc, currentRange.ec]).closest(tagName); |
| 6042 |
$parent.addClass(className); |
| 6043 |
} |
| 6044 |
} |
| 6045 |
} |
| 6046 |
} |
| 6047 |
}, { |
| 6048 |
key: "formatPara", |
| 6049 |
value: function formatPara() { |
| 6050 |
this.formatBlock('P'); |
| 6051 |
} |
| 6052 |
}, { |
| 6053 |
key: "fontStyling", |
| 6054 |
value: function fontStyling(target, value) { |
| 6055 |
var rng = this.getLastRange(); |
| 6056 |
|
| 6057 |
if (rng !== '') { |
| 6058 |
var spans = this.style.styleNodes(rng); |
| 6059 |
this.$editor.find('.note-status-output').html(''); |
| 6060 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(spans).css(target, value); // [workaround] added styled bogus span for style |
| 6061 |
// - also bogus character needed for cursor position |
| 6062 |
|
| 6063 |
if (rng.isCollapsed()) { |
| 6064 |
var firstSpan = lists.head(spans); |
| 6065 |
|
| 6066 |
if (firstSpan && !dom.nodeLength(firstSpan)) { |
| 6067 |
firstSpan.innerHTML = dom.ZERO_WIDTH_NBSP_CHAR; |
| 6068 |
range.createFromNode(firstSpan.firstChild).select(); |
| 6069 |
this.setLastRange(); |
| 6070 |
this.$editable.data(KEY_BOGUS, firstSpan); |
| 6071 |
} |
| 6072 |
} else { |
| 6073 |
this.setLastRange(this.createRangeFromList(spans).select()); |
| 6074 |
} |
| 6075 |
} else { |
| 6076 |
var noteStatusOutput = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.now(); |
| 6077 |
this.$editor.find('.note-status-output').html('<div id="note-status-output-' + noteStatusOutput + '" class="alert alert-info">' + this.lang.output.noSelection + '</div>'); |
| 6078 |
setTimeout(function () { |
| 6079 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('#note-status-output-' + noteStatusOutput).remove(); |
| 6080 |
}, 5000); |
| 6081 |
} |
| 6082 |
} |
| 6083 |
/** |
| 6084 |
* unlink |
| 6085 |
* |
| 6086 |
* @type command |
| 6087 |
*/ |
| 6088 |
|
| 6089 |
}, { |
| 6090 |
key: "unlink", |
| 6091 |
value: function unlink() { |
| 6092 |
var rng = this.getLastRange(); |
| 6093 |
|
| 6094 |
if (rng.isOnAnchor()) { |
| 6095 |
var anchor = dom.ancestor(rng.sc, dom.isAnchor); |
| 6096 |
rng = range.createFromNode(anchor); |
| 6097 |
rng.select(); |
| 6098 |
this.setLastRange(); |
| 6099 |
this.beforeCommand(); |
| 6100 |
document.execCommand('unlink'); |
| 6101 |
this.afterCommand(); |
| 6102 |
} |
| 6103 |
} |
| 6104 |
/** |
| 6105 |
* returns link info |
| 6106 |
* |
| 6107 |
* @return {Object} |
| 6108 |
* @return {WrappedRange} return.range |
| 6109 |
* @return {String} return.text |
| 6110 |
* @return {Boolean} [return.isNewWindow=true] |
| 6111 |
* @return {String} [return.url=""] |
| 6112 |
*/ |
| 6113 |
|
| 6114 |
}, { |
| 6115 |
key: "getLinkInfo", |
| 6116 |
value: function getLinkInfo() { |
| 6117 |
var rng = this.getLastRange().expand(dom.isAnchor); // Get the first anchor on range(for edit). |
| 6118 |
|
| 6119 |
var $anchor = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(lists.head(rng.nodes(dom.isAnchor))); |
| 6120 |
var linkInfo = { |
| 6121 |
range: rng, |
| 6122 |
text: rng.toString(), |
| 6123 |
url: $anchor.length ? $anchor.attr('href') : '' |
| 6124 |
}; // When anchor exists, |
| 6125 |
|
| 6126 |
if ($anchor.length) { |
| 6127 |
// Set isNewWindow by checking its target. |
| 6128 |
linkInfo.isNewWindow = $anchor.attr('target') === '_blank'; |
| 6129 |
} |
| 6130 |
|
| 6131 |
return linkInfo; |
| 6132 |
} |
| 6133 |
}, { |
| 6134 |
key: "addRow", |
| 6135 |
value: function addRow(position) { |
| 6136 |
var rng = this.getLastRange(this.$editable); |
| 6137 |
|
| 6138 |
if (rng.isCollapsed() && rng.isOnCell()) { |
| 6139 |
this.beforeCommand(); |
| 6140 |
this.table.addRow(rng, position); |
| 6141 |
this.afterCommand(); |
| 6142 |
} |
| 6143 |
} |
| 6144 |
}, { |
| 6145 |
key: "addCol", |
| 6146 |
value: function addCol(position) { |
| 6147 |
var rng = this.getLastRange(this.$editable); |
| 6148 |
|
| 6149 |
if (rng.isCollapsed() && rng.isOnCell()) { |
| 6150 |
this.beforeCommand(); |
| 6151 |
this.table.addCol(rng, position); |
| 6152 |
this.afterCommand(); |
| 6153 |
} |
| 6154 |
} |
| 6155 |
}, { |
| 6156 |
key: "deleteRow", |
| 6157 |
value: function deleteRow() { |
| 6158 |
var rng = this.getLastRange(this.$editable); |
| 6159 |
|
| 6160 |
if (rng.isCollapsed() && rng.isOnCell()) { |
| 6161 |
this.beforeCommand(); |
| 6162 |
this.table.deleteRow(rng); |
| 6163 |
this.afterCommand(); |
| 6164 |
} |
| 6165 |
} |
| 6166 |
}, { |
| 6167 |
key: "deleteCol", |
| 6168 |
value: function deleteCol() { |
| 6169 |
var rng = this.getLastRange(this.$editable); |
| 6170 |
|
| 6171 |
if (rng.isCollapsed() && rng.isOnCell()) { |
| 6172 |
this.beforeCommand(); |
| 6173 |
this.table.deleteCol(rng); |
| 6174 |
this.afterCommand(); |
| 6175 |
} |
| 6176 |
} |
| 6177 |
}, { |
| 6178 |
key: "deleteTable", |
| 6179 |
value: function deleteTable() { |
| 6180 |
var rng = this.getLastRange(this.$editable); |
| 6181 |
|
| 6182 |
if (rng.isCollapsed() && rng.isOnCell()) { |
| 6183 |
this.beforeCommand(); |
| 6184 |
this.table.deleteTable(rng); |
| 6185 |
this.afterCommand(); |
| 6186 |
} |
| 6187 |
} |
| 6188 |
/** |
| 6189 |
* @param {Position} pos |
| 6190 |
* @param {jQuery} $target - target element |
| 6191 |
* @param {Boolean} [bKeepRatio] - keep ratio |
| 6192 |
*/ |
| 6193 |
|
| 6194 |
}, { |
| 6195 |
key: "resizeTo", |
| 6196 |
value: function resizeTo(pos, $target, bKeepRatio) { |
| 6197 |
var imageSize; |
| 6198 |
|
| 6199 |
if (bKeepRatio) { |
| 6200 |
var newRatio = pos.y / pos.x; |
| 6201 |
var ratio = $target.data('ratio'); |
| 6202 |
imageSize = { |
| 6203 |
width: ratio > newRatio ? pos.x : pos.y / ratio, |
| 6204 |
height: ratio > newRatio ? pos.x * ratio : pos.y |
| 6205 |
}; |
| 6206 |
} else { |
| 6207 |
imageSize = { |
| 6208 |
width: pos.x, |
| 6209 |
height: pos.y |
| 6210 |
}; |
| 6211 |
} |
| 6212 |
|
| 6213 |
$target.css(imageSize); |
| 6214 |
} |
| 6215 |
/** |
| 6216 |
* returns whether editable area has focus or not. |
| 6217 |
*/ |
| 6218 |
|
| 6219 |
}, { |
| 6220 |
key: "hasFocus", |
| 6221 |
value: function hasFocus() { |
| 6222 |
return this.$editable.is(':focus'); |
| 6223 |
} |
| 6224 |
/** |
| 6225 |
* set focus |
| 6226 |
*/ |
| 6227 |
|
| 6228 |
}, { |
| 6229 |
key: "focus", |
| 6230 |
value: function focus() { |
| 6231 |
// [workaround] Screen will move when page is scolled in IE. |
| 6232 |
// - do focus when not focused |
| 6233 |
if (!this.hasFocus()) { |
| 6234 |
this.$editable.focus(); |
| 6235 |
} |
| 6236 |
} |
| 6237 |
/** |
| 6238 |
* returns whether contents is empty or not. |
| 6239 |
* @return {Boolean} |
| 6240 |
*/ |
| 6241 |
|
| 6242 |
}, { |
| 6243 |
key: "isEmpty", |
| 6244 |
value: function isEmpty() { |
| 6245 |
return dom.isEmpty(this.$editable[0]) || dom.emptyPara === this.$editable.html(); |
| 6246 |
} |
| 6247 |
/** |
| 6248 |
* Removes all contents and restores the editable instance to an _emptyPara_. |
| 6249 |
*/ |
| 6250 |
|
| 6251 |
}, { |
| 6252 |
key: "empty", |
| 6253 |
value: function empty() { |
| 6254 |
this.context.invoke('code', dom.emptyPara); |
| 6255 |
} |
| 6256 |
/** |
| 6257 |
* normalize content |
| 6258 |
*/ |
| 6259 |
|
| 6260 |
}, { |
| 6261 |
key: "normalizeContent", |
| 6262 |
value: function normalizeContent() { |
| 6263 |
this.$editable[0].normalize(); |
| 6264 |
} |
| 6265 |
}]); |
| 6266 |
|
| 6267 |
return Editor; |
| 6268 |
}(); |
| 6269 |
|
| 6270 |
|
| 6271 |
// CONCATENATED MODULE: ./src/js/base/module/Clipboard.js |
| 6272 |
function Clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 6273 |
|
| 6274 |
function Clipboard_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); } } |
| 6275 |
|
| 6276 |
function Clipboard_createClass(Constructor, protoProps, staticProps) { if (protoProps) Clipboard_defineProperties(Constructor.prototype, protoProps); if (staticProps) Clipboard_defineProperties(Constructor, staticProps); return Constructor; } |
| 6277 |
|
| 6278 |
|
| 6279 |
|
| 6280 |
var Clipboard_Clipboard = /*#__PURE__*/function () { |
| 6281 |
function Clipboard(context) { |
| 6282 |
Clipboard_classCallCheck(this, Clipboard); |
| 6283 |
|
| 6284 |
this.context = context; |
| 6285 |
this.$editable = context.layoutInfo.editable; |
| 6286 |
} |
| 6287 |
|
| 6288 |
Clipboard_createClass(Clipboard, [{ |
| 6289 |
key: "initialize", |
| 6290 |
value: function initialize() { |
| 6291 |
this.$editable.on('paste', this.pasteByEvent.bind(this)); |
| 6292 |
} |
| 6293 |
/** |
| 6294 |
* paste by clipboard event |
| 6295 |
* |
| 6296 |
* @param {Event} event |
| 6297 |
*/ |
| 6298 |
|
| 6299 |
}, { |
| 6300 |
key: "pasteByEvent", |
| 6301 |
value: function pasteByEvent(event) { |
| 6302 |
var _this = this; |
| 6303 |
|
| 6304 |
var clipboardData = event.originalEvent.clipboardData; |
| 6305 |
|
| 6306 |
if (clipboardData && clipboardData.items && clipboardData.items.length) { |
| 6307 |
var item = clipboardData.items.length > 1 ? clipboardData.items[1] : lists.head(clipboardData.items); |
| 6308 |
|
| 6309 |
if (item.kind === 'file' && item.type.indexOf('image/') !== -1) { |
| 6310 |
// paste img file |
| 6311 |
this.context.invoke('editor.insertImagesOrCallback', [item.getAsFile()]); |
| 6312 |
event.preventDefault(); |
| 6313 |
} else if (item.kind === 'string') { |
| 6314 |
// paste text with maxTextLength check |
| 6315 |
if (this.context.invoke('editor.isLimited', clipboardData.getData('Text').length)) { |
| 6316 |
event.preventDefault(); |
| 6317 |
} |
| 6318 |
} |
| 6319 |
} else if (window.clipboardData) { |
| 6320 |
// for IE |
| 6321 |
var text = window.clipboardData.getData('text'); |
| 6322 |
|
| 6323 |
if (this.context.invoke('editor.isLimited', text.length)) { |
| 6324 |
event.preventDefault(); |
| 6325 |
} |
| 6326 |
} // Call editor.afterCommand after proceeding default event handler |
| 6327 |
|
| 6328 |
|
| 6329 |
setTimeout(function () { |
| 6330 |
_this.context.invoke('editor.afterCommand'); |
| 6331 |
}, 10); |
| 6332 |
} |
| 6333 |
}]); |
| 6334 |
|
| 6335 |
return Clipboard; |
| 6336 |
}(); |
| 6337 |
|
| 6338 |
|
| 6339 |
// CONCATENATED MODULE: ./src/js/base/module/Dropzone.js |
| 6340 |
function Dropzone_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 6341 |
|
| 6342 |
function Dropzone_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); } } |
| 6343 |
|
| 6344 |
function Dropzone_createClass(Constructor, protoProps, staticProps) { if (protoProps) Dropzone_defineProperties(Constructor.prototype, protoProps); if (staticProps) Dropzone_defineProperties(Constructor, staticProps); return Constructor; } |
| 6345 |
|
| 6346 |
|
| 6347 |
|
| 6348 |
var Dropzone_Dropzone = /*#__PURE__*/function () { |
| 6349 |
function Dropzone(context) { |
| 6350 |
Dropzone_classCallCheck(this, Dropzone); |
| 6351 |
|
| 6352 |
this.context = context; |
| 6353 |
this.$eventListener = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document); |
| 6354 |
this.$editor = context.layoutInfo.editor; |
| 6355 |
this.$editable = context.layoutInfo.editable; |
| 6356 |
this.options = context.options; |
| 6357 |
this.lang = this.options.langInfo; |
| 6358 |
this.documentEventHandlers = {}; |
| 6359 |
this.$dropzone = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(['<div class="note-dropzone">', '<div class="note-dropzone-message"></div>', '</div>'].join('')).prependTo(this.$editor); |
| 6360 |
} |
| 6361 |
/** |
| 6362 |
* attach Drag and Drop Events |
| 6363 |
*/ |
| 6364 |
|
| 6365 |
|
| 6366 |
Dropzone_createClass(Dropzone, [{ |
| 6367 |
key: "initialize", |
| 6368 |
value: function initialize() { |
| 6369 |
if (this.options.disableDragAndDrop) { |
| 6370 |
// prevent default drop event |
| 6371 |
this.documentEventHandlers.onDrop = function (e) { |
| 6372 |
e.preventDefault(); |
| 6373 |
}; // do not consider outside of dropzone |
| 6374 |
|
| 6375 |
|
| 6376 |
this.$eventListener = this.$dropzone; |
| 6377 |
this.$eventListener.on('drop', this.documentEventHandlers.onDrop); |
| 6378 |
} else { |
| 6379 |
this.attachDragAndDropEvent(); |
| 6380 |
} |
| 6381 |
} |
| 6382 |
/** |
| 6383 |
* attach Drag and Drop Events |
| 6384 |
*/ |
| 6385 |
|
| 6386 |
}, { |
| 6387 |
key: "attachDragAndDropEvent", |
| 6388 |
value: function attachDragAndDropEvent() { |
| 6389 |
var _this = this; |
| 6390 |
|
| 6391 |
var collection = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(); |
| 6392 |
var $dropzoneMessage = this.$dropzone.find('.note-dropzone-message'); |
| 6393 |
|
| 6394 |
this.documentEventHandlers.onDragenter = function (e) { |
| 6395 |
var isCodeview = _this.context.invoke('codeview.isActivated'); |
| 6396 |
|
| 6397 |
var hasEditorSize = _this.$editor.width() > 0 && _this.$editor.height() > 0; |
| 6398 |
|
| 6399 |
if (!isCodeview && !collection.length && hasEditorSize) { |
| 6400 |
_this.$editor.addClass('dragover'); |
| 6401 |
|
| 6402 |
_this.$dropzone.width(_this.$editor.width()); |
| 6403 |
|
| 6404 |
_this.$dropzone.height(_this.$editor.height()); |
| 6405 |
|
| 6406 |
$dropzoneMessage.text(_this.lang.image.dragImageHere); |
| 6407 |
} |
| 6408 |
|
| 6409 |
collection = collection.add(e.target); |
| 6410 |
}; |
| 6411 |
|
| 6412 |
this.documentEventHandlers.onDragleave = function (e) { |
| 6413 |
collection = collection.not(e.target); // If nodeName is BODY, then just make it over (fix for IE) |
| 6414 |
|
| 6415 |
if (!collection.length || e.target.nodeName === 'BODY') { |
| 6416 |
collection = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(); |
| 6417 |
|
| 6418 |
_this.$editor.removeClass('dragover'); |
| 6419 |
} |
| 6420 |
}; |
| 6421 |
|
| 6422 |
this.documentEventHandlers.onDrop = function () { |
| 6423 |
collection = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(); |
| 6424 |
|
| 6425 |
_this.$editor.removeClass('dragover'); |
| 6426 |
}; // show dropzone on dragenter when dragging a object to document |
| 6427 |
// -but only if the editor is visible, i.e. has a positive width and height |
| 6428 |
|
| 6429 |
|
| 6430 |
this.$eventListener.on('dragenter', this.documentEventHandlers.onDragenter).on('dragleave', this.documentEventHandlers.onDragleave).on('drop', this.documentEventHandlers.onDrop); // change dropzone's message on hover. |
| 6431 |
|
| 6432 |
this.$dropzone.on('dragenter', function () { |
| 6433 |
_this.$dropzone.addClass('hover'); |
| 6434 |
|
| 6435 |
$dropzoneMessage.text(_this.lang.image.dropImage); |
| 6436 |
}).on('dragleave', function () { |
| 6437 |
_this.$dropzone.removeClass('hover'); |
| 6438 |
|
| 6439 |
$dropzoneMessage.text(_this.lang.image.dragImageHere); |
| 6440 |
}); // attach dropImage |
| 6441 |
|
| 6442 |
this.$dropzone.on('drop', function (event) { |
| 6443 |
var dataTransfer = event.originalEvent.dataTransfer; // stop the browser from opening the dropped content |
| 6444 |
|
| 6445 |
event.preventDefault(); |
| 6446 |
|
| 6447 |
if (dataTransfer && dataTransfer.files && dataTransfer.files.length) { |
| 6448 |
_this.$editable.focus(); |
| 6449 |
|
| 6450 |
_this.context.invoke('editor.insertImagesOrCallback', dataTransfer.files); |
| 6451 |
} else { |
| 6452 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(dataTransfer.types, function (idx, type) { |
| 6453 |
// skip moz-specific types |
| 6454 |
if (type.toLowerCase().indexOf('_moz_') > -1) { |
| 6455 |
return; |
| 6456 |
} |
| 6457 |
|
| 6458 |
var content = dataTransfer.getData(type); |
| 6459 |
|
| 6460 |
if (type.toLowerCase().indexOf('text') > -1) { |
| 6461 |
_this.context.invoke('editor.pasteHTML', content); |
| 6462 |
} else { |
| 6463 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(content).each(function (idx, item) { |
| 6464 |
_this.context.invoke('editor.insertNode', item); |
| 6465 |
}); |
| 6466 |
} |
| 6467 |
}); |
| 6468 |
} |
| 6469 |
}).on('dragover', false); // prevent default dragover event |
| 6470 |
} |
| 6471 |
}, { |
| 6472 |
key: "destroy", |
| 6473 |
value: function destroy() { |
| 6474 |
var _this2 = this; |
| 6475 |
|
| 6476 |
Object.keys(this.documentEventHandlers).forEach(function (key) { |
| 6477 |
_this2.$eventListener.off(key.substr(2).toLowerCase(), _this2.documentEventHandlers[key]); |
| 6478 |
}); |
| 6479 |
this.documentEventHandlers = {}; |
| 6480 |
} |
| 6481 |
}]); |
| 6482 |
|
| 6483 |
return Dropzone; |
| 6484 |
}(); |
| 6485 |
|
| 6486 |
|
| 6487 |
// CONCATENATED MODULE: ./src/js/base/module/Codeview.js |
| 6488 |
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } |
| 6489 |
|
| 6490 |
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } |
| 6491 |
|
| 6492 |
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } |
| 6493 |
|
| 6494 |
function Codeview_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 6495 |
|
| 6496 |
function Codeview_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); } } |
| 6497 |
|
| 6498 |
function Codeview_createClass(Constructor, protoProps, staticProps) { if (protoProps) Codeview_defineProperties(Constructor.prototype, protoProps); if (staticProps) Codeview_defineProperties(Constructor, staticProps); return Constructor; } |
| 6499 |
|
| 6500 |
|
| 6501 |
|
| 6502 |
/** |
| 6503 |
* @class Codeview |
| 6504 |
*/ |
| 6505 |
|
| 6506 |
var Codeview_CodeView = /*#__PURE__*/function () { |
| 6507 |
function CodeView(context) { |
| 6508 |
Codeview_classCallCheck(this, CodeView); |
| 6509 |
|
| 6510 |
this.context = context; |
| 6511 |
this.$editor = context.layoutInfo.editor; |
| 6512 |
this.$editable = context.layoutInfo.editable; |
| 6513 |
this.$codable = context.layoutInfo.codable; |
| 6514 |
this.options = context.options; |
| 6515 |
this.CodeMirrorConstructor = window.CodeMirror; |
| 6516 |
|
| 6517 |
if (this.options.codemirror.CodeMirrorConstructor) { |
| 6518 |
this.CodeMirrorConstructor = this.options.codemirror.CodeMirrorConstructor; |
| 6519 |
} |
| 6520 |
} |
| 6521 |
|
| 6522 |
Codeview_createClass(CodeView, [{ |
| 6523 |
key: "sync", |
| 6524 |
value: function sync(html) { |
| 6525 |
var isCodeview = this.isActivated(); |
| 6526 |
var CodeMirror = this.CodeMirrorConstructor; |
| 6527 |
|
| 6528 |
if (isCodeview) { |
| 6529 |
if (html) { |
| 6530 |
if (CodeMirror) { |
| 6531 |
this.$codable.data('cmEditor').getDoc().setValue(html); |
| 6532 |
} else { |
| 6533 |
this.$codable.val(html); |
| 6534 |
} |
| 6535 |
} else { |
| 6536 |
if (CodeMirror) { |
| 6537 |
this.$codable.data('cmEditor').save(); |
| 6538 |
} |
| 6539 |
} |
| 6540 |
} |
| 6541 |
} |
| 6542 |
}, { |
| 6543 |
key: "initialize", |
| 6544 |
value: function initialize() { |
| 6545 |
var _this = this; |
| 6546 |
|
| 6547 |
this.$codable.on('keyup', function (event) { |
| 6548 |
if (event.keyCode === core_key.code.ESCAPE) { |
| 6549 |
_this.deactivate(); |
| 6550 |
} |
| 6551 |
}); |
| 6552 |
} |
| 6553 |
/** |
| 6554 |
* @return {Boolean} |
| 6555 |
*/ |
| 6556 |
|
| 6557 |
}, { |
| 6558 |
key: "isActivated", |
| 6559 |
value: function isActivated() { |
| 6560 |
return this.$editor.hasClass('codeview'); |
| 6561 |
} |
| 6562 |
/** |
| 6563 |
* toggle codeview |
| 6564 |
*/ |
| 6565 |
|
| 6566 |
}, { |
| 6567 |
key: "toggle", |
| 6568 |
value: function toggle() { |
| 6569 |
if (this.isActivated()) { |
| 6570 |
this.deactivate(); |
| 6571 |
} else { |
| 6572 |
this.activate(); |
| 6573 |
} |
| 6574 |
|
| 6575 |
this.context.triggerEvent('codeview.toggled'); |
| 6576 |
} |
| 6577 |
/** |
| 6578 |
* purify input value |
| 6579 |
* @param value |
| 6580 |
* @returns {*} |
| 6581 |
*/ |
| 6582 |
|
| 6583 |
}, { |
| 6584 |
key: "purify", |
| 6585 |
value: function purify(value) { |
| 6586 |
if (this.options.codeviewFilter) { |
| 6587 |
// filter code view regex |
| 6588 |
value = value.replace(this.options.codeviewFilterRegex, ''); // allow specific iframe tag |
| 6589 |
|
| 6590 |
if (this.options.codeviewIframeFilter) { |
| 6591 |
var whitelist = this.options.codeviewIframeWhitelistSrc.concat(this.options.codeviewIframeWhitelistSrcBase); |
| 6592 |
value = value.replace(/(<iframe.*?>.*?(?:<\/iframe>)?)/gi, function (tag) { |
| 6593 |
// remove if src attribute is duplicated |
| 6594 |
if (/<.+src(?==?('|"|\s)?)[\s\S]+src(?=('|"|\s)?)[^>]*?>/i.test(tag)) { |
| 6595 |
return ''; |
| 6596 |
} |
| 6597 |
|
| 6598 |
var _iterator = _createForOfIteratorHelper(whitelist), |
| 6599 |
_step; |
| 6600 |
|
| 6601 |
try { |
| 6602 |
for (_iterator.s(); !(_step = _iterator.n()).done;) { |
| 6603 |
var src = _step.value; |
| 6604 |
|
| 6605 |
// pass if src is trusted |
| 6606 |
if (new RegExp('src="(https?:)?\/\/' + src.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '\/(.+)"').test(tag)) { |
| 6607 |
return tag; |
| 6608 |
} |
| 6609 |
} |
| 6610 |
} catch (err) { |
| 6611 |
_iterator.e(err); |
| 6612 |
} finally { |
| 6613 |
_iterator.f(); |
| 6614 |
} |
| 6615 |
|
| 6616 |
return ''; |
| 6617 |
}); |
| 6618 |
} |
| 6619 |
} |
| 6620 |
|
| 6621 |
return value; |
| 6622 |
} |
| 6623 |
/** |
| 6624 |
* activate code view |
| 6625 |
*/ |
| 6626 |
|
| 6627 |
}, { |
| 6628 |
key: "activate", |
| 6629 |
value: function activate() { |
| 6630 |
var _this2 = this; |
| 6631 |
|
| 6632 |
var CodeMirror = this.CodeMirrorConstructor; |
| 6633 |
this.$codable.val(dom.html(this.$editable, this.options.prettifyHtml)); |
| 6634 |
this.$codable.height(this.$editable.height()); |
| 6635 |
this.context.invoke('toolbar.updateCodeview', true); |
| 6636 |
this.context.invoke('airPopover.updateCodeview', true); |
| 6637 |
this.$editor.addClass('codeview'); |
| 6638 |
this.$codable.focus(); // activate CodeMirror as codable |
| 6639 |
|
| 6640 |
if (CodeMirror) { |
| 6641 |
var cmEditor = CodeMirror.fromTextArea(this.$codable[0], this.options.codemirror); // CodeMirror TernServer |
| 6642 |
|
| 6643 |
if (this.options.codemirror.tern) { |
| 6644 |
var server = new CodeMirror.TernServer(this.options.codemirror.tern); |
| 6645 |
cmEditor.ternServer = server; |
| 6646 |
cmEditor.on('cursorActivity', function (cm) { |
| 6647 |
server.updateArgHints(cm); |
| 6648 |
}); |
| 6649 |
} |
| 6650 |
|
| 6651 |
cmEditor.on('blur', function (event) { |
| 6652 |
_this2.context.triggerEvent('blur.codeview', cmEditor.getValue(), event); |
| 6653 |
}); |
| 6654 |
cmEditor.on('change', function () { |
| 6655 |
_this2.context.triggerEvent('change.codeview', cmEditor.getValue(), cmEditor); |
| 6656 |
}); // CodeMirror hasn't Padding. |
| 6657 |
|
| 6658 |
cmEditor.setSize(null, this.$editable.outerHeight()); |
| 6659 |
this.$codable.data('cmEditor', cmEditor); |
| 6660 |
} else { |
| 6661 |
this.$codable.on('blur', function (event) { |
| 6662 |
_this2.context.triggerEvent('blur.codeview', _this2.$codable.val(), event); |
| 6663 |
}); |
| 6664 |
this.$codable.on('input', function () { |
| 6665 |
_this2.context.triggerEvent('change.codeview', _this2.$codable.val(), _this2.$codable); |
| 6666 |
}); |
| 6667 |
} |
| 6668 |
} |
| 6669 |
/** |
| 6670 |
* deactivate code view |
| 6671 |
*/ |
| 6672 |
|
| 6673 |
}, { |
| 6674 |
key: "deactivate", |
| 6675 |
value: function deactivate() { |
| 6676 |
var CodeMirror = this.CodeMirrorConstructor; // deactivate CodeMirror as codable |
| 6677 |
|
| 6678 |
if (CodeMirror) { |
| 6679 |
var cmEditor = this.$codable.data('cmEditor'); |
| 6680 |
this.$codable.val(cmEditor.getValue()); |
| 6681 |
cmEditor.toTextArea(); |
| 6682 |
} |
| 6683 |
|
| 6684 |
var value = this.purify(dom.value(this.$codable, this.options.prettifyHtml) || dom.emptyPara); |
| 6685 |
var isChange = this.$editable.html() !== value; |
| 6686 |
this.$editable.html(value); |
| 6687 |
this.$editable.height(this.options.height ? this.$codable.height() : 'auto'); |
| 6688 |
this.$editor.removeClass('codeview'); |
| 6689 |
|
| 6690 |
if (isChange) { |
| 6691 |
this.context.triggerEvent('change', this.$editable.html(), this.$editable); |
| 6692 |
} |
| 6693 |
|
| 6694 |
this.$editable.focus(); |
| 6695 |
this.context.invoke('toolbar.updateCodeview', false); |
| 6696 |
this.context.invoke('airPopover.updateCodeview', false); |
| 6697 |
} |
| 6698 |
}, { |
| 6699 |
key: "destroy", |
| 6700 |
value: function destroy() { |
| 6701 |
if (this.isActivated()) { |
| 6702 |
this.deactivate(); |
| 6703 |
} |
| 6704 |
} |
| 6705 |
}]); |
| 6706 |
|
| 6707 |
return CodeView; |
| 6708 |
}(); |
| 6709 |
|
| 6710 |
|
| 6711 |
// CONCATENATED MODULE: ./src/js/base/module/Statusbar.js |
| 6712 |
function Statusbar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 6713 |
|
| 6714 |
function Statusbar_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); } } |
| 6715 |
|
| 6716 |
function Statusbar_createClass(Constructor, protoProps, staticProps) { if (protoProps) Statusbar_defineProperties(Constructor.prototype, protoProps); if (staticProps) Statusbar_defineProperties(Constructor, staticProps); return Constructor; } |
| 6717 |
|
| 6718 |
|
| 6719 |
var EDITABLE_PADDING = 24; |
| 6720 |
|
| 6721 |
var Statusbar_Statusbar = /*#__PURE__*/function () { |
| 6722 |
function Statusbar(context) { |
| 6723 |
Statusbar_classCallCheck(this, Statusbar); |
| 6724 |
|
| 6725 |
this.$document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document); |
| 6726 |
this.$statusbar = context.layoutInfo.statusbar; |
| 6727 |
this.$editable = context.layoutInfo.editable; |
| 6728 |
this.options = context.options; |
| 6729 |
} |
| 6730 |
|
| 6731 |
Statusbar_createClass(Statusbar, [{ |
| 6732 |
key: "initialize", |
| 6733 |
value: function initialize() { |
| 6734 |
var _this = this; |
| 6735 |
|
| 6736 |
if (this.options.airMode || this.options.disableResizeEditor) { |
| 6737 |
this.destroy(); |
| 6738 |
return; |
| 6739 |
} |
| 6740 |
|
| 6741 |
this.$statusbar.on('mousedown', function (event) { |
| 6742 |
event.preventDefault(); |
| 6743 |
event.stopPropagation(); |
| 6744 |
|
| 6745 |
var editableTop = _this.$editable.offset().top - _this.$document.scrollTop(); |
| 6746 |
|
| 6747 |
var onMouseMove = function onMouseMove(event) { |
| 6748 |
var height = event.clientY - (editableTop + EDITABLE_PADDING); |
| 6749 |
height = _this.options.minheight > 0 ? Math.max(height, _this.options.minheight) : height; |
| 6750 |
height = _this.options.maxHeight > 0 ? Math.min(height, _this.options.maxHeight) : height; |
| 6751 |
|
| 6752 |
_this.$editable.height(height); |
| 6753 |
}; |
| 6754 |
|
| 6755 |
_this.$document.on('mousemove', onMouseMove).one('mouseup', function () { |
| 6756 |
_this.$document.off('mousemove', onMouseMove); |
| 6757 |
}); |
| 6758 |
}); |
| 6759 |
} |
| 6760 |
}, { |
| 6761 |
key: "destroy", |
| 6762 |
value: function destroy() { |
| 6763 |
this.$statusbar.off(); |
| 6764 |
this.$statusbar.addClass('locked'); |
| 6765 |
} |
| 6766 |
}]); |
| 6767 |
|
| 6768 |
return Statusbar; |
| 6769 |
}(); |
| 6770 |
|
| 6771 |
|
| 6772 |
// CONCATENATED MODULE: ./src/js/base/module/Fullscreen.js |
| 6773 |
function Fullscreen_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 6774 |
|
| 6775 |
function Fullscreen_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); } } |
| 6776 |
|
| 6777 |
function Fullscreen_createClass(Constructor, protoProps, staticProps) { if (protoProps) Fullscreen_defineProperties(Constructor.prototype, protoProps); if (staticProps) Fullscreen_defineProperties(Constructor, staticProps); return Constructor; } |
| 6778 |
|
| 6779 |
|
| 6780 |
|
| 6781 |
var Fullscreen_Fullscreen = /*#__PURE__*/function () { |
| 6782 |
function Fullscreen(context) { |
| 6783 |
var _this = this; |
| 6784 |
|
| 6785 |
Fullscreen_classCallCheck(this, Fullscreen); |
| 6786 |
|
| 6787 |
this.context = context; |
| 6788 |
this.$editor = context.layoutInfo.editor; |
| 6789 |
this.$toolbar = context.layoutInfo.toolbar; |
| 6790 |
this.$editable = context.layoutInfo.editable; |
| 6791 |
this.$codable = context.layoutInfo.codable; |
| 6792 |
this.$window = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(window); |
| 6793 |
this.$scrollbar = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('html, body'); |
| 6794 |
|
| 6795 |
this.onResize = function () { |
| 6796 |
_this.resizeTo({ |
| 6797 |
h: _this.$window.height() - _this.$toolbar.outerHeight() |
| 6798 |
}); |
| 6799 |
}; |
| 6800 |
} |
| 6801 |
|
| 6802 |
Fullscreen_createClass(Fullscreen, [{ |
| 6803 |
key: "resizeTo", |
| 6804 |
value: function resizeTo(size) { |
| 6805 |
this.$editable.css('height', size.h); |
| 6806 |
this.$codable.css('height', size.h); |
| 6807 |
|
| 6808 |
if (this.$codable.data('cmeditor')) { |
| 6809 |
this.$codable.data('cmeditor').setsize(null, size.h); |
| 6810 |
} |
| 6811 |
} |
| 6812 |
/** |
| 6813 |
* toggle fullscreen |
| 6814 |
*/ |
| 6815 |
|
| 6816 |
}, { |
| 6817 |
key: "toggle", |
| 6818 |
value: function toggle() { |
| 6819 |
this.$editor.toggleClass('fullscreen'); |
| 6820 |
|
| 6821 |
if (this.isFullscreen()) { |
| 6822 |
this.$editable.data('orgHeight', this.$editable.css('height')); |
| 6823 |
this.$editable.data('orgMaxHeight', this.$editable.css('maxHeight')); |
| 6824 |
this.$editable.css('maxHeight', ''); |
| 6825 |
this.$window.on('resize', this.onResize).trigger('resize'); |
| 6826 |
this.$scrollbar.css('overflow', 'hidden'); |
| 6827 |
} else { |
| 6828 |
this.$window.off('resize', this.onResize); |
| 6829 |
this.resizeTo({ |
| 6830 |
h: this.$editable.data('orgHeight') |
| 6831 |
}); |
| 6832 |
this.$editable.css('maxHeight', this.$editable.css('orgMaxHeight')); |
| 6833 |
this.$scrollbar.css('overflow', 'visible'); |
| 6834 |
} |
| 6835 |
|
| 6836 |
this.context.invoke('toolbar.updateFullscreen', this.isFullscreen()); |
| 6837 |
} |
| 6838 |
}, { |
| 6839 |
key: "isFullscreen", |
| 6840 |
value: function isFullscreen() { |
| 6841 |
return this.$editor.hasClass('fullscreen'); |
| 6842 |
} |
| 6843 |
}]); |
| 6844 |
|
| 6845 |
return Fullscreen; |
| 6846 |
}(); |
| 6847 |
|
| 6848 |
|
| 6849 |
// CONCATENATED MODULE: ./src/js/base/module/Handle.js |
| 6850 |
function Handle_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 6851 |
|
| 6852 |
function Handle_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); } } |
| 6853 |
|
| 6854 |
function Handle_createClass(Constructor, protoProps, staticProps) { if (protoProps) Handle_defineProperties(Constructor.prototype, protoProps); if (staticProps) Handle_defineProperties(Constructor, staticProps); return Constructor; } |
| 6855 |
|
| 6856 |
|
| 6857 |
|
| 6858 |
|
| 6859 |
var Handle_Handle = /*#__PURE__*/function () { |
| 6860 |
function Handle(context) { |
| 6861 |
var _this = this; |
| 6862 |
|
| 6863 |
Handle_classCallCheck(this, Handle); |
| 6864 |
|
| 6865 |
this.context = context; |
| 6866 |
this.$document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document); |
| 6867 |
this.$editingArea = context.layoutInfo.editingArea; |
| 6868 |
this.options = context.options; |
| 6869 |
this.lang = this.options.langInfo; |
| 6870 |
this.events = { |
| 6871 |
'summernote.mousedown': function summernoteMousedown(we, e) { |
| 6872 |
if (_this.update(e.target, e)) { |
| 6873 |
e.preventDefault(); |
| 6874 |
} |
| 6875 |
}, |
| 6876 |
'summernote.keyup summernote.scroll summernote.change summernote.dialog.shown': function summernoteKeyupSummernoteScrollSummernoteChangeSummernoteDialogShown() { |
| 6877 |
_this.update(); |
| 6878 |
}, |
| 6879 |
'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() { |
| 6880 |
_this.hide(); |
| 6881 |
}, |
| 6882 |
'summernote.codeview.toggled': function summernoteCodeviewToggled() { |
| 6883 |
_this.update(); |
| 6884 |
} |
| 6885 |
}; |
| 6886 |
} |
| 6887 |
|
| 6888 |
Handle_createClass(Handle, [{ |
| 6889 |
key: "initialize", |
| 6890 |
value: function initialize() { |
| 6891 |
var _this2 = this; |
| 6892 |
|
| 6893 |
this.$handle = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(['<div class="note-handle">', '<div class="note-control-selection">', '<div class="note-control-selection-bg"></div>', '<div class="note-control-holder note-control-nw"></div>', '<div class="note-control-holder note-control-ne"></div>', '<div class="note-control-holder note-control-sw"></div>', '<div class="', this.options.disableResizeImage ? 'note-control-holder' : 'note-control-sizing', ' note-control-se"></div>', this.options.disableResizeImage ? '' : '<div class="note-control-selection-info"></div>', '</div>', '</div>'].join('')).prependTo(this.$editingArea); |
| 6894 |
this.$handle.on('mousedown', function (event) { |
| 6895 |
if (dom.isControlSizing(event.target)) { |
| 6896 |
event.preventDefault(); |
| 6897 |
event.stopPropagation(); |
| 6898 |
|
| 6899 |
var $target = _this2.$handle.find('.note-control-selection').data('target'); |
| 6900 |
|
| 6901 |
var posStart = $target.offset(); |
| 6902 |
|
| 6903 |
var scrollTop = _this2.$document.scrollTop(); |
| 6904 |
|
| 6905 |
var onMouseMove = function onMouseMove(event) { |
| 6906 |
_this2.context.invoke('editor.resizeTo', { |
| 6907 |
x: event.clientX - posStart.left, |
| 6908 |
y: event.clientY - (posStart.top - scrollTop) |
| 6909 |
}, $target, !event.shiftKey); |
| 6910 |
|
| 6911 |
_this2.update($target[0], event); |
| 6912 |
}; |
| 6913 |
|
| 6914 |
_this2.$document.on('mousemove', onMouseMove).one('mouseup', function (e) { |
| 6915 |
e.preventDefault(); |
| 6916 |
|
| 6917 |
_this2.$document.off('mousemove', onMouseMove); |
| 6918 |
|
| 6919 |
_this2.context.invoke('editor.afterCommand'); |
| 6920 |
}); |
| 6921 |
|
| 6922 |
if (!$target.data('ratio')) { |
| 6923 |
// original ratio. |
| 6924 |
$target.data('ratio', $target.height() / $target.width()); |
| 6925 |
} |
| 6926 |
} |
| 6927 |
}); // Listen for scrolling on the handle overlay. |
| 6928 |
|
| 6929 |
this.$handle.on('wheel', function (e) { |
| 6930 |
e.preventDefault(); |
| 6931 |
|
| 6932 |
_this2.update(); |
| 6933 |
}); |
| 6934 |
} |
| 6935 |
}, { |
| 6936 |
key: "destroy", |
| 6937 |
value: function destroy() { |
| 6938 |
this.$handle.remove(); |
| 6939 |
} |
| 6940 |
}, { |
| 6941 |
key: "update", |
| 6942 |
value: function update(target, event) { |
| 6943 |
if (this.context.isDisabled()) { |
| 6944 |
return false; |
| 6945 |
} |
| 6946 |
|
| 6947 |
var isImage = dom.isImg(target); |
| 6948 |
var $selection = this.$handle.find('.note-control-selection'); |
| 6949 |
this.context.invoke('imagePopover.update', target, event); |
| 6950 |
|
| 6951 |
if (isImage) { |
| 6952 |
var $image = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(target); |
| 6953 |
var position = $image.position(); |
| 6954 |
var pos = { |
| 6955 |
left: position.left + parseInt($image.css('marginLeft'), 10), |
| 6956 |
top: position.top + parseInt($image.css('marginTop'), 10) |
| 6957 |
}; // exclude margin |
| 6958 |
|
| 6959 |
var imageSize = { |
| 6960 |
w: $image.outerWidth(false), |
| 6961 |
h: $image.outerHeight(false) |
| 6962 |
}; |
| 6963 |
$selection.css({ |
| 6964 |
display: 'block', |
| 6965 |
left: pos.left, |
| 6966 |
top: pos.top, |
| 6967 |
width: imageSize.w, |
| 6968 |
height: imageSize.h |
| 6969 |
}).data('target', $image); // save current image element. |
| 6970 |
|
| 6971 |
var origImageObj = new Image(); |
| 6972 |
origImageObj.src = $image.attr('src'); |
| 6973 |
var sizingText = imageSize.w + 'x' + imageSize.h + ' (' + this.lang.image.original + ': ' + origImageObj.width + 'x' + origImageObj.height + ')'; |
| 6974 |
$selection.find('.note-control-selection-info').text(sizingText); |
| 6975 |
this.context.invoke('editor.saveTarget', target); |
| 6976 |
} else { |
| 6977 |
this.hide(); |
| 6978 |
} |
| 6979 |
|
| 6980 |
return isImage; |
| 6981 |
} |
| 6982 |
/** |
| 6983 |
* hide |
| 6984 |
* |
| 6985 |
* @param {jQuery} $handle |
| 6986 |
*/ |
| 6987 |
|
| 6988 |
}, { |
| 6989 |
key: "hide", |
| 6990 |
value: function hide() { |
| 6991 |
this.context.invoke('editor.clearTarget'); |
| 6992 |
this.$handle.children().hide(); |
| 6993 |
} |
| 6994 |
}]); |
| 6995 |
|
| 6996 |
return Handle; |
| 6997 |
}(); |
| 6998 |
|
| 6999 |
|
| 7000 |
// CONCATENATED MODULE: ./src/js/base/module/AutoLink.js |
| 7001 |
function AutoLink_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 7002 |
|
| 7003 |
function AutoLink_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); } } |
| 7004 |
|
| 7005 |
function AutoLink_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoLink_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoLink_defineProperties(Constructor, staticProps); return Constructor; } |
| 7006 |
|
| 7007 |
|
| 7008 |
|
| 7009 |
|
| 7010 |
var defaultScheme = 'http://'; |
| 7011 |
var linkPattern = /^([A-Za-z][A-Za-z0-9+-.]*\:[\/]{2}|tel:|mailto:[A-Z0-9._%+-]+@)?(www\.)?(.+)$/i; |
| 7012 |
|
| 7013 |
var AutoLink_AutoLink = /*#__PURE__*/function () { |
| 7014 |
function AutoLink(context) { |
| 7015 |
var _this = this; |
| 7016 |
|
| 7017 |
AutoLink_classCallCheck(this, AutoLink); |
| 7018 |
|
| 7019 |
this.context = context; |
| 7020 |
this.options = context.options; |
| 7021 |
this.events = { |
| 7022 |
'summernote.keyup': function summernoteKeyup(we, e) { |
| 7023 |
if (!e.isDefaultPrevented()) { |
| 7024 |
_this.handleKeyup(e); |
| 7025 |
} |
| 7026 |
}, |
| 7027 |
'summernote.keydown': function summernoteKeydown(we, e) { |
| 7028 |
_this.handleKeydown(e); |
| 7029 |
} |
| 7030 |
}; |
| 7031 |
} |
| 7032 |
|
| 7033 |
AutoLink_createClass(AutoLink, [{ |
| 7034 |
key: "initialize", |
| 7035 |
value: function initialize() { |
| 7036 |
this.lastWordRange = null; |
| 7037 |
} |
| 7038 |
}, { |
| 7039 |
key: "destroy", |
| 7040 |
value: function destroy() { |
| 7041 |
this.lastWordRange = null; |
| 7042 |
} |
| 7043 |
}, { |
| 7044 |
key: "replace", |
| 7045 |
value: function replace() { |
| 7046 |
if (!this.lastWordRange) { |
| 7047 |
return; |
| 7048 |
} |
| 7049 |
|
| 7050 |
var keyword = this.lastWordRange.toString(); |
| 7051 |
var match = keyword.match(linkPattern); |
| 7052 |
|
| 7053 |
if (match && (match[1] || match[2])) { |
| 7054 |
var link = match[1] ? keyword : defaultScheme + keyword; |
| 7055 |
var urlText = this.options.showDomainOnlyForAutolink ? keyword.replace(/^(?:https?:\/\/)?(?:tel?:?)?(?:mailto?:?)?(?:www\.)?/i, '').split('/')[0] : keyword; |
| 7056 |
var node = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<a />').html(urlText).attr('href', link)[0]; |
| 7057 |
|
| 7058 |
if (this.context.options.linkTargetBlank) { |
| 7059 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).attr('target', '_blank'); |
| 7060 |
} |
| 7061 |
|
| 7062 |
this.lastWordRange.insertNode(node); |
| 7063 |
this.lastWordRange = null; |
| 7064 |
this.context.invoke('editor.focus'); |
| 7065 |
} |
| 7066 |
} |
| 7067 |
}, { |
| 7068 |
key: "handleKeydown", |
| 7069 |
value: function handleKeydown(e) { |
| 7070 |
if (lists.contains([core_key.code.ENTER, core_key.code.SPACE], e.keyCode)) { |
| 7071 |
var wordRange = this.context.invoke('editor.createRange').getWordRange(); |
| 7072 |
this.lastWordRange = wordRange; |
| 7073 |
} |
| 7074 |
} |
| 7075 |
}, { |
| 7076 |
key: "handleKeyup", |
| 7077 |
value: function handleKeyup(e) { |
| 7078 |
if (lists.contains([core_key.code.ENTER, core_key.code.SPACE], e.keyCode)) { |
| 7079 |
this.replace(); |
| 7080 |
} |
| 7081 |
} |
| 7082 |
}]); |
| 7083 |
|
| 7084 |
return AutoLink; |
| 7085 |
}(); |
| 7086 |
|
| 7087 |
|
| 7088 |
// CONCATENATED MODULE: ./src/js/base/module/AutoSync.js |
| 7089 |
function AutoSync_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 7090 |
|
| 7091 |
function AutoSync_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); } } |
| 7092 |
|
| 7093 |
function AutoSync_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoSync_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoSync_defineProperties(Constructor, staticProps); return Constructor; } |
| 7094 |
|
| 7095 |
|
| 7096 |
/** |
| 7097 |
* textarea auto sync. |
| 7098 |
*/ |
| 7099 |
|
| 7100 |
var AutoSync_AutoSync = /*#__PURE__*/function () { |
| 7101 |
function AutoSync(context) { |
| 7102 |
var _this = this; |
| 7103 |
|
| 7104 |
AutoSync_classCallCheck(this, AutoSync); |
| 7105 |
|
| 7106 |
this.$note = context.layoutInfo.note; |
| 7107 |
this.events = { |
| 7108 |
'summernote.change': function summernoteChange() { |
| 7109 |
_this.$note.val(context.invoke('code')); |
| 7110 |
} |
| 7111 |
}; |
| 7112 |
} |
| 7113 |
|
| 7114 |
AutoSync_createClass(AutoSync, [{ |
| 7115 |
key: "shouldInitialize", |
| 7116 |
value: function shouldInitialize() { |
| 7117 |
return dom.isTextarea(this.$note[0]); |
| 7118 |
} |
| 7119 |
}]); |
| 7120 |
|
| 7121 |
return AutoSync; |
| 7122 |
}(); |
| 7123 |
|
| 7124 |
|
| 7125 |
// CONCATENATED MODULE: ./src/js/base/module/AutoReplace.js |
| 7126 |
function AutoReplace_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 7127 |
|
| 7128 |
function AutoReplace_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); } } |
| 7129 |
|
| 7130 |
function AutoReplace_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoReplace_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoReplace_defineProperties(Constructor, staticProps); return Constructor; } |
| 7131 |
|
| 7132 |
|
| 7133 |
|
| 7134 |
|
| 7135 |
|
| 7136 |
var AutoReplace_AutoReplace = /*#__PURE__*/function () { |
| 7137 |
function AutoReplace(context) { |
| 7138 |
var _this = this; |
| 7139 |
|
| 7140 |
AutoReplace_classCallCheck(this, AutoReplace); |
| 7141 |
|
| 7142 |
this.context = context; |
| 7143 |
this.options = context.options.replace || {}; |
| 7144 |
this.keys = [core_key.code.ENTER, core_key.code.SPACE, core_key.code.PERIOD, core_key.code.COMMA, core_key.code.SEMICOLON, core_key.code.SLASH]; |
| 7145 |
this.previousKeydownCode = null; |
| 7146 |
this.events = { |
| 7147 |
'summernote.keyup': function summernoteKeyup(we, e) { |
| 7148 |
if (!e.isDefaultPrevented()) { |
| 7149 |
_this.handleKeyup(e); |
| 7150 |
} |
| 7151 |
}, |
| 7152 |
'summernote.keydown': function summernoteKeydown(we, e) { |
| 7153 |
_this.handleKeydown(e); |
| 7154 |
} |
| 7155 |
}; |
| 7156 |
} |
| 7157 |
|
| 7158 |
AutoReplace_createClass(AutoReplace, [{ |
| 7159 |
key: "shouldInitialize", |
| 7160 |
value: function shouldInitialize() { |
| 7161 |
return !!this.options.match; |
| 7162 |
} |
| 7163 |
}, { |
| 7164 |
key: "initialize", |
| 7165 |
value: function initialize() { |
| 7166 |
this.lastWord = null; |
| 7167 |
} |
| 7168 |
}, { |
| 7169 |
key: "destroy", |
| 7170 |
value: function destroy() { |
| 7171 |
this.lastWord = null; |
| 7172 |
} |
| 7173 |
}, { |
| 7174 |
key: "replace", |
| 7175 |
value: function replace() { |
| 7176 |
if (!this.lastWord) { |
| 7177 |
return; |
| 7178 |
} |
| 7179 |
|
| 7180 |
var self = this; |
| 7181 |
var keyword = this.lastWord.toString(); |
| 7182 |
this.options.match(keyword, function (match) { |
| 7183 |
if (match) { |
| 7184 |
var node = ''; |
| 7185 |
|
| 7186 |
if (typeof match === 'string') { |
| 7187 |
node = dom.createText(match); |
| 7188 |
} else if (match instanceof jQuery) { |
| 7189 |
node = match[0]; |
| 7190 |
} else if (match instanceof Node) { |
| 7191 |
node = match; |
| 7192 |
} |
| 7193 |
|
| 7194 |
if (!node) return; |
| 7195 |
self.lastWord.insertNode(node); |
| 7196 |
self.lastWord = null; |
| 7197 |
self.context.invoke('editor.focus'); |
| 7198 |
} |
| 7199 |
}); |
| 7200 |
} |
| 7201 |
}, { |
| 7202 |
key: "handleKeydown", |
| 7203 |
value: function handleKeydown(e) { |
| 7204 |
// this forces it to remember the last whole word, even if multiple termination keys are pressed |
| 7205 |
// before the previous key is let go. |
| 7206 |
if (this.previousKeydownCode && lists.contains(this.keys, this.previousKeydownCode)) { |
| 7207 |
this.previousKeydownCode = e.keyCode; |
| 7208 |
return; |
| 7209 |
} |
| 7210 |
|
| 7211 |
if (lists.contains(this.keys, e.keyCode)) { |
| 7212 |
var wordRange = this.context.invoke('editor.createRange').getWordRange(); |
| 7213 |
this.lastWord = wordRange; |
| 7214 |
} |
| 7215 |
|
| 7216 |
this.previousKeydownCode = e.keyCode; |
| 7217 |
} |
| 7218 |
}, { |
| 7219 |
key: "handleKeyup", |
| 7220 |
value: function handleKeyup(e) { |
| 7221 |
if (lists.contains(this.keys, e.keyCode)) { |
| 7222 |
this.replace(); |
| 7223 |
} |
| 7224 |
} |
| 7225 |
}]); |
| 7226 |
|
| 7227 |
return AutoReplace; |
| 7228 |
}(); |
| 7229 |
|
| 7230 |
|
| 7231 |
// CONCATENATED MODULE: ./src/js/base/module/Placeholder.js |
| 7232 |
function Placeholder_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 7233 |
|
| 7234 |
function Placeholder_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); } } |
| 7235 |
|
| 7236 |
function Placeholder_createClass(Constructor, protoProps, staticProps) { if (protoProps) Placeholder_defineProperties(Constructor.prototype, protoProps); if (staticProps) Placeholder_defineProperties(Constructor, staticProps); return Constructor; } |
| 7237 |
|
| 7238 |
|
| 7239 |
|
| 7240 |
var Placeholder_Placeholder = /*#__PURE__*/function () { |
| 7241 |
function Placeholder(context) { |
| 7242 |
var _this = this; |
| 7243 |
|
| 7244 |
Placeholder_classCallCheck(this, Placeholder); |
| 7245 |
|
| 7246 |
this.context = context; |
| 7247 |
this.$editingArea = context.layoutInfo.editingArea; |
| 7248 |
this.options = context.options; |
| 7249 |
|
| 7250 |
if (this.options.inheritPlaceholder === true) { |
| 7251 |
// get placeholder value from the original element |
| 7252 |
this.options.placeholder = this.context.$note.attr('placeholder') || this.options.placeholder; |
| 7253 |
} |
| 7254 |
|
| 7255 |
this.events = { |
| 7256 |
'summernote.init summernote.change': function summernoteInitSummernoteChange() { |
| 7257 |
_this.update(); |
| 7258 |
}, |
| 7259 |
'summernote.codeview.toggled': function summernoteCodeviewToggled() { |
| 7260 |
_this.update(); |
| 7261 |
} |
| 7262 |
}; |
| 7263 |
} |
| 7264 |
|
| 7265 |
Placeholder_createClass(Placeholder, [{ |
| 7266 |
key: "shouldInitialize", |
| 7267 |
value: function shouldInitialize() { |
| 7268 |
return !!this.options.placeholder; |
| 7269 |
} |
| 7270 |
}, { |
| 7271 |
key: "initialize", |
| 7272 |
value: function initialize() { |
| 7273 |
var _this2 = this; |
| 7274 |
|
| 7275 |
this.$placeholder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div class="note-placeholder">'); |
| 7276 |
this.$placeholder.on('click', function () { |
| 7277 |
_this2.context.invoke('focus'); |
| 7278 |
}).html(this.options.placeholder).prependTo(this.$editingArea); |
| 7279 |
this.update(); |
| 7280 |
} |
| 7281 |
}, { |
| 7282 |
key: "destroy", |
| 7283 |
value: function destroy() { |
| 7284 |
this.$placeholder.remove(); |
| 7285 |
} |
| 7286 |
}, { |
| 7287 |
key: "update", |
| 7288 |
value: function update() { |
| 7289 |
var isShow = !this.context.invoke('codeview.isActivated') && this.context.invoke('editor.isEmpty'); |
| 7290 |
this.$placeholder.toggle(isShow); |
| 7291 |
} |
| 7292 |
}]); |
| 7293 |
|
| 7294 |
return Placeholder; |
| 7295 |
}(); |
| 7296 |
|
| 7297 |
|
| 7298 |
// CONCATENATED MODULE: ./src/js/base/module/Buttons.js |
| 7299 |
function Buttons_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 7300 |
|
| 7301 |
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); } } |
| 7302 |
|
| 7303 |
function Buttons_createClass(Constructor, protoProps, staticProps) { if (protoProps) Buttons_defineProperties(Constructor.prototype, protoProps); if (staticProps) Buttons_defineProperties(Constructor, staticProps); return Constructor; } |
| 7304 |
|
| 7305 |
|
| 7306 |
|
| 7307 |
|
| 7308 |
|
| 7309 |
|
| 7310 |
var Buttons_Buttons = /*#__PURE__*/function () { |
| 7311 |
function Buttons(context) { |
| 7312 |
Buttons_classCallCheck(this, Buttons); |
| 7313 |
|
| 7314 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 7315 |
this.context = context; |
| 7316 |
this.$toolbar = context.layoutInfo.toolbar; |
| 7317 |
this.options = context.options; |
| 7318 |
this.lang = this.options.langInfo; |
| 7319 |
this.invertedKeyMap = func.invertObject(this.options.keyMap[env.isMac ? 'mac' : 'pc']); |
| 7320 |
} |
| 7321 |
|
| 7322 |
Buttons_createClass(Buttons, [{ |
| 7323 |
key: "representShortcut", |
| 7324 |
value: function representShortcut(editorMethod) { |
| 7325 |
var shortcut = this.invertedKeyMap[editorMethod]; |
| 7326 |
|
| 7327 |
if (!this.options.shortcuts || !shortcut) { |
| 7328 |
return ''; |
| 7329 |
} |
| 7330 |
|
| 7331 |
if (env.isMac) { |
| 7332 |
shortcut = shortcut.replace('CMD', '⌘').replace('SHIFT', '⇧'); |
| 7333 |
} |
| 7334 |
|
| 7335 |
shortcut = shortcut.replace('BACKSLASH', '\\').replace('SLASH', '/').replace('LEFTBRACKET', '[').replace('RIGHTBRACKET', ']'); |
| 7336 |
return ' (' + shortcut + ')'; |
| 7337 |
} |
| 7338 |
}, { |
| 7339 |
key: "button", |
| 7340 |
value: function button(o) { |
| 7341 |
if (!this.options.tooltip && o.tooltip) { |
| 7342 |
delete o.tooltip; |
| 7343 |
} |
| 7344 |
|
| 7345 |
o.container = this.options.container; |
| 7346 |
return this.ui.button(o); |
| 7347 |
} |
| 7348 |
}, { |
| 7349 |
key: "initialize", |
| 7350 |
value: function initialize() { |
| 7351 |
this.addToolbarButtons(); |
| 7352 |
this.addImagePopoverButtons(); |
| 7353 |
this.addLinkPopoverButtons(); |
| 7354 |
this.addTablePopoverButtons(); |
| 7355 |
this.fontInstalledMap = {}; |
| 7356 |
} |
| 7357 |
}, { |
| 7358 |
key: "destroy", |
| 7359 |
value: function destroy() { |
| 7360 |
delete this.fontInstalledMap; |
| 7361 |
} |
| 7362 |
}, { |
| 7363 |
key: "isFontInstalled", |
| 7364 |
value: function isFontInstalled(name) { |
| 7365 |
if (!Object.prototype.hasOwnProperty.call(this.fontInstalledMap, name)) { |
| 7366 |
this.fontInstalledMap[name] = env.isFontInstalled(name) || lists.contains(this.options.fontNamesIgnoreCheck, name); |
| 7367 |
} |
| 7368 |
|
| 7369 |
return this.fontInstalledMap[name]; |
| 7370 |
} |
| 7371 |
}, { |
| 7372 |
key: "isFontDeservedToAdd", |
| 7373 |
value: function isFontDeservedToAdd(name) { |
| 7374 |
name = name.toLowerCase(); |
| 7375 |
return name !== '' && this.isFontInstalled(name) && env.genericFontFamilies.indexOf(name) === -1; |
| 7376 |
} |
| 7377 |
}, { |
| 7378 |
key: "colorPalette", |
| 7379 |
value: function colorPalette(className, tooltip, backColor, foreColor) { |
| 7380 |
var _this = this; |
| 7381 |
|
| 7382 |
return this.ui.buttonGroup({ |
| 7383 |
className: 'note-color ' + className, |
| 7384 |
children: [this.button({ |
| 7385 |
className: 'note-current-color-button', |
| 7386 |
contents: this.ui.icon(this.options.icons.font + ' note-recent-color'), |
| 7387 |
tooltip: tooltip, |
| 7388 |
click: function click(e) { |
| 7389 |
var $button = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.currentTarget); |
| 7390 |
|
| 7391 |
if (backColor && foreColor) { |
| 7392 |
_this.context.invoke('editor.color', { |
| 7393 |
backColor: $button.attr('data-backColor'), |
| 7394 |
foreColor: $button.attr('data-foreColor') |
| 7395 |
}); |
| 7396 |
} else if (backColor) { |
| 7397 |
_this.context.invoke('editor.color', { |
| 7398 |
backColor: $button.attr('data-backColor') |
| 7399 |
}); |
| 7400 |
} else if (foreColor) { |
| 7401 |
_this.context.invoke('editor.color', { |
| 7402 |
foreColor: $button.attr('data-foreColor') |
| 7403 |
}); |
| 7404 |
} |
| 7405 |
}, |
| 7406 |
callback: function callback($button) { |
| 7407 |
var $recentColor = $button.find('.note-recent-color'); |
| 7408 |
|
| 7409 |
if (backColor) { |
| 7410 |
$recentColor.css('background-color', _this.options.colorButton.backColor); |
| 7411 |
$button.attr('data-backColor', _this.options.colorButton.backColor); |
| 7412 |
} |
| 7413 |
|
| 7414 |
if (foreColor) { |
| 7415 |
$recentColor.css('color', _this.options.colorButton.foreColor); |
| 7416 |
$button.attr('data-foreColor', _this.options.colorButton.foreColor); |
| 7417 |
} else { |
| 7418 |
$recentColor.css('color', 'transparent'); |
| 7419 |
} |
| 7420 |
} |
| 7421 |
}), this.button({ |
| 7422 |
className: 'dropdown-toggle', |
| 7423 |
contents: this.ui.dropdownButtonContents('', this.options), |
| 7424 |
tooltip: this.lang.color.more, |
| 7425 |
data: { |
| 7426 |
toggle: 'dropdown' |
| 7427 |
} |
| 7428 |
}), this.ui.dropdown({ |
| 7429 |
items: (backColor ? ['<div class="note-palette">', '<div class="note-palette-title">' + this.lang.color.background + '</div>', '<div>', '<button type="button" class="note-color-reset btn btn-light btn-default" data-event="backColor" data-value="transparent">', this.lang.color.transparent, '</button>', '</div>', '<div class="note-holder" data-event="backColor"><!-- back colors --></div>', '<div>', '<button type="button" class="note-color-select btn btn-light btn-default" data-event="openPalette" data-value="backColorPicker">', this.lang.color.cpSelect, '</button>', '<input type="color" id="backColorPicker" class="note-btn note-color-select-btn" value="' + this.options.colorButton.backColor + '" data-event="backColorPalette">', '</div>', '<div class="note-holder-custom" id="backColorPalette" data-event="backColor"></div>', '</div>'].join('') : '') + (foreColor ? ['<div class="note-palette">', '<div class="note-palette-title">' + this.lang.color.foreground + '</div>', '<div>', '<button type="button" class="note-color-reset btn btn-light btn-default" data-event="removeFormat" data-value="foreColor">', this.lang.color.resetToDefault, '</button>', '</div>', '<div class="note-holder" data-event="foreColor"><!-- fore colors --></div>', '<div>', '<button type="button" class="note-color-select btn btn-light btn-default" data-event="openPalette" data-value="foreColorPicker">', this.lang.color.cpSelect, '</button>', '<input type="color" id="foreColorPicker" class="note-btn note-color-select-btn" value="' + this.options.colorButton.foreColor + '" data-event="foreColorPalette">', '</div>', // Fix missing Div, Commented to find easily if it's wrong |
| 7430 |
'<div class="note-holder-custom" id="foreColorPalette" data-event="foreColor"></div>', '</div>'].join('') : ''), |
| 7431 |
callback: function callback($dropdown) { |
| 7432 |
$dropdown.find('.note-holder').each(function (idx, item) { |
| 7433 |
var $holder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); |
| 7434 |
$holder.append(_this.ui.palette({ |
| 7435 |
colors: _this.options.colors, |
| 7436 |
colorsName: _this.options.colorsName, |
| 7437 |
eventName: $holder.data('event'), |
| 7438 |
container: _this.options.container, |
| 7439 |
tooltip: _this.options.tooltip |
| 7440 |
}).render()); |
| 7441 |
}); |
| 7442 |
/* TODO: do we have to record recent custom colors within cookies? */ |
| 7443 |
|
| 7444 |
var customColors = [['#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF']]; |
| 7445 |
$dropdown.find('.note-holder-custom').each(function (idx, item) { |
| 7446 |
var $holder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); |
| 7447 |
$holder.append(_this.ui.palette({ |
| 7448 |
colors: customColors, |
| 7449 |
colorsName: customColors, |
| 7450 |
eventName: $holder.data('event'), |
| 7451 |
container: _this.options.container, |
| 7452 |
tooltip: _this.options.tooltip |
| 7453 |
}).render()); |
| 7454 |
}); |
| 7455 |
$dropdown.find('input[type=color]').each(function (idx, item) { |
| 7456 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item).change(function () { |
| 7457 |
var $chip = $dropdown.find('#' + external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this).data('event')).find('.note-color-btn').first(); |
| 7458 |
var color = this.value.toUpperCase(); |
| 7459 |
$chip.css('background-color', color).attr('aria-label', color).attr('data-value', color).attr('data-original-title', color); |
| 7460 |
$chip.click(); |
| 7461 |
}); |
| 7462 |
}); |
| 7463 |
}, |
| 7464 |
click: function click(event) { |
| 7465 |
event.stopPropagation(); |
| 7466 |
var $parent = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('.' + className).find('.note-dropdown-menu'); |
| 7467 |
var $button = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target); |
| 7468 |
var eventName = $button.data('event'); |
| 7469 |
var value = $button.attr('data-value'); |
| 7470 |
|
| 7471 |
if (eventName === 'openPalette') { |
| 7472 |
var $picker = $parent.find('#' + value); |
| 7473 |
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 |
| 7474 |
|
| 7475 |
var $chip = $palette.find('.note-color-btn').last().detach(); // Set chip attributes |
| 7476 |
|
| 7477 |
var color = $picker.val(); |
| 7478 |
$chip.css('background-color', color).attr('aria-label', color).attr('data-value', color).attr('data-original-title', color); |
| 7479 |
$palette.prepend($chip); |
| 7480 |
$picker.click(); |
| 7481 |
} else { |
| 7482 |
if (lists.contains(['backColor', 'foreColor'], eventName)) { |
| 7483 |
var key = eventName === 'backColor' ? 'background-color' : 'color'; |
| 7484 |
var $color = $button.closest('.note-color').find('.note-recent-color'); |
| 7485 |
var $currentButton = $button.closest('.note-color').find('.note-current-color-button'); |
| 7486 |
$color.css(key, value); |
| 7487 |
$currentButton.attr('data-' + eventName, value); |
| 7488 |
} |
| 7489 |
|
| 7490 |
_this.context.invoke('editor.' + eventName, value); |
| 7491 |
} |
| 7492 |
} |
| 7493 |
})] |
| 7494 |
}).render(); |
| 7495 |
} |
| 7496 |
}, { |
| 7497 |
key: "addToolbarButtons", |
| 7498 |
value: function addToolbarButtons() { |
| 7499 |
var _this2 = this; |
| 7500 |
|
| 7501 |
this.context.memo('button.style', function () { |
| 7502 |
return _this2.ui.buttonGroup([_this2.button({ |
| 7503 |
className: 'dropdown-toggle', |
| 7504 |
contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.magic), _this2.options), |
| 7505 |
tooltip: _this2.lang.style.style, |
| 7506 |
data: { |
| 7507 |
toggle: 'dropdown' |
| 7508 |
} |
| 7509 |
}), _this2.ui.dropdown({ |
| 7510 |
className: 'dropdown-style', |
| 7511 |
items: _this2.options.styleTags, |
| 7512 |
title: _this2.lang.style.style, |
| 7513 |
template: function template(item) { |
| 7514 |
// TBD: need to be simplified |
| 7515 |
if (typeof item === 'string') { |
| 7516 |
item = { |
| 7517 |
tag: item, |
| 7518 |
title: Object.prototype.hasOwnProperty.call(_this2.lang.style, item) ? _this2.lang.style[item] : item |
| 7519 |
}; |
| 7520 |
} |
| 7521 |
|
| 7522 |
var tag = item.tag; |
| 7523 |
var title = item.title; |
| 7524 |
var style = item.style ? ' style="' + item.style + '" ' : ''; |
| 7525 |
var className = item.className ? ' class="' + item.className + '"' : ''; |
| 7526 |
return '<' + tag + style + className + '>' + title + '</' + tag + '>'; |
| 7527 |
}, |
| 7528 |
click: _this2.context.createInvokeHandler('editor.formatBlock') |
| 7529 |
})]).render(); |
| 7530 |
}); |
| 7531 |
|
| 7532 |
var _loop = function _loop(styleIdx, styleLen) { |
| 7533 |
var item = _this2.options.styleTags[styleIdx]; |
| 7534 |
|
| 7535 |
_this2.context.memo('button.style.' + item, function () { |
| 7536 |
return _this2.button({ |
| 7537 |
className: 'note-btn-style-' + item, |
| 7538 |
contents: '<div data-value="' + item + '">' + item.toUpperCase() + '</div>', |
| 7539 |
tooltip: _this2.lang.style[item], |
| 7540 |
click: _this2.context.createInvokeHandler('editor.formatBlock') |
| 7541 |
}).render(); |
| 7542 |
}); |
| 7543 |
}; |
| 7544 |
|
| 7545 |
for (var styleIdx = 0, styleLen = this.options.styleTags.length; styleIdx < styleLen; styleIdx++) { |
| 7546 |
_loop(styleIdx, styleLen); |
| 7547 |
} |
| 7548 |
|
| 7549 |
this.context.memo('button.bold', function () { |
| 7550 |
return _this2.button({ |
| 7551 |
className: 'note-btn-bold', |
| 7552 |
contents: _this2.ui.icon(_this2.options.icons.bold), |
| 7553 |
tooltip: _this2.lang.font.bold + _this2.representShortcut('bold'), |
| 7554 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.bold') |
| 7555 |
}).render(); |
| 7556 |
}); |
| 7557 |
this.context.memo('button.italic', function () { |
| 7558 |
return _this2.button({ |
| 7559 |
className: 'note-btn-italic', |
| 7560 |
contents: _this2.ui.icon(_this2.options.icons.italic), |
| 7561 |
tooltip: _this2.lang.font.italic + _this2.representShortcut('italic'), |
| 7562 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.italic') |
| 7563 |
}).render(); |
| 7564 |
}); |
| 7565 |
this.context.memo('button.underline', function () { |
| 7566 |
return _this2.button({ |
| 7567 |
className: 'note-btn-underline', |
| 7568 |
contents: _this2.ui.icon(_this2.options.icons.underline), |
| 7569 |
tooltip: _this2.lang.font.underline + _this2.representShortcut('underline'), |
| 7570 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.underline') |
| 7571 |
}).render(); |
| 7572 |
}); |
| 7573 |
this.context.memo('button.clear', function () { |
| 7574 |
return _this2.button({ |
| 7575 |
contents: _this2.ui.icon(_this2.options.icons.eraser), |
| 7576 |
tooltip: _this2.lang.font.clear + _this2.representShortcut('removeFormat'), |
| 7577 |
click: _this2.context.createInvokeHandler('editor.removeFormat') |
| 7578 |
}).render(); |
| 7579 |
}); |
| 7580 |
this.context.memo('button.strikethrough', function () { |
| 7581 |
return _this2.button({ |
| 7582 |
className: 'note-btn-strikethrough', |
| 7583 |
contents: _this2.ui.icon(_this2.options.icons.strikethrough), |
| 7584 |
tooltip: _this2.lang.font.strikethrough + _this2.representShortcut('strikethrough'), |
| 7585 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.strikethrough') |
| 7586 |
}).render(); |
| 7587 |
}); |
| 7588 |
this.context.memo('button.superscript', function () { |
| 7589 |
return _this2.button({ |
| 7590 |
className: 'note-btn-superscript', |
| 7591 |
contents: _this2.ui.icon(_this2.options.icons.superscript), |
| 7592 |
tooltip: _this2.lang.font.superscript, |
| 7593 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.superscript') |
| 7594 |
}).render(); |
| 7595 |
}); |
| 7596 |
this.context.memo('button.subscript', function () { |
| 7597 |
return _this2.button({ |
| 7598 |
className: 'note-btn-subscript', |
| 7599 |
contents: _this2.ui.icon(_this2.options.icons.subscript), |
| 7600 |
tooltip: _this2.lang.font.subscript, |
| 7601 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.subscript') |
| 7602 |
}).render(); |
| 7603 |
}); |
| 7604 |
this.context.memo('button.fontname', function () { |
| 7605 |
var styleInfo = _this2.context.invoke('editor.currentStyle'); |
| 7606 |
|
| 7607 |
if (_this2.options.addDefaultFonts) { |
| 7608 |
// Add 'default' fonts into the fontnames array if not exist |
| 7609 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(styleInfo['font-family'].split(','), function (idx, fontname) { |
| 7610 |
fontname = fontname.trim().replace(/['"]+/g, ''); |
| 7611 |
|
| 7612 |
if (_this2.isFontDeservedToAdd(fontname)) { |
| 7613 |
if (_this2.options.fontNames.indexOf(fontname) === -1) { |
| 7614 |
_this2.options.fontNames.push(fontname); |
| 7615 |
} |
| 7616 |
} |
| 7617 |
}); |
| 7618 |
} |
| 7619 |
|
| 7620 |
return _this2.ui.buttonGroup([_this2.button({ |
| 7621 |
className: 'dropdown-toggle', |
| 7622 |
contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontname"></span>', _this2.options), |
| 7623 |
tooltip: _this2.lang.font.name, |
| 7624 |
data: { |
| 7625 |
toggle: 'dropdown' |
| 7626 |
} |
| 7627 |
}), _this2.ui.dropdownCheck({ |
| 7628 |
className: 'dropdown-fontname', |
| 7629 |
checkClassName: _this2.options.icons.menuCheck, |
| 7630 |
items: _this2.options.fontNames.filter(_this2.isFontInstalled.bind(_this2)), |
| 7631 |
title: _this2.lang.font.name, |
| 7632 |
template: function template(item) { |
| 7633 |
return '<span style="font-family: ' + env.validFontName(item) + '">' + item + '</span>'; |
| 7634 |
}, |
| 7635 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontName') |
| 7636 |
})]).render(); |
| 7637 |
}); |
| 7638 |
this.context.memo('button.fontsize', function () { |
| 7639 |
return _this2.ui.buttonGroup([_this2.button({ |
| 7640 |
className: 'dropdown-toggle', |
| 7641 |
contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontsize"></span>', _this2.options), |
| 7642 |
tooltip: _this2.lang.font.size, |
| 7643 |
data: { |
| 7644 |
toggle: 'dropdown' |
| 7645 |
} |
| 7646 |
}), _this2.ui.dropdownCheck({ |
| 7647 |
className: 'dropdown-fontsize', |
| 7648 |
checkClassName: _this2.options.icons.menuCheck, |
| 7649 |
items: _this2.options.fontSizes, |
| 7650 |
title: _this2.lang.font.size, |
| 7651 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontSize') |
| 7652 |
})]).render(); |
| 7653 |
}); |
| 7654 |
this.context.memo('button.fontsizeunit', function () { |
| 7655 |
return _this2.ui.buttonGroup([_this2.button({ |
| 7656 |
className: 'dropdown-toggle', |
| 7657 |
contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontsizeunit"></span>', _this2.options), |
| 7658 |
tooltip: _this2.lang.font.sizeunit, |
| 7659 |
data: { |
| 7660 |
toggle: 'dropdown' |
| 7661 |
} |
| 7662 |
}), _this2.ui.dropdownCheck({ |
| 7663 |
className: 'dropdown-fontsizeunit', |
| 7664 |
checkClassName: _this2.options.icons.menuCheck, |
| 7665 |
items: _this2.options.fontSizeUnits, |
| 7666 |
title: _this2.lang.font.sizeunit, |
| 7667 |
click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontSizeUnit') |
| 7668 |
})]).render(); |
| 7669 |
}); |
| 7670 |
this.context.memo('button.color', function () { |
| 7671 |
return _this2.colorPalette('note-color-all', _this2.lang.color.recent, true, true); |
| 7672 |
}); |
| 7673 |
this.context.memo('button.forecolor', function () { |
| 7674 |
return _this2.colorPalette('note-color-fore', _this2.lang.color.foreground, false, true); |
| 7675 |
}); |
| 7676 |
this.context.memo('button.backcolor', function () { |
| 7677 |
return _this2.colorPalette('note-color-back', _this2.lang.color.background, true, false); |
| 7678 |
}); |
| 7679 |
this.context.memo('button.ul', function () { |
| 7680 |
return _this2.button({ |
| 7681 |
contents: _this2.ui.icon(_this2.options.icons.unorderedlist), |
| 7682 |
tooltip: _this2.lang.lists.unordered + _this2.representShortcut('insertUnorderedList'), |
| 7683 |
click: _this2.context.createInvokeHandler('editor.insertUnorderedList') |
| 7684 |
}).render(); |
| 7685 |
}); |
| 7686 |
this.context.memo('button.ol', function () { |
| 7687 |
return _this2.button({ |
| 7688 |
contents: _this2.ui.icon(_this2.options.icons.orderedlist), |
| 7689 |
tooltip: _this2.lang.lists.ordered + _this2.representShortcut('insertOrderedList'), |
| 7690 |
click: _this2.context.createInvokeHandler('editor.insertOrderedList') |
| 7691 |
}).render(); |
| 7692 |
}); |
| 7693 |
var justifyLeft = this.button({ |
| 7694 |
contents: this.ui.icon(this.options.icons.alignLeft), |
| 7695 |
tooltip: this.lang.paragraph.left + this.representShortcut('justifyLeft'), |
| 7696 |
click: this.context.createInvokeHandler('editor.justifyLeft') |
| 7697 |
}); |
| 7698 |
var justifyCenter = this.button({ |
| 7699 |
contents: this.ui.icon(this.options.icons.alignCenter), |
| 7700 |
tooltip: this.lang.paragraph.center + this.representShortcut('justifyCenter'), |
| 7701 |
click: this.context.createInvokeHandler('editor.justifyCenter') |
| 7702 |
}); |
| 7703 |
var justifyRight = this.button({ |
| 7704 |
contents: this.ui.icon(this.options.icons.alignRight), |
| 7705 |
tooltip: this.lang.paragraph.right + this.representShortcut('justifyRight'), |
| 7706 |
click: this.context.createInvokeHandler('editor.justifyRight') |
| 7707 |
}); |
| 7708 |
var justifyFull = this.button({ |
| 7709 |
contents: this.ui.icon(this.options.icons.alignJustify), |
| 7710 |
tooltip: this.lang.paragraph.justify + this.representShortcut('justifyFull'), |
| 7711 |
click: this.context.createInvokeHandler('editor.justifyFull') |
| 7712 |
}); |
| 7713 |
var outdent = this.button({ |
| 7714 |
contents: this.ui.icon(this.options.icons.outdent), |
| 7715 |
tooltip: this.lang.paragraph.outdent + this.representShortcut('outdent'), |
| 7716 |
click: this.context.createInvokeHandler('editor.outdent') |
| 7717 |
}); |
| 7718 |
var indent = this.button({ |
| 7719 |
contents: this.ui.icon(this.options.icons.indent), |
| 7720 |
tooltip: this.lang.paragraph.indent + this.representShortcut('indent'), |
| 7721 |
click: this.context.createInvokeHandler('editor.indent') |
| 7722 |
}); |
| 7723 |
this.context.memo('button.justifyLeft', func.invoke(justifyLeft, 'render')); |
| 7724 |
this.context.memo('button.justifyCenter', func.invoke(justifyCenter, 'render')); |
| 7725 |
this.context.memo('button.justifyRight', func.invoke(justifyRight, 'render')); |
| 7726 |
this.context.memo('button.justifyFull', func.invoke(justifyFull, 'render')); |
| 7727 |
this.context.memo('button.outdent', func.invoke(outdent, 'render')); |
| 7728 |
this.context.memo('button.indent', func.invoke(indent, 'render')); |
| 7729 |
this.context.memo('button.paragraph', function () { |
| 7730 |
return _this2.ui.buttonGroup([_this2.button({ |
| 7731 |
className: 'dropdown-toggle', |
| 7732 |
contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.alignLeft), _this2.options), |
| 7733 |
tooltip: _this2.lang.paragraph.paragraph, |
| 7734 |
data: { |
| 7735 |
toggle: 'dropdown' |
| 7736 |
} |
| 7737 |
}), _this2.ui.dropdown([_this2.ui.buttonGroup({ |
| 7738 |
className: 'note-align', |
| 7739 |
children: [justifyLeft, justifyCenter, justifyRight, justifyFull] |
| 7740 |
}), _this2.ui.buttonGroup({ |
| 7741 |
className: 'note-list', |
| 7742 |
children: [outdent, indent] |
| 7743 |
})])]).render(); |
| 7744 |
}); |
| 7745 |
this.context.memo('button.height', function () { |
| 7746 |
return _this2.ui.buttonGroup([_this2.button({ |
| 7747 |
className: 'dropdown-toggle', |
| 7748 |
contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.textHeight), _this2.options), |
| 7749 |
tooltip: _this2.lang.font.height, |
| 7750 |
data: { |
| 7751 |
toggle: 'dropdown' |
| 7752 |
} |
| 7753 |
}), _this2.ui.dropdownCheck({ |
| 7754 |
items: _this2.options.lineHeights, |
| 7755 |
checkClassName: _this2.options.icons.menuCheck, |
| 7756 |
className: 'dropdown-line-height', |
| 7757 |
title: _this2.lang.font.height, |
| 7758 |
click: _this2.context.createInvokeHandler('editor.lineHeight') |
| 7759 |
})]).render(); |
| 7760 |
}); |
| 7761 |
this.context.memo('button.table', function () { |
| 7762 |
return _this2.ui.buttonGroup([_this2.button({ |
| 7763 |
className: 'dropdown-toggle', |
| 7764 |
contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.table), _this2.options), |
| 7765 |
tooltip: _this2.lang.table.table, |
| 7766 |
data: { |
| 7767 |
toggle: 'dropdown' |
| 7768 |
} |
| 7769 |
}), _this2.ui.dropdown({ |
| 7770 |
title: _this2.lang.table.table, |
| 7771 |
className: 'note-table', |
| 7772 |
items: ['<div class="note-dimension-picker">', '<div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"></div>', '<div class="note-dimension-picker-highlighted"></div>', '<div class="note-dimension-picker-unhighlighted"></div>', '</div>', '<div class="note-dimension-display">1 x 1</div>'].join('') |
| 7773 |
})], { |
| 7774 |
callback: function callback($node) { |
| 7775 |
var $catcher = $node.find('.note-dimension-picker-mousecatcher'); |
| 7776 |
$catcher.css({ |
| 7777 |
width: _this2.options.insertTableMaxSize.col + 'em', |
| 7778 |
height: _this2.options.insertTableMaxSize.row + 'em' |
| 7779 |
}).mousedown(_this2.context.createInvokeHandler('editor.insertTable')).on('mousemove', _this2.tableMoveHandler.bind(_this2)); |
| 7780 |
} |
| 7781 |
}).render(); |
| 7782 |
}); |
| 7783 |
this.context.memo('button.link', function () { |
| 7784 |
return _this2.button({ |
| 7785 |
contents: _this2.ui.icon(_this2.options.icons.link), |
| 7786 |
tooltip: _this2.lang.link.link + _this2.representShortcut('linkDialog.show'), |
| 7787 |
click: _this2.context.createInvokeHandler('linkDialog.show') |
| 7788 |
}).render(); |
| 7789 |
}); |
| 7790 |
this.context.memo('button.picture', function () { |
| 7791 |
return _this2.button({ |
| 7792 |
contents: _this2.ui.icon(_this2.options.icons.picture), |
| 7793 |
tooltip: _this2.lang.image.image, |
| 7794 |
click: _this2.context.createInvokeHandler('imageDialog.show') |
| 7795 |
}).render(); |
| 7796 |
}); |
| 7797 |
this.context.memo('button.video', function () { |
| 7798 |
return _this2.button({ |
| 7799 |
contents: _this2.ui.icon(_this2.options.icons.video), |
| 7800 |
tooltip: _this2.lang.video.video, |
| 7801 |
click: _this2.context.createInvokeHandler('videoDialog.show') |
| 7802 |
}).render(); |
| 7803 |
}); |
| 7804 |
this.context.memo('button.hr', function () { |
| 7805 |
return _this2.button({ |
| 7806 |
contents: _this2.ui.icon(_this2.options.icons.minus), |
| 7807 |
tooltip: _this2.lang.hr.insert + _this2.representShortcut('insertHorizontalRule'), |
| 7808 |
click: _this2.context.createInvokeHandler('editor.insertHorizontalRule') |
| 7809 |
}).render(); |
| 7810 |
}); |
| 7811 |
this.context.memo('button.fullscreen', function () { |
| 7812 |
return _this2.button({ |
| 7813 |
className: 'btn-fullscreen note-codeview-keep', |
| 7814 |
contents: _this2.ui.icon(_this2.options.icons.arrowsAlt), |
| 7815 |
tooltip: _this2.lang.options.fullscreen, |
| 7816 |
click: _this2.context.createInvokeHandler('fullscreen.toggle') |
| 7817 |
}).render(); |
| 7818 |
}); |
| 7819 |
this.context.memo('button.codeview', function () { |
| 7820 |
return _this2.button({ |
| 7821 |
className: 'btn-codeview note-codeview-keep', |
| 7822 |
contents: _this2.ui.icon(_this2.options.icons.code), |
| 7823 |
tooltip: _this2.lang.options.codeview, |
| 7824 |
click: _this2.context.createInvokeHandler('codeview.toggle') |
| 7825 |
}).render(); |
| 7826 |
}); |
| 7827 |
this.context.memo('button.redo', function () { |
| 7828 |
return _this2.button({ |
| 7829 |
contents: _this2.ui.icon(_this2.options.icons.redo), |
| 7830 |
tooltip: _this2.lang.history.redo + _this2.representShortcut('redo'), |
| 7831 |
click: _this2.context.createInvokeHandler('editor.redo') |
| 7832 |
}).render(); |
| 7833 |
}); |
| 7834 |
this.context.memo('button.undo', function () { |
| 7835 |
return _this2.button({ |
| 7836 |
contents: _this2.ui.icon(_this2.options.icons.undo), |
| 7837 |
tooltip: _this2.lang.history.undo + _this2.representShortcut('undo'), |
| 7838 |
click: _this2.context.createInvokeHandler('editor.undo') |
| 7839 |
}).render(); |
| 7840 |
}); |
| 7841 |
this.context.memo('button.help', function () { |
| 7842 |
return _this2.button({ |
| 7843 |
contents: _this2.ui.icon(_this2.options.icons.question), |
| 7844 |
tooltip: _this2.lang.options.help, |
| 7845 |
click: _this2.context.createInvokeHandler('helpDialog.show') |
| 7846 |
}).render(); |
| 7847 |
}); |
| 7848 |
} |
| 7849 |
/** |
| 7850 |
* image: [ |
| 7851 |
* ['imageResize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']], |
| 7852 |
* ['float', ['floatLeft', 'floatRight', 'floatNone']], |
| 7853 |
* ['remove', ['removeMedia']], |
| 7854 |
* ], |
| 7855 |
*/ |
| 7856 |
|
| 7857 |
}, { |
| 7858 |
key: "addImagePopoverButtons", |
| 7859 |
value: function addImagePopoverButtons() { |
| 7860 |
var _this3 = this; |
| 7861 |
|
| 7862 |
// Image Size Buttons |
| 7863 |
this.context.memo('button.resizeFull', function () { |
| 7864 |
return _this3.button({ |
| 7865 |
contents: '<span class="note-fontsize-10">100%</span>', |
| 7866 |
tooltip: _this3.lang.image.resizeFull, |
| 7867 |
click: _this3.context.createInvokeHandler('editor.resize', '1') |
| 7868 |
}).render(); |
| 7869 |
}); |
| 7870 |
this.context.memo('button.resizeHalf', function () { |
| 7871 |
return _this3.button({ |
| 7872 |
contents: '<span class="note-fontsize-10">50%</span>', |
| 7873 |
tooltip: _this3.lang.image.resizeHalf, |
| 7874 |
click: _this3.context.createInvokeHandler('editor.resize', '0.5') |
| 7875 |
}).render(); |
| 7876 |
}); |
| 7877 |
this.context.memo('button.resizeQuarter', function () { |
| 7878 |
return _this3.button({ |
| 7879 |
contents: '<span class="note-fontsize-10">25%</span>', |
| 7880 |
tooltip: _this3.lang.image.resizeQuarter, |
| 7881 |
click: _this3.context.createInvokeHandler('editor.resize', '0.25') |
| 7882 |
}).render(); |
| 7883 |
}); |
| 7884 |
this.context.memo('button.resizeNone', function () { |
| 7885 |
return _this3.button({ |
| 7886 |
contents: _this3.ui.icon(_this3.options.icons.rollback), |
| 7887 |
tooltip: _this3.lang.image.resizeNone, |
| 7888 |
click: _this3.context.createInvokeHandler('editor.resize', '0') |
| 7889 |
}).render(); |
| 7890 |
}); // Float Buttons |
| 7891 |
|
| 7892 |
this.context.memo('button.floatLeft', function () { |
| 7893 |
return _this3.button({ |
| 7894 |
contents: _this3.ui.icon(_this3.options.icons.floatLeft), |
| 7895 |
tooltip: _this3.lang.image.floatLeft, |
| 7896 |
click: _this3.context.createInvokeHandler('editor.floatMe', 'left') |
| 7897 |
}).render(); |
| 7898 |
}); |
| 7899 |
this.context.memo('button.floatRight', function () { |
| 7900 |
return _this3.button({ |
| 7901 |
contents: _this3.ui.icon(_this3.options.icons.floatRight), |
| 7902 |
tooltip: _this3.lang.image.floatRight, |
| 7903 |
click: _this3.context.createInvokeHandler('editor.floatMe', 'right') |
| 7904 |
}).render(); |
| 7905 |
}); |
| 7906 |
this.context.memo('button.floatNone', function () { |
| 7907 |
return _this3.button({ |
| 7908 |
contents: _this3.ui.icon(_this3.options.icons.rollback), |
| 7909 |
tooltip: _this3.lang.image.floatNone, |
| 7910 |
click: _this3.context.createInvokeHandler('editor.floatMe', 'none') |
| 7911 |
}).render(); |
| 7912 |
}); // Remove Buttons |
| 7913 |
|
| 7914 |
this.context.memo('button.removeMedia', function () { |
| 7915 |
return _this3.button({ |
| 7916 |
contents: _this3.ui.icon(_this3.options.icons.trash), |
| 7917 |
tooltip: _this3.lang.image.remove, |
| 7918 |
click: _this3.context.createInvokeHandler('editor.removeMedia') |
| 7919 |
}).render(); |
| 7920 |
}); |
| 7921 |
} |
| 7922 |
}, { |
| 7923 |
key: "addLinkPopoverButtons", |
| 7924 |
value: function addLinkPopoverButtons() { |
| 7925 |
var _this4 = this; |
| 7926 |
|
| 7927 |
this.context.memo('button.linkDialogShow', function () { |
| 7928 |
return _this4.button({ |
| 7929 |
contents: _this4.ui.icon(_this4.options.icons.link), |
| 7930 |
tooltip: _this4.lang.link.edit, |
| 7931 |
click: _this4.context.createInvokeHandler('linkDialog.show') |
| 7932 |
}).render(); |
| 7933 |
}); |
| 7934 |
this.context.memo('button.unlink', function () { |
| 7935 |
return _this4.button({ |
| 7936 |
contents: _this4.ui.icon(_this4.options.icons.unlink), |
| 7937 |
tooltip: _this4.lang.link.unlink, |
| 7938 |
click: _this4.context.createInvokeHandler('editor.unlink') |
| 7939 |
}).render(); |
| 7940 |
}); |
| 7941 |
} |
| 7942 |
/** |
| 7943 |
* table : [ |
| 7944 |
* ['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']], |
| 7945 |
* ['delete', ['deleteRow', 'deleteCol', 'deleteTable']] |
| 7946 |
* ], |
| 7947 |
*/ |
| 7948 |
|
| 7949 |
}, { |
| 7950 |
key: "addTablePopoverButtons", |
| 7951 |
value: function addTablePopoverButtons() { |
| 7952 |
var _this5 = this; |
| 7953 |
|
| 7954 |
this.context.memo('button.addRowUp', function () { |
| 7955 |
return _this5.button({ |
| 7956 |
className: 'btn-md', |
| 7957 |
contents: _this5.ui.icon(_this5.options.icons.rowAbove), |
| 7958 |
tooltip: _this5.lang.table.addRowAbove, |
| 7959 |
click: _this5.context.createInvokeHandler('editor.addRow', 'top') |
| 7960 |
}).render(); |
| 7961 |
}); |
| 7962 |
this.context.memo('button.addRowDown', function () { |
| 7963 |
return _this5.button({ |
| 7964 |
className: 'btn-md', |
| 7965 |
contents: _this5.ui.icon(_this5.options.icons.rowBelow), |
| 7966 |
tooltip: _this5.lang.table.addRowBelow, |
| 7967 |
click: _this5.context.createInvokeHandler('editor.addRow', 'bottom') |
| 7968 |
}).render(); |
| 7969 |
}); |
| 7970 |
this.context.memo('button.addColLeft', function () { |
| 7971 |
return _this5.button({ |
| 7972 |
className: 'btn-md', |
| 7973 |
contents: _this5.ui.icon(_this5.options.icons.colBefore), |
| 7974 |
tooltip: _this5.lang.table.addColLeft, |
| 7975 |
click: _this5.context.createInvokeHandler('editor.addCol', 'left') |
| 7976 |
}).render(); |
| 7977 |
}); |
| 7978 |
this.context.memo('button.addColRight', function () { |
| 7979 |
return _this5.button({ |
| 7980 |
className: 'btn-md', |
| 7981 |
contents: _this5.ui.icon(_this5.options.icons.colAfter), |
| 7982 |
tooltip: _this5.lang.table.addColRight, |
| 7983 |
click: _this5.context.createInvokeHandler('editor.addCol', 'right') |
| 7984 |
}).render(); |
| 7985 |
}); |
| 7986 |
this.context.memo('button.deleteRow', function () { |
| 7987 |
return _this5.button({ |
| 7988 |
className: 'btn-md', |
| 7989 |
contents: _this5.ui.icon(_this5.options.icons.rowRemove), |
| 7990 |
tooltip: _this5.lang.table.delRow, |
| 7991 |
click: _this5.context.createInvokeHandler('editor.deleteRow') |
| 7992 |
}).render(); |
| 7993 |
}); |
| 7994 |
this.context.memo('button.deleteCol', function () { |
| 7995 |
return _this5.button({ |
| 7996 |
className: 'btn-md', |
| 7997 |
contents: _this5.ui.icon(_this5.options.icons.colRemove), |
| 7998 |
tooltip: _this5.lang.table.delCol, |
| 7999 |
click: _this5.context.createInvokeHandler('editor.deleteCol') |
| 8000 |
}).render(); |
| 8001 |
}); |
| 8002 |
this.context.memo('button.deleteTable', function () { |
| 8003 |
return _this5.button({ |
| 8004 |
className: 'btn-md', |
| 8005 |
contents: _this5.ui.icon(_this5.options.icons.trash), |
| 8006 |
tooltip: _this5.lang.table.delTable, |
| 8007 |
click: _this5.context.createInvokeHandler('editor.deleteTable') |
| 8008 |
}).render(); |
| 8009 |
}); |
| 8010 |
} |
| 8011 |
}, { |
| 8012 |
key: "build", |
| 8013 |
value: function build($container, groups) { |
| 8014 |
for (var groupIdx = 0, groupLen = groups.length; groupIdx < groupLen; groupIdx++) { |
| 8015 |
var group = groups[groupIdx]; |
| 8016 |
var groupName = Array.isArray(group) ? group[0] : group; |
| 8017 |
var buttons = Array.isArray(group) ? group.length === 1 ? [group[0]] : group[1] : [group]; |
| 8018 |
var $group = this.ui.buttonGroup({ |
| 8019 |
className: 'note-' + groupName |
| 8020 |
}).render(); |
| 8021 |
|
| 8022 |
for (var idx = 0, len = buttons.length; idx < len; idx++) { |
| 8023 |
var btn = this.context.memo('button.' + buttons[idx]); |
| 8024 |
|
| 8025 |
if (btn) { |
| 8026 |
$group.append(typeof btn === 'function' ? btn(this.context) : btn); |
| 8027 |
} |
| 8028 |
} |
| 8029 |
|
| 8030 |
$group.appendTo($container); |
| 8031 |
} |
| 8032 |
} |
| 8033 |
/** |
| 8034 |
* @param {jQuery} [$container] |
| 8035 |
*/ |
| 8036 |
|
| 8037 |
}, { |
| 8038 |
key: "updateCurrentStyle", |
| 8039 |
value: function updateCurrentStyle($container) { |
| 8040 |
var _this6 = this; |
| 8041 |
|
| 8042 |
var $cont = $container || this.$toolbar; |
| 8043 |
var styleInfo = this.context.invoke('editor.currentStyle'); |
| 8044 |
this.updateBtnStates($cont, { |
| 8045 |
'.note-btn-bold': function noteBtnBold() { |
| 8046 |
return styleInfo['font-bold'] === 'bold'; |
| 8047 |
}, |
| 8048 |
'.note-btn-italic': function noteBtnItalic() { |
| 8049 |
return styleInfo['font-italic'] === 'italic'; |
| 8050 |
}, |
| 8051 |
'.note-btn-underline': function noteBtnUnderline() { |
| 8052 |
return styleInfo['font-underline'] === 'underline'; |
| 8053 |
}, |
| 8054 |
'.note-btn-subscript': function noteBtnSubscript() { |
| 8055 |
return styleInfo['font-subscript'] === 'subscript'; |
| 8056 |
}, |
| 8057 |
'.note-btn-superscript': function noteBtnSuperscript() { |
| 8058 |
return styleInfo['font-superscript'] === 'superscript'; |
| 8059 |
}, |
| 8060 |
'.note-btn-strikethrough': function noteBtnStrikethrough() { |
| 8061 |
return styleInfo['font-strikethrough'] === 'strikethrough'; |
| 8062 |
} |
| 8063 |
}); |
| 8064 |
|
| 8065 |
if (styleInfo['font-family']) { |
| 8066 |
var fontNames = styleInfo['font-family'].split(',').map(function (name) { |
| 8067 |
return name.replace(/[\'\"]/g, '').replace(/\s+$/, '').replace(/^\s+/, ''); |
| 8068 |
}); |
| 8069 |
var fontName = lists.find(fontNames, this.isFontInstalled.bind(this)); |
| 8070 |
$cont.find('.dropdown-fontname a').each(function (idx, item) { |
| 8071 |
var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); // always compare string to avoid creating another func. |
| 8072 |
|
| 8073 |
var isChecked = $item.data('value') + '' === fontName + ''; |
| 8074 |
$item.toggleClass('checked', isChecked); |
| 8075 |
}); |
| 8076 |
$cont.find('.note-current-fontname').text(fontName).css('font-family', fontName); |
| 8077 |
} |
| 8078 |
|
| 8079 |
if (styleInfo['font-size']) { |
| 8080 |
var fontSize = styleInfo['font-size']; |
| 8081 |
$cont.find('.dropdown-fontsize a').each(function (idx, item) { |
| 8082 |
var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); // always compare with string to avoid creating another func. |
| 8083 |
|
| 8084 |
var isChecked = $item.data('value') + '' === fontSize + ''; |
| 8085 |
$item.toggleClass('checked', isChecked); |
| 8086 |
}); |
| 8087 |
$cont.find('.note-current-fontsize').text(fontSize); |
| 8088 |
var fontSizeUnit = styleInfo['font-size-unit']; |
| 8089 |
$cont.find('.dropdown-fontsizeunit a').each(function (idx, item) { |
| 8090 |
var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); |
| 8091 |
var isChecked = $item.data('value') + '' === fontSizeUnit + ''; |
| 8092 |
$item.toggleClass('checked', isChecked); |
| 8093 |
}); |
| 8094 |
$cont.find('.note-current-fontsizeunit').text(fontSizeUnit); |
| 8095 |
} |
| 8096 |
|
| 8097 |
if (styleInfo['line-height']) { |
| 8098 |
var lineHeight = styleInfo['line-height']; |
| 8099 |
$cont.find('.dropdown-line-height li a').each(function (idx, item) { |
| 8100 |
// always compare with string to avoid creating another func. |
| 8101 |
var isChecked = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item).data('value') + '' === lineHeight + ''; |
| 8102 |
_this6.className = isChecked ? 'checked' : ''; |
| 8103 |
}); |
| 8104 |
} |
| 8105 |
} |
| 8106 |
}, { |
| 8107 |
key: "updateBtnStates", |
| 8108 |
value: function updateBtnStates($container, infos) { |
| 8109 |
var _this7 = this; |
| 8110 |
|
| 8111 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(infos, function (selector, pred) { |
| 8112 |
_this7.ui.toggleBtnActive($container.find(selector), pred()); |
| 8113 |
}); |
| 8114 |
} |
| 8115 |
}, { |
| 8116 |
key: "tableMoveHandler", |
| 8117 |
value: function tableMoveHandler(event) { |
| 8118 |
var PX_PER_EM = 18; |
| 8119 |
var $picker = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target.parentNode); // target is mousecatcher |
| 8120 |
|
| 8121 |
var $dimensionDisplay = $picker.next(); |
| 8122 |
var $catcher = $picker.find('.note-dimension-picker-mousecatcher'); |
| 8123 |
var $highlighted = $picker.find('.note-dimension-picker-highlighted'); |
| 8124 |
var $unhighlighted = $picker.find('.note-dimension-picker-unhighlighted'); |
| 8125 |
var posOffset; // HTML5 with jQuery - e.offsetX is undefined in Firefox |
| 8126 |
|
| 8127 |
if (event.offsetX === undefined) { |
| 8128 |
var posCatcher = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target).offset(); |
| 8129 |
posOffset = { |
| 8130 |
x: event.pageX - posCatcher.left, |
| 8131 |
y: event.pageY - posCatcher.top |
| 8132 |
}; |
| 8133 |
} else { |
| 8134 |
posOffset = { |
| 8135 |
x: event.offsetX, |
| 8136 |
y: event.offsetY |
| 8137 |
}; |
| 8138 |
} |
| 8139 |
|
| 8140 |
var dim = { |
| 8141 |
c: Math.ceil(posOffset.x / PX_PER_EM) || 1, |
| 8142 |
r: Math.ceil(posOffset.y / PX_PER_EM) || 1 |
| 8143 |
}; |
| 8144 |
$highlighted.css({ |
| 8145 |
width: dim.c + 'em', |
| 8146 |
height: dim.r + 'em' |
| 8147 |
}); |
| 8148 |
$catcher.data('value', dim.c + 'x' + dim.r); |
| 8149 |
|
| 8150 |
if (dim.c > 3 && dim.c < this.options.insertTableMaxSize.col) { |
| 8151 |
$unhighlighted.css({ |
| 8152 |
width: dim.c + 1 + 'em' |
| 8153 |
}); |
| 8154 |
} |
| 8155 |
|
| 8156 |
if (dim.r > 3 && dim.r < this.options.insertTableMaxSize.row) { |
| 8157 |
$unhighlighted.css({ |
| 8158 |
height: dim.r + 1 + 'em' |
| 8159 |
}); |
| 8160 |
} |
| 8161 |
|
| 8162 |
$dimensionDisplay.html(dim.c + ' x ' + dim.r); |
| 8163 |
} |
| 8164 |
}]); |
| 8165 |
|
| 8166 |
return Buttons; |
| 8167 |
}(); |
| 8168 |
|
| 8169 |
|
| 8170 |
// CONCATENATED MODULE: ./src/js/base/module/Toolbar.js |
| 8171 |
function Toolbar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8172 |
|
| 8173 |
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); } } |
| 8174 |
|
| 8175 |
function Toolbar_createClass(Constructor, protoProps, staticProps) { if (protoProps) Toolbar_defineProperties(Constructor.prototype, protoProps); if (staticProps) Toolbar_defineProperties(Constructor, staticProps); return Constructor; } |
| 8176 |
|
| 8177 |
|
| 8178 |
|
| 8179 |
var Toolbar_Toolbar = /*#__PURE__*/function () { |
| 8180 |
function Toolbar(context) { |
| 8181 |
Toolbar_classCallCheck(this, Toolbar); |
| 8182 |
|
| 8183 |
this.context = context; |
| 8184 |
this.$window = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(window); |
| 8185 |
this.$document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document); |
| 8186 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 8187 |
this.$note = context.layoutInfo.note; |
| 8188 |
this.$editor = context.layoutInfo.editor; |
| 8189 |
this.$toolbar = context.layoutInfo.toolbar; |
| 8190 |
this.$editable = context.layoutInfo.editable; |
| 8191 |
this.$statusbar = context.layoutInfo.statusbar; |
| 8192 |
this.options = context.options; |
| 8193 |
this.isFollowing = false; |
| 8194 |
this.followScroll = this.followScroll.bind(this); |
| 8195 |
} |
| 8196 |
|
| 8197 |
Toolbar_createClass(Toolbar, [{ |
| 8198 |
key: "shouldInitialize", |
| 8199 |
value: function shouldInitialize() { |
| 8200 |
return !this.options.airMode; |
| 8201 |
} |
| 8202 |
}, { |
| 8203 |
key: "initialize", |
| 8204 |
value: function initialize() { |
| 8205 |
var _this = this; |
| 8206 |
|
| 8207 |
this.options.toolbar = this.options.toolbar || []; |
| 8208 |
|
| 8209 |
if (!this.options.toolbar.length) { |
| 8210 |
this.$toolbar.hide(); |
| 8211 |
} else { |
| 8212 |
this.context.invoke('buttons.build', this.$toolbar, this.options.toolbar); |
| 8213 |
} |
| 8214 |
|
| 8215 |
if (this.options.toolbarContainer) { |
| 8216 |
this.$toolbar.appendTo(this.options.toolbarContainer); |
| 8217 |
} |
| 8218 |
|
| 8219 |
this.changeContainer(false); |
| 8220 |
this.$note.on('summernote.keyup summernote.mouseup summernote.change', function () { |
| 8221 |
_this.context.invoke('buttons.updateCurrentStyle'); |
| 8222 |
}); |
| 8223 |
this.context.invoke('buttons.updateCurrentStyle'); |
| 8224 |
|
| 8225 |
if (this.options.followingToolbar) { |
| 8226 |
this.$window.on('scroll resize', this.followScroll); |
| 8227 |
} |
| 8228 |
} |
| 8229 |
}, { |
| 8230 |
key: "destroy", |
| 8231 |
value: function destroy() { |
| 8232 |
this.$toolbar.children().remove(); |
| 8233 |
|
| 8234 |
if (this.options.followingToolbar) { |
| 8235 |
this.$window.off('scroll resize', this.followScroll); |
| 8236 |
} |
| 8237 |
} |
| 8238 |
}, { |
| 8239 |
key: "followScroll", |
| 8240 |
value: function followScroll() { |
| 8241 |
if (this.$editor.hasClass('fullscreen')) { |
| 8242 |
return false; |
| 8243 |
} |
| 8244 |
|
| 8245 |
var editorHeight = this.$editor.outerHeight(); |
| 8246 |
var editorWidth = this.$editor.width(); |
| 8247 |
var toolbarHeight = this.$toolbar.height(); |
| 8248 |
var statusbarHeight = this.$statusbar.height(); // check if the web app is currently using another static bar |
| 8249 |
|
| 8250 |
var otherBarHeight = 0; |
| 8251 |
|
| 8252 |
if (this.options.otherStaticBar) { |
| 8253 |
otherBarHeight = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.otherStaticBar).outerHeight(); |
| 8254 |
} |
| 8255 |
|
| 8256 |
var currentOffset = this.$document.scrollTop(); |
| 8257 |
var editorOffsetTop = this.$editor.offset().top; |
| 8258 |
var editorOffsetBottom = editorOffsetTop + editorHeight; |
| 8259 |
var activateOffset = editorOffsetTop - otherBarHeight; |
| 8260 |
var deactivateOffsetBottom = editorOffsetBottom - otherBarHeight - toolbarHeight - statusbarHeight; |
| 8261 |
|
| 8262 |
if (!this.isFollowing && currentOffset > activateOffset && currentOffset < deactivateOffsetBottom - toolbarHeight) { |
| 8263 |
this.isFollowing = true; |
| 8264 |
this.$editable.css({ |
| 8265 |
marginTop: this.$toolbar.outerHeight() |
| 8266 |
}); |
| 8267 |
this.$toolbar.css({ |
| 8268 |
position: 'fixed', |
| 8269 |
top: otherBarHeight, |
| 8270 |
width: editorWidth, |
| 8271 |
zIndex: 1000 |
| 8272 |
}); |
| 8273 |
} else if (this.isFollowing && (currentOffset < activateOffset || currentOffset > deactivateOffsetBottom)) { |
| 8274 |
this.isFollowing = false; |
| 8275 |
this.$toolbar.css({ |
| 8276 |
position: 'relative', |
| 8277 |
top: 0, |
| 8278 |
width: '100%', |
| 8279 |
zIndex: 'auto' |
| 8280 |
}); |
| 8281 |
this.$editable.css({ |
| 8282 |
marginTop: '' |
| 8283 |
}); |
| 8284 |
} |
| 8285 |
} |
| 8286 |
}, { |
| 8287 |
key: "changeContainer", |
| 8288 |
value: function changeContainer(isFullscreen) { |
| 8289 |
if (isFullscreen) { |
| 8290 |
this.$toolbar.prependTo(this.$editor); |
| 8291 |
} else { |
| 8292 |
if (this.options.toolbarContainer) { |
| 8293 |
this.$toolbar.appendTo(this.options.toolbarContainer); |
| 8294 |
} |
| 8295 |
} |
| 8296 |
|
| 8297 |
if (this.options.followingToolbar) { |
| 8298 |
this.followScroll(); |
| 8299 |
} |
| 8300 |
} |
| 8301 |
}, { |
| 8302 |
key: "updateFullscreen", |
| 8303 |
value: function updateFullscreen(isFullscreen) { |
| 8304 |
this.ui.toggleBtnActive(this.$toolbar.find('.btn-fullscreen'), isFullscreen); |
| 8305 |
this.changeContainer(isFullscreen); |
| 8306 |
} |
| 8307 |
}, { |
| 8308 |
key: "updateCodeview", |
| 8309 |
value: function updateCodeview(isCodeview) { |
| 8310 |
this.ui.toggleBtnActive(this.$toolbar.find('.btn-codeview'), isCodeview); |
| 8311 |
|
| 8312 |
if (isCodeview) { |
| 8313 |
this.deactivate(); |
| 8314 |
} else { |
| 8315 |
this.activate(); |
| 8316 |
} |
| 8317 |
} |
| 8318 |
}, { |
| 8319 |
key: "activate", |
| 8320 |
value: function activate(isIncludeCodeview) { |
| 8321 |
var $btn = this.$toolbar.find('button'); |
| 8322 |
|
| 8323 |
if (!isIncludeCodeview) { |
| 8324 |
$btn = $btn.not('.note-codeview-keep'); |
| 8325 |
} |
| 8326 |
|
| 8327 |
this.ui.toggleBtn($btn, true); |
| 8328 |
} |
| 8329 |
}, { |
| 8330 |
key: "deactivate", |
| 8331 |
value: function deactivate(isIncludeCodeview) { |
| 8332 |
var $btn = this.$toolbar.find('button'); |
| 8333 |
|
| 8334 |
if (!isIncludeCodeview) { |
| 8335 |
$btn = $btn.not('.note-codeview-keep'); |
| 8336 |
} |
| 8337 |
|
| 8338 |
this.ui.toggleBtn($btn, false); |
| 8339 |
} |
| 8340 |
}]); |
| 8341 |
|
| 8342 |
return Toolbar; |
| 8343 |
}(); |
| 8344 |
|
| 8345 |
|
| 8346 |
// CONCATENATED MODULE: ./src/js/base/module/LinkDialog.js |
| 8347 |
function LinkDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8348 |
|
| 8349 |
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); } } |
| 8350 |
|
| 8351 |
function LinkDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) LinkDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) LinkDialog_defineProperties(Constructor, staticProps); return Constructor; } |
| 8352 |
|
| 8353 |
|
| 8354 |
|
| 8355 |
|
| 8356 |
|
| 8357 |
|
| 8358 |
var LinkDialog_LinkDialog = /*#__PURE__*/function () { |
| 8359 |
function LinkDialog(context) { |
| 8360 |
LinkDialog_classCallCheck(this, LinkDialog); |
| 8361 |
|
| 8362 |
this.context = context; |
| 8363 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 8364 |
this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body); |
| 8365 |
this.$editor = context.layoutInfo.editor; |
| 8366 |
this.options = context.options; |
| 8367 |
this.lang = this.options.langInfo; |
| 8368 |
context.memo('help.linkDialog.show', this.options.langInfo.help['linkDialog.show']); |
| 8369 |
} |
| 8370 |
|
| 8371 |
LinkDialog_createClass(LinkDialog, [{ |
| 8372 |
key: "initialize", |
| 8373 |
value: function initialize() { |
| 8374 |
var $container = this.options.dialogsInBody ? this.$body : this.options.container; |
| 8375 |
var body = ['<div class="form-group note-form-group">', "<label for=\"note-dialog-link-txt-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.link.textToDisplay, "</label>"), "<input id=\"note-dialog-link-txt-".concat(this.options.id, "\" class=\"note-link-text form-control note-form-control note-input\" type=\"text\"/>"), '</div>', '<div class="form-group note-form-group">', "<label for=\"note-dialog-link-url-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.link.url, "</label>"), "<input id=\"note-dialog-link-url-".concat(this.options.id, "\" class=\"note-link-url form-control note-form-control note-input\" type=\"text\" value=\"http://\"/>"), '</div>', !this.options.disableLinkTarget ? external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div/>').append(this.ui.checkbox({ |
| 8376 |
className: 'sn-checkbox-open-in-new-window', |
| 8377 |
text: this.lang.link.openInNewWindow, |
| 8378 |
checked: true |
| 8379 |
}).render()).html() : '', external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div/>').append(this.ui.checkbox({ |
| 8380 |
className: 'sn-checkbox-use-protocol', |
| 8381 |
text: this.lang.link.useProtocol, |
| 8382 |
checked: true |
| 8383 |
}).render()).html()].join(''); |
| 8384 |
var buttonClass = 'btn btn-primary note-btn note-btn-primary note-link-btn'; |
| 8385 |
var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.link.insert, "\" disabled>"); |
| 8386 |
this.$dialog = this.ui.dialog({ |
| 8387 |
className: 'link-dialog', |
| 8388 |
title: this.lang.link.insert, |
| 8389 |
fade: this.options.dialogsFade, |
| 8390 |
body: body, |
| 8391 |
footer: footer |
| 8392 |
}).render().appendTo($container); |
| 8393 |
} |
| 8394 |
}, { |
| 8395 |
key: "destroy", |
| 8396 |
value: function destroy() { |
| 8397 |
this.ui.hideDialog(this.$dialog); |
| 8398 |
this.$dialog.remove(); |
| 8399 |
} |
| 8400 |
}, { |
| 8401 |
key: "bindEnterKey", |
| 8402 |
value: function bindEnterKey($input, $btn) { |
| 8403 |
$input.on('keypress', function (event) { |
| 8404 |
if (event.keyCode === core_key.code.ENTER) { |
| 8405 |
event.preventDefault(); |
| 8406 |
$btn.trigger('click'); |
| 8407 |
} |
| 8408 |
}); |
| 8409 |
} |
| 8410 |
/** |
| 8411 |
* toggle update button |
| 8412 |
*/ |
| 8413 |
|
| 8414 |
}, { |
| 8415 |
key: "toggleLinkBtn", |
| 8416 |
value: function toggleLinkBtn($linkBtn, $linkText, $linkUrl) { |
| 8417 |
this.ui.toggleBtn($linkBtn, $linkText.val() && $linkUrl.val()); |
| 8418 |
} |
| 8419 |
/** |
| 8420 |
* Show link dialog and set event handlers on dialog controls. |
| 8421 |
* |
| 8422 |
* @param {Object} linkInfo |
| 8423 |
* @return {Promise} |
| 8424 |
*/ |
| 8425 |
|
| 8426 |
}, { |
| 8427 |
key: "showLinkDialog", |
| 8428 |
value: function showLinkDialog(linkInfo) { |
| 8429 |
var _this = this; |
| 8430 |
|
| 8431 |
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) { |
| 8432 |
var $linkText = _this.$dialog.find('.note-link-text'); |
| 8433 |
|
| 8434 |
var $linkUrl = _this.$dialog.find('.note-link-url'); |
| 8435 |
|
| 8436 |
var $linkBtn = _this.$dialog.find('.note-link-btn'); |
| 8437 |
|
| 8438 |
var $openInNewWindow = _this.$dialog.find('.sn-checkbox-open-in-new-window input[type=checkbox]'); |
| 8439 |
|
| 8440 |
var $useProtocol = _this.$dialog.find('.sn-checkbox-use-protocol input[type=checkbox]'); |
| 8441 |
|
| 8442 |
_this.ui.onDialogShown(_this.$dialog, function () { |
| 8443 |
_this.context.triggerEvent('dialog.shown'); // If no url was given and given text is valid URL then copy that into URL Field |
| 8444 |
|
| 8445 |
|
| 8446 |
if (!linkInfo.url && func.isValidUrl(linkInfo.text)) { |
| 8447 |
linkInfo.url = linkInfo.text; |
| 8448 |
} |
| 8449 |
|
| 8450 |
$linkText.on('input paste propertychange', function () { |
| 8451 |
// If linktext was modified by input events, |
| 8452 |
// cloning text from linkUrl will be stopped. |
| 8453 |
linkInfo.text = $linkText.val(); |
| 8454 |
|
| 8455 |
_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl); |
| 8456 |
}).val(linkInfo.text); |
| 8457 |
$linkUrl.on('input paste propertychange', function () { |
| 8458 |
// Display same text on `Text to display` as default |
| 8459 |
// when linktext has no text |
| 8460 |
if (!linkInfo.text) { |
| 8461 |
$linkText.val($linkUrl.val()); |
| 8462 |
} |
| 8463 |
|
| 8464 |
_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl); |
| 8465 |
}).val(linkInfo.url); |
| 8466 |
|
| 8467 |
if (!env.isSupportTouch) { |
| 8468 |
$linkUrl.trigger('focus'); |
| 8469 |
} |
| 8470 |
|
| 8471 |
_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl); |
| 8472 |
|
| 8473 |
_this.bindEnterKey($linkUrl, $linkBtn); |
| 8474 |
|
| 8475 |
_this.bindEnterKey($linkText, $linkBtn); |
| 8476 |
|
| 8477 |
var isNewWindowChecked = linkInfo.isNewWindow !== undefined ? linkInfo.isNewWindow : _this.context.options.linkTargetBlank; |
| 8478 |
$openInNewWindow.prop('checked', isNewWindowChecked); |
| 8479 |
var useProtocolChecked = linkInfo.url ? false : _this.context.options.useProtocol; |
| 8480 |
$useProtocol.prop('checked', useProtocolChecked); |
| 8481 |
$linkBtn.one('click', function (event) { |
| 8482 |
event.preventDefault(); |
| 8483 |
deferred.resolve({ |
| 8484 |
range: linkInfo.range, |
| 8485 |
url: $linkUrl.val(), |
| 8486 |
text: $linkText.val(), |
| 8487 |
isNewWindow: $openInNewWindow.is(':checked'), |
| 8488 |
checkProtocol: $useProtocol.is(':checked') |
| 8489 |
}); |
| 8490 |
|
| 8491 |
_this.ui.hideDialog(_this.$dialog); |
| 8492 |
}); |
| 8493 |
}); |
| 8494 |
|
| 8495 |
_this.ui.onDialogHidden(_this.$dialog, function () { |
| 8496 |
// detach events |
| 8497 |
$linkText.off(); |
| 8498 |
$linkUrl.off(); |
| 8499 |
$linkBtn.off(); |
| 8500 |
|
| 8501 |
if (deferred.state() === 'pending') { |
| 8502 |
deferred.reject(); |
| 8503 |
} |
| 8504 |
}); |
| 8505 |
|
| 8506 |
_this.ui.showDialog(_this.$dialog); |
| 8507 |
}).promise(); |
| 8508 |
} |
| 8509 |
/** |
| 8510 |
* @param {Object} layoutInfo |
| 8511 |
*/ |
| 8512 |
|
| 8513 |
}, { |
| 8514 |
key: "show", |
| 8515 |
value: function show() { |
| 8516 |
var _this2 = this; |
| 8517 |
|
| 8518 |
var linkInfo = this.context.invoke('editor.getLinkInfo'); |
| 8519 |
this.context.invoke('editor.saveRange'); |
| 8520 |
this.showLinkDialog(linkInfo).then(function (linkInfo) { |
| 8521 |
_this2.context.invoke('editor.restoreRange'); |
| 8522 |
|
| 8523 |
_this2.context.invoke('editor.createLink', linkInfo); |
| 8524 |
}).fail(function () { |
| 8525 |
_this2.context.invoke('editor.restoreRange'); |
| 8526 |
}); |
| 8527 |
} |
| 8528 |
}]); |
| 8529 |
|
| 8530 |
return LinkDialog; |
| 8531 |
}(); |
| 8532 |
|
| 8533 |
|
| 8534 |
// CONCATENATED MODULE: ./src/js/base/module/LinkPopover.js |
| 8535 |
function LinkPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8536 |
|
| 8537 |
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); } } |
| 8538 |
|
| 8539 |
function LinkPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) LinkPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) LinkPopover_defineProperties(Constructor, staticProps); return Constructor; } |
| 8540 |
|
| 8541 |
|
| 8542 |
|
| 8543 |
|
| 8544 |
|
| 8545 |
var LinkPopover_LinkPopover = /*#__PURE__*/function () { |
| 8546 |
function LinkPopover(context) { |
| 8547 |
var _this = this; |
| 8548 |
|
| 8549 |
LinkPopover_classCallCheck(this, LinkPopover); |
| 8550 |
|
| 8551 |
this.context = context; |
| 8552 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 8553 |
this.options = context.options; |
| 8554 |
this.events = { |
| 8555 |
'summernote.keyup summernote.mouseup summernote.change summernote.scroll': function summernoteKeyupSummernoteMouseupSummernoteChangeSummernoteScroll() { |
| 8556 |
_this.update(); |
| 8557 |
}, |
| 8558 |
'summernote.disable summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteDialogShownSummernoteBlur() { |
| 8559 |
_this.hide(); |
| 8560 |
} |
| 8561 |
}; |
| 8562 |
} |
| 8563 |
|
| 8564 |
LinkPopover_createClass(LinkPopover, [{ |
| 8565 |
key: "shouldInitialize", |
| 8566 |
value: function shouldInitialize() { |
| 8567 |
return !lists.isEmpty(this.options.popover.link); |
| 8568 |
} |
| 8569 |
}, { |
| 8570 |
key: "initialize", |
| 8571 |
value: function initialize() { |
| 8572 |
this.$popover = this.ui.popover({ |
| 8573 |
className: 'note-link-popover', |
| 8574 |
callback: function callback($node) { |
| 8575 |
var $content = $node.find('.popover-content,.note-popover-content'); |
| 8576 |
$content.prepend('<span><a target="_blank"></a> </span>'); |
| 8577 |
} |
| 8578 |
}).render().appendTo(this.options.container); |
| 8579 |
var $content = this.$popover.find('.popover-content,.note-popover-content'); |
| 8580 |
this.context.invoke('buttons.build', $content, this.options.popover.link); |
| 8581 |
this.$popover.on('mousedown', function (e) { |
| 8582 |
e.preventDefault(); |
| 8583 |
}); |
| 8584 |
} |
| 8585 |
}, { |
| 8586 |
key: "destroy", |
| 8587 |
value: function destroy() { |
| 8588 |
this.$popover.remove(); |
| 8589 |
} |
| 8590 |
}, { |
| 8591 |
key: "update", |
| 8592 |
value: function update() { |
| 8593 |
// Prevent focusing on editable when invoke('code') is executed |
| 8594 |
if (!this.context.invoke('editor.hasFocus')) { |
| 8595 |
this.hide(); |
| 8596 |
return; |
| 8597 |
} |
| 8598 |
|
| 8599 |
var rng = this.context.invoke('editor.getLastRange'); |
| 8600 |
|
| 8601 |
if (rng.isCollapsed() && rng.isOnAnchor()) { |
| 8602 |
var anchor = dom.ancestor(rng.sc, dom.isAnchor); |
| 8603 |
var href = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).attr('href'); |
| 8604 |
this.$popover.find('a').attr('href', href).text(href); |
| 8605 |
var pos = dom.posFromPlaceholder(anchor); |
| 8606 |
var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset(); |
| 8607 |
pos.top -= containerOffset.top; |
| 8608 |
pos.left -= containerOffset.left; |
| 8609 |
this.$popover.css({ |
| 8610 |
display: 'block', |
| 8611 |
left: pos.left, |
| 8612 |
top: pos.top |
| 8613 |
}); |
| 8614 |
} else { |
| 8615 |
this.hide(); |
| 8616 |
} |
| 8617 |
} |
| 8618 |
}, { |
| 8619 |
key: "hide", |
| 8620 |
value: function hide() { |
| 8621 |
this.$popover.hide(); |
| 8622 |
} |
| 8623 |
}]); |
| 8624 |
|
| 8625 |
return LinkPopover; |
| 8626 |
}(); |
| 8627 |
|
| 8628 |
|
| 8629 |
// CONCATENATED MODULE: ./src/js/base/module/ImageDialog.js |
| 8630 |
function ImageDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8631 |
|
| 8632 |
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); } } |
| 8633 |
|
| 8634 |
function ImageDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) ImageDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) ImageDialog_defineProperties(Constructor, staticProps); return Constructor; } |
| 8635 |
|
| 8636 |
|
| 8637 |
|
| 8638 |
|
| 8639 |
|
| 8640 |
var ImageDialog_ImageDialog = /*#__PURE__*/function () { |
| 8641 |
function ImageDialog(context) { |
| 8642 |
ImageDialog_classCallCheck(this, ImageDialog); |
| 8643 |
|
| 8644 |
this.context = context; |
| 8645 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 8646 |
this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body); |
| 8647 |
this.$editor = context.layoutInfo.editor; |
| 8648 |
this.options = context.options; |
| 8649 |
this.lang = this.options.langInfo; |
| 8650 |
} |
| 8651 |
|
| 8652 |
ImageDialog_createClass(ImageDialog, [{ |
| 8653 |
key: "initialize", |
| 8654 |
value: function initialize() { |
| 8655 |
var imageLimitation = ''; |
| 8656 |
|
| 8657 |
if (this.options.maximumImageFileSize) { |
| 8658 |
var unit = Math.floor(Math.log(this.options.maximumImageFileSize) / Math.log(1024)); |
| 8659 |
var readableSize = (this.options.maximumImageFileSize / Math.pow(1024, unit)).toFixed(2) * 1 + ' ' + ' KMGTP'[unit] + 'B'; |
| 8660 |
imageLimitation = "<small>".concat(this.lang.image.maximumFileSize + ' : ' + readableSize, "</small>"); |
| 8661 |
} |
| 8662 |
|
| 8663 |
var $container = this.options.dialogsInBody ? this.$body : this.options.container; |
| 8664 |
var body = ['<div class="form-group note-form-group note-group-select-from-files">', '<label for="note-dialog-image-file-' + this.options.id + '" class="note-form-label">' + this.lang.image.selectFromFiles + '</label>', '<input id="note-dialog-image-file-' + this.options.id + '" class="note-image-input form-control-file note-form-control note-input" ', ' type="file" name="files" accept="image/*" multiple="multiple"/>', imageLimitation, '</div>', '<div class="form-group note-group-image-url">', '<label for="note-dialog-image-url-' + this.options.id + '" class="note-form-label">' + this.lang.image.url + '</label>', '<input id="note-dialog-image-url-' + this.options.id + '" class="note-image-url form-control note-form-control note-input" type="text"/>', '</div>'].join(''); |
| 8665 |
var buttonClass = 'btn btn-primary note-btn note-btn-primary note-image-btn'; |
| 8666 |
var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.image.insert, "\" disabled>"); |
| 8667 |
this.$dialog = this.ui.dialog({ |
| 8668 |
title: this.lang.image.insert, |
| 8669 |
fade: this.options.dialogsFade, |
| 8670 |
body: body, |
| 8671 |
footer: footer |
| 8672 |
}).render().appendTo($container); |
| 8673 |
} |
| 8674 |
}, { |
| 8675 |
key: "destroy", |
| 8676 |
value: function destroy() { |
| 8677 |
this.ui.hideDialog(this.$dialog); |
| 8678 |
this.$dialog.remove(); |
| 8679 |
} |
| 8680 |
}, { |
| 8681 |
key: "bindEnterKey", |
| 8682 |
value: function bindEnterKey($input, $btn) { |
| 8683 |
$input.on('keypress', function (event) { |
| 8684 |
if (event.keyCode === core_key.code.ENTER) { |
| 8685 |
event.preventDefault(); |
| 8686 |
$btn.trigger('click'); |
| 8687 |
} |
| 8688 |
}); |
| 8689 |
} |
| 8690 |
}, { |
| 8691 |
key: "show", |
| 8692 |
value: function show() { |
| 8693 |
var _this = this; |
| 8694 |
|
| 8695 |
this.context.invoke('editor.saveRange'); |
| 8696 |
this.showImageDialog().then(function (data) { |
| 8697 |
// [workaround] hide dialog before restore range for IE range focus |
| 8698 |
_this.ui.hideDialog(_this.$dialog); |
| 8699 |
|
| 8700 |
_this.context.invoke('editor.restoreRange'); |
| 8701 |
|
| 8702 |
if (typeof data === 'string') { |
| 8703 |
// image url |
| 8704 |
// If onImageLinkInsert set, |
| 8705 |
if (_this.options.callbacks.onImageLinkInsert) { |
| 8706 |
_this.context.triggerEvent('image.link.insert', data); |
| 8707 |
} else { |
| 8708 |
_this.context.invoke('editor.insertImage', data); |
| 8709 |
} |
| 8710 |
} else { |
| 8711 |
// array of files |
| 8712 |
_this.context.invoke('editor.insertImagesOrCallback', data); |
| 8713 |
} |
| 8714 |
}).fail(function () { |
| 8715 |
_this.context.invoke('editor.restoreRange'); |
| 8716 |
}); |
| 8717 |
} |
| 8718 |
/** |
| 8719 |
* show image dialog |
| 8720 |
* |
| 8721 |
* @param {jQuery} $dialog |
| 8722 |
* @return {Promise} |
| 8723 |
*/ |
| 8724 |
|
| 8725 |
}, { |
| 8726 |
key: "showImageDialog", |
| 8727 |
value: function showImageDialog() { |
| 8728 |
var _this2 = this; |
| 8729 |
|
| 8730 |
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) { |
| 8731 |
var $imageInput = _this2.$dialog.find('.note-image-input'); |
| 8732 |
|
| 8733 |
var $imageUrl = _this2.$dialog.find('.note-image-url'); |
| 8734 |
|
| 8735 |
var $imageBtn = _this2.$dialog.find('.note-image-btn'); |
| 8736 |
|
| 8737 |
_this2.ui.onDialogShown(_this2.$dialog, function () { |
| 8738 |
_this2.context.triggerEvent('dialog.shown'); // Cloning imageInput to clear element. |
| 8739 |
|
| 8740 |
|
| 8741 |
$imageInput.replaceWith($imageInput.clone().on('change', function (event) { |
| 8742 |
deferred.resolve(event.target.files || event.target.value); |
| 8743 |
}).val('')); |
| 8744 |
$imageUrl.on('input paste propertychange', function () { |
| 8745 |
_this2.ui.toggleBtn($imageBtn, $imageUrl.val()); |
| 8746 |
}).val(''); |
| 8747 |
|
| 8748 |
if (!env.isSupportTouch) { |
| 8749 |
$imageUrl.trigger('focus'); |
| 8750 |
} |
| 8751 |
|
| 8752 |
$imageBtn.click(function (event) { |
| 8753 |
event.preventDefault(); |
| 8754 |
deferred.resolve($imageUrl.val()); |
| 8755 |
}); |
| 8756 |
|
| 8757 |
_this2.bindEnterKey($imageUrl, $imageBtn); |
| 8758 |
}); |
| 8759 |
|
| 8760 |
_this2.ui.onDialogHidden(_this2.$dialog, function () { |
| 8761 |
$imageInput.off(); |
| 8762 |
$imageUrl.off(); |
| 8763 |
$imageBtn.off(); |
| 8764 |
|
| 8765 |
if (deferred.state() === 'pending') { |
| 8766 |
deferred.reject(); |
| 8767 |
} |
| 8768 |
}); |
| 8769 |
|
| 8770 |
_this2.ui.showDialog(_this2.$dialog); |
| 8771 |
}); |
| 8772 |
} |
| 8773 |
}]); |
| 8774 |
|
| 8775 |
return ImageDialog; |
| 8776 |
}(); |
| 8777 |
|
| 8778 |
|
| 8779 |
// CONCATENATED MODULE: ./src/js/base/module/ImagePopover.js |
| 8780 |
function ImagePopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8781 |
|
| 8782 |
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); } } |
| 8783 |
|
| 8784 |
function ImagePopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) ImagePopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) ImagePopover_defineProperties(Constructor, staticProps); return Constructor; } |
| 8785 |
|
| 8786 |
|
| 8787 |
|
| 8788 |
|
| 8789 |
/** |
| 8790 |
* Image popover module |
| 8791 |
* mouse events that show/hide popover will be handled by Handle.js. |
| 8792 |
* Handle.js will receive the events and invoke 'imagePopover.update'. |
| 8793 |
*/ |
| 8794 |
|
| 8795 |
var ImagePopover_ImagePopover = /*#__PURE__*/function () { |
| 8796 |
function ImagePopover(context) { |
| 8797 |
var _this = this; |
| 8798 |
|
| 8799 |
ImagePopover_classCallCheck(this, ImagePopover); |
| 8800 |
|
| 8801 |
this.context = context; |
| 8802 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 8803 |
this.editable = context.layoutInfo.editable[0]; |
| 8804 |
this.options = context.options; |
| 8805 |
this.events = { |
| 8806 |
'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() { |
| 8807 |
_this.hide(); |
| 8808 |
} |
| 8809 |
}; |
| 8810 |
} |
| 8811 |
|
| 8812 |
ImagePopover_createClass(ImagePopover, [{ |
| 8813 |
key: "shouldInitialize", |
| 8814 |
value: function shouldInitialize() { |
| 8815 |
return !lists.isEmpty(this.options.popover.image); |
| 8816 |
} |
| 8817 |
}, { |
| 8818 |
key: "initialize", |
| 8819 |
value: function initialize() { |
| 8820 |
this.$popover = this.ui.popover({ |
| 8821 |
className: 'note-image-popover' |
| 8822 |
}).render().appendTo(this.options.container); |
| 8823 |
var $content = this.$popover.find('.popover-content,.note-popover-content'); |
| 8824 |
this.context.invoke('buttons.build', $content, this.options.popover.image); |
| 8825 |
this.$popover.on('mousedown', function (e) { |
| 8826 |
e.preventDefault(); |
| 8827 |
}); |
| 8828 |
} |
| 8829 |
}, { |
| 8830 |
key: "destroy", |
| 8831 |
value: function destroy() { |
| 8832 |
this.$popover.remove(); |
| 8833 |
} |
| 8834 |
}, { |
| 8835 |
key: "update", |
| 8836 |
value: function update(target, event) { |
| 8837 |
if (dom.isImg(target)) { |
| 8838 |
var position = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(target).offset(); |
| 8839 |
var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset(); |
| 8840 |
var pos = {}; |
| 8841 |
|
| 8842 |
if (this.options.popatmouse) { |
| 8843 |
pos.left = event.pageX - 20; |
| 8844 |
pos.top = event.pageY; |
| 8845 |
} else { |
| 8846 |
pos = position; |
| 8847 |
} |
| 8848 |
|
| 8849 |
pos.top -= containerOffset.top; |
| 8850 |
pos.left -= containerOffset.left; |
| 8851 |
this.$popover.css({ |
| 8852 |
display: 'block', |
| 8853 |
left: pos.left, |
| 8854 |
top: pos.top |
| 8855 |
}); |
| 8856 |
} else { |
| 8857 |
this.hide(); |
| 8858 |
} |
| 8859 |
} |
| 8860 |
}, { |
| 8861 |
key: "hide", |
| 8862 |
value: function hide() { |
| 8863 |
this.$popover.hide(); |
| 8864 |
} |
| 8865 |
}]); |
| 8866 |
|
| 8867 |
return ImagePopover; |
| 8868 |
}(); |
| 8869 |
|
| 8870 |
|
| 8871 |
// CONCATENATED MODULE: ./src/js/base/module/TablePopover.js |
| 8872 |
function TablePopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8873 |
|
| 8874 |
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); } } |
| 8875 |
|
| 8876 |
function TablePopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) TablePopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) TablePopover_defineProperties(Constructor, staticProps); return Constructor; } |
| 8877 |
|
| 8878 |
|
| 8879 |
|
| 8880 |
|
| 8881 |
|
| 8882 |
|
| 8883 |
var TablePopover_TablePopover = /*#__PURE__*/function () { |
| 8884 |
function TablePopover(context) { |
| 8885 |
var _this = this; |
| 8886 |
|
| 8887 |
TablePopover_classCallCheck(this, TablePopover); |
| 8888 |
|
| 8889 |
this.context = context; |
| 8890 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 8891 |
this.options = context.options; |
| 8892 |
this.events = { |
| 8893 |
'summernote.mousedown': function summernoteMousedown(we, e) { |
| 8894 |
_this.update(e.target); |
| 8895 |
}, |
| 8896 |
'summernote.keyup summernote.scroll summernote.change': function summernoteKeyupSummernoteScrollSummernoteChange() { |
| 8897 |
_this.update(); |
| 8898 |
}, |
| 8899 |
'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() { |
| 8900 |
_this.hide(); |
| 8901 |
} |
| 8902 |
}; |
| 8903 |
} |
| 8904 |
|
| 8905 |
TablePopover_createClass(TablePopover, [{ |
| 8906 |
key: "shouldInitialize", |
| 8907 |
value: function shouldInitialize() { |
| 8908 |
return !lists.isEmpty(this.options.popover.table); |
| 8909 |
} |
| 8910 |
}, { |
| 8911 |
key: "initialize", |
| 8912 |
value: function initialize() { |
| 8913 |
this.$popover = this.ui.popover({ |
| 8914 |
className: 'note-table-popover' |
| 8915 |
}).render().appendTo(this.options.container); |
| 8916 |
var $content = this.$popover.find('.popover-content,.note-popover-content'); |
| 8917 |
this.context.invoke('buttons.build', $content, this.options.popover.table); // [workaround] Disable Firefox's default table editor |
| 8918 |
|
| 8919 |
if (env.isFF) { |
| 8920 |
document.execCommand('enableInlineTableEditing', false, false); |
| 8921 |
} |
| 8922 |
|
| 8923 |
this.$popover.on('mousedown', function (e) { |
| 8924 |
e.preventDefault(); |
| 8925 |
}); |
| 8926 |
} |
| 8927 |
}, { |
| 8928 |
key: "destroy", |
| 8929 |
value: function destroy() { |
| 8930 |
this.$popover.remove(); |
| 8931 |
} |
| 8932 |
}, { |
| 8933 |
key: "update", |
| 8934 |
value: function update(target) { |
| 8935 |
if (this.context.isDisabled()) { |
| 8936 |
return false; |
| 8937 |
} |
| 8938 |
|
| 8939 |
var isCell = dom.isCell(target); |
| 8940 |
|
| 8941 |
if (isCell) { |
| 8942 |
var pos = dom.posFromPlaceholder(target); |
| 8943 |
var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset(); |
| 8944 |
pos.top -= containerOffset.top; |
| 8945 |
pos.left -= containerOffset.left; |
| 8946 |
this.$popover.css({ |
| 8947 |
display: 'block', |
| 8948 |
left: pos.left, |
| 8949 |
top: pos.top |
| 8950 |
}); |
| 8951 |
} else { |
| 8952 |
this.hide(); |
| 8953 |
} |
| 8954 |
|
| 8955 |
return isCell; |
| 8956 |
} |
| 8957 |
}, { |
| 8958 |
key: "hide", |
| 8959 |
value: function hide() { |
| 8960 |
this.$popover.hide(); |
| 8961 |
} |
| 8962 |
}]); |
| 8963 |
|
| 8964 |
return TablePopover; |
| 8965 |
}(); |
| 8966 |
|
| 8967 |
|
| 8968 |
// CONCATENATED MODULE: ./src/js/base/module/VideoDialog.js |
| 8969 |
function VideoDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8970 |
|
| 8971 |
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); } } |
| 8972 |
|
| 8973 |
function VideoDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) VideoDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) VideoDialog_defineProperties(Constructor, staticProps); return Constructor; } |
| 8974 |
|
| 8975 |
|
| 8976 |
|
| 8977 |
|
| 8978 |
|
| 8979 |
var VideoDialog_VideoDialog = /*#__PURE__*/function () { |
| 8980 |
function VideoDialog(context) { |
| 8981 |
VideoDialog_classCallCheck(this, VideoDialog); |
| 8982 |
|
| 8983 |
this.context = context; |
| 8984 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 8985 |
this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body); |
| 8986 |
this.$editor = context.layoutInfo.editor; |
| 8987 |
this.options = context.options; |
| 8988 |
this.lang = this.options.langInfo; |
| 8989 |
} |
| 8990 |
|
| 8991 |
VideoDialog_createClass(VideoDialog, [{ |
| 8992 |
key: "initialize", |
| 8993 |
value: function initialize() { |
| 8994 |
var $container = this.options.dialogsInBody ? this.$body : this.options.container; |
| 8995 |
var body = ['<div class="form-group note-form-group row-fluid">', "<label for=\"note-dialog-video-url-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.video.url, " <small class=\"text-muted\">").concat(this.lang.video.providers, "</small></label>"), "<input id=\"note-dialog-video-url-".concat(this.options.id, "\" class=\"note-video-url form-control note-form-control note-input\" type=\"text\"/>"), '</div>'].join(''); |
| 8996 |
var buttonClass = 'btn btn-primary note-btn note-btn-primary note-video-btn'; |
| 8997 |
var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.video.insert, "\" disabled>"); |
| 8998 |
this.$dialog = this.ui.dialog({ |
| 8999 |
title: this.lang.video.insert, |
| 9000 |
fade: this.options.dialogsFade, |
| 9001 |
body: body, |
| 9002 |
footer: footer |
| 9003 |
}).render().appendTo($container); |
| 9004 |
} |
| 9005 |
}, { |
| 9006 |
key: "destroy", |
| 9007 |
value: function destroy() { |
| 9008 |
this.ui.hideDialog(this.$dialog); |
| 9009 |
this.$dialog.remove(); |
| 9010 |
} |
| 9011 |
}, { |
| 9012 |
key: "bindEnterKey", |
| 9013 |
value: function bindEnterKey($input, $btn) { |
| 9014 |
$input.on('keypress', function (event) { |
| 9015 |
if (event.keyCode === core_key.code.ENTER) { |
| 9016 |
event.preventDefault(); |
| 9017 |
$btn.trigger('click'); |
| 9018 |
} |
| 9019 |
}); |
| 9020 |
} |
| 9021 |
}, { |
| 9022 |
key: "createVideoNode", |
| 9023 |
value: function createVideoNode(url) { |
| 9024 |
// video url patterns(youtube, instagram, vimeo, dailymotion, youku, mp4, ogg, webm) |
| 9025 |
var ytRegExp = /\/\/(?:(?:www|m)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w|-]{11})(?:(?:[\?&]t=)(\S+))?$/; |
| 9026 |
var ytRegExpForStart = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/; |
| 9027 |
var ytMatch = url.match(ytRegExp); |
| 9028 |
var igRegExp = /(?:www\.|\/\/)instagram\.com\/p\/(.[a-zA-Z0-9_-]*)/; |
| 9029 |
var igMatch = url.match(igRegExp); |
| 9030 |
var vRegExp = /\/\/vine\.co\/v\/([a-zA-Z0-9]+)/; |
| 9031 |
var vMatch = url.match(vRegExp); |
| 9032 |
var vimRegExp = /\/\/(player\.)?vimeo\.com\/([a-z]*\/)*(\d+)[?]?.*/; |
| 9033 |
var vimMatch = url.match(vimRegExp); |
| 9034 |
var dmRegExp = /.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/; |
| 9035 |
var dmMatch = url.match(dmRegExp); |
| 9036 |
var youkuRegExp = /\/\/v\.youku\.com\/v_show\/id_(\w+)=*\.html/; |
| 9037 |
var youkuMatch = url.match(youkuRegExp); |
| 9038 |
var qqRegExp = /\/\/v\.qq\.com.*?vid=(.+)/; |
| 9039 |
var qqMatch = url.match(qqRegExp); |
| 9040 |
var qqRegExp2 = /\/\/v\.qq\.com\/x?\/?(page|cover).*?\/([^\/]+)\.html\??.*/; |
| 9041 |
var qqMatch2 = url.match(qqRegExp2); |
| 9042 |
var mp4RegExp = /^.+.(mp4|m4v)$/; |
| 9043 |
var mp4Match = url.match(mp4RegExp); |
| 9044 |
var oggRegExp = /^.+.(ogg|ogv)$/; |
| 9045 |
var oggMatch = url.match(oggRegExp); |
| 9046 |
var webmRegExp = /^.+.(webm)$/; |
| 9047 |
var webmMatch = url.match(webmRegExp); |
| 9048 |
var fbRegExp = /(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/; |
| 9049 |
var fbMatch = url.match(fbRegExp); |
| 9050 |
var $video; |
| 9051 |
|
| 9052 |
if (ytMatch && ytMatch[1].length === 11) { |
| 9053 |
var youtubeId = ytMatch[1]; |
| 9054 |
var start = 0; |
| 9055 |
|
| 9056 |
if (typeof ytMatch[2] !== 'undefined') { |
| 9057 |
var ytMatchForStart = ytMatch[2].match(ytRegExpForStart); |
| 9058 |
|
| 9059 |
if (ytMatchForStart) { |
| 9060 |
for (var n = [3600, 60, 1], i = 0, r = n.length; i < r; i++) { |
| 9061 |
start += typeof ytMatchForStart[i + 1] !== 'undefined' ? n[i] * parseInt(ytMatchForStart[i + 1], 10) : 0; |
| 9062 |
} |
| 9063 |
} |
| 9064 |
} |
| 9065 |
|
| 9066 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', '//www.youtube.com/embed/' + youtubeId + (start > 0 ? '?start=' + start : '')).attr('width', '640').attr('height', '360'); |
| 9067 |
} else if (igMatch && igMatch[0].length) { |
| 9068 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', 'https://instagram.com/p/' + igMatch[1] + '/embed/').attr('width', '612').attr('height', '710').attr('scrolling', 'no').attr('allowtransparency', 'true'); |
| 9069 |
} else if (vMatch && vMatch[0].length) { |
| 9070 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', vMatch[0] + '/embed/simple').attr('width', '600').attr('height', '600').attr('class', 'vine-embed'); |
| 9071 |
} else if (vimMatch && vimMatch[3].length) { |
| 9072 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('src', '//player.vimeo.com/video/' + vimMatch[3]).attr('width', '640').attr('height', '360'); |
| 9073 |
} else if (dmMatch && dmMatch[2].length) { |
| 9074 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', '//www.dailymotion.com/embed/video/' + dmMatch[2]).attr('width', '640').attr('height', '360'); |
| 9075 |
} else if (youkuMatch && youkuMatch[1].length) { |
| 9076 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('height', '498').attr('width', '510').attr('src', '//player.youku.com/embed/' + youkuMatch[1]); |
| 9077 |
} else if (qqMatch && qqMatch[1].length || qqMatch2 && qqMatch2[2].length) { |
| 9078 |
var vid = qqMatch && qqMatch[1].length ? qqMatch[1] : qqMatch2[2]; |
| 9079 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('height', '310').attr('width', '500').attr('src', 'https://v.qq.com/txp/iframe/player.html?vid=' + vid + '&auto=0'); |
| 9080 |
} else if (mp4Match || oggMatch || webmMatch) { |
| 9081 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<video controls>').attr('src', url).attr('width', '640').attr('height', '360'); |
| 9082 |
} else if (fbMatch && fbMatch[0].length) { |
| 9083 |
$video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', 'https://www.facebook.com/plugins/video.php?href=' + encodeURIComponent(fbMatch[0]) + '&show_text=0&width=560').attr('width', '560').attr('height', '301').attr('scrolling', 'no').attr('allowtransparency', 'true'); |
| 9084 |
} else { |
| 9085 |
// this is not a known video link. Now what, Cat? Now what? |
| 9086 |
return false; |
| 9087 |
} |
| 9088 |
|
| 9089 |
$video.addClass('note-video-clip'); |
| 9090 |
return $video[0]; |
| 9091 |
} |
| 9092 |
}, { |
| 9093 |
key: "show", |
| 9094 |
value: function show() { |
| 9095 |
var _this = this; |
| 9096 |
|
| 9097 |
var text = this.context.invoke('editor.getSelectedText'); |
| 9098 |
this.context.invoke('editor.saveRange'); |
| 9099 |
this.showVideoDialog(text).then(function (url) { |
| 9100 |
// [workaround] hide dialog before restore range for IE range focus |
| 9101 |
_this.ui.hideDialog(_this.$dialog); |
| 9102 |
|
| 9103 |
_this.context.invoke('editor.restoreRange'); // build node |
| 9104 |
|
| 9105 |
|
| 9106 |
var $node = _this.createVideoNode(url); |
| 9107 |
|
| 9108 |
if ($node) { |
| 9109 |
// insert video node |
| 9110 |
_this.context.invoke('editor.insertNode', $node); |
| 9111 |
} |
| 9112 |
}).fail(function () { |
| 9113 |
_this.context.invoke('editor.restoreRange'); |
| 9114 |
}); |
| 9115 |
} |
| 9116 |
/** |
| 9117 |
* show video dialog |
| 9118 |
* |
| 9119 |
* @param {jQuery} $dialog |
| 9120 |
* @return {Promise} |
| 9121 |
*/ |
| 9122 |
|
| 9123 |
}, { |
| 9124 |
key: "showVideoDialog", |
| 9125 |
value: function showVideoDialog() |
| 9126 |
/* text */ |
| 9127 |
{ |
| 9128 |
var _this2 = this; |
| 9129 |
|
| 9130 |
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) { |
| 9131 |
var $videoUrl = _this2.$dialog.find('.note-video-url'); |
| 9132 |
|
| 9133 |
var $videoBtn = _this2.$dialog.find('.note-video-btn'); |
| 9134 |
|
| 9135 |
_this2.ui.onDialogShown(_this2.$dialog, function () { |
| 9136 |
_this2.context.triggerEvent('dialog.shown'); |
| 9137 |
|
| 9138 |
$videoUrl.on('input paste propertychange', function () { |
| 9139 |
_this2.ui.toggleBtn($videoBtn, $videoUrl.val()); |
| 9140 |
}); |
| 9141 |
|
| 9142 |
if (!env.isSupportTouch) { |
| 9143 |
$videoUrl.trigger('focus'); |
| 9144 |
} |
| 9145 |
|
| 9146 |
$videoBtn.click(function (event) { |
| 9147 |
event.preventDefault(); |
| 9148 |
deferred.resolve($videoUrl.val()); |
| 9149 |
}); |
| 9150 |
|
| 9151 |
_this2.bindEnterKey($videoUrl, $videoBtn); |
| 9152 |
}); |
| 9153 |
|
| 9154 |
_this2.ui.onDialogHidden(_this2.$dialog, function () { |
| 9155 |
$videoUrl.off(); |
| 9156 |
$videoBtn.off(); |
| 9157 |
|
| 9158 |
if (deferred.state() === 'pending') { |
| 9159 |
deferred.reject(); |
| 9160 |
} |
| 9161 |
}); |
| 9162 |
|
| 9163 |
_this2.ui.showDialog(_this2.$dialog); |
| 9164 |
}); |
| 9165 |
} |
| 9166 |
}]); |
| 9167 |
|
| 9168 |
return VideoDialog; |
| 9169 |
}(); |
| 9170 |
|
| 9171 |
|
| 9172 |
// CONCATENATED MODULE: ./src/js/base/module/HelpDialog.js |
| 9173 |
function HelpDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 9174 |
|
| 9175 |
function HelpDialog_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); } } |
| 9176 |
|
| 9177 |
function HelpDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) HelpDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) HelpDialog_defineProperties(Constructor, staticProps); return Constructor; } |
| 9178 |
|
| 9179 |
|
| 9180 |
|
| 9181 |
|
| 9182 |
var HelpDialog_HelpDialog = /*#__PURE__*/function () { |
| 9183 |
function HelpDialog(context) { |
| 9184 |
HelpDialog_classCallCheck(this, HelpDialog); |
| 9185 |
|
| 9186 |
this.context = context; |
| 9187 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 9188 |
this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body); |
| 9189 |
this.$editor = context.layoutInfo.editor; |
| 9190 |
this.options = context.options; |
| 9191 |
this.lang = this.options.langInfo; |
| 9192 |
} |
| 9193 |
|
| 9194 |
HelpDialog_createClass(HelpDialog, [{ |
| 9195 |
key: "initialize", |
| 9196 |
value: function initialize() { |
| 9197 |
var $container = this.options.dialogsInBody ? this.$body : this.options.container; |
| 9198 |
var body = ['<p class="text-center">', '<a href="http://summernote.org/" target="_blank">Summernote 0.8.18</a> · ', '<a href="https://github.com/summernote/summernote" target="_blank">Project</a> · ', '<a href="https://github.com/summernote/summernote/issues" target="_blank">Issues</a>', '</p>'].join(''); |
| 9199 |
this.$dialog = this.ui.dialog({ |
| 9200 |
title: this.lang.options.help, |
| 9201 |
fade: this.options.dialogsFade, |
| 9202 |
body: this.createShortcutList(), |
| 9203 |
footer: body, |
| 9204 |
callback: function callback($node) { |
| 9205 |
$node.find('.modal-body,.note-modal-body').css({ |
| 9206 |
'max-height': 300, |
| 9207 |
'overflow': 'scroll' |
| 9208 |
}); |
| 9209 |
} |
| 9210 |
}).render().appendTo($container); |
| 9211 |
} |
| 9212 |
}, { |
| 9213 |
key: "destroy", |
| 9214 |
value: function destroy() { |
| 9215 |
this.ui.hideDialog(this.$dialog); |
| 9216 |
this.$dialog.remove(); |
| 9217 |
} |
| 9218 |
}, { |
| 9219 |
key: "createShortcutList", |
| 9220 |
value: function createShortcutList() { |
| 9221 |
var _this = this; |
| 9222 |
|
| 9223 |
var keyMap = this.options.keyMap[env.isMac ? 'mac' : 'pc']; |
| 9224 |
return Object.keys(keyMap).map(function (key) { |
| 9225 |
var command = keyMap[key]; |
| 9226 |
var $row = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div><div class="help-list-item"></div></div>'); |
| 9227 |
$row.append(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<label><kbd>' + key + '</kdb></label>').css({ |
| 9228 |
'width': 180, |
| 9229 |
'margin-right': 10 |
| 9230 |
})).append(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<span/>').html(_this.context.memo('help.' + command) || command)); |
| 9231 |
return $row.html(); |
| 9232 |
}).join(''); |
| 9233 |
} |
| 9234 |
/** |
| 9235 |
* show help dialog |
| 9236 |
* |
| 9237 |
* @return {Promise} |
| 9238 |
*/ |
| 9239 |
|
| 9240 |
}, { |
| 9241 |
key: "showHelpDialog", |
| 9242 |
value: function showHelpDialog() { |
| 9243 |
var _this2 = this; |
| 9244 |
|
| 9245 |
return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) { |
| 9246 |
_this2.ui.onDialogShown(_this2.$dialog, function () { |
| 9247 |
_this2.context.triggerEvent('dialog.shown'); |
| 9248 |
|
| 9249 |
deferred.resolve(); |
| 9250 |
}); |
| 9251 |
|
| 9252 |
_this2.ui.showDialog(_this2.$dialog); |
| 9253 |
}).promise(); |
| 9254 |
} |
| 9255 |
}, { |
| 9256 |
key: "show", |
| 9257 |
value: function show() { |
| 9258 |
var _this3 = this; |
| 9259 |
|
| 9260 |
this.context.invoke('editor.saveRange'); |
| 9261 |
this.showHelpDialog().then(function () { |
| 9262 |
_this3.context.invoke('editor.restoreRange'); |
| 9263 |
}); |
| 9264 |
} |
| 9265 |
}]); |
| 9266 |
|
| 9267 |
return HelpDialog; |
| 9268 |
}(); |
| 9269 |
|
| 9270 |
|
| 9271 |
// CONCATENATED MODULE: ./src/js/base/module/AirPopover.js |
| 9272 |
function AirPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 9273 |
|
| 9274 |
function AirPopover_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); } } |
| 9275 |
|
| 9276 |
function AirPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) AirPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) AirPopover_defineProperties(Constructor, staticProps); return Constructor; } |
| 9277 |
|
| 9278 |
|
| 9279 |
|
| 9280 |
var AIRMODE_POPOVER_X_OFFSET = -5; |
| 9281 |
var AIRMODE_POPOVER_Y_OFFSET = 5; |
| 9282 |
|
| 9283 |
var AirPopover_AirPopover = /*#__PURE__*/function () { |
| 9284 |
function AirPopover(context) { |
| 9285 |
var _this = this; |
| 9286 |
|
| 9287 |
AirPopover_classCallCheck(this, AirPopover); |
| 9288 |
|
| 9289 |
this.context = context; |
| 9290 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 9291 |
this.options = context.options; |
| 9292 |
this.hidable = true; |
| 9293 |
this.onContextmenu = false; |
| 9294 |
this.pageX = null; |
| 9295 |
this.pageY = null; |
| 9296 |
this.events = { |
| 9297 |
'summernote.contextmenu': function summernoteContextmenu(e) { |
| 9298 |
if (_this.options.editing) { |
| 9299 |
e.preventDefault(); |
| 9300 |
e.stopPropagation(); |
| 9301 |
_this.onContextmenu = true; |
| 9302 |
|
| 9303 |
_this.update(true); |
| 9304 |
} |
| 9305 |
}, |
| 9306 |
'summernote.mousedown': function summernoteMousedown(we, e) { |
| 9307 |
_this.pageX = e.pageX; |
| 9308 |
_this.pageY = e.pageY; |
| 9309 |
}, |
| 9310 |
'summernote.keyup summernote.mouseup summernote.scroll': function summernoteKeyupSummernoteMouseupSummernoteScroll(we, e) { |
| 9311 |
if (_this.options.editing && !_this.onContextmenu) { |
| 9312 |
_this.pageX = e.pageX; |
| 9313 |
_this.pageY = e.pageY; |
| 9314 |
|
| 9315 |
_this.update(); |
| 9316 |
} |
| 9317 |
|
| 9318 |
_this.onContextmenu = false; |
| 9319 |
}, |
| 9320 |
'summernote.disable summernote.change summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteChangeSummernoteDialogShownSummernoteBlur() { |
| 9321 |
_this.hide(); |
| 9322 |
}, |
| 9323 |
'summernote.focusout': function summernoteFocusout() { |
| 9324 |
if (!_this.$popover.is(':active,:focus')) { |
| 9325 |
_this.hide(); |
| 9326 |
} |
| 9327 |
} |
| 9328 |
}; |
| 9329 |
} |
| 9330 |
|
| 9331 |
AirPopover_createClass(AirPopover, [{ |
| 9332 |
key: "shouldInitialize", |
| 9333 |
value: function shouldInitialize() { |
| 9334 |
return this.options.airMode && !lists.isEmpty(this.options.popover.air); |
| 9335 |
} |
| 9336 |
}, { |
| 9337 |
key: "initialize", |
| 9338 |
value: function initialize() { |
| 9339 |
var _this2 = this; |
| 9340 |
|
| 9341 |
this.$popover = this.ui.popover({ |
| 9342 |
className: 'note-air-popover' |
| 9343 |
}).render().appendTo(this.options.container); |
| 9344 |
var $content = this.$popover.find('.popover-content'); |
| 9345 |
this.context.invoke('buttons.build', $content, this.options.popover.air); // disable hiding this popover preemptively by 'summernote.blur' event. |
| 9346 |
|
| 9347 |
this.$popover.on('mousedown', function () { |
| 9348 |
_this2.hidable = false; |
| 9349 |
}); // (re-)enable hiding after 'summernote.blur' has been handled (aka. ignored). |
| 9350 |
|
| 9351 |
this.$popover.on('mouseup', function () { |
| 9352 |
_this2.hidable = true; |
| 9353 |
}); |
| 9354 |
} |
| 9355 |
}, { |
| 9356 |
key: "destroy", |
| 9357 |
value: function destroy() { |
| 9358 |
this.$popover.remove(); |
| 9359 |
} |
| 9360 |
}, { |
| 9361 |
key: "update", |
| 9362 |
value: function update(forcelyOpen) { |
| 9363 |
var styleInfo = this.context.invoke('editor.currentStyle'); |
| 9364 |
|
| 9365 |
if (styleInfo.range && (!styleInfo.range.isCollapsed() || forcelyOpen)) { |
| 9366 |
var rect = { |
| 9367 |
left: this.pageX, |
| 9368 |
top: this.pageY |
| 9369 |
}; |
| 9370 |
var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset(); |
| 9371 |
rect.top -= containerOffset.top; |
| 9372 |
rect.left -= containerOffset.left; |
| 9373 |
this.$popover.css({ |
| 9374 |
display: 'block', |
| 9375 |
left: Math.max(rect.left, 0) + AIRMODE_POPOVER_X_OFFSET, |
| 9376 |
top: rect.top + AIRMODE_POPOVER_Y_OFFSET |
| 9377 |
}); |
| 9378 |
this.context.invoke('buttons.updateCurrentStyle', this.$popover); |
| 9379 |
} else { |
| 9380 |
this.hide(); |
| 9381 |
} |
| 9382 |
} |
| 9383 |
}, { |
| 9384 |
key: "updateCodeview", |
| 9385 |
value: function updateCodeview(isCodeview) { |
| 9386 |
this.ui.toggleBtnActive(this.$popover.find('.btn-codeview'), isCodeview); |
| 9387 |
|
| 9388 |
if (isCodeview) { |
| 9389 |
this.hide(); |
| 9390 |
} |
| 9391 |
} |
| 9392 |
}, { |
| 9393 |
key: "hide", |
| 9394 |
value: function hide() { |
| 9395 |
if (this.hidable) { |
| 9396 |
this.$popover.hide(); |
| 9397 |
} |
| 9398 |
} |
| 9399 |
}]); |
| 9400 |
|
| 9401 |
return AirPopover; |
| 9402 |
}(); |
| 9403 |
|
| 9404 |
|
| 9405 |
// CONCATENATED MODULE: ./src/js/base/module/HintPopover.js |
| 9406 |
function HintPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 9407 |
|
| 9408 |
function HintPopover_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); } } |
| 9409 |
|
| 9410 |
function HintPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) HintPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) HintPopover_defineProperties(Constructor, staticProps); return Constructor; } |
| 9411 |
|
| 9412 |
|
| 9413 |
|
| 9414 |
|
| 9415 |
|
| 9416 |
|
| 9417 |
|
| 9418 |
var POPOVER_DIST = 5; |
| 9419 |
|
| 9420 |
var HintPopover_HintPopover = /*#__PURE__*/function () { |
| 9421 |
function HintPopover(context) { |
| 9422 |
var _this = this; |
| 9423 |
|
| 9424 |
HintPopover_classCallCheck(this, HintPopover); |
| 9425 |
|
| 9426 |
this.context = context; |
| 9427 |
this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui; |
| 9428 |
this.$editable = context.layoutInfo.editable; |
| 9429 |
this.options = context.options; |
| 9430 |
this.hint = this.options.hint || []; |
| 9431 |
this.direction = this.options.hintDirection || 'bottom'; |
| 9432 |
this.hints = Array.isArray(this.hint) ? this.hint : [this.hint]; |
| 9433 |
this.events = { |
| 9434 |
'summernote.keyup': function summernoteKeyup(we, e) { |
| 9435 |
if (!e.isDefaultPrevented()) { |
| 9436 |
_this.handleKeyup(e); |
| 9437 |
} |
| 9438 |
}, |
| 9439 |
'summernote.keydown': function summernoteKeydown(we, e) { |
| 9440 |
_this.handleKeydown(e); |
| 9441 |
}, |
| 9442 |
'summernote.disable summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteDialogShownSummernoteBlur() { |
| 9443 |
_this.hide(); |
| 9444 |
} |
| 9445 |
}; |
| 9446 |
} |
| 9447 |
|
| 9448 |
HintPopover_createClass(HintPopover, [{ |
| 9449 |
key: "shouldInitialize", |
| 9450 |
value: function shouldInitialize() { |
| 9451 |
return this.hints.length > 0; |
| 9452 |
} |
| 9453 |
}, { |
| 9454 |
key: "initialize", |
| 9455 |
value: function initialize() { |
| 9456 |
var _this2 = this; |
| 9457 |
|
| 9458 |
this.lastWordRange = null; |
| 9459 |
this.matchingWord = null; |
| 9460 |
this.$popover = this.ui.popover({ |
| 9461 |
className: 'note-hint-popover', |
| 9462 |
hideArrow: true, |
| 9463 |
direction: '' |
| 9464 |
}).render().appendTo(this.options.container); |
| 9465 |
this.$popover.hide(); |
| 9466 |
this.$content = this.$popover.find('.popover-content,.note-popover-content'); |
| 9467 |
this.$content.on('click', '.note-hint-item', function (e) { |
| 9468 |
_this2.$content.find('.active').removeClass('active'); |
| 9469 |
|
| 9470 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.currentTarget).addClass('active'); |
| 9471 |
|
| 9472 |
_this2.replace(); |
| 9473 |
}); |
| 9474 |
this.$popover.on('mousedown', function (e) { |
| 9475 |
e.preventDefault(); |
| 9476 |
}); |
| 9477 |
} |
| 9478 |
}, { |
| 9479 |
key: "destroy", |
| 9480 |
value: function destroy() { |
| 9481 |
this.$popover.remove(); |
| 9482 |
} |
| 9483 |
}, { |
| 9484 |
key: "selectItem", |
| 9485 |
value: function selectItem($item) { |
| 9486 |
this.$content.find('.active').removeClass('active'); |
| 9487 |
$item.addClass('active'); |
| 9488 |
this.$content[0].scrollTop = $item[0].offsetTop - this.$content.innerHeight() / 2; |
| 9489 |
} |
| 9490 |
}, { |
| 9491 |
key: "moveDown", |
| 9492 |
value: function moveDown() { |
| 9493 |
var $current = this.$content.find('.note-hint-item.active'); |
| 9494 |
var $next = $current.next(); |
| 9495 |
|
| 9496 |
if ($next.length) { |
| 9497 |
this.selectItem($next); |
| 9498 |
} else { |
| 9499 |
var $nextGroup = $current.parent().next(); |
| 9500 |
|
| 9501 |
if (!$nextGroup.length) { |
| 9502 |
$nextGroup = this.$content.find('.note-hint-group').first(); |
| 9503 |
} |
| 9504 |
|
| 9505 |
this.selectItem($nextGroup.find('.note-hint-item').first()); |
| 9506 |
} |
| 9507 |
} |
| 9508 |
}, { |
| 9509 |
key: "moveUp", |
| 9510 |
value: function moveUp() { |
| 9511 |
var $current = this.$content.find('.note-hint-item.active'); |
| 9512 |
var $prev = $current.prev(); |
| 9513 |
|
| 9514 |
if ($prev.length) { |
| 9515 |
this.selectItem($prev); |
| 9516 |
} else { |
| 9517 |
var $prevGroup = $current.parent().prev(); |
| 9518 |
|
| 9519 |
if (!$prevGroup.length) { |
| 9520 |
$prevGroup = this.$content.find('.note-hint-group').last(); |
| 9521 |
} |
| 9522 |
|
| 9523 |
this.selectItem($prevGroup.find('.note-hint-item').last()); |
| 9524 |
} |
| 9525 |
} |
| 9526 |
}, { |
| 9527 |
key: "replace", |
| 9528 |
value: function replace() { |
| 9529 |
var $item = this.$content.find('.note-hint-item.active'); |
| 9530 |
|
| 9531 |
if ($item.length) { |
| 9532 |
var node = this.nodeFromItem($item); // If matchingWord length = 0 -> capture OK / open hint / but as mention capture "" (\w*) |
| 9533 |
|
| 9534 |
if (this.matchingWord !== null && this.matchingWord.length === 0) { |
| 9535 |
this.lastWordRange.so = this.lastWordRange.eo; // Else si > 0 and normal case -> adjust range "before" for correct position of insertion |
| 9536 |
} else if (this.matchingWord !== null && this.matchingWord.length > 0 && !this.lastWordRange.isCollapsed()) { |
| 9537 |
var rangeCompute = this.lastWordRange.eo - this.lastWordRange.so - this.matchingWord.length; |
| 9538 |
|
| 9539 |
if (rangeCompute > 0) { |
| 9540 |
this.lastWordRange.so += rangeCompute; |
| 9541 |
} |
| 9542 |
} |
| 9543 |
|
| 9544 |
this.lastWordRange.insertNode(node); |
| 9545 |
|
| 9546 |
if (this.options.hintSelect === 'next') { |
| 9547 |
var blank = document.createTextNode(''); |
| 9548 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).after(blank); |
| 9549 |
range.createFromNodeBefore(blank).select(); |
| 9550 |
} else { |
| 9551 |
range.createFromNodeAfter(node).select(); |
| 9552 |
} |
| 9553 |
|
| 9554 |
this.lastWordRange = null; |
| 9555 |
this.hide(); |
| 9556 |
this.context.invoke('editor.focus'); |
| 9557 |
} |
| 9558 |
} |
| 9559 |
}, { |
| 9560 |
key: "nodeFromItem", |
| 9561 |
value: function nodeFromItem($item) { |
| 9562 |
var hint = this.hints[$item.data('index')]; |
| 9563 |
var item = $item.data('item'); |
| 9564 |
var node = hint.content ? hint.content(item) : item; |
| 9565 |
|
| 9566 |
if (typeof node === 'string') { |
| 9567 |
node = dom.createText(node); |
| 9568 |
} |
| 9569 |
|
| 9570 |
return node; |
| 9571 |
} |
| 9572 |
}, { |
| 9573 |
key: "createItemTemplates", |
| 9574 |
value: function createItemTemplates(hintIdx, items) { |
| 9575 |
var hint = this.hints[hintIdx]; |
| 9576 |
return items.map(function (item |
| 9577 |
/*, idx */ |
| 9578 |
) { |
| 9579 |
var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div class="note-hint-item"/>'); |
| 9580 |
$item.append(hint.template ? hint.template(item) : item + ''); |
| 9581 |
$item.data({ |
| 9582 |
'index': hintIdx, |
| 9583 |
'item': item |
| 9584 |
}); |
| 9585 |
return $item; |
| 9586 |
}); |
| 9587 |
} |
| 9588 |
}, { |
| 9589 |
key: "handleKeydown", |
| 9590 |
value: function handleKeydown(e) { |
| 9591 |
if (!this.$popover.is(':visible')) { |
| 9592 |
return; |
| 9593 |
} |
| 9594 |
|
| 9595 |
if (e.keyCode === core_key.code.ENTER) { |
| 9596 |
e.preventDefault(); |
| 9597 |
this.replace(); |
| 9598 |
} else if (e.keyCode === core_key.code.UP) { |
| 9599 |
e.preventDefault(); |
| 9600 |
this.moveUp(); |
| 9601 |
} else if (e.keyCode === core_key.code.DOWN) { |
| 9602 |
e.preventDefault(); |
| 9603 |
this.moveDown(); |
| 9604 |
} |
| 9605 |
} |
| 9606 |
}, { |
| 9607 |
key: "searchKeyword", |
| 9608 |
value: function searchKeyword(index, keyword, callback) { |
| 9609 |
var hint = this.hints[index]; |
| 9610 |
|
| 9611 |
if (hint && hint.match.test(keyword) && hint.search) { |
| 9612 |
var matches = hint.match.exec(keyword); |
| 9613 |
this.matchingWord = matches[0]; |
| 9614 |
hint.search(matches[1], callback); |
| 9615 |
} else { |
| 9616 |
callback(); |
| 9617 |
} |
| 9618 |
} |
| 9619 |
}, { |
| 9620 |
key: "createGroup", |
| 9621 |
value: function createGroup(idx, keyword) { |
| 9622 |
var _this3 = this; |
| 9623 |
|
| 9624 |
var $group = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div class="note-hint-group note-hint-group-' + idx + '"></div>'); |
| 9625 |
this.searchKeyword(idx, keyword, function (items) { |
| 9626 |
items = items || []; |
| 9627 |
|
| 9628 |
if (items.length) { |
| 9629 |
$group.html(_this3.createItemTemplates(idx, items)); |
| 9630 |
|
| 9631 |
_this3.show(); |
| 9632 |
} |
| 9633 |
}); |
| 9634 |
return $group; |
| 9635 |
} |
| 9636 |
}, { |
| 9637 |
key: "handleKeyup", |
| 9638 |
value: function handleKeyup(e) { |
| 9639 |
var _this4 = this; |
| 9640 |
|
| 9641 |
if (!lists.contains([core_key.code.ENTER, core_key.code.UP, core_key.code.DOWN], e.keyCode)) { |
| 9642 |
var _range = this.context.invoke('editor.getLastRange'); |
| 9643 |
|
| 9644 |
var wordRange, keyword; |
| 9645 |
|
| 9646 |
if (this.options.hintMode === 'words') { |
| 9647 |
wordRange = _range.getWordsRange(_range); |
| 9648 |
keyword = wordRange.toString(); |
| 9649 |
this.hints.forEach(function (hint) { |
| 9650 |
if (hint.match.test(keyword)) { |
| 9651 |
wordRange = _range.getWordsMatchRange(hint.match); |
| 9652 |
return false; |
| 9653 |
} |
| 9654 |
}); |
| 9655 |
|
| 9656 |
if (!wordRange) { |
| 9657 |
this.hide(); |
| 9658 |
return; |
| 9659 |
} |
| 9660 |
|
| 9661 |
keyword = wordRange.toString(); |
| 9662 |
} else { |
| 9663 |
wordRange = _range.getWordRange(); |
| 9664 |
keyword = wordRange.toString(); |
| 9665 |
} |
| 9666 |
|
| 9667 |
if (this.hints.length && keyword) { |
| 9668 |
this.$content.empty(); |
| 9669 |
var bnd = func.rect2bnd(lists.last(wordRange.getClientRects())); |
| 9670 |
var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset(); |
| 9671 |
|
| 9672 |
if (bnd) { |
| 9673 |
bnd.top -= containerOffset.top; |
| 9674 |
bnd.left -= containerOffset.left; |
| 9675 |
this.$popover.hide(); |
| 9676 |
this.lastWordRange = wordRange; |
| 9677 |
this.hints.forEach(function (hint, idx) { |
| 9678 |
if (hint.match.test(keyword)) { |
| 9679 |
_this4.createGroup(idx, keyword).appendTo(_this4.$content); |
| 9680 |
} |
| 9681 |
}); // select first .note-hint-item |
| 9682 |
|
| 9683 |
this.$content.find('.note-hint-item:first').addClass('active'); // set position for popover after group is created |
| 9684 |
|
| 9685 |
if (this.direction === 'top') { |
| 9686 |
this.$popover.css({ |
| 9687 |
left: bnd.left, |
| 9688 |
top: bnd.top - this.$popover.outerHeight() - POPOVER_DIST |
| 9689 |
}); |
| 9690 |
} else { |
| 9691 |
this.$popover.css({ |
| 9692 |
left: bnd.left, |
| 9693 |
top: bnd.top + bnd.height + POPOVER_DIST |
| 9694 |
}); |
| 9695 |
} |
| 9696 |
} |
| 9697 |
} else { |
| 9698 |
this.hide(); |
| 9699 |
} |
| 9700 |
} |
| 9701 |
} |
| 9702 |
}, { |
| 9703 |
key: "show", |
| 9704 |
value: function show() { |
| 9705 |
this.$popover.show(); |
| 9706 |
} |
| 9707 |
}, { |
| 9708 |
key: "hide", |
| 9709 |
value: function hide() { |
| 9710 |
this.$popover.hide(); |
| 9711 |
} |
| 9712 |
}]); |
| 9713 |
|
| 9714 |
return HintPopover; |
| 9715 |
}(); |
| 9716 |
|
| 9717 |
|
| 9718 |
// CONCATENATED MODULE: ./src/js/base/settings.js |
| 9719 |
|
| 9720 |
|
| 9721 |
|
| 9722 |
|
| 9723 |
|
| 9724 |
|
| 9725 |
|
| 9726 |
|
| 9727 |
|
| 9728 |
|
| 9729 |
|
| 9730 |
|
| 9731 |
|
| 9732 |
|
| 9733 |
|
| 9734 |
|
| 9735 |
|
| 9736 |
|
| 9737 |
|
| 9738 |
|
| 9739 |
|
| 9740 |
|
| 9741 |
|
| 9742 |
|
| 9743 |
|
| 9744 |
|
| 9745 |
|
| 9746 |
|
| 9747 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote, { |
| 9748 |
version: '0.8.18', |
| 9749 |
plugins: {}, |
| 9750 |
dom: dom, |
| 9751 |
range: range, |
| 9752 |
lists: lists, |
| 9753 |
options: { |
| 9754 |
langInfo: external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.lang['en-US'], |
| 9755 |
editing: true, |
| 9756 |
modules: { |
| 9757 |
'editor': Editor_Editor, |
| 9758 |
'clipboard': Clipboard_Clipboard, |
| 9759 |
'dropzone': Dropzone_Dropzone, |
| 9760 |
'codeview': Codeview_CodeView, |
| 9761 |
'statusbar': Statusbar_Statusbar, |
| 9762 |
'fullscreen': Fullscreen_Fullscreen, |
| 9763 |
'handle': Handle_Handle, |
| 9764 |
// FIXME: HintPopover must be front of autolink |
| 9765 |
// - Script error about range when Enter key is pressed on hint popover |
| 9766 |
'hintPopover': HintPopover_HintPopover, |
| 9767 |
'autoLink': AutoLink_AutoLink, |
| 9768 |
'autoSync': AutoSync_AutoSync, |
| 9769 |
'autoReplace': AutoReplace_AutoReplace, |
| 9770 |
'placeholder': Placeholder_Placeholder, |
| 9771 |
'buttons': Buttons_Buttons, |
| 9772 |
'toolbar': Toolbar_Toolbar, |
| 9773 |
'linkDialog': LinkDialog_LinkDialog, |
| 9774 |
'linkPopover': LinkPopover_LinkPopover, |
| 9775 |
'imageDialog': ImageDialog_ImageDialog, |
| 9776 |
'imagePopover': ImagePopover_ImagePopover, |
| 9777 |
'tablePopover': TablePopover_TablePopover, |
| 9778 |
'videoDialog': VideoDialog_VideoDialog, |
| 9779 |
'helpDialog': HelpDialog_HelpDialog, |
| 9780 |
'airPopover': AirPopover_AirPopover |
| 9781 |
}, |
| 9782 |
buttons: {}, |
| 9783 |
lang: 'en-US', |
| 9784 |
followingToolbar: false, |
| 9785 |
toolbarPosition: 'top', |
| 9786 |
otherStaticBar: '', |
| 9787 |
// toolbar |
| 9788 |
codeviewKeepButton: false, |
| 9789 |
toolbar: [['style', ['style']], ['font', ['bold', 'underline', 'clear']], ['fontname', ['fontname']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture', 'video']], ['view', ['fullscreen', 'codeview', 'help']]], |
| 9790 |
// popover |
| 9791 |
popatmouse: true, |
| 9792 |
popover: { |
| 9793 |
image: [['resize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']], ['float', ['floatLeft', 'floatRight', 'floatNone']], ['remove', ['removeMedia']]], |
| 9794 |
link: [['link', ['linkDialogShow', 'unlink']]], |
| 9795 |
table: [['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']], ['delete', ['deleteRow', 'deleteCol', 'deleteTable']]], |
| 9796 |
air: [['color', ['color']], ['font', ['bold', 'underline', 'clear']], ['para', ['ul', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture']], ['view', ['fullscreen', 'codeview']]] |
| 9797 |
}, |
| 9798 |
// air mode: inline editor |
| 9799 |
airMode: false, |
| 9800 |
overrideContextMenu: false, |
| 9801 |
// TBD |
| 9802 |
width: null, |
| 9803 |
height: null, |
| 9804 |
linkTargetBlank: true, |
| 9805 |
useProtocol: true, |
| 9806 |
defaultProtocol: 'http://', |
| 9807 |
focus: false, |
| 9808 |
tabDisabled: false, |
| 9809 |
tabSize: 4, |
| 9810 |
styleWithCSS: false, |
| 9811 |
shortcuts: true, |
| 9812 |
textareaAutoSync: true, |
| 9813 |
tooltip: 'auto', |
| 9814 |
container: null, |
| 9815 |
maxTextLength: 0, |
| 9816 |
blockquoteBreakingLevel: 2, |
| 9817 |
spellCheck: true, |
| 9818 |
disableGrammar: false, |
| 9819 |
placeholder: null, |
| 9820 |
inheritPlaceholder: false, |
| 9821 |
// TODO: need to be documented |
| 9822 |
recordEveryKeystroke: false, |
| 9823 |
historyLimit: 200, |
| 9824 |
// TODO: need to be documented |
| 9825 |
showDomainOnlyForAutolink: false, |
| 9826 |
// TODO: need to be documented |
| 9827 |
hintMode: 'word', |
| 9828 |
hintSelect: 'after', |
| 9829 |
hintDirection: 'bottom', |
| 9830 |
styleTags: ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'], |
| 9831 |
fontNames: ['Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Helvetica Neue', 'Helvetica', 'Impact', 'Lucida Grande', 'Tahoma', 'Times New Roman', 'Verdana'], |
| 9832 |
fontNamesIgnoreCheck: [], |
| 9833 |
addDefaultFonts: true, |
| 9834 |
fontSizes: ['8', '9', '10', '11', '12', '14', '18', '24', '36'], |
| 9835 |
fontSizeUnits: ['px', 'pt'], |
| 9836 |
// pallete colors(n x n) |
| 9837 |
colors: [['#000000', '#424242', '#636363', '#9C9C94', '#CEC6CE', '#EFEFEF', '#F7F7F7', '#FFFFFF'], ['#FF0000', '#FF9C00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#9C00FF', '#FF00FF'], ['#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE'], ['#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD'], ['#E76363', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5'], ['#CE0000', '#E79439', '#EFC631', '#6BA54A', '#4A7B8C', '#3984C6', '#634AA5', '#A54A7B'], ['#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842'], ['#630000', '#7B3900', '#846300', '#295218', '#083139', '#003163', '#21104A', '#4A1031']], |
| 9838 |
// http://chir.ag/projects/name-that-color/ |
| 9839 |
colorsName: [['Black', 'Tundora', 'Dove Gray', 'Star Dust', 'Pale Slate', 'Gallery', 'Alabaster', 'White'], ['Red', 'Orange Peel', 'Yellow', 'Green', 'Cyan', 'Blue', 'Electric Violet', 'Magenta'], ['Azalea', 'Karry', 'Egg White', 'Zanah', 'Botticelli', 'Tropical Blue', 'Mischka', 'Twilight'], ['Tonys Pink', 'Peach Orange', 'Cream Brulee', 'Sprout', 'Casper', 'Perano', 'Cold Purple', 'Careys Pink'], ['Mandy', 'Rajah', 'Dandelion', 'Olivine', 'Gulf Stream', 'Viking', 'Blue Marguerite', 'Puce'], ['Guardsman Red', 'Fire Bush', 'Golden Dream', 'Chelsea Cucumber', 'Smalt Blue', 'Boston Blue', 'Butterfly Bush', 'Cadillac'], ['Sangria', 'Mai Tai', 'Buddha Gold', 'Forest Green', 'Eden', 'Venice Blue', 'Meteorite', 'Claret'], ['Rosewood', 'Cinnamon', 'Olive', 'Parsley', 'Tiber', 'Midnight Blue', 'Valentino', 'Loulou']], |
| 9840 |
colorButton: { |
| 9841 |
foreColor: '#000000', |
| 9842 |
backColor: '#FFFF00' |
| 9843 |
}, |
| 9844 |
lineHeights: ['1.0', '1.2', '1.4', '1.5', '1.6', '1.8', '2.0', '3.0'], |
| 9845 |
tableClassName: 'table table-bordered', |
| 9846 |
insertTableMaxSize: { |
| 9847 |
col: 10, |
| 9848 |
row: 10 |
| 9849 |
}, |
| 9850 |
// By default, dialogs are attached in container. |
| 9851 |
dialogsInBody: false, |
| 9852 |
dialogsFade: false, |
| 9853 |
maximumImageFileSize: null, |
| 9854 |
callbacks: { |
| 9855 |
onBeforeCommand: null, |
| 9856 |
onBlur: null, |
| 9857 |
onBlurCodeview: null, |
| 9858 |
onChange: null, |
| 9859 |
onChangeCodeview: null, |
| 9860 |
onDialogShown: null, |
| 9861 |
onEnter: null, |
| 9862 |
onFocus: null, |
| 9863 |
onImageLinkInsert: null, |
| 9864 |
onImageUpload: null, |
| 9865 |
onImageUploadError: null, |
| 9866 |
onInit: null, |
| 9867 |
onKeydown: null, |
| 9868 |
onKeyup: null, |
| 9869 |
onMousedown: null, |
| 9870 |
onMouseup: null, |
| 9871 |
onPaste: null, |
| 9872 |
onScroll: null |
| 9873 |
}, |
| 9874 |
codemirror: { |
| 9875 |
mode: 'text/html', |
| 9876 |
htmlMode: true, |
| 9877 |
lineNumbers: true |
| 9878 |
}, |
| 9879 |
codeviewFilter: false, |
| 9880 |
codeviewFilterRegex: /<\/*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|ilayer|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|t(?:itle|extarea)|xml)[^>]*?>/gi, |
| 9881 |
codeviewIframeFilter: true, |
| 9882 |
codeviewIframeWhitelistSrc: [], |
| 9883 |
codeviewIframeWhitelistSrcBase: ['www.youtube.com', 'www.youtube-nocookie.com', 'www.facebook.com', 'vine.co', 'instagram.com', 'player.vimeo.com', 'www.dailymotion.com', 'player.youku.com', 'v.qq.com'], |
| 9884 |
keyMap: { |
| 9885 |
pc: { |
| 9886 |
'ESC': 'escape', |
| 9887 |
'ENTER': 'insertParagraph', |
| 9888 |
'CTRL+Z': 'undo', |
| 9889 |
'CTRL+Y': 'redo', |
| 9890 |
'TAB': 'tab', |
| 9891 |
'SHIFT+TAB': 'untab', |
| 9892 |
'CTRL+B': 'bold', |
| 9893 |
'CTRL+I': 'italic', |
| 9894 |
'CTRL+U': 'underline', |
| 9895 |
'CTRL+SHIFT+S': 'strikethrough', |
| 9896 |
'CTRL+BACKSLASH': 'removeFormat', |
| 9897 |
'CTRL+SHIFT+L': 'justifyLeft', |
| 9898 |
'CTRL+SHIFT+E': 'justifyCenter', |
| 9899 |
'CTRL+SHIFT+R': 'justifyRight', |
| 9900 |
'CTRL+SHIFT+J': 'justifyFull', |
| 9901 |
'CTRL+SHIFT+NUM7': 'insertUnorderedList', |
| 9902 |
'CTRL+SHIFT+NUM8': 'insertOrderedList', |
| 9903 |
'CTRL+LEFTBRACKET': 'outdent', |
| 9904 |
'CTRL+RIGHTBRACKET': 'indent', |
| 9905 |
'CTRL+NUM0': 'formatPara', |
| 9906 |
'CTRL+NUM1': 'formatH1', |
| 9907 |
'CTRL+NUM2': 'formatH2', |
| 9908 |
'CTRL+NUM3': 'formatH3', |
| 9909 |
'CTRL+NUM4': 'formatH4', |
| 9910 |
'CTRL+NUM5': 'formatH5', |
| 9911 |
'CTRL+NUM6': 'formatH6', |
| 9912 |
'CTRL+ENTER': 'insertHorizontalRule', |
| 9913 |
'CTRL+K': 'linkDialog.show' |
| 9914 |
}, |
| 9915 |
mac: { |
| 9916 |
'ESC': 'escape', |
| 9917 |
'ENTER': 'insertParagraph', |
| 9918 |
'CMD+Z': 'undo', |
| 9919 |
'CMD+SHIFT+Z': 'redo', |
| 9920 |
'TAB': 'tab', |
| 9921 |
'SHIFT+TAB': 'untab', |
| 9922 |
'CMD+B': 'bold', |
| 9923 |
'CMD+I': 'italic', |
| 9924 |
'CMD+U': 'underline', |
| 9925 |
'CMD+SHIFT+S': 'strikethrough', |
| 9926 |
'CMD+BACKSLASH': 'removeFormat', |
| 9927 |
'CMD+SHIFT+L': 'justifyLeft', |
| 9928 |
'CMD+SHIFT+E': 'justifyCenter', |
| 9929 |
'CMD+SHIFT+R': 'justifyRight', |
| 9930 |
'CMD+SHIFT+J': 'justifyFull', |
| 9931 |
'CMD+SHIFT+NUM7': 'insertUnorderedList', |
| 9932 |
'CMD+SHIFT+NUM8': 'insertOrderedList', |
| 9933 |
'CMD+LEFTBRACKET': 'outdent', |
| 9934 |
'CMD+RIGHTBRACKET': 'indent', |
| 9935 |
'CMD+NUM0': 'formatPara', |
| 9936 |
'CMD+NUM1': 'formatH1', |
| 9937 |
'CMD+NUM2': 'formatH2', |
| 9938 |
'CMD+NUM3': 'formatH3', |
| 9939 |
'CMD+NUM4': 'formatH4', |
| 9940 |
'CMD+NUM5': 'formatH5', |
| 9941 |
'CMD+NUM6': 'formatH6', |
| 9942 |
'CMD+ENTER': 'insertHorizontalRule', |
| 9943 |
'CMD+K': 'linkDialog.show' |
| 9944 |
} |
| 9945 |
}, |
| 9946 |
icons: { |
| 9947 |
'align': 'note-icon-align', |
| 9948 |
'alignCenter': 'note-icon-align-center', |
| 9949 |
'alignJustify': 'note-icon-align-justify', |
| 9950 |
'alignLeft': 'note-icon-align-left', |
| 9951 |
'alignRight': 'note-icon-align-right', |
| 9952 |
'rowBelow': 'note-icon-row-below', |
| 9953 |
'colBefore': 'note-icon-col-before', |
| 9954 |
'colAfter': 'note-icon-col-after', |
| 9955 |
'rowAbove': 'note-icon-row-above', |
| 9956 |
'rowRemove': 'note-icon-row-remove', |
| 9957 |
'colRemove': 'note-icon-col-remove', |
| 9958 |
'indent': 'note-icon-align-indent', |
| 9959 |
'outdent': 'note-icon-align-outdent', |
| 9960 |
'arrowsAlt': 'note-icon-arrows-alt', |
| 9961 |
'bold': 'note-icon-bold', |
| 9962 |
'caret': 'note-icon-caret', |
| 9963 |
'circle': 'note-icon-circle', |
| 9964 |
'close': 'note-icon-close', |
| 9965 |
'code': 'note-icon-code', |
| 9966 |
'eraser': 'note-icon-eraser', |
| 9967 |
'floatLeft': 'note-icon-float-left', |
| 9968 |
'floatRight': 'note-icon-float-right', |
| 9969 |
'font': 'note-icon-font', |
| 9970 |
'frame': 'note-icon-frame', |
| 9971 |
'italic': 'note-icon-italic', |
| 9972 |
'link': 'note-icon-link', |
| 9973 |
'unlink': 'note-icon-chain-broken', |
| 9974 |
'magic': 'note-icon-magic', |
| 9975 |
'menuCheck': 'note-icon-menu-check', |
| 9976 |
'minus': 'note-icon-minus', |
| 9977 |
'orderedlist': 'note-icon-orderedlist', |
| 9978 |
'pencil': 'note-icon-pencil', |
| 9979 |
'picture': 'note-icon-picture', |
| 9980 |
'question': 'note-icon-question', |
| 9981 |
'redo': 'note-icon-redo', |
| 9982 |
'rollback': 'note-icon-rollback', |
| 9983 |
'square': 'note-icon-square', |
| 9984 |
'strikethrough': 'note-icon-strikethrough', |
| 9985 |
'subscript': 'note-icon-subscript', |
| 9986 |
'superscript': 'note-icon-superscript', |
| 9987 |
'table': 'note-icon-table', |
| 9988 |
'textHeight': 'note-icon-text-height', |
| 9989 |
'trash': 'note-icon-trash', |
| 9990 |
'underline': 'note-icon-underline', |
| 9991 |
'undo': 'note-icon-undo', |
| 9992 |
'unorderedlist': 'note-icon-unorderedlist', |
| 9993 |
'video': 'note-icon-video' |
| 9994 |
} |
| 9995 |
} |
| 9996 |
}); |
| 9997 |
|
| 9998 |
/***/ }), |
| 9999 |
|
| 10000 |
/***/ 4: |
| 10001 |
/***/ (function(module, exports, __webpack_require__) { |
| 10002 |
|
| 10003 |
// extracted by mini-css-extract-plugin |
| 10004 |
|
| 10005 |
/***/ }), |
| 10006 |
|
| 10007 |
/***/ 52: |
| 10008 |
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
| 10009 |
|
| 10010 |
"use strict"; |
| 10011 |
// ESM COMPAT FLAG |
| 10012 |
__webpack_require__.r(__webpack_exports__); |
| 10013 |
|
| 10014 |
// EXTERNAL MODULE: external {"root":"jQuery","commonjs2":"jquery","commonjs":"jquery","amd":"jquery"} |
| 10015 |
var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_ = __webpack_require__(0); |
| 10016 |
var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default = /*#__PURE__*/__webpack_require__.n(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_); |
| 10017 |
|
| 10018 |
// EXTERNAL MODULE: ./src/js/base/renderer.js |
| 10019 |
var renderer = __webpack_require__(1); |
| 10020 |
|
| 10021 |
// CONCATENATED MODULE: ./src/js/bs3/ui.js |
| 10022 |
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } |
| 10023 |
|
| 10024 |
|
| 10025 |
|
| 10026 |
var editor = renderer["a" /* default */].create('<div class="note-editor note-frame panel panel-default"/>'); |
| 10027 |
var toolbar = renderer["a" /* default */].create('<div class="panel-heading note-toolbar" role="toolbar"/>'); |
| 10028 |
var editingArea = renderer["a" /* default */].create('<div class="note-editing-area"/>'); |
| 10029 |
var codable = renderer["a" /* default */].create('<textarea class="note-codable" aria-multiline="true"/>'); |
| 10030 |
var editable = renderer["a" /* default */].create('<div class="note-editable" contentEditable="true" role="textbox" aria-multiline="true"/>'); |
| 10031 |
var statusbar = renderer["a" /* default */].create(['<output class="note-status-output" role="status" aria-live="polite"></output>', '<div class="note-statusbar" role="status">', '<div class="note-resizebar" aria-label="Resize">', '<div class="note-icon-bar"></div>', '<div class="note-icon-bar"></div>', '<div class="note-icon-bar"></div>', '</div>', '</div>'].join('')); |
| 10032 |
var airEditor = renderer["a" /* default */].create('<div class="note-editor note-airframe"/>'); |
| 10033 |
var airEditable = renderer["a" /* default */].create(['<div class="note-editable" contentEditable="true" role="textbox" aria-multiline="true"></div>', '<output class="note-status-output" role="status" aria-live="polite"></output>'].join('')); |
| 10034 |
var buttonGroup = renderer["a" /* default */].create('<div class="note-btn-group btn-group">'); |
| 10035 |
var dropdown = renderer["a" /* default */].create('<ul class="note-dropdown-menu dropdown-menu">', function ($node, options) { |
| 10036 |
var markup = Array.isArray(options.items) ? options.items.map(function (item) { |
| 10037 |
var value = typeof item === 'string' ? item : item.value || ''; |
| 10038 |
var content = options.template ? options.template(item) : item; |
| 10039 |
var option = _typeof(item) === 'object' ? item.option : undefined; |
| 10040 |
var dataValue = 'data-value="' + value + '"'; |
| 10041 |
var dataOption = option !== undefined ? ' data-option="' + option + '"' : ''; |
| 10042 |
return '<li aria-label="' + value + '"><a href="#" ' + (dataValue + dataOption) + '>' + content + '</a></li>'; |
| 10043 |
}).join('') : options.items; |
| 10044 |
$node.html(markup).attr({ |
| 10045 |
'aria-label': options.title |
| 10046 |
}); |
| 10047 |
|
| 10048 |
if (options && options.codeviewKeepButton) { |
| 10049 |
$node.addClass('note-codeview-keep'); |
| 10050 |
} |
| 10051 |
}); |
| 10052 |
|
| 10053 |
var dropdownButtonContents = function dropdownButtonContents(contents, options) { |
| 10054 |
return contents + ' ' + icon(options.icons.caret, 'span'); |
| 10055 |
}; |
| 10056 |
|
| 10057 |
var dropdownCheck = renderer["a" /* default */].create('<ul class="note-dropdown-menu dropdown-menu note-check">', function ($node, options) { |
| 10058 |
var markup = Array.isArray(options.items) ? options.items.map(function (item) { |
| 10059 |
var value = typeof item === 'string' ? item : item.value || ''; |
| 10060 |
var content = options.template ? options.template(item) : item; |
| 10061 |
return '<li aria-label="' + item + '"><a href="#" data-value="' + value + '">' + icon(options.checkClassName) + ' ' + content + '</a></li>'; |
| 10062 |
}).join('') : options.items; |
| 10063 |
$node.html(markup).attr({ |
| 10064 |
'aria-label': options.title |
| 10065 |
}); |
| 10066 |
|
| 10067 |
if (options && options.codeviewKeepButton) { |
| 10068 |
$node.addClass('note-codeview-keep'); |
| 10069 |
} |
| 10070 |
}); |
| 10071 |
var dialog = renderer["a" /* default */].create('<div class="modal note-modal" aria-hidden="false" tabindex="-1" role="dialog"/>', function ($node, options) { |
| 10072 |
if (options.fade) { |
| 10073 |
$node.addClass('fade'); |
| 10074 |
} |
| 10075 |
|
| 10076 |
$node.attr({ |
| 10077 |
'aria-label': options.title |
| 10078 |
}); |
| 10079 |
$node.html(['<div class="modal-dialog">', '<div class="modal-content">', options.title ? '<div class="modal-header">' + '<button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">×</button>' + '<h4 class="modal-title">' + options.title + '</h4>' + '</div>' : '', '<div class="modal-body">' + options.body + '</div>', options.footer ? '<div class="modal-footer">' + options.footer + '</div>' : '', '</div>', '</div>'].join('')); |
| 10080 |
}); |
| 10081 |
var popover = renderer["a" /* default */].create(['<div class="note-popover popover in">', '<div class="arrow"></div>', '<div class="popover-content note-children-container"></div>', '</div>'].join(''), function ($node, options) { |
| 10082 |
var direction = typeof options.direction !== 'undefined' ? options.direction : 'bottom'; |
| 10083 |
$node.addClass(direction); |
| 10084 |
|
| 10085 |
if (options.hideArrow) { |
| 10086 |
$node.find('.arrow').hide(); |
| 10087 |
} |
| 10088 |
}); |
| 10089 |
var ui_checkbox = renderer["a" /* default */].create('<div class="checkbox"></div>', function ($node, options) { |
| 10090 |
$node.html(['<label' + (options.id ? ' for="note-' + options.id + '"' : '') + '>', '<input type="checkbox"' + (options.id ? ' id="note-' + options.id + '"' : ''), options.checked ? ' checked' : '', ' aria-checked="' + (options.checked ? 'true' : 'false') + '"/>', options.text ? options.text : '', '</label>'].join('')); |
| 10091 |
}); |
| 10092 |
|
| 10093 |
var icon = function icon(iconClassName, tagName) { |
| 10094 |
tagName = tagName || 'i'; |
| 10095 |
return '<' + tagName + ' class="' + iconClassName + '"></' + tagName + '>'; |
| 10096 |
}; |
| 10097 |
|
| 10098 |
var ui_ui = function ui(editorOptions) { |
| 10099 |
return { |
| 10100 |
editor: editor, |
| 10101 |
toolbar: toolbar, |
| 10102 |
editingArea: editingArea, |
| 10103 |
codable: codable, |
| 10104 |
editable: editable, |
| 10105 |
statusbar: statusbar, |
| 10106 |
airEditor: airEditor, |
| 10107 |
airEditable: airEditable, |
| 10108 |
buttonGroup: buttonGroup, |
| 10109 |
dropdown: dropdown, |
| 10110 |
dropdownButtonContents: dropdownButtonContents, |
| 10111 |
dropdownCheck: dropdownCheck, |
| 10112 |
dialog: dialog, |
| 10113 |
popover: popover, |
| 10114 |
checkbox: ui_checkbox, |
| 10115 |
icon: icon, |
| 10116 |
options: editorOptions, |
| 10117 |
palette: function palette($node, options) { |
| 10118 |
return renderer["a" /* default */].create('<div class="note-color-palette"/>', function ($node, options) { |
| 10119 |
var contents = []; |
| 10120 |
|
| 10121 |
for (var row = 0, rowSize = options.colors.length; row < rowSize; row++) { |
| 10122 |
var eventName = options.eventName; |
| 10123 |
var colors = options.colors[row]; |
| 10124 |
var colorsName = options.colorsName[row]; |
| 10125 |
var buttons = []; |
| 10126 |
|
| 10127 |
for (var col = 0, colSize = colors.length; col < colSize; col++) { |
| 10128 |
var color = colors[col]; |
| 10129 |
var colorName = colorsName[col]; |
| 10130 |
buttons.push(['<button type="button" class="note-color-btn"', 'style="background-color:', color, '" ', 'data-event="', eventName, '" ', 'data-value="', color, '" ', 'title="', colorName, '" ', 'aria-label="', colorName, '" ', 'data-toggle="button" tabindex="-1"></button>'].join('')); |
| 10131 |
} |
| 10132 |
|
| 10133 |
contents.push('<div class="note-color-row">' + buttons.join('') + '</div>'); |
| 10134 |
} |
| 10135 |
|
| 10136 |
$node.html(contents.join('')); |
| 10137 |
|
| 10138 |
if (options.tooltip) { |
| 10139 |
$node.find('.note-color-btn').tooltip({ |
| 10140 |
container: options.container || editorOptions.container, |
| 10141 |
trigger: 'hover', |
| 10142 |
placement: 'bottom' |
| 10143 |
}); |
| 10144 |
} |
| 10145 |
})($node, options); |
| 10146 |
}, |
| 10147 |
button: function button($node, options) { |
| 10148 |
return renderer["a" /* default */].create('<button type="button" class="note-btn btn btn-default btn-sm" tabindex="-1">', function ($node, options) { |
| 10149 |
if (options && options.tooltip) { |
| 10150 |
$node.attr({ |
| 10151 |
title: options.tooltip, |
| 10152 |
'aria-label': options.tooltip |
| 10153 |
}).tooltip({ |
| 10154 |
container: options.container || editorOptions.container, |
| 10155 |
trigger: 'hover', |
| 10156 |
placement: 'bottom' |
| 10157 |
}).on('click', function (e) { |
| 10158 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.currentTarget).tooltip('hide'); |
| 10159 |
}); |
| 10160 |
} |
| 10161 |
|
| 10162 |
if (options && options.codeviewButton) { |
| 10163 |
$node.addClass('note-codeview-keep'); |
| 10164 |
} |
| 10165 |
})($node, options); |
| 10166 |
}, |
| 10167 |
toggleBtn: function toggleBtn($btn, isEnable) { |
| 10168 |
$btn.toggleClass('disabled', !isEnable); |
| 10169 |
$btn.attr('disabled', !isEnable); |
| 10170 |
}, |
| 10171 |
toggleBtnActive: function toggleBtnActive($btn, isActive) { |
| 10172 |
$btn.toggleClass('active', isActive); |
| 10173 |
}, |
| 10174 |
onDialogShown: function onDialogShown($dialog, handler) { |
| 10175 |
$dialog.one('shown.bs.modal', handler); |
| 10176 |
}, |
| 10177 |
onDialogHidden: function onDialogHidden($dialog, handler) { |
| 10178 |
$dialog.one('hidden.bs.modal', handler); |
| 10179 |
}, |
| 10180 |
showDialog: function showDialog($dialog) { |
| 10181 |
$dialog.modal('show'); |
| 10182 |
}, |
| 10183 |
hideDialog: function hideDialog($dialog) { |
| 10184 |
$dialog.modal('hide'); |
| 10185 |
}, |
| 10186 |
createLayout: function createLayout($note) { |
| 10187 |
var $editor = (editorOptions.airMode ? airEditor([editingArea([codable(), airEditable()])]) : editorOptions.toolbarPosition === 'bottom' ? editor([editingArea([codable(), editable()]), toolbar(), statusbar()]) : editor([toolbar(), editingArea([codable(), editable()]), statusbar()])).render(); |
| 10188 |
$editor.insertAfter($note); |
| 10189 |
return { |
| 10190 |
note: $note, |
| 10191 |
editor: $editor, |
| 10192 |
toolbar: $editor.find('.note-toolbar'), |
| 10193 |
editingArea: $editor.find('.note-editing-area'), |
| 10194 |
editable: $editor.find('.note-editable'), |
| 10195 |
codable: $editor.find('.note-codable'), |
| 10196 |
statusbar: $editor.find('.note-statusbar') |
| 10197 |
}; |
| 10198 |
}, |
| 10199 |
removeLayout: function removeLayout($note, layoutInfo) { |
| 10200 |
$note.html(layoutInfo.editable.html()); |
| 10201 |
layoutInfo.editor.remove(); |
| 10202 |
$note.show(); |
| 10203 |
} |
| 10204 |
}; |
| 10205 |
}; |
| 10206 |
|
| 10207 |
/* harmony default export */ var bs3_ui = (ui_ui); |
| 10208 |
// EXTERNAL MODULE: ./src/js/base/settings.js + 37 modules |
| 10209 |
var settings = __webpack_require__(3); |
| 10210 |
|
| 10211 |
// EXTERNAL MODULE: ./src/styles/summernote-bs3.scss |
| 10212 |
var summernote_bs3 = __webpack_require__(4); |
| 10213 |
|
| 10214 |
// CONCATENATED MODULE: ./src/js/bs3/settings.js |
| 10215 |
|
| 10216 |
|
| 10217 |
|
| 10218 |
|
| 10219 |
external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote, { |
| 10220 |
ui_template: bs3_ui, |
| 10221 |
"interface": 'bs3' |
| 10222 |
}); |
| 10223 |
|
| 10224 |
/***/ }) |
| 10225 |
|
| 10226 |
/******/ }); |
| 10227 |
}); |
| 10228 |
//# sourceMappingURL=summernote.js.map |