Skip to content

Commit

Permalink
Merge branch 'main' into fix/multiple_rows_insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum authored Dec 13, 2024
2 parents 73bc0e9 + 66f805c commit 8e05911
Show file tree
Hide file tree
Showing 40 changed files with 327 additions and 151 deletions.
7 changes: 0 additions & 7 deletions packages/lexical-code/flow/LexicalCode.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ declare export class CodeHighlightNode extends TextNode {
// $FlowFixMe
static clone(node: CodeHighlightNode): CodeHighlightNode;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(
// $FlowFixMe
prevNode: CodeHighlightNode,
dom: HTMLElement,
config: EditorConfig,
): boolean;
setFormat(format: number): this;
}

Expand Down Expand Up @@ -125,7 +119,6 @@ declare export class CodeNode extends ElementNode {
static clone(node: CodeNode): CodeNode;
constructor(language: ?string, key?: NodeKey): void;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(prevNode: CodeNode, dom: HTMLElement): boolean;
insertNewAfter(
selection: RangeSelection,
restoreSelection?: boolean,
Expand Down
6 changes: 1 addition & 5 deletions packages/lexical-code/src/CodeHighlightNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@ export class CodeHighlightNode extends TextNode {
return element;
}

updateDOM(
prevNode: CodeHighlightNode,
dom: HTMLElement,
config: EditorConfig,
): boolean {
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean {
const update = super.updateDOM(prevNode, dom, config);
const prevClassName = getHighlightThemeClass(
config.theme,
Expand Down
6 changes: 1 addition & 5 deletions packages/lexical-code/src/CodeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ export class CodeNode extends ElementNode {
}
return element;
}
updateDOM(
prevNode: CodeNode,
dom: HTMLElement,
config: EditorConfig,
): boolean {
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean {
const language = this.__language;
const prevLanguage = prevNode.__language;

Expand Down
5 changes: 0 additions & 5 deletions packages/lexical-link/flow/LexicalLink.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ declare export class LinkNode extends ElementNode {
static clone(node: LinkNode): LinkNode;
constructor(url: string, attributes?: LinkAttributes, key?: NodeKey): void;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(
prevNode: LinkNode,
dom: HTMLElement,
config: EditorConfig,
): boolean;
static importDOM(): DOMConversionMap | null;
exportJSON(): SerializedLinkNode;
getURL(): string;
Expand Down
4 changes: 2 additions & 2 deletions packages/lexical-link/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class LinkNode extends ElementNode {
}

updateDOM(
prevNode: LinkNode,
prevNode: this,
anchor: LinkHTMLElementType,
config: EditorConfig,
): boolean {
Expand Down Expand Up @@ -393,7 +393,7 @@ export class AutoLinkNode extends LinkNode {
}

updateDOM(
prevNode: AutoLinkNode,
prevNode: this,
anchor: LinkHTMLElementType,
config: EditorConfig,
): boolean {
Expand Down
6 changes: 1 addition & 5 deletions packages/lexical-list/src/LexicalListNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ export class ListNode extends ElementNode {
return dom;
}

updateDOM(
prevNode: ListNode,
dom: HTMLElement,
config: EditorConfig,
): boolean {
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean {
if (prevNode.__tag !== this.__tag) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-mark/src/MarkNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class MarkNode extends ElementNode {
}

updateDOM(
prevNode: MarkNode,
prevNode: this,
element: HTMLElement,
config: EditorConfig,
): boolean {
Expand Down
1 change: 0 additions & 1 deletion packages/lexical-overflow/flow/LexicalOverflow.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ declare export class OverflowNode extends ElementNode {
static clone(node: OverflowNode): OverflowNode;
constructor(key?: NodeKey): void;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(prevNode: OverflowNode, dom: HTMLElement): boolean;
insertNewAfter(selection: RangeSelection): null | LexicalNode;
excludeFromCopy(): boolean;
static importJSON(serializedNode: SerializedOverflowNode): OverflowNode;
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-overflow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class OverflowNode extends ElementNode {
return div;
}

updateDOM(prevNode: OverflowNode, dom: HTMLElement): boolean {
updateDOM(prevNode: this, dom: HTMLElement): boolean {
return false;
}

Expand Down
35 changes: 30 additions & 5 deletions packages/lexical-playground/__tests__/e2e/Autocomplete.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ test.describe('Autocomplete', () => {
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Sort by alpha</span>
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__autocomplete"
style="font-size: 15px; display: none"
data-lexical-text="true">
betical (TAB)
</span>
</p>
`,
);
Expand Down Expand Up @@ -118,7 +123,12 @@ test.describe('Autocomplete', () => {
data-lexical-text="true">
Test
</strong>
<span data-lexical-text="true"></span>
<strong
class="PlaygroundEditorTheme__textUnderlineStrikethrough PlaygroundEditorTheme__textBold PlaygroundEditorTheme__textItalic PlaygroundEditorTheme__autocomplete"
style="font-size: 17px; display: none"
data-lexical-text="true">
imonials (TAB)
</strong>
</p>
`,
);
Expand Down Expand Up @@ -204,7 +214,12 @@ test.describe('Autocomplete', () => {
data-lexical-text="true">
Test
</strong>
<span data-lexical-text="true"></span>
<strong
class="PlaygroundEditorTheme__textUnderlineStrikethrough PlaygroundEditorTheme__textBold PlaygroundEditorTheme__textItalic PlaygroundEditorTheme__autocomplete"
style="font-size: 17px; display: none"
data-lexical-text="true">
imonials (TAB)
</strong>
</p>
`,
);
Expand Down Expand Up @@ -241,7 +256,12 @@ test.describe('Autocomplete', () => {
data-lexical-text="true">
Test
</strong>
<span data-lexical-text="true"></span>
<strong
class="PlaygroundEditorTheme__textUnderlineStrikethrough PlaygroundEditorTheme__textBold PlaygroundEditorTheme__textItalic"
style="font-size: 17px; display: none"
data-lexical-text="true">
imonials
</strong>
</p>
`,
);
Expand Down Expand Up @@ -278,7 +298,12 @@ test.describe('Autocomplete', () => {
data-lexical-text="true">
Test
</strong>
<span data-lexical-text="true"></span>
<strong
class="PlaygroundEditorTheme__textUnderlineStrikethrough PlaygroundEditorTheme__textBold PlaygroundEditorTheme__textItalic PlaygroundEditorTheme__autocomplete"
style="font-size: 17px; display: none"
data-lexical-text="true">
imonials (TAB)
</strong>
</p>
`,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/lexical-playground/__tests__/e2e/Tables.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ test.describe.parallel('Tables', () => {
});

test(
'Grid selection: can select multiple cells and insert an image',
'Table selection: can select multiple cells and insert an image',
{
tag: '@flaky',
},
Expand Down Expand Up @@ -1742,7 +1742,7 @@ test.describe.parallel('Tables', () => {
},
);

test('Grid selection: can backspace lines, backspacing empty cell does not destroy it #3278', async ({
test('Table selection: can backspace lines, backspacing empty cell does not destroy it #3278', async ({
page,
isPlainText,
isCollab,
Expand Down
18 changes: 9 additions & 9 deletions packages/lexical-playground/src/nodes/AutocompleteNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ export class AutocompleteNode extends TextNode {
this.__uuid = uuid;
}

updateDOM(
prevNode: unknown,
dom: HTMLElement,
config: EditorConfig,
): boolean {
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean {
return false;
}

exportDOM(_: LexicalEditor): DOMExportOutput {
return {element: null};
}

excludeFromCopy() {
return true;
}

createDOM(config: EditorConfig): HTMLElement {
if (this.__uuid !== UUID) {
return document.createElement('span');
}
const dom = super.createDOM(config);
dom.classList.add(config.theme.autocomplete);
if (this.__uuid !== UUID) {
dom.style.display = 'none';
}
return dom;
}
}
Expand All @@ -99,5 +99,5 @@ export function $createAutocompleteNode(
text: string,
uuid: string,
): AutocompleteNode {
return new AutocompleteNode(text, uuid);
return new AutocompleteNode(text, uuid).setMode('token');
}
6 changes: 1 addition & 5 deletions packages/lexical-playground/src/nodes/EmojiNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ export class EmojiNode extends TextNode {
return dom;
}

updateDOM(
prevNode: TextNode,
dom: HTMLElement,
config: EditorConfig,
): boolean {
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean {
const inner = dom.firstChild;
if (inner === null) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-playground/src/nodes/EquationNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class EquationNode extends DecoratorNode<JSX.Element> {
};
}

updateDOM(prevNode: EquationNode): boolean {
updateDOM(prevNode: this): boolean {
// If the inline property changes, replace the element
return this.__inline !== prevNode.__inline;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ export class InlineImageNode extends DecoratorNode<JSX.Element> {
return span;
}

updateDOM(
prevNode: InlineImageNode,
dom: HTMLElement,
config: EditorConfig,
): false {
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): false {
const position = this.__position;
if (position !== prevNode.__position) {
const className = `${config.theme.inlineImage} position-${position}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class LayoutContainerNode extends ElementNode {
return {element};
}

updateDOM(prevNode: LayoutContainerNode, dom: HTMLElement): boolean {
updateDOM(prevNode: this, dom: HTMLElement): boolean {
if (prevNode.__templateColumns !== this.__templateColumns) {
dom.style.gridTemplateColumns = this.__templateColumns;
}
Expand Down
6 changes: 1 addition & 5 deletions packages/lexical-playground/src/nodes/SpecialTextNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ export class SpecialTextNode extends TextNode {
return dom;
}

updateDOM(
prevNode: TextNode,
dom: HTMLElement,
config: EditorConfig,
): boolean {
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean {
if (prevNode.__text.startsWith('[') && prevNode.__text.endsWith(']')) {
const strippedText = this.__text.substring(1, this.__text.length - 1); // Strip brackets again
dom.textContent = strippedText; // Update the text content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ export class CollapsibleContainerNode extends ElementNode {
return dom;
}

updateDOM(
prevNode: CollapsibleContainerNode,
dom: HTMLDetailsElement,
): boolean {
updateDOM(prevNode: this, dom: HTMLDetailsElement): boolean {
const currentOpen = this.__open;
if (prevNode.__open !== currentOpen) {
// details is not well supported in Chrome #5582
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class CollapsibleContentNode extends ElementNode {
return dom;
}

updateDOM(prevNode: CollapsibleContentNode, dom: HTMLElement): boolean {
updateDOM(prevNode: this, dom: HTMLElement): boolean {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class CollapsibleTitleNode extends ElementNode {
return dom;
}

updateDOM(prevNode: CollapsibleTitleNode, dom: HTMLElement): boolean {
updateDOM(prevNode: this, dom: HTMLElement): boolean {
return false;
}

Expand Down
2 changes: 0 additions & 2 deletions packages/lexical-rich-text/flow/LexicalRichText.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ declare export class QuoteNode extends ElementNode {
static clone(node: QuoteNode): QuoteNode;
constructor(key?: NodeKey): void;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(prevNode: QuoteNode, dom: HTMLElement): boolean;
insertNewAfter(
selection: RangeSelection,
restoreSelection?: boolean,
Expand All @@ -44,7 +43,6 @@ declare export class HeadingNode extends ElementNode {
constructor(tag: HeadingTagType, key?: NodeKey): void;
getTag(): HeadingTagType;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(prevNode: HeadingNode, dom: HTMLElement): boolean;
static importDOM(): DOMConversionMap | null;
insertNewAfter(
selection: RangeSelection,
Expand Down
4 changes: 2 additions & 2 deletions packages/lexical-rich-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class QuoteNode extends ElementNode {
addClassNamesToElement(element, config.theme.quote);
return element;
}
updateDOM(prevNode: QuoteNode, dom: HTMLElement): boolean {
updateDOM(prevNode: this, dom: HTMLElement): boolean {
return false;
}

Expand Down Expand Up @@ -257,7 +257,7 @@ export class HeadingNode extends ElementNode {
return element;
}

updateDOM(prevNode: HeadingNode, dom: HTMLElement): boolean {
updateDOM(prevNode: this, dom: HTMLElement): boolean {
return false;
}

Expand Down
4 changes: 0 additions & 4 deletions packages/lexical-table/flow/LexicalTable.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ declare export class TableCellNode extends ElementNode {
key?: NodeKey,
): void;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(prevNode: TableCellNode, dom: HTMLElement): boolean;
insertNewAfter(
selection: RangeSelection,
): null | ParagraphNode | TableCellNode;
Expand All @@ -70,7 +69,6 @@ declare export class TableCellNode extends ElementNode {
setBackgroundColor(newBackgroundColor: null | string): TableCellNode;
toggleHeaderStyle(headerState: TableCellHeaderState): TableCellNode;
hasHeader(): boolean;
updateDOM(prevNode: TableCellNode): boolean;
collapseAtStart(): true;
canBeEmpty(): false;
}
Expand Down Expand Up @@ -99,7 +97,6 @@ declare export class TableNode extends ElementNode {
static clone(node: TableNode): TableNode;
constructor(key?: NodeKey): void;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(prevNode: TableNode, dom: HTMLElement): boolean;
insertNewAfter(selection: RangeSelection): null | ParagraphNode | TableNode;
collapseAtStart(): true;
getCordsFromCellNode(
Expand All @@ -126,7 +123,6 @@ declare export class TableRowNode extends ElementNode {
static clone(node: TableRowNode): TableRowNode;
constructor(height?: ?number, key?: NodeKey): void;
createDOM(config: EditorConfig): HTMLElement;
updateDOM(prevNode: TableRowNode, dom: HTMLElement): boolean;
setHeight(height: number): ?number;
getHeight(): ?number;
insertNewAfter(
Expand Down
Loading

0 comments on commit 8e05911

Please sign in to comment.