@@ -5,20 +5,43 @@ import {CommonSliceType} from "../slice";
55import { SliceBehavior } from '../slice/constants' ;
66import { SliceRegistry } from "./SliceRegistry" ;
77
8+ const undefSchema = s . con ( undefined ) ;
9+
810/**
911 * Default annotation type registry.
1012 */
1113export const registry = new SliceRegistry ( ) ;
1214
15+ registry . def ( CommonSliceType . i , undefSchema , SliceBehavior . One , true , {
16+ fromHtml : {
17+ i : ( ) => [ CommonSliceType . i , null ] ,
18+ em : ( ) => [ CommonSliceType . i , null ] ,
19+ } ,
20+ } ) ;
21+
22+ registry . def ( CommonSliceType . b , undefSchema , SliceBehavior . One , true , {
23+ fromHtml : {
24+ b : ( ) => [ CommonSliceType . b , null ] ,
25+ strong : ( ) => [ CommonSliceType . b , null ] ,
26+ } ,
27+ } ) ;
28+
29+ registry . def ( CommonSliceType . u , undefSchema , SliceBehavior . One , true ) ;
30+ registry . def ( CommonSliceType . s , undefSchema , SliceBehavior . One , true ) ;
31+ registry . def ( CommonSliceType . code , undefSchema , SliceBehavior . One , true ) ;
32+ registry . def ( CommonSliceType . mark , undefSchema , SliceBehavior . One , true ) ;
33+ registry . def ( CommonSliceType . kbd , undefSchema , SliceBehavior . One , true ) ;
34+ registry . def ( CommonSliceType . del , undefSchema , SliceBehavior . One , true ) ;
35+ registry . def ( CommonSliceType . ins , undefSchema , SliceBehavior . One , true ) ;
36+ registry . def ( CommonSliceType . sup , undefSchema , SliceBehavior . One , true ) ;
37+ registry . def ( CommonSliceType . sub , undefSchema , SliceBehavior . One , true ) ;
38+ registry . def ( CommonSliceType . math , undefSchema , SliceBehavior . One , true ) ;
39+
1340const aSchema = s . obj ( {
1441 href : s . str < string > ( '' ) ,
1542 title : s . str < string > ( '' ) ,
1643} ) ;
17-
18- registry . add ( {
19- type : CommonSliceType . a ,
20- schema : aSchema ,
21- // toHtml: (el) => ['a', {...el[1]?.data}],
44+ registry . def ( CommonSliceType . a , aSchema , SliceBehavior . Many , true , {
2245 fromHtml : {
2346 a : ( jsonml ) => {
2447 const attr = jsonml [ 1 ] || { } ;
@@ -31,12 +54,14 @@ registry.add({
3154 } ,
3255} ) ;
3356
34- registry . add ( {
35- type : CommonSliceType . i ,
36- behavior : SliceBehavior . One ,
37- schema : s . con ( undefined ) ,
38- fromHtml : {
39- em : ( ) => [ CommonSliceType . i , null ] ,
40- i : ( ) => [ CommonSliceType . i , null ] ,
41- } ,
42- } ) ;
57+ // TODO: add more default annotations
58+ // comment = SliceTypeCon.comment,
59+ // font = SliceTypeCon.font,
60+ // col = SliceTypeCon.col,
61+ // bg = SliceTypeCon.bg,
62+ // hidden = SliceTypeCon.hidden,
63+ // footnote = SliceTypeCon.footnote,
64+ // ref = SliceTypeCon.ref,
65+ // iaside = SliceTypeCon.iaside,
66+ // iembed = SliceTypeCon.iembed,
67+ // bookmark = SliceTypeCon.bookmark,
0 commit comments