Skip to content

Commit

Permalink
🐛 fix #1269
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Aug 4, 2022
1 parent e7a4f6a commit f799408
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -105,6 +105,7 @@

### v3.8.16 / 2022-08

* [1269](https://github.com/Vanessa219/vditor/issues/1269) 代码块自动补全会包含链接引用和脚注 `修复缺陷`
* [1263](https://github.com/Vanessa219/vditor/issues/1263) 所见即所得和即使渲染只有空格输入时,不会触发 input 事件 `修复缺陷`
* [1264](https://github.com/Vanessa219/vditor/issues/1264) 链接中,会强制将&reg解析为 ® 字符 `修复缺陷`
* [1242](https://github.com/Vanessa219/vditor/issues/1242) 在即时渲染模式下表格源文件未对齐 `改进功能`
Expand Down
30 changes: 16 additions & 14 deletions src/ts/ir/input.ts
Expand Up @@ -148,21 +148,23 @@ export const input = (vditor: IVditor, range: Range, ignoreSpace = false, event?
html = blockElement.previousElementSibling.outerHTML + html;
blockElement.previousElementSibling.remove();
}
// 添加链接引用
vditor.ir.element.querySelectorAll("[data-type='link-ref-defs-block']").forEach((item) => {
if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
html += item.outerHTML;
item.remove();
}
});
if (!blockElement.innerText.startsWith("```")) {
// 添加链接引用
vditor.ir.element.querySelectorAll("[data-type='link-ref-defs-block']").forEach((item) => {
if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
html += item.outerHTML;
item.remove();
}
});

// 添加脚注
vditor.ir.element.querySelectorAll("[data-type='footnotes-block']").forEach((item) => {
if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
html += item.outerHTML;
item.remove();
}
});
// 添加脚注
vditor.ir.element.querySelectorAll("[data-type='footnotes-block']").forEach((item) => {
if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
html += item.outerHTML;
item.remove();
}
});
}
} else {
html = blockElement.innerHTML;
}
Expand Down
31 changes: 16 additions & 15 deletions src/ts/sv/inputEvent.ts
Expand Up @@ -140,22 +140,23 @@ export const inputEvent = (vditor: IVditor, event?: InputEvent) => {
html = blockElement.previousElementSibling.textContent + html;
blockElement.previousElementSibling.remove();
}
if (!blockElement.innerText.startsWith("```")) {
// 添加链接引用
vditor.sv.element.querySelectorAll("[data-type='link-ref-defs-block']").forEach((item, index) => {
if (index === 0 && item && !(blockElement as HTMLElement).isEqualNode(item.parentElement)) {
html += "\n" + item.parentElement.textContent;
item.parentElement.remove();
}
});

// 添加链接引用
vditor.sv.element.querySelectorAll("[data-type='link-ref-defs-block']").forEach((item, index) => {
if (index === 0 && item && !(blockElement as HTMLElement).isEqualNode(item.parentElement)) {
html += "\n" + item.parentElement.textContent;
item.parentElement.remove();
}
});

// 添加脚注
vditor.sv.element.querySelectorAll("[data-type='footnotes-link']").forEach((item, index) => {
if (index === 0 && item && !(blockElement as HTMLElement).isEqualNode(item.parentElement)) {
html += "\n" + item.parentElement.textContent;
item.parentElement.remove();
}
});
// 添加脚注
vditor.sv.element.querySelectorAll("[data-type='footnotes-link']").forEach((item, index) => {
if (index === 0 && item && !(blockElement as HTMLElement).isEqualNode(item.parentElement)) {
html += "\n" + item.parentElement.textContent;
item.parentElement.remove();
}
});
}
}
html = processSpinVditorSVDOM(html, vditor);
if (isSVElement) {
Expand Down
30 changes: 16 additions & 14 deletions src/ts/wysiwyg/input.ts
Expand Up @@ -108,21 +108,23 @@ export const input = (vditor: IVditor, range: Range, event?: InputEvent) => {
html = html.replace("<div><wbr><br></div>", "<li><p><wbr><br></p></li>");
}

// 添加链接引用
vditor.wysiwyg.element.querySelectorAll("[data-type='link-ref-defs-block']").forEach((item) => {
if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
html += item.outerHTML;
item.remove();
}
});
if (!blockElement.innerText.startsWith("```")) {
// 添加链接引用
vditor.wysiwyg.element.querySelectorAll("[data-type='link-ref-defs-block']").forEach((item) => {
if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
html += item.outerHTML;
item.remove();
}
});

// 添加脚注
vditor.wysiwyg.element.querySelectorAll("[data-type='footnotes-block']").forEach((item) => {
if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
html += item.outerHTML;
item.remove();
}
});
// 添加脚注
vditor.wysiwyg.element.querySelectorAll("[data-type='footnotes-block']").forEach((item) => {
if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
html += item.outerHTML;
item.remove();
}
});
}
} else {
html = blockElement.innerHTML;
}
Expand Down

0 comments on commit f799408

Please sign in to comment.