This repository was archived by the owner on May 5, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
packages/plugin-dom-helpers/src Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,32 @@ export class DomHelpers<T extends JWPluginConfig = JWPluginConfig> extends JWPlu
175
175
}
176
176
await this . editor . dispatcher . dispatchHooks ( '@redraw' ) ;
177
177
}
178
+ /**
179
+ * Prepend a DOM Node to another DOM Node's children.
180
+ *
181
+ * @param params
182
+ */
183
+ async prepend ( fromDomNode : Node , toDomNode : Node ) : Promise < void > {
184
+ const toNodes = this . getNodes ( toDomNode ) ;
185
+ const toNode = toNodes [ toNodes . length - 1 ] ;
186
+ for ( const fromNode of this . getNodes ( fromDomNode ) . reverse ( ) ) {
187
+ fromNode . prepend ( toNode ) ;
188
+ }
189
+ await this . editor . dispatcher . dispatchHooks ( '@redraw' ) ;
190
+ }
191
+ /**
192
+ * Append a DOM Node to another DOM Node's children.
193
+ *
194
+ * @param params
195
+ */
196
+ async append ( fromDomNode : Node , toDomNode : Node ) : Promise < void > {
197
+ const toNodes = this . getNodes ( toDomNode ) ;
198
+ const toNode = toNodes [ toNodes . length - 1 ] ;
199
+ for ( const fromNode of this . getNodes ( fromDomNode ) ) {
200
+ fromNode . append ( toNode ) ;
201
+ }
202
+ await this . editor . dispatcher . dispatchHooks ( '@redraw' ) ;
203
+ }
178
204
/**
179
205
* Insert html content before, after or inside a DOM Node. If no DOM Node
180
206
* was provided, empty the range and insert the html content before the it.
You can’t perform that action at this time.
0 commit comments