Compare commits
2 Commits
a2303841ec
...
6dc47f6672
| Author | SHA1 | Date | |
|---|---|---|---|
| 6dc47f6672 | |||
| da108f25d4 |
@@ -57,6 +57,10 @@ function Article({ cache }) {
|
||||
setPConv(prevPConv => [...prevPConv, n]);
|
||||
};
|
||||
|
||||
const isCodeBlock = (v) => {
|
||||
return v.localName === 'pre' || v.localName === 'code' || (v.children?.length === 1 && v.children[0].localName === 'code');
|
||||
};
|
||||
|
||||
const nodes = useMemo(() => {
|
||||
if (story && story.text) {
|
||||
let div = document.createElement('div');
|
||||
@@ -105,7 +109,7 @@ function Article({ cache }) {
|
||||
:
|
||||
<React.Fragment key={k}>
|
||||
<v.localName dangerouslySetInnerHTML={v.innerHTML ? { __html: v.innerHTML } : null} />
|
||||
{(v.localName === 'pre' || v.localName === 'code') && <button onClick={() => pConvert(k)}>Convert Code to Paragraph</button>}
|
||||
{isCodeBlock(v) && <button onClick={() => pConvert(k)}>Convert Code to Paragraph</button>}
|
||||
</React.Fragment>
|
||||
)
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user