mirror of
https://github.com/docmost/docmost.git
synced 2026-05-08 07:13:06 +08:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb9f449dc4 | |||
| 732951a322 | |||
| 2544775266 | |||
| d59539f197 | |||
| b061df7f7d | |||
| 0fe1459864 | |||
| 6af7956889 | |||
| 3dbb957bd7 | |||
| f39a4cf2d5 | |||
| 724e01bd55 | |||
| 6e350f6746 | |||
| cb9f27da9a | |||
| d2629afff2 | |||
| 9139d393ef | |||
| ab96672ecd | |||
| 2ea3c2da58 | |||
| 9fb16bc842 | |||
| c3b350d943 | |||
| 8014ba3ab7 | |||
| ec3a04f7c7 | |||
| 04a17c9b92 | |||
| 520c07a0bc | |||
| 60a8ed6826 | |||
| f5684b792e | |||
| 042836cb6d | |||
| 4f1f0ba513 | |||
| 3164b6981c | |||
| 16c1e864af | |||
| c9b1cad982 | |||
| bf8cf6254f | |||
| 3135030376 | |||
| 3fae41a5ca | |||
| b50e25600a | |||
| 1f3b0c7276 |
+4
-2
@@ -1,4 +1,4 @@
|
|||||||
FROM node:22-alpine AS base
|
FROM node:22-slim AS base
|
||||||
LABEL org.opencontainers.image.source="https://github.com/docmost/docmost"
|
LABEL org.opencontainers.image.source="https://github.com/docmost/docmost"
|
||||||
|
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
@@ -13,7 +13,9 @@ RUN pnpm build
|
|||||||
|
|
||||||
FROM base AS installer
|
FROM base AS installer
|
||||||
|
|
||||||
RUN apk add --no-cache curl bash
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends curl bash \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.23.2",
|
"version": "0.24.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
"@emoji-mart/react": "^1.1.1",
|
"@emoji-mart/react": "^1.1.1",
|
||||||
"@excalidraw/excalidraw": "0.18.0-864353b",
|
"@excalidraw/excalidraw": "0.18.0-864353b",
|
||||||
"@mantine/core": "^8.1.3",
|
"@mantine/core": "^8.1.3",
|
||||||
|
"@mantine/dates": "^8.3.2",
|
||||||
"@mantine/form": "^8.1.3",
|
"@mantine/form": "^8.1.3",
|
||||||
"@mantine/hooks": "^8.1.3",
|
"@mantine/hooks": "^8.1.3",
|
||||||
"@mantine/modals": "^8.1.3",
|
"@mantine/modals": "^8.1.3",
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
"@tanstack/react-query": "^5.80.6",
|
"@tanstack/react-query": "^5.80.6",
|
||||||
"@tiptap/extension-character-count": "^2.10.3",
|
"@tiptap/extension-character-count": "^2.10.3",
|
||||||
"alfaaz": "^1.1.0",
|
"alfaaz": "^1.1.0",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.13.2",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"emoji-mart": "^5.6.0",
|
"emoji-mart": "^5.6.0",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
@@ -56,7 +57,7 @@
|
|||||||
"socket.io-client": "^4.8.1",
|
"socket.io-client": "^4.8.1",
|
||||||
"tippy.js": "^6.3.7",
|
"tippy.js": "^6.3.7",
|
||||||
"tiptap-extension-global-drag-handle": "^0.1.18",
|
"tiptap-extension-global-drag-handle": "^0.1.18",
|
||||||
"zod": "^3.25.56"
|
"zod": "^3.25.76"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.16.0",
|
"@eslint/js": "^9.16.0",
|
||||||
@@ -64,10 +65,10 @@
|
|||||||
"@types/file-saver": "^2.0.7",
|
"@types/file-saver": "^2.0.7",
|
||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/katex": "^0.16.7",
|
"@types/katex": "^0.16.7",
|
||||||
"@types/node": "22.10.0",
|
"@types/node": "22.19.1",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react-dom": "^18.3.1",
|
||||||
"@vitejs/plugin-react": "^4.4.1",
|
"@vitejs/plugin-react": "^5.1.1",
|
||||||
"eslint": "^9.15.0",
|
"eslint": "^9.15.0",
|
||||||
"eslint-plugin-react": "^7.37.2",
|
"eslint-plugin-react": "^7.37.2",
|
||||||
"eslint-plugin-react-hooks": "^5.1.0",
|
"eslint-plugin-react-hooks": "^5.1.0",
|
||||||
@@ -80,6 +81,6 @@
|
|||||||
"prettier": "^3.4.1",
|
"prettier": "^3.4.1",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
"typescript-eslint": "^8.17.0",
|
"typescript-eslint": "^8.17.0",
|
||||||
"vite": "^6.3.5"
|
"vite": "^7.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
"Delete group": "Gruppe löschen",
|
"Delete group": "Gruppe löschen",
|
||||||
"Are you sure you want to delete this page? This will delete its children and page history. This action is irreversible.": "Sind Sie sicher, dass Sie diese Seite löschen möchten? Dadurch werden ihre Unterseiten und die Seitengeschichte gelöscht. Diese Aktion ist unwiderruflich.",
|
"Are you sure you want to delete this page? This will delete its children and page history. This action is irreversible.": "Sind Sie sicher, dass Sie diese Seite löschen möchten? Dadurch werden ihre Unterseiten und die Seitengeschichte gelöscht. Diese Aktion ist unwiderruflich.",
|
||||||
"Description": "Beschreibung",
|
"Description": "Beschreibung",
|
||||||
"Details": "Einzelheiten",
|
"Details": "Details",
|
||||||
"e.g ACME": "z.B. ACME",
|
"e.g ACME": "z.B. ACME",
|
||||||
"e.g ACME Inc": "z.B. ACME Inc.",
|
"e.g ACME Inc": "z.B. ACME Inc.",
|
||||||
"e.g Developers": "z.B. Entwickler",
|
"e.g Developers": "z.B. Entwickler",
|
||||||
@@ -234,9 +234,7 @@
|
|||||||
"Anyone with this link can join this workspace.": "Jeder mit diesem Link kann dem Arbeitsbereich beitreten.",
|
"Anyone with this link can join this workspace.": "Jeder mit diesem Link kann dem Arbeitsbereich beitreten.",
|
||||||
"Invite link": "Einladungslink",
|
"Invite link": "Einladungslink",
|
||||||
"Copy": "Kopieren",
|
"Copy": "Kopieren",
|
||||||
"Copy to space": "In Raum kopieren",
|
|
||||||
"Copied": "Kopiert",
|
"Copied": "Kopiert",
|
||||||
"Duplicate": "Duplizieren",
|
|
||||||
"Select a user": "Benutzer auswählen",
|
"Select a user": "Benutzer auswählen",
|
||||||
"Select a group": "Gruppe auswählen",
|
"Select a group": "Gruppe auswählen",
|
||||||
"Export all pages and attachments in this space.": "Alle Seiten und Anhänge in diesem Bereich exportieren.",
|
"Export all pages and attachments in this space.": "Alle Seiten und Anhänge in diesem Bereich exportieren.",
|
||||||
@@ -527,5 +525,47 @@
|
|||||||
"Delete SSO provider": "SSO-Anbieter löschen",
|
"Delete SSO provider": "SSO-Anbieter löschen",
|
||||||
"Are you sure you want to delete this SSO provider?": "Sind Sie sicher, dass Sie diesen SSO-Anbieter löschen möchten?",
|
"Are you sure you want to delete this SSO provider?": "Sind Sie sicher, dass Sie diesen SSO-Anbieter löschen möchten?",
|
||||||
"Action": "Aktion",
|
"Action": "Aktion",
|
||||||
"{{ssoProviderType}} configuration": "{{ssoProviderType}}-Konfiguration"
|
"{{ssoProviderType}} configuration": "{{ssoProviderType}}-Konfiguration",
|
||||||
|
"Icon": "Icon",
|
||||||
|
"Upload image": "Bild hochladen",
|
||||||
|
"Remove image": "Bild entfernen",
|
||||||
|
"Failed to remove image": "Fehler beim Entfernen des Bildes",
|
||||||
|
"Image exceeds 10MB limit.": "Bild überschreitet das Limit von 10 MB.",
|
||||||
|
"Image removed successfully": "Bild erfolgreich entfernt",
|
||||||
|
"API key": "API-Schlüssel",
|
||||||
|
"API key created successfully": "API-Schlüssel erfolgreich erstellt",
|
||||||
|
"API keys": "API-Schlüssel",
|
||||||
|
"API management": "API-Verwaltung",
|
||||||
|
"Are you sure you want to revoke this API key": "Sind Sie sicher, dass Sie diesen API-Schlüssel widerrufen möchten?",
|
||||||
|
"Create API Key": "API-Schlüssel erstellen",
|
||||||
|
"Custom expiration date": "Benutzerdefiniertes Ablaufdatum",
|
||||||
|
"Enter a descriptive token name": "Geben Sie einen beschreibenden Token-Namen ein",
|
||||||
|
"Expiration": "Ablauf",
|
||||||
|
"Expired": "Abgelaufen",
|
||||||
|
"Expires": "Läuft ab",
|
||||||
|
"I've saved my API key": "Ich habe meinen API-Schlüssel gespeichert",
|
||||||
|
"Last use": "Zuletzt verwendet",
|
||||||
|
"No API keys found": "Keine API-Schlüssel gefunden",
|
||||||
|
"No expiration": "Kein Ablauf",
|
||||||
|
"Revoke API key": "API-Schlüssel widerrufen",
|
||||||
|
"Revoked successfully": "Erfolgreich widerrufen",
|
||||||
|
"Select expiration date": "Ablaufdatum wählen",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "Diese Aktion kann nicht rückgängig gemacht werden. Alle Anwendungen, die diesen API-Schlüssel verwenden, werden nicht mehr funktionieren.",
|
||||||
|
"Update API key": "API-Schlüssel aktualisieren",
|
||||||
|
"Manage API keys for all users in the workspace": "Verwalten Sie API-Schlüssel für alle Benutzer im Arbeitsbereich",
|
||||||
|
"AI settings": "KI-Einstellungen",
|
||||||
|
"AI search": "KI-Suche",
|
||||||
|
"AI Answer": "KI-Antwort",
|
||||||
|
"Ask AI": "KI fragen",
|
||||||
|
"AI is thinking...": "Die KI überlegt...",
|
||||||
|
"Ask a question...": "Fragen stellen...",
|
||||||
|
"AI-powered search (Ask AI)": "KI-gestützte Suche (KI fragen)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "Die KI-Suche verwendet Vektor-Einbettungen, um semantische Suchfunktionen in Ihrem Arbeitsbereich bereitzustellen.",
|
||||||
|
"Toggle AI search": "KI-Suche umschalten",
|
||||||
|
"Sources": "Quellen",
|
||||||
|
"Ask AI not available for attachments": "KI fragen nicht für Anhänge verfügbar",
|
||||||
|
"No answer available": "Keine Antwort verfügbar",
|
||||||
|
"Background color": "Hintergrundfarbe",
|
||||||
|
"Highlight color": "Hervorhebungsfarbe",
|
||||||
|
"Remove color": "Farbe entfernen"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -533,5 +533,41 @@
|
|||||||
"Remove image": "Remove image",
|
"Remove image": "Remove image",
|
||||||
"Failed to remove image": "Failed to remove image",
|
"Failed to remove image": "Failed to remove image",
|
||||||
"Image exceeds 10MB limit.": "Image exceeds 10MB limit.",
|
"Image exceeds 10MB limit.": "Image exceeds 10MB limit.",
|
||||||
"Image removed successfully": "Image removed successfully"
|
"Image removed successfully": "Image removed successfully",
|
||||||
|
"API key": "API key",
|
||||||
|
"API key created successfully": "API key created successfully",
|
||||||
|
"API keys": "API keys",
|
||||||
|
"API management": "API management",
|
||||||
|
"Are you sure you want to revoke this API key": "Are you sure you want to revoke this API key",
|
||||||
|
"Create API Key": "Create API Key",
|
||||||
|
"Custom expiration date": "Custom expiration date",
|
||||||
|
"Enter a descriptive token name": "Enter a descriptive token name",
|
||||||
|
"Expiration": "Expiration",
|
||||||
|
"Expired": "Expired",
|
||||||
|
"Expires": "Expires",
|
||||||
|
"I've saved my API key": "I've saved my API key",
|
||||||
|
"Last use": "Last Used",
|
||||||
|
"No API keys found": "No API keys found",
|
||||||
|
"No expiration": "No expiration",
|
||||||
|
"Revoke API key": "Revoke API key",
|
||||||
|
"Revoked successfully": "Revoked successfully",
|
||||||
|
"Select expiration date": "Select expiration date",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "This action cannot be undone. Any applications using this API key will stop working.",
|
||||||
|
"Update API key": "Update API key",
|
||||||
|
"Manage API keys for all users in the workspace": "Manage API keys for all users in the workspace",
|
||||||
|
"AI settings": "AI settings",
|
||||||
|
"AI search": "AI search",
|
||||||
|
"AI Answer": "AI Answer",
|
||||||
|
"Ask AI": "Ask AI",
|
||||||
|
"AI is thinking...": "AI is thinking...",
|
||||||
|
"Ask a question...": "Ask a question...",
|
||||||
|
"AI-powered search (Ask AI)": "AI-powered search (Ask AI)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "AI search uses vector embeddings to provide semantic search capabilities across your workspace content.",
|
||||||
|
"Toggle AI search": "Toggle AI search",
|
||||||
|
"Sources": "Sources",
|
||||||
|
"Ask AI not available for attachments": "Ask AI not available for attachments",
|
||||||
|
"No answer available": "No answer available",
|
||||||
|
"Background color": "Background color",
|
||||||
|
"Highlight color": "Highlight color",
|
||||||
|
"Remove color": "Remove color"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "Eliminar proveedor de SSO",
|
"Delete SSO provider": "Eliminar proveedor de SSO",
|
||||||
"Are you sure you want to delete this SSO provider?": "¿Está seguro de que desea eliminar este proveedor de SSO?",
|
"Are you sure you want to delete this SSO provider?": "¿Está seguro de que desea eliminar este proveedor de SSO?",
|
||||||
"Action": "Acción",
|
"Action": "Acción",
|
||||||
"{{ssoProviderType}} configuration": "Configuración de {{ssoProviderType}}"
|
"{{ssoProviderType}} configuration": "Configuración de {{ssoProviderType}}",
|
||||||
|
"Icon": "Icono",
|
||||||
|
"Upload image": "Subir imagen",
|
||||||
|
"Remove image": "Eliminar imagen",
|
||||||
|
"Failed to remove image": "No se ha podido eliminar la imagen",
|
||||||
|
"Image exceeds 10MB limit.": "La imagen excede del límite de 10 MB",
|
||||||
|
"Image removed successfully": "Imagen eliminada correctamente",
|
||||||
|
"API key": "Clave API",
|
||||||
|
"API key created successfully": "Clave API creada correctamente",
|
||||||
|
"API keys": "Claves API",
|
||||||
|
"API management": "Gestión de API",
|
||||||
|
"Are you sure you want to revoke this API key": "¿Está seguro de que desea revocar esta clave API? ",
|
||||||
|
"Create API Key": "Crear clave API",
|
||||||
|
"Custom expiration date": "Fecha de vencimiento personalizada",
|
||||||
|
"Enter a descriptive token name": "Introduce un nombre descriptivo del token",
|
||||||
|
"Expiration": "Vencimiento",
|
||||||
|
"Expired": "Vencido",
|
||||||
|
"Expires": "Vence",
|
||||||
|
"I've saved my API key": "He guardado mi clave API",
|
||||||
|
"Last use": "Último uso",
|
||||||
|
"No API keys found": "No se han encontrado claves API",
|
||||||
|
"No expiration": "Sin vencimiento",
|
||||||
|
"Revoke API key": "Revocar clave API",
|
||||||
|
"Revoked successfully": "Revocada correctamente",
|
||||||
|
"Select expiration date": "Seleccionar fecha de vencimiento",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "Esta acción no se puede deshacer. Las aplicaciones que utilicen esta clave API dejarán de funcionar.",
|
||||||
|
"Update API key": "Actualizar clave API",
|
||||||
|
"Manage API keys for all users in the workspace": "Gestionar claves API para todos los usuarios en el espacio de trabajo",
|
||||||
|
"AI settings": "Configuración de IA",
|
||||||
|
"AI search": "Búsqueda de IA",
|
||||||
|
"AI Answer": "Respuesta de IA",
|
||||||
|
"Ask AI": "Preguntar a IA",
|
||||||
|
"AI is thinking...": "IA está pensando...",
|
||||||
|
"Ask a question...": "Haz una pregunta...",
|
||||||
|
"AI-powered search (Ask AI)": "Búsqueda impulsada por IA (Preguntar a IA)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "La búsqueda de IA utiliza incrustaciones vectoriales para proporcionar capacidades de búsqueda semántica en todo el contenido de su espacio de trabajo.",
|
||||||
|
"Toggle AI search": "Alternar búsqueda de IA",
|
||||||
|
"Sources": "Fuentes",
|
||||||
|
"Ask AI not available for attachments": "Preguntar a IA no está disponible para adjuntos",
|
||||||
|
"No answer available": "No hay respuesta disponible",
|
||||||
|
"Background color": "Color de fondo",
|
||||||
|
"Highlight color": "Color de resaltado",
|
||||||
|
"Remove color": "Eliminar color"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "Supprimer le fournisseur SSO",
|
"Delete SSO provider": "Supprimer le fournisseur SSO",
|
||||||
"Are you sure you want to delete this SSO provider?": "Êtes-vous sûr de vouloir supprimer ce fournisseur SSO ?",
|
"Are you sure you want to delete this SSO provider?": "Êtes-vous sûr de vouloir supprimer ce fournisseur SSO ?",
|
||||||
"Action": "Action",
|
"Action": "Action",
|
||||||
"{{ssoProviderType}} configuration": "Configuration {{ssoProviderType}}"
|
"{{ssoProviderType}} configuration": "Configuration {{ssoProviderType}}",
|
||||||
|
"Icon": "Icône",
|
||||||
|
"Upload image": "Téléverser une image",
|
||||||
|
"Remove image": "Supprimer l'image",
|
||||||
|
"Failed to remove image": "Échec de la suppression de l'image",
|
||||||
|
"Image exceeds 10MB limit.": "L'image dépasse la limite de 10 Mo.",
|
||||||
|
"Image removed successfully": "Image supprimée avec succès",
|
||||||
|
"API key": "Clé API",
|
||||||
|
"API key created successfully": "Clé API créée avec succès",
|
||||||
|
"API keys": "Clés API",
|
||||||
|
"API management": "Gestion des API",
|
||||||
|
"Are you sure you want to revoke this API key": "Êtes-vous sûr de vouloir révoquer cette clé API",
|
||||||
|
"Create API Key": "Créer une clé API",
|
||||||
|
"Custom expiration date": "Date d'expiration personnalisée",
|
||||||
|
"Enter a descriptive token name": "Entrez un nom descriptif pour le jeton",
|
||||||
|
"Expiration": "Expiration",
|
||||||
|
"Expired": "Expiré(e)",
|
||||||
|
"Expires": "Expire",
|
||||||
|
"I've saved my API key": "J'ai enregistré ma clé API",
|
||||||
|
"Last use": "Dernière utilisation",
|
||||||
|
"No API keys found": "Aucune clé API trouvée",
|
||||||
|
"No expiration": "Pas d'expiration",
|
||||||
|
"Revoke API key": "Révoquer la clé API",
|
||||||
|
"Revoked successfully": "Révoqué(e) avec succès",
|
||||||
|
"Select expiration date": "Sélectionnez la date d'expiration",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "Cette action ne peut pas être annulée. Toutes les applications utilisant cette clé API cesseront de fonctionner.",
|
||||||
|
"Update API key": "Mettre à jour la clé API",
|
||||||
|
"Manage API keys for all users in the workspace": "Gérer les clés API pour tous les utilisateurs dans l'espace de travail",
|
||||||
|
"AI settings": "Paramètres de l'IA",
|
||||||
|
"AI search": "Recherche IA",
|
||||||
|
"AI Answer": "Réponse IA",
|
||||||
|
"Ask AI": "Demander à l'IA",
|
||||||
|
"AI is thinking...": "L'IA réfléchit...",
|
||||||
|
"Ask a question...": "Posez une question...",
|
||||||
|
"AI-powered search (Ask AI)": "Recherche assistée par l'IA (Demander à l'IA)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "La recherche IA utilise des incorporations vectorielles pour fournir des capacités de recherche sémantique à travers le contenu de votre espace de travail.",
|
||||||
|
"Toggle AI search": "Basculer la recherche IA",
|
||||||
|
"Sources": "Sources",
|
||||||
|
"Ask AI not available for attachments": "Demande à l'IA non disponible pour les pièces jointes",
|
||||||
|
"No answer available": "Pas de réponse disponible",
|
||||||
|
"Background color": "Couleur de fond",
|
||||||
|
"Highlight color": "Couleur de surbrillance",
|
||||||
|
"Remove color": "Supprimer la couleur"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "Elimina provider SSO",
|
"Delete SSO provider": "Elimina provider SSO",
|
||||||
"Are you sure you want to delete this SSO provider?": "Sei sicuro di voler eliminare questo provider SSO?",
|
"Are you sure you want to delete this SSO provider?": "Sei sicuro di voler eliminare questo provider SSO?",
|
||||||
"Action": "Azione",
|
"Action": "Azione",
|
||||||
"{{ssoProviderType}} configuration": "Configurazione {{ssoProviderType}}"
|
"{{ssoProviderType}} configuration": "Configurazione {{ssoProviderType}}",
|
||||||
|
"Icon": "Icona",
|
||||||
|
"Upload image": "Carica immagine",
|
||||||
|
"Remove image": "Rimuovi immagine",
|
||||||
|
"Failed to remove image": "Rimozione immagine fallita",
|
||||||
|
"Image exceeds 10MB limit.": "L'immagine supera il limite di 10MB.",
|
||||||
|
"Image removed successfully": "Immagine rimossa con successo",
|
||||||
|
"API key": "Chiave API",
|
||||||
|
"API key created successfully": "Chiave API creata con successo",
|
||||||
|
"API keys": "Chiavi API",
|
||||||
|
"API management": "Gestione API",
|
||||||
|
"Are you sure you want to revoke this API key": "Sei sicuro di voler revocare questa chiave API",
|
||||||
|
"Create API Key": "Crea Chiave API",
|
||||||
|
"Custom expiration date": "Data di scadenza personalizzata",
|
||||||
|
"Enter a descriptive token name": "Inserisci un nome descrittivo del token",
|
||||||
|
"Expiration": "Scadenza",
|
||||||
|
"Expired": "Scaduto",
|
||||||
|
"Expires": "Scade",
|
||||||
|
"I've saved my API key": "Ho salvato la mia chiave API",
|
||||||
|
"Last use": "Ultimo utilizzo",
|
||||||
|
"No API keys found": "Nessuna chiave API trovata",
|
||||||
|
"No expiration": "Nessuna scadenza",
|
||||||
|
"Revoke API key": "Revoca chiave API",
|
||||||
|
"Revoked successfully": "Revocata con successo",
|
||||||
|
"Select expiration date": "Seleziona la data di scadenza",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "Questa azione non può essere annullata. Qualsiasi applicazione che utilizza questa chiave API smetterà di funzionare.",
|
||||||
|
"Update API key": "Aggiorna chiave API",
|
||||||
|
"Manage API keys for all users in the workspace": "Gestisci le chiavi API per tutti gli utenti nell'area di lavoro",
|
||||||
|
"AI settings": "Impostazioni AI",
|
||||||
|
"AI search": "Ricerca AI",
|
||||||
|
"AI Answer": "Risposta AI",
|
||||||
|
"Ask AI": "Chiedi all'AI",
|
||||||
|
"AI is thinking...": "L'AI sta pensando...",
|
||||||
|
"Ask a question...": "Fai una domanda...",
|
||||||
|
"AI-powered search (Ask AI)": "Ricerca potenziata dall'AI (Chiedi all'AI)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "La ricerca AI utilizza embeddings vettoriali per fornire capacità di ricerca semantica nel contenuto della tua area di lavoro.",
|
||||||
|
"Toggle AI search": "Attiva/disattiva ricerca AI",
|
||||||
|
"Sources": "Fonti",
|
||||||
|
"Ask AI not available for attachments": "Chiedere all'AI non è disponibile per gli allegati",
|
||||||
|
"No answer available": "Nessuna risposta disponibile",
|
||||||
|
"Background color": "Colore di sfondo",
|
||||||
|
"Highlight color": "Colore evidenziato",
|
||||||
|
"Remove color": "Rimuovi colore"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "SSOプロバイダーを削除する",
|
"Delete SSO provider": "SSOプロバイダーを削除する",
|
||||||
"Are you sure you want to delete this SSO provider?": "このSSOプロバイダーを削除してもよろしいですか?",
|
"Are you sure you want to delete this SSO provider?": "このSSOプロバイダーを削除してもよろしいですか?",
|
||||||
"Action": "アクション",
|
"Action": "アクション",
|
||||||
"{{ssoProviderType}} configuration": "{{ssoProviderType}}の構成"
|
"{{ssoProviderType}} configuration": "{{ssoProviderType}}の構成",
|
||||||
|
"Icon": "アイコン",
|
||||||
|
"Upload image": "画像をアップロード",
|
||||||
|
"Remove image": "画像を削除",
|
||||||
|
"Failed to remove image": "画像の削除に失敗しました",
|
||||||
|
"Image exceeds 10MB limit.": "画像が10MBの制限を超えています。",
|
||||||
|
"Image removed successfully": "画像が正常に削除されました",
|
||||||
|
"API key": "APIキー",
|
||||||
|
"API key created successfully": "APIキーが正常に作成されました",
|
||||||
|
"API keys": "APIキー",
|
||||||
|
"API management": "API管理",
|
||||||
|
"Are you sure you want to revoke this API key": "このAPIキーを無効にしてもよろしいですか",
|
||||||
|
"Create API Key": "APIキーを作成",
|
||||||
|
"Custom expiration date": "カスタム有効期限",
|
||||||
|
"Enter a descriptive token name": "説明的なトークン名を入力してください",
|
||||||
|
"Expiration": "有効期限",
|
||||||
|
"Expired": "期限切れ",
|
||||||
|
"Expires": "期限が切れます",
|
||||||
|
"I've saved my API key": "APIキーを保存しました",
|
||||||
|
"Last use": "最終使用",
|
||||||
|
"No API keys found": "APIキーが見つかりません",
|
||||||
|
"No expiration": "期限なし",
|
||||||
|
"Revoke API key": "APIキーを無効にする",
|
||||||
|
"Revoked successfully": "正常に無効化されました",
|
||||||
|
"Select expiration date": "有効期限を選択してください",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "この操作は元に戻せません。このAPIキーを使用しているアプリケーションは動作を停止します。",
|
||||||
|
"Update API key": "APIキーを更新",
|
||||||
|
"Manage API keys for all users in the workspace": "ワークスペース内のすべてのユーザーのAPIキーを管理",
|
||||||
|
"AI settings": "AI設定",
|
||||||
|
"AI search": "AI検索",
|
||||||
|
"AI Answer": "AI回答",
|
||||||
|
"Ask AI": "AIに質問する",
|
||||||
|
"AI is thinking...": "AIが考え中...",
|
||||||
|
"Ask a question...": "質問を入力...",
|
||||||
|
"AI-powered search (Ask AI)": "AIによる検索(AIに質問)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "AI検索はベクター埋め込みを使用して、ワークスペースコンテンツ全体にわたって意味検索機能を提供します。",
|
||||||
|
"Toggle AI search": "AI検索を切り替え",
|
||||||
|
"Sources": "ソース",
|
||||||
|
"Ask AI not available for attachments": "添付ファイルにはAI質問は利用できません",
|
||||||
|
"No answer available": "回答がありません",
|
||||||
|
"Background color": "背景色",
|
||||||
|
"Highlight color": "ハイライト色",
|
||||||
|
"Remove color": "色を削除"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "SSO 제공자 삭제",
|
"Delete SSO provider": "SSO 제공자 삭제",
|
||||||
"Are you sure you want to delete this SSO provider?": "이 SSO 제공자를 삭제하시겠습니까?",
|
"Are you sure you want to delete this SSO provider?": "이 SSO 제공자를 삭제하시겠습니까?",
|
||||||
"Action": "작업",
|
"Action": "작업",
|
||||||
"{{ssoProviderType}} configuration": "{{ssoProviderType}} 구성"
|
"{{ssoProviderType}} configuration": "{{ssoProviderType}} 구성",
|
||||||
|
"Icon": "아이콘",
|
||||||
|
"Upload image": "이미지 업로드",
|
||||||
|
"Remove image": "이미지 제거",
|
||||||
|
"Failed to remove image": "이미지 제거 실패",
|
||||||
|
"Image exceeds 10MB limit.": "이미지가 10MB 용량 제한을 초과합니다.",
|
||||||
|
"Image removed successfully": "이미지가 성공적으로 제거되었습니다",
|
||||||
|
"API key": "API 키",
|
||||||
|
"API key created successfully": "API 키 생성 완료",
|
||||||
|
"API keys": "API 키",
|
||||||
|
"API management": "API 관리",
|
||||||
|
"Are you sure you want to revoke this API key": "이 API 키를 취소하시겠습니까?",
|
||||||
|
"Create API Key": "API 키 생성",
|
||||||
|
"Custom expiration date": "사용자 정의 만료일",
|
||||||
|
"Enter a descriptive token name": "토큰 이름을 입력하세요",
|
||||||
|
"Expiration": "만료",
|
||||||
|
"Expired": "만료됨",
|
||||||
|
"Expires": "만료일",
|
||||||
|
"I've saved my API key": "API 키를 저장했습니다",
|
||||||
|
"Last use": "최근 사용",
|
||||||
|
"No API keys found": "API 키를 찾을 수 없습니다",
|
||||||
|
"No expiration": "유효기간 없음",
|
||||||
|
"Revoke API key": "API 키 취소",
|
||||||
|
"Revoked successfully": "성공적으로 취소되었습니다",
|
||||||
|
"Select expiration date": "만료일 선택",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "이 작업은 되돌릴 수 없습니다. 이 API 키를 사용하는 모든 응용 프로그램이 작동을 멈출 것입니다.",
|
||||||
|
"Update API key": "API 키 갱신",
|
||||||
|
"Manage API keys for all users in the workspace": "워크스페이스 내 모든 사용자의 API 키 관리",
|
||||||
|
"AI settings": "AI 설정",
|
||||||
|
"AI search": "AI 검색",
|
||||||
|
"AI Answer": "AI 답변",
|
||||||
|
"Ask AI": "AI에게 묻기",
|
||||||
|
"AI is thinking...": "AI가 생각 중입니다...",
|
||||||
|
"Ask a question...": "질문하세요...",
|
||||||
|
"AI-powered search (Ask AI)": "AI 지원 검색 (AI에게 묻기)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "AI 검색은 벡터 임베딩을 사용하여 작업공간 콘텐츠에 대한 의미 검색 기능을 제공합니다.",
|
||||||
|
"Toggle AI search": "AI 검색 전환",
|
||||||
|
"Sources": "출처",
|
||||||
|
"Ask AI not available for attachments": "AI에게 묻기 기능은 첨부 파일에 대해 사용할 수 없습니다",
|
||||||
|
"No answer available": "답변을 제공할 수 없습니다",
|
||||||
|
"Background color": "배경 색",
|
||||||
|
"Highlight color": "강조 색",
|
||||||
|
"Remove color": "색 제거"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
"Create group": "Groep aanmaken",
|
"Create group": "Groep aanmaken",
|
||||||
"Create page": "Pagina aanmaken",
|
"Create page": "Pagina aanmaken",
|
||||||
"Create space": "Ruimte aanmaken",
|
"Create space": "Ruimte aanmaken",
|
||||||
"Create workspace": "Wwerkruimte aanmaken",
|
"Create workspace": "Werkruimte aanmaken",
|
||||||
"Current password": "Huidig wachtwoord",
|
"Current password": "Huidig wachtwoord",
|
||||||
"Dark": "Donker",
|
"Dark": "Donker",
|
||||||
"Date": "Datum",
|
"Date": "Datum",
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
"Invite by email": "Uitnodigen via e-mail",
|
"Invite by email": "Uitnodigen via e-mail",
|
||||||
"Invite members": "Leden uitnodigen",
|
"Invite members": "Leden uitnodigen",
|
||||||
"Invite new members": "Nieuwe leden uitnodigen",
|
"Invite new members": "Nieuwe leden uitnodigen",
|
||||||
"Invited members who are yet to accept their invitation will appear here.": "Uigenodigde leden die hun uitnodiging nog moeten accepteren zullen hier worden getoond.",
|
"Invited members who are yet to accept their invitation will appear here.": "Uitgenodigde leden die hun uitnodiging nog moeten accepteren zullen hier worden getoond.",
|
||||||
"Invited members will be granted access to spaces the groups can access": "Uitgenodigde leden wordt toegang gegeven tot ruimtes de groepen toegang toe heeft",
|
"Invited members will be granted access to spaces the groups can access": "Uitgenodigde leden wordt toegang gegeven tot ruimtes de groepen toegang toe heeft",
|
||||||
"Join the workspace": "Word lid van de werkruimte",
|
"Join the workspace": "Word lid van de werkruimte",
|
||||||
"Language": "Taal",
|
"Language": "Taal",
|
||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "Verwijder SSO-provider",
|
"Delete SSO provider": "Verwijder SSO-provider",
|
||||||
"Are you sure you want to delete this SSO provider?": "Weet u zeker dat u deze SSO-provider wilt verwijderen?",
|
"Are you sure you want to delete this SSO provider?": "Weet u zeker dat u deze SSO-provider wilt verwijderen?",
|
||||||
"Action": "Actie",
|
"Action": "Actie",
|
||||||
"{{ssoProviderType}} configuration": "{{ssoProviderType}} configuratie"
|
"{{ssoProviderType}} configuration": "{{ssoProviderType}} configuratie",
|
||||||
|
"Icon": "Icoon",
|
||||||
|
"Upload image": "Afbeelding uploaden",
|
||||||
|
"Remove image": "Afbeelding verwijderen",
|
||||||
|
"Failed to remove image": "Afbeelding verwijderen mislukt",
|
||||||
|
"Image exceeds 10MB limit.": "Afbeelding overschrijdt de limiet van 10MB.",
|
||||||
|
"Image removed successfully": "Afbeelding succesvol verwijderd",
|
||||||
|
"API key": "API-sleutel",
|
||||||
|
"API key created successfully": "API-sleutel succesvol aangemaakt",
|
||||||
|
"API keys": "API-sleutels",
|
||||||
|
"API management": "API-beheer",
|
||||||
|
"Are you sure you want to revoke this API key": "Weet u zeker dat u deze API-sleutel wilt intrekken",
|
||||||
|
"Create API Key": "API-sleutel aanmaken",
|
||||||
|
"Custom expiration date": "Aangepaste vervaldatum",
|
||||||
|
"Enter a descriptive token name": "Voer een beschrijvende tokennaam in",
|
||||||
|
"Expiration": "Vervaldatum",
|
||||||
|
"Expired": "Verlopen",
|
||||||
|
"Expires": "Verloopt",
|
||||||
|
"I've saved my API key": "Ik heb mijn API-sleutel opgeslagen",
|
||||||
|
"Last use": "Laatst gebruikt",
|
||||||
|
"No API keys found": "Geen API-sleutels gevonden",
|
||||||
|
"No expiration": "Geen vervaldatum",
|
||||||
|
"Revoke API key": "API-sleutel intrekken",
|
||||||
|
"Revoked successfully": "Succesvol ingetrokken",
|
||||||
|
"Select expiration date": "Selecteer vervaldatum",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "Deze actie kan niet ongedaan worden gemaakt. Alle toepassingen die deze API-sleutel gebruiken, zullen niet meer werken.",
|
||||||
|
"Update API key": "API-sleutel bijwerken",
|
||||||
|
"Manage API keys for all users in the workspace": "Beheer API-sleutels voor alle gebruikers in de werkruimte",
|
||||||
|
"AI settings": "AI-instellingen",
|
||||||
|
"AI search": "AI-zoekopdracht",
|
||||||
|
"AI Answer": "AI Antwoord",
|
||||||
|
"Ask AI": "Vraag AI",
|
||||||
|
"AI is thinking...": "AI is aan het nadenken...",
|
||||||
|
"Ask a question...": "Stel een vraag...",
|
||||||
|
"AI-powered search (Ask AI)": "AI-ondersteunde zoekopdracht (Vraag AI)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "AI-zoekopdracht maakt gebruik van vectorembeddings om semantische zoekmogelijkheden te bieden in uw werkruimte-inhoud.",
|
||||||
|
"Toggle AI search": "Schakel AI-zoekopdracht in/uit",
|
||||||
|
"Sources": "Bronnen",
|
||||||
|
"Ask AI not available for attachments": "Vraag AI is niet beschikbaar voor bijlages",
|
||||||
|
"No answer available": "Geen antwoord beschikbaar",
|
||||||
|
"Background color": "Achtergrondkleur",
|
||||||
|
"Highlight color": "Markeerkleur",
|
||||||
|
"Remove color": "Kleur verwijderen"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "Excluir provedor de SSO",
|
"Delete SSO provider": "Excluir provedor de SSO",
|
||||||
"Are you sure you want to delete this SSO provider?": "Tem certeza de que deseja excluir este provedor de SSO?",
|
"Are you sure you want to delete this SSO provider?": "Tem certeza de que deseja excluir este provedor de SSO?",
|
||||||
"Action": "Ação",
|
"Action": "Ação",
|
||||||
"{{ssoProviderType}} configuration": "Configuração de {{ssoProviderType}}"
|
"{{ssoProviderType}} configuration": "Configuração de {{ssoProviderType}}",
|
||||||
|
"Icon": "Ícone",
|
||||||
|
"Upload image": "Fazer upload da imagem",
|
||||||
|
"Remove image": "Remover imagem",
|
||||||
|
"Failed to remove image": "Falha ao remover imagem",
|
||||||
|
"Image exceeds 10MB limit.": "A imagem excede o limite de 10MB.",
|
||||||
|
"Image removed successfully": "Imagem removida com sucesso",
|
||||||
|
"API key": "Chave API",
|
||||||
|
"API key created successfully": "Chave API criada com sucesso",
|
||||||
|
"API keys": "Chaves API",
|
||||||
|
"API management": "Gestão de API",
|
||||||
|
"Are you sure you want to revoke this API key": "Tem certeza de que deseja revogar esta chave API",
|
||||||
|
"Create API Key": "Criar Chave API",
|
||||||
|
"Custom expiration date": "Data de expiração personalizada",
|
||||||
|
"Enter a descriptive token name": "Insira um nome descritivo para o token",
|
||||||
|
"Expiration": "Expiração",
|
||||||
|
"Expired": "Expirado",
|
||||||
|
"Expires": "Expira",
|
||||||
|
"I've saved my API key": "Salvei minha chave API",
|
||||||
|
"Last use": "Último uso",
|
||||||
|
"No API keys found": "Nenhuma chave API encontrada",
|
||||||
|
"No expiration": "Sem expiração",
|
||||||
|
"Revoke API key": "Revogar chave API",
|
||||||
|
"Revoked successfully": "Revogada com sucesso",
|
||||||
|
"Select expiration date": "Selecionar data de expiração",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "Esta ação não pode ser desfeita. Qualquer aplicação usando esta chave API deixará de funcionar.",
|
||||||
|
"Update API key": "Atualizar chave API",
|
||||||
|
"Manage API keys for all users in the workspace": "Gerenciar chaves API para todos os usuários no espaço de trabalho",
|
||||||
|
"AI settings": "Configurações de IA",
|
||||||
|
"AI search": "Pesquisa IA",
|
||||||
|
"AI Answer": "Resposta de IA",
|
||||||
|
"Ask AI": "Pergunte à IA",
|
||||||
|
"AI is thinking...": "IA está pensando...",
|
||||||
|
"Ask a question...": "Faça uma pergunta...",
|
||||||
|
"AI-powered search (Ask AI)": "Pesquisa com IA (Pergunte à IA)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "A pesquisa IA usa vetores de incorporação para fornecer capacidades de pesquisa semântica em todo o conteúdo do seu espaço de trabalho.",
|
||||||
|
"Toggle AI search": "Alternar pesquisa de IA",
|
||||||
|
"Sources": "Fontes",
|
||||||
|
"Ask AI not available for attachments": "Perguntar à IA não está disponível para anexos",
|
||||||
|
"No answer available": "Nenhuma resposta disponível",
|
||||||
|
"Background color": "Cor de fundo",
|
||||||
|
"Highlight color": "Cor de destaque",
|
||||||
|
"Remove color": "Remover cor"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -498,10 +498,10 @@
|
|||||||
"Deleted at": "Удалено в",
|
"Deleted at": "Удалено в",
|
||||||
"Preview": "Предпросмотр",
|
"Preview": "Предпросмотр",
|
||||||
"Subpages": "Подстраницы",
|
"Subpages": "Подстраницы",
|
||||||
"Failed to load subpages": "Не удалось загрузить подстраницы",
|
"Failed to load subpages": "Не удалось загрузить под страницы",
|
||||||
"No subpages": "Нет подстраниц",
|
"No subpages": "Нет подстраниц",
|
||||||
"Subpages (Child pages)": "Подстраницы (вложенные страницы)",
|
"Subpages (Child pages)": "Подстраницы (вложенные страницы)",
|
||||||
"List all subpages of the current page": "Показать все подстраницы текущей страницы",
|
"List all subpages of the current page": "Показать все под страницы",
|
||||||
"Attachments": "Вложения",
|
"Attachments": "Вложения",
|
||||||
"All spaces": "Все пространства",
|
"All spaces": "Все пространства",
|
||||||
"Unknown": "Неизвестно",
|
"Unknown": "Неизвестно",
|
||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "Удалить поставщика SSO",
|
"Delete SSO provider": "Удалить поставщика SSO",
|
||||||
"Are you sure you want to delete this SSO provider?": "Вы уверены, что хотите удалить этого поставщика SSO?",
|
"Are you sure you want to delete this SSO provider?": "Вы уверены, что хотите удалить этого поставщика SSO?",
|
||||||
"Action": "Действие",
|
"Action": "Действие",
|
||||||
"{{ssoProviderType}} configuration": "Настройка {{ssoProviderType}}"
|
"{{ssoProviderType}} configuration": "Настройка {{ssoProviderType}}",
|
||||||
|
"Icon": "Иконка",
|
||||||
|
"Upload image": "Загрузить изображение",
|
||||||
|
"Remove image": "Удалить изображение",
|
||||||
|
"Failed to remove image": "Не удалось удалить изображение",
|
||||||
|
"Image exceeds 10MB limit.": "Изображение превышает предел 10MB.",
|
||||||
|
"Image removed successfully": "Изображение успешно удалено",
|
||||||
|
"API key": "API ключ",
|
||||||
|
"API key created successfully": "API ключ успешно создан",
|
||||||
|
"API keys": "API ключи",
|
||||||
|
"API management": "Управление API",
|
||||||
|
"Are you sure you want to revoke this API key": "Вы уверены, что хотите отозвать этот API ключ",
|
||||||
|
"Create API Key": "Создать API ключ",
|
||||||
|
"Custom expiration date": "Пользовательская дата срока действия",
|
||||||
|
"Enter a descriptive token name": "Введите понятное имя токена",
|
||||||
|
"Expiration": "Срок действия",
|
||||||
|
"Expired": "Истек",
|
||||||
|
"Expires": "Истекает",
|
||||||
|
"I've saved my API key": "Я сохранил мой API ключ",
|
||||||
|
"Last use": "Последнее использование",
|
||||||
|
"No API keys found": "API ключи не найдены",
|
||||||
|
"No expiration": "Не истекает",
|
||||||
|
"Revoke API key": "Отозвать API ключ",
|
||||||
|
"Revoked successfully": "Отозван успешно",
|
||||||
|
"Select expiration date": "Выберете срок действия",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "Это действие необратимо. Любые приложения, использующие этот API ключ, перестанут работать.",
|
||||||
|
"Update API key": "Обновить API ключ",
|
||||||
|
"Manage API keys for all users in the workspace": "Управлять API ключами для всех пользователей в рабочей области",
|
||||||
|
"AI settings": "Настройки ИИ",
|
||||||
|
"AI search": "Поиск ИИ",
|
||||||
|
"AI Answer": "Ответ ИИ",
|
||||||
|
"Ask AI": "Спросить ИИ",
|
||||||
|
"AI is thinking...": "ИИ обрабатывает запрос...",
|
||||||
|
"Ask a question...": "Задайте вопрос...",
|
||||||
|
"AI-powered search (Ask AI)": "Поиск на базе ИИ (Спросить ИИ)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "Поиск ИИ использует векторные встраивания для обеспечения семантического поиска по содержимому вашего рабочего пространства.",
|
||||||
|
"Toggle AI search": "Переключить поиск ИИ",
|
||||||
|
"Sources": "Источники",
|
||||||
|
"Ask AI not available for attachments": "Функция \"Спросить ИИ\" недоступна для вложений",
|
||||||
|
"No answer available": "Ответ недоступен",
|
||||||
|
"Background color": "Цвет фона",
|
||||||
|
"Highlight color": "Цвет выделения",
|
||||||
|
"Remove color": "Удалить цвет"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "Видалити постачальника SSO",
|
"Delete SSO provider": "Видалити постачальника SSO",
|
||||||
"Are you sure you want to delete this SSO provider?": "Ви впевнені, що хочете видалити цього постачальника SSO?",
|
"Are you sure you want to delete this SSO provider?": "Ви впевнені, що хочете видалити цього постачальника SSO?",
|
||||||
"Action": "Дія",
|
"Action": "Дія",
|
||||||
"{{ssoProviderType}} configuration": "Конфігурація {{ssoProviderType}}"
|
"{{ssoProviderType}} configuration": "Конфігурація {{ssoProviderType}}",
|
||||||
|
"Icon": "Іконка",
|
||||||
|
"Upload image": "Завантажити зображення",
|
||||||
|
"Remove image": "Видалити зображення",
|
||||||
|
"Failed to remove image": "Не вдалося видалити зображення",
|
||||||
|
"Image exceeds 10MB limit.": "Зображення має займати менше, ніж 10 МБ.",
|
||||||
|
"Image removed successfully": "Зображення видалено",
|
||||||
|
"API key": "Ключ API",
|
||||||
|
"API key created successfully": "Ключ API успішно створено",
|
||||||
|
"API keys": "Ключі API",
|
||||||
|
"API management": "Управління API",
|
||||||
|
"Are you sure you want to revoke this API key": "Ви впевнені, що хочете відкликати цей ключ API",
|
||||||
|
"Create API Key": "Створити ключ API",
|
||||||
|
"Custom expiration date": "Користувацька дата закінчення",
|
||||||
|
"Enter a descriptive token name": "Введіть описову назву токена",
|
||||||
|
"Expiration": "Термін дії",
|
||||||
|
"Expired": "Закінчився",
|
||||||
|
"Expires": "Закінчується",
|
||||||
|
"I've saved my API key": "Я зберіг свій ключ API",
|
||||||
|
"Last use": "Останнє використання",
|
||||||
|
"No API keys found": "Ключі API не знайдено",
|
||||||
|
"No expiration": "Без терміну дії",
|
||||||
|
"Revoke API key": "Відкликати ключ API",
|
||||||
|
"Revoked successfully": "Успішно відкликано",
|
||||||
|
"Select expiration date": "Виберіть дату закінчення",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "Цю дію не можна скасувати. Будь-які додатки, що використовують цей ключ API, перестануть працювати.",
|
||||||
|
"Update API key": "Оновити ключ API",
|
||||||
|
"Manage API keys for all users in the workspace": "Керувати ключами API для всіх користувачів у робочій області",
|
||||||
|
"AI settings": "Налаштування ШІ",
|
||||||
|
"AI search": "Пошук з ШІ",
|
||||||
|
"AI Answer": "Відповідь ШІ",
|
||||||
|
"Ask AI": "Запитати ШІ",
|
||||||
|
"AI is thinking...": "ШІ думає...",
|
||||||
|
"Ask a question...": "Задайте питання...",
|
||||||
|
"AI-powered search (Ask AI)": "Пошук на базі ШІ (Запитати ШІ)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "Пошук з ШІ використовує векторні вбудовування для надання можливостей семантичного пошуку у вашому робочому вмісті.",
|
||||||
|
"Toggle AI search": "Переключити пошук з ШІ",
|
||||||
|
"Sources": "Джерела",
|
||||||
|
"Ask AI not available for attachments": "Запитати ШІ недоступно для вкладень",
|
||||||
|
"No answer available": "Відповідь недоступна",
|
||||||
|
"Background color": "Колір фону",
|
||||||
|
"Highlight color": "Колір підсвічування",
|
||||||
|
"Remove color": "Видалити колір"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,5 +527,47 @@
|
|||||||
"Delete SSO provider": "删除SSO提供商",
|
"Delete SSO provider": "删除SSO提供商",
|
||||||
"Are you sure you want to delete this SSO provider?": "您确定要删除此SSO提供商吗?",
|
"Are you sure you want to delete this SSO provider?": "您确定要删除此SSO提供商吗?",
|
||||||
"Action": "操作",
|
"Action": "操作",
|
||||||
"{{ssoProviderType}} configuration": "{{ssoProviderType}} 配置"
|
"{{ssoProviderType}} configuration": "{{ssoProviderType}} 配置",
|
||||||
|
"Icon": "图标",
|
||||||
|
"Upload image": "上传图片",
|
||||||
|
"Remove image": "删除图片",
|
||||||
|
"Failed to remove image": "无法删除图片",
|
||||||
|
"Image exceeds 10MB limit.": "图片超过10MB限制。",
|
||||||
|
"Image removed successfully": "图片删除成功",
|
||||||
|
"API key": "API密钥",
|
||||||
|
"API key created successfully": "API密钥创建成功",
|
||||||
|
"API keys": "API密钥",
|
||||||
|
"API management": "API管理",
|
||||||
|
"Are you sure you want to revoke this API key": "确定要撤销此API密钥吗",
|
||||||
|
"Create API Key": "创建API密钥",
|
||||||
|
"Custom expiration date": "自定义到期日期",
|
||||||
|
"Enter a descriptive token name": "输入描述性令牌名称",
|
||||||
|
"Expiration": "到期",
|
||||||
|
"Expired": "已过期",
|
||||||
|
"Expires": "到期",
|
||||||
|
"I've saved my API key": "我已保存我的API密钥",
|
||||||
|
"Last use": "上次使用",
|
||||||
|
"No API keys found": "找不到API密钥",
|
||||||
|
"No expiration": "无到期",
|
||||||
|
"Revoke API key": "撤销API密钥",
|
||||||
|
"Revoked successfully": "撤销成功",
|
||||||
|
"Select expiration date": "选择到期日期",
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.": "此操作无法撤销。使用此API密钥的任何应用程序将停止工作。",
|
||||||
|
"Update API key": "更新API密钥",
|
||||||
|
"Manage API keys for all users in the workspace": "管理工作空间中所有用户的API密钥",
|
||||||
|
"AI settings": "AI设置",
|
||||||
|
"AI search": "AI搜索",
|
||||||
|
"AI Answer": "AI回答",
|
||||||
|
"Ask AI": "询问AI",
|
||||||
|
"AI is thinking...": "AI正在思考...",
|
||||||
|
"Ask a question...": "提问...",
|
||||||
|
"AI-powered search (Ask AI)": "AI驱动的搜索(询问AI)",
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.": "AI搜索使用向量嵌入提供跨工作空间内容的语义搜索功能。",
|
||||||
|
"Toggle AI search": "切换AI搜索",
|
||||||
|
"Sources": "来源",
|
||||||
|
"Ask AI not available for attachments": "附件不支持询问AI",
|
||||||
|
"No answer available": "无可用答案",
|
||||||
|
"Background color": "背景颜色",
|
||||||
|
"Highlight color": "突出显示颜色",
|
||||||
|
"Remove color": "移除颜色"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ import SpacesPage from "@/pages/spaces/spaces.tsx";
|
|||||||
import { MfaChallengePage } from "@/ee/mfa/pages/mfa-challenge-page";
|
import { MfaChallengePage } from "@/ee/mfa/pages/mfa-challenge-page";
|
||||||
import { MfaSetupRequiredPage } from "@/ee/mfa/pages/mfa-setup-required-page";
|
import { MfaSetupRequiredPage } from "@/ee/mfa/pages/mfa-setup-required-page";
|
||||||
import SpaceTrash from "@/pages/space/space-trash.tsx";
|
import SpaceTrash from "@/pages/space/space-trash.tsx";
|
||||||
|
import UserApiKeys from "@/ee/api-key/pages/user-api-keys";
|
||||||
|
import WorkspaceApiKeys from "@/ee/api-key/pages/workspace-api-keys";
|
||||||
|
import AiSettings from "@/ee/ai/pages/ai-settings.tsx";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -96,13 +99,16 @@ export default function App() {
|
|||||||
path={"account/preferences"}
|
path={"account/preferences"}
|
||||||
element={<AccountPreferences />}
|
element={<AccountPreferences />}
|
||||||
/>
|
/>
|
||||||
|
<Route path={"account/api-keys"} element={<UserApiKeys />} />
|
||||||
<Route path={"workspace"} element={<WorkspaceSettings />} />
|
<Route path={"workspace"} element={<WorkspaceSettings />} />
|
||||||
<Route path={"members"} element={<WorkspaceMembers />} />
|
<Route path={"members"} element={<WorkspaceMembers />} />
|
||||||
|
<Route path={"api-keys"} element={<WorkspaceApiKeys />} />
|
||||||
<Route path={"groups"} element={<Groups />} />
|
<Route path={"groups"} element={<Groups />} />
|
||||||
<Route path={"groups/:groupId"} element={<GroupInfo />} />
|
<Route path={"groups/:groupId"} element={<GroupInfo />} />
|
||||||
<Route path={"spaces"} element={<Spaces />} />
|
<Route path={"spaces"} element={<Spaces />} />
|
||||||
<Route path={"sharing"} element={<Shares />} />
|
<Route path={"sharing"} element={<Shares />} />
|
||||||
<Route path={"security"} element={<Security />} />
|
<Route path={"security"} element={<Security />} />
|
||||||
|
<Route path={"ai"} element={<AiSettings />} />
|
||||||
{!isCloud() && <Route path={"license"} element={<License />} />}
|
{!isCloud() && <Route path={"license"} element={<License />} />}
|
||||||
{isCloud() && <Route path={"billing"} element={<Billing />} />}
|
{isCloud() && <Route path={"billing"} element={<Billing />} />}
|
||||||
</Route>
|
</Route>
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ import { useTranslation } from "react-i18next";
|
|||||||
|
|
||||||
interface NoTableResultsProps {
|
interface NoTableResultsProps {
|
||||||
colSpan: number;
|
colSpan: number;
|
||||||
|
text?: string;
|
||||||
}
|
}
|
||||||
export default function NoTableResults({ colSpan }: NoTableResultsProps) {
|
export default function NoTableResults({ colSpan, text }: NoTableResultsProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<Table.Tr>
|
<Table.Tr>
|
||||||
<Table.Td colSpan={colSpan}>
|
<Table.Td colSpan={colSpan}>
|
||||||
<Text fw={500} c="dimmed" ta="center">
|
<Text fw={500} c="dimmed" ta="center">
|
||||||
{t("No results found...")}
|
{text || t("No results found...")}
|
||||||
</Text>
|
</Text>
|
||||||
</Table.Td>
|
</Table.Td>
|
||||||
</Table.Tr>
|
</Table.Tr>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { getWorkspaceMembers } from "@/features/workspace/services/workspace-ser
|
|||||||
import { getLicenseInfo } from "@/ee/licence/services/license-service.ts";
|
import { getLicenseInfo } from "@/ee/licence/services/license-service.ts";
|
||||||
import { getSsoProviders } from "@/ee/security/services/security-service.ts";
|
import { getSsoProviders } from "@/ee/security/services/security-service.ts";
|
||||||
import { getShares } from "@/features/share/services/share-service.ts";
|
import { getShares } from "@/features/share/services/share-service.ts";
|
||||||
|
import { getApiKeys } from "@/ee/api-key";
|
||||||
|
|
||||||
export const prefetchWorkspaceMembers = () => {
|
export const prefetchWorkspaceMembers = () => {
|
||||||
const params = { limit: 100, page: 1, query: "" } as QueryParams;
|
const params = { limit: 100, page: 1, query: "" } as QueryParams;
|
||||||
@@ -65,3 +66,17 @@ export const prefetchShares = () => {
|
|||||||
queryFn: () => getShares({ page: 1, limit: 100 }),
|
queryFn: () => getShares({ page: 1, limit: 100 }),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const prefetchApiKeys = () => {
|
||||||
|
queryClient.prefetchQuery({
|
||||||
|
queryKey: ["api-key-list", { page: 1 }],
|
||||||
|
queryFn: () => getApiKeys({ page: 1 }),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const prefetchApiKeyManagement = () => {
|
||||||
|
queryClient.prefetchQuery({
|
||||||
|
queryKey: ["api-key-list", { page: 1 }],
|
||||||
|
queryFn: () => getApiKeys({ page: 1, adminView: true }),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -12,15 +12,18 @@ import {
|
|||||||
IconLock,
|
IconLock,
|
||||||
IconKey,
|
IconKey,
|
||||||
IconWorld,
|
IconWorld,
|
||||||
|
IconSparkles,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
import classes from "./settings.module.css";
|
import classes from "./settings.module.css";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { isCloud } from "@/lib/config.ts";
|
import { isCloud } from "@/lib/config.ts";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
import { useAtom } from "jotai/index";
|
import { useAtom } from "jotai";
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||||
import {
|
import {
|
||||||
|
prefetchApiKeyManagement,
|
||||||
|
prefetchApiKeys,
|
||||||
prefetchBilling,
|
prefetchBilling,
|
||||||
prefetchGroups,
|
prefetchGroups,
|
||||||
prefetchLicense,
|
prefetchLicense,
|
||||||
@@ -60,6 +63,14 @@ const groupedData: DataGroup[] = [
|
|||||||
icon: IconBrush,
|
icon: IconBrush,
|
||||||
path: "/settings/account/preferences",
|
path: "/settings/account/preferences",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "API keys",
|
||||||
|
icon: IconKey,
|
||||||
|
path: "/settings/account/api-keys",
|
||||||
|
isCloud: true,
|
||||||
|
isEnterprise: true,
|
||||||
|
showDisabledInNonEE: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -90,6 +101,22 @@ const groupedData: DataGroup[] = [
|
|||||||
{ label: "Groups", icon: IconUsersGroup, path: "/settings/groups" },
|
{ label: "Groups", icon: IconUsersGroup, path: "/settings/groups" },
|
||||||
{ label: "Spaces", icon: IconSpaces, path: "/settings/spaces" },
|
{ label: "Spaces", icon: IconSpaces, path: "/settings/spaces" },
|
||||||
{ label: "Public sharing", icon: IconWorld, path: "/settings/sharing" },
|
{ label: "Public sharing", icon: IconWorld, path: "/settings/sharing" },
|
||||||
|
{
|
||||||
|
label: "API management",
|
||||||
|
icon: IconKey,
|
||||||
|
path: "/settings/api-keys",
|
||||||
|
isCloud: true,
|
||||||
|
isEnterprise: true,
|
||||||
|
isAdmin: true,
|
||||||
|
showDisabledInNonEE: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "AI settings",
|
||||||
|
icon: IconSparkles,
|
||||||
|
path: "/settings/ai",
|
||||||
|
isAdmin: true,
|
||||||
|
isSelfhosted: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -195,6 +222,12 @@ export default function SettingsSidebar() {
|
|||||||
case "Public sharing":
|
case "Public sharing":
|
||||||
prefetchHandler = prefetchShares;
|
prefetchHandler = prefetchShares;
|
||||||
break;
|
break;
|
||||||
|
case "API keys":
|
||||||
|
prefetchHandler = prefetchApiKeys;
|
||||||
|
break;
|
||||||
|
case "API management":
|
||||||
|
prefetchHandler = prefetchApiKeyManagement;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import React, { useMemo } from "react";
|
||||||
|
import { Paper, Text, Group, Stack, Loader, Box } from "@mantine/core";
|
||||||
|
import { IconSparkles, IconFileText } from "@tabler/icons-react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import { IAiSearchResponse } from "../services/ai-search-service.ts";
|
||||||
|
import { buildPageUrl } from "@/features/page/page.utils.ts";
|
||||||
|
import { markdownToHtml } from "@docmost/editor-ext";
|
||||||
|
import DOMPurify from "dompurify";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
interface AiSearchResultProps {
|
||||||
|
result?: IAiSearchResponse;
|
||||||
|
isLoading?: boolean;
|
||||||
|
streamingAnswer?: string;
|
||||||
|
streamingSources?: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AiSearchResult({
|
||||||
|
result,
|
||||||
|
isLoading,
|
||||||
|
streamingAnswer = "",
|
||||||
|
streamingSources = [],
|
||||||
|
}: AiSearchResultProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
// Use streaming data if available, otherwise fall back to result
|
||||||
|
const answer = streamingAnswer || result?.answer || "";
|
||||||
|
const sources =
|
||||||
|
streamingSources.length > 0 ? streamingSources : result?.sources || [];
|
||||||
|
|
||||||
|
// Deduplicate sources by pageId, keeping the one with highest similarity
|
||||||
|
const deduplicatedSources = useMemo(() => {
|
||||||
|
if (!sources || sources.length === 0) return [];
|
||||||
|
|
||||||
|
const pageMap = new Map();
|
||||||
|
sources.forEach((source) => {
|
||||||
|
const existing = pageMap.get(source.pageId);
|
||||||
|
if (!existing || source.similarity > existing.similarity) {
|
||||||
|
pageMap.set(source.pageId, source);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return Array.from(pageMap.values());
|
||||||
|
}, [sources]);
|
||||||
|
|
||||||
|
if (isLoading && !answer) {
|
||||||
|
return (
|
||||||
|
<Paper p="md" radius="md" withBorder>
|
||||||
|
<Group>
|
||||||
|
<Loader size="sm" />
|
||||||
|
<Text size="sm">{t("AI is thinking...")}</Text>
|
||||||
|
</Group>
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!answer && !isLoading) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack gap="md" p="md">
|
||||||
|
<Paper p="md" radius="md" withBorder>
|
||||||
|
<Group gap="xs" mb="sm">
|
||||||
|
<IconSparkles size={20} color="var(--mantine-color-blue-6)" />
|
||||||
|
<Text fw={600} size="sm">
|
||||||
|
{t("AI Answer")}
|
||||||
|
</Text>
|
||||||
|
{isLoading && <Loader size="xs" />}
|
||||||
|
</Group>
|
||||||
|
<div
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: DOMPurify.sanitize(markdownToHtml(answer) as string),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
{deduplicatedSources.length > 0 && (
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Text size="xs" fw={600} c="dimmed">
|
||||||
|
{t("Sources")}
|
||||||
|
</Text>
|
||||||
|
{deduplicatedSources.map((source) => (
|
||||||
|
<Box
|
||||||
|
key={source.pageId}
|
||||||
|
component={Link}
|
||||||
|
to={buildPageUrl(source.spaceSlug, source.slugId, source.title)}
|
||||||
|
style={{
|
||||||
|
textDecoration: "none",
|
||||||
|
color: "inherit",
|
||||||
|
display: "block",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Paper
|
||||||
|
p="xs"
|
||||||
|
radius="sm"
|
||||||
|
withBorder
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
<Group gap="xs">
|
||||||
|
<IconFileText size={16} />
|
||||||
|
<Text size="sm" truncate>
|
||||||
|
{source.title}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import { Group, Text, Switch, MantineSize, Title } from "@mantine/core";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||||
|
import { notifications } from "@mantine/notifications";
|
||||||
|
import { isCloud } from "@/lib/config.ts";
|
||||||
|
import useLicense from "@/ee/hooks/use-license.tsx";
|
||||||
|
|
||||||
|
export default function EnableAiSearch() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Group justify="space-between" wrap="nowrap" gap="xl">
|
||||||
|
<div>
|
||||||
|
<Text size="md">{t("AI-powered search (Ask AI)")}</Text>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{t(
|
||||||
|
"AI search uses vector embeddings to provide semantic search capabilities across your workspace content.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<AiSearchToggle />
|
||||||
|
</Group>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AiSearchToggleProps {
|
||||||
|
size?: MantineSize;
|
||||||
|
label?: string;
|
||||||
|
}
|
||||||
|
export function AiSearchToggle({ size, label }: AiSearchToggleProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||||
|
const [checked, setChecked] = useState(workspace?.settings?.ai?.search);
|
||||||
|
const { hasLicenseKey } = useLicense();
|
||||||
|
|
||||||
|
const hasAccess = isCloud() || (!isCloud() && hasLicenseKey);
|
||||||
|
|
||||||
|
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const value = event.currentTarget.checked;
|
||||||
|
try {
|
||||||
|
const updatedWorkspace = await updateWorkspace({ aiSearch: value });
|
||||||
|
setChecked(value);
|
||||||
|
setWorkspace(updatedWorkspace);
|
||||||
|
} catch (err) {
|
||||||
|
notifications.show({
|
||||||
|
message: err?.response?.data?.message,
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Switch
|
||||||
|
size={size}
|
||||||
|
label={label}
|
||||||
|
labelPosition="left"
|
||||||
|
defaultChecked={checked}
|
||||||
|
onChange={handleChange}
|
||||||
|
disabled={!hasAccess}
|
||||||
|
aria-label={t("Toggle AI search")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useMutation, UseMutationResult } from "@tanstack/react-query";
|
||||||
|
import { useState, useCallback } from "react";
|
||||||
|
import { askAi, IAiSearchResponse } from "@/ee/ai/services/ai-search-service.ts";
|
||||||
|
import { IPageSearchParams } from "@/features/search/types/search.types.ts";
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
interface UseAiSearchResult extends UseMutationResult<IAiSearchResponse, Error, IPageSearchParams> {
|
||||||
|
streamingAnswer: string;
|
||||||
|
streamingSources: any[];
|
||||||
|
clearStreaming: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAiSearch(): UseAiSearchResult {
|
||||||
|
const [streamingAnswer, setStreamingAnswer] = useState("");
|
||||||
|
const [streamingSources, setStreamingSources] = useState<any[]>([]);
|
||||||
|
|
||||||
|
const clearStreaming = useCallback(() => {
|
||||||
|
setStreamingAnswer("");
|
||||||
|
setStreamingSources([]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const mutation = useMutation({
|
||||||
|
mutationFn: async (params: IPageSearchParams & { contentType?: string }) => {
|
||||||
|
setStreamingAnswer("");
|
||||||
|
setStreamingSources([]);
|
||||||
|
|
||||||
|
const { contentType, ...apiParams } = params;
|
||||||
|
|
||||||
|
return await askAi(apiParams, (chunk) => {
|
||||||
|
if (chunk.content) {
|
||||||
|
setStreamingAnswer((prev) => prev + chunk.content);
|
||||||
|
}
|
||||||
|
if (chunk.sources) {
|
||||||
|
setStreamingSources(chunk.sources);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...mutation,
|
||||||
|
streamingAnswer,
|
||||||
|
streamingSources,
|
||||||
|
clearStreaming,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { useState, useCallback, useRef } from "react";
|
||||||
|
import { useAiGenerateStreamMutation } from "@/ee/ai/queries/ai-query.ts";
|
||||||
|
import { AiGenerateDto } from "@/ee/ai/types/ai.types.ts";
|
||||||
|
|
||||||
|
export function useAiStream() {
|
||||||
|
const [content, setContent] = useState("");
|
||||||
|
const [isStreaming, setIsStreaming] = useState(false);
|
||||||
|
const abortControllerRef = useRef<AbortController | null>(null);
|
||||||
|
const mutation = useAiGenerateStreamMutation();
|
||||||
|
|
||||||
|
const startStream = useCallback(
|
||||||
|
async (data: AiGenerateDto) => {
|
||||||
|
setContent("");
|
||||||
|
setIsStreaming(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const controller = await mutation.mutateAsync({
|
||||||
|
...data,
|
||||||
|
onChunk: (chunk) => {
|
||||||
|
setContent((prev) => prev + chunk.content);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error("AI stream error:", error);
|
||||||
|
setIsStreaming(false);
|
||||||
|
},
|
||||||
|
onComplete: () => {
|
||||||
|
setIsStreaming(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
abortControllerRef.current = controller;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to start stream:", error);
|
||||||
|
setIsStreaming(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[mutation]
|
||||||
|
);
|
||||||
|
|
||||||
|
const stopStream = useCallback(() => {
|
||||||
|
if (abortControllerRef.current) {
|
||||||
|
abortControllerRef.current.abort();
|
||||||
|
abortControllerRef.current = null;
|
||||||
|
setIsStreaming(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const resetContent = useCallback(() => {
|
||||||
|
setContent("");
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
content,
|
||||||
|
isStreaming,
|
||||||
|
startStream,
|
||||||
|
stopStream,
|
||||||
|
resetContent,
|
||||||
|
isLoading: mutation.isPending,
|
||||||
|
error: mutation.error,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName, isCloud } from "@/lib/config.ts";
|
||||||
|
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||||
|
import React from "react";
|
||||||
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import useLicense from "@/ee/hooks/use-license.tsx";
|
||||||
|
import EnableAiSearch from "@/ee/ai/components/enable-ai-search.tsx";
|
||||||
|
import { Alert } from "@mantine/core";
|
||||||
|
import { IconInfoCircle } from "@tabler/icons-react";
|
||||||
|
|
||||||
|
export default function AiSettings() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { isAdmin } = useUserRole();
|
||||||
|
const { hasLicenseKey } = useLicense();
|
||||||
|
|
||||||
|
if (!isAdmin) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasAccess = isCloud() || (!isCloud() && hasLicenseKey);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Helmet>
|
||||||
|
<title>AI - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
|
<SettingsTitle title={t("AI settings")} />
|
||||||
|
|
||||||
|
{!hasAccess && (
|
||||||
|
<Alert
|
||||||
|
icon={<IconInfoCircle />}
|
||||||
|
title={t("Enterprise feature")}
|
||||||
|
color="blue"
|
||||||
|
mb="lg"
|
||||||
|
>
|
||||||
|
{t(
|
||||||
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.",
|
||||||
|
)}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<EnableAiSearch />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import {
|
||||||
|
useMutation,
|
||||||
|
UseMutationResult,
|
||||||
|
useQuery,
|
||||||
|
UseQueryResult,
|
||||||
|
} from "@tanstack/react-query";
|
||||||
|
import {
|
||||||
|
generateAiContent,
|
||||||
|
generateAiContentStream,
|
||||||
|
} from "@/ee/ai/services/ai-service.ts";
|
||||||
|
import {
|
||||||
|
AiConfigResponse,
|
||||||
|
AiContentResponse,
|
||||||
|
AiGenerateDto,
|
||||||
|
AiStreamChunk,
|
||||||
|
AiStreamError,
|
||||||
|
} from "@/ee/ai/types/ai.types.ts";
|
||||||
|
|
||||||
|
export function useAiGenerateMutation(): UseMutationResult<
|
||||||
|
AiContentResponse,
|
||||||
|
Error,
|
||||||
|
AiGenerateDto
|
||||||
|
> {
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (data: AiGenerateDto) => generateAiContent(data),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StreamCallbacks {
|
||||||
|
onChunk: (chunk: AiStreamChunk) => void;
|
||||||
|
onError?: (error: AiStreamError) => void;
|
||||||
|
onComplete?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAiGenerateStreamMutation(): UseMutationResult<
|
||||||
|
AbortController,
|
||||||
|
Error,
|
||||||
|
AiGenerateDto & StreamCallbacks
|
||||||
|
> {
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ onChunk, onError, onComplete, ...data }) =>
|
||||||
|
generateAiContentStream(data, onChunk, onError, onComplete),
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import api from "@/lib/api-client.ts";
|
||||||
|
import { IPageSearchParams } from "@/features/search/types/search.types.ts";
|
||||||
|
|
||||||
|
export interface IAiSearchResponse {
|
||||||
|
answer: string;
|
||||||
|
sources?: Array<{
|
||||||
|
pageId: string;
|
||||||
|
title: string;
|
||||||
|
slugId: string;
|
||||||
|
spaceSlug: string;
|
||||||
|
similarity: number;
|
||||||
|
distance: number;
|
||||||
|
chunkIndex: number;
|
||||||
|
excerpt: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function askAi(
|
||||||
|
params: IPageSearchParams,
|
||||||
|
onChunk?: (chunk: { content?: string; sources?: any[] }) => void,
|
||||||
|
): Promise<IAiSearchResponse> {
|
||||||
|
const response = await fetch("/api/ai/ask", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
credentials: "include",
|
||||||
|
body: JSON.stringify(params),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const reader = response.body?.getReader();
|
||||||
|
const decoder = new TextDecoder();
|
||||||
|
|
||||||
|
let answer = "";
|
||||||
|
let sources: any[] = [];
|
||||||
|
let buffer = "";
|
||||||
|
|
||||||
|
if (reader) {
|
||||||
|
while (true) {
|
||||||
|
const { done, value } = await reader.read();
|
||||||
|
if (done) break;
|
||||||
|
|
||||||
|
buffer += decoder.decode(value, { stream: true });
|
||||||
|
const lines = buffer.split("\n");
|
||||||
|
|
||||||
|
// Keep the last incomplete line in the buffer
|
||||||
|
buffer = lines.pop() || "";
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.startsWith("data: ")) {
|
||||||
|
const data = line.slice(6);
|
||||||
|
if (data === "[DONE]") break;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(data);
|
||||||
|
if (parsed.error) {
|
||||||
|
throw new Error(parsed.error);
|
||||||
|
}
|
||||||
|
if (parsed.content) {
|
||||||
|
answer += parsed.content;
|
||||||
|
onChunk?.({ content: parsed.content });
|
||||||
|
}
|
||||||
|
if (parsed.sources) {
|
||||||
|
sources = parsed.sources;
|
||||||
|
onChunk?.({ sources: parsed.sources });
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
// Skip invalid JSON
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { answer, sources };
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import api from "@/lib/api-client.ts";
|
||||||
|
import {
|
||||||
|
AiGenerateDto,
|
||||||
|
AiContentResponse,
|
||||||
|
AiStreamChunk,
|
||||||
|
AiStreamError,
|
||||||
|
} from "@/ee/ai/types/ai.types.ts";
|
||||||
|
|
||||||
|
export async function generateAiContent(
|
||||||
|
data: AiGenerateDto,
|
||||||
|
): Promise<AiContentResponse> {
|
||||||
|
const req = await api.post<AiContentResponse>("/ai/generate", data);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generateAiContentStream(
|
||||||
|
data: AiGenerateDto,
|
||||||
|
onChunk: (chunk: AiStreamChunk) => void,
|
||||||
|
onError?: (error: AiStreamError) => void,
|
||||||
|
onComplete?: () => void,
|
||||||
|
): Promise<AbortController> {
|
||||||
|
const abortController = new AbortController();
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/ai/generate/stream", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
signal: abortController.signal,
|
||||||
|
credentials: "include", // This ensures cookies are sent, matching axios withCredentials
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const reader = response.body?.getReader();
|
||||||
|
const decoder = new TextDecoder();
|
||||||
|
|
||||||
|
if (!reader) {
|
||||||
|
throw new Error("Response body is not readable");
|
||||||
|
}
|
||||||
|
|
||||||
|
const processStream = async () => {
|
||||||
|
try {
|
||||||
|
while (true) {
|
||||||
|
const { done, value } = await reader.read();
|
||||||
|
if (done) break;
|
||||||
|
|
||||||
|
const chunk = decoder.decode(value, { stream: true });
|
||||||
|
const lines = chunk.split("\n");
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.startsWith("data: ")) {
|
||||||
|
const data = line.slice(6);
|
||||||
|
if (data === "[DONE]") {
|
||||||
|
onComplete?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(data);
|
||||||
|
if (parsed.error) {
|
||||||
|
onError?.(parsed);
|
||||||
|
} else {
|
||||||
|
onChunk(parsed);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore parse errors for incomplete chunks
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error.name !== "AbortError") {
|
||||||
|
onError?.({ error: error.message });
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
reader.releaseLock();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
processStream();
|
||||||
|
} catch (error) {
|
||||||
|
onError?.({ error: error.message });
|
||||||
|
}
|
||||||
|
|
||||||
|
return abortController;
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
export enum AiAction {
|
||||||
|
IMPROVE_WRITING = "improve_writing",
|
||||||
|
FIX_SPELLING_GRAMMAR = "fix_spelling_grammar",
|
||||||
|
MAKE_SHORTER = "make_shorter",
|
||||||
|
MAKE_LONGER = "make_longer",
|
||||||
|
SIMPLIFY = "simplify",
|
||||||
|
CHANGE_TONE = "change_tone",
|
||||||
|
SUMMARIZE = "summarize",
|
||||||
|
CONTINUE_WRITING = "continue_writing",
|
||||||
|
TRANSLATE = "translate",
|
||||||
|
CUSTOM = "custom",
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AiGenerateDto {
|
||||||
|
action?: AiAction;
|
||||||
|
content: string;
|
||||||
|
prompt?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AiContentResponse {
|
||||||
|
content: string;
|
||||||
|
usage?: {
|
||||||
|
promptTokens: number;
|
||||||
|
completionTokens: number;
|
||||||
|
totalTokens: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AiConfigResponse {
|
||||||
|
configured: boolean;
|
||||||
|
availableActions: AiAction[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AiStreamChunk {
|
||||||
|
content: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AiStreamError {
|
||||||
|
error: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import {
|
||||||
|
Modal,
|
||||||
|
Text,
|
||||||
|
Stack,
|
||||||
|
Alert,
|
||||||
|
Group,
|
||||||
|
Button,
|
||||||
|
TextInput,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { IconAlertTriangle } from "@tabler/icons-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { IApiKey } from "@/ee/api-key";
|
||||||
|
import CopyTextButton from "@/components/common/copy.tsx";
|
||||||
|
|
||||||
|
interface ApiKeyCreatedModalProps {
|
||||||
|
opened: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
apiKey: IApiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiKeyCreatedModal({
|
||||||
|
opened,
|
||||||
|
onClose,
|
||||||
|
apiKey,
|
||||||
|
}: ApiKeyCreatedModalProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
if (!apiKey) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={onClose}
|
||||||
|
title={t("API key created")}
|
||||||
|
size="lg"
|
||||||
|
>
|
||||||
|
<Stack gap="md">
|
||||||
|
<Alert
|
||||||
|
icon={<IconAlertTriangle size={16} />}
|
||||||
|
title={t("Important")}
|
||||||
|
color="red"
|
||||||
|
>
|
||||||
|
{t(
|
||||||
|
"Make sure to copy your API key now. You won't be able to see it again!",
|
||||||
|
)}
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Text size="sm" fw={500} mb="xs">
|
||||||
|
{t("API key")}
|
||||||
|
</Text>
|
||||||
|
<Group gap="xs" wrap="nowrap">
|
||||||
|
<TextInput
|
||||||
|
variant="filled"
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
value={apiKey.token}
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CopyTextButton text={apiKey.token} />
|
||||||
|
</Group>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button fullWidth onClick={onClose} mt="md">
|
||||||
|
{t("I've saved my API key")}
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
import { ActionIcon, Group, Menu, Table, Text } from "@mantine/core";
|
||||||
|
import { IconDots, IconEdit, IconTrash } from "@tabler/icons-react";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { IApiKey } from "@/ee/api-key";
|
||||||
|
import { CustomAvatar } from "@/components/ui/custom-avatar.tsx";
|
||||||
|
import React from "react";
|
||||||
|
import NoTableResults from "@/components/common/no-table-results";
|
||||||
|
|
||||||
|
interface ApiKeyTableProps {
|
||||||
|
apiKeys: IApiKey[];
|
||||||
|
isLoading?: boolean;
|
||||||
|
showUserColumn?: boolean;
|
||||||
|
onUpdate?: (apiKey: IApiKey) => void;
|
||||||
|
onRevoke?: (apiKey: IApiKey) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiKeyTable({
|
||||||
|
apiKeys,
|
||||||
|
isLoading,
|
||||||
|
showUserColumn = false,
|
||||||
|
onUpdate,
|
||||||
|
onRevoke,
|
||||||
|
}: ApiKeyTableProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const formatDate = (date: Date | string | null) => {
|
||||||
|
if (!date) return t("Never");
|
||||||
|
return format(new Date(date), "MMM dd, yyyy");
|
||||||
|
};
|
||||||
|
|
||||||
|
const isExpired = (expiresAt: string | null) => {
|
||||||
|
if (!expiresAt) return false;
|
||||||
|
return new Date(expiresAt) < new Date();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table.ScrollContainer minWidth={500}>
|
||||||
|
<Table highlightOnHover verticalSpacing="sm">
|
||||||
|
<Table.Thead>
|
||||||
|
<Table.Tr>
|
||||||
|
<Table.Th>{t("Name")}</Table.Th>
|
||||||
|
{showUserColumn && <Table.Th>{t("User")}</Table.Th>}
|
||||||
|
<Table.Th>{t("Last used")}</Table.Th>
|
||||||
|
<Table.Th>{t("Expires")}</Table.Th>
|
||||||
|
<Table.Th>{t("Created")}</Table.Th>
|
||||||
|
<Table.Th></Table.Th>
|
||||||
|
</Table.Tr>
|
||||||
|
</Table.Thead>
|
||||||
|
|
||||||
|
<Table.Tbody>
|
||||||
|
{apiKeys && apiKeys.length > 0 ? (
|
||||||
|
apiKeys.map((apiKey: IApiKey, index: number) => (
|
||||||
|
<Table.Tr key={index}>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" fw={500}>
|
||||||
|
{apiKey.name}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
|
||||||
|
{showUserColumn && apiKey.creator && (
|
||||||
|
<Table.Td>
|
||||||
|
<Group gap="4" wrap="nowrap">
|
||||||
|
<CustomAvatar
|
||||||
|
avatarUrl={apiKey.creator?.avatarUrl}
|
||||||
|
name={apiKey.creator.name}
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
|
<Text fz="sm" lineClamp={1}>
|
||||||
|
{apiKey.creator.name}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
</Table.Td>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{formatDate(apiKey.lastUsedAt)}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
|
||||||
|
<Table.Td>
|
||||||
|
{apiKey.expiresAt ? (
|
||||||
|
isExpired(apiKey.expiresAt) ? (
|
||||||
|
<Text fz="sm" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{t("Expired")}
|
||||||
|
</Text>
|
||||||
|
) : (
|
||||||
|
<Text fz="sm" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{formatDate(apiKey.expiresAt)}
|
||||||
|
</Text>
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<Text fz="sm" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{t("Never")}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Table.Td>
|
||||||
|
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{formatDate(apiKey.createdAt)}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
|
||||||
|
<Table.Td>
|
||||||
|
<Menu position="bottom-end" withinPortal>
|
||||||
|
<Menu.Target>
|
||||||
|
<ActionIcon variant="subtle" color="gray">
|
||||||
|
<IconDots size={16} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Menu.Target>
|
||||||
|
<Menu.Dropdown>
|
||||||
|
{onUpdate && (
|
||||||
|
<Menu.Item
|
||||||
|
leftSection={<IconEdit size={16} />}
|
||||||
|
onClick={() => onUpdate(apiKey)}
|
||||||
|
>
|
||||||
|
{t("Rename")}
|
||||||
|
</Menu.Item>
|
||||||
|
)}
|
||||||
|
{onRevoke && (
|
||||||
|
<Menu.Item
|
||||||
|
leftSection={<IconTrash size={16} />}
|
||||||
|
color="red"
|
||||||
|
onClick={() => onRevoke(apiKey)}
|
||||||
|
>
|
||||||
|
{t("Revoke")}
|
||||||
|
</Menu.Item>
|
||||||
|
)}
|
||||||
|
</Menu.Dropdown>
|
||||||
|
</Menu>
|
||||||
|
</Table.Td>
|
||||||
|
</Table.Tr>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<NoTableResults colSpan={showUserColumn ? 6 : 5} />
|
||||||
|
)}
|
||||||
|
</Table.Tbody>
|
||||||
|
</Table>
|
||||||
|
</Table.ScrollContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
import { lazy, Suspense, useState } from "react";
|
||||||
|
import { Modal, TextInput, Button, Group, Stack, Select } from "@mantine/core";
|
||||||
|
import { useForm } from "@mantine/form";
|
||||||
|
import { zodResolver } from "mantine-form-zod-resolver";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useCreateApiKeyMutation } from "@/ee/api-key/queries/api-key-query";
|
||||||
|
import { IconCalendar } from "@tabler/icons-react";
|
||||||
|
import { IApiKey } from "@/ee/api-key";
|
||||||
|
|
||||||
|
const DateInput = lazy(() =>
|
||||||
|
import("@mantine/dates").then((module) => ({
|
||||||
|
default: module.DateInput,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
interface CreateApiKeyModalProps {
|
||||||
|
opened: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
onSuccess: (response: IApiKey) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
name: z.string().min(1, "Name is required"),
|
||||||
|
expiresAt: z.string().optional(),
|
||||||
|
});
|
||||||
|
type FormValues = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
|
export function CreateApiKeyModal({
|
||||||
|
opened,
|
||||||
|
onClose,
|
||||||
|
onSuccess,
|
||||||
|
}: CreateApiKeyModalProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [expirationOption, setExpirationOption] = useState<string>("30");
|
||||||
|
const createApiKeyMutation = useCreateApiKeyMutation();
|
||||||
|
|
||||||
|
const form = useForm<FormValues>({
|
||||||
|
validate: zodResolver(formSchema),
|
||||||
|
initialValues: {
|
||||||
|
name: "",
|
||||||
|
expiresAt: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const getExpirationDate = (): string | undefined => {
|
||||||
|
if (expirationOption === "never") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (expirationOption === "custom") {
|
||||||
|
return form.values.expiresAt;
|
||||||
|
}
|
||||||
|
const days = parseInt(expirationOption);
|
||||||
|
const date = new Date();
|
||||||
|
date.setDate(date.getDate() + days);
|
||||||
|
return date.toISOString();
|
||||||
|
};
|
||||||
|
|
||||||
|
const getExpirationLabel = (days: number) => {
|
||||||
|
const date = new Date();
|
||||||
|
date.setDate(date.getDate() + days);
|
||||||
|
const formatted = date.toLocaleDateString("en-US", {
|
||||||
|
month: "short",
|
||||||
|
day: "2-digit",
|
||||||
|
year: "numeric",
|
||||||
|
});
|
||||||
|
return `${days} days (${formatted})`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const expirationOptions = [
|
||||||
|
{ value: "30", label: getExpirationLabel(30) },
|
||||||
|
{ value: "60", label: getExpirationLabel(60) },
|
||||||
|
{ value: "90", label: getExpirationLabel(90) },
|
||||||
|
{ value: "365", label: getExpirationLabel(365) },
|
||||||
|
{ value: "custom", label: t("Custom") },
|
||||||
|
{ value: "never", label: t("No expiration") },
|
||||||
|
];
|
||||||
|
|
||||||
|
const handleSubmit = async (data: {
|
||||||
|
name?: string;
|
||||||
|
expiresAt?: string | Date;
|
||||||
|
}) => {
|
||||||
|
const groupData = {
|
||||||
|
name: data.name,
|
||||||
|
expiresAt: getExpirationDate(),
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const createdKey = await createApiKeyMutation.mutateAsync(groupData);
|
||||||
|
onSuccess(createdKey);
|
||||||
|
form.reset();
|
||||||
|
onClose();
|
||||||
|
} catch (err) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
form.reset();
|
||||||
|
setExpirationOption("30");
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={handleClose}
|
||||||
|
title={t("Create API Key")}
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
<form onSubmit={form.onSubmit((values) => handleSubmit(values))}>
|
||||||
|
<Stack gap="md">
|
||||||
|
<TextInput
|
||||||
|
label={t("Name")}
|
||||||
|
placeholder={t("Enter a descriptive name")}
|
||||||
|
data-autofocus
|
||||||
|
required
|
||||||
|
{...form.getInputProps("name")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Select
|
||||||
|
label={t("Expiration")}
|
||||||
|
data={expirationOptions}
|
||||||
|
value={expirationOption}
|
||||||
|
onChange={(value) => setExpirationOption(value || "30")}
|
||||||
|
leftSection={<IconCalendar size={16} />}
|
||||||
|
allowDeselect={false}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{expirationOption === "custom" && (
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
<DateInput
|
||||||
|
label={t("Custom expiration date")}
|
||||||
|
placeholder={t("Select expiration date")}
|
||||||
|
minDate={new Date()}
|
||||||
|
{...form.getInputProps("expiresAt")}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Group justify="flex-end" mt="md">
|
||||||
|
<Button variant="default" onClick={handleClose}>
|
||||||
|
{t("Cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button type="submit" loading={createApiKeyMutation.isPending}>
|
||||||
|
{t("Create")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import { Modal, Text, Button, Group, Stack } from "@mantine/core";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
import { useRevokeApiKeyMutation } from "@/ee/api-key/queries/api-key-query.ts";
|
||||||
|
import { IApiKey } from "@/ee/api-key";
|
||||||
|
|
||||||
|
interface RevokeApiKeyModalProps {
|
||||||
|
opened: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
apiKey: IApiKey | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RevokeApiKeyModal({
|
||||||
|
opened,
|
||||||
|
onClose,
|
||||||
|
apiKey,
|
||||||
|
}: RevokeApiKeyModalProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const revokeApiKeyMutation = useRevokeApiKeyMutation();
|
||||||
|
|
||||||
|
const handleRevoke = async () => {
|
||||||
|
if (!apiKey) return;
|
||||||
|
await revokeApiKeyMutation.mutateAsync({
|
||||||
|
apiKeyId: apiKey.id,
|
||||||
|
});
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={onClose}
|
||||||
|
title={t("Revoke API key")}
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
<Stack gap="md">
|
||||||
|
<Text>
|
||||||
|
{t("Are you sure you want to revoke this API key")}{" "}
|
||||||
|
<strong>{apiKey?.name}</strong>?
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{t(
|
||||||
|
"This action cannot be undone. Any applications using this API key will stop working.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Group justify="flex-end" mt="md">
|
||||||
|
<Button variant="default" onClick={onClose}>
|
||||||
|
{t("Cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
color="red"
|
||||||
|
onClick={handleRevoke}
|
||||||
|
loading={revokeApiKeyMutation.isPending}
|
||||||
|
>
|
||||||
|
{t("Revoke")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import { Modal, TextInput, Button, Group, Stack } from "@mantine/core";
|
||||||
|
import { useForm } from "@mantine/form";
|
||||||
|
import { zodResolver } from "mantine-form-zod-resolver";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useUpdateApiKeyMutation } from "@/ee/api-key/queries/api-key-query";
|
||||||
|
import { IApiKey } from "@/ee/api-key";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
name: z.string().min(1, "Name is required"),
|
||||||
|
});
|
||||||
|
type FormValues = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
|
interface UpdateApiKeyModalProps {
|
||||||
|
opened: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
apiKey: IApiKey | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UpdateApiKeyModal({
|
||||||
|
opened,
|
||||||
|
onClose,
|
||||||
|
apiKey,
|
||||||
|
}: UpdateApiKeyModalProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const updateApiKeyMutation = useUpdateApiKeyMutation();
|
||||||
|
|
||||||
|
const form = useForm<FormValues>({
|
||||||
|
validate: zodResolver(formSchema),
|
||||||
|
initialValues: {
|
||||||
|
name: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (opened && apiKey) {
|
||||||
|
form.setValues({ name: apiKey.name });
|
||||||
|
}
|
||||||
|
}, [opened, apiKey]);
|
||||||
|
|
||||||
|
const handleSubmit = async (data: { name?: string }) => {
|
||||||
|
const apiKeyData = {
|
||||||
|
apiKeyId: apiKey.id,
|
||||||
|
name: data.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
await updateApiKeyMutation.mutateAsync(apiKeyData);
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={onClose}
|
||||||
|
title={t("Update API key")}
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
<form onSubmit={form.onSubmit((values) => handleSubmit(values))}>
|
||||||
|
<Stack gap="md">
|
||||||
|
<TextInput
|
||||||
|
label={t("Name")}
|
||||||
|
placeholder={t("Enter a descriptive token name")}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("name")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Group justify="flex-end" mt="md">
|
||||||
|
<Button variant="default" onClick={onClose}>
|
||||||
|
{t("Cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button type="submit" loading={updateApiKeyMutation.isPending}>
|
||||||
|
{t("Update")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export { ApiKeyTable } from "./components/api-key-table";
|
||||||
|
export { CreateApiKeyModal } from "./components/create-api-key-modal";
|
||||||
|
export { ApiKeyCreatedModal } from "./components/api-key-created-modal";
|
||||||
|
export { UpdateApiKeyModal } from "./components/update-api-key-modal";
|
||||||
|
export { RevokeApiKeyModal } from "./components/revoke-api-key-modal";
|
||||||
|
|
||||||
|
// Services
|
||||||
|
export * from "./services/api-key-service";
|
||||||
|
|
||||||
|
// Types
|
||||||
|
export * from "./types/api-key.types";
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { Button, Group, Space } from "@mantine/core";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import SettingsTitle from "@/components/settings/settings-title";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
|
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
||||||
|
import { CreateApiKeyModal } from "@/ee/api-key/components/create-api-key-modal";
|
||||||
|
import { ApiKeyCreatedModal } from "@/ee/api-key/components/api-key-created-modal";
|
||||||
|
import { UpdateApiKeyModal } from "@/ee/api-key/components/update-api-key-modal";
|
||||||
|
import { RevokeApiKeyModal } from "@/ee/api-key/components/revoke-api-key-modal";
|
||||||
|
import Paginate from "@/components/common/paginate";
|
||||||
|
import { usePaginateAndSearch } from "@/hooks/use-paginate-and-search";
|
||||||
|
import { useGetApiKeysQuery } from "@/ee/api-key/queries/api-key-query.ts";
|
||||||
|
import { IApiKey } from "@/ee/api-key";
|
||||||
|
|
||||||
|
export default function UserApiKeys() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { page, setPage } = usePaginateAndSearch();
|
||||||
|
const [createModalOpened, setCreateModalOpened] = useState(false);
|
||||||
|
const [createdApiKey, setCreatedApiKey] = useState<IApiKey | null>(null);
|
||||||
|
const [updateModalOpened, setUpdateModalOpened] = useState(false);
|
||||||
|
const [revokeModalOpened, setRevokeModalOpened] = useState(false);
|
||||||
|
const [selectedApiKey, setSelectedApiKey] = useState<IApiKey | null>(null);
|
||||||
|
const { data, isLoading } = useGetApiKeysQuery({ page });
|
||||||
|
|
||||||
|
const handleCreateSuccess = (response: IApiKey) => {
|
||||||
|
setCreatedApiKey(response);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUpdate = (apiKey: IApiKey) => {
|
||||||
|
setSelectedApiKey(apiKey);
|
||||||
|
setUpdateModalOpened(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRevoke = (apiKey: IApiKey) => {
|
||||||
|
setSelectedApiKey(apiKey);
|
||||||
|
setRevokeModalOpened(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("API keys")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
|
<SettingsTitle title={t("API keys")} />
|
||||||
|
|
||||||
|
<Group justify="flex-end" mb="md">
|
||||||
|
<Button onClick={() => setCreateModalOpened(true)}>
|
||||||
|
{t("Create API Key")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<ApiKeyTable
|
||||||
|
apiKeys={data?.items || []}
|
||||||
|
isLoading={isLoading}
|
||||||
|
onUpdate={handleUpdate}
|
||||||
|
onRevoke={handleRevoke}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Space h="md" />
|
||||||
|
|
||||||
|
{data?.items.length > 0 && (
|
||||||
|
<Paginate
|
||||||
|
currentPage={page}
|
||||||
|
hasPrevPage={data?.meta.hasPrevPage}
|
||||||
|
hasNextPage={data?.meta.hasNextPage}
|
||||||
|
onPageChange={setPage}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<CreateApiKeyModal
|
||||||
|
opened={createModalOpened}
|
||||||
|
onClose={() => setCreateModalOpened(false)}
|
||||||
|
onSuccess={handleCreateSuccess}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ApiKeyCreatedModal
|
||||||
|
opened={!!createdApiKey}
|
||||||
|
onClose={() => setCreatedApiKey(null)}
|
||||||
|
apiKey={createdApiKey}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<UpdateApiKeyModal
|
||||||
|
opened={updateModalOpened}
|
||||||
|
onClose={() => {
|
||||||
|
setUpdateModalOpened(false);
|
||||||
|
setSelectedApiKey(null);
|
||||||
|
}}
|
||||||
|
apiKey={selectedApiKey}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<RevokeApiKeyModal
|
||||||
|
opened={revokeModalOpened}
|
||||||
|
onClose={() => {
|
||||||
|
setRevokeModalOpened(false);
|
||||||
|
setSelectedApiKey(null);
|
||||||
|
}}
|
||||||
|
apiKey={selectedApiKey}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { Button, Group, Space, Text } from "@mantine/core";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import SettingsTitle from "@/components/settings/settings-title";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
|
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
||||||
|
import { CreateApiKeyModal } from "@/ee/api-key/components/create-api-key-modal";
|
||||||
|
import { ApiKeyCreatedModal } from "@/ee/api-key/components/api-key-created-modal";
|
||||||
|
import { UpdateApiKeyModal } from "@/ee/api-key/components/update-api-key-modal";
|
||||||
|
import { RevokeApiKeyModal } from "@/ee/api-key/components/revoke-api-key-modal";
|
||||||
|
import Paginate from "@/components/common/paginate";
|
||||||
|
import { usePaginateAndSearch } from "@/hooks/use-paginate-and-search";
|
||||||
|
import { useGetApiKeysQuery } from "@/ee/api-key/queries/api-key-query.ts";
|
||||||
|
import { IApiKey } from "@/ee/api-key";
|
||||||
|
import useUserRole from '@/hooks/use-user-role.tsx';
|
||||||
|
|
||||||
|
export default function WorkspaceApiKeys() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { page, setPage } = usePaginateAndSearch();
|
||||||
|
const [createModalOpened, setCreateModalOpened] = useState(false);
|
||||||
|
const [createdApiKey, setCreatedApiKey] = useState<IApiKey | null>(null);
|
||||||
|
const [updateModalOpened, setUpdateModalOpened] = useState(false);
|
||||||
|
const [revokeModalOpened, setRevokeModalOpened] = useState(false);
|
||||||
|
const [selectedApiKey, setSelectedApiKey] = useState<IApiKey | null>(null);
|
||||||
|
const { data, isLoading } = useGetApiKeysQuery({ page, adminView: true });
|
||||||
|
const { isAdmin } = useUserRole();
|
||||||
|
|
||||||
|
if (!isAdmin) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCreateSuccess = (response: IApiKey) => {
|
||||||
|
setCreatedApiKey(response);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUpdate = (apiKey: IApiKey) => {
|
||||||
|
setSelectedApiKey(apiKey);
|
||||||
|
setUpdateModalOpened(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRevoke = (apiKey: IApiKey) => {
|
||||||
|
setSelectedApiKey(apiKey);
|
||||||
|
setRevokeModalOpened(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("API management")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
|
<SettingsTitle title={t("API management")} />
|
||||||
|
|
||||||
|
<Text size="md" c="dimmed" mb="md">
|
||||||
|
{t("Manage API keys for all users in the workspace")}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Group justify="flex-end" mb="md">
|
||||||
|
<Button onClick={() => setCreateModalOpened(true)}>
|
||||||
|
{t("Create API Key")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<ApiKeyTable
|
||||||
|
apiKeys={data?.items}
|
||||||
|
isLoading={isLoading}
|
||||||
|
showUserColumn
|
||||||
|
onUpdate={handleUpdate}
|
||||||
|
onRevoke={handleRevoke}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Space h="md" />
|
||||||
|
|
||||||
|
{data?.items.length > 0 && (
|
||||||
|
<Paginate
|
||||||
|
currentPage={page}
|
||||||
|
hasPrevPage={data?.meta.hasPrevPage}
|
||||||
|
hasNextPage={data?.meta.hasNextPage}
|
||||||
|
onPageChange={setPage}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<CreateApiKeyModal
|
||||||
|
opened={createModalOpened}
|
||||||
|
onClose={() => setCreateModalOpened(false)}
|
||||||
|
onSuccess={handleCreateSuccess}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ApiKeyCreatedModal
|
||||||
|
opened={!!createdApiKey}
|
||||||
|
onClose={() => setCreatedApiKey(null)}
|
||||||
|
apiKey={createdApiKey}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<UpdateApiKeyModal
|
||||||
|
opened={updateModalOpened}
|
||||||
|
onClose={() => {
|
||||||
|
setUpdateModalOpened(false);
|
||||||
|
setSelectedApiKey(null);
|
||||||
|
}}
|
||||||
|
apiKey={selectedApiKey}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<RevokeApiKeyModal
|
||||||
|
opened={revokeModalOpened}
|
||||||
|
onClose={() => {
|
||||||
|
setRevokeModalOpened(false);
|
||||||
|
setSelectedApiKey(null);
|
||||||
|
}}
|
||||||
|
apiKey={selectedApiKey}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import { IPagination, QueryParams } from "@/lib/types.ts";
|
||||||
|
import {
|
||||||
|
keepPreviousData,
|
||||||
|
useMutation,
|
||||||
|
useQuery,
|
||||||
|
useQueryClient,
|
||||||
|
UseQueryResult,
|
||||||
|
} from "@tanstack/react-query";
|
||||||
|
import {
|
||||||
|
createApiKey,
|
||||||
|
getApiKeys,
|
||||||
|
IApiKey,
|
||||||
|
ICreateApiKeyRequest,
|
||||||
|
IUpdateApiKeyRequest,
|
||||||
|
revokeApiKey,
|
||||||
|
updateApiKey,
|
||||||
|
} from "@/ee/api-key";
|
||||||
|
import { notifications } from "@mantine/notifications";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
export function useGetApiKeysQuery(
|
||||||
|
params?: QueryParams,
|
||||||
|
): UseQueryResult<IPagination<IApiKey>, Error> {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["api-key-list", params],
|
||||||
|
queryFn: () => getApiKeys(params),
|
||||||
|
staleTime: 0,
|
||||||
|
gcTime: 0,
|
||||||
|
placeholderData: keepPreviousData,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRevokeApiKeyMutation() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return useMutation<
|
||||||
|
void,
|
||||||
|
Error,
|
||||||
|
{
|
||||||
|
apiKeyId: string;
|
||||||
|
}
|
||||||
|
>({
|
||||||
|
mutationFn: (data) => revokeApiKey(data),
|
||||||
|
onSuccess: (data, variables) => {
|
||||||
|
notifications.show({ message: t("Revoked successfully") });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
predicate: (item) =>
|
||||||
|
["api-key-list"].includes(item.queryKey[0] as string),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
const errorMessage = error["response"]?.data?.message;
|
||||||
|
notifications.show({ message: errorMessage, color: "red" });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCreateApiKeyMutation() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return useMutation<IApiKey, Error, ICreateApiKeyRequest>({
|
||||||
|
mutationFn: (data) => createApiKey(data),
|
||||||
|
onSuccess: () => {
|
||||||
|
notifications.show({ message: t("API key created successfully") });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
predicate: (item) =>
|
||||||
|
["api-key-list"].includes(item.queryKey[0] as string),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
const errorMessage = error["response"]?.data?.message;
|
||||||
|
notifications.show({ message: errorMessage, color: "red" });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUpdateApiKeyMutation() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return useMutation<IApiKey, Error, IUpdateApiKeyRequest>({
|
||||||
|
mutationFn: (data) => updateApiKey(data),
|
||||||
|
onSuccess: (data, variables) => {
|
||||||
|
notifications.show({ message: t("Updated successfully") });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
predicate: (item) =>
|
||||||
|
["api-key-list"].includes(item.queryKey[0] as string),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
const errorMessage = error["response"]?.data?.message;
|
||||||
|
notifications.show({ message: errorMessage, color: "red" });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import api from "@/lib/api-client";
|
||||||
|
import {
|
||||||
|
ICreateApiKeyRequest,
|
||||||
|
IApiKey,
|
||||||
|
IUpdateApiKeyRequest,
|
||||||
|
} from "@/ee/api-key/types/api-key.types";
|
||||||
|
import { IPagination, QueryParams } from "@/lib/types.ts";
|
||||||
|
|
||||||
|
export async function getApiKeys(
|
||||||
|
params?: QueryParams,
|
||||||
|
): Promise<IPagination<IApiKey>> {
|
||||||
|
const req = await api.post("/api-keys", { ...params });
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createApiKey(
|
||||||
|
data: ICreateApiKeyRequest,
|
||||||
|
): Promise<IApiKey> {
|
||||||
|
const req = await api.post<IApiKey>("/api-keys/create", data);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateApiKey(
|
||||||
|
data: IUpdateApiKeyRequest,
|
||||||
|
): Promise<IApiKey> {
|
||||||
|
const req = await api.post<IApiKey>("/api-keys/update", data);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function revokeApiKey(data: { apiKeyId: string }): Promise<void> {
|
||||||
|
await api.post("/api-keys/revoke", data);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { IUser } from "@/features/user/types/user.types.ts";
|
||||||
|
|
||||||
|
export interface IApiKey {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
token?: string;
|
||||||
|
creatorId: string;
|
||||||
|
workspaceId: string;
|
||||||
|
expiresAt: string | null;
|
||||||
|
lastUsedAt: string | null;
|
||||||
|
createdAt: string;
|
||||||
|
creator: Partial<IUser>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICreateApiKeyRequest {
|
||||||
|
name: string;
|
||||||
|
expiresAt?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IUpdateApiKeyRequest {
|
||||||
|
apiKeyId: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ export default function OssDetails() {
|
|||||||
withTableBorder
|
withTableBorder
|
||||||
>
|
>
|
||||||
<Table.Caption>
|
<Table.Caption>
|
||||||
To unlock enterprise features like SSO, MFA, Resolve comments, contact sales@docmost.com.
|
To unlock enterprise features like AI, SSO, MFA, Resolve comments, contact sales@docmost.com.
|
||||||
</Table.Caption>
|
</Table.Caption>
|
||||||
<Table.Tbody>
|
<Table.Tbody>
|
||||||
<Table.Tr>
|
<Table.Tr>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
BubbleMenuProps,
|
BubbleMenuProps,
|
||||||
isNodeSelection,
|
isNodeSelection,
|
||||||
useEditor,
|
useEditor,
|
||||||
|
useEditorState,
|
||||||
} from "@tiptap/react";
|
} from "@tiptap/react";
|
||||||
import { FC, useEffect, useRef, useState } from "react";
|
import { FC, useEffect, useRef, useState } from "react";
|
||||||
import {
|
import {
|
||||||
@@ -50,34 +51,52 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
showCommentPopupRef.current = showCommentPopup;
|
showCommentPopupRef.current = showCommentPopup;
|
||||||
}, [showCommentPopup]);
|
}, [showCommentPopup]);
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor: props.editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!props.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
isBold: ctx.editor.isActive("bold"),
|
||||||
|
isItalic: ctx.editor.isActive("italic"),
|
||||||
|
isUnderline: ctx.editor.isActive("underline"),
|
||||||
|
isStrike: ctx.editor.isActive("strike"),
|
||||||
|
isCode: ctx.editor.isActive("code"),
|
||||||
|
isComment: ctx.editor.isActive("comment"),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const items: BubbleMenuItem[] = [
|
const items: BubbleMenuItem[] = [
|
||||||
{
|
{
|
||||||
name: "Bold",
|
name: "Bold",
|
||||||
isActive: () => props.editor.isActive("bold"),
|
isActive: () => editorState?.isBold,
|
||||||
command: () => props.editor.chain().focus().toggleBold().run(),
|
command: () => props.editor.chain().focus().toggleBold().run(),
|
||||||
icon: IconBold,
|
icon: IconBold,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Italic",
|
name: "Italic",
|
||||||
isActive: () => props.editor.isActive("italic"),
|
isActive: () => editorState?.isItalic,
|
||||||
command: () => props.editor.chain().focus().toggleItalic().run(),
|
command: () => props.editor.chain().focus().toggleItalic().run(),
|
||||||
icon: IconItalic,
|
icon: IconItalic,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Underline",
|
name: "Underline",
|
||||||
isActive: () => props.editor.isActive("underline"),
|
isActive: () => editorState?.isUnderline,
|
||||||
command: () => props.editor.chain().focus().toggleUnderline().run(),
|
command: () => props.editor.chain().focus().toggleUnderline().run(),
|
||||||
icon: IconUnderline,
|
icon: IconUnderline,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Strike",
|
name: "Strike",
|
||||||
isActive: () => props.editor.isActive("strike"),
|
isActive: () => editorState?.isStrike,
|
||||||
command: () => props.editor.chain().focus().toggleStrike().run(),
|
command: () => props.editor.chain().focus().toggleStrike().run(),
|
||||||
icon: IconStrikethrough,
|
icon: IconStrikethrough,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Code",
|
name: "Code",
|
||||||
isActive: () => props.editor.isActive("code"),
|
isActive: () => editorState?.isCode,
|
||||||
command: () => props.editor.chain().focus().toggleCode().run(),
|
command: () => props.editor.chain().focus().toggleCode().run(),
|
||||||
icon: IconCode,
|
icon: IconCode,
|
||||||
},
|
},
|
||||||
@@ -85,7 +104,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
|
|
||||||
const commentItem: BubbleMenuItem = {
|
const commentItem: BubbleMenuItem = {
|
||||||
name: "Comment",
|
name: "Comment",
|
||||||
isActive: () => props.editor.isActive("comment"),
|
isActive: () => editorState?.isComment,
|
||||||
command: () => {
|
command: () => {
|
||||||
const commentId = uuid7();
|
const commentId = uuid7();
|
||||||
|
|
||||||
@@ -125,16 +144,16 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
onHide: () => {
|
onHide: () => {
|
||||||
setIsNodeSelectorOpen(false);
|
setIsNodeSelectorOpen(false);
|
||||||
setIsTextAlignmentOpen(false);
|
setIsTextAlignmentOpen(false);
|
||||||
setIsColorSelectorOpen(false);
|
|
||||||
setIsLinkSelectorOpen(false);
|
setIsLinkSelectorOpen(false);
|
||||||
|
setIsColorSelectorOpen(false);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const [isNodeSelectorOpen, setIsNodeSelectorOpen] = useState(false);
|
const [isNodeSelectorOpen, setIsNodeSelectorOpen] = useState(false);
|
||||||
const [isTextAlignmentSelectorOpen, setIsTextAlignmentOpen] = useState(false);
|
const [isTextAlignmentSelectorOpen, setIsTextAlignmentOpen] = useState(false);
|
||||||
const [isColorSelectorOpen, setIsColorSelectorOpen] = useState(false);
|
|
||||||
const [isLinkSelectorOpen, setIsLinkSelectorOpen] = useState(false);
|
const [isLinkSelectorOpen, setIsLinkSelectorOpen] = useState(false);
|
||||||
|
const [isColorSelectorOpen, setIsColorSelectorOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BubbleMenu {...bubbleMenuProps}>
|
<BubbleMenu {...bubbleMenuProps}>
|
||||||
@@ -145,8 +164,8 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
setIsOpen={() => {
|
setIsOpen={() => {
|
||||||
setIsNodeSelectorOpen(!isNodeSelectorOpen);
|
setIsNodeSelectorOpen(!isNodeSelectorOpen);
|
||||||
setIsTextAlignmentOpen(false);
|
setIsTextAlignmentOpen(false);
|
||||||
setIsColorSelectorOpen(false);
|
|
||||||
setIsLinkSelectorOpen(false);
|
setIsLinkSelectorOpen(false);
|
||||||
|
setIsColorSelectorOpen(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -156,8 +175,8 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
setIsOpen={() => {
|
setIsOpen={() => {
|
||||||
setIsTextAlignmentOpen(!isTextAlignmentSelectorOpen);
|
setIsTextAlignmentOpen(!isTextAlignmentSelectorOpen);
|
||||||
setIsNodeSelectorOpen(false);
|
setIsNodeSelectorOpen(false);
|
||||||
setIsColorSelectorOpen(false);
|
|
||||||
setIsLinkSelectorOpen(false);
|
setIsLinkSelectorOpen(false);
|
||||||
|
setIsColorSelectorOpen(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Dispatch, FC, SetStateAction } from "react";
|
import React, { Dispatch, FC, SetStateAction } from "react";
|
||||||
import { IconCheck, IconPalette } from "@tabler/icons-react";
|
import { IconCheck, IconChevronDown, IconPalette } from "@tabler/icons-react";
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Button,
|
Button,
|
||||||
@@ -8,8 +8,12 @@ import {
|
|||||||
ScrollArea,
|
ScrollArea,
|
||||||
Text,
|
Text,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
|
SimpleGrid,
|
||||||
|
Box,
|
||||||
|
Stack,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useEditor } from "@tiptap/react";
|
import type { Editor } from "@tiptap/react";
|
||||||
|
import { useEditorState } from "@tiptap/react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export interface BubbleColorMenuItem {
|
export interface BubbleColorMenuItem {
|
||||||
@@ -18,7 +22,7 @@ export interface BubbleColorMenuItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ColorSelectorProps {
|
interface ColorSelectorProps {
|
||||||
editor: ReturnType<typeof useEditor>;
|
editor: Editor | null;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
@@ -60,9 +64,12 @@ const TEXT_COLORS: BubbleColorMenuItem[] = [
|
|||||||
name: "Gray",
|
name: "Gray",
|
||||||
color: "#A8A29E",
|
color: "#A8A29E",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Brown",
|
||||||
|
color: "#92400E",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// TODO: handle dark mode
|
|
||||||
const HIGHLIGHT_COLORS: BubbleColorMenuItem[] = [
|
const HIGHLIGHT_COLORS: BubbleColorMenuItem[] = [
|
||||||
{
|
{
|
||||||
name: "Default",
|
name: "Default",
|
||||||
@@ -70,35 +77,39 @@ const HIGHLIGHT_COLORS: BubbleColorMenuItem[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Blue",
|
name: "Blue",
|
||||||
color: "#c1ecf9",
|
color: "#98d8f2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Green",
|
name: "Green",
|
||||||
color: "#acf79f",
|
color: "#7edb6c",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Purple",
|
name: "Purple",
|
||||||
color: "#f6f3f8",
|
color: "#e0d6ed",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Red",
|
name: "Red",
|
||||||
color: "#fdebeb",
|
color: "#ffc6c2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Yellow",
|
name: "Yellow",
|
||||||
color: "#fbf4a2",
|
color: "#faf594",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Orange",
|
name: "Orange",
|
||||||
color: "#faebdd",
|
color: "#f5c8a9",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Pink",
|
name: "Pink",
|
||||||
color: "#faf1f5",
|
color: "#f5cfe0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Gray",
|
name: "Gray",
|
||||||
color: "#f1f1ef",
|
color: "#dfdfd7",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Brown",
|
||||||
|
color: "#d7c4b7",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -108,67 +119,180 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
|
|||||||
setIsOpen,
|
setIsOpen,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const activeColorItem = TEXT_COLORS.find(({ color }) =>
|
|
||||||
editor.isActive("textStyle", { color }),
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeColors: Record<string, boolean> = {};
|
||||||
|
TEXT_COLORS.forEach(({ color }) => {
|
||||||
|
activeColors[`text_${color}`] = ctx.editor.isActive("textStyle", {
|
||||||
|
color,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
HIGHLIGHT_COLORS.forEach(({ color }) => {
|
||||||
|
activeColors[`highlight_${color}`] = ctx.editor.isActive("highlight", {
|
||||||
|
color,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return activeColors;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!editor || !editorState) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeColorItem = TEXT_COLORS.find(
|
||||||
|
({ color }) => editorState[`text_${color}`],
|
||||||
);
|
);
|
||||||
|
|
||||||
const activeHighlightItem = HIGHLIGHT_COLORS.find(({ color }) =>
|
const activeHighlightItem = HIGHLIGHT_COLORS.find(
|
||||||
editor.isActive("highlight", { color }),
|
({ color }) => editorState[`highlight_${color}`],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover width={200} opened={isOpen} withArrow>
|
<Popover width={220} opened={isOpen} withArrow>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
<Tooltip label={t("Text color")} withArrow>
|
<Tooltip label={t("Text color")} withArrow>
|
||||||
<ActionIcon
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
size="lg"
|
|
||||||
radius="0"
|
radius="0"
|
||||||
style={{
|
rightSection={<IconChevronDown size={16} />}
|
||||||
border: "none",
|
|
||||||
color: activeColorItem?.color,
|
|
||||||
}}
|
|
||||||
onClick={() => setIsOpen(!isOpen)}
|
onClick={() => setIsOpen(!isOpen)}
|
||||||
|
data-text-color={activeColorItem?.color || ""}
|
||||||
|
data-highlight-color={activeHighlightItem?.color || ""}
|
||||||
|
className="color-selector-trigger"
|
||||||
|
style={{
|
||||||
|
height: "34px",
|
||||||
|
border: "none",
|
||||||
|
fontWeight: 500,
|
||||||
|
fontSize: rem(16),
|
||||||
|
paddingLeft: rem(8),
|
||||||
|
paddingRight: rem(4),
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<IconPalette size={16} stroke={2} />
|
A
|
||||||
</ActionIcon>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
|
|
||||||
<Popover.Dropdown>
|
<Popover.Dropdown>
|
||||||
{/* make mah responsive */}
|
|
||||||
<ScrollArea.Autosize type="scroll" mah="400">
|
<ScrollArea.Autosize type="scroll" mah="400">
|
||||||
<Text span c="dimmed" tt="uppercase" inherit>
|
<Stack gap="md">
|
||||||
{t("Color")}
|
<Box>
|
||||||
</Text>
|
<Text size="sm" fw={600} mb="xs">
|
||||||
|
{t("Text color")}
|
||||||
|
</Text>
|
||||||
|
<SimpleGrid cols={5} spacing="xs">
|
||||||
|
{TEXT_COLORS.map(({ name, color }, index) => (
|
||||||
|
<Tooltip key={index} label={t(name)} withArrow>
|
||||||
|
<Box
|
||||||
|
onClick={() => {
|
||||||
|
if (name === "Default") {
|
||||||
|
editor.commands.unsetColor();
|
||||||
|
} else {
|
||||||
|
editor
|
||||||
|
.chain()
|
||||||
|
.focus()
|
||||||
|
.setColor(color || "")
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
setIsOpen(false);
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
width: rem(28),
|
||||||
|
height: rem(28),
|
||||||
|
borderRadius: rem(6),
|
||||||
|
border: editorState[`text_${color}`]
|
||||||
|
? "2px solid var(--mantine-color-gray-8)"
|
||||||
|
: "1px solid var(--mantine-color-gray-4)",
|
||||||
|
cursor: "pointer",
|
||||||
|
position: "relative",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
fontSize: rem(16),
|
||||||
|
fontWeight: 600,
|
||||||
|
color: color || "var(--mantine-color-gray-8)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
A
|
||||||
|
</Box>
|
||||||
|
</Tooltip>
|
||||||
|
))}
|
||||||
|
</SimpleGrid>
|
||||||
|
</Box>
|
||||||
|
|
||||||
<Button.Group orientation="vertical">
|
<Box>
|
||||||
{TEXT_COLORS.map(({ name, color }, index) => (
|
<Text size="sm" fw={600} mb="xs">
|
||||||
<Button
|
{t("Highlight color")}
|
||||||
key={index}
|
</Text>
|
||||||
variant="default"
|
<SimpleGrid cols={5} spacing="xs">
|
||||||
leftSection={<span style={{ color }}>A</span>}
|
{HIGHLIGHT_COLORS.map(({ name, color }, index) => (
|
||||||
justify="left"
|
<Tooltip key={index} label={t(name)} withArrow>
|
||||||
fullWidth
|
<Box
|
||||||
rightSection={
|
onClick={() => {
|
||||||
editor.isActive("textStyle", { color }) && (
|
if (name === "Default") {
|
||||||
<IconCheck style={{ width: rem(16) }} />
|
editor.commands.unsetHighlight();
|
||||||
)
|
} else {
|
||||||
}
|
editor
|
||||||
onClick={() => {
|
.chain()
|
||||||
if (name === "Default") {
|
.focus()
|
||||||
editor.commands.unsetColor();
|
.toggleMark("highlight", {
|
||||||
} else {
|
color: color || "",
|
||||||
editor.chain().focus().setColor(color || "").run();
|
colorName: name.toLowerCase() || "",
|
||||||
}
|
})
|
||||||
setIsOpen(false);
|
.run();
|
||||||
}}
|
}
|
||||||
style={{ border: "none" }}
|
setIsOpen(false);
|
||||||
>
|
}}
|
||||||
{t(name)}
|
style={{
|
||||||
</Button>
|
width: rem(28),
|
||||||
))}
|
height: rem(28),
|
||||||
</Button.Group>
|
borderRadius: rem(4),
|
||||||
|
backgroundColor: color || "var(--mantine-color-gray-2)",
|
||||||
|
border: "1px solid var(--mantine-color-gray-4)",
|
||||||
|
cursor: "pointer",
|
||||||
|
position: "relative",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
fontSize: rem(16),
|
||||||
|
fontWeight: 600,
|
||||||
|
color: "var(--mantine-color-gray-8)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{editorState[`highlight_${color}`] ? (
|
||||||
|
<IconCheck
|
||||||
|
size={16}
|
||||||
|
color="var(--mantine-color-green-7)"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
"A"
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Tooltip>
|
||||||
|
))}
|
||||||
|
</SimpleGrid>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
fullWidth
|
||||||
|
onClick={() => {
|
||||||
|
editor.commands.unsetColor();
|
||||||
|
editor.commands.unsetHighlight();
|
||||||
|
setIsOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("Remove color")}
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
</ScrollArea.Autosize>
|
</ScrollArea.Autosize>
|
||||||
</Popover.Dropdown>
|
</Popover.Dropdown>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|||||||
@@ -13,11 +13,12 @@ import {
|
|||||||
IconTypography,
|
IconTypography,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Popover, Button, ScrollArea } from "@mantine/core";
|
import { Popover, Button, ScrollArea } from "@mantine/core";
|
||||||
import { useEditor } from "@tiptap/react";
|
import type { Editor } from "@tiptap/react";
|
||||||
|
import { useEditorState } from "@tiptap/react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
interface NodeSelectorProps {
|
interface NodeSelectorProps {
|
||||||
editor: ReturnType<typeof useEditor>;
|
editor: Editor | null;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
@@ -36,6 +37,27 @@ export const NodeSelector: FC<NodeSelectorProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
isParagraph: ctx.editor.isActive("paragraph"),
|
||||||
|
isBulletList: ctx.editor.isActive("bulletList"),
|
||||||
|
isOrderedList: ctx.editor.isActive("orderedList"),
|
||||||
|
isHeading1: ctx.editor.isActive("heading", { level: 1 }),
|
||||||
|
isHeading2: ctx.editor.isActive("heading", { level: 2 }),
|
||||||
|
isHeading3: ctx.editor.isActive("heading", { level: 3 }),
|
||||||
|
isTaskItem: ctx.editor.isActive("taskItem"),
|
||||||
|
isBlockquote: ctx.editor.isActive("blockquote"),
|
||||||
|
isCodeBlock: ctx.editor.isActive("codeBlock"),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const items: BubbleMenuItem[] = [
|
const items: BubbleMenuItem[] = [
|
||||||
{
|
{
|
||||||
name: "Text",
|
name: "Text",
|
||||||
@@ -43,45 +65,45 @@ export const NodeSelector: FC<NodeSelectorProps> = ({
|
|||||||
command: () =>
|
command: () =>
|
||||||
editor.chain().focus().toggleNode("paragraph", "paragraph").run(),
|
editor.chain().focus().toggleNode("paragraph", "paragraph").run(),
|
||||||
isActive: () =>
|
isActive: () =>
|
||||||
editor.isActive("paragraph") &&
|
editorState?.isParagraph &&
|
||||||
!editor.isActive("bulletList") &&
|
!editorState?.isBulletList &&
|
||||||
!editor.isActive("orderedList"),
|
!editorState?.isOrderedList,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Heading 1",
|
name: "Heading 1",
|
||||||
icon: IconH1,
|
icon: IconH1,
|
||||||
command: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
|
command: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
|
||||||
isActive: () => editor.isActive("heading", { level: 1 }),
|
isActive: () => editorState?.isHeading1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Heading 2",
|
name: "Heading 2",
|
||||||
icon: IconH2,
|
icon: IconH2,
|
||||||
command: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
|
command: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
|
||||||
isActive: () => editor.isActive("heading", { level: 2 }),
|
isActive: () => editorState?.isHeading2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Heading 3",
|
name: "Heading 3",
|
||||||
icon: IconH3,
|
icon: IconH3,
|
||||||
command: () => editor.chain().focus().toggleHeading({ level: 3 }).run(),
|
command: () => editor.chain().focus().toggleHeading({ level: 3 }).run(),
|
||||||
isActive: () => editor.isActive("heading", { level: 3 }),
|
isActive: () => editorState?.isHeading3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "To-do List",
|
name: "To-do List",
|
||||||
icon: IconCheckbox,
|
icon: IconCheckbox,
|
||||||
command: () => editor.chain().focus().toggleTaskList().run(),
|
command: () => editor.chain().focus().toggleTaskList().run(),
|
||||||
isActive: () => editor.isActive("taskItem"),
|
isActive: () => editorState?.isTaskItem,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Bullet List",
|
name: "Bullet List",
|
||||||
icon: IconList,
|
icon: IconList,
|
||||||
command: () => editor.chain().focus().toggleBulletList().run(),
|
command: () => editor.chain().focus().toggleBulletList().run(),
|
||||||
isActive: () => editor.isActive("bulletList"),
|
isActive: () => editorState?.isBulletList,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Numbered List",
|
name: "Numbered List",
|
||||||
icon: IconListNumbers,
|
icon: IconListNumbers,
|
||||||
command: () => editor.chain().focus().toggleOrderedList().run(),
|
command: () => editor.chain().focus().toggleOrderedList().run(),
|
||||||
isActive: () => editor.isActive("orderedList"),
|
isActive: () => editorState?.isOrderedList,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Blockquote",
|
name: "Blockquote",
|
||||||
@@ -93,13 +115,13 @@ export const NodeSelector: FC<NodeSelectorProps> = ({
|
|||||||
.toggleNode("paragraph", "paragraph")
|
.toggleNode("paragraph", "paragraph")
|
||||||
.toggleBlockquote()
|
.toggleBlockquote()
|
||||||
.run(),
|
.run(),
|
||||||
isActive: () => editor.isActive("blockquote"),
|
isActive: () => editorState?.isBlockquote,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Code",
|
name: "Code",
|
||||||
icon: IconCode,
|
icon: IconCode,
|
||||||
command: () => editor.chain().focus().toggleCodeBlock().run(),
|
command: () => editor.chain().focus().toggleCodeBlock().run(),
|
||||||
isActive: () => editor.isActive("codeBlock"),
|
isActive: () => editorState?.isCodeBlock,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
+29
-10
@@ -8,11 +8,12 @@ import {
|
|||||||
IconChevronDown,
|
IconChevronDown,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Popover, Button, ScrollArea, rem } from "@mantine/core";
|
import { Popover, Button, ScrollArea, rem } from "@mantine/core";
|
||||||
import { useEditor } from "@tiptap/react";
|
import type { Editor } from "@tiptap/react";
|
||||||
|
import { useEditorState } from "@tiptap/react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
interface TextAlignmentProps {
|
interface TextAlignmentProps {
|
||||||
editor: ReturnType<typeof useEditor>;
|
editor: Editor | null;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
@@ -31,36 +32,54 @@ export const TextAlignmentSelector: FC<TextAlignmentProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
isAlignLeft: ctx.editor.isActive({ textAlign: "left" }),
|
||||||
|
isAlignCenter: ctx.editor.isActive({ textAlign: "center" }),
|
||||||
|
isAlignRight: ctx.editor.isActive({ textAlign: "right" }),
|
||||||
|
isAlignJustify: ctx.editor.isActive({ textAlign: "justify" }),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!editor || !editorState) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const items: BubbleMenuItem[] = [
|
const items: BubbleMenuItem[] = [
|
||||||
{
|
{
|
||||||
name: "Align left",
|
name: "Align left",
|
||||||
isActive: () => editor.isActive({ textAlign: "left" }),
|
isActive: () => editorState?.isAlignLeft,
|
||||||
command: () => editor.chain().focus().setTextAlign("left").run(),
|
command: () => editor.chain().focus().setTextAlign("left").run(),
|
||||||
icon: IconAlignLeft,
|
icon: IconAlignLeft,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Align center",
|
name: "Align center",
|
||||||
isActive: () => editor.isActive({ textAlign: "center" }),
|
isActive: () => editorState?.isAlignCenter,
|
||||||
command: () => editor.chain().focus().setTextAlign("center").run(),
|
command: () => editor.chain().focus().setTextAlign("center").run(),
|
||||||
icon: IconAlignCenter,
|
icon: IconAlignCenter,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Align right",
|
name: "Align right",
|
||||||
isActive: () => editor.isActive({ textAlign: "right" }),
|
isActive: () => editorState?.isAlignRight,
|
||||||
command: () => editor.chain().focus().setTextAlign("right").run(),
|
command: () => editor.chain().focus().setTextAlign("right").run(),
|
||||||
icon: IconAlignRight,
|
icon: IconAlignRight,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Justify",
|
name: "Justify",
|
||||||
isActive: () => editor.isActive({ textAlign: "justify" }),
|
isActive: () => editorState?.isAlignJustify,
|
||||||
command: () => editor.chain().focus().setTextAlign("justify").run(),
|
command: () => editor.chain().focus().setTextAlign("justify").run(),
|
||||||
icon: IconAlignJustified,
|
icon: IconAlignJustified,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const activeItem = items.filter((item) => item.isActive()).pop() ?? {
|
const activeItem = items.filter((item) => item.isActive()).pop() ?? items[0];
|
||||||
name: "Multiple",
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover opened={isOpen} withArrow>
|
<Popover opened={isOpen} withArrow>
|
||||||
@@ -73,7 +92,7 @@ export const TextAlignmentSelector: FC<TextAlignmentProps> = ({
|
|||||||
rightSection={<IconChevronDown size={16} />}
|
rightSection={<IconChevronDown size={16} />}
|
||||||
onClick={() => setIsOpen(!isOpen)}
|
onClick={() => setIsOpen(!isOpen)}
|
||||||
>
|
>
|
||||||
<IconAlignLeft style={{ width: rem(16) }} stroke={2} />
|
<activeItem.icon style={{ width: rem(16) }} stroke={2} />
|
||||||
</Button>
|
</Button>
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
BubbleMenu as BaseBubbleMenu,
|
BubbleMenu as BaseBubbleMenu,
|
||||||
findParentNode,
|
findParentNode,
|
||||||
posToDOMRect,
|
posToDOMRect,
|
||||||
|
useEditorState,
|
||||||
} from "@tiptap/react";
|
} from "@tiptap/react";
|
||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
import { Node as PMNode } from "prosemirror-model";
|
import { Node as PMNode } from "prosemirror-model";
|
||||||
@@ -9,7 +10,7 @@ import {
|
|||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
} from "@/features/editor/components/table/types/types.ts";
|
} from "@/features/editor/components/table/types/types.ts";
|
||||||
import { ActionIcon, Tooltip, Divider } from "@mantine/core";
|
import { ActionIcon, Tooltip } from "@mantine/core";
|
||||||
import {
|
import {
|
||||||
IconAlertTriangleFilled,
|
IconAlertTriangleFilled,
|
||||||
IconCircleCheckFilled,
|
IconCircleCheckFilled,
|
||||||
@@ -35,6 +36,23 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
[editor],
|
[editor],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
isCallout: ctx.editor.isActive("callout"),
|
||||||
|
isInfo: ctx.editor.isActive("callout", { type: "info" }),
|
||||||
|
isSuccess: ctx.editor.isActive("callout", { type: "success" }),
|
||||||
|
isWarning: ctx.editor.isActive("callout", { type: "warning" }),
|
||||||
|
isDanger: ctx.editor.isActive("callout", { type: "danger" }),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const getReferenceClientRect = useCallback(() => {
|
const getReferenceClientRect = useCallback(() => {
|
||||||
const { selection } = editor.state;
|
const { selection } = editor.state;
|
||||||
const predicate = (node: PMNode) => node.type.name === "callout";
|
const predicate = (node: PMNode) => node.type.name === "callout";
|
||||||
@@ -92,7 +110,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
return (
|
return (
|
||||||
<BaseBubbleMenu
|
<BaseBubbleMenu
|
||||||
editor={editor}
|
editor={editor}
|
||||||
pluginKey={`callout-menu}`}
|
pluginKey={`callout-menu`}
|
||||||
updateDelay={0}
|
updateDelay={0}
|
||||||
tippyOptions={{
|
tippyOptions={{
|
||||||
getReferenceClientRect,
|
getReferenceClientRect,
|
||||||
@@ -111,9 +129,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={() => setCalloutType("info")}
|
onClick={() => setCalloutType("info")}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Info")}
|
aria-label={t("Info")}
|
||||||
variant={
|
variant={editorState?.isInfo ? "light" : "default"}
|
||||||
editor.isActive("callout", { type: "info" }) ? "light" : "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconInfoCircleFilled size={18} />
|
<IconInfoCircleFilled size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -124,11 +140,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={() => setCalloutType("success")}
|
onClick={() => setCalloutType("success")}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Success")}
|
aria-label={t("Success")}
|
||||||
variant={
|
variant={editorState?.isSuccess ? "light" : "default"}
|
||||||
editor.isActive("callout", { type: "success" })
|
|
||||||
? "light"
|
|
||||||
: "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconCircleCheckFilled size={18} />
|
<IconCircleCheckFilled size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -139,11 +151,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={() => setCalloutType("warning")}
|
onClick={() => setCalloutType("warning")}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Warning")}
|
aria-label={t("Warning")}
|
||||||
variant={
|
variant={editorState?.isWarning ? "light" : "default"}
|
||||||
editor.isActive("callout", { type: "warning" })
|
|
||||||
? "light"
|
|
||||||
: "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconAlertTriangleFilled size={18} />
|
<IconAlertTriangleFilled size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -154,11 +162,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={() => setCalloutType("danger")}
|
onClick={() => setCalloutType("danger")}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Danger")}
|
aria-label={t("Danger")}
|
||||||
variant={
|
variant={editorState?.isDanger ? "light" : "default"}
|
||||||
editor.isActive("callout", { type: "danger" })
|
|
||||||
? "light"
|
|
||||||
: "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconCircleXFilled size={18} />
|
<IconCircleXFilled size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { v4 as uuidv4 } from "uuid";
|
|||||||
import classes from "./code-block.module.css";
|
import classes from "./code-block.module.css";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useComputedColorScheme } from "@mantine/core";
|
import { useComputedColorScheme } from "@mantine/core";
|
||||||
|
import DOMPurify from "dompurify";
|
||||||
|
|
||||||
interface MermaidViewProps {
|
interface MermaidViewProps {
|
||||||
props: NodeViewProps;
|
props: NodeViewProps;
|
||||||
@@ -37,7 +38,7 @@ export default function MermaidView({ props }: MermaidViewProps) {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (props.editor.isEditable) {
|
if (props.editor.isEditable) {
|
||||||
setPreview(
|
setPreview(
|
||||||
`<div class="${classes.error}">${t("Mermaid diagram error:")} ${err}</div>`,
|
`<div class="${classes.error}">${t("Mermaid diagram error:")} ${DOMPurify.sanitize(err)}</div>`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setPreview(
|
setPreview(
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ export const handlePaste = (
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
createMentionAction(url, view, pos, creatorId);
|
const anchorId = match[6] ? match[6].split('#')[0] : undefined;
|
||||||
|
const urlWithoutAnchor = anchorId ? url.substring(0, url.indexOf("#")) : url;
|
||||||
|
createMentionAction(urlWithoutAnchor, view, pos, creatorId, anchorId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ import {
|
|||||||
BubbleMenu as BaseBubbleMenu,
|
BubbleMenu as BaseBubbleMenu,
|
||||||
findParentNode,
|
findParentNode,
|
||||||
posToDOMRect,
|
posToDOMRect,
|
||||||
} from '@tiptap/react';
|
useEditorState,
|
||||||
import { useCallback } from 'react';
|
} from "@tiptap/react";
|
||||||
import { sticky } from 'tippy.js';
|
import { useCallback } from "react";
|
||||||
import { Node as PMNode } from 'prosemirror-model';
|
import { sticky } from "tippy.js";
|
||||||
|
import { Node as PMNode } from "prosemirror-model";
|
||||||
import {
|
import {
|
||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
} from '@/features/editor/components/table/types/types.ts';
|
} from "@/features/editor/components/table/types/types.ts";
|
||||||
import { NodeWidthResize } from '@/features/editor/components/common/node-width-resize.tsx';
|
import { NodeWidthResize } from "@/features/editor/components/common/node-width-resize.tsx";
|
||||||
|
|
||||||
export function DrawioMenu({ editor }: EditorMenuProps) {
|
export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||||
const shouldShow = useCallback(
|
const shouldShow = useCallback(
|
||||||
@@ -19,14 +20,29 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return editor.isActive('drawio') && editor.getAttributes('drawio')?.src;
|
return editor.isActive("drawio") && editor.getAttributes("drawio")?.src;
|
||||||
},
|
},
|
||||||
[editor]
|
[editor],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const drawioAttr = ctx.editor.getAttributes("drawio");
|
||||||
|
return {
|
||||||
|
isDrawio: ctx.editor.isActive("drawio"),
|
||||||
|
width: drawioAttr?.width ? parseInt(drawioAttr.width) : null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const getReferenceClientRect = useCallback(() => {
|
const getReferenceClientRect = useCallback(() => {
|
||||||
const { selection } = editor.state;
|
const { selection } = editor.state;
|
||||||
const predicate = (node: PMNode) => node.type.name === 'drawio';
|
const predicate = (node: PMNode) => node.type.name === "drawio";
|
||||||
const parent = findParentNode(predicate)(selection);
|
const parent = findParentNode(predicate)(selection);
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
@@ -39,40 +55,37 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
|
|
||||||
const onWidthChange = useCallback(
|
const onWidthChange = useCallback(
|
||||||
(value: number) => {
|
(value: number) => {
|
||||||
editor.commands.updateAttributes('drawio', { width: `${value}%` });
|
editor.commands.updateAttributes("drawio", { width: `${value}%` });
|
||||||
},
|
},
|
||||||
[editor]
|
[editor],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseBubbleMenu
|
<BaseBubbleMenu
|
||||||
editor={editor}
|
editor={editor}
|
||||||
pluginKey={`drawio-menu}`}
|
pluginKey={`drawio-menu`}
|
||||||
updateDelay={0}
|
updateDelay={0}
|
||||||
tippyOptions={{
|
tippyOptions={{
|
||||||
getReferenceClientRect,
|
getReferenceClientRect,
|
||||||
offset: [0, 8],
|
offset: [0, 8],
|
||||||
zIndex: 99,
|
zIndex: 99,
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
modifiers: [{ name: 'flip', enabled: false }],
|
modifiers: [{ name: "flip", enabled: false }],
|
||||||
},
|
},
|
||||||
plugins: [sticky],
|
plugins: [sticky],
|
||||||
sticky: 'popper',
|
sticky: "popper",
|
||||||
}}
|
}}
|
||||||
shouldShow={shouldShow}
|
shouldShow={shouldShow}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
flexDirection: 'column',
|
flexDirection: "column",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{editor.getAttributes('drawio')?.width && (
|
{editorState?.width && (
|
||||||
<NodeWidthResize
|
<NodeWidthResize onChange={onWidthChange} value={editorState.width} />
|
||||||
onChange={onWidthChange}
|
|
||||||
value={parseInt(editor.getAttributes('drawio').width)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</BaseBubbleMenu>
|
</BaseBubbleMenu>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export default function DrawioView(props: NodeViewProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<Modal.Root opened={opened} onClose={close} fullScreen>
|
<Modal.Root opened={opened} onClose={close} fullScreen>
|
||||||
<Modal.Overlay />
|
<Modal.Overlay />
|
||||||
<Modal.Content style={{ overflow: "hidden" }}>
|
<Modal.Content style={{ overflow: "hidden" }}>
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export default function EmbedView(props: NodeViewProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper>
|
<NodeViewWrapper data-drag-handle>
|
||||||
{embedUrl ? (
|
{embedUrl ? (
|
||||||
<ResizableWrapper
|
<ResizableWrapper
|
||||||
initialHeight={nodeHeight || 480}
|
initialHeight={nodeHeight || 480}
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ import {
|
|||||||
BubbleMenu as BaseBubbleMenu,
|
BubbleMenu as BaseBubbleMenu,
|
||||||
findParentNode,
|
findParentNode,
|
||||||
posToDOMRect,
|
posToDOMRect,
|
||||||
} from '@tiptap/react';
|
useEditorState,
|
||||||
import { useCallback } from 'react';
|
} from "@tiptap/react";
|
||||||
import { sticky } from 'tippy.js';
|
import { useCallback } from "react";
|
||||||
import { Node as PMNode } from 'prosemirror-model';
|
import { sticky } from "tippy.js";
|
||||||
|
import { Node as PMNode } from "prosemirror-model";
|
||||||
import {
|
import {
|
||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
} from '@/features/editor/components/table/types/types.ts';
|
} from "@/features/editor/components/table/types/types.ts";
|
||||||
import { NodeWidthResize } from '@/features/editor/components/common/node-width-resize.tsx';
|
import { NodeWidthResize } from "@/features/editor/components/common/node-width-resize.tsx";
|
||||||
|
|
||||||
export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||||
const shouldShow = useCallback(
|
const shouldShow = useCallback(
|
||||||
@@ -19,14 +20,31 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return editor.isActive('excalidraw') && editor.getAttributes('excalidraw')?.src;
|
return (
|
||||||
|
editor.isActive("excalidraw") && editor.getAttributes("excalidraw")?.src
|
||||||
|
);
|
||||||
},
|
},
|
||||||
[editor]
|
[editor],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const excalidrawAttr = ctx.editor.getAttributes("excalidraw");
|
||||||
|
return {
|
||||||
|
isExcalidraw: ctx.editor.isActive("excalidraw"),
|
||||||
|
width: excalidrawAttr?.width ? parseInt(excalidrawAttr.width) : null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const getReferenceClientRect = useCallback(() => {
|
const getReferenceClientRect = useCallback(() => {
|
||||||
const { selection } = editor.state;
|
const { selection } = editor.state;
|
||||||
const predicate = (node: PMNode) => node.type.name === 'excalidraw';
|
const predicate = (node: PMNode) => node.type.name === "excalidraw";
|
||||||
const parent = findParentNode(predicate)(selection);
|
const parent = findParentNode(predicate)(selection);
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
@@ -39,9 +57,9 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
|
|
||||||
const onWidthChange = useCallback(
|
const onWidthChange = useCallback(
|
||||||
(value: number) => {
|
(value: number) => {
|
||||||
editor.commands.updateAttributes('excalidraw', { width: `${value}%` });
|
editor.commands.updateAttributes("excalidraw", { width: `${value}%` });
|
||||||
},
|
},
|
||||||
[editor]
|
[editor],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -54,25 +72,22 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
offset: [0, 8],
|
offset: [0, 8],
|
||||||
zIndex: 99,
|
zIndex: 99,
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
modifiers: [{ name: 'flip', enabled: false }],
|
modifiers: [{ name: "flip", enabled: false }],
|
||||||
},
|
},
|
||||||
plugins: [sticky],
|
plugins: [sticky],
|
||||||
sticky: 'popper',
|
sticky: "popper",
|
||||||
}}
|
}}
|
||||||
shouldShow={shouldShow}
|
shouldShow={shouldShow}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
flexDirection: 'column',
|
flexDirection: "column",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{editor.getAttributes('excalidraw')?.width && (
|
{editorState?.width && (
|
||||||
<NodeWidthResize
|
<NodeWidthResize onChange={onWidthChange} value={editorState.width} />
|
||||||
onChange={onWidthChange}
|
|
||||||
value={parseInt(editor.getAttributes('excalidraw').width)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</BaseBubbleMenu>
|
</BaseBubbleMenu>
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<ReactClearModal
|
<ReactClearModal
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
BubbleMenu as BaseBubbleMenu,
|
BubbleMenu as BaseBubbleMenu,
|
||||||
findParentNode,
|
findParentNode,
|
||||||
posToDOMRect,
|
posToDOMRect,
|
||||||
|
useEditorState,
|
||||||
} from "@tiptap/react";
|
} from "@tiptap/react";
|
||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
import { sticky } from "tippy.js";
|
import { sticky } from "tippy.js";
|
||||||
@@ -32,6 +33,25 @@ export function ImageMenu({ editor }: EditorMenuProps) {
|
|||||||
[editor],
|
[editor],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const imageAttrs = ctx.editor.getAttributes("image");
|
||||||
|
|
||||||
|
return {
|
||||||
|
isImage: ctx.editor.isActive("image"),
|
||||||
|
isAlignLeft: ctx.editor.isActive("image", { align: "left" }),
|
||||||
|
isAlignCenter: ctx.editor.isActive("image", { align: "center" }),
|
||||||
|
isAlignRight: ctx.editor.isActive("image", { align: "right" }),
|
||||||
|
width: imageAttrs?.width ? parseInt(imageAttrs.width) : null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const getReferenceClientRect = useCallback(() => {
|
const getReferenceClientRect = useCallback(() => {
|
||||||
const { selection } = editor.state;
|
const { selection } = editor.state;
|
||||||
const predicate = (node: PMNode) => node.type.name === "image";
|
const predicate = (node: PMNode) => node.type.name === "image";
|
||||||
@@ -83,7 +103,7 @@ export function ImageMenu({ editor }: EditorMenuProps) {
|
|||||||
return (
|
return (
|
||||||
<BaseBubbleMenu
|
<BaseBubbleMenu
|
||||||
editor={editor}
|
editor={editor}
|
||||||
pluginKey={`image-menu}`}
|
pluginKey={`image-menu`}
|
||||||
updateDelay={0}
|
updateDelay={0}
|
||||||
tippyOptions={{
|
tippyOptions={{
|
||||||
getReferenceClientRect,
|
getReferenceClientRect,
|
||||||
@@ -103,9 +123,7 @@ export function ImageMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={alignImageLeft}
|
onClick={alignImageLeft}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Align left")}
|
aria-label={t("Align left")}
|
||||||
variant={
|
variant={editorState?.isAlignLeft ? "light" : "default"}
|
||||||
editor.isActive("image", { align: "left" }) ? "light" : "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconLayoutAlignLeft size={18} />
|
<IconLayoutAlignLeft size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -116,11 +134,7 @@ export function ImageMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={alignImageCenter}
|
onClick={alignImageCenter}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Align center")}
|
aria-label={t("Align center")}
|
||||||
variant={
|
variant={editorState?.isAlignCenter ? "light" : "default"}
|
||||||
editor.isActive("image", { align: "center" })
|
|
||||||
? "light"
|
|
||||||
: "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconLayoutAlignCenter size={18} />
|
<IconLayoutAlignCenter size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -131,20 +145,15 @@ export function ImageMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={alignImageRight}
|
onClick={alignImageRight}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Align right")}
|
aria-label={t("Align right")}
|
||||||
variant={
|
variant={editorState?.isAlignRight ? "light" : "default"}
|
||||||
editor.isActive("image", { align: "right" }) ? "light" : "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconLayoutAlignRight size={18} />
|
<IconLayoutAlignRight size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</ActionIcon.Group>
|
</ActionIcon.Group>
|
||||||
|
|
||||||
{editor.getAttributes("image")?.width && (
|
{editorState?.width && (
|
||||||
<NodeWidthResize
|
<NodeWidthResize onChange={onWidthChange} value={editorState.width} />
|
||||||
onChange={onWidthChange}
|
|
||||||
value={parseInt(editor.getAttributes("image").width)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</BaseBubbleMenu>
|
</BaseBubbleMenu>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default function ImageView(props: NodeViewProps) {
|
|||||||
}, [align]);
|
}, [align]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<Image
|
<Image
|
||||||
radius="md"
|
radius="md"
|
||||||
fit="contain"
|
fit="contain"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export type LinkFn = (
|
|||||||
view: EditorView,
|
view: EditorView,
|
||||||
pos: number,
|
pos: number,
|
||||||
creatorId: string,
|
creatorId: string,
|
||||||
|
anchorId?: string,
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
export interface InternalLinkOptions {
|
export interface InternalLinkOptions {
|
||||||
@@ -18,7 +19,7 @@ export interface InternalLinkOptions {
|
|||||||
|
|
||||||
export const handleInternalLink =
|
export const handleInternalLink =
|
||||||
({ validateFn, onResolveLink }: InternalLinkOptions): LinkFn =>
|
({ validateFn, onResolveLink }: InternalLinkOptions): LinkFn =>
|
||||||
async (url: string, view, pos, creatorId) => {
|
async (url: string, view, pos, creatorId, anchorId) => {
|
||||||
const validated = validateFn(url, view);
|
const validated = validateFn(url, view);
|
||||||
if (!validated) return;
|
if (!validated) return;
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ export const handleInternalLink =
|
|||||||
entityId: page.id,
|
entityId: page.id,
|
||||||
slugId: page.slugId,
|
slugId: page.slugId,
|
||||||
creatorId: creatorId,
|
creatorId: creatorId,
|
||||||
|
anchorId: anchorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!node) return;
|
if (!node) return;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react";
|
import { BubbleMenu as BaseBubbleMenu, useEditorState } from "@tiptap/react";
|
||||||
import React, { useCallback, useState } from "react";
|
import React, { useCallback, useState } from "react";
|
||||||
import { EditorMenuProps } from "@/features/editor/components/table/types/types.ts";
|
import { EditorMenuProps } from "@/features/editor/components/table/types/types.ts";
|
||||||
import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel.tsx";
|
import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel.tsx";
|
||||||
@@ -12,7 +12,18 @@ export function LinkMenu({ editor, appendTo }: EditorMenuProps) {
|
|||||||
return editor.isActive("link");
|
return editor.isActive("link");
|
||||||
}, [editor]);
|
}, [editor]);
|
||||||
|
|
||||||
const { href: link } = editor.getAttributes("link");
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const link = ctx.editor.getAttributes("link");
|
||||||
|
return {
|
||||||
|
href: link.href,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const handleEdit = useCallback(() => {
|
const handleEdit = useCallback(() => {
|
||||||
setShowEdit(true);
|
setShowEdit(true);
|
||||||
@@ -70,11 +81,14 @@ export function LinkMenu({ editor, appendTo }: EditorMenuProps) {
|
|||||||
padding="xs"
|
padding="xs"
|
||||||
bg="var(--mantine-color-body)"
|
bg="var(--mantine-color-body)"
|
||||||
>
|
>
|
||||||
<LinkEditorPanel initialUrl={link} onSetLink={onSetLink} />
|
<LinkEditorPanel
|
||||||
|
initialUrl={editorState?.href}
|
||||||
|
onSetLink={onSetLink}
|
||||||
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
) : (
|
) : (
|
||||||
<LinkPreviewPanel
|
<LinkPreviewPanel
|
||||||
url={link}
|
url={editorState?.href}
|
||||||
onClear={onUnsetLink}
|
onClear={onUnsetLink}
|
||||||
onEdit={handleEdit}
|
onEdit={handleEdit}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import classes from "./mention.module.css";
|
|||||||
|
|
||||||
export default function MentionView(props: NodeViewProps) {
|
export default function MentionView(props: NodeViewProps) {
|
||||||
const { node } = props;
|
const { node } = props;
|
||||||
const { label, entityType, entityId, slugId } = node.attrs;
|
const { label, entityType, entityId, slugId, anchorId } = node.attrs;
|
||||||
const { spaceSlug } = useParams();
|
const { spaceSlug } = useParams();
|
||||||
const { shareId } = useParams();
|
const { shareId } = useParams();
|
||||||
const {
|
const {
|
||||||
@@ -27,10 +27,11 @@ export default function MentionView(props: NodeViewProps) {
|
|||||||
shareId,
|
shareId,
|
||||||
pageSlugId: slugId,
|
pageSlugId: slugId,
|
||||||
pageTitle: label,
|
pageTitle: label,
|
||||||
|
anchorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper style={{ display: "inline" }}>
|
<NodeViewWrapper style={{ display: "inline" }} data-drag-handle>
|
||||||
{entityType === "user" && (
|
{entityType === "user" && (
|
||||||
<Text className={classes.userMention} component="span">
|
<Text className={classes.userMention} component="span">
|
||||||
@{label}
|
@{label}
|
||||||
@@ -42,7 +43,7 @@ export default function MentionView(props: NodeViewProps) {
|
|||||||
component={Link}
|
component={Link}
|
||||||
fw={500}
|
fw={500}
|
||||||
to={
|
to={
|
||||||
isShareRoute ? shareSlugUrl : buildPageUrl(spaceSlug, slugId, label)
|
isShareRoute ? shareSlugUrl : buildPageUrl(spaceSlug, slugId, label, anchorId)
|
||||||
}
|
}
|
||||||
underline="never"
|
underline="never"
|
||||||
className={classes.pageMentionLink}
|
className={classes.pageMentionLink}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
IconCalendar,
|
IconCalendar,
|
||||||
IconAppWindow,
|
IconAppWindow,
|
||||||
IconSitemap,
|
IconSitemap,
|
||||||
|
IconLayoutColumns,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import {
|
import {
|
||||||
CommandProps,
|
CommandProps,
|
||||||
@@ -243,6 +244,51 @@ const CommandGroups: SlashMenuGroupedItemsType = {
|
|||||||
.insertTable({ rows: 3, cols: 3, withHeaderRow: true })
|
.insertTable({ rows: 3, cols: 3, withHeaderRow: true })
|
||||||
.run(),
|
.run(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Columns",
|
||||||
|
description: "Insert 2 columns layout.",
|
||||||
|
searchTerms: ["columns", "layout", "grid", "side by side"],
|
||||||
|
icon: IconLayoutColumns,
|
||||||
|
command: ({ editor, range }: CommandProps) => {
|
||||||
|
editor
|
||||||
|
.chain()
|
||||||
|
.focus()
|
||||||
|
.deleteRange(range)
|
||||||
|
.insertContent({
|
||||||
|
type: "column_container",
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "column",
|
||||||
|
attrs: { colWidth: 200 },
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "paragraph",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "column",
|
||||||
|
attrs: { colWidth: 200 },
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "paragraph",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "column",
|
||||||
|
attrs: { colWidth: 200 },
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "paragraph",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.run();
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Toggle block",
|
title: "Toggle block",
|
||||||
description: "Insert collapsible block.",
|
description: "Insert collapsible block.",
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export default function SubpagesView(props: NodeViewProps) {
|
|||||||
|
|
||||||
if (error && !shareId) {
|
if (error && !shareId) {
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<Text c="dimmed" size="md" py="md">
|
<Text c="dimmed" size="md" py="md">
|
||||||
{t("Failed to load subpages")}
|
{t("Failed to load subpages")}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -62,7 +62,7 @@ export default function SubpagesView(props: NodeViewProps) {
|
|||||||
|
|
||||||
if (subpages.length === 0) {
|
if (subpages.length === 0) {
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
<Text c="dimmed" size="md" py="md">
|
<Text c="dimmed" size="md" py="md">
|
||||||
{t("No subpages")}
|
{t("No subpages")}
|
||||||
@@ -73,7 +73,7 @@ export default function SubpagesView(props: NodeViewProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
<Stack gap={5}>
|
<Stack gap={5}>
|
||||||
{subpages.map((page) => (
|
{subpages.map((page) => (
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
UnstyledButton,
|
UnstyledButton,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useEditor } from "@tiptap/react";
|
import type { Editor } from "@tiptap/react";
|
||||||
|
import { useEditorState } from "@tiptap/react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export interface TableColorItem {
|
export interface TableColorItem {
|
||||||
@@ -18,7 +19,7 @@ export interface TableColorItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface TableBackgroundColorProps {
|
interface TableBackgroundColorProps {
|
||||||
editor: ReturnType<typeof useEditor>;
|
editor: Editor | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TABLE_COLORS: TableColorItem[] = [
|
const TABLE_COLORS: TableColorItem[] = [
|
||||||
@@ -38,37 +39,50 @@ export const TableBackgroundColor: FC<TableBackgroundColorProps> = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [opened, setOpened] = React.useState(false);
|
const [opened, setOpened] = React.useState(false);
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentColor = "";
|
||||||
|
if (ctx.editor.isActive("tableCell")) {
|
||||||
|
const attrs = ctx.editor.getAttributes("tableCell");
|
||||||
|
currentColor = attrs.backgroundColor || "";
|
||||||
|
} else if (ctx.editor.isActive("tableHeader")) {
|
||||||
|
const attrs = ctx.editor.getAttributes("tableHeader");
|
||||||
|
currentColor = attrs.backgroundColor || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
currentColor,
|
||||||
|
isTableCell: ctx.editor.isActive("tableCell"),
|
||||||
|
isTableHeader: ctx.editor.isActive("tableHeader"),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!editor || !editorState) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const setTableCellBackground = (color: string, colorName: string) => {
|
const setTableCellBackground = (color: string, colorName: string) => {
|
||||||
editor
|
editor
|
||||||
.chain()
|
.chain()
|
||||||
.focus()
|
.focus()
|
||||||
.updateAttributes("tableCell", {
|
.updateAttributes("tableCell", {
|
||||||
backgroundColor: color || null,
|
backgroundColor: color || null,
|
||||||
backgroundColorName: color ? colorName : null
|
backgroundColorName: color ? colorName : null,
|
||||||
})
|
})
|
||||||
.updateAttributes("tableHeader", {
|
.updateAttributes("tableHeader", {
|
||||||
backgroundColor: color || null,
|
backgroundColor: color || null,
|
||||||
backgroundColorName: color ? colorName : null
|
backgroundColorName: color ? colorName : null,
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
setOpened(false);
|
setOpened(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get current cell's background color
|
|
||||||
const getCurrentColor = () => {
|
|
||||||
if (editor.isActive("tableCell")) {
|
|
||||||
const attrs = editor.getAttributes("tableCell");
|
|
||||||
return attrs.backgroundColor || "";
|
|
||||||
}
|
|
||||||
if (editor.isActive("tableHeader")) {
|
|
||||||
const attrs = editor.getAttributes("tableHeader");
|
|
||||||
return attrs.backgroundColor || "";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
};
|
|
||||||
|
|
||||||
const currentColor = getCurrentColor();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
width={200}
|
width={200}
|
||||||
@@ -123,7 +137,7 @@ export const TableBackgroundColor: FC<TableBackgroundColorProps> = ({
|
|||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{currentColor === item.color && (
|
{editorState.currentColor === item.color && (
|
||||||
<IconCheck
|
<IconCheck
|
||||||
size={18}
|
size={18}
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -9,15 +9,15 @@ import {
|
|||||||
ActionIcon,
|
ActionIcon,
|
||||||
Button,
|
Button,
|
||||||
Popover,
|
Popover,
|
||||||
rem,
|
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useEditor } from "@tiptap/react";
|
import type { Editor } from "@tiptap/react";
|
||||||
|
import { useEditorState } from "@tiptap/react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
interface TableTextAlignmentProps {
|
interface TableTextAlignmentProps {
|
||||||
editor: ReturnType<typeof useEditor>;
|
editor: Editor | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AlignmentItem {
|
interface AlignmentItem {
|
||||||
@@ -32,25 +32,44 @@ export const TableTextAlignment: FC<TableTextAlignmentProps> = ({ editor }) => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [opened, setOpened] = React.useState(false);
|
const [opened, setOpened] = React.useState(false);
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
isAlignLeft: ctx.editor.isActive({ textAlign: "left" }),
|
||||||
|
isAlignCenter: ctx.editor.isActive({ textAlign: "center" }),
|
||||||
|
isAlignRight: ctx.editor.isActive({ textAlign: "right" }),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!editor || !editorState) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const items: AlignmentItem[] = [
|
const items: AlignmentItem[] = [
|
||||||
{
|
{
|
||||||
name: "Align left",
|
name: "Align left",
|
||||||
value: "left",
|
value: "left",
|
||||||
isActive: () => editor.isActive({ textAlign: "left" }),
|
isActive: () => editorState?.isAlignLeft,
|
||||||
command: () => editor.chain().focus().setTextAlign("left").run(),
|
command: () => editor.chain().focus().setTextAlign("left").run(),
|
||||||
icon: IconAlignLeft,
|
icon: IconAlignLeft,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Align center",
|
name: "Align center",
|
||||||
value: "center",
|
value: "center",
|
||||||
isActive: () => editor.isActive({ textAlign: "center" }),
|
isActive: () => editorState?.isAlignCenter,
|
||||||
command: () => editor.chain().focus().setTextAlign("center").run(),
|
command: () => editor.chain().focus().setTextAlign("center").run(),
|
||||||
icon: IconAlignCenter,
|
icon: IconAlignCenter,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Align right",
|
name: "Align right",
|
||||||
value: "right",
|
value: "right",
|
||||||
isActive: () => editor.isActive({ textAlign: "right" }),
|
isActive: () => editorState?.isAlignRight,
|
||||||
command: () => editor.chain().focus().setTextAlign("right").run(),
|
command: () => editor.chain().focus().setTextAlign("right").run(),
|
||||||
icon: IconAlignRight,
|
icon: IconAlignRight,
|
||||||
},
|
},
|
||||||
@@ -64,7 +83,7 @@ export const TableTextAlignment: FC<TableTextAlignmentProps> = ({ editor }) => {
|
|||||||
onChange={setOpened}
|
onChange={setOpened}
|
||||||
position="bottom"
|
position="bottom"
|
||||||
withArrow
|
withArrow
|
||||||
transitionProps={{ transition: 'pop' }}
|
transitionProps={{ transition: "pop" }}
|
||||||
>
|
>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
<Tooltip label={t("Text alignment")} withArrow>
|
<Tooltip label={t("Text alignment")} withArrow>
|
||||||
@@ -87,9 +106,7 @@ export const TableTextAlignment: FC<TableTextAlignmentProps> = ({ editor }) => {
|
|||||||
key={index}
|
key={index}
|
||||||
variant="default"
|
variant="default"
|
||||||
leftSection={<item.icon size={16} />}
|
leftSection={<item.icon size={16} />}
|
||||||
rightSection={
|
rightSection={item.isActive() && <IconCheck size={16} />}
|
||||||
item.isActive() && <IconCheck size={16} />
|
|
||||||
}
|
|
||||||
justify="left"
|
justify="left"
|
||||||
fullWidth
|
fullWidth
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -106,4 +123,4 @@ export const TableTextAlignment: FC<TableTextAlignmentProps> = ({ editor }) => {
|
|||||||
</Popover.Dropdown>
|
</Popover.Dropdown>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
BubbleMenu as BaseBubbleMenu,
|
BubbleMenu as BaseBubbleMenu,
|
||||||
findParentNode,
|
findParentNode,
|
||||||
posToDOMRect,
|
posToDOMRect,
|
||||||
|
useEditorState,
|
||||||
} from "@tiptap/react";
|
} from "@tiptap/react";
|
||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
import { sticky } from "tippy.js";
|
import { sticky } from "tippy.js";
|
||||||
@@ -32,6 +33,25 @@ export function VideoMenu({ editor }: EditorMenuProps) {
|
|||||||
[editor],
|
[editor],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const editorState = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
if (!ctx.editor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const videoAttrs = ctx.editor.getAttributes("video");
|
||||||
|
|
||||||
|
return {
|
||||||
|
isVideo: ctx.editor.isActive("video"),
|
||||||
|
isAlignLeft: ctx.editor.isActive("video", { align: "left" }),
|
||||||
|
isAlignCenter: ctx.editor.isActive("video", { align: "center" }),
|
||||||
|
isAlignRight: ctx.editor.isActive("video", { align: "right" }),
|
||||||
|
width: videoAttrs?.width ? parseInt(videoAttrs.width) : null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const getReferenceClientRect = useCallback(() => {
|
const getReferenceClientRect = useCallback(() => {
|
||||||
const { selection } = editor.state;
|
const { selection } = editor.state;
|
||||||
const predicate = (node: PMNode) => node.type.name === "video";
|
const predicate = (node: PMNode) => node.type.name === "video";
|
||||||
@@ -83,7 +103,7 @@ export function VideoMenu({ editor }: EditorMenuProps) {
|
|||||||
return (
|
return (
|
||||||
<BaseBubbleMenu
|
<BaseBubbleMenu
|
||||||
editor={editor}
|
editor={editor}
|
||||||
pluginKey={`video-menu}`}
|
pluginKey={`video-menu`}
|
||||||
updateDelay={0}
|
updateDelay={0}
|
||||||
tippyOptions={{
|
tippyOptions={{
|
||||||
getReferenceClientRect,
|
getReferenceClientRect,
|
||||||
@@ -103,9 +123,7 @@ export function VideoMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={alignVideoLeft}
|
onClick={alignVideoLeft}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Align left")}
|
aria-label={t("Align left")}
|
||||||
variant={
|
variant={editorState?.isAlignLeft ? "light" : "default"}
|
||||||
editor.isActive("video", { align: "left" }) ? "light" : "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconLayoutAlignLeft size={18} />
|
<IconLayoutAlignLeft size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -116,11 +134,7 @@ export function VideoMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={alignVideoCenter}
|
onClick={alignVideoCenter}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Align center")}
|
aria-label={t("Align center")}
|
||||||
variant={
|
variant={editorState?.isAlignCenter ? "light" : "default"}
|
||||||
editor.isActive("video", { align: "center" })
|
|
||||||
? "light"
|
|
||||||
: "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconLayoutAlignCenter size={18} />
|
<IconLayoutAlignCenter size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -131,20 +145,15 @@ export function VideoMenu({ editor }: EditorMenuProps) {
|
|||||||
onClick={alignVideoRight}
|
onClick={alignVideoRight}
|
||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Align right")}
|
aria-label={t("Align right")}
|
||||||
variant={
|
variant={editorState?.isAlignRight ? "light" : "default"}
|
||||||
editor.isActive("video", { align: "right" }) ? "light" : "default"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconLayoutAlignRight size={18} />
|
<IconLayoutAlignRight size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</ActionIcon.Group>
|
</ActionIcon.Group>
|
||||||
|
|
||||||
{editor.getAttributes("video")?.width && (
|
{editorState?.width && (
|
||||||
<NodeWidthResize
|
<NodeWidthResize onChange={onWidthChange} value={editorState.width} />
|
||||||
onChange={onWidthChange}
|
|
||||||
value={parseInt(editor.getAttributes("video").width)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</BaseBubbleMenu>
|
</BaseBubbleMenu>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default function VideoView(props: NodeViewProps) {
|
|||||||
}, [align]);
|
}, [align]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<video
|
<video
|
||||||
preload="metadata"
|
preload="metadata"
|
||||||
width={width}
|
width={width}
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
import { StarterKit } from "@tiptap/starter-kit";
|
import { StarterKit } from "@tiptap/starter-kit";
|
||||||
import { Placeholder } from "@tiptap/extension-placeholder";
|
import { Placeholder } from "@tiptap/extension-placeholder";
|
||||||
import { TextAlign } from "@tiptap/extension-text-align";
|
import { TextAlign } from "@tiptap/extension-text-align";
|
||||||
|
import { CharacterCount } from "@tiptap/extension-character-count";
|
||||||
import { TaskList } from "@tiptap/extension-task-list";
|
import { TaskList } from "@tiptap/extension-task-list";
|
||||||
|
import { ListKeymap } from "@tiptap/extension-list-keymap";
|
||||||
import { TaskItem } from "@tiptap/extension-task-item";
|
import { TaskItem } from "@tiptap/extension-task-item";
|
||||||
import { Underline } from "@tiptap/extension-underline";
|
import { Underline } from "@tiptap/extension-underline";
|
||||||
import { Superscript } from "@tiptap/extension-superscript";
|
import { Superscript } from "@tiptap/extension-superscript";
|
||||||
import SubScript from "@tiptap/extension-subscript";
|
import SubScript from "@tiptap/extension-subscript";
|
||||||
import { Highlight } from "@tiptap/extension-highlight";
|
|
||||||
import { Typography } from "@tiptap/extension-typography";
|
import { Typography } from "@tiptap/extension-typography";
|
||||||
import { TextStyle } from "@tiptap/extension-text-style";
|
import { TextStyle } from "@tiptap/extension-text-style";
|
||||||
import { Color } from "@tiptap/extension-color";
|
import { Color } from "@tiptap/extension-color";
|
||||||
|
import GlobalDragHandle from "tiptap-extension-global-drag-handle";
|
||||||
|
import { Youtube } from "@tiptap/extension-youtube";
|
||||||
import SlashCommand from "@/features/editor/extensions/slash-command";
|
import SlashCommand from "@/features/editor/extensions/slash-command";
|
||||||
import { Collaboration } from "@tiptap/extension-collaboration";
|
import { Collaboration, isChangeOrigin } from "@tiptap/extension-collaboration";
|
||||||
import { CollaborationCursor } from "@tiptap/extension-collaboration-cursor";
|
import { CollaborationCursor } from "@tiptap/extension-collaboration-cursor";
|
||||||
import { HocuspocusProvider } from "@hocuspocus/provider";
|
import { HocuspocusProvider } from "@hocuspocus/provider";
|
||||||
import {
|
import {
|
||||||
@@ -40,6 +43,10 @@ import {
|
|||||||
Mention,
|
Mention,
|
||||||
Subpages,
|
Subpages,
|
||||||
TableDndExtension,
|
TableDndExtension,
|
||||||
|
Heading,
|
||||||
|
Highlight,
|
||||||
|
UniqueID,
|
||||||
|
ColumnsExtension,
|
||||||
} from "@docmost/editor-ext";
|
} from "@docmost/editor-ext";
|
||||||
import {
|
import {
|
||||||
randomElement,
|
randomElement,
|
||||||
@@ -48,11 +55,8 @@ import {
|
|||||||
import { IUser } from "@/features/user/types/user.types.ts";
|
import { IUser } from "@/features/user/types/user.types.ts";
|
||||||
import MathInlineView from "@/features/editor/components/math/math-inline.tsx";
|
import MathInlineView from "@/features/editor/components/math/math-inline.tsx";
|
||||||
import MathBlockView from "@/features/editor/components/math/math-block.tsx";
|
import MathBlockView from "@/features/editor/components/math/math-block.tsx";
|
||||||
import GlobalDragHandle from "tiptap-extension-global-drag-handle";
|
|
||||||
import { Youtube } from "@tiptap/extension-youtube";
|
|
||||||
import ImageView from "@/features/editor/components/image/image-view.tsx";
|
import ImageView from "@/features/editor/components/image/image-view.tsx";
|
||||||
import CalloutView from "@/features/editor/components/callout/callout-view.tsx";
|
import CalloutView from "@/features/editor/components/callout/callout-view.tsx";
|
||||||
import { common, createLowlight } from "lowlight";
|
|
||||||
import VideoView from "@/features/editor/components/video/video-view.tsx";
|
import VideoView from "@/features/editor/components/video/video-view.tsx";
|
||||||
import AttachmentView from "@/features/editor/components/attachment/attachment-view.tsx";
|
import AttachmentView from "@/features/editor/components/attachment/attachment-view.tsx";
|
||||||
import CodeBlockView from "@/features/editor/components/code-block/code-block-view.tsx";
|
import CodeBlockView from "@/features/editor/components/code-block/code-block-view.tsx";
|
||||||
@@ -60,6 +64,7 @@ import DrawioView from "../components/drawio/drawio-view";
|
|||||||
import ExcalidrawView from "@/features/editor/components/excalidraw/excalidraw-view.tsx";
|
import ExcalidrawView from "@/features/editor/components/excalidraw/excalidraw-view.tsx";
|
||||||
import EmbedView from "@/features/editor/components/embed/embed-view.tsx";
|
import EmbedView from "@/features/editor/components/embed/embed-view.tsx";
|
||||||
import SubpagesView from "@/features/editor/components/subpages/subpages-view.tsx";
|
import SubpagesView from "@/features/editor/components/subpages/subpages-view.tsx";
|
||||||
|
import { common, createLowlight } from "lowlight";
|
||||||
import plaintext from "highlight.js/lib/languages/plaintext";
|
import plaintext from "highlight.js/lib/languages/plaintext";
|
||||||
import powershell from "highlight.js/lib/languages/powershell";
|
import powershell from "highlight.js/lib/languages/powershell";
|
||||||
import abap from "highlightjs-sap-abap";
|
import abap from "highlightjs-sap-abap";
|
||||||
@@ -76,7 +81,6 @@ import MentionView from "@/features/editor/components/mention/mention-view.tsx";
|
|||||||
import i18n from "@/i18n.ts";
|
import i18n from "@/i18n.ts";
|
||||||
import { MarkdownClipboard } from "@/features/editor/extensions/markdown-clipboard.ts";
|
import { MarkdownClipboard } from "@/features/editor/extensions/markdown-clipboard.ts";
|
||||||
import EmojiCommand from "./emoji-command";
|
import EmojiCommand from "./emoji-command";
|
||||||
import { CharacterCount } from "@tiptap/extension-character-count";
|
|
||||||
import { countWords } from "alfaaz";
|
import { countWords } from "alfaaz";
|
||||||
|
|
||||||
const lowlight = createLowlight(common);
|
const lowlight = createLowlight(common);
|
||||||
@@ -93,6 +97,7 @@ lowlight.register("scala", scala);
|
|||||||
|
|
||||||
export const mainExtensions = [
|
export const mainExtensions = [
|
||||||
StarterKit.configure({
|
StarterKit.configure({
|
||||||
|
heading: false,
|
||||||
history: false,
|
history: false,
|
||||||
dropcursor: {
|
dropcursor: {
|
||||||
width: 3,
|
width: 3,
|
||||||
@@ -105,6 +110,11 @@ export const mainExtensions = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
Heading,
|
||||||
|
UniqueID.configure({
|
||||||
|
types: ["heading", "paragraph"],
|
||||||
|
filterTransaction: (transaction) => !isChangeOrigin(transaction),
|
||||||
|
}),
|
||||||
Placeholder.configure({
|
Placeholder.configure({
|
||||||
placeholder: ({ node }) => {
|
placeholder: ({ node }) => {
|
||||||
if (node.type.name === "heading") {
|
if (node.type.name === "heading") {
|
||||||
@@ -125,6 +135,7 @@ export const mainExtensions = [
|
|||||||
TaskItem.configure({
|
TaskItem.configure({
|
||||||
nested: true,
|
nested: true,
|
||||||
}),
|
}),
|
||||||
|
ListKeymap,
|
||||||
Underline,
|
Underline,
|
||||||
LinkExtension.configure({
|
LinkExtension.configure({
|
||||||
openOnClick: false,
|
openOnClick: false,
|
||||||
@@ -219,6 +230,7 @@ export const mainExtensions = [
|
|||||||
Subpages.configure({
|
Subpages.configure({
|
||||||
view: SubpagesView,
|
view: SubpagesView,
|
||||||
}),
|
}),
|
||||||
|
ColumnsExtension,
|
||||||
MarkdownClipboard.configure({
|
MarkdownClipboard.configure({
|
||||||
transformPastedText: true,
|
transformPastedText: true,
|
||||||
}),
|
}),
|
||||||
@@ -228,17 +240,17 @@ export const mainExtensions = [
|
|||||||
SearchAndReplace.extend({
|
SearchAndReplace.extend({
|
||||||
addKeyboardShortcuts() {
|
addKeyboardShortcuts() {
|
||||||
return {
|
return {
|
||||||
'Mod-f': () => {
|
"Mod-f": () => {
|
||||||
const event = new CustomEvent("openFindDialogFromEditor", {});
|
const event = new CustomEvent("openFindDialogFromEditor", {});
|
||||||
document.dispatchEvent(event);
|
document.dispatchEvent(event);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
'Escape': () => {
|
Escape: () => {
|
||||||
const event = new CustomEvent("closeFindDialogFromEditor", {});
|
const event = new CustomEvent("closeFindDialogFromEditor", {});
|
||||||
document.dispatchEvent(event);
|
document.dispatchEvent(event);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
}).configure(),
|
}).configure(),
|
||||||
] as any;
|
] as any;
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { Editor } from "@tiptap/react";
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
|
||||||
|
function waitForState(checkFn: () => boolean): Promise<void> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
if (checkFn()) {
|
||||||
|
clearInterval(interval);
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
}, 800);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useEditorScroll = ({
|
||||||
|
canScroll,
|
||||||
|
initialScrollTo,
|
||||||
|
}: {
|
||||||
|
canScroll: () => boolean;
|
||||||
|
initialScrollTo?: string;
|
||||||
|
}) => {
|
||||||
|
const [scrollTo, setScrollTo] = useState<string>(initialScrollTo || "");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!initialScrollTo) {
|
||||||
|
setScrollTo(window.location.hash ? window.location.hash.slice(1) : "");
|
||||||
|
}
|
||||||
|
}, [initialScrollTo]);
|
||||||
|
|
||||||
|
const handleScrollTo = useCallback(async (editor: Editor, _scrollTo: string | null = null, tryCount: number = 0) => {
|
||||||
|
await waitForState(() => canScroll());
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const MAX_TRY_COUNT = 10;
|
||||||
|
if (tryCount >= MAX_TRY_COUNT) {
|
||||||
|
resolve(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetId = _scrollTo || scrollTo;
|
||||||
|
if (!targetId) {
|
||||||
|
resolve(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dom = editor.view.dom.querySelector(`[id="${targetId}"]`);
|
||||||
|
if (dom) {
|
||||||
|
dom.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
|
resolve(true);
|
||||||
|
} else {
|
||||||
|
setTimeout(async () => {
|
||||||
|
resolve(await handleScrollTo(editor, targetId, tryCount + 1));
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [scrollTo, canScroll]);
|
||||||
|
|
||||||
|
return { scrollTo, handleScrollTo };
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import "@/features/editor/styles/index.css";
|
import "@/features/editor/styles/index.css";
|
||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { IndexeddbPersistence } from "y-indexeddb";
|
import { IndexeddbPersistence } from "y-indexeddb";
|
||||||
import * as Y from "yjs";
|
import * as Y from "yjs";
|
||||||
import {
|
import {
|
||||||
@@ -7,7 +7,12 @@ import {
|
|||||||
onAuthenticationFailedParameters,
|
onAuthenticationFailedParameters,
|
||||||
WebSocketStatus,
|
WebSocketStatus,
|
||||||
} from "@hocuspocus/provider";
|
} from "@hocuspocus/provider";
|
||||||
import { EditorContent, EditorProvider, useEditor } from "@tiptap/react";
|
import {
|
||||||
|
EditorContent,
|
||||||
|
EditorProvider,
|
||||||
|
useEditor,
|
||||||
|
useEditorState,
|
||||||
|
} from "@tiptap/react";
|
||||||
import {
|
import {
|
||||||
collabExtensions,
|
collabExtensions,
|
||||||
mainExtensions,
|
mainExtensions,
|
||||||
@@ -50,7 +55,8 @@ import { extractPageSlugId } from "@/lib";
|
|||||||
import { FIVE_MINUTES } from "@/lib/constants.ts";
|
import { FIVE_MINUTES } from "@/lib/constants.ts";
|
||||||
import { PageEditMode } from "@/features/user/types/user.types.ts";
|
import { PageEditMode } from "@/features/user/types/user.types.ts";
|
||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from "jwt-decode";
|
||||||
import { searchSpotlight } from '@/features/search/constants.ts';
|
import { searchSpotlight } from "@/features/search/constants.ts";
|
||||||
|
import { useEditorScroll } from "./hooks/use-editor-scroll";
|
||||||
|
|
||||||
interface PageEditorProps {
|
interface PageEditorProps {
|
||||||
pageId: string;
|
pageId: string;
|
||||||
@@ -63,7 +69,16 @@ export default function PageEditor({
|
|||||||
editable,
|
editable,
|
||||||
content,
|
content,
|
||||||
}: PageEditorProps) {
|
}: PageEditorProps) {
|
||||||
|
|
||||||
|
|
||||||
const collaborationURL = useCollaborationUrl();
|
const collaborationURL = useCollaborationUrl();
|
||||||
|
const isComponentMounted = useRef(false);
|
||||||
|
const editorCreated = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
isComponentMounted.current = true;
|
||||||
|
}, []);
|
||||||
|
|
||||||
const [currentUser] = useAtom(currentUserAtom);
|
const [currentUser] = useAtom(currentUserAtom);
|
||||||
const [, setEditor] = useAtom(pageEditorAtom);
|
const [, setEditor] = useAtom(pageEditorAtom);
|
||||||
const [, setAsideState] = useAtom(asideStateAtom);
|
const [, setAsideState] = useAtom(asideStateAtom);
|
||||||
@@ -77,7 +92,7 @@ export default function PageEditor({
|
|||||||
const [isLocalSynced, setLocalSynced] = useState(false);
|
const [isLocalSynced, setLocalSynced] = useState(false);
|
||||||
const [isRemoteSynced, setRemoteSynced] = useState(false);
|
const [isRemoteSynced, setRemoteSynced] = useState(false);
|
||||||
const [yjsConnectionStatus, setYjsConnectionStatus] = useAtom(
|
const [yjsConnectionStatus, setYjsConnectionStatus] = useAtom(
|
||||||
yjsConnectionStatusAtom
|
yjsConnectionStatusAtom,
|
||||||
);
|
);
|
||||||
const menuContainerRef = useRef(null);
|
const menuContainerRef = useRef(null);
|
||||||
const documentName = `page.${pageId}`;
|
const documentName = `page.${pageId}`;
|
||||||
@@ -89,7 +104,9 @@ export default function PageEditor({
|
|||||||
const slugId = extractPageSlugId(pageSlug);
|
const slugId = extractPageSlugId(pageSlug);
|
||||||
const userPageEditMode =
|
const userPageEditMode =
|
||||||
currentUser?.user?.settings?.preferences?.pageEditMode ?? PageEditMode.Edit;
|
currentUser?.user?.settings?.preferences?.pageEditMode ?? PageEditMode.Edit;
|
||||||
|
|
||||||
|
const canScroll = useCallback(() => isComponentMounted.current && editorCreated.current, [isComponentMounted, editorCreated]);
|
||||||
|
const { handleScrollTo } = useEditorScroll({ canScroll });
|
||||||
// Providers only created once per pageId
|
// Providers only created once per pageId
|
||||||
const providersRef = useRef<{
|
const providersRef = useRef<{
|
||||||
local: IndexeddbPersistence;
|
local: IndexeddbPersistence;
|
||||||
@@ -213,17 +230,17 @@ export default function PageEditor({
|
|||||||
extensions,
|
extensions,
|
||||||
editable,
|
editable,
|
||||||
immediatelyRender: true,
|
immediatelyRender: true,
|
||||||
shouldRerenderOnTransaction: true,
|
shouldRerenderOnTransaction: false,
|
||||||
editorProps: {
|
editorProps: {
|
||||||
scrollThreshold: 80,
|
scrollThreshold: 80,
|
||||||
scrollMargin: 80,
|
scrollMargin: 80,
|
||||||
handleDOMEvents: {
|
handleDOMEvents: {
|
||||||
keydown: (_view, event) => {
|
keydown: (_view, event) => {
|
||||||
if ((event.ctrlKey || event.metaKey) && event.code === 'KeyS') {
|
if ((event.ctrlKey || event.metaKey) && event.code === "KeyS") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((event.ctrlKey || event.metaKey) && event.code === 'KeyK') {
|
if ((event.ctrlKey || event.metaKey) && event.code === "KeyK") {
|
||||||
searchSpotlight.open();
|
searchSpotlight.open();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -259,6 +276,8 @@ export default function PageEditor({
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
setEditor(editor);
|
setEditor(editor);
|
||||||
editor.storage.pageId = pageId;
|
editor.storage.pageId = pageId;
|
||||||
|
handleScrollTo(editor);
|
||||||
|
editorCreated.current = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onUpdate({ editor }) {
|
onUpdate({ editor }) {
|
||||||
@@ -268,9 +287,16 @@ export default function PageEditor({
|
|||||||
debouncedUpdateContent(editorJson);
|
debouncedUpdateContent(editorJson);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[pageId, editable, remoteProvider]
|
[pageId, editable, remoteProvider],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const editorIsEditable = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: (ctx) => {
|
||||||
|
return ctx.editor?.isEditable ?? false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const debouncedUpdateContent = useDebouncedCallback((newContent: any) => {
|
const debouncedUpdateContent = useDebouncedCallback((newContent: any) => {
|
||||||
const pageData = queryClient.getQueryData<IPage>(["pages", slugId]);
|
const pageData = queryClient.getQueryData<IPage>(["pages", slugId]);
|
||||||
|
|
||||||
@@ -306,7 +332,7 @@ export default function PageEditor({
|
|||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener(
|
document.removeEventListener(
|
||||||
"ACTIVE_COMMENT_EVENT",
|
"ACTIVE_COMMENT_EVENT",
|
||||||
handleActiveCommentEvent
|
handleActiveCommentEvent,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
@@ -389,7 +415,7 @@ export default function PageEditor({
|
|||||||
<SearchAndReplaceDialog editor={editor} editable={editable} />
|
<SearchAndReplaceDialog editor={editor} editable={editable} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{editor && editor.isEditable && (
|
{editor && editorIsEditable && (
|
||||||
<div>
|
<div>
|
||||||
<EditorBubbleMenu editor={editor} />
|
<EditorBubbleMenu editor={editor} />
|
||||||
<TableMenu editor={editor} />
|
<TableMenu editor={editor} />
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import "@/features/editor/styles/index.css";
|
import "@/features/editor/styles/index.css";
|
||||||
import React, { useMemo } from "react";
|
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
||||||
import { EditorProvider } from "@tiptap/react";
|
import { EditorProvider } from "@tiptap/react";
|
||||||
import { mainExtensions } from "@/features/editor/extensions/extensions";
|
import { mainExtensions } from "@/features/editor/extensions/extensions";
|
||||||
import { Document } from "@tiptap/extension-document";
|
import { Document } from "@tiptap/extension-document";
|
||||||
import { Heading } from "@tiptap/extension-heading";
|
import { Heading, generateNodeId, UniqueID } from "@docmost/editor-ext";
|
||||||
import { Text } from "@tiptap/extension-text";
|
import { Text } from "@tiptap/extension-text";
|
||||||
import { Placeholder } from "@tiptap/extension-placeholder";
|
import { Placeholder } from "@tiptap/extension-placeholder";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { readOnlyEditorAtom } from "@/features/editor/atoms/editor-atoms.ts";
|
import { readOnlyEditorAtom } from "@/features/editor/atoms/editor-atoms.ts";
|
||||||
|
import { useEditorScroll } from "./hooks/use-editor-scroll";
|
||||||
|
|
||||||
interface PageEditorProps {
|
interface PageEditorProps {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -21,9 +22,34 @@ export default function ReadonlyPageEditor({
|
|||||||
pageId,
|
pageId,
|
||||||
}: PageEditorProps) {
|
}: PageEditorProps) {
|
||||||
const [, setReadOnlyEditor] = useAtom(readOnlyEditorAtom);
|
const [, setReadOnlyEditor] = useAtom(readOnlyEditorAtom);
|
||||||
|
const isComponentMounted = useRef(false);
|
||||||
|
const editorCreated = useRef(false);
|
||||||
|
|
||||||
|
const canScroll = useCallback(
|
||||||
|
() => isComponentMounted.current && editorCreated.current,
|
||||||
|
[isComponentMounted, editorCreated],
|
||||||
|
);
|
||||||
|
const initialScrollTo = window.location.hash
|
||||||
|
? window.location.hash.slice(1)
|
||||||
|
: "";
|
||||||
|
const { handleScrollTo } = useEditorScroll({ canScroll, initialScrollTo });
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
isComponentMounted.current = true;
|
||||||
|
}, []);
|
||||||
|
|
||||||
const extensions = useMemo(() => {
|
const extensions = useMemo(() => {
|
||||||
return [...mainExtensions];
|
const filteredExtensions = mainExtensions.filter(
|
||||||
|
(ext) => ext.name !== "uniqueID",
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
|
...filteredExtensions,
|
||||||
|
UniqueID.configure({
|
||||||
|
types: ["heading", "paragraph"],
|
||||||
|
updateDocument: false,
|
||||||
|
}),
|
||||||
|
];
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const titleExtensions = [
|
const titleExtensions = [
|
||||||
@@ -59,6 +85,9 @@ export default function ReadonlyPageEditor({
|
|||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
setReadOnlyEditor(editor);
|
setReadOnlyEditor(editor);
|
||||||
|
|
||||||
|
handleScrollTo(editor);
|
||||||
|
editorCreated.current = true;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
></EditorProvider>
|
></EditorProvider>
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
.resize-cursor {
|
||||||
|
cursor: col-resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
width: calc(100% - 8px);
|
||||||
|
gap: 12px;
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container.has-focus .prosemirror-column,
|
||||||
|
.prosemirror-column-container:hover .prosemirror-column {
|
||||||
|
background-color: rgba(100, 106, 115, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container .prosemirror-column {
|
||||||
|
position: relative;
|
||||||
|
border-radius: 8px;
|
||||||
|
min-width: 50px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: background-color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
> :not(div.grid-resize-handle):nth-child(1),
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
> div.grid-resize-handle
|
||||||
|
+ :nth-child(2) {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container .prosemirror-column > :nth-last-child(1) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container .prosemirror-column .grid-resize-handle {
|
||||||
|
position: absolute;
|
||||||
|
right: -7px;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 2px;
|
||||||
|
z-index: 20;
|
||||||
|
background-color: #336df4;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
.grid-resize-handle
|
||||||
|
.circle-button {
|
||||||
|
top: -8px;
|
||||||
|
left: -9px;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
background-color: #007bff;
|
||||||
|
border: 4px solid white;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: relative;
|
||||||
|
pointer-events: auto;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: transform 0.1s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
.grid-resize-handle
|
||||||
|
.circle-button:hover {
|
||||||
|
transform: scale(1.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
.grid-resize-handle
|
||||||
|
.circle-button
|
||||||
|
.plus {
|
||||||
|
position: relative;
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
.grid-resize-handle
|
||||||
|
.circle-button
|
||||||
|
.plus::before,
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
.grid-resize-handle
|
||||||
|
.circle-button
|
||||||
|
.plus::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
background-color: white;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
.grid-resize-handle
|
||||||
|
.circle-button
|
||||||
|
.plus::before {
|
||||||
|
width: 8px;
|
||||||
|
height: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prosemirror-column-container
|
||||||
|
.prosemirror-column
|
||||||
|
.grid-resize-handle
|
||||||
|
.circle-button
|
||||||
|
.plus::after {
|
||||||
|
width: 24px;
|
||||||
|
height: 8px;
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
);
|
);
|
||||||
color: light-dark(
|
color: light-dark(
|
||||||
var(--mantine-color-default-color),
|
var(--mantine-color-default-color),
|
||||||
var(--mantine-color-dark-0)
|
var(--mantine-color-white)
|
||||||
);
|
);
|
||||||
font-size: var(--mantine-font-size-md);
|
font-size: var(--mantine-font-size-md);
|
||||||
line-height: var(--mantine-line-height-xl);
|
line-height: var(--mantine-line-height-xl);
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
& > .react-renderer {
|
& > .react-renderer {
|
||||||
margin-top: var(--mantine-spacing-sm);
|
margin-top: var(--mantine-spacing-sm);
|
||||||
margin-bottom: var(--mantine-spacing-sm);
|
margin-bottom: var(--mantine-spacing-sm);
|
||||||
|
|
||||||
&:first-child {
|
&:first-child {
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
|
|
||||||
.selection,
|
.selection,
|
||||||
*::selection {
|
*::selection {
|
||||||
background-color: Highlight;
|
background-color: light-dark(Highlight, var(--mantine-color-gray-7));
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-mark {
|
.comment-mark {
|
||||||
@@ -186,6 +186,39 @@
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.ProseMirror > h1,
|
||||||
|
.ProseMirror > h2,
|
||||||
|
.ProseMirror > h3,
|
||||||
|
.ProseMirror > h4,
|
||||||
|
.ProseMirror > h5,
|
||||||
|
.ProseMirror > h6 {
|
||||||
|
|
||||||
|
> .link-btn {
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
> .link-btn > .link-btn-content {
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
left: 5px;
|
||||||
|
top: 0;
|
||||||
|
height: 100%;
|
||||||
|
transition: opacity 0.15s ease;
|
||||||
|
display: inline-flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover > .link-btn > .link-btn-content {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
scroll-margin-top: 80px; /* match your header height */
|
||||||
}
|
}
|
||||||
|
|
||||||
.ProseMirror-icon {
|
.ProseMirror-icon {
|
||||||
@@ -209,4 +242,3 @@
|
|||||||
.actionIconGroup {
|
.actionIconGroup {
|
||||||
background: var(--mantine-color-body);
|
background: var(--mantine-color-body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,177 @@
|
|||||||
|
/* Highlight colors with dark mode support */
|
||||||
|
|
||||||
|
.ProseMirror {
|
||||||
|
/* Blue */
|
||||||
|
mark[data-color="#98d8f2"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(224 242 254),
|
||||||
|
rgba(37, 99, 235, 0.35)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Green */
|
||||||
|
mark[data-color="#7edb6c"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(220 252 231),
|
||||||
|
rgba(0, 138, 0, 0.35)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Purple */
|
||||||
|
mark[data-color="#e0d6ed"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(243 232 255),
|
||||||
|
rgba(147, 51, 234, 0.35)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Red */
|
||||||
|
mark[data-color="#ffc6c2"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(255 228 230),
|
||||||
|
rgba(224, 0, 0, 0.35)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yellow */
|
||||||
|
mark[data-color="#faf594"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(254 249 195),
|
||||||
|
rgba(234, 179, 8, 0.35)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Orange */
|
||||||
|
mark[data-color="#f5c8a9"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(251, 236, 221),
|
||||||
|
rgba(255, 165, 0, 0.45)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pink */
|
||||||
|
mark[data-color="#f5cfe0"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(252, 241, 246),
|
||||||
|
rgba(186, 64, 129, 0.35)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Gray */
|
||||||
|
mark[data-color="#dfdfd7"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(238 238 235),
|
||||||
|
rgba(168, 162, 158, 0.35)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brown */
|
||||||
|
mark[data-color="#d7c4b7"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(215 196 183),
|
||||||
|
rgba(146, 64, 14, 0.35)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Color selector trigger button styles */
|
||||||
|
.color-selector-trigger[data-text-color="#2563EB"] {
|
||||||
|
color: #2563EB !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-text-color="#008A00"] {
|
||||||
|
color: #008A00 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-text-color="#9333EA"] {
|
||||||
|
color: #9333EA !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-text-color="#E00000"] {
|
||||||
|
color: #E00000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-text-color="#EAB308"] {
|
||||||
|
color: #EAB308 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-text-color="#FFA500"] {
|
||||||
|
color: #FFA500 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-text-color="#BA4081"] {
|
||||||
|
color: #BA4081 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-text-color="#A8A29E"] {
|
||||||
|
color: #A8A29E !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-text-color="#92400E"] {
|
||||||
|
color: #92400E !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Highlight background colors with light-dark support - solid colors for trigger button */
|
||||||
|
.color-selector-trigger[data-highlight-color="#98d8f2"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(224 242 254),
|
||||||
|
rgb(30 64 175)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-highlight-color="#7edb6c"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(220 252 231),
|
||||||
|
rgb(21 128 61)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-highlight-color="#e0d6ed"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(243 232 255),
|
||||||
|
rgb(107 33 168)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-highlight-color="#ffc6c2"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(255 228 230),
|
||||||
|
rgb(185 28 28)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-highlight-color="#faf594"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(254 249 195),
|
||||||
|
rgb(161 98 7)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-highlight-color="#f5c8a9"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(251 236 221),
|
||||||
|
rgb(194 65 12)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-highlight-color="#f5cfe0"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(252 241 246),
|
||||||
|
rgb(157 23 77)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-highlight-color="#dfdfd7"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(238 238 235),
|
||||||
|
rgb(115 115 115)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-selector-trigger[data-highlight-color="#d7c4b7"] {
|
||||||
|
background-color: light-dark(
|
||||||
|
rgb(215 196 183),
|
||||||
|
rgb(120 53 15)
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
@@ -12,3 +12,5 @@
|
|||||||
@import "./find.css";
|
@import "./find.css";
|
||||||
@import "./mention.css";
|
@import "./mention.css";
|
||||||
@import "./ordered-list.css";
|
@import "./ordered-list.css";
|
||||||
|
@import "./highlight.css";
|
||||||
|
@import "./column.css";
|
||||||
|
|||||||
@@ -104,7 +104,10 @@ export function TitleEditor({
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const pageSlug = buildPageUrl(spaceSlug, slugId, title);
|
const anchorId = window.location.hash
|
||||||
|
? window.location.hash.substring(1)
|
||||||
|
: undefined;
|
||||||
|
const pageSlug = buildPageUrl(spaceSlug, slugId, title, anchorId);
|
||||||
navigate(pageSlug, { replace: true });
|
navigate(pageSlug, { replace: true });
|
||||||
}, [title]);
|
}, [title]);
|
||||||
|
|
||||||
@@ -192,10 +195,43 @@ export function TitleEditor({
|
|||||||
const { key } = event;
|
const { key } = event;
|
||||||
const { $head } = titleEditor.state.selection;
|
const { $head } = titleEditor.state.selection;
|
||||||
|
|
||||||
|
if (key === "Enter") {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const { $from } = titleEditor.state.selection;
|
||||||
|
const titleText = titleEditor.getText();
|
||||||
|
|
||||||
|
// Get the text offset within the heading node (not document position)
|
||||||
|
const textOffset = $from.parentOffset;
|
||||||
|
|
||||||
|
const textAfterCursor = titleText.slice(textOffset);
|
||||||
|
|
||||||
|
// Delete text after cursor from title (this will be in undo history)
|
||||||
|
const endPos = titleEditor.state.doc.content.size;
|
||||||
|
if (textAfterCursor) {
|
||||||
|
titleEditor.commands.deleteRange({ from: $from.pos, to: endPos });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't add to history so undo in page editor won't remove this split
|
||||||
|
pageEditor
|
||||||
|
.chain()
|
||||||
|
.command(({ tr }) => {
|
||||||
|
tr.setMeta("addToHistory", false);
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.insertContentAt(0, {
|
||||||
|
type: "paragraph",
|
||||||
|
content: textAfterCursor
|
||||||
|
? [{ type: "text", text: textAfterCursor }]
|
||||||
|
: undefined,
|
||||||
|
})
|
||||||
|
.focus("start")
|
||||||
|
.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const shouldFocusEditor =
|
const shouldFocusEditor =
|
||||||
key === "Enter" ||
|
key === "ArrowDown" || (key === "ArrowRight" && !$head.nodeAfter);
|
||||||
key === "ArrowDown" ||
|
|
||||||
(key === "ArrowRight" && !$head.nodeAfter);
|
|
||||||
|
|
||||||
if (shouldFocusEditor) {
|
if (shouldFocusEditor) {
|
||||||
pageEditor.commands.focus("start");
|
pageEditor.commands.focus("start");
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { Group, Box, Button, TextInput, Stack, Textarea } from "@mantine/core";
|
import { Group, Box, Button, TextInput, Stack, Textarea } from "@mantine/core";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useCreateGroupMutation } from "@/features/group/queries/group-query.ts";
|
import { useCreateGroupMutation } from "@/features/group/queries/group-query.ts";
|
||||||
import { useForm, zodResolver } from "@mantine/form";
|
import { useForm } from "@mantine/form";
|
||||||
import * as z from "zod";
|
import * as z from "zod";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { MultiUserSelect } from "@/features/group/components/multi-user-select.tsx";
|
import { MultiUserSelect } from "@/features/group/components/multi-user-select.tsx";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { zodResolver } from 'mantine-form-zod-resolver';
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
name: z.string().trim().min(2).max(50),
|
name: z.string().trim().min(2).max(50),
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import {
|
|||||||
useGroupQuery,
|
useGroupQuery,
|
||||||
useUpdateGroupMutation,
|
useUpdateGroupMutation,
|
||||||
} from "@/features/group/queries/group-query.ts";
|
} from "@/features/group/queries/group-query.ts";
|
||||||
import { useForm, zodResolver } from "@mantine/form";
|
import { useForm } from "@mantine/form";
|
||||||
import * as z from "zod";
|
import * as z from "zod";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { zodResolver } from "mantine-form-zod-resolver";
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
name: z.string().min(2).max(50),
|
name: z.string().min(2).max(50),
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { IUser } from "@/features/user/types/user.types.ts";
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { validate as isValidUuid } from "uuid";
|
import { validate as isValidUuid } from "uuid";
|
||||||
import { queryClient } from "@/main.tsx";
|
import { queryClient } from "@/main.tsx";
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
export function useGetGroupsQuery(
|
export function useGetGroupsQuery(
|
||||||
params?: QueryParams,
|
params?: QueryParams,
|
||||||
@@ -73,11 +74,12 @@ export function useCreateGroupMutation() {
|
|||||||
|
|
||||||
export function useUpdateGroupMutation() {
|
export function useUpdateGroupMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation<IGroup, Error, Partial<IGroup>>({
|
return useMutation<IGroup, Error, Partial<IGroup>>({
|
||||||
mutationFn: (data) => updateGroup(data),
|
mutationFn: (data) => updateGroup(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Group updated successfully" });
|
notifications.show({ message: t("Group updated successfully") });
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ["group", variables.groupId],
|
queryKey: ["group", variables.groupId],
|
||||||
});
|
});
|
||||||
@@ -91,11 +93,12 @@ export function useUpdateGroupMutation() {
|
|||||||
|
|
||||||
export function useDeleteGroupMutation() {
|
export function useDeleteGroupMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (groupId: string) => deleteGroup({ groupId }),
|
mutationFn: (groupId: string) => deleteGroup({ groupId }),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Group deleted successfully" });
|
notifications.show({ message: t("Group deleted successfully") });
|
||||||
queryClient.refetchQueries({ queryKey: ["groups"] });
|
queryClient.refetchQueries({ queryKey: ["groups"] });
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
@@ -119,11 +122,12 @@ export function useGroupMembersQuery(
|
|||||||
|
|
||||||
export function useAddGroupMemberMutation() {
|
export function useAddGroupMemberMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation<void, Error, { groupId: string; userIds: string[] }>({
|
return useMutation<void, Error, { groupId: string; userIds: string[] }>({
|
||||||
mutationFn: (data) => addGroupMember(data),
|
mutationFn: (data) => addGroupMember(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Added successfully" });
|
notifications.show({ message: t("Added successfully") });
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ["groupMembers", variables.groupId],
|
queryKey: ["groupMembers", variables.groupId],
|
||||||
});
|
});
|
||||||
@@ -139,6 +143,7 @@ export function useAddGroupMemberMutation() {
|
|||||||
|
|
||||||
export function useRemoveGroupMemberMutation() {
|
export function useRemoveGroupMemberMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation<
|
return useMutation<
|
||||||
void,
|
void,
|
||||||
@@ -150,7 +155,7 @@ export function useRemoveGroupMemberMutation() {
|
|||||||
>({
|
>({
|
||||||
mutationFn: (data) => removeGroupMember(data),
|
mutationFn: (data) => removeGroupMember(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Removed successfully" });
|
notifications.show({ message: t("Removed successfully") });
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ["groupMembers", variables.groupId],
|
queryKey: ["groupMembers", variables.groupId],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,22 +15,29 @@ export const buildPageUrl = (
|
|||||||
spaceName: string,
|
spaceName: string,
|
||||||
pageSlugId: string,
|
pageSlugId: string,
|
||||||
pageTitle?: string,
|
pageTitle?: string,
|
||||||
|
anchorId?: string,
|
||||||
): string => {
|
): string => {
|
||||||
|
let url: string;
|
||||||
if (spaceName === undefined) {
|
if (spaceName === undefined) {
|
||||||
return `/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
url = `/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
||||||
|
} else {
|
||||||
|
url = `/s/${spaceName}/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
||||||
}
|
}
|
||||||
return `/s/${spaceName}/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
return anchorId ? `${url}#${anchorId}` : url;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildSharedPageUrl = (opts: {
|
export const buildSharedPageUrl = (opts: {
|
||||||
shareId: string;
|
shareId: string;
|
||||||
pageSlugId: string;
|
pageSlugId: string;
|
||||||
pageTitle?: string;
|
pageTitle?: string;
|
||||||
|
anchorId?: string;
|
||||||
}): string => {
|
}): string => {
|
||||||
const { shareId, pageSlugId, pageTitle } = opts;
|
const { shareId, pageSlugId, pageTitle, anchorId } = opts;
|
||||||
|
let url: string;
|
||||||
if (!shareId) {
|
if (!shareId) {
|
||||||
return `/share/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
url = `/share/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
||||||
|
} else {
|
||||||
|
url = `/share/${shareId}/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
||||||
}
|
}
|
||||||
|
return anchorId ? `${url}#${anchorId}` : url;
|
||||||
return `/share/${shareId}/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
ScrollArea,
|
ScrollArea,
|
||||||
Avatar,
|
Avatar,
|
||||||
Group,
|
Group,
|
||||||
|
Switch,
|
||||||
getDefaultZIndex,
|
getDefaultZIndex,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import {
|
import {
|
||||||
@@ -17,6 +18,7 @@ import {
|
|||||||
IconFileDescription,
|
IconFileDescription,
|
||||||
IconSearch,
|
IconSearch,
|
||||||
IconCheck,
|
IconCheck,
|
||||||
|
IconSparkles,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useDebouncedValue } from "@mantine/hooks";
|
import { useDebouncedValue } from "@mantine/hooks";
|
||||||
@@ -24,15 +26,21 @@ import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
|||||||
import { useLicense } from "@/ee/hooks/use-license";
|
import { useLicense } from "@/ee/hooks/use-license";
|
||||||
import classes from "./search-spotlight-filters.module.css";
|
import classes from "./search-spotlight-filters.module.css";
|
||||||
import { isCloud } from "@/lib/config.ts";
|
import { isCloud } from "@/lib/config.ts";
|
||||||
|
import { useAtom } from "jotai/index";
|
||||||
|
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||||
|
|
||||||
interface SearchSpotlightFiltersProps {
|
interface SearchSpotlightFiltersProps {
|
||||||
onFiltersChange?: (filters: any) => void;
|
onFiltersChange?: (filters: any) => void;
|
||||||
|
onAskClick?: () => void;
|
||||||
spaceId?: string;
|
spaceId?: string;
|
||||||
|
isAiMode?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SearchSpotlightFilters({
|
export function SearchSpotlightFilters({
|
||||||
onFiltersChange,
|
onFiltersChange,
|
||||||
|
onAskClick,
|
||||||
spaceId,
|
spaceId,
|
||||||
|
isAiMode = false,
|
||||||
}: SearchSpotlightFiltersProps) {
|
}: SearchSpotlightFiltersProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { hasLicenseKey } = useLicense();
|
const { hasLicenseKey } = useLicense();
|
||||||
@@ -42,6 +50,7 @@ export function SearchSpotlightFilters({
|
|||||||
const [spaceSearchQuery, setSpaceSearchQuery] = useState("");
|
const [spaceSearchQuery, setSpaceSearchQuery] = useState("");
|
||||||
const [debouncedSpaceQuery] = useDebouncedValue(spaceSearchQuery, 300);
|
const [debouncedSpaceQuery] = useDebouncedValue(spaceSearchQuery, 300);
|
||||||
const [contentType, setContentType] = useState<string | null>("page");
|
const [contentType, setContentType] = useState<string | null>("page");
|
||||||
|
const [workspace] = useAtom(workspaceAtom);
|
||||||
|
|
||||||
const { data: spacesData } = useGetSpacesQuery({
|
const { data: spacesData } = useGetSpacesQuery({
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -120,6 +129,31 @@ export function SearchSpotlightFilters({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.filtersContainer}>
|
<div className={classes.filtersContainer}>
|
||||||
|
{workspace?.settings?.ai?.search === true && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
height: "32px",
|
||||||
|
paddingLeft: "8px",
|
||||||
|
paddingRight: "8px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Switch
|
||||||
|
checked={isAiMode}
|
||||||
|
onChange={(event) => onAskClick()}
|
||||||
|
label={t("Ask AI")}
|
||||||
|
size="sm"
|
||||||
|
color="blue"
|
||||||
|
labelPosition="left"
|
||||||
|
styles={{
|
||||||
|
root: { display: "flex", alignItems: "center" },
|
||||||
|
label: { paddingRight: "8px", fontSize: "13px", fontWeight: 500 },
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<Menu
|
<Menu
|
||||||
shadow="md"
|
shadow="md"
|
||||||
width={250}
|
width={250}
|
||||||
@@ -231,7 +265,7 @@ export function SearchSpotlightFilters({
|
|||||||
contentType !== option.value &&
|
contentType !== option.value &&
|
||||||
handleFilterChange("contentType", option.value)
|
handleFilterChange("contentType", option.value)
|
||||||
}
|
}
|
||||||
disabled={option.disabled}
|
disabled={option.disabled || (isAiMode && option.value === "attachment")}
|
||||||
>
|
>
|
||||||
<Group flex="1" gap="xs">
|
<Group flex="1" gap="xs">
|
||||||
<div>
|
<div>
|
||||||
@@ -241,6 +275,11 @@ export function SearchSpotlightFilters({
|
|||||||
{t("Enterprise")}
|
{t("Enterprise")}
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
|
{!option.disabled && isAiMode && option.value === "attachment" && (
|
||||||
|
<Text size="xs" mt={4}>
|
||||||
|
{t("Ask AI not available for attachments")}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{contentType === option.value && <IconCheck size={20} />}
|
{contentType === option.value && <IconCheck size={20} />}
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import { Spotlight } from "@mantine/spotlight";
|
import { Spotlight } from "@mantine/spotlight";
|
||||||
import { IconSearch } from "@tabler/icons-react";
|
import { IconSearch, IconSparkles } from "@tabler/icons-react";
|
||||||
import React, { useState, useMemo } from "react";
|
import { Group, Button } from "@mantine/core";
|
||||||
|
import React, { useState, useMemo, useEffect } from "react";
|
||||||
import { useDebouncedValue } from "@mantine/hooks";
|
import { useDebouncedValue } from "@mantine/hooks";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { notifications } from "@mantine/notifications";
|
||||||
import { searchSpotlightStore } from "../constants.ts";
|
import { searchSpotlightStore } from "../constants.ts";
|
||||||
import { SearchSpotlightFilters } from "./search-spotlight-filters.tsx";
|
import { SearchSpotlightFilters } from "./search-spotlight-filters.tsx";
|
||||||
import { useUnifiedSearch } from "../hooks/use-unified-search.ts";
|
import { useUnifiedSearch } from "../hooks/use-unified-search.ts";
|
||||||
|
import { useAiSearch } from "../../../ee/ai/hooks/use-ai-search.ts";
|
||||||
import { SearchResultItem } from "./search-result-item.tsx";
|
import { SearchResultItem } from "./search-result-item.tsx";
|
||||||
|
import { AiSearchResult } from "../../../ee/ai/components/ai-search-result.tsx";
|
||||||
import { useLicense } from "@/ee/hooks/use-license.tsx";
|
import { useLicense } from "@/ee/hooks/use-license.tsx";
|
||||||
|
import { isCloud } from "@/lib/config.ts";
|
||||||
|
|
||||||
interface SearchSpotlightProps {
|
interface SearchSpotlightProps {
|
||||||
spaceId?: string;
|
spaceId?: string;
|
||||||
@@ -23,6 +28,7 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
}>({
|
}>({
|
||||||
contentType: "page",
|
contentType: "page",
|
||||||
});
|
});
|
||||||
|
const [isAiMode, setIsAiMode] = useState(false);
|
||||||
|
|
||||||
// Build unified search params
|
// Build unified search params
|
||||||
const searchParams = useMemo(() => {
|
const searchParams = useMemo(() => {
|
||||||
@@ -39,11 +45,46 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
return params;
|
return params;
|
||||||
}, [debouncedSearchQuery, filters]);
|
}, [debouncedSearchQuery, filters]);
|
||||||
|
|
||||||
const { data: searchResults, isLoading } = useUnifiedSearch(searchParams);
|
const { data: searchResults, isLoading } = useUnifiedSearch(
|
||||||
|
searchParams,
|
||||||
|
!isAiMode // Disable regular search when in AI mode
|
||||||
|
);
|
||||||
|
const {
|
||||||
|
//@ts-ignore
|
||||||
|
data: aiSearchResult,
|
||||||
|
//@ts-ignore
|
||||||
|
isPending: isAiLoading,
|
||||||
|
//@ts-ignore
|
||||||
|
mutate: triggerAiSearchMutation,
|
||||||
|
//@ts-ignore
|
||||||
|
reset: resetAiMutation,
|
||||||
|
//@ts-ignore
|
||||||
|
error: aiSearchError,
|
||||||
|
streamingAnswer,
|
||||||
|
streamingSources,
|
||||||
|
clearStreaming,
|
||||||
|
} = useAiSearch();
|
||||||
|
|
||||||
|
// Clear streaming state and mutation data when query changes (user is typing a new query)
|
||||||
|
useEffect(() => {
|
||||||
|
clearStreaming();
|
||||||
|
resetAiMutation();
|
||||||
|
}, [query, clearStreaming, resetAiMutation]);
|
||||||
|
|
||||||
|
// Show error notification when AI search fails
|
||||||
|
useEffect(() => {
|
||||||
|
if (aiSearchError) {
|
||||||
|
notifications.show({
|
||||||
|
message: aiSearchError.message || t("AI search failed. Please try again."),
|
||||||
|
color: "red",
|
||||||
|
position: "top-center"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [aiSearchError, t]);
|
||||||
|
|
||||||
// Determine result type for rendering
|
// Determine result type for rendering
|
||||||
const isAttachmentSearch =
|
const isAttachmentSearch =
|
||||||
filters.contentType === "attachment" && hasLicenseKey;
|
filters.contentType === "attachment" && (hasLicenseKey || isCloud());
|
||||||
|
|
||||||
const resultItems = (searchResults || []).map((result) => (
|
const resultItems = (searchResults || []).map((result) => (
|
||||||
<SearchResultItem
|
<SearchResultItem
|
||||||
@@ -58,6 +99,16 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
setFilters(newFilters);
|
setFilters(newFilters);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAskClick = () => {
|
||||||
|
setIsAiMode(!isAiMode);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAiSearchTrigger = () => {
|
||||||
|
if (query.trim() && isAiMode) {
|
||||||
|
triggerAiSearchMutation(searchParams);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Spotlight.Root
|
<Spotlight.Root
|
||||||
@@ -71,10 +122,30 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
backgroundOpacity: 0.55,
|
backgroundOpacity: 0.55,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Spotlight.Search
|
<Group gap="xs" px="sm" pt="sm" pb="xs">
|
||||||
placeholder={t("Search...")}
|
<Spotlight.Search
|
||||||
leftSection={<IconSearch size={20} stroke={1.5} />}
|
placeholder={isAiMode ? t("Ask a question...") : t("Search...")}
|
||||||
/>
|
leftSection={<IconSearch size={20} stroke={1.5} />}
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" && isAiMode && query.trim() && !isAiLoading) {
|
||||||
|
e.preventDefault();
|
||||||
|
handleAiSearchTrigger();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{isAiMode && hasLicenseKey && (
|
||||||
|
<Button
|
||||||
|
size="xs"
|
||||||
|
leftSection={<IconSparkles size={16} />}
|
||||||
|
onClick={handleAiSearchTrigger}
|
||||||
|
disabled={!query.trim()}
|
||||||
|
loading={isAiLoading}
|
||||||
|
>
|
||||||
|
Ask
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -83,20 +154,43 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
>
|
>
|
||||||
<SearchSpotlightFilters
|
<SearchSpotlightFilters
|
||||||
onFiltersChange={handleFiltersChange}
|
onFiltersChange={handleFiltersChange}
|
||||||
|
onAskClick={handleAskClick}
|
||||||
spaceId={spaceId}
|
spaceId={spaceId}
|
||||||
|
isAiMode={isAiMode}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Spotlight.ActionsList>
|
<Spotlight.ActionsList>
|
||||||
{query.length === 0 && resultItems.length === 0 && (
|
{isAiMode ? (
|
||||||
<Spotlight.Empty>{t("Start typing to search...")}</Spotlight.Empty>
|
<>
|
||||||
)}
|
{query.length === 0 && (
|
||||||
|
<Spotlight.Empty>{t("Ask a question...")}</Spotlight.Empty>
|
||||||
|
)}
|
||||||
|
{query.length > 0 && (isAiLoading || aiSearchResult || streamingAnswer) && (
|
||||||
|
<AiSearchResult
|
||||||
|
result={aiSearchResult}
|
||||||
|
isLoading={isAiLoading}
|
||||||
|
streamingAnswer={streamingAnswer}
|
||||||
|
streamingSources={streamingSources}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{query.length > 0 && !isAiLoading && !aiSearchResult && (
|
||||||
|
<Spotlight.Empty>{t("No answer available")}</Spotlight.Empty>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{query.length === 0 && resultItems.length === 0 && (
|
||||||
|
<Spotlight.Empty>{t("Start typing to search...")}</Spotlight.Empty>
|
||||||
|
)}
|
||||||
|
|
||||||
{query.length > 0 && !isLoading && resultItems.length === 0 && (
|
{query.length > 0 && !isLoading && resultItems.length === 0 && (
|
||||||
<Spotlight.Empty>{t("No results found...")}</Spotlight.Empty>
|
<Spotlight.Empty>{t("No results found...")}</Spotlight.Empty>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{resultItems.length > 0 && <>{resultItems}</>}
|
{resultItems.length > 0 && <>{resultItems}</>}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Spotlight.ActionsList>
|
</Spotlight.ActionsList>
|
||||||
</Spotlight.Root>
|
</Spotlight.Root>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export interface UseUnifiedSearchParams extends IPageSearchParams {
|
|||||||
|
|
||||||
export function useUnifiedSearch(
|
export function useUnifiedSearch(
|
||||||
params: UseUnifiedSearchParams,
|
params: UseUnifiedSearchParams,
|
||||||
|
enabled: boolean = true,
|
||||||
): UseQueryResult<UnifiedSearchResult[], Error> {
|
): UseQueryResult<UnifiedSearchResult[], Error> {
|
||||||
const { hasLicenseKey } = useLicense();
|
const { hasLicenseKey } = useLicense();
|
||||||
|
|
||||||
@@ -38,6 +39,6 @@ export function useUnifiedSearch(
|
|||||||
return await searchPage(backendParams);
|
return await searchPage(backendParams);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled: !!params.query,
|
enabled: !!params.query && enabled,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,14 +62,17 @@ export default function SpaceSettingsModal({
|
|||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
|
|
||||||
<Tabs.Panel value="general">
|
<Tabs.Panel value="general">
|
||||||
<ScrollArea h={550} scrollbarSize={4} pr={8}>
|
<ScrollArea h={580} scrollbarSize={5} pr={8}>
|
||||||
<SpaceDetails
|
<div style={{ paddingBottom: "100px"}}>
|
||||||
spaceId={space?.id}
|
<SpaceDetails
|
||||||
readOnly={spaceAbility.cannot(
|
spaceId={space?.id}
|
||||||
SpaceCaslAction.Manage,
|
readOnly={spaceAbility.cannot(
|
||||||
SpaceCaslSubject.Settings,
|
SpaceCaslAction.Manage,
|
||||||
)}
|
SpaceCaslSubject.Settings,
|
||||||
/>
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
|
|
||||||
|
|||||||
@@ -8,20 +8,11 @@ import { useTranslation } from "react-i18next";
|
|||||||
import Paginate from "@/components/common/paginate.tsx";
|
import Paginate from "@/components/common/paginate.tsx";
|
||||||
import { CustomAvatar } from "@/components/ui/custom-avatar.tsx";
|
import { CustomAvatar } from "@/components/ui/custom-avatar.tsx";
|
||||||
import { AvatarIconType } from "@/features/attachments/types/attachment.types.ts";
|
import { AvatarIconType } from "@/features/attachments/types/attachment.types.ts";
|
||||||
import { useAtom } from "jotai";
|
|
||||||
import { userAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
import { UserRole } from "@/lib/types.ts";
|
|
||||||
import { useIsEEOnly } from "@/hooks/use-is-cloud-ee.tsx";
|
|
||||||
|
|
||||||
export default function SpaceList() {
|
export default function SpaceList() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [user] = useAtom(userAtom);
|
const { data, isLoading } = useGetSpacesQuery({ page });
|
||||||
const isEEOnly = useIsEEOnly();
|
|
||||||
const { data, isLoading } = useGetSpacesQuery({
|
|
||||||
page,
|
|
||||||
...(isEEOnly && user.role === UserRole.OWNER && { includeAllSpaces: true }),
|
|
||||||
});
|
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [selectedSpaceId, setSelectedSpaceId] = useState<string>(null);
|
const [selectedSpaceId, setSelectedSpaceId] = useState<string>(null);
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export default function SpaceMembersList({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SearchInput onSearch={handleSearch} />
|
<SearchInput onSearch={handleSearch} />
|
||||||
<ScrollArea h={400}>
|
<ScrollArea h={450}>
|
||||||
<Table.ScrollContainer minWidth={500}>
|
<Table.ScrollContainer minWidth={500}>
|
||||||
<Table highlightOnHover verticalSpacing={8}>
|
<Table highlightOnHover verticalSpacing={8}>
|
||||||
<Table.Thead>
|
<Table.Thead>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export async function deleteWorkspaceMember(data: {
|
|||||||
await api.post("/workspace/members/delete", data);
|
await api.post("/workspace/members/delete", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateWorkspace(data: Partial<IWorkspace>) {
|
export async function updateWorkspace(data: Partial<IWorkspace> & { aiSearch?: boolean }) {
|
||||||
const req = await api.post<IWorkspace>("/workspace/update", data);
|
const req = await api.post<IWorkspace>("/workspace/update", data);
|
||||||
return req.data;
|
return req.data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export interface IWorkspace {
|
|||||||
defaultSpaceId: string;
|
defaultSpaceId: string;
|
||||||
customDomain: string;
|
customDomain: string;
|
||||||
enableInvite: boolean;
|
enableInvite: boolean;
|
||||||
settings: any;
|
settings: IWorkspaceSettings;
|
||||||
status: string;
|
status: string;
|
||||||
enforceSso: boolean;
|
enforceSso: boolean;
|
||||||
stripeCustomerId: string;
|
stripeCustomerId: string;
|
||||||
@@ -24,6 +24,14 @@ export interface IWorkspace {
|
|||||||
enforceMfa?: boolean;
|
enforceMfa?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IWorkspaceSettings {
|
||||||
|
ai?: IWorkspaceAiSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IWorkspaceAiSettings {
|
||||||
|
search?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ICreateInvite {
|
export interface ICreateInvite {
|
||||||
role: string;
|
role: string;
|
||||||
emails: string[];
|
emails: string[];
|
||||||
|
|||||||
@@ -1,16 +1,7 @@
|
|||||||
import { isCloud } from "@/lib/config";
|
import { isCloud } from "@/lib/config";
|
||||||
import { useLicense } from "@/ee/hooks/use-license";
|
import { useLicense } from "@/ee/hooks/use-license";
|
||||||
import { useAtom } from "jotai/index";
|
|
||||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
import usePlan from "@/ee/hooks/use-plan";
|
|
||||||
|
|
||||||
export const useIsCloudEE = () => {
|
export const useIsCloudEE = () => {
|
||||||
const { hasLicenseKey } = useLicense();
|
const { hasLicenseKey } = useLicense();
|
||||||
return isCloud() || !!hasLicenseKey;
|
return isCloud() || !!hasLicenseKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useIsEEOnly = () => {
|
|
||||||
const { hasLicenseKey } = useLicense();
|
|
||||||
const { isBusiness } = usePlan();
|
|
||||||
return (isCloud() && isBusiness) || !!hasLicenseKey;
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export const INTERNAL_LINK_REGEX =
|
export const INTERNAL_LINK_REGEX =
|
||||||
/^(https?:\/\/)?([^\/]+)?(\/s\/([^\/]+)\/)?p\/([a-zA-Z0-9-]+)\/?$/;
|
/^(https?:\/\/)?([^\/]+)?(\/s\/([^\/]+)\/)?p\/([a-zA-Z0-9-]+)\/?(?:#(.*))?$/;
|
||||||
|
|
||||||
export const FIVE_MINUTES = 5 * 60 * 1000;
|
export const FIVE_MINUTES = 5 * 60 * 1000;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export interface QueryParams {
|
|||||||
query?: string;
|
query?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
includeAllSpaces?: boolean;
|
adminView?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum UserRole {
|
export enum UserRole {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import "@mantine/core/styles.css";
|
import "@mantine/core/styles.css";
|
||||||
import "@mantine/spotlight/styles.css";
|
import "@mantine/spotlight/styles.css";
|
||||||
import "@mantine/notifications/styles.css";
|
import "@mantine/notifications/styles.css";
|
||||||
|
import '@mantine/dates/styles.css';
|
||||||
|
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
import App from "./App.tsx";
|
import App from "./App.tsx";
|
||||||
import { mantineCssResolver, theme } from "@/theme";
|
import { mantineCssResolver, theme } from "@/theme";
|
||||||
@@ -49,7 +51,7 @@ root.render(
|
|||||||
<MantineProvider theme={theme} cssVariablesResolver={mantineCssResolver}>
|
<MantineProvider theme={theme} cssVariablesResolver={mantineCssResolver}>
|
||||||
<ModalsProvider>
|
<ModalsProvider>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<Notifications position="bottom-center" limit={3} />
|
<Notifications position="bottom-center" limit={3} zIndex={10000} />
|
||||||
<HelmetProvider>
|
<HelmetProvider>
|
||||||
<PostHogProvider client={posthog}>
|
<PostHogProvider client={posthog}>
|
||||||
<App />
|
<App />
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const MemoizedHistoryModal = React.memo(HistoryModal);
|
|||||||
export default function Page() {
|
export default function Page() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { pageSlug } = useParams();
|
const { pageSlug } = useParams();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: page,
|
data: page,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
|||||||
+28
-18
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.23.2",
|
"version": "0.24.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -30,6 +30,9 @@
|
|||||||
"test:e2e": "jest --config test/jest-e2e.json"
|
"test:e2e": "jest --config test/jest-e2e.json"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ai-sdk/azure": "^2.0.47",
|
||||||
|
"@ai-sdk/google": "^2.0.18",
|
||||||
|
"@ai-sdk/openai": "^2.0.46",
|
||||||
"@aws-sdk/client-s3": "3.701.0",
|
"@aws-sdk/client-s3": "3.701.0",
|
||||||
"@aws-sdk/lib-storage": "3.701.0",
|
"@aws-sdk/lib-storage": "3.701.0",
|
||||||
"@aws-sdk/s3-request-presigner": "3.701.0",
|
"@aws-sdk/s3-request-presigner": "3.701.0",
|
||||||
@@ -37,49 +40,55 @@
|
|||||||
"@fastify/cookie": "^11.0.2",
|
"@fastify/cookie": "^11.0.2",
|
||||||
"@fastify/multipart": "^9.0.3",
|
"@fastify/multipart": "^9.0.3",
|
||||||
"@fastify/static": "^8.2.0",
|
"@fastify/static": "^8.2.0",
|
||||||
"@nestjs/bullmq": "^11.0.2",
|
"@langchain/textsplitters": "^0.1.0",
|
||||||
"@nestjs/common": "^11.1.3",
|
"@nestjs-labs/nestjs-ioredis": "^11.0.4",
|
||||||
|
"@nestjs/bullmq": "^11.0.4",
|
||||||
|
"@nestjs/common": "^11.1.9",
|
||||||
"@nestjs/config": "^4.0.2",
|
"@nestjs/config": "^4.0.2",
|
||||||
"@nestjs/core": "^11.1.3",
|
"@nestjs/core": "^11.1.9",
|
||||||
"@nestjs/event-emitter": "^3.0.1",
|
"@nestjs/event-emitter": "^3.0.1",
|
||||||
"@nestjs/jwt": "^11.0.0",
|
"@nestjs/jwt": "11.0.0",
|
||||||
"@nestjs/mapped-types": "^2.1.0",
|
"@nestjs/mapped-types": "^2.1.0",
|
||||||
"@nestjs/passport": "^11.0.5",
|
"@nestjs/passport": "^11.0.5",
|
||||||
"@nestjs/platform-fastify": "^11.1.3",
|
"@nestjs/platform-fastify": "^11.1.9",
|
||||||
"@nestjs/platform-socket.io": "^11.1.3",
|
"@nestjs/platform-socket.io": "^11.1.9",
|
||||||
"@nestjs/schedule": "^6.0.0",
|
"@nestjs/schedule": "^6.0.1",
|
||||||
"@nestjs/terminus": "^11.0.0",
|
"@nestjs/terminus": "^11.0.0",
|
||||||
"@nestjs/websockets": "^11.1.3",
|
"@nestjs/websockets": "^11.1.9",
|
||||||
"@node-saml/passport-saml": "^5.1.0",
|
"@node-saml/passport-saml": "^5.1.0",
|
||||||
"@react-email/components": "0.0.28",
|
"@react-email/components": "0.0.28",
|
||||||
"@react-email/render": "1.0.2",
|
"@react-email/render": "1.0.2",
|
||||||
"@socket.io/redis-adapter": "^8.3.0",
|
"@socket.io/redis-adapter": "^8.3.0",
|
||||||
"bcrypt": "^5.1.1",
|
"ai": "^5.0.65",
|
||||||
"bullmq": "^5.53.2",
|
"ai-sdk-ollama": "^0.12.0",
|
||||||
|
"bcrypt": "^6.0.0",
|
||||||
|
"bullmq": "^5.65.0",
|
||||||
"cache-manager": "^6.4.3",
|
"cache-manager": "^6.4.3",
|
||||||
"cheerio": "^1.1.0",
|
"cheerio": "^1.1.0",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.3",
|
||||||
"cookie": "^1.0.2",
|
"cookie": "^1.0.2",
|
||||||
"fs-extra": "^11.3.0",
|
"fs-extra": "^11.3.0",
|
||||||
"happy-dom": "^15.11.6",
|
"happy-dom": "20.0.10",
|
||||||
|
"ioredis": "^5.4.1",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"kysely": "^0.28.2",
|
"kysely": "^0.28.2",
|
||||||
"kysely-migration-cli": "^0.4.2",
|
"kysely-migration-cli": "^0.4.2",
|
||||||
"ldapts": "^7.4.0",
|
"ldapts": "^7.4.0",
|
||||||
"mammoth": "^1.10.0",
|
"mammoth": "^1.11.0",
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
"nanoid": "3.3.11",
|
"nanoid": "3.3.11",
|
||||||
"nestjs-kysely": "^1.2.0",
|
"nestjs-kysely": "^1.2.0",
|
||||||
"nodemailer": "^7.0.3",
|
"nodemailer": "^7.0.11",
|
||||||
"openid-client": "^5.7.1",
|
"openid-client": "^5.7.1",
|
||||||
"otpauth": "^9.4.0",
|
"otpauth": "^9.4.0",
|
||||||
"p-limit": "^6.2.0",
|
"p-limit": "^6.2.0",
|
||||||
"passport-google-oauth20": "^2.0.0",
|
"passport-google-oauth20": "^2.0.0",
|
||||||
"passport-jwt": "^4.0.1",
|
"passport-jwt": "^4.0.1",
|
||||||
"pdfjs-dist": "^5.4.54",
|
"pdfjs-dist": "^5.4.394",
|
||||||
"pg": "^8.16.0",
|
"pg": "^8.16.3",
|
||||||
"pg-tsquery": "^8.4.2",
|
"pg-tsquery": "^8.4.2",
|
||||||
|
"pgvector": "^0.2.1",
|
||||||
"postmark": "^4.0.5",
|
"postmark": "^4.0.5",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
@@ -89,7 +98,8 @@
|
|||||||
"socket.io": "^4.8.1",
|
"socket.io": "^4.8.1",
|
||||||
"stripe": "^17.5.0",
|
"stripe": "^17.5.0",
|
||||||
"tmp-promise": "^3.0.3",
|
"tmp-promise": "^3.0.3",
|
||||||
"ws": "^8.18.2",
|
"typesense": "^2.1.0",
|
||||||
|
"ws": "^8.18.3",
|
||||||
"yauzl": "^3.2.0"
|
"yauzl": "^3.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import { ExportModule } from './integrations/export/export.module';
|
|||||||
import { ImportModule } from './integrations/import/import.module';
|
import { ImportModule } from './integrations/import/import.module';
|
||||||
import { SecurityModule } from './integrations/security/security.module';
|
import { SecurityModule } from './integrations/security/security.module';
|
||||||
import { TelemetryModule } from './integrations/telemetry/telemetry.module';
|
import { TelemetryModule } from './integrations/telemetry/telemetry.module';
|
||||||
|
import { RedisModule } from '@nestjs-labs/nestjs-ioredis';
|
||||||
|
import { RedisConfigService } from './integrations/redis/redis-config.service';
|
||||||
|
|
||||||
const enterpriseModules = [];
|
const enterpriseModules = [];
|
||||||
try {
|
try {
|
||||||
@@ -36,6 +38,9 @@ try {
|
|||||||
CoreModule,
|
CoreModule,
|
||||||
DatabaseModule,
|
DatabaseModule,
|
||||||
EnvironmentModule,
|
EnvironmentModule,
|
||||||
|
RedisModule.forRootAsync({
|
||||||
|
useClass: RedisConfigService,
|
||||||
|
}),
|
||||||
CollaborationModule,
|
CollaborationModule,
|
||||||
WsModule,
|
WsModule,
|
||||||
QueueModule,
|
QueueModule,
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import { TaskItem } from '@tiptap/extension-task-item';
|
|||||||
import { Underline } from '@tiptap/extension-underline';
|
import { Underline } from '@tiptap/extension-underline';
|
||||||
import { Superscript } from '@tiptap/extension-superscript';
|
import { Superscript } from '@tiptap/extension-superscript';
|
||||||
import SubScript from '@tiptap/extension-subscript';
|
import SubScript from '@tiptap/extension-subscript';
|
||||||
import { Highlight } from '@tiptap/extension-highlight';
|
|
||||||
import { Typography } from '@tiptap/extension-typography';
|
import { Typography } from '@tiptap/extension-typography';
|
||||||
import { TextStyle } from '@tiptap/extension-text-style';
|
import { TextStyle } from '@tiptap/extension-text-style';
|
||||||
import { Color } from '@tiptap/extension-color';
|
import { Color } from '@tiptap/extension-color';
|
||||||
import { Youtube } from '@tiptap/extension-youtube';
|
import { Youtube } from '@tiptap/extension-youtube';
|
||||||
import {
|
import {
|
||||||
|
Heading,
|
||||||
Callout,
|
Callout,
|
||||||
Comment,
|
Comment,
|
||||||
CustomCodeBlock,
|
CustomCodeBlock,
|
||||||
@@ -33,18 +33,26 @@ import {
|
|||||||
Embed,
|
Embed,
|
||||||
Mention,
|
Mention,
|
||||||
Subpages,
|
Subpages,
|
||||||
|
Highlight,
|
||||||
|
UniqueID,
|
||||||
|
ColumnsExtension,
|
||||||
|
addUniqueIdsToDoc,
|
||||||
} from '@docmost/editor-ext';
|
} from '@docmost/editor-ext';
|
||||||
import { generateText, getSchema, JSONContent } from '@tiptap/core';
|
import { generateText, getSchema, JSONContent } from '@tiptap/core';
|
||||||
import { generateHTML } from '../common/helpers/prosemirror/html';
|
import { generateHTML, generateJSON } from '../common/helpers/prosemirror/html';
|
||||||
// @tiptap/html library works best for generating prosemirror json state but not HTML
|
// @tiptap/html library works best for generating prosemirror json state but not HTML
|
||||||
// see: https://github.com/ueberdosis/tiptap/issues/5352
|
// see: https://github.com/ueberdosis/tiptap/issues/5352
|
||||||
// see:https://github.com/ueberdosis/tiptap/issues/4089
|
// see:https://github.com/ueberdosis/tiptap/issues/4089
|
||||||
import { generateJSON } from '@tiptap/html';
|
|
||||||
import { Node } from '@tiptap/pm/model';
|
import { Node } from '@tiptap/pm/model';
|
||||||
|
|
||||||
export const tiptapExtensions = [
|
export const tiptapExtensions = [
|
||||||
StarterKit.configure({
|
StarterKit.configure({
|
||||||
codeBlock: false,
|
codeBlock: false,
|
||||||
|
heading: false,
|
||||||
|
}),
|
||||||
|
Heading,
|
||||||
|
UniqueID.configure({
|
||||||
|
types: ['heading', 'paragraph'],
|
||||||
}),
|
}),
|
||||||
Comment,
|
Comment,
|
||||||
TextAlign.configure({ types: ['heading', 'paragraph'] }),
|
TextAlign.configure({ types: ['heading', 'paragraph'] }),
|
||||||
@@ -81,6 +89,7 @@ export const tiptapExtensions = [
|
|||||||
Embed,
|
Embed,
|
||||||
Mention,
|
Mention,
|
||||||
Subpages,
|
Subpages,
|
||||||
|
ColumnsExtension
|
||||||
] as any;
|
] as any;
|
||||||
|
|
||||||
export function jsonToHtml(tiptapJson: any) {
|
export function jsonToHtml(tiptapJson: any) {
|
||||||
@@ -88,7 +97,14 @@ export function jsonToHtml(tiptapJson: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function htmlToJson(html: string) {
|
export function htmlToJson(html: string) {
|
||||||
return generateJSON(html, tiptapExtensions);
|
const pmJson = generateJSON(html, tiptapExtensions);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return addUniqueIdsToDoc(pmJson, tiptapExtensions);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('failed to add unique ids to doc', error);
|
||||||
|
return pmJson;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function jsonToText(tiptapJson: JSONContent) {
|
export function jsonToText(tiptapJson: JSONContent) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { UserRepo } from '@docmost/db/repos/user/user.repo';
|
|||||||
import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
||||||
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
||||||
import { findHighestUserSpaceRole } from '@docmost/db/repos/space/utils';
|
import { findHighestUserSpaceRole } from '@docmost/db/repos/space/utils';
|
||||||
import { SpaceRole, UserRole } from '../../common/helpers/types/permission';
|
import { SpaceRole } from '../../common/helpers/types/permission';
|
||||||
import { getPageId } from '../collaboration.util';
|
import { getPageId } from '../collaboration.util';
|
||||||
import { JwtCollabPayload, JwtType } from '../../core/auth/dto/jwt-payload';
|
import { JwtCollabPayload, JwtType } from '../../core/auth/dto/jwt-payload';
|
||||||
|
|
||||||
@@ -63,10 +63,7 @@ export class AuthenticationExtension implements Extension {
|
|||||||
|
|
||||||
const userSpaceRole = findHighestUserSpaceRole(userSpaceRoles);
|
const userSpaceRole = findHighestUserSpaceRole(userSpaceRoles);
|
||||||
|
|
||||||
// if role not found but user is a workspace owner, grant them readonly permission
|
if (!userSpaceRole) {
|
||||||
if (!userSpaceRole && user.role === UserRole.OWNER) {
|
|
||||||
data.connection.readOnly = true;
|
|
||||||
} else if (!userSpaceRole) {
|
|
||||||
this.logger.warn(`User not authorized to access page: ${pageId}`);
|
this.logger.warn(`User not authorized to access page: ${pageId}`);
|
||||||
throw new UnauthorizedException();
|
throw new UnauthorizedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export class PersistenceExtension implements Extension {
|
|||||||
@InjectKysely() private readonly db: KyselyDB,
|
@InjectKysely() private readonly db: KyselyDB,
|
||||||
private eventEmitter: EventEmitter2,
|
private eventEmitter: EventEmitter2,
|
||||||
@InjectQueue(QueueName.GENERAL_QUEUE) private generalQueue: Queue,
|
@InjectQueue(QueueName.GENERAL_QUEUE) private generalQueue: Queue,
|
||||||
|
@InjectQueue(QueueName.AI_QUEUE) private aiQueue: Queue,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async onLoadDocument(data: onLoadDocumentPayload) {
|
async onLoadDocument(data: onLoadDocumentPayload) {
|
||||||
@@ -168,6 +169,11 @@ export class PersistenceExtension implements Extension {
|
|||||||
workspaceId: page.workspaceId,
|
workspaceId: page.workspaceId,
|
||||||
mentions: pageMentions,
|
mentions: pageMentions,
|
||||||
} as IPageBacklinkJob);
|
} as IPageBacklinkJob);
|
||||||
|
|
||||||
|
await this.aiQueue.add(QueueJob.PAGE_CONTENT_UPDATED, {
|
||||||
|
pageIds: [pageId],
|
||||||
|
workspaceId: page.workspaceId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
export enum EventName {
|
export enum EventName {
|
||||||
COLLAB_PAGE_UPDATED = 'collab.page.updated',
|
COLLAB_PAGE_UPDATED = 'collab.page.updated',
|
||||||
}
|
PAGE_CREATED = 'page.created',
|
||||||
|
PAGE_UPDATED = 'page.updated',
|
||||||
|
PAGE_CONTENT_UPDATED = 'page-content-updated',
|
||||||
|
PAGE_MOVED_TO_SPACE = 'page-moved-to-space',
|
||||||
|
PAGE_DELETED = 'page.deleted',
|
||||||
|
PAGE_SOFT_DELETED = 'page.soft_deleted',
|
||||||
|
PAGE_RESTORED = 'page.restored',
|
||||||
|
|
||||||
|
SPACE_CREATED = 'space.created',
|
||||||
|
SPACE_UPDATED = 'space.updated',
|
||||||
|
SPACE_DELETED = 'space.deleted',
|
||||||
|
|
||||||
|
WORKSPACE_CREATED = 'workspace.created',
|
||||||
|
WORKSPACE_UPDATED = 'workspace.updated',
|
||||||
|
WORKSPACE_DELETED = 'workspace.deleted',
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,21 +1,29 @@
|
|||||||
import { Extensions, getSchema, JSONContent } from '@tiptap/core';
|
import { type Extensions, type JSONContent, getSchema } from '@tiptap/core';
|
||||||
import { DOMSerializer, Node } from '@tiptap/pm/model';
|
import { Node } from '@tiptap/pm/model';
|
||||||
import { Window } from 'happy-dom';
|
import { getHTMLFromFragment } from './getHTMLFromFragment';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function generates HTML from a ProseMirror JSON content object.
|
||||||
|
*
|
||||||
|
* @remarks **Important**: This function requires `happy-dom` to be installed in your project.
|
||||||
|
* @param doc - The ProseMirror JSON content object.
|
||||||
|
* @param extensions - The Tiptap extensions used to build the schema.
|
||||||
|
* @returns The generated HTML string.
|
||||||
|
* @example
|
||||||
|
* ```js
|
||||||
|
* const html = generateHTML(doc, extensions)
|
||||||
|
* console.log(html)
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
export function generateHTML(doc: JSONContent, extensions: Extensions): string {
|
export function generateHTML(doc: JSONContent, extensions: Extensions): string {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
throw new Error(
|
||||||
|
'generateHTML can only be used in a Node environment\nIf you want to use this in a browser environment, use the `@tiptap/html` import instead.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const schema = getSchema(extensions);
|
const schema = getSchema(extensions);
|
||||||
const contentNode = Node.fromJSON(schema, doc);
|
const contentNode = Node.fromJSON(schema, doc);
|
||||||
|
|
||||||
const window = new Window();
|
return getHTMLFromFragment(contentNode, schema);
|
||||||
|
|
||||||
const fragment = DOMSerializer.fromSchema(schema).serializeFragment(
|
|
||||||
contentNode.content,
|
|
||||||
{
|
|
||||||
document: window.document as unknown as Document,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const serializer = new window.XMLSerializer();
|
|
||||||
// @ts-ignore
|
|
||||||
return serializer.serializeToString(fragment as unknown as Node);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,55 @@
|
|||||||
import { Extensions, getSchema } from '@tiptap/core';
|
import type { Extensions } from '@tiptap/core';
|
||||||
import { DOMParser, ParseOptions } from '@tiptap/pm/model';
|
import { getSchema } from '@tiptap/core';
|
||||||
|
import { type ParseOptions, DOMParser as PMDOMParser } from '@tiptap/pm/model';
|
||||||
import { Window } from 'happy-dom';
|
import { Window } from 'happy-dom';
|
||||||
|
|
||||||
// this function does not work as intended
|
/**
|
||||||
// it has issues with closing tags
|
* Generates a JSON object from the given HTML string and converts it into a Prosemirror node with content.
|
||||||
|
* @remarks **Important**: This function requires `happy-dom` to be installed in your project.
|
||||||
|
* @param {string} html - The HTML string to be converted into a Prosemirror node.
|
||||||
|
* @param {Extensions} extensions - The extensions to be used for generating the schema.
|
||||||
|
* @param {ParseOptions} options - The options to be supplied to the parser.
|
||||||
|
* @returns {Promise<Record<string, any>>} - A promise with the generated JSON object.
|
||||||
|
* @example
|
||||||
|
* const html = '<p>Hello, world!</p>'
|
||||||
|
* const extensions = [...]
|
||||||
|
* const json = generateJSON(html, extensions)
|
||||||
|
* console.log(json) // { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Hello, world!' }] }] }
|
||||||
|
*/
|
||||||
export function generateJSON(
|
export function generateJSON(
|
||||||
html: string,
|
html: string,
|
||||||
extensions: Extensions,
|
extensions: Extensions,
|
||||||
options?: ParseOptions,
|
options?: ParseOptions,
|
||||||
): Record<string, any> {
|
): Record<string, any> {
|
||||||
const schema = getSchema(extensions);
|
if (typeof window !== 'undefined') {
|
||||||
|
throw new Error(
|
||||||
|
'generateJSON can only be used in a Node environment\nIf you want to use this in a browser environment, use the `@tiptap/html` import instead.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const window = new Window();
|
const localWindow = new Window();
|
||||||
const document = window.document;
|
const localDOMParser = new localWindow.DOMParser();
|
||||||
document.body.innerHTML = html;
|
let result: Record<string, any>;
|
||||||
|
|
||||||
return DOMParser.fromSchema(schema)
|
try {
|
||||||
.parse(document as never, options)
|
const schema = getSchema(extensions);
|
||||||
.toJSON();
|
let doc: ReturnType<typeof localDOMParser.parseFromString> | null = null;
|
||||||
|
|
||||||
|
const htmlString = `<!DOCTYPE html><html><body>${html}</body></html>`;
|
||||||
|
doc = localDOMParser.parseFromString(htmlString, 'text/html');
|
||||||
|
|
||||||
|
if (!doc) {
|
||||||
|
throw new Error('Failed to parse HTML string');
|
||||||
|
}
|
||||||
|
|
||||||
|
result = PMDOMParser.fromSchema(schema)
|
||||||
|
.parse(doc.body as unknown as Node, options)
|
||||||
|
.toJSON();
|
||||||
|
} finally {
|
||||||
|
// clean up happy-dom to avoid memory leaks
|
||||||
|
localWindow.happyDOM.abort();
|
||||||
|
localWindow.happyDOM.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import type { Node, Schema } from '@tiptap/pm/model';
|
||||||
|
import { DOMSerializer } from '@tiptap/pm/model';
|
||||||
|
import { Window } from 'happy-dom';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the HTML string representation of a given document node.
|
||||||
|
*
|
||||||
|
* @remarks **Important**: This function requires `happy-dom` to be installed in your project.
|
||||||
|
* @param doc - The document node to serialize.
|
||||||
|
* @param schema - The Prosemirror schema to use for serialization.
|
||||||
|
* @returns A promise containing the HTML string representation of the document fragment.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const html = getHTMLFromFragment(doc, schema)
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export function getHTMLFromFragment(
|
||||||
|
doc: Node,
|
||||||
|
schema: Schema,
|
||||||
|
options?: { document?: Document },
|
||||||
|
): string {
|
||||||
|
if (options?.document) {
|
||||||
|
const wrap = options.document.createElement('div');
|
||||||
|
|
||||||
|
DOMSerializer.fromSchema(schema).serializeFragment(
|
||||||
|
doc.content,
|
||||||
|
{ document: options.document },
|
||||||
|
wrap,
|
||||||
|
);
|
||||||
|
return wrap.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
const localWindow = new Window();
|
||||||
|
let result: string;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const fragment = DOMSerializer.fromSchema(schema).serializeFragment(
|
||||||
|
doc.content,
|
||||||
|
{
|
||||||
|
document: localWindow.document as unknown as Document,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const serializer = new localWindow.XMLSerializer();
|
||||||
|
result = serializer.serializeToString(fragment as any);
|
||||||
|
} finally {
|
||||||
|
// clean up happy-dom to avoid memory leaks
|
||||||
|
localWindow.happyDOM.abort();
|
||||||
|
localWindow.happyDOM.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// MIT - https://github.com/typestack/class-validator/pull/2626
|
||||||
|
import isISO6391Validator from 'validator/lib/isISO6391';
|
||||||
|
import { buildMessage, ValidateBy, ValidationOptions } from 'class-validator';
|
||||||
|
|
||||||
|
export const IS_ISO6391 = 'isISO6391';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the string is a valid [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) officially assigned language code.
|
||||||
|
*/
|
||||||
|
export function isISO6391(value: unknown): boolean {
|
||||||
|
return typeof value === 'string' && isISO6391Validator(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the string is a valid [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) officially assigned language code.
|
||||||
|
*/
|
||||||
|
export function IsISO6391(
|
||||||
|
validationOptions?: ValidationOptions,
|
||||||
|
): PropertyDecorator {
|
||||||
|
return ValidateBy(
|
||||||
|
{
|
||||||
|
name: IS_ISO6391,
|
||||||
|
validator: {
|
||||||
|
validate: (value, args): boolean => isISO6391(value),
|
||||||
|
defaultMessage: buildMessage(
|
||||||
|
(eachPrefix) =>
|
||||||
|
eachPrefix + '$property must be a valid ISO 639-1 language code',
|
||||||
|
validationOptions,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
validationOptions,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ export enum JwtType {
|
|||||||
EXCHANGE = 'exchange',
|
EXCHANGE = 'exchange',
|
||||||
ATTACHMENT = 'attachment',
|
ATTACHMENT = 'attachment',
|
||||||
MFA_TOKEN = 'mfa_token',
|
MFA_TOKEN = 'mfa_token',
|
||||||
|
API_KEY = 'api_key',
|
||||||
}
|
}
|
||||||
export type JwtPayload = {
|
export type JwtPayload = {
|
||||||
sub: string;
|
sub: string;
|
||||||
@@ -36,3 +37,10 @@ export interface JwtMfaTokenPayload {
|
|||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
type: 'mfa_token';
|
type: 'mfa_token';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type JwtApiKeyPayload = {
|
||||||
|
sub: string;
|
||||||
|
workspaceId: string;
|
||||||
|
apiKeyId: string;
|
||||||
|
type: 'api_key';
|
||||||
|
};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
||||||
import {
|
import {
|
||||||
|
JwtApiKeyPayload,
|
||||||
JwtAttachmentPayload,
|
JwtAttachmentPayload,
|
||||||
JwtCollabPayload,
|
JwtCollabPayload,
|
||||||
JwtExchangePayload,
|
JwtExchangePayload,
|
||||||
@@ -77,10 +78,7 @@ export class TokenService {
|
|||||||
return this.jwtService.sign(payload, { expiresIn: '1h' });
|
return this.jwtService.sign(payload, { expiresIn: '1h' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateMfaToken(
|
async generateMfaToken(user: User, workspaceId: string): Promise<string> {
|
||||||
user: User,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<string> {
|
|
||||||
if (user.deactivatedAt || user.deletedAt) {
|
if (user.deactivatedAt || user.deletedAt) {
|
||||||
throw new ForbiddenException();
|
throw new ForbiddenException();
|
||||||
}
|
}
|
||||||
@@ -93,6 +91,27 @@ export class TokenService {
|
|||||||
return this.jwtService.sign(payload, { expiresIn: '5m' });
|
return this.jwtService.sign(payload, { expiresIn: '5m' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async generateApiToken(opts: {
|
||||||
|
apiKeyId: string;
|
||||||
|
user: User;
|
||||||
|
workspaceId: string;
|
||||||
|
expiresIn?: string | number;
|
||||||
|
}): Promise<string> {
|
||||||
|
const { apiKeyId, user, workspaceId, expiresIn } = opts;
|
||||||
|
if (user.deactivatedAt || user.deletedAt) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload: JwtApiKeyPayload = {
|
||||||
|
sub: user.id,
|
||||||
|
apiKeyId: apiKeyId,
|
||||||
|
workspaceId,
|
||||||
|
type: JwtType.API_KEY,
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.jwtService.sign(payload, expiresIn ? { expiresIn } : {});
|
||||||
|
}
|
||||||
|
|
||||||
async verifyJwt(token: string, tokenType: string) {
|
async verifyJwt(token: string, tokenType: string) {
|
||||||
const payload = await this.jwtService.verifyAsync(token, {
|
const payload = await this.jwtService.verifyAsync(token, {
|
||||||
secret: this.environmentService.getAppSecret(),
|
secret: this.environmentService.getAppSecret(),
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user