-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no refs - updated lexical to the latest release - this brings various fixes and improvements that are not listed here; we were held up for a while by waiting for changes that we needed after the `insertNodes` changes in lexical 0.12.3 - changes to lexical types in 0.13.0 necessitate some type declarations and finagling that were not necessary before, and are pushing us to migrate all Koenig code over to typescript as a result
- Loading branch information
1 parent
84d673f
commit f689b94
Showing
59 changed files
with
373 additions
and
337 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
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
6 changes: 3 additions & 3 deletions
6
packages/kg-default-transforms/src/transforms/merge-list-nodes.ts
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
declare module '@tryghost/kg-default-nodes'; | ||
declare module '@tryghost/kg-default-nodes' { | ||
import {DEFAULT_NODES, ExtendedHeadingNode, ImageNode} from '@tryghost/kg-default-nodes'; | ||
|
||
export {DEFAULT_NODES, ExtendedHeadingNode, ImageNode}; | ||
}; |
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
16 changes: 7 additions & 9 deletions
16
packages/kg-lexical-html-renderer/lib/get-dynamic-data-nodes.ts
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 |
---|---|---|
@@ -1,23 +1,21 @@ | ||
import type {EditorState, LexicalNode} from 'lexical'; | ||
|
||
import {$getRoot} from 'lexical'; | ||
// TODO: update to import when this is moved to typescript | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const {$isKoenigCard} = require('@tryghost/kg-default-nodes'); | ||
import {$isKoenigCard, KoenigDecoratorNode} from '@tryghost/kg-default-nodes'; | ||
|
||
import type {EditorState} from 'lexical'; | ||
|
||
export default function getDynamicDataNodes(editorState: EditorState) { | ||
const dynamicNodes: LexicalNode[] = []; | ||
export default function getDynamicDataNodes(editorState: EditorState): KoenigDecoratorNode[] { | ||
const dynamicNodes: KoenigDecoratorNode[] = []; | ||
|
||
editorState.read(() => { | ||
const root = $getRoot(); | ||
const nodes = root.getChildren(); | ||
|
||
nodes.forEach((node: LexicalNode) => { | ||
nodes.forEach((node) => { | ||
if ($isKoenigCard(node) && node.hasDynamicData?.()) { | ||
dynamicNodes.push(node); | ||
} | ||
}); | ||
}); | ||
|
||
return dynamicNodes; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/kg-lexical-html-renderer/lib/kg-default-nodes.d.ts
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,27 @@ | ||
declare module '@tryghost/kg-default-nodes' { | ||
import {LexicalNode, DecoratorNode, LexicalEditor, ElementNode} from 'lexical'; | ||
import * as KgDefaultNodes from '@tryghost/kg-default-nodes'; | ||
|
||
export interface RendererOptions { | ||
usedIdAttributes?: Record<string, number>; | ||
dom?: import('jsdom').JSDOM, | ||
type?: 'inner' | 'outer' | 'value' | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
type X = any; | ||
|
||
export class KoenigDecoratorNode extends DecoratorNode<X> { | ||
// TODO: exportDOM override isn't directly compatible with base class, should fix when converting kg-default-nodes | ||
exportDOM(options: LexicalEditor | RendererOptions): { | ||
element: HTMLElement | HTMLInputElement | HTMLTextAreaElement; | ||
type: 'inner' | 'outer' | 'value' | ||
}; | ||
hasDynamicData?(): boolean; | ||
getDynamicData?(options: RendererOptions): Promise<{key: number; data: unknown}>; | ||
} | ||
export function $isKoenigCard(node: LexicalNode): node is KgDefaultNodes.KoenigDecoratorNode; | ||
|
||
export class AsideNode extends ElementNode {} | ||
export function $isAsideNode(node: LexicalNode): node is KgDefaultNodes.AsideNode; | ||
} |
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,3 @@ | ||
declare module '@tryghost/kg-utils' { | ||
export function slugify (text: string, options?: {ghostVersion?: string, type?: string}): string; | ||
} |
9 changes: 3 additions & 6 deletions
9
packages/kg-lexical-html-renderer/lib/transformers/element/aside.ts
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
6 changes: 3 additions & 3 deletions
6
packages/kg-lexical-html-renderer/lib/transformers/element/blockquote.ts
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
6 changes: 3 additions & 3 deletions
6
packages/kg-lexical-html-renderer/lib/transformers/element/heading.ts
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
Oops, something went wrong.