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' ;
3
2
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' ;
24
4
25
5
// MAJOR: use `import {sanitize} from '@diplodoc/transform/lib/sanitize.js'`
26
- const diplodocSanitize = getSanitizeFunction ( ) ;
6
+ const diplodocSanitize = getSanitize ( 'YfmHtmlBlock' ) ;
27
7
28
8
// yfmHtmlBlock additional css properties white list
29
9
const getYfmHtmlBlockWhiteList = ( ) => {
Original file line number Diff line number Diff line change 1
- import sanitize from '@diplodoc/transform/lib/sanitize.js' ;
2
1
import type { NodeSpec } from 'prosemirror-model' ;
3
2
3
+ import { getSanitize } from 'src/utils/getSanitize' ;
4
+
4
5
import { HtmlAttr , HtmlNode } from './const' ;
5
6
6
7
enum DomAttr {
7
8
Html = 'data-html' ,
8
9
HtmlRaw = 'data-html-raw' ,
9
10
}
10
11
12
+ const sanitize = getSanitize ( 'Html' ) ;
13
+
11
14
export const schemaSpecs : Record < HtmlNode , NodeSpec > = {
12
15
[ HtmlNode . Block ] : {
13
16
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