File tree 3 files changed +24
-3
lines changed
3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ export interface BlockProviderOptions {
47
47
middleware ?: Middleware [ ]
48
48
/// Options for floating ui. If you pass `middleware` or `placement`, it will override the internal settings.
49
49
floatingUIOptions ?: Partial < ComputePositionConfig >
50
+ /// The root element that the block will be appended to.
51
+ root ?: HTMLElement
50
52
}
51
53
52
54
/// A provider for creating block.
@@ -63,6 +65,9 @@ export class BlockProvider {
63
65
/// @internal
64
66
#activeNode: ActiveNode | null = null
65
67
68
+ /// @internal
69
+ readonly #root?: HTMLElement
70
+
66
71
/// @internal
67
72
#initialized = false
68
73
@@ -102,13 +107,15 @@ export class BlockProvider {
102
107
this . #getPlacement = options . getPlacement
103
108
this . #middleware = options . middleware ?? [ ]
104
109
this . #floatingUIOptions = options . floatingUIOptions ?? { }
110
+ this . #root = options . root
105
111
this . hide ( )
106
112
}
107
113
108
114
/// @internal
109
115
#init( ) {
110
116
const view = this . #ctx. get ( editorViewCtx )
111
- view . dom . parentElement ?. appendChild ( this . #element)
117
+ const root = this . #root ?? view . dom . parentElement ?? document . body
118
+ root . appendChild ( this . #element)
112
119
113
120
const service = this . #ctx. get ( blockService . key )
114
121
service . bind ( this . #ctx, ( message ) => {
Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ export interface SlashProviderOptions {
33
33
middleware ?: Middleware [ ]
34
34
/// Options for floating ui. If you pass `middleware` or `placement`, it will override the internal settings.
35
35
floatingUIOptions ?: Partial < ComputePositionConfig >
36
+ /// The root element that the slash will be appended to.
37
+ root ?: HTMLElement
36
38
}
37
39
38
40
/// A provider for creating slash.
@@ -49,6 +51,9 @@ export class SlashProvider {
49
51
/// @internal
50
52
readonly #floatingUIOptions: Partial < ComputePositionConfig >
51
53
54
+ /// @internal
55
+ readonly #root?: HTMLElement
56
+
52
57
/// @internal
53
58
readonly #debounce: number
54
59
@@ -81,6 +86,7 @@ export class SlashProvider {
81
86
this . #offset = options . offset
82
87
this . #middleware = options . middleware ?? [ ]
83
88
this . #floatingUIOptions = options . floatingUIOptions ?? { }
89
+ this . #root = options . root
84
90
}
85
91
86
92
/// @internal
@@ -94,7 +100,8 @@ export class SlashProvider {
94
100
prevState && prevState . doc . eq ( doc ) && prevState . selection . eq ( selection )
95
101
96
102
if ( ! this . #initialized) {
97
- view . dom . parentElement ?. appendChild ( this . element )
103
+ const root = this . #root ?? view . dom . parentElement ?? document . body
104
+ root . appendChild ( this . element )
98
105
this . #initialized = true
99
106
}
100
107
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ export interface TooltipProviderOptions {
30
30
middleware ?: Middleware [ ]
31
31
/// Options for floating ui. If you pass `middleware` or `placement`, it will override the internal settings.
32
32
floatingUIOptions ?: Partial < ComputePositionConfig >
33
+ /// The root element that the tooltip will be appended to.
34
+ root ?: HTMLElement
33
35
}
34
36
35
37
/// A provider for creating tooltip.
@@ -46,6 +48,9 @@ export class TooltipProvider {
46
48
/// @internal
47
49
readonly #floatingUIOptions: Partial < ComputePositionConfig >
48
50
51
+ /// @internal
52
+ readonly #root?: HTMLElement
53
+
49
54
/// @internal
50
55
#initialized = false
51
56
@@ -74,6 +79,7 @@ export class TooltipProvider {
74
79
this . #offset = options . offset
75
80
this . #middleware = options . middleware ?? [ ]
76
81
this . #floatingUIOptions = options . floatingUIOptions ?? { }
82
+ this . #root = options . root
77
83
this . element . dataset . show = 'false'
78
84
}
79
85
@@ -88,7 +94,8 @@ export class TooltipProvider {
88
94
prevState && prevState . doc . eq ( doc ) && prevState . selection . eq ( selection )
89
95
90
96
if ( ! this . #initialized) {
91
- view . dom . parentElement ?. appendChild ( this . element )
97
+ const root = this . #root ?? view . dom . parentElement ?? document . body
98
+ root . appendChild ( this . element )
92
99
this . #initialized = true
93
100
}
94
101
You can’t perform that action at this time.
0 commit comments