Socket
Socket
Sign inDemoInstall

summernote

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

summernote - npm Package Compare versions

Comparing version 0.6.10 to 0.6.11

lang/summernote-lt-LT.js

9

CONTRIBUTING.md
# Thanks for contributing to [Summernote](http://summernote.org)!
## [Create Issue](#issues) or [Create PR](#pull-requests)
# issues

@@ -10,5 +7,6 @@

- [ ] steps to reproduce
- [ ] browser version and os version
- [ ] [gif from www.recordit.co](www.recordit.co)
- [ ] screenshot of issue
- [ ] steps to reproduce.

@@ -23,3 +21,3 @@ # pull-requests

```markdown
#### What's this PR do?
#### What does this PR do?

@@ -44,2 +42,3 @@ - awesome stuff

#### Screenshots (if for frontend)

@@ -46,0 +45,0 @@

@@ -109,3 +109,8 @@ module.exports = function (grunt) {

port: 3000,
livereload: true,
livereload: {
options: {
open: true,
base: ['index.html']
}
},
middleware: function (connect, options, middlewares) {

@@ -152,2 +157,18 @@ var base = options.base[0];

browsers: [{
browserName: 'internet explorer',
version: '8.0',
platform: 'windows XP'
}, {
browserName: 'internet explorer',
version: '9.0',
platform: 'windows 7'
}, {
browserName: 'internet explorer',
version: '10.0',
platform: 'windows 8'
}, {
browserName: 'internet explorer',
version: '11.0',
platform: 'windows 8.1'
}, {
browserName: 'chrome',

@@ -154,0 +175,0 @@ version: '43',

{
"name": "summernote",
"description": "Super Simple WYSIWYG Editor on Bootstrap",
"version": "0.6.10",
"version": "0.6.11",
"keywords": [

@@ -6,0 +6,0 @@ "editor",

@@ -61,2 +61,43 @@ define(['jquery'], function ($) {

if (!Array.prototype.map) {
/**
* Array.prototype.map polyfill
*
* @param {Function} callback
* @return {Array}
*
* @see https://goo.gl/SMWaMK
*/
Array.prototype.map = function (callback, thisArg) {
var T, A, k;
if (this === null) {
throw new TypeError(' this is null or not defined');
}
var O = Object(this);
var len = O.length >>> 0;
if (typeof callback !== 'function') {
throw new TypeError(callback + ' is not a function');
}
if (arguments.length > 1) {
T = thisArg;
}
A = new Array(len);
k = 0;
while (k < len) {
var kValue, mappedValue;
if (k in O) {
kValue = O[k];
mappedValue = callback.call(T, kValue, k, O);
A[k] = mappedValue;
}
k++;
}
return A;
};
}
var isSupportAmd = typeof define === 'function' && define.amd;

@@ -88,2 +129,14 @@

var userAgent = navigator.userAgent;
var isMSIE = /MSIE|Trident/i.test(userAgent);
var browserVersion;
if (isMSIE) {
var matches = /MSIE (\d+[.]\d+)/.exec(userAgent);
if (matches) {
browserVersion = parseFloat(matches[1]);
}
matches = /Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.exec(userAgent);
if (matches) {
browserVersion = parseFloat(matches[1]);
}
}

@@ -102,3 +155,3 @@ /**

/** @property {Boolean} [isMSIE=false] true if this agent is a Internet Explorer */
isMSIE: /MSIE|Trident/i.test(userAgent),
isMSIE: isMSIE,
/** @property {Boolean} [isFF=false] true if this agent is a Firefox */

@@ -109,2 +162,4 @@ isFF: /firefox/i.test(userAgent),

isSafari: /safari/i.test(userAgent),
/** @property {Float} browserVersion current browser version */
browserVersion: browserVersion,
/** @property {String} jqueryVersion current jQuery version string */

@@ -111,0 +166,0 @@ jqueryVersion: parseFloat($.fn.jquery),

@@ -80,9 +80,9 @@ define([

} else {
makeFinder = function (sClassName, sBaseElement) {
var $baseElement = sBaseElement ? $(sBaseElement) : $editor;
return function () { return $baseElement.find(sClassName); };
makeFinder = function (className, $base) {
$base = $base || $editor;
return function () { return $base.find(className); };
};
var options = $editor.data('options');
var dialogHolder = (options && options.dialogsInBody) ? document.body : null;
var $dialogHolder = (options && options.dialogsInBody) ? $(document.body) : null;

@@ -99,3 +99,3 @@ return {

handle: makeFinder('.note-handle'),
dialog: makeFinder('.note-dialog', dialogHolder)
dialog: makeFinder('.note-dialog', $dialogHolder)
};

@@ -250,5 +250,6 @@ }

* blank HTML for cursor position
* - [workaround] for MSIE IE doesn't works with bogus br
* - [workaround] old IE only works with &nbsp;
* - [workaround] IE11 and other browser works with bogus br
*/
var blankHTML = agent.isMSIE ? '&nbsp;' : '<br>';
var blankHTML = agent.isMSIE && agent.browserVersion < 11 ? '&nbsp;' : '<br>';

@@ -767,3 +768,3 @@ /**

var ancestors = listAncestor(node, func.eq(ancestor));
return $.map(ancestors, position).reverse();
return ancestors.map(position).reverse();
};

@@ -770,0 +771,0 @@

@@ -41,2 +41,3 @@ define([

'U': 85,
'V': 86,
'Y': 89,

@@ -43,0 +44,0 @@ 'Z': 90,

@@ -72,6 +72,13 @@ define(['summernote/core/func'], function (func) {

/**
* returns index of item
*/
var indexOf = function (array, item) {
return $.inArray(item, array);
};
/**
* returns true if the value is present in the list.
*/
var contains = function (array, item) {
return $.inArray(item, array) !== -1;
return indexOf(array, item) !== -1;
};

@@ -161,3 +168,3 @@

var next = function (array, item) {
var idx = array.indexOf(item);
var idx = indexOf(array, item);
if (idx === -1) { return null; }

@@ -173,3 +180,3 @@

var prev = function (array, item) {
var idx = array.indexOf(item);
var idx = indexOf(array, item);
if (idx === -1) { return null; }

@@ -179,3 +186,2 @@

};

@@ -182,0 +188,0 @@ return { head: head, last: last, initial: initial, tail: tail,

@@ -519,10 +519,9 @@ define([

this.pasteHTML = function (markup) {
var self = this;
var contentsContainer = $('<div></div>').html(markup)[0];
var childNodes = list.from(contentsContainer.childNodes);
this.wrapBodyInlineWithPara().deleteContents();
var rng = this.wrapBodyInlineWithPara().deleteContents();
return $.map(childNodes.reverse(), function (childNode) {
return self.insertNode(childNode);
return childNodes.reverse().map(function (childNode) {
return rng.insertNode(childNode);
}).reverse();

@@ -529,0 +528,0 @@ };

@@ -124,2 +124,4 @@ define('summernote/defaults', function () {

dialogsInBody: false, // false will add dialogs into editor
codemirror: { // codemirror options

@@ -126,0 +128,0 @@ mode: 'text/html',

@@ -156,3 +156,3 @@ define([

// P to LI
paras = $.map(paras, function (para) {
paras = paras.map(function (para) {
return dom.isPurePara(para) ? dom.replace(para, 'LI') : para;

@@ -207,3 +207,3 @@ });

if (isEscapseToBody || !dom.isList(headList.parentNode)) {
paras = $.map(paras, function (para) {
paras = paras.map(function (para) {
return dom.replace(para, 'P');

@@ -210,0 +210,0 @@ });

@@ -74,5 +74,5 @@ define([

var pred = dom.makePredByNodeName(nodeName);
var nodes = $.map(rng.nodes(dom.isText, {
var nodes = rng.nodes(dom.isText, {
fullyContains: true
}), function (text) {
}).map(function (text) {
return dom.singleChildAncestor(text, pred) || dom.wrap(text, nodeName);

@@ -90,3 +90,3 @@ });

return $.map(nodes, function (node) {
return nodes.map(function (node) {
var siblings = dom.withClosestSiblings(node, pred);

@@ -93,0 +93,0 @@ var head = list.head(siblings);

@@ -474,4 +474,4 @@ define([

// [workaround] for old IE - IE8 don't have input events
// - TODO check IE version
// [workaround] IE doesn't have input events for contentEditable
// - see: https://goo.gl/4bfIvA
var changeEventName = agent.isMSIE ? 'DOMCharacterDataModified DOMSubtreeModified DOMNodeInserted' : 'input';

@@ -478,0 +478,0 @@ $editable.on(changeEventName, function () {

define([
'summernote/core/list',
'summernote/core/dom',
'summernote/core/key',
'summernote/core/agent'
], function (list, dom, agent) {
], function (list, dom, key, agent) {
var Clipboard = function (handler) {
var $paste;
this.attach = function (layoutInfo) {
if (window.clipboardData || agent.isFF) {

@@ -19,10 +18,8 @@ $paste = $('<div />').attr('contenteditable', true).css({

layoutInfo.editable().after($paste);
$paste.on('paste', hPasteClipboardImage);
$paste.on('paste', hPaste);
layoutInfo.editable().on('keydown', function (e) {
if (e.ctrlKey && e.keyCode === 86) { // CTRL+V
if (e.ctrlKey && e.keyCode === key.code.V) {
handler.invoke('saveRange', layoutInfo.editable());
if ($paste) {
$paste.focus();
}
$paste.focus();
}

@@ -32,14 +29,5 @@ });

layoutInfo.editable().on('paste', hPasteClipboardImage);
layoutInfo.editable().on('paste', hPaste);
};
var hPasteContent = function (handler, $paste, $editable) {
var pasteContent = $('<div />').html($paste.html());
handler.invoke('restoreRange', $editable);
handler.invoke('focus', $editable);
handler.invoke('pasteHTML', $editable, pasteContent.html());
$paste.empty();
};
/**

@@ -50,4 +38,3 @@ * paste clipboard image

*/
var hPasteClipboardImage = function (event) {
var hPaste = function (event) {
var clipboardData = event.originalEvent.clipboardData;

@@ -57,32 +44,22 @@ var layoutInfo = dom.makeLayoutInfo(event.currentTarget || event.target);

if (!clipboardData || !clipboardData.items || !clipboardData.items.length) {
var callbacks = $editable.data('callbacks');
// only can run if it has onImageUpload method
if (!callbacks.onImageUpload) {
hPasteContent(handler, $paste, $editable);
return;
if (clipboardData && clipboardData.items && clipboardData.items.length) {
// using clipboardData case
var item = list.head(clipboardData.items);
if (item.kind === 'file' && item.type.indexOf('image/') !== -1) {
handler.insertImages(layoutInfo, [item.getAsFile()]);
}
handler.invoke('editor.afterCommand', $editable);
} else if ($paste && $editable.data('callbacks').onImageUpload) {
// using dummy contenteditable: only can run if it has onImageUpload method
setTimeout(function () {
if (!$paste) {
return;
}
var imgNode = $paste[0].firstChild;
if (!imgNode) {
hPasteContent(handler, $paste, $editable);
return;
}
if (!dom.isImg(imgNode)) {
hPasteContent(handler, $paste, $editable);
} else {
var node = $paste[0].firstChild;
if (dom.isImg(node)) {
handler.invoke('restoreRange', $editable);
var datauri = imgNode.src;
var dataURI = node.src;
var data = atob(datauri.split(',')[1]);
var array = new Uint8Array(data.length);
for (var i = 0; i < data.length; i++) {
array[i] = data.charCodeAt(i);
var decodedData = atob(dataURI.split(',')[1]);
var array = new Uint8Array(decodedData.length);
for (var i = 0; i < decodedData.length; i++) {
array[i] = decodedData.charCodeAt(i);
}

@@ -94,19 +71,12 @@

handler.insertImages(layoutInfo, [blob]);
$paste.empty();
} else {
var pasteContent = $('<div />').html($paste.html());
handler.invoke('restoreRange', $editable);
handler.invoke('focus', $editable);
handler.invoke('pasteHTML', $editable, pasteContent.html());
$paste.empty();
}
}, 0);
return;
}
var item = list.head(clipboardData.items);
var isClipboardImage = item.kind === 'file' && item.type.indexOf('image/') !== -1;
if (isClipboardImage) {
handler.insertImages(layoutInfo, [item.getAsFile()]);
}
handler.invoke('editor.afterCommand', $editable);
};

@@ -113,0 +83,0 @@ };

@@ -114,4 +114,4 @@ define([

this.currentStyle = function (target) {
var rng = range.create().normalize();
return rng ? rng.isOnEditable() && style.current(rng, target) : false;
var rng = range.create();
return rng && rng.isOnEditable() ? style.current(rng.normalize(), target) : false;
};

@@ -118,0 +118,0 @@

@@ -20,11 +20,13 @@ define([

* @param {Node} placeholder
* @param {Boolean} isAirMode
* @return {Object}
* @return {Number} return.left
* @return {Number} return.top
* @param {Object} options
* @param {Boolean} options.isAirMode
* @return {Position}
*/
var posFromPlaceholder = function (placeholder, isAirMode) {
var posFromPlaceholder = function (placeholder, options) {
var isAirMode = options && options.isAirMode;
var isLeftTop = options && options.isLeftTop;
var $placeholder = $(placeholder);
var pos = isAirMode ? $placeholder.offset() : $placeholder.position();
var height = $placeholder.outerHeight(true); // include margin
var height = isLeftTop ? 0 : $placeholder.outerHeight(true); // include margin

@@ -75,3 +77,5 @@ // popover below placeholder.

}
showPopover($linkPopover, posFromPlaceholder(styleInfo.anchor, isAirMode));
showPopover($linkPopover, posFromPlaceholder(styleInfo.anchor, {
isAirMode: isAirMode
}));
} else {

@@ -83,3 +87,6 @@ $linkPopover.hide();

if (styleInfo.image) {
showPopover($imagePopover, posFromPlaceholder(styleInfo.image, isAirMode));
showPopover($imagePopover, posFromPlaceholder(styleInfo.image, {
isAirMode: isAirMode,
isLeftTop: true
}));
} else {

@@ -86,0 +93,0 @@ $imagePopover.hide();

define([
'summernote/core/agent',
'summernote/core/dom',
'summernote/core/func'
], function (agent, dom, func) {
'summernote/core/func',
'summernote/core/list'
], function (agent, dom, func, list) {
/**

@@ -38,3 +39,3 @@ * @class Renderer

'<button type="button"' +
' class="btn btn-default btn-sm btn-small' +
' class="btn btn-default btn-sm' +
((!dropdown && className) ? ' ' + className : '') +

@@ -181,3 +182,3 @@ (dropdown ? ' dropdown-toggle' : '') +

var items = options.fontNames.reduce(function (memo, v) {
if (!agent.isFontInstalled(v) && options.fontNamesIgnoreCheck.indexOf(v) === -1) {
if (!agent.isFontInstalled(v) && !list.contains(options.fontNamesIgnoreCheck, v)) {
return memo;

@@ -476,3 +477,3 @@ }

var content = '<div class="btn-group">' + fullButton + halfButton + quarterButton + '</div>' +
'<div class="btn-group">' + leftButton + rightButton + justifyButton + '</div>' +
'<div class="btn-group">' + leftButton + rightButton + justifyButton + '</div><br>' +
'<div class="btn-group">' + roundedButton + circleButton + thumbnailButton + noneButton + '</div>' +

@@ -644,3 +645,3 @@ '<div class="btn-group">' + removeButton + '</div>';

var body = '<div class="form-group row-fluid note-group-select-from-files">' +
var body = '<div class="form-group row note-group-select-from-files">' +
'<label>' + lang.image.selectFromFiles + '</label>' +

@@ -650,5 +651,5 @@ '<input class="note-image-input" type="file" name="files" accept="image/*" multiple="multiple" />' +

'</div>' +
'<div class="form-group row-fluid">' +
'<div class="form-group row">' +
'<label>' + lang.image.url + '</label>' +
'<input class="note-image-url form-control span12" type="text" />' +
'<input class="note-image-url form-control col-md-12" type="text" />' +
'</div>';

@@ -660,9 +661,9 @@ var footer = '<button href="#" class="btn btn-primary note-image-btn disabled" disabled>' + lang.image.insert + '</button>';

link: function (lang, options) {
var body = '<div class="form-group row-fluid">' +
var body = '<div class="form-group row">' +
'<label>' + lang.link.textToDisplay + '</label>' +
'<input class="note-link-text form-control span12" type="text" />' +
'<input class="note-link-text form-control col-md-12" type="text" />' +
'</div>' +
'<div class="form-group row-fluid">' +
'<div class="form-group row">' +
'<label>' + lang.link.url + '</label>' +
'<input class="note-link-url form-control span12" type="text" value="http://" />' +
'<input class="note-link-url form-control col-md-12" type="text" value="http://" />' +
'</div>' +

@@ -786,3 +787,3 @@ (!options.disableLinkTarget ?

$holder.addClass('note-air-editor note-editable');
$holder.addClass('note-air-editor note-editable panel-body');
$holder.attr({

@@ -829,3 +830,3 @@ 'id': 'note-editor-' + id,

//01. create Editor
var $editor = $('<div class="note-editor"></div>');
var $editor = $('<div class="note-editor panel panel-default" />');
if (options.width) {

@@ -840,6 +841,8 @@ $editor.width(options.width);

//03. create Editable
//03 editing area
var $editingArea = $('<div class="note-editing-area" />');
//03. create editable
var isContentEditable = !$holder.is(':disabled');
var $editable = $('<div class="note-editable" contentEditable="' + isContentEditable + '"></div>')
.prependTo($editor);
var $editable = $('<div class="note-editable panel-body" contentEditable="' + isContentEditable + '"></div>').prependTo($editingArea);
if (options.height) {

@@ -856,9 +859,19 @@ $editable.height(options.height);

$editable.html(dom.html($holder));
$editable.html(dom.html($holder) || dom.emptyPara);
//031. create codable
$('<textarea class="note-codable"></textarea>').prependTo($editor);
$('<textarea class="note-codable"></textarea>').prependTo($editingArea);
//04. create Toolbar
var $toolbar = $('<div class="note-toolbar btn-toolbar" />');
//04. create Popover
var $popover = $(tplPopovers(langInfo, options)).prependTo($editingArea);
createPalette($popover, options);
createTooltip($popover, keyMap);
//05. handle(control selection, ...)
$(tplHandles()).prependTo($editingArea);
$editingArea.prependTo($editor);
//06. create Toolbar
var $toolbar = $('<div class="note-toolbar panel-heading" />');
for (var idx = 0, len = options.toolbar.length; idx < len; idx ++) {

@@ -881,18 +894,12 @@ var groupName = options.toolbar[idx][0];

$toolbar.prependTo($editor);
var keyMap = options.keyMap[agent.isMac ? 'mac' : 'pc'];
createPalette($toolbar, options);
createTooltip($toolbar, keyMap, 'bottom');
$toolbar.prependTo($editor);
//05. create Popover
var $popover = $(tplPopovers(langInfo, options)).prependTo($editor);
createPalette($popover, options);
createTooltip($popover, keyMap);
//07. create Dropzone
$('<div class="note-dropzone"><div class="note-dropzone-message"></div></div>').prependTo($editor);
//06. handle(control selection, ...)
$(tplHandles()).prependTo($editor);
var $dialogContainer = options.dialogsInBody ? document.body : $editor;
//07. create Dialog
//08. create Dialog
var $dialogContainer = options.dialogsInBody ? $(document.body) : $editor;
var $dialog = $(tplDialogs(langInfo, options)).prependTo($dialogContainer);

@@ -903,5 +910,2 @@ $dialog.find('button.close, a.modal-close').click(function () {

//08. create Dropzone
$('<div class="note-dropzone"><div class="note-dropzone-message"></div></div>').prependTo($editor);
//09. Editor/Holder switch

@@ -908,0 +912,0 @@ $editor.insertAfter($holder);

@@ -23,2 +23,3 @@ /**

require([
'summernote/core/agent',
'../../test/unit/dom.spec',

@@ -28,12 +29,31 @@ '../../test/unit/list.spec',

'../../test/unit/style.spec'
], function (domSpec, listSpec, rangeSpec, styleSpec) {
], function (agent, domSpec, listSpec, rangeSpec, styleSpec) {
/* global QUnit */
QUnit.start();
var helper = {
equalsToUpperCase: function (actual, expected, comment) {
actual = actual.toUpperCase();
expected = expected.toUpperCase();
// [workaround] IE8-10 use &nbsp; instead of bogus br
if (agent.isMSIE && agent.browserVersion < 11) {
expected = expected.replace(/<BR>/g, '&NBSP;');
}
// [workaround] IE8 actual markup has newline between tags
if (agent.isMSIE && agent.browserVersion < 9) {
actual = actual.replace(/\r\n/g, '');
}
equal(actual, expected, comment);
}
};
module('unit/dom');
domSpec();
domSpec(helper);
module('unit/list');
listSpec();
listSpec(helper);
module('unit/range');
rangeSpec();
rangeSpec(helper);
module('unit/styleSpec');

@@ -40,0 +60,0 @@ styleSpec();

@@ -6,7 +6,11 @@ /**

*/
define(['jquery', 'summernote/core/dom', 'summernote/core/func'], function ($, dom, func) {
return function () {
define([
'jquery',
'summernote/core/dom',
'summernote/core/func'
], function ($, dom, func) {
return function (helper) {
test('dom.ancestor', function () {
var $cont, $b, txtB;
// basic case

@@ -173,6 +177,2 @@ $cont = $('<div class="note-editable"><b>b</b><u>u</u><s>s</s><i>i</i></div>'); //busi

var equalsToUpperCase = function (actual, expected, comment) {
equal(actual.toUpperCase(), expected.toUpperCase(), comment);
};
test('dom.splitTree', function () {

@@ -186,4 +186,4 @@ var $busi, $para, $cont, $b, $u, $s, $i, $span;

dom.splitTree($para[0], {node: $u[0], offset: 0 });
equalsToUpperCase($para.html(), '<b>b</b><u><br></u>', 'splitBy u tag with offset 0');
equalsToUpperCase($para.next().html(), '<u>u</u><s>strike</s><i>i</i>', 'right hand side');
helper.equalsToUpperCase($para.html(), '<b>b</b><u><br></u>', 'splitBy u tag with offset 0');
helper.equalsToUpperCase($para.next().html(), '<u>u</u><s>strike</s><i>i</i>', 'right hand side');

@@ -193,4 +193,4 @@ $para = $busi.clone().find('p');

dom.splitTree($para[0], {node: $u[0], offset: 1 });
equalsToUpperCase($para.html(), '<b>b</b><u>u</u>', 'splitBy u tag with offset 1');
equalsToUpperCase($para.next().html(), '<u><br></u><s>strike</s><i>i</i>', 'right hand side');
helper.equalsToUpperCase($para.html(), '<b>b</b><u>u</u>', 'splitBy u tag with offset 1');
helper.equalsToUpperCase($para.next().html(), '<u><br></u><s>strike</s><i>i</i>', 'right hand side');

@@ -200,4 +200,4 @@ $para = $busi.clone().find('p');

dom.splitTree($para[0], {node: $b[0], offset: 0 });
equalsToUpperCase($para.html(), '<b><br></b>', 'splitBy b tag with offset 0 (left edge case)');
equalsToUpperCase($para.next().html(), '<b>b</b><u>u</u><s>strike</s><i>i</i>', 'right hand side');
helper.equalsToUpperCase($para.html(), '<b><br></b>', 'splitBy b tag with offset 0 (left edge case)');
helper.equalsToUpperCase($para.next().html(), '<b>b</b><u>u</u><s>strike</s><i>i</i>', 'right hand side');

@@ -207,5 +207,5 @@ $para = $busi.clone().find('p');

dom.splitTree($para[0], {node: $i[0], offset: 1 });
equalsToUpperCase($para.html(),
helper.equalsToUpperCase($para.html(),
'<b>b</b><u>u</u><s>strike</s><i>i</i>', 'splitBy i tag with offset 1 (right edge case)');
equalsToUpperCase($para.next().html(), '<i><br></i>', 'right hand side');
helper.equalsToUpperCase($para.next().html(), '<i><br></i>', 'right hand side');

@@ -216,4 +216,4 @@ // 02. textNode case

dom.splitTree($para[0], {node: $s[0].firstChild, offset: 3 });
equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s>str</s>', 'splitBy s tag with offset 3 (middle case)');
equalsToUpperCase($para.next().html(), '<s>ike</s><i>i</i>', 'right hand side');
helper.equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s>str</s>', 'splitBy s tag with offset 3 (middle case)');
helper.equalsToUpperCase($para.next().html(), '<s>ike</s><i>i</i>', 'right hand side');

@@ -223,4 +223,4 @@ $para = $busi.clone().find('p');

dom.splitTree($para[0], {node: $s[0].firstChild, offset: 0 });
equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s><br></s>', 'splitBy s tag with offset 0 (left edge case)');
equalsToUpperCase($para.next().html(), '<s>strike</s><i>i</i>', 'right hand side');
helper.equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s><br></s>', 'splitBy s tag with offset 0 (left edge case)');
helper.equalsToUpperCase($para.next().html(), '<s>strike</s><i>i</i>', 'right hand side');

@@ -230,4 +230,4 @@ $para = $busi.clone().find('p');

dom.splitTree($para[0], {node: $s[0].firstChild, offset: 6});
equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s>strike</s>', 'splitBy s tag with offset 6 (right edge case)');
equalsToUpperCase($para.next().html(), '<s><br></s><i>i</i>', 'right hand side');
helper.equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s>strike</s>', 'splitBy s tag with offset 6 (right edge case)');
helper.equalsToUpperCase($para.next().html(), '<s><br></s><i>i</i>', 'right hand side');

@@ -237,3 +237,3 @@ $para = $busi.clone().find('p');

dom.splitTree($s[0], {node: $s[0].firstChild, offset: 3});
equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s>str</s><s>ike</s><i>i</i>',
helper.equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s>str</s><s>ike</s><i>i</i>',
'splitBy s tag with offset 3 (2 depth case)');

@@ -244,3 +244,3 @@

dom.splitTree($s[0].firstChild, {node: $s[0].firstChild, offset: 3});
equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s>strike</s><i>i</i>',
helper.equalsToUpperCase($para.html(), '<b>b</b><u>u</u><s>strike</s><i>i</i>',
'splitBy s tag with offset 3 (1 depth, textNode case)');

@@ -251,3 +251,3 @@

dom.splitTree($span[0], {node: $span[0], offset: 2});
equalsToUpperCase($cont.html(), '<p><span><b>b</b><u>u</u></span><span><s>s</s><i>i</i></span></p>',
helper.equalsToUpperCase($cont.html(), '<p><span><b>b</b><u>u</u></span><span><s>s</s><i>i</i></span></p>',
'splitBy span tag with offset 2 (1 depth, element case)');

@@ -254,0 +254,0 @@ });

@@ -8,11 +8,7 @@ /**

'jquery',
'summernote/core/agent',
'summernote/core/dom',
'summernote/core/range'
], function ($, dom, range) {
return function () {
var equalsToUpperCase = function (actual, expected, comment) {
ok(actual.toUpperCase() === expected.toUpperCase(), comment);
};
], function ($, agent, dom, range) {
return function (helper) {
test('rng.nodes', function () {

@@ -162,3 +158,7 @@ var rng, $cont, $para, $li, $h1, $h2, $b;

range.create($b[0].firstChild, 2, $b[0].firstChild, 2).insertNode($p2[0]);
equalsToUpperCase($cont.html(), '<p><b>bo</b></p><p>p</p><p><b>ld</b></p>', 'rng.insertNode with block should split paragraph.');
helper.equalsToUpperCase(
$cont.html(),
'<p><b>bo</b></p><p>p</p><p><b>ld</b></p>',
'rng.insertNode with block should split paragraph.'
);

@@ -171,3 +171,3 @@ $cont = $('<div class="note-editable"><p>text</p></div>');

range.create($p[0].firstChild, 2, $p[0].firstChild, 2).insertNode($u[0]);
equalsToUpperCase($cont.html(), '<p>te<u>u</u>xt</p>', 'rng.insertNode with inline should not split paragraph.');
helper.equalsToUpperCase($cont.html(), '<p>te<u>u</u>xt</p>', 'rng.insertNode with inline should not split paragraph.');

@@ -180,3 +180,3 @@ $cont = $('<div class="note-editable"><p><b>bold</b></p></div>');

range.create($b[0].firstChild, 2, $b[0].firstChild, 2).insertNode($u[0]);
equalsToUpperCase($cont.html(), '<p><b>bo</b><u>u</u><b>ld</b></p>', 'rng.insertNode with inline should not split paragraph.');
helper.equalsToUpperCase($cont.html(), '<p><b>bo</b><u>u</u><b>ld</b></p>', 'rng.insertNode with inline should not split paragraph.');
});

@@ -193,3 +193,7 @@

range.create($p[0].firstChild, 2).pasteHTML(markup);
equalsToUpperCase($cont.html(), '<p>te<span>span</span><i>italic</i>xt</p>', 'rng.pasteHTML with inlines should not split text.');
helper.equalsToUpperCase(
$cont.html(),
'<p>te<span>span</span><i>italic</i>xt</p>',
'rng.pasteHTML with inlines should not split text.'
);

@@ -203,3 +207,3 @@ // split inline node with inline nodes

range.create($b[0].firstChild, 2).pasteHTML(markup);
equalsToUpperCase(
helper.equalsToUpperCase(
$cont.html(),

@@ -217,3 +221,3 @@ '<p><b>bo</b><span>span</span><i>italic</i><b>ld</b></p>',

range.create($b[0].firstChild, 2).pasteHTML(markup);
equalsToUpperCase(
helper.equalsToUpperCase(
$cont.html(),

@@ -231,3 +235,3 @@ '<p><b>bo</b><span>span</span></p><p><i>italic</i></p><p><b>ld</b></p>',

range.create($b[0].firstChild, 2).pasteHTML(markup);
equalsToUpperCase(
helper.equalsToUpperCase(
$cont.html(),

@@ -249,3 +253,3 @@ '<p><b>bo</b><span>span</span></p><p><i>italic</i></p><p><b>ld</b></p>',

range.create($b[0].firstChild, 1, $b[0].firstChild, 3).deleteContents();
equalsToUpperCase($cont.html(), '<p><b>bd</b><u>u</u></p>', 'rng.deleteContents on partial text should remove only text');
helper.equalsToUpperCase($cont.html(), '<p><b>bd</b><u>u</u></p>', 'rng.deleteContents on partial text should remove only text');

@@ -259,3 +263,3 @@ // deleteContents on full text

range.create($b[0].firstChild, 0, $b[0].firstChild, 4).deleteContents();
equalsToUpperCase($cont.html(), '<p><b></b><u>u</u></p>', 'rng.deleteContents on full text should remove text');
helper.equalsToUpperCase($cont.html(), '<p><b></b><u>u</u></p>', 'rng.deleteContents on full text should remove text');

@@ -270,3 +274,3 @@ });

range.create($cont[0], 0).wrapBodyInlineWithPara();
equalsToUpperCase($cont.html(), '<p><br></p>', 'rng.wrapBodyInlineWithPara with blank should insert empty paragraph.');
helper.equalsToUpperCase($cont.html(), '<p><br></p>', 'rng.wrapBodyInlineWithPara with blank should insert empty paragraph.');

@@ -276,3 +280,3 @@ // body text case

range.create($cont[0].firstChild, 2).wrapBodyInlineWithPara();
equalsToUpperCase($cont.html(), '<p>text</p>', 'rng.wrapBodyInlineWithPara with body text should wrap text with paragraph.');
helper.equalsToUpperCase($cont.html(), '<p>text</p>', 'rng.wrapBodyInlineWithPara with body text should wrap text with paragraph.');

@@ -283,3 +287,7 @@ // body inline case 1

range.create($b[0].firstChild, 2).wrapBodyInlineWithPara();
equalsToUpperCase($cont.html(), '<p><b>bold</b></p>', 'rng.wrapBodyInlineWithPara with inline text should wrap text with paragraph.');
helper.equalsToUpperCase(
$cont.html(),
'<p><b>bold</b></p>',
'rng.wrapBodyInlineWithPara with inline text should wrap text with paragraph.'
);

@@ -289,3 +297,7 @@ // body inline case 2

range.create($cont[0], 0).wrapBodyInlineWithPara();
equalsToUpperCase($cont.html(), '<p><b>b</b><i>i</i></p>', 'rng.wrapBodyInlineWithPara with inline should wrap text with paragraph.');
helper.equalsToUpperCase(
$cont.html(),
'<p><b>b</b><i>i</i></p>',
'rng.wrapBodyInlineWithPara with inline should wrap text with paragraph.'
);

@@ -295,3 +307,7 @@ // body inline case 3

range.create($cont[0], 1).wrapBodyInlineWithPara();
equalsToUpperCase($cont.html(), '<p><b>b</b><i>i</i></p>', 'rng.wrapBodyInlineWithPara with inline should wrap text with paragraph.');
helper.equalsToUpperCase(
$cont.html(),
'<p><b>b</b><i>i</i></p>',
'rng.wrapBodyInlineWithPara with inline should wrap text with paragraph.'
);

@@ -301,3 +317,7 @@ // body inline case 4

range.create($cont[0], 2).wrapBodyInlineWithPara();
equalsToUpperCase($cont.html(), '<p><b>b</b><i>i</i></p>', 'rng.wrapBodyInlineWithPara with inline should wrap text with paragraph.');
helper.equalsToUpperCase(
$cont.html(),
'<p><b>b</b><i>i</i></p>',
'rng.wrapBodyInlineWithPara with inline should wrap text with paragraph.'
);
});

@@ -304,0 +324,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc