update: heading id repeat

This commit is contained in:
yanmao 2021-12-29 01:12:49 +08:00
parent a0a57ff573
commit b1660c49f0
1 changed files with 1 additions and 2 deletions

View File

@ -151,8 +151,7 @@ export default class<T extends HeadingOptions> extends BlockPlugin<T> {
}
let id = node.attributes('id');
const dataId = node.attributes(DATA_ID);
if (!id || dataId !== id) {
if (!id || $(`[id="${id}"]`).length > 1) {
id = node.attributes(DATA_ID) || getHashId(node);
node.attributes('id', id);
}