@eeacms/volto-slate-footnote 8.0.1 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/package.json +1 -1
- package/src/editor/utils.js +6 -12
- package/src/editor/utils.test.js +2 -24
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
-
### [8.0.
|
|
7
|
+
### [8.0.2](https://github.com/eea/volto-slate-footnote/compare/8.0.1...8.0.2) - 23 April 2026
|
|
8
|
+
|
|
9
|
+
#### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
- fix: Hydration warnings - refs #302095 [Alin Voinea - [`6dc22d5`](https://github.com/eea/volto-slate-footnote/commit/6dc22d5e7f459d2177dbafb1fbb02e5e71a6734c)]
|
|
12
|
+
|
|
13
|
+
### [8.0.1](https://github.com/eea/volto-slate-footnote/compare/8.0.0...8.0.1) - 9 April 2026
|
|
8
14
|
|
|
9
15
|
## [8.0.0](https://github.com/eea/volto-slate-footnote/compare/7.2.6...8.0.0) - 30 March 2026
|
|
10
16
|
|
package/package.json
CHANGED
package/src/editor/utils.js
CHANGED
|
@@ -295,18 +295,12 @@ const iterateFootnoteObj = (notesObjResultTemp, node, parentUid) => {
|
|
|
295
295
|
};
|
|
296
296
|
|
|
297
297
|
export function isValidHTML(htmlString) {
|
|
298
|
-
if (
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const parser = new DOMParser();
|
|
305
|
-
const parsedDocument = parser.parseFromString(htmlString, 'text/html');
|
|
306
|
-
const errors = parsedDocument.querySelectorAll('parsererror');
|
|
307
|
-
return errors.length === 0;
|
|
308
|
-
}
|
|
309
|
-
return false;
|
|
298
|
+
if (typeof htmlString !== 'string') return false;
|
|
299
|
+
const text = htmlString.trim();
|
|
300
|
+
if (!text) return false;
|
|
301
|
+
// Keep server/client output deterministic for hydration by using
|
|
302
|
+
// the same lightweight HTML detection in both environments.
|
|
303
|
+
return /<\/?[a-z][\s\S]*>/i.test(text);
|
|
310
304
|
}
|
|
311
305
|
|
|
312
306
|
const cleanUrls = (urls, text) => {
|
package/src/editor/utils.test.js
CHANGED
|
@@ -279,28 +279,12 @@ describe('getAllBlocksAndSlateFields', () => {
|
|
|
279
279
|
});
|
|
280
280
|
|
|
281
281
|
describe('isValidHTML', () => {
|
|
282
|
-
beforeAll(() => {
|
|
283
|
-
global.DOMParser = class {
|
|
284
|
-
parseFromString(str) {
|
|
285
|
-
const doc = {
|
|
286
|
-
querySelectorAll: (selector) => {
|
|
287
|
-
if (selector === 'parsererror' && str.includes('<error>')) {
|
|
288
|
-
return [{}]; // Simulate an error
|
|
289
|
-
}
|
|
290
|
-
return [];
|
|
291
|
-
},
|
|
292
|
-
};
|
|
293
|
-
return doc;
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
});
|
|
297
|
-
|
|
298
282
|
test('returns true for valid HTML', () => {
|
|
299
283
|
expect(isValidHTML('<div>Hello</div>')).toBe(true);
|
|
300
284
|
});
|
|
301
285
|
|
|
302
|
-
test('returns false for
|
|
303
|
-
expect(isValidHTML('
|
|
286
|
+
test('returns false for plain text', () => {
|
|
287
|
+
expect(isValidHTML('Invalid HTML')).toBe(false);
|
|
304
288
|
});
|
|
305
289
|
});
|
|
306
290
|
|
|
@@ -361,12 +345,6 @@ describe('renderTextWithLinks', () => {
|
|
|
361
345
|
});
|
|
362
346
|
|
|
363
347
|
it('should render HTML when zoteroId is provided', () => {
|
|
364
|
-
global.__CLIENT__ = true;
|
|
365
|
-
global.DOMParser = class {
|
|
366
|
-
parseFromString() {
|
|
367
|
-
return { querySelectorAll: () => [] };
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
348
|
const text = '<em>Test</em> content';
|
|
371
349
|
const result = renderTextWithLinks(text, 'zotero123');
|
|
372
350
|
expect(result).toBeDefined();
|