Commit b2268b6
committed
The previous fix for #44 used parentElement.querySelector() to detect
existing <code> elements in the block, but this was too broad: it
blocked wrapping any new selection as long as any <code> existed
anywhere in the block, breaking the ability to apply inline code to
multiple non-contiguous selections (#46).
The correct scope for the check is the selection itself, not the
whole block. Using range.cloneContents().querySelector() only inspects
what the user has actually selected:
- If the selection contains an existing <code> → skip wrap (prevents #44)
- If the selection is clean, even if other <code> exist elsewhere
in the block → wrap as normal (fixes #46)
Closes #46
1 parent 908296f commit b2268b6
1 file changed
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | 91 | | |
97 | 92 | | |
98 | 93 | | |
99 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
| |||
0 commit comments