lakelib 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lake.css +133 -137
- package/dist/lake.min.js +7 -7
- package/dist/lake.min.js.map +1 -1
- package/lib/lake.css +133 -137
- package/lib/lake.js +60 -53
- package/lib/lake.js.map +1 -1
- package/package.json +1 -1
package/lib/lake.js
CHANGED
|
@@ -3484,7 +3484,7 @@ class Dropdown {
|
|
|
3484
3484
|
</button>
|
|
3485
3485
|
</div>
|
|
3486
3486
|
`);
|
|
3487
|
-
this.menuNode = query('<ul class="lake-popup lake-dropdown-menu
|
|
3487
|
+
this.menuNode = query('<ul class="lake-popup lake-dropdown-menu" />');
|
|
3488
3488
|
if (config.tabIndex !== undefined) {
|
|
3489
3489
|
const titleNode = this.node.find('.lake-dropdown-title');
|
|
3490
3490
|
titleNode.attr('tabindex', config.tabIndex.toString());
|
|
@@ -3780,7 +3780,7 @@ class BoxToolbar {
|
|
|
3780
3780
|
this.items = config.items;
|
|
3781
3781
|
this.locale = config.locale || i18nObject('en-US');
|
|
3782
3782
|
this.placement = config.placement || 'top';
|
|
3783
|
-
this.container = query('<div class="lake-popup lake-box-toolbar
|
|
3783
|
+
this.container = query('<div class="lake-popup lake-box-toolbar" />');
|
|
3784
3784
|
}
|
|
3785
3785
|
appendDivider() {
|
|
3786
3786
|
this.container.append('<div class="lake-toolbar-divider" />');
|
|
@@ -5108,22 +5108,28 @@ function removePreviousOrNextZWS(node) {
|
|
|
5108
5108
|
nextNode.remove();
|
|
5109
5109
|
}
|
|
5110
5110
|
}
|
|
5111
|
-
// Returns
|
|
5112
|
-
function
|
|
5113
|
-
|
|
5114
|
-
|
|
5111
|
+
// Returns a nested mark copied from ancestors of the specified node.
|
|
5112
|
+
function getNestedMark$1(node) {
|
|
5113
|
+
let parent = node;
|
|
5114
|
+
if (parent.isText) {
|
|
5115
|
+
parent = parent.parent();
|
|
5115
5116
|
}
|
|
5116
|
-
let
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
const newChild = child.clone();
|
|
5121
|
-
newMark.append(newChild);
|
|
5122
|
-
newMark = newChild;
|
|
5117
|
+
let mark = null;
|
|
5118
|
+
while (parent.length > 0) {
|
|
5119
|
+
if (!parent.isMark) {
|
|
5120
|
+
break;
|
|
5123
5121
|
}
|
|
5124
|
-
|
|
5122
|
+
if (mark) {
|
|
5123
|
+
const newMark = parent.clone();
|
|
5124
|
+
newMark.append(mark);
|
|
5125
|
+
mark = newMark;
|
|
5126
|
+
}
|
|
5127
|
+
else {
|
|
5128
|
+
mark = parent.clone();
|
|
5129
|
+
}
|
|
5130
|
+
parent = parent.parent();
|
|
5125
5131
|
}
|
|
5126
|
-
return
|
|
5132
|
+
return mark;
|
|
5127
5133
|
}
|
|
5128
5134
|
// Returns the topmost mark element or the closest element with the same tag name as the specified node.
|
|
5129
5135
|
function getUpperMark(node, tagName) {
|
|
@@ -5171,23 +5177,26 @@ function addMark(range, value) {
|
|
|
5171
5177
|
removeBreak(block);
|
|
5172
5178
|
// https://en.wikipedia.org/wiki/Zero-width_space
|
|
5173
5179
|
const zeroWidthSpace = new Nodes(document.createTextNode('\u200B'));
|
|
5174
|
-
const
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
}
|
|
5182
|
-
else {
|
|
5183
|
-
const deepestMark = getDeepElement(newMark);
|
|
5184
|
-
deepestMark.append(zeroWidthSpace);
|
|
5185
|
-
valueNode.append(newMark);
|
|
5180
|
+
const newMark = getNestedMark$1(range.startNode);
|
|
5181
|
+
splitMarks(range);
|
|
5182
|
+
if (newMark) {
|
|
5183
|
+
let child = newMark;
|
|
5184
|
+
while (child.length > 0) {
|
|
5185
|
+
if (child.name === tagName) {
|
|
5186
|
+
child.css(cssProperties);
|
|
5186
5187
|
}
|
|
5188
|
+
child = child.first();
|
|
5189
|
+
}
|
|
5190
|
+
if (newMark.name === tagName) {
|
|
5191
|
+
valueNode = newMark;
|
|
5192
|
+
}
|
|
5193
|
+
else {
|
|
5194
|
+
valueNode.append(newMark);
|
|
5187
5195
|
}
|
|
5188
5196
|
}
|
|
5189
5197
|
if (valueNode.text() === '') {
|
|
5190
|
-
valueNode
|
|
5198
|
+
const deepestMark = getDeepElement(valueNode);
|
|
5199
|
+
deepestMark.append(zeroWidthSpace);
|
|
5191
5200
|
}
|
|
5192
5201
|
insertNode(range, valueNode);
|
|
5193
5202
|
removePreviousOrNextZWS(valueNode);
|
|
@@ -5227,30 +5236,32 @@ function removeEmptyMarks$1(node) {
|
|
|
5227
5236
|
}
|
|
5228
5237
|
}
|
|
5229
5238
|
}
|
|
5230
|
-
// Returns
|
|
5231
|
-
function
|
|
5239
|
+
// Returns a nested mark copied from each last child of the descendants of the specified node.
|
|
5240
|
+
function getNestedMark(node, tagName) {
|
|
5232
5241
|
if (!node.isMark || !tagName) {
|
|
5233
5242
|
return null;
|
|
5234
5243
|
}
|
|
5235
|
-
let
|
|
5236
|
-
let
|
|
5244
|
+
let mark = null;
|
|
5245
|
+
let deepestMark = null;
|
|
5246
|
+
let child = node;
|
|
5237
5247
|
while (child.length > 0) {
|
|
5238
|
-
if (child.isMark
|
|
5239
|
-
|
|
5240
|
-
newMark.append(newChild);
|
|
5241
|
-
newMark = newChild;
|
|
5242
|
-
}
|
|
5243
|
-
child = child.last();
|
|
5244
|
-
}
|
|
5245
|
-
if (newMark.name === tagName) {
|
|
5246
|
-
if (newMark.first().length > 0) {
|
|
5247
|
-
newMark = newMark.first();
|
|
5248
|
+
if (!child.isMark) {
|
|
5249
|
+
break;
|
|
5248
5250
|
}
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
+
if (child.name !== tagName) {
|
|
5252
|
+
if (deepestMark) {
|
|
5253
|
+
const newMark = child.clone();
|
|
5254
|
+
deepestMark.append(newMark);
|
|
5255
|
+
deepestMark = newMark;
|
|
5256
|
+
}
|
|
5257
|
+
else {
|
|
5258
|
+
mark = child.clone();
|
|
5259
|
+
deepestMark = mark;
|
|
5260
|
+
}
|
|
5251
5261
|
}
|
|
5262
|
+
child = child.last();
|
|
5252
5263
|
}
|
|
5253
|
-
return
|
|
5264
|
+
return mark;
|
|
5254
5265
|
}
|
|
5255
5266
|
// Removes the specified marks from the range.
|
|
5256
5267
|
function removeMark(range, value) {
|
|
@@ -5277,7 +5288,7 @@ function removeMark(range, value) {
|
|
|
5277
5288
|
removeEmptyMarks$1(parts.end);
|
|
5278
5289
|
}
|
|
5279
5290
|
const zeroWidthSpace = new Nodes(document.createTextNode('\u200B'));
|
|
5280
|
-
const newMark =
|
|
5291
|
+
const newMark = getNestedMark(parts.start, tagName);
|
|
5281
5292
|
if (!newMark) {
|
|
5282
5293
|
parts.start.after(zeroWidthSpace);
|
|
5283
5294
|
removeEmptyMarks$1(parts.start);
|
|
@@ -5441,7 +5452,7 @@ function removeBox(range) {
|
|
|
5441
5452
|
return box;
|
|
5442
5453
|
}
|
|
5443
5454
|
|
|
5444
|
-
var version = "0.2.
|
|
5455
|
+
var version = "0.2.4";
|
|
5445
5456
|
|
|
5446
5457
|
// Returns the attributes of the element as an key-value object.
|
|
5447
5458
|
function getAttributes(node) {
|
|
@@ -6189,7 +6200,6 @@ class Editor {
|
|
|
6189
6200
|
this.container = query('<div class="lake-container" />');
|
|
6190
6201
|
this.overlayContainer = query('<div class="lake-overlay" />');
|
|
6191
6202
|
this.readonly = this.config.readonly;
|
|
6192
|
-
this.root.addClass('lake-custom-properties');
|
|
6193
6203
|
this.container.attr({
|
|
6194
6204
|
contenteditable: this.readonly ? 'false' : 'true',
|
|
6195
6205
|
spellcheck: this.config.spellcheck ? 'true' : 'false',
|
|
@@ -6545,7 +6555,6 @@ class Editor {
|
|
|
6545
6555
|
this.event.removeAllListeners();
|
|
6546
6556
|
this.history.event.removeAllListeners();
|
|
6547
6557
|
this.root.off();
|
|
6548
|
-
this.root.removeClass('lake-custom-properties');
|
|
6549
6558
|
this.root.empty();
|
|
6550
6559
|
document.removeEventListener('copy', this.copyListener);
|
|
6551
6560
|
if (!this.readonly) {
|
|
@@ -7237,7 +7246,6 @@ class Toolbar {
|
|
|
7237
7246
|
this.placement = config.placement;
|
|
7238
7247
|
}
|
|
7239
7248
|
this.container = query('<div class="lake-toolbar" />');
|
|
7240
|
-
this.root.addClass('lake-custom-properties');
|
|
7241
7249
|
}
|
|
7242
7250
|
appendDivider() {
|
|
7243
7251
|
this.container.append('<div class="lake-toolbar-divider" />');
|
|
@@ -7426,7 +7434,6 @@ class Toolbar {
|
|
|
7426
7434
|
for (const dropdown of this.dropdownList) {
|
|
7427
7435
|
dropdown.unmount();
|
|
7428
7436
|
}
|
|
7429
|
-
this.root.removeClass('lake-custom-properties');
|
|
7430
7437
|
this.container.remove();
|
|
7431
7438
|
}
|
|
7432
7439
|
}
|
|
@@ -9447,7 +9454,7 @@ class LinkPopup {
|
|
|
9447
9454
|
this.config = config || {};
|
|
9448
9455
|
this.locale = this.config.locale || i18nObject('en-US');
|
|
9449
9456
|
this.container = query(safeTemplate `
|
|
9450
|
-
<div class="lake-popup lake-link-popup
|
|
9457
|
+
<div class="lake-popup lake-link-popup">
|
|
9451
9458
|
<div class="lake-row">${this.locale.link.url()}</div>
|
|
9452
9459
|
<div class="lake-row lake-url-row">
|
|
9453
9460
|
<input type="text" name="url" />
|
|
@@ -10026,7 +10033,7 @@ class Menu {
|
|
|
10026
10033
|
this.items = config.items;
|
|
10027
10034
|
this.onShow = config.onShow || emptyCallback$2;
|
|
10028
10035
|
this.onHide = config.onHide || emptyCallback$2;
|
|
10029
|
-
this.container = query('<ul class="lake-popup lake-menu
|
|
10036
|
+
this.container = query('<ul class="lake-popup lake-menu" />');
|
|
10030
10037
|
}
|
|
10031
10038
|
appendItemNode(itemNode) {
|
|
10032
10039
|
itemNode.on('mouseenter', () => {
|