Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Markdown paste (#1077)

Oleg Isonena7ad9a14cab4
diff --git a/apps/builder/app/shared/copy-paste/init-copy-paste.ts b/apps/builder/app/shared/copy-paste/init-copy-paste.ts
index 12e47e15cd..406b7b61e8 100644
--- a/apps/builder/app/shared/copy-paste/init-copy-paste.ts
+++ b/apps/builder/app/shared/copy-paste/init-copy-paste.ts
@@ -28,25 +28,26 @@ const isValidClipboardEvent = (event: ClipboardEvent) => {
return true;
};
-type Props = {
+type Options = {
mimeType?: string;
- onCopy: () => undefined | string;
- onCut: () => undefined | string;
- onPaste: (data: string) => void;
+ onCopy?: () => undefined | string;
+ onCut?: () => undefined | string;
+ onPaste?: (data: string) => void;
};
-export const initCopyPaste = (props: Props) => {
- const { mimeType = "application/json" } = props;
+export const initCopyPaste = (options: Options) => {
+ const { mimeType = "application/json", onCopy, onCut, onPaste } = options;
const handleCopy = (event: ClipboardEvent) => {
if (
+ onCopy === undefined ||
event.clipboardData === null ||
isValidClipboardEvent(event) === false
) {
return;
}
- const data = props.onCopy();
+ const data = onCopy();
if (data === undefined) {
return;
}
@@ -58,13 +59,14 @@ export const initCopyPaste = (props: Props) => {
const handleCut = (event: ClipboardEvent) => {
if (
+ onCut === undefined ||
event.clipboardData === null ||
isValidClipboardEvent(event) === false
) {
return;
}
- const data = props.onCut();
+ const data = onCut();
if (data === undefined) {
return;
}
@@ -76,6 +78,7 @@ export const initCopyPaste = (props: Props) => {
const handlePaste = (event: ClipboardEvent) => {
if (
+ onPaste === undefined ||
event.clipboardData === null ||
// we might want a separate predicate for paste,
// but for now the logic is the same
@@ -86,16 +89,31 @@ export const initCopyPaste = (props: Props) => {
// this shouldn't matter, but just in case
event.preventDefault();
- props.onPaste(event.clipboardData.getData(mimeType));
+ const data = event.clipboardData.getData(mimeType).trim();
+ if (data) {
+ onPaste(data);
+ }
};
- document.addEventListener("copy", handleCopy);
- document.addEventListener("cut", handleCut);
- document.addEventListener("paste", handlePaste);
+ if (onCopy) {
+ document.addEventListener("copy", handleCopy);
+ }
+ if (onCut) {
+ document.addEventListener("cut", handleCut);
+ }
+ if (onPaste) {
+ document.addEventListener("paste", handlePaste);
+ }
return () => {
- document.removeEventListener("copy", handleCopy);
- document.removeEventListener("cut", handleCut);
- document.removeEventListener("paste", handlePaste);
+ if (onCopy) {
+ document.removeEventListener("copy", handleCopy);
+ }
+ if (onCut) {
+ document.removeEventListener("cut", handleCut);
+ }
+ if (onPaste) {
+ document.removeEventListener("paste", handlePaste);
+ }
};
};
diff --git a/apps/builder/app/shared/copy-paste/plugin-instance.ts b/apps/builder/app/shared/copy-paste/plugin-instance.ts
index c841a51b94..69d2324af7 100644
--- a/apps/builder/app/shared/copy-paste/plugin-instance.ts
+++ b/apps/builder/app/shared/copy-paste/plugin-instance.ts
@@ -30,7 +30,6 @@ import {
insertInstanceMutable,
} from "../tree-utils";
import { deleteInstance } from "../instance-utils";
-import { initCopyPaste } from "./init-copy-paste";
const version = "@webstudio/instance/v0.1";
@@ -98,16 +97,18 @@ const stringify = (data: InstanceData) => {
const ClipboardData = z.object({ [version]: InstanceData });
-const parse = (text: string): InstanceData | undefined => {
+const parse = (clipboardData: string): InstanceData | undefined => {
try {
- const data = ClipboardData.parse(JSON.parse(text));
+ const data = ClipboardData.parse(JSON.parse(clipboardData));
return data[version];
} catch {
return;
}
};
-const onPaste = (clipboardData: string) => {
+export const mimeType = "application/json";
+
+export const onPaste = (clipboardData: string) => {
const data = parse(clipboardData);
if (data === undefined) {
return;
@@ -147,7 +148,7 @@ const onPaste = (clipboardData: string) => {
selectedInstanceIdStore.set(data.instance.id);
};
-const onCopy = () => {
+export const onCopy = () => {
const selectedInstanceId = selectedInstanceIdStore.get();
if (selectedInstanceId === undefined) {
return;
@@ -159,7 +160,7 @@ const onCopy = () => {
return stringify(data);
};
-const onCut = () => {
+export const onCut = () => {
const selectedInstanceId = selectedInstanceIdStore.get();
if (selectedInstanceId === undefined) {
return;
@@ -174,11 +175,3 @@ const onCut = () => {
}
return stringify(data);
};
-
-export const init = () => {
- return initCopyPaste({
- onCopy,
- onCut,
- onPaste,
- });
-};
diff --git a/apps/builder/app/shared/copy-paste/plugin-markdown.test.ts b/apps/builder/app/shared/copy-paste/plugin-markdown.test.ts
new file mode 100644
index 0000000000..07bcc44aa0
--- /dev/null
+++ b/apps/builder/app/shared/copy-paste/plugin-markdown.test.ts
@@ -0,0 +1,586 @@
+import { describe, expect } from "@jest/globals";
+import { Instance, Prop } from "@webstudio-is/project-build";
+import { parse } from "./plugin-markdown";
+
+const parseInstanceData = (data?: {
+ children: Instance["children"];
+ props: Array<Prop>;
+}) => {
+ if (data === undefined) {
+ return;
+ }
+ const { children, props } = data;
+ for (const child of children) {
+ if (child.type === "instance") {
+ Instance.parse(child);
+ parseInstanceData({ children: child.children, props });
+ }
+ }
+ for (const prop of props) {
+ Prop.parse(prop);
+ }
+ return { children, props };
+};
+
+const options = { generateId: () => "123" };
+
+describe("Plugin Markdown", () => {
+ test("paragraph", () => {
+ expect(parseInstanceData(parse("xyz", options))).toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "xyz",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("h1", () => {
+ expect(parseInstanceData(parse("# heading", options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "heading",
+ },
+ ],
+ "component": "Heading",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "tag",
+ "type": "string",
+ "value": "h1",
+ },
+ ],
+ }
+ `);
+ });
+
+ test("h6", () => {
+ expect(parseInstanceData(parse("###### heading", options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "heading",
+ },
+ ],
+ "component": "Heading",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "tag",
+ "type": "string",
+ "value": "h6",
+ },
+ ],
+ }
+ `);
+ });
+
+ test("bold 1", () => {
+ expect(parseInstanceData(parse("__bold__", options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "bold",
+ },
+ ],
+ "component": "Bold",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("bold 2", () => {
+ expect(parseInstanceData(parse("**bold**", options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "bold",
+ },
+ ],
+ "component": "Bold",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("italic 1", () => {
+ expect(parseInstanceData(parse("_italic_", options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "italic",
+ },
+ ],
+ "component": "Italic",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("italic 2", () => {
+ expect(parseInstanceData(parse("*italic*", options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "italic",
+ },
+ ],
+ "component": "Italic",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("link", () => {
+ expect(parseInstanceData(parse('[link](/uri "Title")', options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "link",
+ },
+ ],
+ "component": "Link",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "href",
+ "type": "string",
+ "value": "/uri",
+ },
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "title",
+ "type": "string",
+ "value": "Title",
+ },
+ ],
+ }
+ `);
+ });
+
+ test("image", () => {
+ expect(parseInstanceData(parse('![foo](/url "title")', options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [],
+ "component": "Image",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "src",
+ "type": "string",
+ "value": "/url",
+ },
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "title",
+ "type": "string",
+ "value": "title",
+ },
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "alt",
+ "type": "string",
+ "value": "foo",
+ },
+ ],
+ }
+ `);
+ });
+
+ test("hard line break", () => {
+ expect(
+ parseInstanceData(
+ parse(
+ `foo
+ baz`,
+ options
+ )
+ )
+ ).toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "foo",
+ },
+ {
+ "type": "text",
+ "value": "baz",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("soft line break", () => {
+ expect(
+ parseInstanceData(
+ parse(
+ `foo
+ baz`,
+ options
+ )
+ )
+ ).toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "foo
+ baz",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("blockquote", () => {
+ expect(parseInstanceData(parse("> bar", options))).toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "bar",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "Blockquote",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("inline code", () => {
+ expect(parseInstanceData(parse("`foo`", options))).toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "foo",
+ },
+ ],
+ "component": "InlineCode",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ test("code", () => {
+ expect(parseInstanceData(parse("```js meta\nfoo\n```", options)))
+ .toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "foo",
+ },
+ ],
+ "component": "Code",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "lang",
+ "type": "string",
+ "value": "js",
+ },
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "meta",
+ "type": "string",
+ "value": "meta",
+ },
+ ],
+ }
+ `);
+ });
+
+ test("list unordered", () => {
+ expect(parseInstanceData(parse("- one", options))).toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "one",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "ListItem",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "List",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "ordered",
+ "type": "boolean",
+ "value": false,
+ },
+ ],
+ }
+ `);
+ });
+
+ test("list ordered", () => {
+ expect(parseInstanceData(parse("3. one", options))).toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "children": [
+ {
+ "type": "text",
+ "value": "one",
+ },
+ ],
+ "component": "Paragraph",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "ListItem",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "component": "List",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "ordered",
+ "type": "boolean",
+ "value": true,
+ },
+ {
+ "id": "123",
+ "instanceId": "123",
+ "name": "start",
+ "type": "number",
+ "value": 3,
+ },
+ ],
+ }
+ `);
+ });
+
+ test("thematic break | separator", () => {
+ expect(parseInstanceData(parse("---", options))).toMatchInlineSnapshot(`
+ {
+ "children": [
+ {
+ "children": [],
+ "component": "Separator",
+ "id": "123",
+ "type": "instance",
+ },
+ ],
+ "props": [],
+ }
+ `);
+ });
+
+ // @todo For some reason doesn't work
+ test.skip("strikethrough", () => {
+ expect(
+ parseInstanceData(parse("~One~ ~~two~~ ~~~three~~~.", options))
+ ).toMatchInlineSnapshot();
+ });
+});
diff --git a/apps/builder/app/shared/copy-paste/plugin-markdown.ts b/apps/builder/app/shared/copy-paste/plugin-markdown.ts
new file mode 100644
index 0000000000..c1df29777f
--- /dev/null
+++ b/apps/builder/app/shared/copy-paste/plugin-markdown.ts
@@ -0,0 +1,222 @@
+import store from "immerhin";
+import { gfm } from "micromark-extension-gfm";
+import type { Root } from "mdast";
+import { fromMarkdown } from "mdast-util-from-markdown";
+import type { Instance, Prop } from "@webstudio-is/project-build";
+import { utils } from "@webstudio-is/project";
+import { nanoid } from "nanoid";
+import {
+ createInstancesIndex,
+ findClosestDroppableTarget,
+ insertInstanceMutable,
+} from "../tree-utils";
+import {
+ instancesIndexStore,
+ propsStore,
+ rootInstanceContainer,
+ selectedInstanceIdStore,
+} from "../nano-states";
+
+const micromarkOptions = { extensions: [gfm()] };
+
+export const mimeType = "text/plain";
+
+// @todo Definition, Strikethrough, Table
+const astTypeComponentMap: Record<string, Instance["component"]> = {
+ paragraph: "Paragraph",
+ heading: "Heading",
+ strong: "Bold",
+ emphasis: "Italic",
+ link: "Link",
+ image: "Image",
+ blockquote: "Blockquote",
+ code: "Code",
+ inlineCode: "InlineCode",
+ list: "List",
+ listItem: "ListItem",
+ thematicBreak: "Separator",
+};
+
+type Options = { generateId?: typeof nanoid };
+
+const createInstance = (
+ {
+ component,
+ node,
+ props,
+ }: {
+ component: Instance["component"];
+ node: Root["children"][number];
+ props: Array<Prop>;
+ },
+ options: Options
+) => {
+ const { generateId = nanoid } = options;
+ return utils.tree.createInstance({
+ id: generateId(),
+ component,
+ children:
+ "children" in node ? toInstanceData(node, options, props).children : [],
+ });
+};
+
+const toInstanceData = (
+ ast: { children: Root["children"] },
+ options: Options = {},
+ props: Array<Prop> = []
+): { children: Instance["children"]; props: Array<Prop> } => {
+ const { generateId = nanoid } = options;
+ const children: Instance["children"] = [];
+
+ for (const child of ast.children) {
+ if (child.type === "text") {
+ children.push({
+ type: child.type,
+ value: child.value,
+ });
+ continue;
+ }
+
+ const component = astTypeComponentMap[child.type];
+ if (component) {
+ const instance = createInstance(
+ { component, node: child, props },
+ options
+ );
+ children.push(instance);
+ if (child.type === "heading") {
+ props.push({
+ id: generateId(),
+ type: "string",
+ name: "tag",
+ instanceId: instance.id,
+ value: `h${child.depth}`,
+ });
+ }
+ if (child.type === "link") {
+ props.push({
+ id: generateId(),
+ type: "string",
+ name: "href",
+ instanceId: instance.id,
+ value: child.url,
+ });
+ }
+ if (child.type === "image") {
+ props.push({
+ id: generateId(),
+ type: "string",
+ name: "src",
+ instanceId: instance.id,
+ value: child.url,
+ });
+ }
+ if (child.type === "inlineCode") {
+ instance.children.push({
+ type: "text",
+ value: child.value,
+ });
+ }
+ if (child.type === "code") {
+ instance.children.push({
+ type: "text",
+ value: child.value,
+ });
+ if (child.lang) {
+ props.push({
+ id: generateId(),
+ type: "string",
+ name: "lang",
+ instanceId: instance.id,
+ value: child.lang,
+ });
+ }
+ if (child.meta) {
+ props.push({
+ id: generateId(),
+ type: "string",
+ name: "meta",
+ instanceId: instance.id,
+ value: child.meta,
+ });
+ }
+ }
+ if (child.type === "list") {
+ if (typeof child.ordered === "boolean") {
+ props.push({
+ id: generateId(),
+ type: "boolean",
+ name: "ordered",
+ instanceId: instance.id,
+ value: child.ordered,
+ });
+ }
+ if (typeof child.start === "number") {
+ props.push({
+ id: generateId(),
+ type: "number",
+ name: "start",
+ instanceId: instance.id,
+ value: child.start,
+ });
+ }
+ }
+
+ if ("title" in child && child.title) {
+ props.push({
+ id: generateId(),
+ type: "string",
+ name: "title",
+ instanceId: instance.id,
+ value: child.title,
+ });
+ }
+ if ("alt" in child && child.alt) {
+ props.push({
+ id: generateId(),
+ type: "string",
+ name: "alt",
+ instanceId: instance.id,
+ value: child.alt,
+ });
+ }
+ }
+ }
+ return { children, props };
+};
+
+export const parse = (clipboardData: string, options?: Options) => {
+ const ast = fromMarkdown(clipboardData, micromarkOptions);
+ if (ast.children.length === 0) {
+ return;
+ }
+ return toInstanceData(ast, options);
+};
+
+export const onPaste = (clipboardData: string) => {
+ const data = parse(clipboardData);
+ if (data === undefined) {
+ return;
+ }
+
+ const dropTarget = findClosestDroppableTarget(
+ instancesIndexStore.get(),
+ selectedInstanceIdStore.get()
+ );
+ store.createTransaction(
+ [rootInstanceContainer, propsStore],
+ (rootInstance, props) => {
+ const instancesIndex = createInstancesIndex(rootInstance);
+ // We are inserting backwards, so we need to reverse the order
+ data.children.reverse();
+ for (const child of data.children) {
+ if (child.type === "instance") {
+ insertInstanceMutable(instancesIndex, child, dropTarget);
+ }
+ }
+ for (const prop of data.props) {
+ props.set(prop.id, prop);
+ }
+ }
+ );
+};
diff --git a/apps/builder/app/shared/copy-paste/plugins.ts b/apps/builder/app/shared/copy-paste/plugins.ts
index f7ad251655..4f80f0cf8d 100644
--- a/apps/builder/app/shared/copy-paste/plugins.ts
+++ b/apps/builder/app/shared/copy-paste/plugins.ts
@@ -1 +1,2 @@
export * as instance from "./plugin-instance";
+export * as mardkown from "./plugin-markdown";
diff --git a/apps/builder/app/shared/copy-paste/use-copy-paste.ts b/apps/builder/app/shared/copy-paste/use-copy-paste.ts
index 0f1ee4454d..9f5b331498 100644
--- a/apps/builder/app/shared/copy-paste/use-copy-paste.ts
+++ b/apps/builder/app/shared/copy-paste/use-copy-paste.ts
@@ -1,13 +1,12 @@
import { useEffect } from "react";
+import { initCopyPaste } from "./init-copy-paste";
import * as plugins from "./plugins";
const initPlugins = () => {
const cleanups: Array<() => void> = [];
for (const plugin of Object.values(plugins)) {
- if (plugin.init) {
- cleanups.push(plugin.init());
- }
+ cleanups.push(initCopyPaste(plugin));
}
return () => {
diff --git a/apps/builder/package.json b/apps/builder/package.json
index c6952827a5..429ee525cc 100644
--- a/apps/builder/package.json
+++ b/apps/builder/package.json
@@ -74,6 +74,9 @@
"lodash.noop": "^3.0.1",
"lodash.snakecase": "^4.1.1",
"match-sorter": "^6.3.1",
+ "mdast-util-from-markdown": "^1.3.0",
+ "micromark": "^3.1.0",
+ "micromark-extension-gfm": "^2.0.1",
"mitt": "^3.0.0",
"nanoid": "^3.2.0",
"nanostores": "^0.7.1",
diff --git a/apps/builder/remix.config.js b/apps/builder/remix.config.js
index 9967365577..1897ee8fe3 100644
--- a/apps/builder/remix.config.js
+++ b/apps/builder/remix.config.js
@@ -18,6 +18,11 @@ module.exports = {
"djb2a",
"nanostores",
"@nanostores/react",
+ /micromark/,
+ "decode-named-character-reference",
+ "character-entities",
+ /mdast-/,
+ "unist-util-stringify-position",
],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3bac490858..aca9d22ae4 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -130,6 +130,9 @@ importers:
lodash.noop: ^3.0.1
lodash.snakecase: ^4.1.1
match-sorter: ^6.3.1
+ mdast-util-from-markdown: ^1.3.0
+ micromark: ^3.1.0
+ micromark-extension-gfm: ^2.0.1
mitt: ^3.0.0
nanoid: ^3.2.0
nanostores: ^0.7.1
@@ -212,6 +215,9 @@ importers:
lodash.noop: 3.0.1
lodash.snakecase: 4.1.1
match-sorter: 6.3.1
+ mdast-util-from-markdown: 1.3.0
+ micromark: 3.1.0
+ micromark-extension-gfm: 2.0.1
mitt: 3.0.0
nanoid: 3.3.4
nanostores: 0.7.1
@@ -10121,7 +10127,6 @@ packages:
resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==}
dependencies:
'@types/ms': 0.7.31
- dev: true
/@types/eslint-scope/3.7.4:
resolution: {integrity: sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==}
@@ -10312,7 +10317,6 @@ packages:
/@types/ms/0.7.31:
resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==}
- dev: true
/@types/node-fetch/2.6.2:
resolution: {integrity: sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==}
@@ -12266,7 +12270,6 @@ packages:
/character-entities/2.0.2:
resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==}
- dev: true
/character-reference-invalid/1.1.4:
resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==}
@@ -13018,7 +13021,6 @@ packages:
resolution: {integrity: sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==}
dependencies:
character-entities: 2.0.2
- dev: true
/decode-uri-component/0.2.0:
resolution: {integrity: sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==}
@@ -13128,7 +13130,6 @@ packages:
/dequal/2.0.3:
resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
engines: {node: '>=6'}
- dev: true
/des.js/1.0.1:
resolution: {integrity: sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==}
@@ -13203,7 +13204,6 @@ packages:
/diff/5.1.0:
resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==}
engines: {node: '>=0.3.1'}
- dev: true
/diffie-hellman/5.0.3:
resolution: {integrity: sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==}
@@ -16924,7 +16924,6 @@ packages:
/kleur/4.1.5:
resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==}
engines: {node: '>=6'}
- dev: true
/klona/2.0.5:
resolution: {integrity: sha512-pJiBpiXMbt7dkzXe8Ghj/u4FfXOOa98fPW+bihOJ4SjnoijweJrNThJfd3ifXpXhREjpoF2mZVH1GfS9LV3kHQ==}
@@ -17254,7 +17253,6 @@ packages:
uvu: 0.5.6
transitivePeerDependencies:
- supports-color
- dev: true
/mdast-util-frontmatter/1.0.1:
resolution: {integrity: sha512-JjA2OjxRqAa8wEG8hloD0uTU0kdn8kbtOWpPP94NBkfAlbxn4S8gCGf/9DwFtEeGPXrDcNXdiDjVaRdUFqYokw==}
@@ -17365,7 +17363,6 @@ packages:
resolution: {integrity: sha512-tGvhT94e+cVnQt8JWE9/b3cUQZWS732TJxXHktvP+BYo62PpYD53Ls/6cC60rW21dW+txxiM4zMdc6abASvZKA==}
dependencies:
'@types/mdast': 3.0.10
- dev: true
/mdn-data/2.0.14:
resolution: {integrity: sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==}
@@ -17477,7 +17474,6 @@ packages:
micromark-util-symbol: 1.0.1
micromark-util-types: 1.0.2
uvu: 0.5.6
- dev: true
/micromark-extension-frontmatter/1.0.0:
resolution: {integrity: sha512-EXjmRnupoX6yYuUJSQhrQ9ggK0iQtQlpi6xeJzVD5xscyAI+giqco5fdymayZhJMbIFecjnE2yz85S9NzIgQpg==}
@@ -17487,6 +17483,79 @@ packages:
micromark-util-symbol: 1.0.1
dev: true
+ /micromark-extension-gfm-autolink-literal/1.0.3:
+ resolution: {integrity: sha512-i3dmvU0htawfWED8aHMMAzAVp/F0Z+0bPh3YrbTPPL1v4YAlCZpy5rBO5p0LPYiZo0zFVkoYh7vDU7yQSiCMjg==}
+ dependencies:
+ micromark-util-character: 1.1.0
+ micromark-util-sanitize-uri: 1.1.0
+ micromark-util-symbol: 1.0.1
+ micromark-util-types: 1.0.2
+ uvu: 0.5.6
+ dev: false
+
+ /micromark-extension-gfm-footnote/1.0.4:
+ resolution: {integrity: sha512-E/fmPmDqLiMUP8mLJ8NbJWJ4bTw6tS+FEQS8CcuDtZpILuOb2kjLqPEeAePF1djXROHXChM/wPJw0iS4kHCcIg==}
+ dependencies:
+ micromark-core-commonmark: 1.0.6
+ micromark-factory-space: 1.0.0
+ micromark-util-character: 1.1.0
+ micromark-util-normalize-identifier: 1.0.0
+ micromark-util-sanitize-uri: 1.1.0
+ micromark-util-symbol: 1.0.1
+ micromark-util-types: 1.0.2
+ uvu: 0.5.6
+ dev: false
+
+ /micromark-extension-gfm-strikethrough/1.0.4:
+ resolution: {integrity: sha512-/vjHU/lalmjZCT5xt7CcHVJGq8sYRm80z24qAKXzaHzem/xsDYb2yLL+NNVbYvmpLx3O7SYPuGL5pzusL9CLIQ==}
+ dependencies:
+ micromark-util-chunked: 1.0.0
+ micromark-util-classify-character: 1.0.0
+ micromark-util-resolve-all: 1.0.0
+ micromark-util-symbol: 1.0.1
+ micromark-util-types: 1.0.2
+ uvu: 0.5.6
+ dev: false
+
+ /micromark-extension-gfm-table/1.0.5:
+ resolution: {integrity: sha512-xAZ8J1X9W9K3JTJTUL7G6wSKhp2ZYHrFk5qJgY/4B33scJzE2kpfRL6oiw/veJTbt7jiM/1rngLlOKPWr1G+vg==}
+ dependencies:
+ micromark-factory-space: 1.0.0
+ micromark-util-character: 1.1.0
+ micromark-util-symbol: 1.0.1
+ micromark-util-types: 1.0.2
+ uvu: 0.5.6
+ dev: false
+
+ /micromark-extension-gfm-tagfilter/1.0.1:
+ resolution: {integrity: sha512-Ty6psLAcAjboRa/UKUbbUcwjVAv5plxmpUTy2XC/3nJFL37eHej8jrHrRzkqcpipJliuBH30DTs7+3wqNcQUVA==}
+ dependencies:
+ micromark-util-types: 1.0.2
+ dev: false
+
+ /micromark-extension-gfm-task-list-item/1.0.3:
+ resolution: {integrity: sha512-PpysK2S1Q/5VXi72IIapbi/jliaiOFzv7THH4amwXeYXLq3l1uo8/2Be0Ac1rEwK20MQEsGH2ltAZLNY2KI/0Q==}
+ dependencies:
+ micromark-factory-space: 1.0.0
+ micromark-util-character: 1.1.0
+ micromark-util-symbol: 1.0.1
+ micromark-util-types: 1.0.2
+ uvu: 0.5.6
+ dev: false
+
+ /micromark-extension-gfm/2.0.1:
+ resolution: {integrity: sha512-p2sGjajLa0iYiGQdT0oelahRYtMWvLjy8J9LOCxzIQsllMCGLbsLW+Nc+N4vi02jcRJvedVJ68cjelKIO6bpDA==}
+ dependencies:
+ micromark-extension-gfm-autolink-literal: 1.0.3
+ micromark-extension-gfm-footnote: 1.0.4
+ micromark-extension-gfm-strikethrough: 1.0.4
+ micromark-extension-gfm-table: 1.0.5
+ micromark-extension-gfm-tagfilter: 1.0.1
+ micromark-extension-gfm-task-list-item: 1.0.3
+ micromark-util-combine-extensions: 1.0.0
+ micromark-util-types: 1.0.2
+ dev: false
+
/micromark-extension-mdx-expression/1.0.4:
resolution: {integrity: sha512-TCgLxqW6ReQ3AJgtj1P0P+8ZThBTloLbeb7jNaqr6mCOLDpxUiBFE/9STgooMZttEwOQu5iEcCCa3ZSDhY9FGw==}
dependencies:
@@ -17551,7 +17620,6 @@ packages:
micromark-util-character: 1.1.0
micromark-util-symbol: 1.0.1
micromark-util-types: 1.0.2
- dev: true
/micromark-factory-label/1.0.2:
resolution: {integrity: sha512-CTIwxlOnU7dEshXDQ+dsr2n+yxpP0+fn271pu0bwDIS8uqfFcumXpj5mLn3hSC8iw2MUr6Gx8EcKng1dD7i6hg==}
@@ -17560,7 +17628,6 @@ packages:
micromark-util-symbol: 1.0.1
micromark-util-types: 1.0.2
uvu: 0.5.6
- dev: true
/micromark-factory-mdx-expression/1.0.7:
resolution: {integrity: sha512-QAdFbkQagTZ/eKb8zDGqmjvgevgJH3+aQpvvKrXWxNJp3o8/l2cAbbrBd0E04r0Gx6nssPpqWIjnbHFvZu5qsQ==}
@@ -17580,7 +17647,6 @@ packages:
dependencies:
micromark-util-character: 1.1.0
micromark-util-types: 1.0.2
- dev: true
/micromark-factory-title/1.0.2:
resolution: {integrity: sha512-zily+Nr4yFqgMGRKLpTVsNl5L4PMu485fGFDOQJQBl2NFpjGte1e86zC0da93wf97jrc4+2G2GQudFMHn3IX+A==}
@@ -17590,7 +17656,6 @@ packages:
micromark-util-symbol: 1.0.1
micromark-util-types: 1.0.2
uvu: 0.5.6
- dev: true
/micromark-factory-whitespace/1.0.0:
resolution: {integrity: sha512-Qx7uEyahU1lt1RnsECBiuEbfr9INjQTGa6Err+gF3g0Tx4YEviPbqqGKNv/NrBaE7dVHdn1bVZKM/n5I/Bak7A==}
@@ -17599,20 +17664,17 @@ packages:
micromark-util-character: 1.1.0
micromark-util-symbol: 1.0.1
micromark-util-types: 1.0.2
- dev: true
/micromark-util-character/1.1.0:
resolution: {integrity: sha512-agJ5B3unGNJ9rJvADMJ5ZiYjBRyDpzKAOk01Kpi1TKhlT1APx3XZk6eN7RtSz1erbWHC2L8T3xLZ81wdtGRZzg==}
dependencies:
micromark-util-symbol: 1.0.1
micromark-util-types: 1.0.2
- dev: true
/micromark-util-chunked/1.0.0:
resolution: {integrity: sha512-5e8xTis5tEZKgesfbQMKRCyzvffRRUX+lK/y+DvsMFdabAicPkkZV6gO+FEWi9RfuKKoxxPwNL+dFF0SMImc1g==}
dependencies:
micromark-util-symbol: 1.0.1
- dev: true
/micromark-util-classify-character/1.0.0:
resolution: {integrity: sha512-F8oW2KKrQRb3vS5ud5HIqBVkCqQi224Nm55o5wYLzY/9PwHGXC01tr3d7+TqHHz6zrKQ72Okwtvm/xQm6OVNZA==}
@@ -17620,20 +17682,17 @@ packages:
micromark-util-character: 1.1.0
micromark-util-symbol: 1.0.1
micromark-util-types: 1.0.2
- dev: true
/micromark-util-combine-extensions/1.0.0:
resolution: {integrity: sha512-J8H058vFBdo/6+AsjHp2NF7AJ02SZtWaVUjsayNFeAiydTxUwViQPxN0Hf8dp4FmCQi0UUFovFsEyRSUmFH3MA==}
dependencies:
micromark-util-chunked: 1.0.0
micromark-util-types: 1.0.2
- dev: true
/micromark-util-decode-numeric-character-reference/1.0.0:
resolution: {integrity: sha512-OzO9AI5VUtrTD7KSdagf4MWgHMtET17Ua1fIpXTpuhclCqD8egFWo85GxSGvxgkGS74bEahvtM0WP0HjvV0e4w==}
dependencies:
micromark-util-symbol: 1.0.1
- dev: true
/micromark-util-decode-string/1.0.2:
resolution: {integrity: sha512-DLT5Ho02qr6QWVNYbRZ3RYOSSWWFuH3tJexd3dgN1odEuPNxCngTCXJum7+ViRAd9BbdxCvMToPOD/IvVhzG6Q==}
@@ -17642,11 +17701,9 @@ packages:
micromark-util-character: 1.1.0
micromark-util-decode-numeric-character-reference: 1.0.0
micromark-util-symbol: 1.0.1
- dev: true
/micromark-util-encode/1.0.1:
resolution: {integrity: sha512-U2s5YdnAYexjKDel31SVMPbfi+eF8y1U4pfiRW/Y8EFVCy/vgxk/2wWTxzcqE71LHtCuCzlBDRU2a5CQ5j+mQA==}
- dev: true
/micromark-util-events-to-acorn/1.2.1:
resolution: {integrity: sha512-mkg3BaWlw6ZTkQORrKVBW4o9ICXPxLtGz51vml5mQpKFdo9vqIX68CAx5JhTOdjQyAHH7JFmm4rh8toSPQZUmg==}
@@ -17662,19 +17719,16 @@ packages:
/micromark-util-html-tag-name/1.1.0:
resolution: {integrity: sha512-BKlClMmYROy9UiV03SwNmckkjn8QHVaWkqoAqzivabvdGcwNGMMMH/5szAnywmsTBUzDsU57/mFi0sp4BQO6dA==}
- dev: true
/micromark-util-normalize-identifier/1.0.0:
resolution: {integrity: sha512-yg+zrL14bBTFrQ7n35CmByWUTFsgst5JhA4gJYoty4Dqzj4Z4Fr/DHekSS5aLfH9bdlfnSvKAWsAgJhIbogyBg==}
dependencies:
micromark-util-symbol: 1.0.1
- dev: true
/micromark-util-resolve-all/1.0.0:
resolution: {integrity: sha512-CB/AGk98u50k42kvgaMM94wzBqozSzDDaonKU7P7jwQIuH2RU0TeBqGYJz2WY1UdihhjweivStrJ2JdkdEmcfw==}
dependencies:
micromark-util-types: 1.0.2
- dev: true
/micromark-util-sanitize-uri/1.1.0:
resolution: {integrity: sha512-RoxtuSCX6sUNtxhbmsEFQfWzs8VN7cTctmBPvYivo98xb/kDEoTCtJQX5wyzIYEmk/lvNFTat4hL8oW0KndFpg==}
@@ -17682,7 +17736,6 @@ packages:
micromark-util-character: 1.1.0
micromark-util-encode: 1.0.1
micromark-util-symbol: 1.0.1
- dev: true
/micromark-util-subtokenize/1.0.2:
resolution: {integrity: sha512-d90uqCnXp/cy4G881Ub4psE57Sf8YD0pim9QdjCRNjfas2M1u6Lbt+XZK9gnHL2XFhnozZiEdCa9CNfXSfQ6xA==}
@@ -17691,15 +17744,12 @@ packages:
micromark-util-symbol: 1.0.1
micromark-util-types: 1.0.2
uvu: 0.5.6
- dev: true
/micromark-util-symbol/1.0.1:
resolution: {integrity: sha512-oKDEMK2u5qqAptasDAwWDXq0tG9AssVwAx3E9bBF3t/shRIGsWIRG+cGafs2p/SnDSOecnt6hZPCE2o6lHfFmQ==}
- dev: true
/micromark-util-types/1.0.2:
resolution: {integrity: sha512-DCfg/T8fcrhrRKTPjRrw/5LLvdGV7BHySf/1LOZx7TzWZdYRjogNtyNq885z3nNallwr3QUKARjqvHqX1/7t+w==}
- dev: true
/micromark/3.1.0:
resolution: {integrity: sha512-6Mj0yHLdUZjHnOPgr5xfWIMqMWS12zDN6iws9SLuSz76W8jTtAv24MN4/CL7gJrl5vtxGInkkqDv/JIoRsQOvA==}
@@ -17723,7 +17773,6 @@ packages:
uvu: 0.5.6
transitivePeerDependencies:
- supports-color
- dev: true
/micromatch/3.1.10:
resolution: {integrity: sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==}
@@ -20222,7 +20271,6 @@ packages:
engines: {node: '>=6'}
dependencies:
mri: 1.2.0
- dev: true
/safe-buffer/5.1.1:
resolution: {integrity: sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==}
@@ -21756,7 +21804,6 @@ packages:
resolution: {integrity: sha512-k5GzIBZ/QatR8N5X2y+drfpWG8IDBzdnVj6OInRNWm1oXrzydiaAT2OQiA8DPRRZyAKb9b6I2a6PxYklZD0gKg==}
dependencies:
'@types/unist': 2.0.6
- dev: true
/unist-util-visit-parents/3.1.1:
resolution: {integrity: sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==}
@@ -21999,7 +22046,6 @@ packages:
diff: 5.1.0
kleur: 4.1.5
sade: 1.8.1
- dev: true
/v8-to-istanbul/9.0.1:
resolution: {integrity: sha512-74Y4LqY74kLE6IFyIjPtkSTWzUZmj8tdHT9Ii/26dvQ6K9Dl2NbEfj0XgU2sHCtKgt5VupqhlO/5aWuqS+IY1w==}