Skip to content

Commit

Permalink
fix: markdown: default image width to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
Wattenberger committed Aug 30, 2022
1 parent 0d765a7 commit ef94a37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion blocks/file-blocks/markdown-edit/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ export function makeExtensions({
!(match = /^https?:\/\/.*/.exec(fullText))
)
return -1;
const hasIncludedLink = match[0].indexOf("](http") !== -1;
if (hasIncludedLink) return -1;
return cx.addElement(
cx.elt("URL", start, start + 1 + match[0].length)
cx.elt("URL", start, start + 1 + firstMatch.length)
);
},
},
Expand Down
3 changes: 1 addition & 2 deletions blocks/file-blocks/markdown-edit/image-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ImageWidget extends WidgetType {
if (Number.isFinite(+style)) return `${style}px`;
return style;
};
image.style.width = parseStyle(this.width) || "auto";
image.style.width = parseStyle(this.width) || "100%";
image.style.maxWidth = "100%";
image.style.height = parseStyle(this.height) || "auto";
image.alt = this.alt || "";
Expand Down Expand Up @@ -97,7 +97,6 @@ export const images = ({
enter: ({ type, from, to }) => {
if (type.name === "Image") {
const text = state.doc.sliceString(from, to);
console.log(text);
const result = imageRegex.exec(text);

if (result && result.groups && result.groups.url) {
Expand Down

0 comments on commit ef94a37

Please sign in to comment.