@37signals/lexxy 0.9.5-beta → 0.9.6-beta.bc0
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/lexxy.esm.js +42 -11
- package/dist/lexxy_helpers.esm.js +15 -1
- package/package.json +1 -1
package/dist/lexxy.esm.js
CHANGED
|
@@ -18,14 +18,28 @@ import { marked } from 'marked';
|
|
|
18
18
|
import { $insertDataTransferForRichText } from '@lexical/clipboard';
|
|
19
19
|
import 'prismjs';
|
|
20
20
|
import 'prismjs/components/prism-clike';
|
|
21
|
+
import 'prismjs/components/prism-diff';
|
|
22
|
+
import 'prismjs/components/prism-javascript';
|
|
21
23
|
import 'prismjs/components/prism-markup';
|
|
24
|
+
import 'prismjs/components/prism-markdown';
|
|
25
|
+
import 'prismjs/components/prism-c';
|
|
26
|
+
import 'prismjs/components/prism-css';
|
|
27
|
+
import 'prismjs/components/prism-objectivec';
|
|
28
|
+
import 'prismjs/components/prism-sql';
|
|
29
|
+
import 'prismjs/components/prism-powershell';
|
|
30
|
+
import 'prismjs/components/prism-python';
|
|
31
|
+
import 'prismjs/components/prism-rust';
|
|
32
|
+
import 'prismjs/components/prism-swift';
|
|
33
|
+
import 'prismjs/components/prism-typescript';
|
|
34
|
+
import 'prismjs/components/prism-java';
|
|
35
|
+
import 'prismjs/components/prism-cpp';
|
|
22
36
|
import 'prismjs/components/prism-markup-templating';
|
|
23
37
|
import 'prismjs/components/prism-ruby';
|
|
24
38
|
import 'prismjs/components/prism-php';
|
|
25
39
|
import 'prismjs/components/prism-go';
|
|
26
40
|
import 'prismjs/components/prism-bash';
|
|
27
41
|
import 'prismjs/components/prism-json';
|
|
28
|
-
import 'prismjs/components/prism-
|
|
42
|
+
import 'prismjs/components/prism-kotlin';
|
|
29
43
|
|
|
30
44
|
const ALLOWED_HTML_ATTRIBUTES = [ "class", "contenteditable", "href", "src", "style", "title" ];
|
|
31
45
|
|
|
@@ -58,7 +72,7 @@ DOMPurify.addHook("uponSanitizeElement", (node, data) => {
|
|
|
58
72
|
}
|
|
59
73
|
});
|
|
60
74
|
|
|
61
|
-
function buildConfig(allowedElements) {
|
|
75
|
+
function buildConfig(allowedElements ) {
|
|
62
76
|
const tagAttributes = {};
|
|
63
77
|
|
|
64
78
|
for (const element of allowedElements) {
|
|
@@ -1158,15 +1172,12 @@ var Lexxy = {
|
|
|
1158
1172
|
}
|
|
1159
1173
|
};
|
|
1160
1174
|
|
|
1161
|
-
function
|
|
1162
|
-
|
|
1175
|
+
function setSanitizerConfig(allowedTags) {
|
|
1176
|
+
DOMPurify.clearConfig();
|
|
1177
|
+
DOMPurify.setConfig(buildConfig(allowedTags));
|
|
1163
1178
|
}
|
|
1164
1179
|
|
|
1165
|
-
|
|
1166
|
-
// Uses DOMPurify defaults to strip XSS vectors (scripts, event handlers)
|
|
1167
|
-
// while preserving the richer tag set that server-rendered attachment
|
|
1168
|
-
// content legitimately uses (e.g. <span>, <div>, <img>).
|
|
1169
|
-
function sanitizeAttachmentContent(html) {
|
|
1180
|
+
function sanitize(html) {
|
|
1170
1181
|
return DOMPurify.sanitize(html)
|
|
1171
1182
|
}
|
|
1172
1183
|
|
|
@@ -1262,7 +1273,7 @@ class CustomActionTextAttachmentNode extends DecoratorNode {
|
|
|
1262
1273
|
createDOM() {
|
|
1263
1274
|
const figure = createElement(this.tagName, { "content-type": this.contentType, "data-lexxy-decorator": true });
|
|
1264
1275
|
|
|
1265
|
-
figure.insertAdjacentHTML("beforeend",
|
|
1276
|
+
figure.insertAdjacentHTML("beforeend", sanitize(this.innerHtml));
|
|
1266
1277
|
|
|
1267
1278
|
const deleteButton = createElement("lexxy-node-delete-button");
|
|
1268
1279
|
figure.appendChild(deleteButton);
|
|
@@ -6350,6 +6361,11 @@ class EarlyEscapeCodeNode extends CodeNode {
|
|
|
6350
6361
|
insertNewAfter(selection, restoreSelection) {
|
|
6351
6362
|
if (!selection.isCollapsed()) return super.insertNewAfter(selection, restoreSelection)
|
|
6352
6363
|
|
|
6364
|
+
if (this.#isCursorAtStart(selection)) {
|
|
6365
|
+
this.insertBefore($createParagraphNode());
|
|
6366
|
+
return null
|
|
6367
|
+
}
|
|
6368
|
+
|
|
6353
6369
|
if (this.#isCursorOnEmptyLastLine(selection)) {
|
|
6354
6370
|
$trimTrailingBlankNodes(this);
|
|
6355
6371
|
|
|
@@ -6361,6 +6377,14 @@ class EarlyEscapeCodeNode extends CodeNode {
|
|
|
6361
6377
|
return super.insertNewAfter(selection, restoreSelection)
|
|
6362
6378
|
}
|
|
6363
6379
|
|
|
6380
|
+
#isCursorAtStart(selection) {
|
|
6381
|
+
const { anchor } = selection;
|
|
6382
|
+
if (!$isAtNodeStart(anchor)) return false
|
|
6383
|
+
|
|
6384
|
+
const anchorNode = anchor.getNode();
|
|
6385
|
+
return this.is(anchorNode) || this.getFirstChild()?.is(anchorNode)
|
|
6386
|
+
}
|
|
6387
|
+
|
|
6364
6388
|
#isCursorOnEmptyLastLine(selection) {
|
|
6365
6389
|
if (!$isCursorOnLastLine(selection)) return false
|
|
6366
6390
|
|
|
@@ -6698,7 +6722,7 @@ class LexicalEditorElement extends HTMLElement {
|
|
|
6698
6722
|
get value() {
|
|
6699
6723
|
if (!this.cachedValue) {
|
|
6700
6724
|
this.editor?.getEditorState().read(() => {
|
|
6701
|
-
this.cachedValue = sanitize($generateHtmlFromNodes(this.editor, null)
|
|
6725
|
+
this.cachedValue = sanitize($generateHtmlFromNodes(this.editor, null));
|
|
6702
6726
|
});
|
|
6703
6727
|
}
|
|
6704
6728
|
|
|
@@ -6757,6 +6781,7 @@ class LexicalEditorElement extends HTMLElement {
|
|
|
6757
6781
|
this.#registerFocusEvents();
|
|
6758
6782
|
this.#attachDebugHooks();
|
|
6759
6783
|
this.#attachToolbar();
|
|
6784
|
+
this.#configureSanitizer();
|
|
6760
6785
|
this.#loadInitialValue();
|
|
6761
6786
|
this.#resetBeforeTurboCaches();
|
|
6762
6787
|
}
|
|
@@ -7033,6 +7058,10 @@ class LexicalEditorElement extends HTMLElement {
|
|
|
7033
7058
|
}
|
|
7034
7059
|
}
|
|
7035
7060
|
|
|
7061
|
+
#configureSanitizer() {
|
|
7062
|
+
setSanitizerConfig(this.#allowedElements);
|
|
7063
|
+
}
|
|
7064
|
+
|
|
7036
7065
|
get #allowedElements() {
|
|
7037
7066
|
return this.#importableTags.concat(this.extensions.allowedElements)
|
|
7038
7067
|
}
|
|
@@ -8123,6 +8152,8 @@ class CodeLanguagePicker extends HTMLElement {
|
|
|
8123
8152
|
languages.bash ||= "Bash";
|
|
8124
8153
|
languages.json ||= "JSON";
|
|
8125
8154
|
languages.diff ||= "Diff";
|
|
8155
|
+
languages.kotlin ||= "Kotlin";
|
|
8156
|
+
|
|
8126
8157
|
|
|
8127
8158
|
// Place the "plain" entry first, then the rest of language sorted alphabetically
|
|
8128
8159
|
delete languages.plain;
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import Prism from 'prismjs';
|
|
2
2
|
import 'prismjs/components/prism-clike';
|
|
3
|
+
import 'prismjs/components/prism-diff';
|
|
4
|
+
import 'prismjs/components/prism-javascript';
|
|
3
5
|
import 'prismjs/components/prism-markup';
|
|
6
|
+
import 'prismjs/components/prism-markdown';
|
|
7
|
+
import 'prismjs/components/prism-c';
|
|
8
|
+
import 'prismjs/components/prism-css';
|
|
9
|
+
import 'prismjs/components/prism-objectivec';
|
|
10
|
+
import 'prismjs/components/prism-sql';
|
|
11
|
+
import 'prismjs/components/prism-powershell';
|
|
12
|
+
import 'prismjs/components/prism-python';
|
|
13
|
+
import 'prismjs/components/prism-rust';
|
|
14
|
+
import 'prismjs/components/prism-swift';
|
|
15
|
+
import 'prismjs/components/prism-typescript';
|
|
16
|
+
import 'prismjs/components/prism-java';
|
|
17
|
+
import 'prismjs/components/prism-cpp';
|
|
4
18
|
import 'prismjs/components/prism-markup-templating';
|
|
5
19
|
import 'prismjs/components/prism-ruby';
|
|
6
20
|
import 'prismjs/components/prism-php';
|
|
7
21
|
import 'prismjs/components/prism-go';
|
|
8
22
|
import 'prismjs/components/prism-bash';
|
|
9
23
|
import 'prismjs/components/prism-json';
|
|
10
|
-
import 'prismjs/components/prism-
|
|
24
|
+
import 'prismjs/components/prism-kotlin';
|
|
11
25
|
|
|
12
26
|
// Configure Prism for manual highlighting mode
|
|
13
27
|
// This must be set before importing prismjs
|