@@ -9,6 +9,7 @@ export const API_ENDPOINTS = {
|
||||
geometries: `${API_BASE_URL}/geometries`,
|
||||
entities: `${API_BASE_URL}/entities`,
|
||||
wikis: `${API_BASE_URL}/wikis`,
|
||||
wikiContent: (id: string) => `${API_BASE_URL}/wikis/content/${id}`,
|
||||
// New API uses projects + commits + submissions (JWT-protected).
|
||||
authSignin: `${API_BASE_URL}/auth/signin`,
|
||||
authRefresh: `${API_BASE_URL}/auth/refresh`,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import api from "@/config/config";
|
||||
import { API_ENDPOINTS } from "@/uhm/api/config";
|
||||
import { ApiError, requestJson } from "@/uhm/api/http";
|
||||
|
||||
@@ -10,6 +11,11 @@ export type Wiki = {
|
||||
is_deleted?: boolean;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
content_sample?:{
|
||||
created_at?: string;
|
||||
content?: string;
|
||||
id?: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
export async function searchWikisByTitle(title: string, options?: { limit?: number; cursor?: string; entityId?: string }): Promise<Wiki[]> {
|
||||
@@ -60,3 +66,8 @@ export async function checkWikiSlugExists(slug: string): Promise<boolean> {
|
||||
// Be conservative: unknown payload shape, treat as "exists" to prevent creating conflicting slugs.
|
||||
return true;
|
||||
}
|
||||
|
||||
export const getContentByVersionWikiId = async (id: string) => {
|
||||
const response = await api.get(API_ENDPOINTS.wikiContent(id));
|
||||
return response?.data;
|
||||
};
|
||||
@@ -28,6 +28,7 @@ type QuillLike = {
|
||||
type QuillModule = {
|
||||
Quill?: {
|
||||
import?: (path: string) => unknown;
|
||||
register?: (pathOrModule: unknown, moduleOrOverwrite?: unknown, overwrite?: boolean) => void;
|
||||
};
|
||||
};
|
||||
type QuillLinkFormat = {
|
||||
@@ -114,11 +115,38 @@ export default function WikiSidebarPanel({ projectId, wikis, setWikis, autoOpen,
|
||||
const BlotFormatterModule = await import("quill-blot-formatter");
|
||||
const BlotFormatter = BlotFormatterModule.default;
|
||||
// Only register if not already registered to avoid errors in dev/HMR
|
||||
Quill.register("modules/blotFormatter", BlotFormatter, true);
|
||||
Quill.register?.("modules/blotFormatter", BlotFormatter, true);
|
||||
} catch (err) {
|
||||
console.error("Failed to load quill-blot-formatter", err);
|
||||
}
|
||||
|
||||
const ImageFormat = Quill.import?.("formats/image") as any;
|
||||
if (ImageFormat) {
|
||||
class CustomImage extends ImageFormat {
|
||||
static formats(domNode: Element) {
|
||||
const formats = ImageFormat.formats(domNode) || {};
|
||||
if (domNode.hasAttribute("style")) formats.style = domNode.getAttribute("style");
|
||||
if (domNode.hasAttribute("width")) formats.width = domNode.getAttribute("width");
|
||||
if (domNode.hasAttribute("height")) formats.height = domNode.getAttribute("height");
|
||||
if (domNode.hasAttribute("class")) formats.class = domNode.getAttribute("class");
|
||||
return formats;
|
||||
}
|
||||
|
||||
format(name: string, value: string) {
|
||||
if (["style", "width", "height", "class"].includes(name)) {
|
||||
if (value) {
|
||||
this.domNode.setAttribute(name, value);
|
||||
} else {
|
||||
this.domNode.removeAttribute(name);
|
||||
}
|
||||
} else {
|
||||
super.format(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Quill.register?.(CustomImage, true);
|
||||
}
|
||||
|
||||
const Link = Quill.import?.("formats/link");
|
||||
if (!Link) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user