-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEV-13006] Update model: callout block & highlighted text
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComposedElement } from '../ComposedElement'; | ||
import type { Node } from '../Node'; | ||
|
||
export interface CalloutNode<Inline extends Node> extends ComposedElement<typeof CalloutNode.TYPE, Inline> {} | ||
|
||
export namespace CalloutNode { | ||
export const TYPE = 'callout'; | ||
|
||
export function isCalloutNode<T extends CalloutNode<Inline>, Inline extends Node>(value: any): value is T { | ||
return ComposedElement.isComposedElement(value, CalloutNode.TYPE); | ||
} | ||
|
||
export function validateCalloutNode<Quote extends CalloutNode<Inline>, Inline extends Node>( | ||
value: any, | ||
validateInlineNode: (node: any) => Inline | null, | ||
): Quote | null { | ||
const isValid = | ||
ComposedElement.validateComposedElement(value, TYPE, validateInlineNode) && | ||
(typeof value.icon === 'string' || typeof value.icon === 'undefined') && | ||
(typeof value.align === 'string' || typeof value.align === 'undefined'); | ||
|
||
return isValid ? value : 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
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