mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
core: fix Cannot read properties of undefined (reading 'length') error
This commit is contained in:
@@ -44,28 +44,30 @@ function wrapIntoHTMLDocument(input) {
|
||||
|
||||
export function extractFirstParagraph(html) {
|
||||
let text = "";
|
||||
let start = false;
|
||||
const parser = new Parser(
|
||||
{
|
||||
onopentag: (name) => {
|
||||
if (name === "p") start = true;
|
||||
},
|
||||
onclosetag: (name) => {
|
||||
if (name === "p") {
|
||||
start = false;
|
||||
parser.pause();
|
||||
parser.reset();
|
||||
try {
|
||||
let start = false;
|
||||
const parser = new Parser(
|
||||
{
|
||||
onopentag: (name) => {
|
||||
if (name === "p") start = true;
|
||||
},
|
||||
onclosetag: (name) => {
|
||||
if (name === "p") {
|
||||
start = false;
|
||||
parser.pause();
|
||||
parser.reset();
|
||||
}
|
||||
},
|
||||
ontext: (data) => {
|
||||
if (start) text += data;
|
||||
}
|
||||
},
|
||||
ontext: (data) => {
|
||||
if (start) text += data;
|
||||
{
|
||||
lowerCaseTags: false,
|
||||
decodeEntities: true
|
||||
}
|
||||
},
|
||||
{
|
||||
lowerCaseTags: false,
|
||||
decodeEntities: true
|
||||
}
|
||||
);
|
||||
parser.end(html);
|
||||
);
|
||||
parser.end(html);
|
||||
} catch (e) {}
|
||||
return text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user