This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hook useLexicalNode<TReturn, TNode: LexicalNode>( | |
nodeKey: NodeKey, | |
callback: (TNode | null) => TReturn, | |
predicate: (node: LexicalNode | null) => node is TNode, | |
): TReturn { | |
return useLexicalSubscription<TReturn>((editor: LexicalEditor) => { | |
const getValue = () => { | |
return editor.read(() => { | |
const node = $getNodeByKey<LexicalNode>(nodeKey); | |
return callback(predicate(node) ? node : null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) Meta Platforms, Inc. and affiliates. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE file in the root directory of this source tree. | |
* | |
*/ | |
import type {LexicalEditor, LexicalNode} from 'lexical'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const domMap: Map<NodeKey, HTMLElement | null> = new Map(); | |
return editor.registerMutationListener( | |
MentionNode, | |
(mutations, {prevEditorState}) => { | |
for (const [nodeKey, mutation] of mutations) { | |
if (mutation === 'created' || mutation === 'updated') { | |
domMap.set(nodeKey, editor.getElementByKey(nodeKey)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function $walk( | |
start: LexicalNode | null, | |
isBackward: boolean = false | |
): LexicalNode | null { | |
let node: LexicalNode | null = start; | |
if ($isElementNode(node) && !node.isEmpty()) { | |
return isBackward ? node.getLastChild() : node.getFirstChild(); | |
} | |
let sibling: LexicalNode | null = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const INTERNAL_PROPS = new Set([ | |
'__first', | |
'__last', | |
'__size', | |
'__parent', | |
'__next', | |
'__prev', | |
'__cachedText', | |
'__key', | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
import type { LexicalEditor, LexicalNode } from "Lexical"; | |
import type { Binding, Provider } from "LexicalYjs"; | |
import { | |
createBinding, | |
syncLexicalUpdateToYjs, | |
syncYjsChangesToLexical, | |
} from "LexicalYjs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createDom() { | |
return <div> | |
<div> | |
<div contenteditable=false>expand/collapse button</div> | |
<div ref=this.childrenContainer> </div> | |
</div> | |
</div> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {createEditor} from 'Lexical'; | |
import {createBinding, syncYjsChangesToLexical} from 'LexicalYjs'; | |
import {Doc, applyUpdate} from 'yjs'; | |
export default function exportYDoc( | |
yDocState: Uint8Array, | |
nodes: Array<Class<LexicalNode>>, | |
): SerializedEditorState { | |
const emptyFunction = () => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Config = { | |
'legal-entities/:id': 'entities#show', | |
'external-contact/current/legal-entities': 'ecEntities#index', | |
'internal-contact/current/legal-entities': 'icEntities#index', | |
'outreach-campaigns': 'oc#index', | |
'outreach-campaigns/new': 'oc#create', | |
'outreach-campaigns/:id': 'oc#show', | |
'outreach-campaigns/:id/edit': 'oc#edit', | |
'outreach-campaigns/:id/legal-entities': 'ocEntities#index' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var dot, | |
tooltip; | |
var help = function (steps) { | |
dot = dot || $('<div class="dot">').appendTo('body'); | |
tooltip = tooltip || $('<div class="tooltip">').hide().appendTo('body'); | |
steps = steps.slice(); |
NewerOlder