File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ export default function extractHeadings(doc: Node) {
3131 }
3232
3333 doc . descendants ( ( node , offset ) => {
34- // Don't descent into detials blocks - their headings are hidden
35- if ( node . type . name === 'details' ) {
34+ // Don't descent into details/blockquote nodes - their headings are hidden
35+ if ( node . type . name === 'details' || node . type . name === 'blockquote' ) {
3636 return false
3737 }
3838 if ( node . type . name !== 'heading' ) {
Original file line number Diff line number Diff line change 33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6+ import Blockquote from '@tiptap/extension-blockquote'
67import Details from '../../nodes/Details.js'
78import Heading from '../../nodes/Heading.js'
89import extractHeadings from '../../plugins/extractHeadings.ts'
@@ -50,6 +51,19 @@ describe('extractHeadings', () => {
5051 expect ( headings [ 0 ] . text ) . toBe ( 'Visible heading' )
5152 } )
5253
54+ it ( 'ignores headings inside a block quote block' , ( ) => {
55+ const content = `
56+ <h1>Visible heading</h1>
57+ <blockquote>
58+ <h1>Quoted heading</h1>
59+ </blockquote>
60+ `
61+ const doc = prepareDoc ( content , [ Blockquote ] )
62+ const headings = extractHeadings ( doc )
63+ expect ( headings ) . toHaveLength ( 1 )
64+ expect ( headings [ 0 ] . text ) . toBe ( 'Visible heading' )
65+ } )
66+
5367 it ( 'creates unique ids with a counter' , ( ) => {
5468 const content = `
5569 <h1>Level 1 heading</h1>
You can’t perform that action at this time.
0 commit comments