11import isNumber from 'is-number' ;
22import type { NodeSpec } from 'prosemirror-model' ;
33import imsize from '@diplodoc/transform/lib/plugins/imsize' ;
4- import { ImsizeAttr as ImgSizeAttr } from '@diplodoc/transform/lib/plugins/imsize/const' ;
54import log from '@diplodoc/transform/lib/log' ;
65
76import type { ExtensionAuto } from '../../../../core' ;
87import { imageNodeName } from '../../../markdown/Image/const' ;
8+ import { ImgSizeAttr } from './const' ;
99
1010type ImsizeTypedAttributes = {
1111 [ ImgSizeAttr . Src ] : string ;
1212 [ ImgSizeAttr . Title ] : string | null ;
1313 [ ImgSizeAttr . Alt ] : string | null ;
1414 [ ImgSizeAttr . Width ] : string | null ;
1515 [ ImgSizeAttr . Height ] : string | null ;
16+ [ ImgSizeAttr . Loading ] : string | null ;
1617} ;
1718
1819export { ImgSizeAttr } ;
@@ -37,6 +38,7 @@ export const ImgSizeSpecs: ExtensionAuto<ImgSizeSpecsOptions> = (builder, opts)
3738 [ ImgSizeAttr . Title ] : { default : null } ,
3839 [ ImgSizeAttr . Height ] : { default : null } ,
3940 [ ImgSizeAttr . Width ] : { default : null } ,
41+ [ ImgSizeAttr . Loading ] : { default : null } ,
4042 } ,
4143 placeholder : placeholderContent ? { content : placeholderContent } : opts . placeholder ,
4244 group : 'inline' ,
@@ -52,6 +54,9 @@ export const ImgSizeSpecs: ExtensionAuto<ImgSizeSpecsOptions> = (builder, opts)
5254 [ ImgSizeAttr . Src ] : ( dom as Element ) . getAttribute ( ImgSizeAttr . Src ) ,
5355 [ ImgSizeAttr . Alt ] : ( dom as Element ) . getAttribute ( ImgSizeAttr . Alt ) ,
5456 [ ImgSizeAttr . Title ] : ( dom as Element ) . getAttribute ( ImgSizeAttr . Title ) ,
57+ [ ImgSizeAttr . Loading ] : ( dom as Element ) . getAttribute (
58+ ImgSizeAttr . Loading ,
59+ ) ,
5560 [ ImgSizeAttr . Height ] : isNumber ( height ) ? height : null ,
5661 [ ImgSizeAttr . Width ] : isNumber ( width ) ? height : null ,
5762 } ;
@@ -71,6 +76,7 @@ export const ImgSizeSpecs: ExtensionAuto<ImgSizeSpecsOptions> = (builder, opts)
7176 [ ImgSizeAttr . Title ] : tok . attrGet ( ImgSizeAttr . Title ) ,
7277 [ ImgSizeAttr . Height ] : tok . attrGet ( ImgSizeAttr . Height ) ,
7378 [ ImgSizeAttr . Width ] : tok . attrGet ( ImgSizeAttr . Width ) ,
79+ [ ImgSizeAttr . Loading ] : tok . attrGet ( ImgSizeAttr . Loading ) ,
7480 [ ImgSizeAttr . Alt ] : tok . children ?. [ 0 ] ?. content || null ,
7581 } ) ,
7682 } ,
0 commit comments