Skip to content

Commit d115b6a

Browse files
authored
'getSemanticHTML' method should return the correct code block markup when the root container is hidden (T1042310) (#32)
1 parent 6e75e94 commit d115b6a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

formats/code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CodeBlockContainer extends Container {
1515

1616
code(index, length) {
1717
const text = this.children
18-
.map(child => (child.length() <= 1 ? '' : child.domNode.innerText))
18+
.map(child => (child.length() <= 1 ? '' : child.domNode.textContent))
1919
.join('\n')
2020
.slice(index, index + length);
2121
return escapeText(text);

test/unit/core/quill.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,5 +856,25 @@ describe('Quill', function() {
856856

857857
expect(instance.getSemanticHTML()).toEqual(expected);
858858
});
859+
860+
it('should correctly convert hidden code blocks', function() {
861+
const instance = this.initialize(
862+
Quill,
863+
`<p>123</p>
864+
<pre>ab</pre>
865+
<p>45</p>`,
866+
this.container,
867+
{
868+
modules: {
869+
table: true,
870+
},
871+
},
872+
);
873+
const expected = '<p>123</p><pre>\nab\n</pre><p>45</p>';
874+
this.container.style.visibility = 'hidden';
875+
876+
expect(instance.getSemanticHTML()).toEqual(expected);
877+
this.container.style.visibility = '';
878+
});
859879
});
860880
});

0 commit comments

Comments
 (0)