11import { s } from '../../../json-crdt-patch' ;
2- import { SliceBehavior , SliceTypeCon } from '../slice/constants' ;
2+ import { SliceBehavior , SliceTypeCon as TAG } from '../slice/constants' ;
33import { SliceRegistry , SliceRegistryEntry , TagType } from './SliceRegistry' ;
44import type { JsonNodeView } from '../../../json-crdt/nodes' ;
55import type { SchemaToJsonNode } from '../../../json-crdt/schema/types' ;
@@ -14,7 +14,7 @@ const undefSchema = s.con(undefined);
1414
1515// ----------------------------------------- Inline elements with "One" behavior
1616
17- const inlineOne = < Tag extends TagType = TagType > (
17+ const i0 = < Tag extends TagType = TagType > (
1818 tag : Tag ,
1919 fromHtml ?: SliceRegistryEntry < SliceBehavior . One , Tag , typeof undefSchema > [ 'fromHtml' ] ,
2020) : void => {
@@ -30,24 +30,24 @@ const inlineOne = <Tag extends TagType = TagType>(
3030 ) ;
3131} ;
3232
33- const inlineOne2 = < Tag extends TagType = TagType > ( tag : Tag , htmlTags : string [ ] ) : void => {
33+ const i1 = < Tag extends TagType = TagType > ( tag : Tag , htmlTags : string [ ] ) : void => {
3434 const fromHtml = { } as Record < any , any > ;
3535 for ( const htmlTag of htmlTags ) fromHtml [ htmlTag ] = ( ) => [ tag , null ] ;
36- inlineOne ( tag , fromHtml ) ;
36+ i0 ( tag , fromHtml ) ;
3737} ;
3838
39- inlineOne2 ( SliceTypeCon . i , [ 'i' , 'em' ] ) ;
40- inlineOne2 ( SliceTypeCon . b , [ 'b' , 'strong' ] ) ;
41- inlineOne2 ( SliceTypeCon . s , [ 's' , 'strike' ] ) ;
42- inlineOne ( SliceTypeCon . u ) ;
43- inlineOne ( SliceTypeCon . code ) ;
44- inlineOne ( SliceTypeCon . mark ) ;
45- inlineOne ( SliceTypeCon . kbd ) ;
46- inlineOne ( SliceTypeCon . del ) ;
47- inlineOne ( SliceTypeCon . ins ) ;
48- inlineOne ( SliceTypeCon . sup ) ;
49- inlineOne ( SliceTypeCon . sub ) ;
50- inlineOne ( SliceTypeCon . math ) ;
39+ i1 ( TAG . i , [ 'i' , 'em' ] ) ;
40+ i1 ( TAG . b , [ 'b' , 'strong' ] ) ;
41+ i1 ( TAG . s , [ 's' , 'strike' ] ) ;
42+ i0 ( TAG . u ) ;
43+ i0 ( TAG . code ) ;
44+ i0 ( TAG . mark ) ;
45+ i0 ( TAG . kbd ) ;
46+ i0 ( TAG . del ) ;
47+ i0 ( TAG . ins ) ;
48+ i0 ( TAG . sup ) ;
49+ i0 ( TAG . sub ) ;
50+ i0 ( TAG . math ) ;
5151
5252// ---------------------------------------- Inline elements with "Many" behavior
5353
@@ -58,7 +58,7 @@ const aSchema = s.obj({
5858registry . add (
5959 new SliceRegistryEntry (
6060 SliceBehavior . Many ,
61- SliceTypeCon . a ,
61+ TAG . a ,
6262 aSchema ,
6363 false ,
6464 void 0 ,
@@ -69,7 +69,7 @@ registry.add(
6969 href : attr . href ?? '' ,
7070 title : attr . title ?? '' ,
7171 } ;
72- return [ SliceTypeCon . a , { data, inline : true } ] as PeritextMlElement < SliceTypeCon . a , any , true > ;
72+ return [ TAG . a , { data, inline : true } ] as PeritextMlElement < TAG . a , any , true > ;
7373 } ,
7474 } ,
7575 )
@@ -89,4 +89,54 @@ registry.add(
8989
9090// --------------------------------------- Block elements with "Marker" behavior
9191
92- // registry.def(CommonSliceType.blockquote, undefSchema, SliceBehavior.Marker, false);
92+ const commonBlockSchema = s . obj ( { } , {
93+ indent : s . con ( 0 ) ,
94+ align : s . str < 'left' | 'center' | 'right' | 'justify' > ( 'left' ) ,
95+ } ) ;
96+
97+ const b0 = < Tag extends TagType = TagType > (
98+ tag : Tag ,
99+ container : boolean ,
100+ ) => {
101+ registry . add (
102+ new SliceRegistryEntry (
103+ SliceBehavior . Marker ,
104+ tag ,
105+ commonBlockSchema ,
106+ container ,
107+ )
108+ ) ;
109+ } ;
110+
111+ b0 ( TAG . p , false ) ;
112+ b0 ( TAG . blockquote , true ) ;
113+ b0 ( TAG . codeblock , false ) ;
114+ b0 ( TAG . pre , false ) ;
115+ b0 ( TAG . ul , true ) ;
116+ b0 ( TAG . ol , true ) ;
117+ b0 ( TAG . tl , true ) ;
118+ b0 ( TAG . ol , true ) ;
119+ b0 ( TAG . li , true ) ;
120+ b0 ( TAG . h1 , false ) ;
121+ b0 ( TAG . h2 , false ) ;
122+ b0 ( TAG . h3 , false ) ;
123+ b0 ( TAG . h4 , false ) ;
124+ b0 ( TAG . h5 , false ) ;
125+ b0 ( TAG . h6 , false ) ;
126+ b0 ( TAG . title , false ) ;
127+ b0 ( TAG . subtitle , false ) ;
128+ // b0(TAG.br, false);
129+ // b0(TAG.nl, false);
130+ // b0(TAG.hr, false);
131+ // b0(TAG.page, false);
132+ // b0(TAG.aside, true);
133+ // b0(TAG.embed, false);
134+ // b0(TAG.column, true);
135+ // b0(TAG.contents, true);
136+ // b0(TAG.table, true);
137+ // b0(TAG.row, true);
138+ // b0(TAG.cell, true);
139+ // b0(TAG.collapselist, true);
140+ // b0(TAG.collapse, true);
141+ // b0(TAG.note, true);
142+ // b0(TAG.mathblock, false);
0 commit comments