File tree Expand file tree Collapse file tree 3 files changed +30
-24
lines changed
Expand file tree Collapse file tree 3 files changed +30
-24
lines changed Original file line number Diff line number Diff line change 1- import type { SanitizeOptions } from '@diplodoc/transform/lib/sanitize.js' ;
2- import * as sanitizeModule from '@diplodoc/transform/lib/sanitize.js' ;
1+ import type { SanitizeOptions } from '@diplodoc/transform/lib/sanitize' ;
32
4- type SanitizeFn = (
5- html : string ,
6- options ?: SanitizeOptions ,
7- additionalOptions ?: SanitizeOptions ,
8- ) => string ;
9-
10- interface SanitizeModule {
11- sanitize ?: SanitizeFn ;
12- default ?: SanitizeFn ;
13- }
14-
15- const sanitizeAll = ( ) => {
16- console . warn ( '[YfmHtmlBlock]: sanitize function not found' ) ;
17- return '' ;
18- } ;
19- const getSanitizeFunction = ( ) : SanitizeFn => {
20- const module = sanitizeModule as SanitizeModule ;
21- const sanitize = 'sanitize' in module && module . sanitize ? module . sanitize : module . default ;
22- return sanitize instanceof Function ? sanitize : sanitizeAll ;
23- } ;
3+ import { getSanitize } from 'src/utils/getSanitize' ;
244
255// MAJOR: use `import {sanitize} from '@diplodoc/transform/lib/sanitize.js'`
26- const diplodocSanitize = getSanitizeFunction ( ) ;
6+ const diplodocSanitize = getSanitize ( 'YfmHtmlBlock' ) ;
277
288// yfmHtmlBlock additional css properties white list
299const getYfmHtmlBlockWhiteList = ( ) => {
Original file line number Diff line number Diff line change 1- import sanitize from '@diplodoc/transform/lib/sanitize.js' ;
21import type { NodeSpec } from 'prosemirror-model' ;
32
3+ import { getSanitize } from 'src/utils/getSanitize' ;
4+
45import { HtmlAttr , HtmlNode } from './const' ;
56
67enum DomAttr {
78 Html = 'data-html' ,
89 HtmlRaw = 'data-html-raw' ,
910}
1011
12+ const sanitize = getSanitize ( 'Html' ) ;
13+
1114export const schemaSpecs : Record < HtmlNode , NodeSpec > = {
1215 [ HtmlNode . Block ] : {
1316 atom : true ,
Original file line number Diff line number Diff line change 1+ import type { SanitizeOptions } from '@diplodoc/transform/lib/sanitize.js' ;
2+ import * as sanitizeModule from '@diplodoc/transform/lib/sanitize.js' ;
3+
4+ type SanitizeFn = (
5+ html : string ,
6+ options ?: SanitizeOptions ,
7+ additionalOptions ?: SanitizeOptions ,
8+ ) => string ;
9+
10+ interface SanitizeModule {
11+ sanitize ?: SanitizeFn ;
12+ default ?: SanitizeFn ;
13+ }
14+
15+ const sanitizeAll = ( blockName : string ) => ( ) => {
16+ console . warn ( `[${ blockName } ]: sanitize function not found` ) ;
17+ return '' ;
18+ } ;
19+ export const getSanitize = ( blockName : string ) : SanitizeFn => {
20+ const module = sanitizeModule as SanitizeModule ;
21+ const sanitize = 'sanitize' in module && module . sanitize ? module . sanitize : module . default ;
22+ return sanitize instanceof Function ? sanitize : sanitizeAll ( blockName ) ;
23+ } ;
You can’t perform that action at this time.
0 commit comments