lakelib 0.3.7 → 0.3.9
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.min.css +1 -1
- package/dist/lake.min.js +24 -24
- package/dist/lake.min.js.map +1 -1
- package/lib/lake.css +4 -4
- package/lib/lake.d.ts +22 -15
- package/lib/lake.js +154 -137
- package/lib/lake.js.map +1 -1
- package/package.json +7 -7
package/lib/lake.css
CHANGED
|
@@ -870,7 +870,7 @@ button.lake-primary-button.lake-button-hovered {
|
|
|
870
870
|
.lake-container ul {
|
|
871
871
|
list-style: none;
|
|
872
872
|
margin: 0;
|
|
873
|
-
margin-bottom:
|
|
873
|
+
margin-bottom: 8px;
|
|
874
874
|
padding: 0;
|
|
875
875
|
}
|
|
876
876
|
|
|
@@ -931,8 +931,8 @@ button.lake-primary-button.lake-button-hovered {
|
|
|
931
931
|
|
|
932
932
|
.lake-container ol li,
|
|
933
933
|
.lake-container ul li {
|
|
934
|
-
margin
|
|
935
|
-
padding
|
|
934
|
+
margin: 0 0 0 20px;
|
|
935
|
+
padding: 0 0 0 4px;
|
|
936
936
|
}
|
|
937
937
|
|
|
938
938
|
.lake-container ol li {
|
|
@@ -1218,7 +1218,7 @@ lake-box[name="hr"] .lake-box-focused .lake-hr {
|
|
|
1218
1218
|
border-top: 1px solid var(--lake-border-color);
|
|
1219
1219
|
}
|
|
1220
1220
|
|
|
1221
|
-
/*
|
|
1221
|
+
/* variables */
|
|
1222
1222
|
:root {
|
|
1223
1223
|
--lake-code-highlight-keyword: #af00db;
|
|
1224
1224
|
--lake-code-highlight-name: #444d56;
|
package/lib/lake.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { LocalizedString } from 'typesafe-i18n';
|
|
|
3
3
|
|
|
4
4
|
type KeyValue = Record<string, string>;
|
|
5
5
|
|
|
6
|
+
type ContentStyleValue = string | string[] | RegExp;
|
|
7
|
+
type ContentStyle = Record<string, ContentStyleValue>;
|
|
8
|
+
type ContentAttributeValue = string | string[] | RegExp | ContentStyle;
|
|
9
|
+
type ContentAttribute = Record<string, ContentAttributeValue>;
|
|
10
|
+
type ContentRules = Record<string, string | ContentAttribute>;
|
|
11
|
+
|
|
6
12
|
interface EventItem {
|
|
7
13
|
type: string;
|
|
8
14
|
listener: EventListener;
|
|
@@ -1013,7 +1019,7 @@ declare class Range$1 {
|
|
|
1013
1019
|
*/
|
|
1014
1020
|
get endOffset(): number;
|
|
1015
1021
|
/**
|
|
1016
|
-
* The deepest
|
|
1022
|
+
* The deepest node, or the lowest point in the document tree, that contains both boundary points of the range.
|
|
1017
1023
|
*/
|
|
1018
1024
|
get commonAncestor(): Nodes;
|
|
1019
1025
|
/**
|
|
@@ -1451,13 +1457,17 @@ declare class History {
|
|
|
1451
1457
|
*/
|
|
1452
1458
|
readonly list: Nodes[];
|
|
1453
1459
|
/**
|
|
1454
|
-
*
|
|
1460
|
+
* A number that always indicates the position at which new content is stored.
|
|
1455
1461
|
*/
|
|
1456
1462
|
index: number;
|
|
1457
1463
|
/**
|
|
1458
1464
|
* The maximum length of the history. Once this limit is reached, the earliest item in the list will be removed.
|
|
1459
1465
|
*/
|
|
1460
1466
|
limit: number;
|
|
1467
|
+
/**
|
|
1468
|
+
* A ContentRules object defining the HTML parsing rules used by HTMLParser.
|
|
1469
|
+
*/
|
|
1470
|
+
contentRules: ContentRules;
|
|
1461
1471
|
/**
|
|
1462
1472
|
* An EventEmitter object used to set up events.
|
|
1463
1473
|
*/
|
|
@@ -1674,24 +1684,15 @@ interface Config {
|
|
|
1674
1684
|
placeholder: string;
|
|
1675
1685
|
indentWithTab: boolean;
|
|
1676
1686
|
lang: string;
|
|
1687
|
+
contentRules: ContentRules;
|
|
1677
1688
|
minChangeSize: number;
|
|
1678
1689
|
historySize: number;
|
|
1679
1690
|
onMessage: OnMessage;
|
|
1680
1691
|
[name: string]: any;
|
|
1681
1692
|
}
|
|
1682
|
-
interface EditorConfig {
|
|
1693
|
+
interface EditorConfig extends Partial<Config> {
|
|
1683
1694
|
root: string | Node | Nodes;
|
|
1684
1695
|
toolbar?: Toolbar;
|
|
1685
|
-
value?: string;
|
|
1686
|
-
readonly?: boolean;
|
|
1687
|
-
spellcheck?: boolean;
|
|
1688
|
-
tabIndex?: number;
|
|
1689
|
-
placeholder?: string;
|
|
1690
|
-
indentWithTab?: boolean;
|
|
1691
|
-
lang?: string;
|
|
1692
|
-
minChangeSize?: number;
|
|
1693
|
-
onMessage?: OnMessage;
|
|
1694
|
-
[name: string]: any;
|
|
1695
1696
|
}
|
|
1696
1697
|
/**
|
|
1697
1698
|
* The Editor interface provides properties and methods for rendering and manipulating the editor.
|
|
@@ -1824,6 +1825,10 @@ declare class Editor {
|
|
|
1824
1825
|
* Binds events for history.
|
|
1825
1826
|
*/
|
|
1826
1827
|
private bindHistoryEvents;
|
|
1828
|
+
/**
|
|
1829
|
+
* Binds events for pointer.
|
|
1830
|
+
*/
|
|
1831
|
+
private bindPointerEvents;
|
|
1827
1832
|
/**
|
|
1828
1833
|
* Returns translation functions for the specified language.
|
|
1829
1834
|
*/
|
|
@@ -1993,6 +1998,8 @@ type SlashItem = SlashButtonItem | SlashUploadItem;
|
|
|
1993
1998
|
|
|
1994
1999
|
declare const icons: Map<string, string>;
|
|
1995
2000
|
|
|
2001
|
+
declare function getContentRules(): ContentRules;
|
|
2002
|
+
|
|
1996
2003
|
/**
|
|
1997
2004
|
* Returns a Nodes object representing a collection of the nodes.
|
|
1998
2005
|
* This function is similar to jQuery, but its implementation is very simple.
|
|
@@ -2024,7 +2031,7 @@ declare function getBox(boxNode: string | Node | Nodes): Box;
|
|
|
2024
2031
|
declare class HTMLParser {
|
|
2025
2032
|
private readonly rules;
|
|
2026
2033
|
private readonly source;
|
|
2027
|
-
constructor(content: string | Nodes, rules?:
|
|
2034
|
+
constructor(content: string | Nodes, rules?: ContentRules);
|
|
2028
2035
|
/**
|
|
2029
2036
|
* Parses the given HTML string and returns the body element from the result.
|
|
2030
2037
|
*/
|
|
@@ -2149,4 +2156,4 @@ declare class Dropdown {
|
|
|
2149
2156
|
unmount(): void;
|
|
2150
2157
|
}
|
|
2151
2158
|
|
|
2152
|
-
export { type ActiveItem, Box, type BoxComponent, type BoxValue, Button, type CommandItem, Dropdown, type DropdownItem, type DropdownMenuItem, Editor, Fragment, HTMLParser, type InitializePlugin, type KeyValue, type MentionItem, type NodePath, Nodes, Range$1 as Range, type SelectionState, type SlashButtonItem, type SlashItem, type SlashUploadItem, TextParser, Toolbar, type ToolbarButtonItem, type ToolbarDropdownItem, type ToolbarItem, type ToolbarUploadItem, type UnmountPlugin, addMark, deleteContents, getBox, icons, insertBlock, insertBookmark, insertBox, insertContents, query, removeBox, removeMark, setBlocks, splitBlock, splitMarks, template, toBookmark, toHex };
|
|
2159
|
+
export { type ActiveItem, Box, type BoxComponent, type BoxValue, Button, type CommandItem, type ContentRules, Dropdown, type DropdownItem, type DropdownMenuItem, Editor, Fragment, HTMLParser, type InitializePlugin, type KeyValue, type MentionItem, type NodePath, Nodes, Range$1 as Range, type SelectionState, type SlashButtonItem, type SlashItem, type SlashUploadItem, TextParser, Toolbar, type ToolbarButtonItem, type ToolbarDropdownItem, type ToolbarItem, type ToolbarUploadItem, type UnmountPlugin, addMark, deleteContents, getBox, getContentRules, icons, insertBlock, insertBookmark, insertBox, insertContents, query, removeBox, removeMark, setBlocks, splitBlock, splitMarks, template, toBookmark, toHex };
|
package/lib/lake.js
CHANGED
|
@@ -285,6 +285,112 @@ const icons = new Map([
|
|
|
285
285
|
['danger', danger],
|
|
286
286
|
]);
|
|
287
287
|
|
|
288
|
+
const blockAttributeRules = {
|
|
289
|
+
id: /^[\w-]+$/,
|
|
290
|
+
class: /^[\w\- ]+$/,
|
|
291
|
+
style: {
|
|
292
|
+
'text-align': ['left', 'center', 'right', 'justify', 'start', 'end'],
|
|
293
|
+
'margin-left': /^-?\d+px$/i,
|
|
294
|
+
'text-indent': /^-?\d+em$/i,
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
function getContentRules() {
|
|
298
|
+
return {
|
|
299
|
+
h1: Object.assign({}, blockAttributeRules),
|
|
300
|
+
h2: Object.assign({}, blockAttributeRules),
|
|
301
|
+
h3: Object.assign({}, blockAttributeRules),
|
|
302
|
+
h4: Object.assign({}, blockAttributeRules),
|
|
303
|
+
h5: Object.assign({}, blockAttributeRules),
|
|
304
|
+
h6: Object.assign({}, blockAttributeRules),
|
|
305
|
+
p: Object.assign({}, blockAttributeRules),
|
|
306
|
+
blockquote: Object.assign(Object.assign({}, blockAttributeRules), { type: ['info', 'tip', 'success', 'warning', 'error', 'danger'] }),
|
|
307
|
+
ul: Object.assign(Object.assign({}, blockAttributeRules), { type: 'checklist', indent: /^\d+$/ }),
|
|
308
|
+
ol: Object.assign(Object.assign({}, blockAttributeRules), { start: /^\d+$/, indent: /^\d+$/ }),
|
|
309
|
+
li: {
|
|
310
|
+
value: ['true', 'false'],
|
|
311
|
+
},
|
|
312
|
+
table: {
|
|
313
|
+
style: {
|
|
314
|
+
width: /^-?\d+(px|%)$/i,
|
|
315
|
+
height: /^-?\d+(px|%)$/i,
|
|
316
|
+
border: /^[^"]+$/,
|
|
317
|
+
'border-width': /^-?\d+px$/i,
|
|
318
|
+
'border-style': /^[\w-]+$/,
|
|
319
|
+
'border-color': /^[^"]+$/,
|
|
320
|
+
'background-color': /^[^"]+$/,
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
tr: {
|
|
324
|
+
style: {
|
|
325
|
+
height: /^-?\d+(px|%)$/i,
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
th: 'td',
|
|
329
|
+
td: {
|
|
330
|
+
colspan: /^\d+$/,
|
|
331
|
+
rowspan: /^\d+$/,
|
|
332
|
+
style: {
|
|
333
|
+
width: /^-?\d+(px|%)$/i,
|
|
334
|
+
height: /^-?\d+(px|%)$/i,
|
|
335
|
+
border: /^[^"]+$/,
|
|
336
|
+
'border-width': /^-?\d+px$/i,
|
|
337
|
+
'border-style': /^[\w-]+$/,
|
|
338
|
+
'border-color': /^[^"]+$/,
|
|
339
|
+
'background-color': /^[^"]+$/,
|
|
340
|
+
'text-align': ['left', 'center', 'right', 'justify'],
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
'lake-box': {
|
|
344
|
+
type: ['inline', 'block'],
|
|
345
|
+
name: /^[\w-]+$/,
|
|
346
|
+
value: /^[^"]+$/,
|
|
347
|
+
focus: ['start', 'center', 'end'],
|
|
348
|
+
},
|
|
349
|
+
br: {},
|
|
350
|
+
hr: {},
|
|
351
|
+
img: {
|
|
352
|
+
src: /^[^"]+$/,
|
|
353
|
+
width: /^-?\d+px$/i,
|
|
354
|
+
height: /^-?\d+px$/i,
|
|
355
|
+
'data-lake-value': /^[^"]+$/,
|
|
356
|
+
alt: /^[^"]+$/,
|
|
357
|
+
style: {
|
|
358
|
+
width: /^-?\d+px$/i,
|
|
359
|
+
height: /^-?\d+px$/i,
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
span: {
|
|
363
|
+
class: /^[\w\- ]+$/,
|
|
364
|
+
style: {
|
|
365
|
+
color: /^[^"]+$/,
|
|
366
|
+
'background-color': /^[^"]+$/,
|
|
367
|
+
'font-family': /^[^;]+$/,
|
|
368
|
+
'font-size': /^[^"]+$/,
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
b: 'strong',
|
|
372
|
+
strong: {},
|
|
373
|
+
em: 'i',
|
|
374
|
+
i: {},
|
|
375
|
+
u: {},
|
|
376
|
+
s: {},
|
|
377
|
+
sub: {},
|
|
378
|
+
sup: {},
|
|
379
|
+
code: {},
|
|
380
|
+
a: {
|
|
381
|
+
class: /^[\w\- ]+$/,
|
|
382
|
+
name: /^[\w-]+$/,
|
|
383
|
+
href: /^[^"]+$/,
|
|
384
|
+
target: /^[\w-]+$/,
|
|
385
|
+
rel: /^[^"]+$/,
|
|
386
|
+
download: /^[^"]+$/,
|
|
387
|
+
},
|
|
388
|
+
'lake-bookmark': {
|
|
389
|
+
type: ['anchor', 'focus'],
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
|
|
288
394
|
// Returns an array representing a list of the document's elements.
|
|
289
395
|
function toNodeList(content, valueType) {
|
|
290
396
|
const nodeList = [];
|
|
@@ -1543,7 +1649,7 @@ class Range {
|
|
|
1543
1649
|
return this.range.endOffset;
|
|
1544
1650
|
}
|
|
1545
1651
|
/**
|
|
1546
|
-
* The deepest
|
|
1652
|
+
* The deepest node, or the lowest point in the document tree, that contains both boundary points of the range.
|
|
1547
1653
|
*/
|
|
1548
1654
|
get commonAncestor() {
|
|
1549
1655
|
return new Nodes(this.range.commonAncestorContainer);
|
|
@@ -4843,112 +4949,6 @@ class Fragment {
|
|
|
4843
4949
|
}
|
|
4844
4950
|
}
|
|
4845
4951
|
|
|
4846
|
-
const blockAttributeRules = {
|
|
4847
|
-
id: /^[\w-]+$/,
|
|
4848
|
-
class: /^[\w\- ]+$/,
|
|
4849
|
-
style: {
|
|
4850
|
-
'text-align': ['left', 'center', 'right', 'justify', 'start', 'end'],
|
|
4851
|
-
'margin-left': /^-?\d+px$/i,
|
|
4852
|
-
'text-indent': /^-?\d+em$/i,
|
|
4853
|
-
},
|
|
4854
|
-
};
|
|
4855
|
-
function getElementRules() {
|
|
4856
|
-
return {
|
|
4857
|
-
h1: Object.assign({}, blockAttributeRules),
|
|
4858
|
-
h2: Object.assign({}, blockAttributeRules),
|
|
4859
|
-
h3: Object.assign({}, blockAttributeRules),
|
|
4860
|
-
h4: Object.assign({}, blockAttributeRules),
|
|
4861
|
-
h5: Object.assign({}, blockAttributeRules),
|
|
4862
|
-
h6: Object.assign({}, blockAttributeRules),
|
|
4863
|
-
p: Object.assign({}, blockAttributeRules),
|
|
4864
|
-
blockquote: Object.assign(Object.assign({}, blockAttributeRules), { type: ['info', 'tip', 'success', 'warning', 'error', 'danger'] }),
|
|
4865
|
-
ul: Object.assign(Object.assign({}, blockAttributeRules), { type: 'checklist', indent: /^\d+$/ }),
|
|
4866
|
-
ol: Object.assign(Object.assign({}, blockAttributeRules), { start: /^\d+$/, indent: /^\d+$/ }),
|
|
4867
|
-
li: {
|
|
4868
|
-
value: ['true', 'false'],
|
|
4869
|
-
},
|
|
4870
|
-
table: {
|
|
4871
|
-
style: {
|
|
4872
|
-
width: /^-?\d+(px|%)$/i,
|
|
4873
|
-
height: /^-?\d+(px|%)$/i,
|
|
4874
|
-
border: /^[^"]+$/,
|
|
4875
|
-
'border-width': /^-?\d+px$/i,
|
|
4876
|
-
'border-style': /^[\w-]+$/,
|
|
4877
|
-
'border-color': /^[^"]+$/,
|
|
4878
|
-
'background-color': /^[^"]+$/,
|
|
4879
|
-
},
|
|
4880
|
-
},
|
|
4881
|
-
tr: {
|
|
4882
|
-
style: {
|
|
4883
|
-
height: /^-?\d+(px|%)$/i,
|
|
4884
|
-
},
|
|
4885
|
-
},
|
|
4886
|
-
th: 'td',
|
|
4887
|
-
td: {
|
|
4888
|
-
colspan: /^\d+$/,
|
|
4889
|
-
rowspan: /^\d+$/,
|
|
4890
|
-
style: {
|
|
4891
|
-
width: /^-?\d+(px|%)$/i,
|
|
4892
|
-
height: /^-?\d+(px|%)$/i,
|
|
4893
|
-
border: /^[^"]+$/,
|
|
4894
|
-
'border-width': /^-?\d+px$/i,
|
|
4895
|
-
'border-style': /^[\w-]+$/,
|
|
4896
|
-
'border-color': /^[^"]+$/,
|
|
4897
|
-
'background-color': /^[^"]+$/,
|
|
4898
|
-
'text-align': ['left', 'center', 'right', 'justify'],
|
|
4899
|
-
},
|
|
4900
|
-
},
|
|
4901
|
-
'lake-box': {
|
|
4902
|
-
type: ['inline', 'block'],
|
|
4903
|
-
name: /^[\w-]+$/,
|
|
4904
|
-
value: /^[^"]+$/,
|
|
4905
|
-
focus: ['start', 'center', 'end'],
|
|
4906
|
-
},
|
|
4907
|
-
br: {},
|
|
4908
|
-
hr: {},
|
|
4909
|
-
img: {
|
|
4910
|
-
src: /^[^"]+$/,
|
|
4911
|
-
width: /^-?\d+px$/i,
|
|
4912
|
-
height: /^-?\d+px$/i,
|
|
4913
|
-
'data-lake-value': /^[^"]+$/,
|
|
4914
|
-
alt: /^[^"]+$/,
|
|
4915
|
-
style: {
|
|
4916
|
-
width: /^-?\d+px$/i,
|
|
4917
|
-
height: /^-?\d+px$/i,
|
|
4918
|
-
},
|
|
4919
|
-
},
|
|
4920
|
-
span: {
|
|
4921
|
-
class: /^[\w\- ]+$/,
|
|
4922
|
-
style: {
|
|
4923
|
-
color: /^[^"]+$/,
|
|
4924
|
-
'background-color': /^[^"]+$/,
|
|
4925
|
-
'font-family': /^[^;]+$/,
|
|
4926
|
-
'font-size': /^[^"]+$/,
|
|
4927
|
-
},
|
|
4928
|
-
},
|
|
4929
|
-
b: 'strong',
|
|
4930
|
-
strong: {},
|
|
4931
|
-
em: 'i',
|
|
4932
|
-
i: {},
|
|
4933
|
-
u: {},
|
|
4934
|
-
s: {},
|
|
4935
|
-
sub: {},
|
|
4936
|
-
sup: {},
|
|
4937
|
-
code: {},
|
|
4938
|
-
a: {
|
|
4939
|
-
class: /^[\w\- ]+$/,
|
|
4940
|
-
name: /^[\w-]+$/,
|
|
4941
|
-
href: /^[^"]+$/,
|
|
4942
|
-
target: /^[\w-]+$/,
|
|
4943
|
-
rel: /^[^"]+$/,
|
|
4944
|
-
download: /^[^"]+$/,
|
|
4945
|
-
},
|
|
4946
|
-
'lake-bookmark': {
|
|
4947
|
-
type: ['anchor', 'focus'],
|
|
4948
|
-
},
|
|
4949
|
-
};
|
|
4950
|
-
}
|
|
4951
|
-
|
|
4952
4952
|
// Converts a string from style property of element to a key-value object that contains a list of all styles properties.
|
|
4953
4953
|
function parseStyle(styleValue) {
|
|
4954
4954
|
styleValue = styleValue.replace(/"/gi, '"');
|
|
@@ -4967,7 +4967,7 @@ function parseStyle(styleValue) {
|
|
|
4967
4967
|
* The HTMLParser interface provides the ability to parse an HTML string according to specified rules.
|
|
4968
4968
|
*/
|
|
4969
4969
|
class HTMLParser {
|
|
4970
|
-
constructor(content, rules =
|
|
4970
|
+
constructor(content, rules = getContentRules()) {
|
|
4971
4971
|
this.rules = rules;
|
|
4972
4972
|
if (typeof content === 'string') {
|
|
4973
4973
|
this.source = this.parseHTML(content);
|
|
@@ -6273,7 +6273,7 @@ function removeBox(range) {
|
|
|
6273
6273
|
return box;
|
|
6274
6274
|
}
|
|
6275
6275
|
|
|
6276
|
-
var version = "0.3.
|
|
6276
|
+
var version = "0.3.9";
|
|
6277
6277
|
|
|
6278
6278
|
// Converts the custom HTML tags to the special tags that can not be parsed by browser.
|
|
6279
6279
|
function denormalizeValue(value) {
|
|
@@ -7212,13 +7212,17 @@ class History {
|
|
|
7212
7212
|
*/
|
|
7213
7213
|
this.list = [];
|
|
7214
7214
|
/**
|
|
7215
|
-
*
|
|
7215
|
+
* A number that always indicates the position at which new content is stored.
|
|
7216
7216
|
*/
|
|
7217
7217
|
this.index = 0;
|
|
7218
7218
|
/**
|
|
7219
7219
|
* The maximum length of the history. Once this limit is reached, the earliest item in the list will be removed.
|
|
7220
7220
|
*/
|
|
7221
7221
|
this.limit = 100;
|
|
7222
|
+
/**
|
|
7223
|
+
* A ContentRules object defining the HTML parsing rules used by HTMLParser.
|
|
7224
|
+
*/
|
|
7225
|
+
this.contentRules = getContentRules();
|
|
7222
7226
|
/**
|
|
7223
7227
|
* An EventEmitter object used to set up events.
|
|
7224
7228
|
*/
|
|
@@ -7232,7 +7236,7 @@ class History {
|
|
|
7232
7236
|
.replace(/<lake-bookmark\s+type="focus">\s*<\/lake-bookmark>/gi, '');
|
|
7233
7237
|
}
|
|
7234
7238
|
getValue(container) {
|
|
7235
|
-
return new HTMLParser(container).getHTML();
|
|
7239
|
+
return new HTMLParser(container, this.contentRules).getHTML();
|
|
7236
7240
|
}
|
|
7237
7241
|
addIdToBoxes(node) {
|
|
7238
7242
|
node.find('lake-box').each(nativeNode => {
|
|
@@ -7575,6 +7579,7 @@ const defaultConfig = {
|
|
|
7575
7579
|
placeholder: '',
|
|
7576
7580
|
indentWithTab: true,
|
|
7577
7581
|
lang: 'en-US',
|
|
7582
|
+
contentRules: getContentRules(),
|
|
7578
7583
|
minChangeSize: 5,
|
|
7579
7584
|
historySize: 100,
|
|
7580
7585
|
onMessage: (type, message) => {
|
|
@@ -7762,6 +7767,7 @@ class Editor {
|
|
|
7762
7767
|
this.command = new Command(this.selection);
|
|
7763
7768
|
this.history = new History(this.selection);
|
|
7764
7769
|
this.history.limit = this.config.historySize;
|
|
7770
|
+
this.history.contentRules = this.config.contentRules;
|
|
7765
7771
|
this.keystroke = new Keystroke(this.container);
|
|
7766
7772
|
editors.set(this.container.id, this);
|
|
7767
7773
|
}
|
|
@@ -7932,6 +7938,28 @@ class Editor {
|
|
|
7932
7938
|
}
|
|
7933
7939
|
});
|
|
7934
7940
|
}
|
|
7941
|
+
/**
|
|
7942
|
+
* Binds events for pointer.
|
|
7943
|
+
*/
|
|
7944
|
+
bindPointerEvents() {
|
|
7945
|
+
this.container.on('pointerdown', event => {
|
|
7946
|
+
const pointerEvent = event;
|
|
7947
|
+
if (pointerEvent.target !== null && pointerEvent.target !== this.container.get(0)) {
|
|
7948
|
+
return;
|
|
7949
|
+
}
|
|
7950
|
+
const lastChild = this.container.last();
|
|
7951
|
+
if (lastChild.isTable || lastChild.isBlockBox) {
|
|
7952
|
+
const lastChildRect = lastChild.get(0).getBoundingClientRect();
|
|
7953
|
+
if (pointerEvent.clientY > lastChildRect.bottom) {
|
|
7954
|
+
pointerEvent.preventDefault();
|
|
7955
|
+
const paragraph = query('<p><br /></p>');
|
|
7956
|
+
lastChild.after(paragraph);
|
|
7957
|
+
this.selection.range.shrinkBefore(paragraph);
|
|
7958
|
+
this.selection.sync();
|
|
7959
|
+
}
|
|
7960
|
+
}
|
|
7961
|
+
});
|
|
7962
|
+
}
|
|
7935
7963
|
/**
|
|
7936
7964
|
* Returns translation functions for the specified language.
|
|
7937
7965
|
*/
|
|
@@ -8104,7 +8132,7 @@ class Editor {
|
|
|
8104
8132
|
*/
|
|
8105
8133
|
setValue(value) {
|
|
8106
8134
|
value = normalizeValue(value);
|
|
8107
|
-
const htmlParser = new HTMLParser(value);
|
|
8135
|
+
const htmlParser = new HTMLParser(value, this.config.contentRules);
|
|
8108
8136
|
const fragment = htmlParser.getFragment();
|
|
8109
8137
|
this.container.empty();
|
|
8110
8138
|
this.togglePlaceholderClass(htmlParser.getHTML());
|
|
@@ -8117,7 +8145,7 @@ class Editor {
|
|
|
8117
8145
|
*/
|
|
8118
8146
|
getValue() {
|
|
8119
8147
|
const item = this.history.cloneContainer();
|
|
8120
|
-
let value = new HTMLParser(item).getHTML();
|
|
8148
|
+
let value = new HTMLParser(item, this.config.contentRules).getHTML();
|
|
8121
8149
|
value = denormalizeValue(value);
|
|
8122
8150
|
return value;
|
|
8123
8151
|
}
|
|
@@ -8126,7 +8154,7 @@ class Editor {
|
|
|
8126
8154
|
*/
|
|
8127
8155
|
render() {
|
|
8128
8156
|
const value = normalizeValue(this.config.value);
|
|
8129
|
-
const htmlParser = new HTMLParser(value);
|
|
8157
|
+
const htmlParser = new HTMLParser(value, this.config.contentRules);
|
|
8130
8158
|
const fragment = htmlParser.getFragment();
|
|
8131
8159
|
this.root.empty();
|
|
8132
8160
|
this.root.append(this.containerWrapper);
|
|
@@ -8155,6 +8183,7 @@ class Editor {
|
|
|
8155
8183
|
document.addEventListener('click', this.clickListener);
|
|
8156
8184
|
this.bindInputEvents();
|
|
8157
8185
|
this.bindHistoryEvents();
|
|
8186
|
+
this.bindPointerEvents();
|
|
8158
8187
|
}
|
|
8159
8188
|
}
|
|
8160
8189
|
/**
|
|
@@ -8292,13 +8321,14 @@ function changeTagName(element, newTagName) {
|
|
|
8292
8321
|
}
|
|
8293
8322
|
|
|
8294
8323
|
const blockSelector = Array.from(blockTagNames).join(',');
|
|
8295
|
-
function
|
|
8296
|
-
const rules = getElementRules();
|
|
8324
|
+
function changeContentRules(rules) {
|
|
8297
8325
|
rules.div = rules.p;
|
|
8298
8326
|
for (const key of Object.keys(rules)) {
|
|
8299
8327
|
const attributeRules = rules[key];
|
|
8300
|
-
|
|
8301
|
-
|
|
8328
|
+
if (typeof attributeRules !== 'string') {
|
|
8329
|
+
delete attributeRules.id;
|
|
8330
|
+
delete attributeRules.class;
|
|
8331
|
+
}
|
|
8302
8332
|
}
|
|
8303
8333
|
return rules;
|
|
8304
8334
|
}
|
|
@@ -8496,7 +8526,7 @@ var paste = (editor) => {
|
|
|
8496
8526
|
return;
|
|
8497
8527
|
}
|
|
8498
8528
|
const content = normalizeValue(dataTransfer.getData('text/html'));
|
|
8499
|
-
const rules =
|
|
8529
|
+
const rules = changeContentRules(editor.config.contentRules);
|
|
8500
8530
|
const htmlParser = new HTMLParser(content, rules);
|
|
8501
8531
|
const fragment = htmlParser.getFragment();
|
|
8502
8532
|
editor.event.emit('beforepaste', fragment);
|
|
@@ -11406,6 +11436,9 @@ function appendButtonGroup(box) {
|
|
|
11406
11436
|
const editor = box.getEditor();
|
|
11407
11437
|
const boxContainer = box.getContainer();
|
|
11408
11438
|
const rootNode = boxContainer.find('.lake-video');
|
|
11439
|
+
if (rootNode.find('.lake-corner-toolbar').length > 0) {
|
|
11440
|
+
return;
|
|
11441
|
+
}
|
|
11409
11442
|
new CornerToolbar({
|
|
11410
11443
|
locale: editor.locale,
|
|
11411
11444
|
root: rootNode,
|
|
@@ -11451,22 +11484,6 @@ function showVideo(box) {
|
|
|
11451
11484
|
if (!editor.readonly) {
|
|
11452
11485
|
iframeNode.on('load', () => {
|
|
11453
11486
|
appendButtonGroup(box);
|
|
11454
|
-
new CornerToolbar({
|
|
11455
|
-
locale: editor.locale,
|
|
11456
|
-
root: rootNode,
|
|
11457
|
-
items: [
|
|
11458
|
-
{
|
|
11459
|
-
name: 'remove',
|
|
11460
|
-
icon: icons.get('remove'),
|
|
11461
|
-
tooltip: editor.locale.video.remove(),
|
|
11462
|
-
onClick: event => {
|
|
11463
|
-
event.stopPropagation();
|
|
11464
|
-
editor.selection.removeBox(box);
|
|
11465
|
-
editor.history.save();
|
|
11466
|
-
},
|
|
11467
|
-
},
|
|
11468
|
-
],
|
|
11469
|
-
}).render();
|
|
11470
11487
|
new Resizer({
|
|
11471
11488
|
root: rootNode,
|
|
11472
11489
|
target: boxContainer,
|
|
@@ -11485,7 +11502,7 @@ function showVideo(box) {
|
|
|
11485
11502
|
}).render();
|
|
11486
11503
|
});
|
|
11487
11504
|
}
|
|
11488
|
-
rootNode.
|
|
11505
|
+
rootNode.prepend(iframeNode);
|
|
11489
11506
|
}
|
|
11490
11507
|
var videoBox = {
|
|
11491
11508
|
type: 'inline',
|
|
@@ -13765,5 +13782,5 @@ Editor.plugin.add('arrowKeys', arrowKeys);
|
|
|
13765
13782
|
Editor.plugin.add('escapeKey', escapeKey);
|
|
13766
13783
|
Editor.plugin.add('slash', slash);
|
|
13767
13784
|
|
|
13768
|
-
export { Box, Button, Dropdown, Editor, Fragment, HTMLParser, Nodes, Range, TextParser, Toolbar, addMark, deleteContents, getBox, icons, insertBlock, insertBookmark, insertBox, insertContents, query, removeBox, removeMark, setBlocks, splitBlock$1 as splitBlock, splitMarks, template, toBookmark, toHex };
|
|
13785
|
+
export { Box, Button, Dropdown, Editor, Fragment, HTMLParser, Nodes, Range, TextParser, Toolbar, addMark, deleteContents, getBox, getContentRules, icons, insertBlock, insertBookmark, insertBox, insertContents, query, removeBox, removeMark, setBlocks, splitBlock$1 as splitBlock, splitMarks, template, toBookmark, toHex };
|
|
13769
13786
|
//# sourceMappingURL=lake.js.map
|