-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add CommentPlugin
- Loading branch information
Showing
29 changed files
with
1,903 additions
and
168 deletions.
There are no files selected for viewing
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
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
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
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
4 changes: 4 additions & 0 deletions
4
packages/lexical-playground/src/images/icons/chat-left-text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
packages/lexical-playground/src/images/icons/chat-right-dots.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
packages/lexical-playground/src/images/icons/chat-right-text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/** | ||
* 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. | ||
* | ||
* @flow strict | ||
*/ | ||
|
||
import type {EditorConfig, LexicalNode, NodeKey, RangeSelection} from 'lexical'; | ||
|
||
import {addClassNamesToElement} from '@lexical/utils'; | ||
import {$isElementNode, ElementNode} from 'lexical'; | ||
|
||
export class MarkNode extends ElementNode { | ||
__ids: Array<string>; | ||
|
||
static getType(): string { | ||
return 'mark'; | ||
} | ||
|
||
static clone(node: MarkNode): MarkNode { | ||
return new MarkNode(node.__ids, node.__key); | ||
} | ||
|
||
constructor(ids: Array<string>, key?: NodeKey): void { | ||
super(key); | ||
this.__ids = ids || []; | ||
} | ||
|
||
createDOM(config: EditorConfig): HTMLElement { | ||
const element = document.createElement('mark'); | ||
addClassNamesToElement(element, config.theme.mark); | ||
return element; | ||
} | ||
|
||
updateDOM(): boolean { | ||
return false; | ||
} | ||
|
||
hasID(id: string): boolean { | ||
const ids = this.getIDs(); | ||
for (let i = 0; i < ids.length; i++) { | ||
if (id === ids[i]) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
getIDs(): Array<string> { | ||
const self = this.getLatest(); | ||
return self.__ids; | ||
} | ||
|
||
addID(id: string): void { | ||
const self = this.getWritable(); | ||
const ids = Array.from(self.__ids); | ||
self.__ids = ids; | ||
for (let i = 0; i < ids.length; i++) { | ||
// If we already have it, don't add again | ||
if (id === ids[i]) { | ||
return; | ||
} | ||
} | ||
ids.push(id); | ||
} | ||
|
||
deleteID(id: string): void { | ||
const self = this.getWritable(); | ||
const ids = Array.from(self.__ids); | ||
self.__ids = ids; | ||
for (let i = 0; i < ids.length; i++) { | ||
if (id === ids[i]) { | ||
ids.splice(i, 1); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
insertNewAfter(selection: RangeSelection): null | ElementNode { | ||
const element = this.getParentOrThrow().insertNewAfter(selection); | ||
if ($isElementNode(element)) { | ||
const linkNode = $createMarkNode(this.__ids); | ||
element.append(linkNode); | ||
return linkNode; | ||
} | ||
return null; | ||
} | ||
|
||
canInsertTextBefore(): false { | ||
return false; | ||
} | ||
|
||
canInsertTextAfter(): false { | ||
return false; | ||
} | ||
|
||
canBeEmpty(): false { | ||
return false; | ||
} | ||
|
||
isInline(): true { | ||
return true; | ||
} | ||
|
||
// TODO: It seems excludeFromCopy doesn't work as expected anymore. | ||
// excludeFromCopy(): true { | ||
// return true; | ||
// } | ||
} | ||
|
||
export function $createMarkNode(ids: Array<string>): MarkNode { | ||
return new MarkNode(ids); | ||
} | ||
|
||
export function $isMarkNode(node: ?LexicalNode): boolean %checks { | ||
return node instanceof MarkNode; | ||
} |
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
Oops, something went wrong.
b84076e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
lexical – ./packages/lexical-website-new
www.lexical.dev
lexical.dev
lexical-fbopensource.vercel.app
lexical-git-main-fbopensource.vercel.app
lexicaljs.org
lexicaljs.com
b84076e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
lexical-playground – ./packages/lexical-playground
lexical-playground-fbopensource.vercel.app
playground.lexical.dev
lexical-playground.vercel.app
lexical-playground-git-main-fbopensource.vercel.app