Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
fix: Image caption empty after pasting
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Nov 13, 2020
1 parent a3762d6 commit 1a9a262
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/nodes/CheckboxItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class CheckboxItem extends Node {
parseDOM: [
{
tag: `li[data-type="${this.name}"]`,
getAttrs: dom => ({
getAttrs: (dom: HTMLLIElement) => ({
checked: dom.className.includes("checked"),
}),
},
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/CodeFence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export default class CodeFence extends Node {
tag: ".code-block",
preserveWhitespace: "full",
contentElement: "code",
getAttrs: node => {
getAttrs: (dom: HTMLDivElement) => {
return {
language: node.dataset.language,
language: dom.dataset.language,
};
},
},
Expand Down
5 changes: 2 additions & 3 deletions src/nodes/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,12 @@ export default class Image extends Node {
parseDOM: [
{
tag: "div[class=image]",
getAttrs: (dom: HTMLElement) => {
getAttrs: (dom: HTMLDivElement) => {
const img = dom.getElementsByTagName("img")[0];
const caption = dom.getElementsByTagName("p")[0];

return {
src: img.getAttribute("src"),
alt: caption.innerText,
alt: img.getAttribute("alt"),
};
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/Notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class Notice extends Node {
tag: "div.notice-block",
preserveWhitespace: "full",
contentElement: "div:last-child",
getAttrs: dom => ({
getAttrs: (dom: HTMLDivElement) => ({
style: dom.className.includes("tip")
? "tip"
: dom.className.includes("warning")
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/OrderedList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class OrderedList extends Node {
parseDOM: [
{
tag: "ol",
getAttrs: (dom: HTMLElement) => ({
getAttrs: (dom: HTMLOListElement) => ({
order: dom.hasAttribute("start")
? parseInt(dom.getAttribute("start") || "1", 10)
: 1,
Expand Down

0 comments on commit 1a9a262

Please sign in to comment.