File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -289,6 +289,21 @@ export default class Cursor {
289289 return content . adoptElement ( node , this . win . document )
290290 }
291291
292+ // Check whether the cursor's closest parent element node matches
293+ // the given tagName (and optional className), and return that
294+ // parent if it does or null if not.
295+ getParentContainer ( tagName , className ) {
296+ const container = this . range . startContainer
297+
298+ if ( container . nodeType !== Node . TEXT_NODE ) return null
299+
300+ const parent = container . parentElement
301+ if ( parent . nodeName !== tagName ) return null
302+ if ( className && ! parent . classList . contains ( className ) ) return null
303+
304+ return parent
305+ }
306+
292307 // Currently we call triggerChange manually after format changes.
293308 // This is to prevent excessive triggering of the change event during
294309 // merge or split operations or other manipulations by scripts.
You can’t perform that action at this time.
0 commit comments