@37signals/lexxy 0.9.15-alpha.2 → 0.9.15-alpha.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/lexxy.esm.js +19 -5
- package/dist/lexxy_helpers.esm.js +7 -3
- package/package.json +1 -1
package/dist/lexxy.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { highlightCode } from './lexxy_helpers.esm.js';
|
|
1
|
+
export { highlightCode, highlightElement } from './lexxy_helpers.esm.js';
|
|
2
2
|
import DOMPurify from 'dompurify';
|
|
3
3
|
import { getStyleObjectFromCSS, getCSSFromStyleObject, $getSelectionStyleValueForProperty, $ensureForwardRangeSelection, $isAtNodeEnd, $patchStyleText, $setBlocksType, $forEachSelectedTextNode } from '@lexical/selection';
|
|
4
4
|
import { SKIP_DOM_SELECTION_TAG, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW, CAN_REDO_COMMAND, $getSelection, $isRangeSelection, DecoratorNode, $createTextNode, $getRoot, $caretFromPoint, $setSelectionFromCaretRange, $getCaretRange, $normalizeCaret, $getChildCaret, $getCaretInDirection, $isParagraphNode, $isLineBreakNode, $createParagraphNode, $isElementNode, $isRootOrShadowRoot, $isRootNode, $createNodeSelection, $isDecoratorNode, $isTextNode, $getSiblingCaret, $rewindSiblingCaret, $splitAtPointCaretNext, $isChildCaret, $isTextPointCaret, $isExtendableTextPointCaret, $isSiblingCaret, $getCommonAncestor, $findMatchingParent, TextNode, createCommand, defineExtension, COMMAND_PRIORITY_EDITOR, $getEditor, $getNodeByKey, HISTORY_MERGE_TAG, SKIP_SCROLL_INTO_VIEW_TAG, $cloneWithProperties, $getNearestRootOrShadowRoot, $createRangeSelection, $setSelection, createState, COMMAND_PRIORITY_NORMAL, $getState, $setState, $hasUpdateTag, PASTE_TAG, FORMAT_TEXT_COMMAND, UNDO_COMMAND, REDO_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_TAB_COMMAND, OUTDENT_CONTENT_COMMAND, INDENT_CONTENT_COMMAND, $isNodeSelection, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ARROW_DOWN_COMMAND, DELETE_CHARACTER_COMMAND, SELECTION_CHANGE_COMMAND, CLICK_COMMAND, isDOMNode, $getNearestNodeFromDOMNode, $addUpdateTag, ElementNode, $splitNode, $getChildCaretAtIndex, $createLineBreakNode, PASTE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, ParagraphNode, RootNode, COMMAND_PRIORITY_HIGH, DRAGSTART_COMMAND, DROP_COMMAND, INSERT_PARAGRAPH_COMMAND, mergeRegister as mergeRegister$1, CLEAR_HISTORY_COMMAND, $onUpdate, KEY_ENTER_COMMAND, COMMAND_PRIORITY_CRITICAL, KEY_SPACE_COMMAND, INPUT_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DOWN_COMMAND } from 'lexical';
|
|
5
5
|
import { LinkNode, $createAutoLinkNode, $toggleLink, $createLinkNode, $isLinkNode, AutoLinkNode } from '@lexical/link';
|
|
6
6
|
import { buildEditorFromExtensions } from '@lexical/extension';
|
|
7
7
|
import { ListNode, ListItemNode, $getListDepth, INSERT_UNORDERED_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, $isListItemNode, $isListNode, registerList } from '@lexical/list';
|
|
8
|
-
import { $getNearestNodeOfType, $wrapNodeInElement, $lastToFirstIterator, $descendantsMatching, mergeRegister, $insertFirst, $unwrapAndFilterDescendants, $firstToLastIterator, $getNearestBlockElementAncestorOrThrow, IS_APPLE } from '@lexical/utils';
|
|
8
|
+
import { $getNearestNodeOfType, $wrapNodeInElement, $lastToFirstIterator, $descendantsMatching, mergeRegister, $insertNodeToNearestRoot, $insertFirst, $unwrapAndFilterDescendants, $firstToLastIterator, $getNearestBlockElementAncestorOrThrow, IS_APPLE } from '@lexical/utils';
|
|
9
9
|
import { registerPlainText } from '@lexical/plain-text';
|
|
10
10
|
import { RichTextExtension, $isQuoteNode, $isHeadingNode, $createHeadingNode, $createQuoteNode, QuoteNode, HeadingNode, registerRichText } from '@lexical/rich-text';
|
|
11
11
|
import { $generateNodesFromDOM, $generateHtmlFromNodes } from '@lexical/html';
|
|
@@ -2308,6 +2308,13 @@ class ActionTextAttachmentNode extends DecoratorNode {
|
|
|
2308
2308
|
if (!this.editor.read(() => this.isAttached())) return
|
|
2309
2309
|
this.#swapToPreviewDOM(figure, this.src);
|
|
2310
2310
|
};
|
|
2311
|
+
img.onerror = () => {
|
|
2312
|
+
// Clear pendingPreview so undo/redo or any JSON round-trip doesn't
|
|
2313
|
+
// re-enter the pending flow and issue another fetch. The file icon
|
|
2314
|
+
// stays as the stable fallback.
|
|
2315
|
+
if (!this.editor.read(() => this.isAttached())) return
|
|
2316
|
+
this.patchAndRewriteHistory({ pendingPreview: false });
|
|
2317
|
+
};
|
|
2311
2318
|
img.src = this.src;
|
|
2312
2319
|
}
|
|
2313
2320
|
|
|
@@ -3653,8 +3660,7 @@ class CommandDispatcher {
|
|
|
3653
3660
|
}
|
|
3654
3661
|
|
|
3655
3662
|
dispatchInsertHorizontalDivider() {
|
|
3656
|
-
|
|
3657
|
-
this.editor.focus();
|
|
3663
|
+
$insertNodeToNearestRoot(new HorizontalDividerNode);
|
|
3658
3664
|
}
|
|
3659
3665
|
|
|
3660
3666
|
dispatchSetFormatHeadingLarge() {
|
|
@@ -8667,6 +8673,10 @@ class LexicalPromptElement extends HTMLElement {
|
|
|
8667
8673
|
return this.getAttribute("only-at")
|
|
8668
8674
|
}
|
|
8669
8675
|
|
|
8676
|
+
get verticalDirection() {
|
|
8677
|
+
return this.getAttribute("vertical-direction")
|
|
8678
|
+
}
|
|
8679
|
+
|
|
8670
8680
|
get open() {
|
|
8671
8681
|
return this.popoverElement?.classList?.contains("lexxy-prompt-menu--visible")
|
|
8672
8682
|
}
|
|
@@ -8899,7 +8909,11 @@ class LexicalPromptElement extends HTMLElement {
|
|
|
8899
8909
|
this.popoverElement.toggleAttribute("data-clipped-at-right", true);
|
|
8900
8910
|
}
|
|
8901
8911
|
|
|
8902
|
-
|
|
8912
|
+
const forceTop = this.verticalDirection === "top";
|
|
8913
|
+
const forceBottom = this.verticalDirection === "bottom";
|
|
8914
|
+
const overflowsWindow = popoverRect.bottom > window.innerHeight;
|
|
8915
|
+
|
|
8916
|
+
if (!forceBottom && (forceTop || overflowsWindow)) {
|
|
8903
8917
|
this.#setPopoverOffsetY(contentRect.height - y + fontSize);
|
|
8904
8918
|
this.popoverElement.toggleAttribute("data-clipped-at-bottom", true);
|
|
8905
8919
|
}
|
|
@@ -28,8 +28,8 @@ import 'prismjs/components/prism-kotlin';
|
|
|
28
28
|
window.Prism ||= {};
|
|
29
29
|
window.Prism.manual = true;
|
|
30
30
|
|
|
31
|
-
function highlightCode() {
|
|
32
|
-
const elements =
|
|
31
|
+
function highlightCode(root = document) {
|
|
32
|
+
const elements = root.querySelectorAll("pre[data-language]:not([data-highlighted])");
|
|
33
33
|
|
|
34
34
|
elements.forEach(preElement => {
|
|
35
35
|
highlightElement(preElement);
|
|
@@ -37,6 +37,8 @@ function highlightCode() {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function highlightElement(preElement) {
|
|
40
|
+
if (preElement.dataset.highlighted === "true") return
|
|
41
|
+
|
|
40
42
|
const language = preElement.getAttribute("data-language");
|
|
41
43
|
let code = preElement.innerHTML.replace(/<br\s*\/?>/gi, "\n");
|
|
42
44
|
|
|
@@ -55,6 +57,8 @@ function highlightElement(preElement) {
|
|
|
55
57
|
if (highlights.length > 0) {
|
|
56
58
|
applyHighlightRanges(preElement, highlights);
|
|
57
59
|
}
|
|
60
|
+
|
|
61
|
+
preElement.dataset.highlighted = "true";
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
// Walk the DOM tree inside a <pre> element and build a list of
|
|
@@ -160,4 +164,4 @@ function collectTextNodes(root) {
|
|
|
160
164
|
return nodes
|
|
161
165
|
}
|
|
162
166
|
|
|
163
|
-
export { highlightCode };
|
|
167
|
+
export { highlightCode, highlightElement };
|