File tree 2 files changed +29
-2
lines changed
2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1
- import diplodocSanitize , { type SanitizeOptions } from '@diplodoc/transform/lib/sanitize.js' ;
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 = ( ) => {
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
+ } ;
24
+
25
+ // MAJOR: use `import {sanitize} from '@diplodoc/transform/lib/sanitize.js'`
26
+ const diplodocSanitize = getSanitizeFunction ( ) ;
2
27
3
28
// yfmHtmlBlock additional css properties white list
4
29
const getYfmHtmlBlockWhiteList = ( ) => {
Original file line number Diff line number Diff line change 1
1
import { Fragment , type Node } from 'prosemirror-model' ;
2
2
import { Plugin , TextSelection , type Transaction } from 'prosemirror-state' ;
3
+ // @ts -ignore // TODO: fix cjs build
3
4
import { findChildren , hasParentNode } from 'prosemirror-utils' ;
4
5
5
6
import { getChildrenOfNode } from '../../../../utils' ;
@@ -36,7 +37,8 @@ export function collapseEmptyListItems(
36
37
nodes : ReturnType < typeof findChildren > ,
37
38
) : number {
38
39
const stepsCountBefore = tr . steps . length ;
39
- nodes . reverse ( ) . forEach ( ( list ) => {
40
+ // TODO: fix cjs build
41
+ nodes . reverse ( ) . forEach ( ( list : { node : Node ; pos : number } ) => {
40
42
const listNode = list . node ;
41
43
const listPos = list . pos ;
42
44
const childrenOfList = getChildrenOfNode ( listNode ) . reverse ( ) ;
You can’t perform that action at this time.
0 commit comments