@37signals/lexxy 0.1.23-beta → 0.1.24-beta
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 +1 -1
- package/dist/lexxy.esm.js +32 -15
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ A modern rich text editor for Rails.
|
|
|
23
23
|
Add this line to your application's Gemfile:
|
|
24
24
|
|
|
25
25
|
```ruby
|
|
26
|
-
gem 'lexxy', '~> 0.1.
|
|
26
|
+
gem 'lexxy', '~> 0.1.23.beta' # Need to specify the version since it's a pre-release
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
And then execute:
|
package/dist/lexxy.esm.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import Prism from 'prismjs';
|
|
2
|
+
import 'prismjs/components/prism-clike';
|
|
3
|
+
import 'prismjs/components/prism-markup';
|
|
4
|
+
import 'prismjs/components/prism-markup-templating';
|
|
5
|
+
import 'prismjs/components/prism-ruby';
|
|
6
|
+
import 'prismjs/components/prism-php';
|
|
7
|
+
import 'prismjs/components/prism-go';
|
|
8
|
+
import 'prismjs/components/prism-bash';
|
|
9
|
+
import 'prismjs/components/prism-json';
|
|
10
|
+
import 'prismjs/components/prism-diff';
|
|
1
11
|
import DOMPurify from 'dompurify';
|
|
2
12
|
import { getStyleObjectFromCSS, getCSSFromStyleObject, $getSelectionStyleValueForProperty, $patchStyleText } from '@lexical/selection';
|
|
3
13
|
import { $isTextNode, TextNode, $isRangeSelection, $getSelection, DecoratorNode, $getNodeByKey, HISTORY_MERGE_TAG, FORMAT_TEXT_COMMAND, $createTextNode, UNDO_COMMAND, REDO_COMMAND, PASTE_COMMAND, COMMAND_PRIORITY_LOW, KEY_TAB_COMMAND, COMMAND_PRIORITY_NORMAL, OUTDENT_CONTENT_COMMAND, INDENT_CONTENT_COMMAND, $isNodeSelection, $getRoot, $isLineBreakNode, $isElementNode, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND, SELECTION_CHANGE_COMMAND, $createNodeSelection, $setSelection, $createParagraphNode, KEY_ENTER_COMMAND, COMMAND_PRIORITY_HIGH, $isParagraphNode, $insertNodes, $createLineBreakNode, CLEAR_HISTORY_COMMAND, $addUpdateTag, SKIP_DOM_SELECTION_TAG, createEditor, BLUR_COMMAND, FOCUS_COMMAND, KEY_SPACE_COMMAND } from 'lexical';
|
|
@@ -5,18 +15,17 @@ import { $isListNode, $isListItemNode, INSERT_UNORDERED_LIST_COMMAND, INSERT_ORD
|
|
|
5
15
|
import { $isQuoteNode, $isHeadingNode, $createQuoteNode, $createHeadingNode, QuoteNode, HeadingNode, registerRichText } from '@lexical/rich-text';
|
|
6
16
|
import { $isCodeNode, CodeNode, normalizeCodeLang, CodeHighlightNode, registerCodeHighlighting, CODE_LANGUAGE_FRIENDLY_NAME_MAP } from '@lexical/code';
|
|
7
17
|
import { $isLinkNode, $createAutoLinkNode, $toggleLink, $createLinkNode, LinkNode, AutoLinkNode } from '@lexical/link';
|
|
8
|
-
import 'prismjs/components/prism-ruby';
|
|
9
|
-
import 'prismjs/components/prism-php';
|
|
10
|
-
import 'prismjs/components/prism-go';
|
|
11
|
-
import 'prismjs/components/prism-bash';
|
|
12
|
-
import 'prismjs/components/prism-json';
|
|
13
|
-
import 'prismjs/components/prism-diff';
|
|
14
18
|
import { $generateNodesFromDOM, $generateHtmlFromNodes } from '@lexical/html';
|
|
15
19
|
import { registerMarkdownShortcuts, TRANSFORMERS } from '@lexical/markdown';
|
|
16
20
|
import { createEmptyHistoryState, registerHistory } from '@lexical/history';
|
|
17
21
|
import { DirectUpload } from '@rails/activestorage';
|
|
18
22
|
import { marked } from 'marked';
|
|
19
23
|
|
|
24
|
+
// Configure Prism for manual highlighting mode
|
|
25
|
+
// This must be set before importing prismjs
|
|
26
|
+
window.Prism = window.Prism || {};
|
|
27
|
+
window.Prism.manual = true;
|
|
28
|
+
|
|
20
29
|
const ALLOWED_HTML_TAGS = [ "a", "action-text-attachment", "b", "blockquote", "br", "code", "em",
|
|
21
30
|
"figcaption", "figure", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "li", "mark", "ol", "p", "pre", "q", "s", "strong", "ul" ];
|
|
22
31
|
|
|
@@ -878,6 +887,11 @@ class ActionTextAttachmentUploadNode extends ActionTextAttachmentNode {
|
|
|
878
887
|
return new ActionTextAttachmentUploadNode({ ...serializedNode })
|
|
879
888
|
}
|
|
880
889
|
|
|
890
|
+
// Should never run since this is a transient node. Defined to remove console warning.
|
|
891
|
+
static importDOM() {
|
|
892
|
+
return null
|
|
893
|
+
}
|
|
894
|
+
|
|
881
895
|
constructor({ file, uploadUrl, blobUrlTemplate, editor, progress }, key) {
|
|
882
896
|
super({ contentType: file.type }, key);
|
|
883
897
|
this.file = file;
|
|
@@ -3179,7 +3193,7 @@ class Clipboard {
|
|
|
3179
3193
|
|
|
3180
3194
|
if (!clipboardData) return false
|
|
3181
3195
|
|
|
3182
|
-
if (this.#
|
|
3196
|
+
if (this.#isPlainTextOrURLPasted(clipboardData) && !this.#isPastingIntoCodeBlock()) {
|
|
3183
3197
|
this.#pastePlainText(clipboardData);
|
|
3184
3198
|
event.preventDefault();
|
|
3185
3199
|
return true
|
|
@@ -3188,11 +3202,21 @@ class Clipboard {
|
|
|
3188
3202
|
this.#handlePastedFiles(clipboardData);
|
|
3189
3203
|
}
|
|
3190
3204
|
|
|
3205
|
+
#isPlainTextOrURLPasted(clipboardData) {
|
|
3206
|
+
return this.#isOnlyPlainTextPasted(clipboardData) || this.#isOnlyURLPasted(clipboardData)
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3191
3209
|
#isOnlyPlainTextPasted(clipboardData) {
|
|
3192
3210
|
const types = Array.from(clipboardData.types);
|
|
3193
3211
|
return types.length === 1 && types[0] === "text/plain"
|
|
3194
3212
|
}
|
|
3195
3213
|
|
|
3214
|
+
#isOnlyURLPasted(clipboardData) {
|
|
3215
|
+
// Safari URLs are copied as a text/plain + text/uri-list object
|
|
3216
|
+
const types = Array.from(clipboardData.types);
|
|
3217
|
+
return types.length === 2 && types.includes("text/uri-list") && types.includes("text/plain")
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3196
3220
|
#isPastingIntoCodeBlock() {
|
|
3197
3221
|
let result = false;
|
|
3198
3222
|
|
|
@@ -4738,24 +4762,17 @@ function highlightAll() {
|
|
|
4738
4762
|
|
|
4739
4763
|
function highlightElement(preElement) {
|
|
4740
4764
|
const language = preElement.getAttribute("data-language");
|
|
4741
|
-
|
|
4742
4765
|
let code = preElement.innerHTML.replace(/<br\s*\/?>/gi, "\n");
|
|
4743
4766
|
|
|
4744
|
-
const grammar = Prism.languages[language];
|
|
4767
|
+
const grammar = Prism.languages?.[language];
|
|
4745
4768
|
if (!grammar) return
|
|
4746
4769
|
|
|
4747
4770
|
// unescape HTML entities in the code block
|
|
4748
4771
|
code = new DOMParser().parseFromString(code, "text/html").body.textContent || "";
|
|
4749
4772
|
|
|
4750
4773
|
const highlightedHtml = Prism.highlight(code, grammar, language);
|
|
4751
|
-
|
|
4752
4774
|
const codeElement = createElement("code", { "data-language": language, innerHTML: highlightedHtml });
|
|
4753
4775
|
preElement.replaceWith(codeElement);
|
|
4754
4776
|
}
|
|
4755
4777
|
|
|
4756
|
-
// Manual highlighting mode to prevent invocation on every page. See https://prismjs.com/docs/prism
|
|
4757
|
-
// This must happen before importing any Prism components
|
|
4758
|
-
window.Prism = window.Prism || {};
|
|
4759
|
-
Prism.manual = true;
|
|
4760
|
-
|
|
4761
4778
|
export { highlightAll };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@37signals/lexxy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24-beta",
|
|
4
4
|
"description": "Lexxy - A modern rich text editor for Rails.",
|
|
5
5
|
"module": "dist/lexxy.esm.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@eslint/js": "^9.15.0",
|
|
16
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
17
|
+
"@rollup/plugin-inject": "^5.0.5",
|
|
16
18
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
17
19
|
"@rollup/plugin-terser": "^0.4.4",
|
|
18
20
|
"eslint": "^9.15.0",
|