lakelib 0.0.7 → 0.1.0
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/README.md +6 -75
- package/dist/lake.css +17 -11
- package/dist/lake.min.js +10 -10
- package/dist/lake.min.js.map +1 -1
- package/lib/lake.css +17 -11
- package/lib/lake.js +56 -24
- package/lib/lake.js.map +1 -1
- package/package.json +11 -10
package/lib/lake.css
CHANGED
|
@@ -33,12 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
.lake-container {
|
|
36
|
+
box-sizing: content-box;
|
|
36
37
|
font-family: var(--font-family);
|
|
37
38
|
font-size: 16px;
|
|
38
39
|
font-weight: normal;
|
|
39
40
|
line-height: normal;
|
|
40
|
-
color: var(--text-color);
|
|
41
|
-
background-color: #fff;
|
|
42
41
|
padding: 16px 24px;
|
|
43
42
|
}
|
|
44
43
|
.lake-container:focus {
|
|
@@ -379,8 +378,9 @@ button.lake-text-button span {
|
|
|
379
378
|
.lake-container h4,
|
|
380
379
|
.lake-container h5,
|
|
381
380
|
.lake-container h6 {
|
|
382
|
-
color: #000000e0;
|
|
383
381
|
font-weight: bold;
|
|
382
|
+
line-height: normal;
|
|
383
|
+
border: 0;
|
|
384
384
|
margin: 0;
|
|
385
385
|
padding: 0;
|
|
386
386
|
}
|
|
@@ -496,6 +496,7 @@ button.lake-text-button span {
|
|
|
496
496
|
padding-left: 24px;
|
|
497
497
|
}
|
|
498
498
|
.lake-container ul[type="checklist"] li::before {
|
|
499
|
+
box-sizing: content-box;
|
|
499
500
|
content: '';
|
|
500
501
|
position: absolute;
|
|
501
502
|
top: 3px;
|
|
@@ -513,6 +514,7 @@ button.lake-text-button span {
|
|
|
513
514
|
background-color: #fff;
|
|
514
515
|
}
|
|
515
516
|
.lake-container ul[type="checklist"] li::after {
|
|
517
|
+
box-sizing: content-box;
|
|
516
518
|
content: '';
|
|
517
519
|
position: absolute;
|
|
518
520
|
top: 3px;
|
|
@@ -534,6 +536,7 @@ button.lake-text-button span {
|
|
|
534
536
|
}
|
|
535
537
|
|
|
536
538
|
.lake-container blockquote {
|
|
539
|
+
box-sizing: content-box;
|
|
537
540
|
margin: 0;
|
|
538
541
|
margin-bottom: 8px;
|
|
539
542
|
padding: 8px 12px;
|
|
@@ -544,19 +547,21 @@ button.lake-text-button span {
|
|
|
544
547
|
color: var(--text-color);
|
|
545
548
|
border-radius: 8px;
|
|
546
549
|
}
|
|
550
|
+
.lake-container blockquote[type="info"],
|
|
551
|
+
.lake-container blockquote[type="tip"] {
|
|
552
|
+
background-color: #e6f4ff;
|
|
553
|
+
border: 1px solid #91caff;
|
|
554
|
+
}
|
|
547
555
|
.lake-container blockquote[type="success"] {
|
|
548
556
|
background-color: #f6ffed;
|
|
549
557
|
border: 1px solid #b7eb8f;
|
|
550
558
|
}
|
|
551
|
-
.lake-container blockquote[type="info"] {
|
|
552
|
-
background-color: #e6f4ff;
|
|
553
|
-
border: 1px solid #91caff;
|
|
554
|
-
}
|
|
555
559
|
.lake-container blockquote[type="warning"] {
|
|
556
560
|
background-color: #fffbe6;
|
|
557
561
|
border: 1px solid #ffe58f;
|
|
558
562
|
}
|
|
559
|
-
.lake-container blockquote[type="error"]
|
|
563
|
+
.lake-container blockquote[type="error"],
|
|
564
|
+
.lake-container blockquote[type="danger"] {
|
|
560
565
|
background-color: #fff2f0;
|
|
561
566
|
border: 1px solid #ffccc7;
|
|
562
567
|
}
|
|
@@ -658,11 +663,11 @@ lake-box[name="hr"] .lake-box-focused .lake-hr {
|
|
|
658
663
|
.lake-image {
|
|
659
664
|
position: relative;
|
|
660
665
|
line-height: 0;
|
|
666
|
+
box-sizing: content-box;
|
|
661
667
|
border: 1px solid transparent;
|
|
662
668
|
border-radius: 4px;
|
|
663
669
|
}
|
|
664
670
|
.lake-image .lake-image-img {
|
|
665
|
-
box-sizing: border-box;
|
|
666
671
|
border: 0;
|
|
667
672
|
border-radius: 4px;
|
|
668
673
|
width: 100%;
|
|
@@ -881,6 +886,8 @@ lake-box[name="codeBlock"] .lake-box-activated .lake-code-block .lake-dropdown {
|
|
|
881
886
|
}
|
|
882
887
|
.lake-code-block .lake-dropdown .lake-dropdown-menu {
|
|
883
888
|
top: 24px;
|
|
889
|
+
left: auto;
|
|
890
|
+
right: 0;
|
|
884
891
|
overflow-y: scroll;
|
|
885
892
|
scrollbar-width: thin;
|
|
886
893
|
height: 200px;
|
|
@@ -898,6 +905,7 @@ lake-box[name="codeBlock"] .lake-box-activated .lake-code-block .lake-dropdown {
|
|
|
898
905
|
top: 0;
|
|
899
906
|
left: 0;
|
|
900
907
|
z-index: 1;
|
|
908
|
+
box-sizing: content-box;
|
|
901
909
|
border: 1px solid var(--border-color);
|
|
902
910
|
border-radius: 5px;
|
|
903
911
|
padding: 16px;
|
|
@@ -940,8 +948,6 @@ lake-box[name="codeBlock"] .lake-box-activated .lake-code-block .lake-dropdown {
|
|
|
940
948
|
font-size: 14px;
|
|
941
949
|
font-weight: normal;
|
|
942
950
|
line-height: normal;
|
|
943
|
-
color: var(--text-color);
|
|
944
|
-
background-color: #fff;
|
|
945
951
|
padding: 4px;
|
|
946
952
|
display: flex;
|
|
947
953
|
flex-wrap: wrap;
|
package/lib/lake.js
CHANGED
|
@@ -11,11 +11,15 @@ import PhotoSwipe from 'photoswipe';
|
|
|
11
11
|
|
|
12
12
|
class BoxElement extends HTMLElement {
|
|
13
13
|
}
|
|
14
|
-
customElements.
|
|
14
|
+
if (customElements.get('lake-box') !== undefined) {
|
|
15
|
+
customElements.define('lake-box', BoxElement);
|
|
16
|
+
}
|
|
15
17
|
|
|
16
18
|
class BookmarkElement extends HTMLElement {
|
|
17
19
|
}
|
|
18
|
-
customElements.
|
|
20
|
+
if (customElements.get('lake-bookmark') !== undefined) {
|
|
21
|
+
customElements.define('lake-bookmark', BookmarkElement);
|
|
22
|
+
}
|
|
19
23
|
|
|
20
24
|
var plus = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" fill=\"#000000\" viewBox=\"0 0 256 256\"><path d=\"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm48-88a8,8,0,0,1-8,8H136v32a8,8,0,0,1-16,0V136H88a8,8,0,0,1,0-16h32V88a8,8,0,0,1,16,0v32h32A8,8,0,0,1,176,128Z\"></path></svg>";
|
|
21
25
|
|
|
@@ -2995,7 +2999,7 @@ function getElementRules() {
|
|
|
2995
2999
|
h5: Object.assign({}, blockAttributeRules),
|
|
2996
3000
|
h6: Object.assign({}, blockAttributeRules),
|
|
2997
3001
|
p: Object.assign({}, blockAttributeRules),
|
|
2998
|
-
blockquote: Object.assign(Object.assign({}, blockAttributeRules), { type: ['
|
|
3002
|
+
blockquote: Object.assign(Object.assign({}, blockAttributeRules), { type: ['info', 'tip', 'success', 'warning', 'error', 'danger'] }),
|
|
2999
3003
|
ul: Object.assign(Object.assign({}, blockAttributeRules), { type: 'checklist', indent: /^\d+$/ }),
|
|
3000
3004
|
ol: Object.assign(Object.assign({}, blockAttributeRules), { start: /^\d+$/, indent: /^\d+$/ }),
|
|
3001
3005
|
li: {
|
|
@@ -4295,7 +4299,7 @@ class Dropdown {
|
|
|
4295
4299
|
}
|
|
4296
4300
|
}
|
|
4297
4301
|
|
|
4298
|
-
var version = "0.0
|
|
4302
|
+
var version = "0.1.0";
|
|
4299
4303
|
|
|
4300
4304
|
// Inserts a box into the specified range.
|
|
4301
4305
|
function insertBox(range, boxName, boxValue) {
|
|
@@ -5261,7 +5265,6 @@ class Editor {
|
|
|
5261
5265
|
this.container.append(fragment);
|
|
5262
5266
|
if (!this.readonly) {
|
|
5263
5267
|
this.bindFocusEvents();
|
|
5264
|
-
this.focus();
|
|
5265
5268
|
this.selection.synByBookmark();
|
|
5266
5269
|
this.history.save();
|
|
5267
5270
|
Editor.plugin.loadAll(this);
|
|
@@ -5273,11 +5276,11 @@ class Editor {
|
|
|
5273
5276
|
if (!this.readonly) {
|
|
5274
5277
|
window.addEventListener('beforeunload', this.beforeunloadListener);
|
|
5275
5278
|
document.addEventListener('selectionchange', this.selectionchangeListener);
|
|
5279
|
+
document.addEventListener('click', this.clickListener);
|
|
5280
|
+
window.addEventListener('resize', this.resizeListener);
|
|
5276
5281
|
this.bindInputEvents();
|
|
5277
5282
|
this.bindHistoryEvents();
|
|
5278
5283
|
}
|
|
5279
|
-
document.addEventListener('click', this.clickListener);
|
|
5280
|
-
window.addEventListener('resize', this.resizeListener);
|
|
5281
5284
|
}
|
|
5282
5285
|
// Destroys a rendered editor.
|
|
5283
5286
|
unmount() {
|
|
@@ -5286,9 +5289,9 @@ class Editor {
|
|
|
5286
5289
|
if (!this.readonly) {
|
|
5287
5290
|
window.removeEventListener('beforeunload', this.beforeunloadListener);
|
|
5288
5291
|
document.removeEventListener('selectionchange', this.selectionchangeListener);
|
|
5292
|
+
document.removeEventListener('click', this.clickListener);
|
|
5293
|
+
window.removeEventListener('resize', this.resizeListener);
|
|
5289
5294
|
}
|
|
5290
|
-
document.removeEventListener('click', this.clickListener);
|
|
5291
|
-
window.removeEventListener('resize', this.resizeListener);
|
|
5292
5295
|
}
|
|
5293
5296
|
}
|
|
5294
5297
|
Editor.version = version;
|
|
@@ -6955,10 +6958,15 @@ const imageBox = {
|
|
|
6955
6958
|
container.empty();
|
|
6956
6959
|
container.append(imageNode);
|
|
6957
6960
|
imageNode.find('.lake-button-view').on('click', () => openFullScreen(box));
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6961
|
+
if (editor.readonly) {
|
|
6962
|
+
imageNode.find('.lake-button-remove').hide();
|
|
6963
|
+
}
|
|
6964
|
+
else {
|
|
6965
|
+
imageNode.find('.lake-button-remove').on('click', event => {
|
|
6966
|
+
event.stopPropagation();
|
|
6967
|
+
removeImageBox(box);
|
|
6968
|
+
});
|
|
6969
|
+
}
|
|
6962
6970
|
box.event.emit('render');
|
|
6963
6971
|
});
|
|
6964
6972
|
imageNode.on('click', () => {
|
|
@@ -7460,11 +7468,24 @@ var heading = (editor) => {
|
|
|
7460
7468
|
});
|
|
7461
7469
|
};
|
|
7462
7470
|
|
|
7471
|
+
const typeList = [
|
|
7472
|
+
'info',
|
|
7473
|
+
'tip',
|
|
7474
|
+
'success',
|
|
7475
|
+
'warning',
|
|
7476
|
+
'error',
|
|
7477
|
+
'danger',
|
|
7478
|
+
];
|
|
7463
7479
|
var blockQuote = (editor) => {
|
|
7464
7480
|
editor.command.add('blockQuote', {
|
|
7465
7481
|
isSelected: appliedItems => !!appliedItems.find(item => item.name === 'blockquote'),
|
|
7466
|
-
execute: () => {
|
|
7467
|
-
|
|
7482
|
+
execute: (type) => {
|
|
7483
|
+
if (type && typeList.indexOf(type) >= 0) {
|
|
7484
|
+
editor.selection.setBlocks(safeTemplate `<blockquote type="${type}" />`);
|
|
7485
|
+
}
|
|
7486
|
+
else {
|
|
7487
|
+
editor.selection.setBlocks('<blockquote />');
|
|
7488
|
+
}
|
|
7468
7489
|
editor.history.save();
|
|
7469
7490
|
},
|
|
7470
7491
|
});
|
|
@@ -7829,9 +7850,9 @@ var removeFormat = (editor) => {
|
|
|
7829
7850
|
});
|
|
7830
7851
|
};
|
|
7831
7852
|
|
|
7832
|
-
let markList = [];
|
|
7833
7853
|
const formatPainterClassName = 'lake-format-painter';
|
|
7834
7854
|
var formatPainter = (editor) => {
|
|
7855
|
+
let markList = [];
|
|
7835
7856
|
editor.command.add('formatPainter', {
|
|
7836
7857
|
execute: () => {
|
|
7837
7858
|
editor.container.addClass(formatPainterClassName);
|
|
@@ -7856,7 +7877,7 @@ var formatPainter = (editor) => {
|
|
|
7856
7877
|
editor.history.save();
|
|
7857
7878
|
});
|
|
7858
7879
|
editor.event.on('click', (tagetNode) => {
|
|
7859
|
-
if (tagetNode.isInside) {
|
|
7880
|
+
if (tagetNode.isInside && tagetNode.closestContainer().get(0) === editor.container.get(0)) {
|
|
7860
7881
|
return;
|
|
7861
7882
|
}
|
|
7862
7883
|
const buttonNode = tagetNode.closest('button[name="formatPainter"]');
|
|
@@ -8126,17 +8147,13 @@ var link = (editor) => {
|
|
|
8126
8147
|
return;
|
|
8127
8148
|
}
|
|
8128
8149
|
if (linkNode.isOutside ||
|
|
8150
|
+
linkNode.closestContainer().get(0) !== editor.container.get(0) ||
|
|
8129
8151
|
linkNode.closest('lake-box').length > 0) {
|
|
8152
|
+
popup.hide();
|
|
8130
8153
|
return;
|
|
8131
8154
|
}
|
|
8132
8155
|
popup.show(linkNode);
|
|
8133
8156
|
});
|
|
8134
|
-
editor.container.on('click', event => {
|
|
8135
|
-
const targetNode = new Nodes(event.target);
|
|
8136
|
-
if (targetNode.closest('a').length > 0) {
|
|
8137
|
-
event.preventDefault();
|
|
8138
|
-
}
|
|
8139
|
-
});
|
|
8140
8157
|
editor.command.add('link', {
|
|
8141
8158
|
execute: () => {
|
|
8142
8159
|
const linkNode = editor.selection.insertLink(`<a href="">${locale.link.newLink()}</a>`);
|
|
@@ -8310,7 +8327,22 @@ const blockItemListForSpaceKey = [
|
|
|
8310
8327
|
];
|
|
8311
8328
|
const blockItemListForEnterKey = [
|
|
8312
8329
|
{
|
|
8313
|
-
re:
|
|
8330
|
+
re: /^:{3,}([a-z]*)$/i,
|
|
8331
|
+
getParameters: (results) => {
|
|
8332
|
+
if (!results[1]) {
|
|
8333
|
+
return [
|
|
8334
|
+
'blockQuote',
|
|
8335
|
+
'info',
|
|
8336
|
+
];
|
|
8337
|
+
}
|
|
8338
|
+
return [
|
|
8339
|
+
'blockQuote',
|
|
8340
|
+
results[1],
|
|
8341
|
+
];
|
|
8342
|
+
},
|
|
8343
|
+
},
|
|
8344
|
+
{
|
|
8345
|
+
re: /^-{3,}$/,
|
|
8314
8346
|
getParameters: () => [
|
|
8315
8347
|
'hr',
|
|
8316
8348
|
],
|