1- import { SliceBehavior , SliceTypeCon } from '../slice/constants' ;
1+ import { SliceBehavior , type SliceTypeCon } from '../slice/constants' ;
22import { CommonSliceType } from '../slice' ;
33import type { PeritextMlElement } from '../block/types' ;
44import type { NodeBuilder } from '../../../json-crdt-patch' ;
@@ -14,22 +14,21 @@ export class SliceRegistryEntry<
1414 Tag extends TagType = TagType ,
1515 Schema extends NodeBuilder = NodeBuilder ,
1616> {
17-
1817 public isInline ( ) : boolean {
1918 return this . behavior !== SliceBehavior . Marker ;
2019 }
21-
20+
2221 constructor (
2322 public readonly behavior : Behavior ,
2423
2524 /**
2625 * The tag name of this slice. The tag is one step in the type path of the
2726 * slice. For example, below is a type path composed of three steps:
28- *
27+ *
2928 * ```js
3029 * ['ul', 'li', 'p']
3130 * ```
32- *
31+ *
3332 * Tag types are normally numbers of type {@link SliceTypeCon}, however,
3433 * they can also be any arbitrary strings or numbers.
3534 */
@@ -47,34 +46,48 @@ export class SliceRegistryEntry<
4746 * For example, a `blockquote` is a container for `paragraph` elements,
4847 * however, a `paragraph` is not a container (it can only contain inline
4948 * elements).
50- *
49+ *
5150 * If the marker slice is of the container sort, they tag can appear in the
5251 * path steps of the type:
53- *
52+ *
5453 * ```
55- *
54+ *
5655 * ```
5756 */
5857 public readonly container : boolean = false ,
59-
58+
6059 /**
6160 * Converts a node of this type to HTML representation: returns the HTML tag
6261 * and attributes. The method receives {@link PeritextMlElement} as an
6362 * argument, which is a tuple of internal HTML-like representation of the
6463 * node.
6564 */
66- public readonly toHtml : ToHtmlConverter < PeritextMlElement < Tag , JsonNodeView < SchemaToJsonNode < Schema > > , Behavior extends SliceBehavior . Marker ? false : true > > | undefined = void 0 ,
65+ public readonly toHtml :
66+ | ToHtmlConverter <
67+ PeritextMlElement <
68+ Tag ,
69+ JsonNodeView < SchemaToJsonNode < Schema > > ,
70+ Behavior extends SliceBehavior . Marker ? false : true
71+ >
72+ >
73+ | undefined = void 0 ,
6774
6875 /**
6976 * Specifies a mapping of converters from HTML {@link JsonMlElement} to
7077 * {@link PeritextMlElement}. This way a slice type can specify multiple
7178 * HTML tags that are converted to the same slice type.
72- *
79+ *
7380 * For example, both, `<b>` and `<strong>` tags can be converted to the
7481 * {@link SliceTypeCon.b} slice type.
7582 */
7683 public readonly fromHtml ?: {
77- [ htmlTag : string ] : FromHtmlConverter < PeritextMlElement < Tag , JsonNodeView < SchemaToJsonNode < Schema > > , Behavior extends SliceBehavior . Marker ? false : true > > ;
84+ [ htmlTag : string ] : FromHtmlConverter <
85+ PeritextMlElement <
86+ Tag ,
87+ JsonNodeView < SchemaToJsonNode < Schema > > ,
88+ Behavior extends SliceBehavior . Marker ? false : true
89+ >
90+ > ;
7891 } ,
7992 ) { }
8093}
@@ -85,8 +98,7 @@ export class SliceRegistryEntry<
8598 */
8699export class SliceRegistry {
87100 private map : Map < TagType , SliceRegistryEntry > = new Map ( ) ;
88- private _fromHtml : Map < string , [ entry : SliceRegistryEntry , converter : FromHtmlConverter ] [ ] > =
89- new Map ( ) ;
101+ private _fromHtml : Map < string , [ entry : SliceRegistryEntry , converter : FromHtmlConverter ] [ ] > = new Map ( ) ;
90102
91103 public add ( entry : SliceRegistryEntry < any , any , any > ) : void {
92104 const { tag, fromHtml} = entry ;
@@ -100,8 +112,7 @@ export class SliceRegistry {
100112 }
101113 }
102114 const tagStr = CommonSliceType [ tag as SliceTypeCon ] ;
103- if ( tagStr && typeof tagStr === 'string' )
104- _fromHtml . set ( tagStr , [ [ entry , ( ) => [ tag , null ] ] ] ) ;
115+ if ( tagStr && typeof tagStr === 'string' ) _fromHtml . set ( tagStr , [ [ entry , ( ) => [ tag , null ] ] ] ) ;
105116 }
106117
107118 public toHtml ( el : PeritextMlElement ) : ReturnType < ToHtmlConverter < any > > | undefined {
0 commit comments