feat(columns): update timeline column

This commit is contained in:
2023-12-27 15:01:40 +07:00
parent b4dac2d477
commit ed538c91c6
14 changed files with 282 additions and 130 deletions

View File

@@ -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 <div key={nanoid()} className="h-3" />;
});
if (typeof parsedContent[0] === "string") {

View File

@@ -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 };
}