= (props: Props) => {
>
{getDateTimeString(memo.displayTime)}
-
+
diff --git a/web/src/grpcweb.ts b/web/src/grpcweb.ts
index d6b521a6..2d3ba8bc 100644
--- a/web/src/grpcweb.ts
+++ b/web/src/grpcweb.ts
@@ -3,7 +3,7 @@ import { ActivityServiceDefinition } from "./types/proto/api/v1/activity_service
import { AuthServiceDefinition } from "./types/proto/api/v1/auth_service";
import { IdentityProviderServiceDefinition } from "./types/proto/api/v1/idp_service";
import { InboxServiceDefinition } from "./types/proto/api/v1/inbox_service";
-import { LinkServiceDefinition } from "./types/proto/api/v1/link_service";
+import { MarkdownServiceDefinition } from "./types/proto/api/v1/markdown_service";
import { MemoServiceDefinition } from "./types/proto/api/v1/memo_service";
import { ResourceServiceDefinition } from "./types/proto/api/v1/resource_service";
import { TagServiceDefinition } from "./types/proto/api/v1/tag_service";
@@ -41,6 +41,6 @@ export const activityServiceClient = clientFactory.create(ActivityServiceDefinit
export const webhookServiceClient = clientFactory.create(WebhookServiceDefinition, channel);
-export const linkServiceClient = clientFactory.create(LinkServiceDefinition, channel);
+export const markdownServiceClient = clientFactory.create(MarkdownServiceDefinition, channel);
export const identityProviderServiceClient = clientFactory.create(IdentityProviderServiceDefinition, channel);
diff --git a/web/src/main.tsx b/web/src/main.tsx
index 242e4d4f..440012b1 100644
--- a/web/src/main.tsx
+++ b/web/src/main.tsx
@@ -4,8 +4,6 @@ import { createRoot } from "react-dom/client";
import { Toaster } from "react-hot-toast";
import { Provider } from "react-redux";
import { RouterProvider } from "react-router-dom";
-import gomarkWasm from "./assets/gomark.wasm?url";
-import "./assets/wasm_exec.js";
import "./css/global.css";
import "./css/tailwind.css";
import "./helpers/polyfill";
@@ -17,10 +15,6 @@ import store from "./store";
import theme from "./theme";
(async () => {
- const go = new window.Go();
- const { instance } = await WebAssembly.instantiateStreaming(fetch(gomarkWasm), go.importObject);
- go.run(instance);
-
const container = document.getElementById("root");
const root = createRoot(container as HTMLElement);
root.render(
diff --git a/web/src/pages/Archived.tsx b/web/src/pages/Archived.tsx
index 1cdc8cc2..755883e6 100644
--- a/web/src/pages/Archived.tsx
+++ b/web/src/pages/Archived.tsx
@@ -121,7 +121,7 @@ const Archived = () => {
-
+
))}
{isRequesting ? (
diff --git a/web/src/types/global.d.ts b/web/src/types/global.d.ts
deleted file mode 100644
index dd6c6dac..00000000
--- a/web/src/types/global.d.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Node } from "./node";
-
-declare class Go {
- argv: string[];
- env: { [envKey: string]: string };
- exit: (code: number) => void;
- importObject: WebAssembly.Imports;
- exited: boolean;
- mem: DataView;
- run(instance: WebAssembly.Instance): Promise;
-}
-
-declare global {
- interface Window {
- Go: typeof Go;
- parse: (content: string) => Node[];
- restore: (input: Node[]) => string;
- }
-}
-
-export {};
diff --git a/web/src/types/node.ts b/web/src/types/node.ts
deleted file mode 100644
index e09d1bb7..00000000
--- a/web/src/types/node.ts
+++ /dev/null
@@ -1,202 +0,0 @@
-export enum NodeType {
- LINE_BREAK = "LINE_BREAK",
- PARAGRAPH = "PARAGRAPH",
- CODE_BLOCK = "CODE_BLOCK",
- HEADING = "HEADING",
- HORIZONTAL_RULE = "HORIZONTAL_RULE",
- BLOCKQUOTE = "BLOCKQUOTE",
- ORDERED_LIST = "ORDERED_LIST",
- UNORDERED_LIST = "UNORDERED_LIST",
- TASK_LIST = "TASK_LIST",
- MATH_BLOCK = "MATH_BLOCK",
- TABLE = "TABLE",
- EMBEDDED_CONTENT = "EMBEDDED_CONTENT",
- TEXT = "TEXT",
- BOLD = "BOLD",
- ITALIC = "ITALIC",
- BOLD_ITALIC = "BOLD_ITALIC",
- CODE = "CODE",
- IMAGE = "IMAGE",
- LINK = "LINK",
- AUTO_LINK = "AUTO_LINK",
- TAG = "TAG",
- STRIKETHROUGH = "STRIKETHROUGH",
- ESCAPING_CHARACTER = "ESCAPING_CHARACTER",
- MATH = "MATH",
- HIGHLIGHT = "HIGHLIGHT",
- SUBSCRIPT = "SUBSCRIPT",
- SUPERSCRIPT = "SUPERSCRIPT",
- REFERENCED_CONTENT = "REFERENCED_CONTENT",
- SPOILER = "SPOILER",
-}
-
-export interface Node {
- type: NodeType;
- value:
- | LineBreakNode
- | ParagraphNode
- | CodeBlockNode
- | HeadingNode
- | HorizontalRuleNode
- | BlockquoteNode
- | OrderedListNode
- | UnorderedListNode
- | TaskListNode
- | MathBlockNode
- | TableNode
- | EmbeddedContentNode
- | TextNode
- | BoldNode
- | ItalicNode
- | BoldItalicNode
- | CodeNode
- | ImageNode
- | LinkNode
- | AutoLinkNode
- | TagNode
- | StrikethroughNode
- | EscapingCharacterNode
- | MathNode
- | HighlightNode
- | SubscriptNode
- | SuperscriptNode
- | ReferencedContentNode
- | SpoilerNode;
-}
-
-export interface LineBreakNode {}
-
-export interface ParagraphNode {
- children: Node[];
-}
-
-export interface CodeBlockNode {
- language: string;
- content: string;
-}
-
-export interface HeadingNode {
- level: number;
- children: Node[];
-}
-
-export interface HorizontalRuleNode {
- symbol: string;
-}
-
-export interface BlockquoteNode {
- children: Node[];
-}
-
-export interface OrderedListNode {
- number: string;
- indent: number;
- children: Node[];
-}
-
-export interface UnorderedListNode {
- symbol: string;
- indent: number;
- children: Node[];
-}
-
-export interface TaskListNode {
- symbol: string;
- indent: number;
- complete: boolean;
- children: Node[];
-}
-
-export interface MathBlockNode {
- content: string;
-}
-
-export interface TableNode {
- header: string[];
- delimiter: string[];
- rows: TableNode_Row[];
-}
-
-export interface TableNode_Row {
- cells: string[];
-}
-
-export interface EmbeddedContentNode {
- resourceName: string;
- params: string;
-}
-
-export interface TextNode {
- content: string;
-}
-
-export interface BoldNode {
- symbol: string;
- children: Node[];
-}
-
-export interface ItalicNode {
- symbol: string;
- content: string;
-}
-
-export interface BoldItalicNode {
- symbol: string;
- content: string;
-}
-
-export interface CodeNode {
- content: string;
-}
-
-export interface ImageNode {
- altText: string;
- url: string;
-}
-
-export interface LinkNode {
- text: string;
- url: string;
-}
-
-export interface AutoLinkNode {
- url: string;
- isRawText: boolean;
-}
-
-export interface TagNode {
- content: string;
-}
-
-export interface StrikethroughNode {
- content: string;
-}
-
-export interface EscapingCharacterNode {
- symbol: string;
-}
-
-export interface MathNode {
- content: string;
-}
-
-export interface HighlightNode {
- content: string;
-}
-
-export interface SubscriptNode {
- content: string;
-}
-
-export interface SuperscriptNode {
- content: string;
-}
-
-export interface ReferencedContentNode {
- resourceName: string;
- params: string;
-}
-
-export interface SpoilerNode {
- content: string;
-}
diff --git a/web/src/utils/tag.ts b/web/src/utils/tag.ts
index ceb5a2fb..911f8161 100644
--- a/web/src/utils/tag.ts
+++ b/web/src/utils/tag.ts
@@ -1,10 +1,11 @@
-import { Node, TagNode } from "@/types/node";
+import { markdownServiceClient } from "@/grpcweb";
+import { Node, NodeType, TagNode } from "@/types/proto/api/v1/markdown_service";
export const TAG_REG = /#([^\s#,]+)/;
// extractTagsFromContent extracts tags from content.
-export const extractTagsFromContent = (content: string) => {
- const nodes = window.parse(content);
+export const extractTagsFromContent = async (content: string) => {
+ const { nodes } = await markdownServiceClient.parseMarkdown({ markdown: content });
const tags = new Set();
const traverse = (nodes: Node[], handle: (node: Node) => void) => {
@@ -15,7 +16,7 @@ export const extractTagsFromContent = (content: string) => {
handle(node);
if (node.type === "PARAGRAPH" || node.type === "ORDERED_LIST" || node.type === "UNORDERED_LIST") {
- const children = (node.value as any).children;
+ const children = node.paragraphNode?.children || node.orderedListNode?.children || node.unorderedListNode?.children;
if (Array.isArray(children)) {
traverse(children, handle);
}
@@ -24,8 +25,8 @@ export const extractTagsFromContent = (content: string) => {
};
traverse(nodes, (node) => {
- if (node.type === "TAG" && node.value) {
- tags.add((node.value as TagNode).content);
+ if (node.type === NodeType.TAG && node.tagNode) {
+ tags.add((node.tagNode as TagNode).content);
}
});