@@ -116,7 +116,7 @@ export function NoteUser({
@@ -161,7 +161,7 @@ export function NoteUser({
@@ -212,7 +212,7 @@ export function NoteUser({
diff --git a/packages/ark/src/hooks/useRichContent.tsx b/packages/ark/src/hooks/useRichContent.tsx
index ba9bfb1e..058117d2 100644
--- a/packages/ark/src/hooks/useRichContent.tsx
+++ b/packages/ark/src/hooks/useRichContent.tsx
@@ -1,3 +1,4 @@
+import { nanoid } from "nanoid";
import { nip19 } from "nostr-tools";
import { ReactNode } from "react";
import { Link } from "react-router-dom";
@@ -172,7 +173,6 @@ export function useRichContent(content: string, textmode = false) {
/(https?:\/\/\S+)/g,
(match, i) => {
const url = new URL(match);
- url.search = "";
if (!linkPreview && !textmode) {
linkPreview = match;
@@ -194,7 +194,7 @@ export function useRichContent(content: string, textmode = false) {
);
parsedContent = reactStringReplace(parsedContent, "\n", () => {
- return null;
+ return
;
});
if (typeof parsedContent[0] === "string") {
diff --git a/packages/ark/src/hooks/useSuggestion.ts b/packages/ark/src/hooks/useSuggestion.ts
deleted file mode 100644
index 34edc12f..00000000
--- a/packages/ark/src/hooks/useSuggestion.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import { MentionOptions } from "@tiptap/extension-mention";
-import { ReactRenderer } from "@tiptap/react";
-import tippy from "tippy.js";
-import { MentionList } from "../components/mentions";
-import { useStorage } from "../provider";
-
-export function useSuggestion() {
- const storage = useStorage();
-
- const suggestion: MentionOptions["suggestion"] = {
- items: async ({ query }) => {
- const users = await storage.getAllCacheUsers();
- return users
- .filter((item) => {
- if (item.name)
- return item.name.toLowerCase().startsWith(query.toLowerCase());
- return item.displayName.toLowerCase().startsWith(query.toLowerCase());
- })
- .slice(0, 5);
- },
- render: () => {
- let component;
- let popup;
-
- return {
- onStart: (props) => {
- component = new ReactRenderer(MentionList, {
- props,
- editor: props.editor,
- });
-
- if (!props.clientRect) {
- return;
- }
-
- popup = tippy("body", {
- getReferenceClientRect: props.clientRect,
- appendTo: () => document.body,
- content: component.element,
- showOnCreate: true,
- interactive: true,
- trigger: "manual",
- placement: "bottom-start",
- });
- },
-
- onUpdate(props) {
- component.updateProps(props);
-
- if (!props.clientRect) {
- return;
- }
-
- popup[0].setProps({
- getReferenceClientRect: props.clientRect,
- });
- },
-
- onKeyDown(props) {
- if (props.event.key === "Escape") {
- popup[0].hide();
-
- return true;
- }
-
- return component.ref?.onKeyDown(props);
- },
-
- onExit() {
- popup[0].destroy();
- component.destroy();
- },
- };
- },
- };
-
- return { suggestion };
-}
diff --git a/packages/ark/src/index.ts b/packages/ark/src/index.ts
index a4d68e34..62d47af8 100644
--- a/packages/ark/src/index.ts
+++ b/packages/ark/src/index.ts
@@ -6,5 +6,4 @@ export * from "./hooks/useWidget";
export * from "./hooks/useRichContent";
export * from "./hooks/useEvent";
export * from "./hooks/useProfile";
-export * from "./hooks/useSuggestion";
export * from "./hooks/useRelay";
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index 6868f604..c6eab7fb 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -10,3 +10,4 @@ export * from "./layouts/auth";
export * from "./layouts/composer";
export * from "./layouts/home";
export * from "./layouts/settings";
+export * from "./mentions";
diff --git a/packages/ark/src/components/mentions.tsx b/packages/ui/src/mentions.tsx
similarity index 100%
rename from packages/ark/src/components/mentions.tsx
rename to packages/ui/src/mentions.tsx
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 60baf1d4..2fe29e9b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -371,6 +371,9 @@ importers:
'@lume/icons':
specifier: workspace:^
version: link:../../icons
+ '@lume/ui':
+ specifier: workspace:^
+ version: link:../../ui
'@lume/utils':
specifier: workspace:^
version: link:../../utils
@@ -386,6 +389,9 @@ importers:
react-router-dom:
specifier: ^6.21.0
version: 6.21.0(react-dom@18.2.0)(react@18.2.0)
+ sonner:
+ specifier: ^1.2.4
+ version: 1.2.4(react-dom@18.2.0)(react@18.2.0)
virtua:
specifier: ^0.18.0
version: 0.18.0(react-dom@18.2.0)(react@18.2.0)