mirror of
https://github.com/docmost/docmost.git
synced 2026-08-28 01:07:08 +08:00
Compare commits
54
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f0ebdd0bf | ||
|
|
8ba4792e25 | ||
|
|
06d7e24676 | ||
|
|
3219bd7160 | ||
|
|
8b73343b6c | ||
|
|
809f6eb3be | ||
|
|
5d8e9fde8b | ||
|
|
dacaaf5629 | ||
|
|
1dd7d79453 | ||
|
|
ecc6b974b5 | ||
|
|
defc1f4ba5 | ||
|
|
50e81ade57 | ||
|
|
228fe14cd8 | ||
|
|
2fe13daa09 | ||
|
|
44086cbb01 | ||
|
|
a81e5c42ec | ||
|
|
65af1cc2a4 | ||
|
|
231f0deeb0 | ||
|
|
b9d8612ecd | ||
|
|
e76c138e4c | ||
|
|
e146cfd075 | ||
|
|
efcca2e4fd | ||
|
|
3b57ce7c89 | ||
|
|
86687d2bf2 | ||
|
|
15f893184e | ||
|
|
dc3f7b0be4 | ||
|
|
88e057c76e | ||
|
|
89bf9f3078 | ||
|
|
b0f7c11fb3 | ||
|
|
feb5167771 | ||
|
|
97a1248818 | ||
|
|
b7d7ad4521 | ||
|
|
79df1229cb | ||
|
|
812d0765b5 | ||
|
|
234bd13453 | ||
|
|
affd2e6740 | ||
|
|
37e652ade5 | ||
|
|
38a847f305 | ||
|
|
7c80688698 | ||
|
|
0320e07bb1 | ||
|
|
1982a0ed1e | ||
|
|
fcb2b08cf3 | ||
|
|
e5ff58a73a | ||
|
|
d3bb105366 | ||
|
|
bbb1b5eb26 | ||
|
|
3e66aff1e2 | ||
|
|
89442f5154 | ||
|
|
12ef426541 | ||
|
|
93ff3f43b7 | ||
|
|
cbf03fc956 | ||
|
|
68309247b5 | ||
|
|
474ff6c629 | ||
|
|
c5e9be6b36 | ||
|
|
00e8c53852 |
@@ -18,15 +18,6 @@ RUN apt-get update \
|
|||||||
&& apt-get install -y --no-install-recommends curl bash \
|
&& apt-get install -y --no-install-recommends curl bash \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# drop npm and corepack
|
|
||||||
RUN rm -rf /usr/local/lib/node_modules/npm \
|
|
||||||
&& rm -rf /usr/local/lib/node_modules/corepack \
|
|
||||||
&& rm -rf /usr/local/bin/npm \
|
|
||||||
&& rm -rf /usr/local/bin/npx \
|
|
||||||
&& rm -rf /usr/local/bin/corepack \
|
|
||||||
&& rm -rf /root/.npm \
|
|
||||||
&& rm -rf /root/.node-gyp
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy apps
|
# Copy apps
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
"mantine-form-zod-resolver": "1.3.0",
|
"mantine-form-zod-resolver": "1.3.0",
|
||||||
"mermaid": "11.16.1",
|
"mermaid": "11.16.1",
|
||||||
"mitt": "3.0.1",
|
"mitt": "3.0.1",
|
||||||
"nanoid": "3.3.18",
|
"nanoid": "3.3.17",
|
||||||
"posthog-js": "1.391.2",
|
"posthog-js": "1.391.2",
|
||||||
"react": "19.2.7",
|
"react": "19.2.7",
|
||||||
"react-clear-modal": "^2.0.18",
|
"react-clear-modal": "^2.0.18",
|
||||||
@@ -64,7 +64,6 @@
|
|||||||
"react-router-dom": "7.18.2",
|
"react-router-dom": "7.18.2",
|
||||||
"semver": "7.7.4",
|
"semver": "7.7.4",
|
||||||
"socket.io-client": "4.8.3",
|
"socket.io-client": "4.8.3",
|
||||||
"yet-another-react-lightbox": "^3.32.2",
|
|
||||||
"zod": "4.3.6"
|
"zod": "4.3.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "Upgrade Ihres Plans",
|
"Upgrade your plan": "Upgrade Ihres Plans",
|
||||||
"Available with a paid license": "Verfügbar mit einer kostenpflichtigen Lizenz",
|
"Available with a paid license": "Verfügbar mit einer kostenpflichtigen Lizenz",
|
||||||
"Upgrade your license tier.": "Stufen Sie Ihre Lizenz hoch.",
|
"Upgrade your license tier.": "Stufen Sie Ihre Lizenz hoch.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "KI ist in den kostenpflichtigen Docmost-Editionen verfügbar. Kontaktieren Sie sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "KI ist nur in der Docmost Enterprise-Edition verfügbar. Kontaktieren Sie sales@docmost.com.",
|
||||||
"AI & MCP": "KI & MCP",
|
"AI & MCP": "KI & MCP",
|
||||||
"AI": "KI",
|
"AI": "KI",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"Can view": "Can view",
|
"Can view": "Can view",
|
||||||
"Can view pages in space but not edit.": "Can view pages in space but not edit.",
|
"Can view pages in space but not edit.": "Can view pages in space but not edit.",
|
||||||
"Cancel": "Cancel",
|
"Cancel": "Cancel",
|
||||||
|
"Cancelled": "Cancelled",
|
||||||
"Change email": "Change email",
|
"Change email": "Change email",
|
||||||
"Change password": "Change password",
|
"Change password": "Change password",
|
||||||
"Change photo": "Change photo",
|
"Change photo": "Change photo",
|
||||||
@@ -29,7 +30,9 @@
|
|||||||
"Choose your preferred color scheme.": "Choose your preferred color scheme.",
|
"Choose your preferred color scheme.": "Choose your preferred color scheme.",
|
||||||
"Choose your preferred interface language.": "Choose your preferred interface language.",
|
"Choose your preferred interface language.": "Choose your preferred interface language.",
|
||||||
"Choose your preferred page width.": "Choose your preferred page width.",
|
"Choose your preferred page width.": "Choose your preferred page width.",
|
||||||
|
"Completed": "Completed",
|
||||||
"Confirm": "Confirm",
|
"Confirm": "Confirm",
|
||||||
|
"Confluence site": "Confluence site",
|
||||||
"Copy as Markdown": "Copy as Markdown",
|
"Copy as Markdown": "Copy as Markdown",
|
||||||
"Copy link": "Copy link",
|
"Copy link": "Copy link",
|
||||||
"Create": "Create",
|
"Create": "Create",
|
||||||
@@ -57,6 +60,10 @@
|
|||||||
"e.g Space for product team": "e.g Space for product team",
|
"e.g Space for product team": "e.g Space for product team",
|
||||||
"e.g Space for sales team to collaborate": "e.g Space for sales team to collaborate",
|
"e.g Space for sales team to collaborate": "e.g Space for sales team to collaborate",
|
||||||
"Edit": "Edit",
|
"Edit": "Edit",
|
||||||
|
"Everyone with access to this space": "Everyone with access to this space",
|
||||||
|
"Failed": "Failed",
|
||||||
|
"Import details": "Import details",
|
||||||
|
"Permissions": "Permissions",
|
||||||
"Read": "Read",
|
"Read": "Read",
|
||||||
"Edit group": "Edit group",
|
"Edit group": "Edit group",
|
||||||
"Email": "Email",
|
"Email": "Email",
|
||||||
@@ -76,6 +83,7 @@
|
|||||||
"Failed to restore page": "Failed to restore page",
|
"Failed to restore page": "Failed to restore page",
|
||||||
"Failed to fetch recent pages": "Failed to fetch recent pages",
|
"Failed to fetch recent pages": "Failed to fetch recent pages",
|
||||||
"Failed to import pages": "Failed to import pages",
|
"Failed to import pages": "Failed to import pages",
|
||||||
|
"Failed to load comments. An error occurred.": "Failed to load comments. An error occurred.",
|
||||||
"Failed to load page. An error occurred.": "Failed to load page. An error occurred.",
|
"Failed to load page. An error occurred.": "Failed to load page. An error occurred.",
|
||||||
"Failed to update data": "Failed to update data",
|
"Failed to update data": "Failed to update data",
|
||||||
"Failed to create base": "Failed to create base",
|
"Failed to create base": "Failed to create base",
|
||||||
@@ -150,6 +158,9 @@
|
|||||||
"page": "page",
|
"page": "page",
|
||||||
"Page deleted successfully": "Page deleted successfully",
|
"Page deleted successfully": "Page deleted successfully",
|
||||||
"Page history": "Page history",
|
"Page history": "Page history",
|
||||||
|
"Restricted pages": "Restricted pages",
|
||||||
|
"Restrictions": "Restrictions",
|
||||||
|
"Running": "Running",
|
||||||
"Select version": "Select version",
|
"Select version": "Select version",
|
||||||
"Highlight changes": "Highlight changes",
|
"Highlight changes": "Highlight changes",
|
||||||
"Page import is in progress. Please do not close this tab.": "Page import is in progress. Please do not close this tab.",
|
"Page import is in progress. Please do not close this tab.": "Page import is in progress. Please do not close this tab.",
|
||||||
@@ -186,6 +197,7 @@
|
|||||||
"Setup workspace": "Setup workspace",
|
"Setup workspace": "Setup workspace",
|
||||||
"Sign In": "Sign In",
|
"Sign In": "Sign In",
|
||||||
"Sign Up": "Sign Up",
|
"Sign Up": "Sign Up",
|
||||||
|
"Site": "Site",
|
||||||
"Slug": "Slug",
|
"Slug": "Slug",
|
||||||
"Space": "Space",
|
"Space": "Space",
|
||||||
"Space description": "Space description",
|
"Space description": "Space description",
|
||||||
@@ -194,10 +206,13 @@
|
|||||||
"Space settings": "Space settings",
|
"Space settings": "Space settings",
|
||||||
"Space slug": "Space slug",
|
"Space slug": "Space slug",
|
||||||
"Spaces": "Spaces",
|
"Spaces": "Spaces",
|
||||||
|
"spaces": "spaces",
|
||||||
"Spaces you belong to": "Spaces you belong to",
|
"Spaces you belong to": "Spaces you belong to",
|
||||||
"No space found": "No space found",
|
"No space found": "No space found",
|
||||||
"Search for spaces": "Search for spaces",
|
"Search for spaces": "Search for spaces",
|
||||||
"Start typing to search...": "Start typing to search...",
|
"Start typing to search...": "Start typing to search...",
|
||||||
|
"Started at": "Started at",
|
||||||
|
"Started by": "Started by",
|
||||||
"Status": "Status",
|
"Status": "Status",
|
||||||
"Successfully imported": "Successfully imported",
|
"Successfully imported": "Successfully imported",
|
||||||
"Successfully restored": "Successfully restored",
|
"Successfully restored": "Successfully restored",
|
||||||
@@ -211,6 +226,8 @@
|
|||||||
"Untitled": "Untitled",
|
"Untitled": "Untitled",
|
||||||
"Updated successfully": "Updated successfully",
|
"Updated successfully": "Updated successfully",
|
||||||
"User": "User",
|
"User": "User",
|
||||||
|
"Users": "Users",
|
||||||
|
"users": "users",
|
||||||
"Workspace": "Workspace",
|
"Workspace": "Workspace",
|
||||||
"Workspace Name": "Workspace Name",
|
"Workspace Name": "Workspace Name",
|
||||||
"Workspace settings": "Workspace settings",
|
"Workspace settings": "Workspace settings",
|
||||||
@@ -294,7 +311,6 @@
|
|||||||
"Export space": "Export space",
|
"Export space": "Export space",
|
||||||
"Export {{type}}": "Export {{type}}",
|
"Export {{type}}": "Export {{type}}",
|
||||||
"File exceeds the {{limit}} attachment limit": "File exceeds the {{limit}} attachment limit",
|
"File exceeds the {{limit}} attachment limit": "File exceeds the {{limit}} attachment limit",
|
||||||
"Media": "Media",
|
|
||||||
"Align left": "Align left",
|
"Align left": "Align left",
|
||||||
"Align right": "Align right",
|
"Align right": "Align right",
|
||||||
"Align center": "Align center",
|
"Align center": "Align center",
|
||||||
@@ -699,7 +715,7 @@
|
|||||||
"Upgrade your plan": "Upgrade your plan",
|
"Upgrade your plan": "Upgrade your plan",
|
||||||
"Available with a paid license": "Available with a paid license",
|
"Available with a paid license": "Available with a paid license",
|
||||||
"Upgrade your license tier.": "Upgrade your license tier.",
|
"Upgrade your license tier.": "Upgrade your license tier.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "AI is available in the Docmost paid editions. Contact sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.",
|
||||||
"AI & MCP": "AI & MCP",
|
"AI & MCP": "AI & MCP",
|
||||||
"AI": "AI",
|
"AI": "AI",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
@@ -1303,13 +1319,5 @@
|
|||||||
"Error loading attachments.": "Error loading attachments.",
|
"Error loading attachments.": "Error loading attachments.",
|
||||||
"No attachments on this page yet.": "No attachments on this page yet.",
|
"No attachments on this page yet.": "No attachments on this page yet.",
|
||||||
"Uploaded by {{name}}": "Uploaded by {{name}}",
|
"Uploaded by {{name}}": "Uploaded by {{name}}",
|
||||||
"Download {{name}}": "Download {{name}}",
|
"Download {{name}}": "Download {{name}}"
|
||||||
"Workspace knowledge only": "Workspace knowledge only",
|
|
||||||
"Restrict AI Chat to answering from your workspace pages and uploaded files only. It will not use outside knowledge.": "Restrict AI Chat to answering from your workspace pages and uploaded files only. It will not use outside knowledge.",
|
|
||||||
"Toggle workspace knowledge only": "Toggle workspace knowledge only",
|
|
||||||
"Read-only mode": "Read-only mode",
|
|
||||||
"AI Chat can search and read workspace content, but cannot create or edit pages.": "AI Chat can search and read workspace content, but cannot create or edit pages.",
|
|
||||||
"Toggle AI Chat read-only mode": "Toggle AI Chat read-only mode",
|
|
||||||
"Title only": "Title only",
|
|
||||||
"you": "you"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "Mejora tu plan",
|
"Upgrade your plan": "Mejora tu plan",
|
||||||
"Available with a paid license": "Disponible con una licencia de pago",
|
"Available with a paid license": "Disponible con una licencia de pago",
|
||||||
"Upgrade your license tier.": "Mejora el nivel de tu licencia.",
|
"Upgrade your license tier.": "Mejora el nivel de tu licencia.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "La IA está disponible en las ediciones de pago de Docmost. Contacte con sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "La IA solo está disponible en la edición empresarial de Docmost. Contacte con sales@docmost.com.",
|
||||||
"AI & MCP": "IA y MCP",
|
"AI & MCP": "IA y MCP",
|
||||||
"AI": "IA",
|
"AI": "IA",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "Mettez à niveau votre forfait",
|
"Upgrade your plan": "Mettez à niveau votre forfait",
|
||||||
"Available with a paid license": "Disponible avec une licence payante",
|
"Available with a paid license": "Disponible avec une licence payante",
|
||||||
"Upgrade your license tier.": "Mettez à niveau votre niveau de licence.",
|
"Upgrade your license tier.": "Mettez à niveau votre niveau de licence.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "L'IA est disponible dans les éditions payantes de Docmost. Contactez sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "L'IA n'est disponible que dans l'édition Entreprise de Docmost. Contactez sales@docmost.com.",
|
||||||
"AI & MCP": "IA & MCP",
|
"AI & MCP": "IA & MCP",
|
||||||
"AI": "IA",
|
"AI": "IA",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "Aggiorna il tuo piano",
|
"Upgrade your plan": "Aggiorna il tuo piano",
|
||||||
"Available with a paid license": "Disponibile con una licenza a pagamento",
|
"Available with a paid license": "Disponibile con una licenza a pagamento",
|
||||||
"Upgrade your license tier.": "Aggiorna il livello della tua licenza.",
|
"Upgrade your license tier.": "Aggiorna il livello della tua licenza.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "L'IA è disponibile nelle edizioni a pagamento di Docmost. Contatta sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "L'IA è disponibile solo nell'edizione Enterprise di Docmost. Contatta sales@docmost.com.",
|
||||||
"AI & MCP": "IA e MCP",
|
"AI & MCP": "IA e MCP",
|
||||||
"AI": "IA",
|
"AI": "IA",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "プランをアップグレードする",
|
"Upgrade your plan": "プランをアップグレードする",
|
||||||
"Available with a paid license": "有料ライセンスで利用可能",
|
"Available with a paid license": "有料ライセンスで利用可能",
|
||||||
"Upgrade your license tier.": "ライセンスタイアをアップグレードしてください。",
|
"Upgrade your license tier.": "ライセンスタイアをアップグレードしてください。",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "AI は Docmost の有料版で利用可能です。sales@docmost.com までお問い合わせください。",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "AI は Docmost のエンタープライズ版でのみ利用可能です。sales@docmost.com までお問い合わせください。",
|
||||||
"AI & MCP": "AI と MCP",
|
"AI & MCP": "AI と MCP",
|
||||||
"AI": "AI",
|
"AI": "AI",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "요금제를 업그레이드하세요",
|
"Upgrade your plan": "요금제를 업그레이드하세요",
|
||||||
"Available with a paid license": "유료 라이선스에서만 사용 가능합니다",
|
"Available with a paid license": "유료 라이선스에서만 사용 가능합니다",
|
||||||
"Upgrade your license tier.": "라이선스 등급을 업그레이드하세요.",
|
"Upgrade your license tier.": "라이선스 등급을 업그레이드하세요.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "AI는 Docmost 유료 에디션에서 제공됩니다. sales@docmost.com으로 문의하세요.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "AI는 Docmost 엔터프라이즈 에디션에서만 제공됩니다. sales@docmost.com으로 문의하세요.",
|
||||||
"AI & MCP": "AI 및 MCP",
|
"AI & MCP": "AI 및 MCP",
|
||||||
"AI": "AI",
|
"AI": "AI",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "Upgrade je abonnement",
|
"Upgrade your plan": "Upgrade je abonnement",
|
||||||
"Available with a paid license": "Beschikbaar met een betaalde licentie",
|
"Available with a paid license": "Beschikbaar met een betaalde licentie",
|
||||||
"Upgrade your license tier.": "Upgrade je licentieniveau.",
|
"Upgrade your license tier.": "Upgrade je licentieniveau.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "AI is beschikbaar in de betaalde edities van Docmost. Neem contact op met sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "AI is alleen beschikbaar in de Docmost Enterprise-editie. Neem contact op met sales@docmost.com.",
|
||||||
"AI & MCP": "AI & MCP",
|
"AI & MCP": "AI & MCP",
|
||||||
"AI": "AI",
|
"AI": "AI",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "Faça upgrade do seu plano",
|
"Upgrade your plan": "Faça upgrade do seu plano",
|
||||||
"Available with a paid license": "Disponível com uma licença paga",
|
"Available with a paid license": "Disponível com uma licença paga",
|
||||||
"Upgrade your license tier.": "Faça upgrade do seu nível de licença.",
|
"Upgrade your license tier.": "Faça upgrade do seu nível de licença.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "A IA está disponível nas edições pagas do Docmost. Contate sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "A IA está disponível apenas na edição empresarial do Docmost. Contate sales@docmost.com.",
|
||||||
"AI & MCP": "IA e MCP",
|
"AI & MCP": "IA e MCP",
|
||||||
"AI": "IA",
|
"AI": "IA",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "Обновите свой тарифный план",
|
"Upgrade your plan": "Обновите свой тарифный план",
|
||||||
"Available with a paid license": "Доступно с платной лицензией",
|
"Available with a paid license": "Доступно с платной лицензией",
|
||||||
"Upgrade your license tier.": "Обновите уровень вашей лицензии.",
|
"Upgrade your license tier.": "Обновите уровень вашей лицензии.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "ИИ доступен в платных версиях Docmost. Свяжитесь по адресу sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "ИИ доступен только в корпоративной версии Docmost. Свяжитесь по адресу sales@docmost.com.",
|
||||||
"AI & MCP": "ИИ и MCP",
|
"AI & MCP": "ИИ и MCP",
|
||||||
"AI": "ИИ",
|
"AI": "ИИ",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "Оновіть свій тарифний план",
|
"Upgrade your plan": "Оновіть свій тарифний план",
|
||||||
"Available with a paid license": "Доступно за платною ліцензією",
|
"Available with a paid license": "Доступно за платною ліцензією",
|
||||||
"Upgrade your license tier.": "Оновіть рівень своєї ліцензії.",
|
"Upgrade your license tier.": "Оновіть рівень своєї ліцензії.",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "ШІ доступний у платних редакціях Docmost. Зверніться до sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "ШІ доступний лише в корпоративній редакції Docmost. Зверніться до sales@docmost.com.",
|
||||||
"AI & MCP": "ШІ та MCP",
|
"AI & MCP": "ШІ та MCP",
|
||||||
"AI": "ШІ",
|
"AI": "ШІ",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -696,7 +696,7 @@
|
|||||||
"Upgrade your plan": "升级您的方案",
|
"Upgrade your plan": "升级您的方案",
|
||||||
"Available with a paid license": "需付费许可才可用",
|
"Available with a paid license": "需付费许可才可用",
|
||||||
"Upgrade your license tier.": "升级您的许可等级。",
|
"Upgrade your license tier.": "升级您的许可等级。",
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.": "AI 在 Docmost 付费版中提供。请联系 sales@docmost.com。",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "AI 仅在 Docmost 企业版中提供。请联系 sales@docmost.com。",
|
||||||
"AI & MCP": "AI 与 MCP",
|
"AI & MCP": "AI 与 MCP",
|
||||||
"AI": "AI",
|
"AI": "AI",
|
||||||
"MCP": "MCP",
|
"MCP": "MCP",
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import FavoritesPage from "@/pages/favorites/favorites-page";
|
|||||||
import AiChat from "@/ee/ai-chat/pages/ai-chat.tsx";
|
import AiChat from "@/ee/ai-chat/pages/ai-chat.tsx";
|
||||||
import VerifyEmail from "@/ee/pages/verify-email.tsx";
|
import VerifyEmail from "@/ee/pages/verify-email.tsx";
|
||||||
import LabelPage from "@/pages/label/label-page";
|
import LabelPage from "@/pages/label/label-page";
|
||||||
|
import ConfluenceImportPage from "@/ee/confluence-import/pages/confluence-import.tsx";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -128,6 +129,10 @@ export default function App() {
|
|||||||
<Route path={"ai/mcp"} element={<AiSettings />} />
|
<Route path={"ai/mcp"} element={<AiSettings />} />
|
||||||
<Route path={"audit"} element={<AuditLogs />} />
|
<Route path={"audit"} element={<AuditLogs />} />
|
||||||
<Route path={"verifications"} element={<VerifiedPages />} />
|
<Route path={"verifications"} element={<VerifiedPages />} />
|
||||||
|
<Route
|
||||||
|
path={"import/confluence"}
|
||||||
|
element={<ConfluenceImportPage />}
|
||||||
|
/>
|
||||||
{!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>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ActionIcon, Box, Group, ScrollArea, Title, Tooltip } from "@mantine/core";
|
import { ActionIcon, Box, Group, ScrollArea, Title, Tooltip } from "@mantine/core";
|
||||||
import { IconX } from "@tabler/icons-react";
|
import { IconX } from "@tabler/icons-react";
|
||||||
import CommentListWithTabs from "@/features/comment/components/comment-list-with-tabs.tsx";
|
import CommentListWithTabs from "@/features/comment/components/comment-list-with-tabs.tsx";
|
||||||
|
import { CommentErrorBoundary } from "@/features/comment/components/comment-error-boundary.tsx";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
||||||
import React, { ReactNode, useEffect } from "react";
|
import React, { ReactNode, useEffect } from "react";
|
||||||
@@ -28,7 +29,11 @@ export default function Aside() {
|
|||||||
|
|
||||||
switch (tab) {
|
switch (tab) {
|
||||||
case "comments":
|
case "comments":
|
||||||
component = <CommentListWithTabs />;
|
component = (
|
||||||
|
<CommentErrorBoundary>
|
||||||
|
<CommentListWithTabs />
|
||||||
|
</CommentErrorBoundary>
|
||||||
|
);
|
||||||
title = "Comments";
|
title = "Comments";
|
||||||
break;
|
break;
|
||||||
case "toc":
|
case "toc":
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ import {
|
|||||||
IconSparkles,
|
IconSparkles,
|
||||||
IconHistory,
|
IconHistory,
|
||||||
IconShieldCheck,
|
IconShieldCheck,
|
||||||
|
IconFileImport,
|
||||||
} 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 { isBetaConfluenceImporter, 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";
|
import { useAtom } from "jotai";
|
||||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||||
@@ -51,6 +52,7 @@ type DataItem = {
|
|||||||
feature?: string;
|
feature?: string;
|
||||||
role?: "admin" | "owner";
|
role?: "admin" | "owner";
|
||||||
env?: "cloud" | "selfhosted";
|
env?: "cloud" | "selfhosted";
|
||||||
|
show?: () => boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DataGroup = {
|
type DataGroup = {
|
||||||
@@ -125,6 +127,14 @@ const groupedData: DataGroup[] = [
|
|||||||
role: "owner",
|
role: "owner",
|
||||||
env: "selfhosted",
|
env: "selfhosted",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Import",
|
||||||
|
icon: IconFileImport,
|
||||||
|
path: "/settings/import/confluence",
|
||||||
|
feature: Feature.CONFLUENCE_API_IMPORT,
|
||||||
|
role: "admin",
|
||||||
|
show: () => isBetaConfluenceImporter(),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -158,6 +168,7 @@ export default function SettingsSidebar() {
|
|||||||
entitlements?.features?.includes(f) ?? false;
|
entitlements?.features?.includes(f) ?? false;
|
||||||
|
|
||||||
const canShowItem = (item: DataItem) => {
|
const canShowItem = (item: DataItem) => {
|
||||||
|
if (item.show && !item.show()) return false;
|
||||||
if (item.env === "cloud" && !isCloud()) return false;
|
if (item.env === "cloud" && !isCloud()) return false;
|
||||||
if (item.env === "selfhosted" && isCloud()) return false;
|
if (item.env === "selfhosted" && isCloud()) return false;
|
||||||
if (item.role === "admin" && !isAdmin) return false;
|
if (item.role === "admin" && !isAdmin) return false;
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
import { UnstyledButton } from "@mantine/core";
|
|
||||||
import { type ComponentPropsWithoutRef, forwardRef } from "react";
|
|
||||||
|
|
||||||
// Menu.Item hard-codes role="menuitem"; use as its `component` to restore role="menuitemcheckbox" so aria-checked works.
|
|
||||||
export const CheckboxMenuItem = forwardRef<
|
|
||||||
HTMLButtonElement,
|
|
||||||
ComponentPropsWithoutRef<"button">
|
|
||||||
>((props, ref) => (
|
|
||||||
<UnstyledButton ref={ref} {...props} role="menuitemcheckbox" />
|
|
||||||
));
|
|
||||||
|
|
||||||
CheckboxMenuItem.displayName = "CheckboxMenuItem";
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
import { Badge, Group, Text, Switch, Tooltip } from "@mantine/core";
|
|
||||||
import { useAtom } from "jotai";
|
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
|
||||||
import { notifications } from "@mantine/notifications";
|
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
|
||||||
import { Feature } from "@/ee/features";
|
|
||||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
|
||||||
|
|
||||||
export default function AiChatReadOnly() {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const hasAccess = useHasFeature(Feature.AI_CONTROLS);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Group justify="space-between" wrap="nowrap" gap="xl">
|
|
||||||
<div>
|
|
||||||
<Group gap="xs" align="center">
|
|
||||||
<Text size="md">{t("Read-only mode")}</Text>
|
|
||||||
{!hasAccess && (
|
|
||||||
<Badge variant="light" size="sm" radius="sm">
|
|
||||||
{t("Enterprise")}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
<Text size="sm" c="dimmed">
|
|
||||||
{t(
|
|
||||||
"AI Chat can search and read workspace content, but cannot create or edit pages.",
|
|
||||||
)}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<AiChatReadOnlyToggle />
|
|
||||||
</Group>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AiChatReadOnlyToggle() {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
|
||||||
const [checked, setChecked] = useState(
|
|
||||||
workspace?.settings?.ai?.chatReadOnly,
|
|
||||||
);
|
|
||||||
const hasAccess = useHasFeature(Feature.AI_CONTROLS);
|
|
||||||
const upgradeLabel = useUpgradeLabel();
|
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
const value = event.currentTarget.checked;
|
|
||||||
try {
|
|
||||||
const updatedWorkspace = await updateWorkspace({
|
|
||||||
aiChatReadOnly: value,
|
|
||||||
});
|
|
||||||
setChecked(value);
|
|
||||||
setWorkspace(updatedWorkspace);
|
|
||||||
} catch (err: any) {
|
|
||||||
notifications.show({
|
|
||||||
message: err?.response?.data?.message,
|
|
||||||
color: "red",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tooltip label={upgradeLabel} disabled={hasAccess} refProp="rootRef">
|
|
||||||
<Switch
|
|
||||||
defaultChecked={checked}
|
|
||||||
onChange={handleChange}
|
|
||||||
disabled={!hasAccess}
|
|
||||||
aria-label={t("Toggle AI Chat read-only mode")}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
import { Badge, Group, Text, Switch, Tooltip } from "@mantine/core";
|
|
||||||
import { useAtom } from "jotai";
|
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
|
||||||
import { notifications } from "@mantine/notifications";
|
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
|
||||||
import { Feature } from "@/ee/features";
|
|
||||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
|
||||||
|
|
||||||
export default function AiChatWorkspaceKnowledgeOnly() {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const hasAccess = useHasFeature(Feature.AI_CONTROLS);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Group justify="space-between" wrap="nowrap" gap="xl">
|
|
||||||
<div>
|
|
||||||
<Group gap="xs" align="center">
|
|
||||||
<Text size="md">{t("Workspace knowledge only")}</Text>
|
|
||||||
{!hasAccess && (
|
|
||||||
<Badge variant="light" size="sm" radius="sm">
|
|
||||||
{t("Enterprise")}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
<Text size="sm" c="dimmed">
|
|
||||||
{t(
|
|
||||||
"Restrict AI Chat to answering from your workspace pages and uploaded files only. It will not use outside knowledge.",
|
|
||||||
)}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<AiChatWorkspaceKnowledgeOnlyToggle />
|
|
||||||
</Group>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AiChatWorkspaceKnowledgeOnlyToggle() {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
|
||||||
const [checked, setChecked] = useState(
|
|
||||||
workspace?.settings?.ai?.chatWorkspaceKnowledgeOnly,
|
|
||||||
);
|
|
||||||
const hasAccess = useHasFeature(Feature.AI_CONTROLS);
|
|
||||||
const upgradeLabel = useUpgradeLabel();
|
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
const value = event.currentTarget.checked;
|
|
||||||
try {
|
|
||||||
const updatedWorkspace = await updateWorkspace({
|
|
||||||
aiChatWorkspaceKnowledgeOnly: value,
|
|
||||||
});
|
|
||||||
setChecked(value);
|
|
||||||
setWorkspace(updatedWorkspace);
|
|
||||||
} catch (err: any) {
|
|
||||||
notifications.show({
|
|
||||||
message: err?.response?.data?.message,
|
|
||||||
color: "red",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tooltip label={upgradeLabel} disabled={hasAccess} refProp="rootRef">
|
|
||||||
<Switch
|
|
||||||
defaultChecked={checked}
|
|
||||||
onChange={handleChange}
|
|
||||||
disabled={!hasAccess}
|
|
||||||
aria-label={t("Toggle workspace knowledge only")}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -6,10 +6,7 @@ import {
|
|||||||
IconFileText,
|
IconFileText,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAtomValue } from "jotai";
|
import ChatInput from "./chat-input";
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
import { useRef } from "react";
|
|
||||||
import ChatInput, { ChatInputHandle } from "./chat-input";
|
|
||||||
import type { ChatAttachment, PageMention } from "../types/ai-chat.types";
|
import type { ChatAttachment, PageMention } from "../types/ai-chat.types";
|
||||||
import classes from "../styles/ai-chat.module.css";
|
import classes from "../styles/ai-chat.module.css";
|
||||||
|
|
||||||
@@ -17,7 +14,6 @@ type Suggestion = {
|
|||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
text: string;
|
text: string;
|
||||||
prompt: string;
|
prompt: string;
|
||||||
write?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const SUGGESTIONS: Suggestion[] = [
|
const SUGGESTIONS: Suggestion[] = [
|
||||||
@@ -30,7 +26,6 @@ const SUGGESTIONS: Suggestion[] = [
|
|||||||
icon: <IconFilePlus size={16} />,
|
icon: <IconFilePlus size={16} />,
|
||||||
text: "Create a new page",
|
text: "Create a new page",
|
||||||
prompt: "Create a new page titled ",
|
prompt: "Create a new page titled ",
|
||||||
write: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: <IconFileText size={16} />,
|
icon: <IconFileText size={16} />,
|
||||||
@@ -41,7 +36,6 @@ const SUGGESTIONS: Suggestion[] = [
|
|||||||
icon: <IconEdit size={16} />,
|
icon: <IconEdit size={16} />,
|
||||||
text: "Update page content",
|
text: "Update page content",
|
||||||
prompt: "Update the page @",
|
prompt: "Update the page @",
|
||||||
write: true,
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -53,13 +47,9 @@ type Props = {
|
|||||||
|
|
||||||
export default function ChatEmptyState({ isStreaming, onSend, onStop }: Props) {
|
export default function ChatEmptyState({ isStreaming, onSend, onStop }: Props) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const workspace = useAtomValue(workspaceAtom);
|
|
||||||
const writesDisabled = workspace?.settings?.ai?.chatReadOnly === true;
|
|
||||||
|
|
||||||
const inputRef = useRef<ChatInputHandle>(null);
|
|
||||||
|
|
||||||
const handleSuggestionClick = (prompt: string) => {
|
const handleSuggestionClick = (prompt: string) => {
|
||||||
inputRef.current?.prefill(prompt);
|
onSend(prompt, [], []);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -72,7 +62,6 @@ export default function ChatEmptyState({ isStreaming, onSend, onStop }: Props) {
|
|||||||
|
|
||||||
<div className={classes.emptyStateInput}>
|
<div className={classes.emptyStateInput}>
|
||||||
<ChatInput
|
<ChatInput
|
||||||
ref={inputRef}
|
|
||||||
isStreaming={isStreaming}
|
isStreaming={isStreaming}
|
||||||
onSend={onSend}
|
onSend={onSend}
|
||||||
onStop={onStop}
|
onStop={onStop}
|
||||||
@@ -84,7 +73,7 @@ export default function ChatEmptyState({ isStreaming, onSend, onStop }: Props) {
|
|||||||
<div className={classes.suggestionsSection}>
|
<div className={classes.suggestionsSection}>
|
||||||
<h2 className={classes.suggestionsLabel}>{t("Get started")}</h2>
|
<h2 className={classes.suggestionsLabel}>{t("Get started")}</h2>
|
||||||
<div className={classes.suggestionsGrid}>
|
<div className={classes.suggestionsGrid}>
|
||||||
{SUGGESTIONS.filter((s) => !writesDisabled || !s.write).map((s) => (
|
{SUGGESTIONS.map((s) => (
|
||||||
<button
|
<button
|
||||||
key={s.text}
|
key={s.text}
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
import {
|
import { useCallback, useId, useRef, useEffect, useState } from "react";
|
||||||
forwardRef,
|
|
||||||
useCallback,
|
|
||||||
useId,
|
|
||||||
useImperativeHandle,
|
|
||||||
useRef,
|
|
||||||
useEffect,
|
|
||||||
useState,
|
|
||||||
} from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { IconArrowUp, IconPaperclip, IconPlayerStopFilled, IconX, IconFile, IconPhoto, IconPlus, IconAt, IconFileText } from "@tabler/icons-react";
|
import { IconArrowUp, IconPaperclip, IconPlayerStopFilled, IconX, IconFile, IconPhoto, IconPlus, IconAt, IconFileText } from "@tabler/icons-react";
|
||||||
import { Popover } from "@mantine/core";
|
import { Popover } from "@mantine/core";
|
||||||
@@ -43,10 +35,6 @@ type Props = {
|
|||||||
chatId?: string;
|
chatId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ChatInputHandle = {
|
|
||||||
prefill: (text: string) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
function extractMentions(json: any): PageMention[] {
|
function extractMentions(json: any): PageMention[] {
|
||||||
const mentions: PageMention[] = [];
|
const mentions: PageMention[] = [];
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
@@ -101,7 +89,7 @@ function editorJsonToText(json: any): string {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChatInput = forwardRef<ChatInputHandle, Props>(function ChatInput({
|
export default function ChatInput({
|
||||||
isStreaming,
|
isStreaming,
|
||||||
onSend,
|
onSend,
|
||||||
onStop,
|
onStop,
|
||||||
@@ -112,7 +100,7 @@ const ChatInput = forwardRef<ChatInputHandle, Props>(function ChatInput({
|
|||||||
variant = "card",
|
variant = "card",
|
||||||
showDisclaimer = true,
|
showDisclaimer = true,
|
||||||
chatId,
|
chatId,
|
||||||
}: Props, ref) {
|
}: Props) {
|
||||||
const chatIdRef = useRef(chatId);
|
const chatIdRef = useRef(chatId);
|
||||||
chatIdRef.current = chatId;
|
chatIdRef.current = chatId;
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -282,19 +270,6 @@ const ChatInput = forwardRef<ChatInputHandle, Props>(function ChatInput({
|
|||||||
}
|
}
|
||||||
}, [editor]);
|
}, [editor]);
|
||||||
|
|
||||||
useImperativeHandle(
|
|
||||||
ref,
|
|
||||||
() => ({
|
|
||||||
prefill: (text: string) => {
|
|
||||||
if (!editor || editor.isDestroyed) return;
|
|
||||||
editor.commands.clearContent();
|
|
||||||
editor.commands.insertContent(text);
|
|
||||||
editor.commands.focus();
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
[editor],
|
|
||||||
);
|
|
||||||
|
|
||||||
const hasContent = !isEmpty || pendingAttachments.some((a) => !a.uploading) || (contextPages?.length ?? 0) > 0;
|
const hasContent = !isEmpty || pendingAttachments.some((a) => !a.uploading) || (contextPages?.length ?? 0) > 0;
|
||||||
|
|
||||||
const wrapperClass = variant === "flat" ? classes.inputWrapperFlat : classes.inputWrapper;
|
const wrapperClass = variant === "flat" ? classes.inputWrapperFlat : classes.inputWrapper;
|
||||||
@@ -454,6 +429,4 @@ const ChatInput = forwardRef<ChatInputHandle, Props>(function ChatInput({
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
export default ChatInput;
|
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ import { useTranslation } from "react-i18next";
|
|||||||
import EnableAiSearch from "@/ee/ai/components/enable-ai-search.tsx";
|
import EnableAiSearch from "@/ee/ai/components/enable-ai-search.tsx";
|
||||||
import EnableGenerativeAi from "@/ee/ai/components/enable-generative-ai.tsx";
|
import EnableGenerativeAi from "@/ee/ai/components/enable-generative-ai.tsx";
|
||||||
import EnableAiChat from "@/ee/ai-chat/components/enable-ai-chat.tsx";
|
import EnableAiChat from "@/ee/ai-chat/components/enable-ai-chat.tsx";
|
||||||
import AiChatReadOnly from "@/ee/ai-chat/components/ai-chat-read-only.tsx";
|
|
||||||
import AiChatWorkspaceKnowledgeOnly from "@/ee/ai-chat/components/ai-chat-workspace-knowledge-only.tsx";
|
|
||||||
import McpSettings from "@/ee/ai/components/mcp-settings.tsx";
|
import McpSettings from "@/ee/ai/components/mcp-settings.tsx";
|
||||||
import { Alert, Collapse, Stack, Tabs } from "@mantine/core";
|
import { Alert, Stack, Tabs } from "@mantine/core";
|
||||||
import { IconInfoCircle } from "@tabler/icons-react";
|
import { IconInfoCircle } from "@tabler/icons-react";
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
import { Feature } from "@/ee/features";
|
import { Feature } from "@/ee/features";
|
||||||
@@ -16,16 +14,12 @@ import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
|||||||
import { isCloud } from "@/lib/config.ts";
|
import { isCloud } from "@/lib/config.ts";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||||
import { useAtomValue } from "jotai";
|
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
|
|
||||||
export default function AiSettings() {
|
export default function AiSettings() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { isAdmin } = useUserRole();
|
const { isAdmin } = useUserRole();
|
||||||
const hasAccess = useHasFeature(Feature.AI);
|
const hasAccess = useHasFeature(Feature.AI);
|
||||||
const upgradeLabel = useUpgradeLabel();
|
const upgradeLabel = useUpgradeLabel();
|
||||||
const workspace = useAtomValue(workspaceAtom);
|
|
||||||
const aiChatEnabled = workspace?.settings?.ai?.chat === true;
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@@ -67,7 +61,7 @@ export default function AiSettings() {
|
|||||||
mb="lg"
|
mb="lg"
|
||||||
>
|
>
|
||||||
{t(
|
{t(
|
||||||
"AI is available in the Docmost paid editions. Contact sales@docmost.com.",
|
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.",
|
||||||
)}
|
)}
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
@@ -76,20 +70,6 @@ export default function AiSettings() {
|
|||||||
{!isCloud() && <EnableAiSearch />}
|
{!isCloud() && <EnableAiSearch />}
|
||||||
<EnableGenerativeAi />
|
<EnableGenerativeAi />
|
||||||
<EnableAiChat />
|
<EnableAiChat />
|
||||||
<Collapse expanded={aiChatEnabled}>
|
|
||||||
<Stack
|
|
||||||
gap="md"
|
|
||||||
pl="md"
|
|
||||||
ml="xs"
|
|
||||||
style={{
|
|
||||||
borderLeft:
|
|
||||||
"2px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4))",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<AiChatReadOnly />
|
|
||||||
<AiChatWorkspaceKnowledgeOnly />
|
|
||||||
</Stack>
|
|
||||||
</Collapse>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,6 @@ export interface IAiSearchResponse {
|
|||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function hintVectorCache(): Promise<void> {
|
|
||||||
try {
|
|
||||||
await api.post("/ai/vector-cache-hint");
|
|
||||||
} catch {
|
|
||||||
// best-effort cache hint
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function aiAnswers(
|
export async function aiAnswers(
|
||||||
params: IPageSearchParams,
|
params: IPageSearchParams,
|
||||||
onChunk?: (chunk: { content?: string; sources?: any[] }) => void,
|
onChunk?: (chunk: { content?: string; sources?: any[] }) => void,
|
||||||
|
|||||||
@@ -0,0 +1,340 @@
|
|||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import {
|
||||||
|
Badge,
|
||||||
|
Group,
|
||||||
|
Loader,
|
||||||
|
Modal,
|
||||||
|
Progress,
|
||||||
|
Skeleton,
|
||||||
|
Stack,
|
||||||
|
Table,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { IconAlertCircle, IconCheck, IconX } from "@tabler/icons-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import {
|
||||||
|
ConfluenceImportHistoryItem,
|
||||||
|
ConfluenceImportStatus,
|
||||||
|
} from "@/ee/confluence-import/types/confluence-import.types";
|
||||||
|
import { CustomAvatar } from "@/components/ui/custom-avatar";
|
||||||
|
import { formattedDate } from "@/lib/time";
|
||||||
|
import NoTableResults from "@/components/common/no-table-results";
|
||||||
|
import { useConfluenceImportsQuery } from "@/ee/confluence-import/queries/confluence-import-queries";
|
||||||
|
|
||||||
|
const BADGE_STYLES = {
|
||||||
|
root: { flexShrink: 0 },
|
||||||
|
label: { overflow: "visible" as const },
|
||||||
|
};
|
||||||
|
|
||||||
|
function statusBadge(
|
||||||
|
status: ConfluenceImportStatus,
|
||||||
|
cancelled: boolean,
|
||||||
|
t: (key: string) => string,
|
||||||
|
) {
|
||||||
|
if (cancelled) {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
color="gray"
|
||||||
|
variant="light"
|
||||||
|
leftSection={<IconX size={12} />}
|
||||||
|
styles={BADGE_STYLES}
|
||||||
|
>
|
||||||
|
{t("Cancelled")}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (status === "processing") {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
color="blue"
|
||||||
|
variant="light"
|
||||||
|
leftSection={<Loader size={10} />}
|
||||||
|
styles={BADGE_STYLES}
|
||||||
|
>
|
||||||
|
{t("Running")}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (status === "success") {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
color="teal"
|
||||||
|
variant="light"
|
||||||
|
leftSection={<IconCheck size={12} />}
|
||||||
|
styles={BADGE_STYLES}
|
||||||
|
>
|
||||||
|
{t("Completed")}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
color="red"
|
||||||
|
variant="light"
|
||||||
|
leftSection={<IconAlertCircle size={12} />}
|
||||||
|
styles={BADGE_STYLES}
|
||||||
|
>
|
||||||
|
{t("Failed")}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function phaseLabel(phase: string | null, t: (key: string) => string): string {
|
||||||
|
if (!phase) return "—";
|
||||||
|
return t(phase.charAt(0).toUpperCase() + phase.slice(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
function progressValue(item: ConfluenceImportHistoryItem) {
|
||||||
|
if (item.status === "success") return 100;
|
||||||
|
if (item.totalPages > 0) {
|
||||||
|
return Math.min(
|
||||||
|
100,
|
||||||
|
Math.round((item.importedPages / item.totalPages) * 100),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return item.status === "processing" ? 5 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ProgressCell({ item }: { item: ConfluenceImportHistoryItem }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const value = progressValue(item);
|
||||||
|
const color =
|
||||||
|
item.status === "failed"
|
||||||
|
? "red"
|
||||||
|
: item.status === "success"
|
||||||
|
? "teal"
|
||||||
|
: "blue";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack gap={4}>
|
||||||
|
<Progress value={value} color={color} size="xs" animated={item.status === "processing"} />
|
||||||
|
<Group gap="xs" wrap="nowrap">
|
||||||
|
<Text fz="xs" c="dimmed" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{item.importedPages}/{item.totalPages || "?"} {t("pages")}
|
||||||
|
</Text>
|
||||||
|
<Text fz="xs" c="dimmed" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
· {item.importedSpaces}/{item.totalSpaces || "?"} {t("spaces")}
|
||||||
|
</Text>
|
||||||
|
<Text fz="xs" c="dimmed" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
· {item.importedUsers}/{item.totalUsers || "?"} {t("users")}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ImportStatsModal({
|
||||||
|
item,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
item: ConfluenceImportHistoryItem | null;
|
||||||
|
onClose: () => void;
|
||||||
|
}) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const stats = item
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
label: t("Spaces"),
|
||||||
|
imported: item.importedSpaces,
|
||||||
|
total: item.totalSpaces,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Pages"),
|
||||||
|
imported: item.importedPages,
|
||||||
|
total: item.totalPages,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Users"),
|
||||||
|
imported: item.importedUsers,
|
||||||
|
total: item.totalUsers,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Groups"),
|
||||||
|
imported: item.importedGroups,
|
||||||
|
total: item.totalGroups,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Attachments"),
|
||||||
|
imported: item.importedAttachments,
|
||||||
|
total: item.totalAttachments,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Labels"),
|
||||||
|
imported: item.importedLabels,
|
||||||
|
total: item.totalLabels,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Restricted pages"),
|
||||||
|
imported: item.importedRestrictedPages,
|
||||||
|
total: item.totalRestrictedPages,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={!!item}
|
||||||
|
onClose={onClose}
|
||||||
|
title={t("Import details")}
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
{item && (
|
||||||
|
<Stack gap="sm">
|
||||||
|
<div>
|
||||||
|
<Text fz="sm" c="dimmed">
|
||||||
|
{t("Confluence site")}
|
||||||
|
</Text>
|
||||||
|
<Text fz="sm" fw={500} lineClamp={1}>
|
||||||
|
{item.siteUrl}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text fz="sm" c="dimmed">
|
||||||
|
{t("Started at")}
|
||||||
|
</Text>
|
||||||
|
<Text fz="sm">{formattedDate(new Date(item.createdAt))}</Text>
|
||||||
|
</div>
|
||||||
|
<Table verticalSpacing="xs" fz="sm">
|
||||||
|
<Table.Tbody>
|
||||||
|
{stats.map((stat) => (
|
||||||
|
<Table.Tr key={stat.label}>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm">{stat.label}</Text>
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" ta="right">
|
||||||
|
{stat.imported} / {stat.total}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
</Table.Tr>
|
||||||
|
))}
|
||||||
|
</Table.Tbody>
|
||||||
|
</Table>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableSkeleton() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{Array.from({ length: 3 }).map((_, i) => (
|
||||||
|
<Table.Tr key={i}>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={120} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={180} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={80} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={140} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={120} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={120} />
|
||||||
|
</Table.Td>
|
||||||
|
</Table.Tr>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ConfluenceImportHistory() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { data, isLoading } = useConfluenceImportsQuery();
|
||||||
|
const [selectedItem, setSelectedItem] =
|
||||||
|
useState<ConfluenceImportHistoryItem | null>(null);
|
||||||
|
|
||||||
|
const items = useMemo(() => data?.items ?? [], [data]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table.ScrollContainer minWidth={720}>
|
||||||
|
<Table verticalSpacing="xs" highlightOnHover>
|
||||||
|
<Table.Thead>
|
||||||
|
<Table.Tr>
|
||||||
|
<Table.Th>{t("Status")}</Table.Th>
|
||||||
|
<Table.Th>{t("Site")}</Table.Th>
|
||||||
|
<Table.Th>{t("Phase")}</Table.Th>
|
||||||
|
<Table.Th>{t("Progress")}</Table.Th>
|
||||||
|
<Table.Th>{t("Started by")}</Table.Th>
|
||||||
|
<Table.Th>{t("Started at")}</Table.Th>
|
||||||
|
</Table.Tr>
|
||||||
|
</Table.Thead>
|
||||||
|
|
||||||
|
<Table.Tbody>
|
||||||
|
{isLoading ? (
|
||||||
|
<TableSkeleton />
|
||||||
|
) : items.length > 0 ? (
|
||||||
|
items.map((item) => (
|
||||||
|
<Table.Tr
|
||||||
|
key={item.fileTaskId}
|
||||||
|
onClick={() => setSelectedItem(item)}
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
<Table.Td>
|
||||||
|
{statusBadge(item.status, item.cancelled, t)}
|
||||||
|
{item.status === "failed" && item.errorMessage && (
|
||||||
|
<Tooltip label={item.errorMessage} multiline w={320}>
|
||||||
|
<Text fz="xs" c="red" lineClamp={1} maw={180}>
|
||||||
|
{item.errorMessage}
|
||||||
|
</Text>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" lineClamp={1} maw={240}>
|
||||||
|
{item.siteUrl}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm">{phaseLabel(item.currentPhase, t)}</Text>
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<ProgressCell item={item} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
{item.creatorName ? (
|
||||||
|
<Group gap="sm" wrap="nowrap">
|
||||||
|
<CustomAvatar
|
||||||
|
avatarUrl={item.creatorAvatarUrl}
|
||||||
|
name={item.creatorName}
|
||||||
|
size={24}
|
||||||
|
/>
|
||||||
|
<Text fz="sm" lineClamp={1}>
|
||||||
|
{item.creatorName}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
) : (
|
||||||
|
<Text fz="sm" c="dimmed">
|
||||||
|
—
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{formattedDate(new Date(item.createdAt))}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
</Table.Tr>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<NoTableResults colSpan={6} />
|
||||||
|
)}
|
||||||
|
</Table.Tbody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
|
<ImportStatsModal
|
||||||
|
item={selectedItem}
|
||||||
|
onClose={() => setSelectedItem(null)}
|
||||||
|
/>
|
||||||
|
</Table.ScrollContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,445 @@
|
|||||||
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
Group,
|
||||||
|
Modal,
|
||||||
|
PasswordInput,
|
||||||
|
ScrollArea,
|
||||||
|
SegmentedControl,
|
||||||
|
Stack,
|
||||||
|
Stepper,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import {
|
||||||
|
IconAlertCircle,
|
||||||
|
IconCheck,
|
||||||
|
IconCloudCheck,
|
||||||
|
IconPlug,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useForm } from "@mantine/form";
|
||||||
|
import { notifications } from "@mantine/notifications";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import {
|
||||||
|
listConfluenceSpaces,
|
||||||
|
startConfluenceImport,
|
||||||
|
testConfluenceConnection,
|
||||||
|
} from "@/ee/confluence-import/services/confluence-import-service";
|
||||||
|
import {
|
||||||
|
ConfluenceAuthType,
|
||||||
|
ConfluenceCredentials,
|
||||||
|
ConfluenceSpaceSummary,
|
||||||
|
} from "@/ee/confluence-import/types/confluence-import.types";
|
||||||
|
import { confluenceImportsQueryKey } from "@/ee/confluence-import/queries/confluence-import-queries";
|
||||||
|
|
||||||
|
type ConfluenceEditionChoice = "cloud" | "server";
|
||||||
|
|
||||||
|
type CredentialsFormValues = {
|
||||||
|
edition: ConfluenceEditionChoice;
|
||||||
|
authType: ConfluenceAuthType;
|
||||||
|
siteUrl: string;
|
||||||
|
email: string;
|
||||||
|
token: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
opened: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ConfluenceImportModal({ opened, onClose }: Props) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const [active, setActive] = useState(0);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [spaces, setSpaces] = useState<ConfluenceSpaceSummary[]>([]);
|
||||||
|
const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
|
||||||
|
const [importAll, setImportAll] = useState(true);
|
||||||
|
|
||||||
|
const form = useForm<CredentialsFormValues>({
|
||||||
|
initialValues: {
|
||||||
|
edition: "server",
|
||||||
|
authType: "pat",
|
||||||
|
siteUrl: "",
|
||||||
|
email: "",
|
||||||
|
token: "",
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
},
|
||||||
|
validate: {
|
||||||
|
siteUrl: (value) =>
|
||||||
|
!value?.trim()
|
||||||
|
? t("Site URL is required")
|
||||||
|
: !/^https?:\/\//i.test(value.trim())
|
||||||
|
? t("Site URL must start with http:// or https://")
|
||||||
|
: null,
|
||||||
|
email: (value, values) =>
|
||||||
|
values.edition === "cloud" && !value?.trim()
|
||||||
|
? t("Email is required")
|
||||||
|
: null,
|
||||||
|
token: (value, values) =>
|
||||||
|
(values.authType === "cloud_token" || values.authType === "pat") &&
|
||||||
|
!value?.trim()
|
||||||
|
? t("API token is required")
|
||||||
|
: null,
|
||||||
|
username: (value, values) =>
|
||||||
|
values.authType === "basic" && !value?.trim()
|
||||||
|
? t("Username is required")
|
||||||
|
: null,
|
||||||
|
password: (value, values) =>
|
||||||
|
values.authType === "basic" && !value?.trim()
|
||||||
|
? t("Password is required")
|
||||||
|
: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!opened) {
|
||||||
|
setActive(0);
|
||||||
|
setError(null);
|
||||||
|
setSpaces([]);
|
||||||
|
setSelectedKeys([]);
|
||||||
|
setImportAll(true);
|
||||||
|
setLoading(false);
|
||||||
|
form.reset();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [opened]);
|
||||||
|
|
||||||
|
const credentials: ConfluenceCredentials = useMemo(() => {
|
||||||
|
const values = form.values;
|
||||||
|
return {
|
||||||
|
siteUrl: values.siteUrl.trim().replace(/\/+$/, ""),
|
||||||
|
authType: values.authType,
|
||||||
|
email: values.email?.trim() || undefined,
|
||||||
|
token: values.token?.trim() || undefined,
|
||||||
|
username: values.username?.trim() || undefined,
|
||||||
|
password: values.password || undefined,
|
||||||
|
};
|
||||||
|
}, [form.values]);
|
||||||
|
|
||||||
|
const handleEditionChange = (edition: ConfluenceEditionChoice) => {
|
||||||
|
form.setFieldValue("edition", edition);
|
||||||
|
if (edition === "cloud") {
|
||||||
|
form.setFieldValue("authType", "cloud_token");
|
||||||
|
} else if (form.values.authType === "cloud_token") {
|
||||||
|
form.setFieldValue("authType", "pat");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNextFromCredentials = async () => {
|
||||||
|
if ((await form.validate()).hasErrors) return;
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
const test = await testConfluenceConnection(credentials);
|
||||||
|
if (!test.success) {
|
||||||
|
setError(test.error || t("Connection failed"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const list = await listConfluenceSpaces(credentials);
|
||||||
|
if (!list.success || !list.spaces) {
|
||||||
|
setError(list.error || t("Failed to load spaces"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSpaces(list.spaces);
|
||||||
|
setSelectedKeys(list.spaces.map((s) => s.key));
|
||||||
|
setImportAll(true);
|
||||||
|
setActive(1);
|
||||||
|
} catch (err: any) {
|
||||||
|
setError(
|
||||||
|
err?.response?.data?.message || err?.message || t("Unexpected error"),
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleSpace = (key: string, checked: boolean) => {
|
||||||
|
setSelectedKeys((prev) =>
|
||||||
|
checked
|
||||||
|
? Array.from(new Set([...prev, key]))
|
||||||
|
: prev.filter((k) => k !== key),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleAll = (checked: boolean) => {
|
||||||
|
setImportAll(checked);
|
||||||
|
setSelectedKeys(checked ? spaces.map((s) => s.key) : []);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStartImport = async () => {
|
||||||
|
const spaceKeys = importAll ? [] : selectedKeys;
|
||||||
|
if (!importAll && spaceKeys.length === 0) {
|
||||||
|
setError(t("Select at least one space to import"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
const result = await startConfluenceImport({
|
||||||
|
...credentials,
|
||||||
|
spaceKeys,
|
||||||
|
});
|
||||||
|
if (!result.success || !result.fileTaskId) {
|
||||||
|
setError(result.error || t("Failed to start import"));
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: confluenceImportsQueryKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
notifications.show({
|
||||||
|
title: t("Confluence import started"),
|
||||||
|
message: t("Track progress below. This runs in the background."),
|
||||||
|
color: "blue",
|
||||||
|
icon: <IconCheck size={18} />,
|
||||||
|
autoClose: 4000,
|
||||||
|
});
|
||||||
|
|
||||||
|
onClose();
|
||||||
|
} catch (err: any) {
|
||||||
|
setError(
|
||||||
|
err?.response?.data?.message || err?.message || t("Unexpected error"),
|
||||||
|
);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancelFlow = async () => {
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
const editionSegment = (
|
||||||
|
<SegmentedControl
|
||||||
|
value={form.values.edition}
|
||||||
|
onChange={(val) => handleEditionChange(val as ConfluenceEditionChoice)}
|
||||||
|
data={[
|
||||||
|
{ value: "server", label: t("Data Center / Server") },
|
||||||
|
{ value: "cloud", label: t("Cloud") },
|
||||||
|
]}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const authTypeSegment = form.values.edition === "server" && (
|
||||||
|
<SegmentedControl
|
||||||
|
value={form.values.authType}
|
||||||
|
onChange={(val) =>
|
||||||
|
form.setFieldValue("authType", val as ConfluenceAuthType)
|
||||||
|
}
|
||||||
|
data={[
|
||||||
|
{ value: "pat", label: t("Personal Access Token") },
|
||||||
|
{ value: "basic", label: t("Username + password") },
|
||||||
|
]}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const selectedCount = importAll ? spaces.length : selectedKeys.length;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={onClose}
|
||||||
|
title={t("Import from Confluence")}
|
||||||
|
size={720}
|
||||||
|
centered
|
||||||
|
closeOnClickOutside={!loading}
|
||||||
|
closeOnEscape={!loading}
|
||||||
|
>
|
||||||
|
<Stepper active={active} size="sm" mb="md" allowNextStepsSelect={false}>
|
||||||
|
<Stepper.Step
|
||||||
|
label={t("Connect")}
|
||||||
|
description={t("Credentials")}
|
||||||
|
icon={<IconPlug size={18} />}
|
||||||
|
/>
|
||||||
|
<Stepper.Step
|
||||||
|
label={t("Select spaces")}
|
||||||
|
description={t("Choose what to import")}
|
||||||
|
icon={<IconCloudCheck size={18} />}
|
||||||
|
/>
|
||||||
|
</Stepper>
|
||||||
|
|
||||||
|
{active === 0 && (
|
||||||
|
<Stack>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{t(
|
||||||
|
"Enter your Confluence URL and credentials. We'll validate the connection before continuing.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
{editionSegment}
|
||||||
|
{authTypeSegment}
|
||||||
|
<TextInput
|
||||||
|
label={t("Site URL")}
|
||||||
|
placeholder={
|
||||||
|
form.values.edition === "cloud"
|
||||||
|
? "https://your-site.atlassian.net/wiki"
|
||||||
|
: "https://confluence.example.com"
|
||||||
|
}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("siteUrl")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{form.values.edition === "cloud" && (
|
||||||
|
<>
|
||||||
|
<TextInput
|
||||||
|
label={t("Email")}
|
||||||
|
placeholder="you@company.com"
|
||||||
|
required
|
||||||
|
{...form.getInputProps("email")}
|
||||||
|
/>
|
||||||
|
<PasswordInput
|
||||||
|
label={t("API token")}
|
||||||
|
description={t(
|
||||||
|
"Create at id.atlassian.com/manage-profile/security/api-tokens",
|
||||||
|
)}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("token")}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{form.values.edition === "server" &&
|
||||||
|
form.values.authType === "pat" && (
|
||||||
|
<>
|
||||||
|
<TextInput
|
||||||
|
label={t("Email")}
|
||||||
|
placeholder="you@company.com"
|
||||||
|
{...form.getInputProps("email")}
|
||||||
|
/>
|
||||||
|
<PasswordInput
|
||||||
|
label={t("Personal Access Token")}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("token")}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{form.values.edition === "server" &&
|
||||||
|
form.values.authType === "basic" && (
|
||||||
|
<>
|
||||||
|
<TextInput
|
||||||
|
label={t("Username")}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("username")}
|
||||||
|
/>
|
||||||
|
<PasswordInput
|
||||||
|
label={t("Password")}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("password")}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={t("Email (optional)")}
|
||||||
|
placeholder="you@company.com"
|
||||||
|
{...form.getInputProps("email")}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<Alert color="red" icon={<IconAlertCircle size={18} />}>
|
||||||
|
{error}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Group justify="flex-end">
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
onClick={handleCancelFlow}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{t("Cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleNextFromCredentials} loading={loading}>
|
||||||
|
{t("Test & continue")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{active === 1 && (
|
||||||
|
<Stack>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{t(
|
||||||
|
"Pages, comments, page labels, users, groups, spaces and permissions will be imported.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Checkbox
|
||||||
|
label={t("Import all spaces ({{count}})", {
|
||||||
|
count: spaces.length,
|
||||||
|
})}
|
||||||
|
checked={importAll}
|
||||||
|
onChange={(e) => toggleAll(e.currentTarget.checked)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ScrollArea h={320} type="auto" offsetScrollbars>
|
||||||
|
<Stack gap="xs">
|
||||||
|
{spaces.map((space) => (
|
||||||
|
<Checkbox
|
||||||
|
key={space.id}
|
||||||
|
label={
|
||||||
|
<Group gap={6} wrap="nowrap">
|
||||||
|
<Text fw={500}>{space.name}</Text>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
({space.key})
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
}
|
||||||
|
checked={importAll || selectedKeys.includes(space.key)}
|
||||||
|
disabled={importAll}
|
||||||
|
onChange={(e) =>
|
||||||
|
toggleSpace(space.key, e.currentTarget.checked)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
{spaces.length === 0 && (
|
||||||
|
<Text c="dimmed" ta="center" py="lg">
|
||||||
|
{t("No spaces found for this account.")}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</ScrollArea>
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<Alert color="red" icon={<IconAlertCircle size={18} />}>
|
||||||
|
{error}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Group justify="space-between">
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{t("{{count}} selected", { count: selectedCount })}
|
||||||
|
</Text>
|
||||||
|
<Group>
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
onClick={() => setActive(0)}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{t("Back")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={handleStartImport}
|
||||||
|
loading={loading}
|
||||||
|
disabled={!importAll && selectedKeys.length === 0}
|
||||||
|
>
|
||||||
|
{t("Start import")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Divider,
|
||||||
|
Group,
|
||||||
|
Paper,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
|
import SettingsTitle from "@/components/settings/settings-title";
|
||||||
|
import { ConfluenceIcon } from "@/components/icons/confluence-icon";
|
||||||
|
import ConfluenceImportModal from "@/ee/confluence-import/components/confluence-import-modal";
|
||||||
|
import ConfluenceImportHistory from "@/ee/confluence-import/components/confluence-import-history";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
|
import { Feature } from "@/ee/features";
|
||||||
|
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||||
|
|
||||||
|
export default function ConfluenceImportPage() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
|
const hasConfluenceImport = useHasFeature(Feature.CONFLUENCE_API_IMPORT);
|
||||||
|
const upgradeLabel = useUpgradeLabel();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Import from Confluence")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
|
<SettingsTitle title={t("Import from Confluence")} />
|
||||||
|
|
||||||
|
<Paper withBorder p="lg" radius="md" mb="lg">
|
||||||
|
<Group align="flex-start" justify="space-between" wrap="nowrap">
|
||||||
|
<Group align="flex-start" wrap="nowrap">
|
||||||
|
<ConfluenceIcon size={32} />
|
||||||
|
<Stack gap={4}>
|
||||||
|
<Text fw={600}>{t("Confluence API import")}</Text>
|
||||||
|
<Text size="sm" c="dimmed" maw={560}>
|
||||||
|
{t(
|
||||||
|
"Connect to Confluence Cloud or Data Center to import spaces, pages, attachments, comments, users, groups and permissions directly via the API.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Tooltip label={upgradeLabel} disabled={hasConfluenceImport}>
|
||||||
|
<Button onClick={open} disabled={!hasConfluenceImport}>
|
||||||
|
{t("Start import")}
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</Group>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<Divider my="md" label={t("Import history")} labelPosition="left" />
|
||||||
|
|
||||||
|
<ConfluenceImportHistory />
|
||||||
|
|
||||||
|
<ConfluenceImportModal opened={opened} onClose={close} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { listConfluenceImports } from "@/ee/confluence-import/services/confluence-import-service";
|
||||||
|
|
||||||
|
export const confluenceImportsQueryKey = ["confluence-imports"] as const;
|
||||||
|
|
||||||
|
export function useConfluenceImportsQuery() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: confluenceImportsQueryKey,
|
||||||
|
queryFn: listConfluenceImports,
|
||||||
|
refetchInterval: (query) => {
|
||||||
|
const hasRunning = query.state.data?.items?.some(
|
||||||
|
(i) => i.status === "processing",
|
||||||
|
);
|
||||||
|
return hasRunning ? 3000 : false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import api from "@/lib/api-client";
|
||||||
|
import {
|
||||||
|
ConfluenceCredentials,
|
||||||
|
ImportStatusResponse,
|
||||||
|
ListImportsResponse,
|
||||||
|
ListSpacesResponse,
|
||||||
|
StartImportResponse,
|
||||||
|
TestConnectionResponse,
|
||||||
|
} from "@/ee/confluence-import/types/confluence-import.types";
|
||||||
|
|
||||||
|
export async function testConfluenceConnection(
|
||||||
|
data: ConfluenceCredentials,
|
||||||
|
): Promise<TestConnectionResponse> {
|
||||||
|
const req = await api.post<TestConnectionResponse>(
|
||||||
|
"/confluence-import/test-connection",
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listConfluenceSpaces(
|
||||||
|
data: ConfluenceCredentials,
|
||||||
|
): Promise<ListSpacesResponse> {
|
||||||
|
const req = await api.post<ListSpacesResponse>(
|
||||||
|
"/confluence-import/spaces",
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function startConfluenceImport(
|
||||||
|
data: ConfluenceCredentials & { spaceKeys?: string[] },
|
||||||
|
): Promise<StartImportResponse> {
|
||||||
|
const req = await api.post<StartImportResponse>(
|
||||||
|
"/confluence-import/start",
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getConfluenceImportStatus(
|
||||||
|
fileTaskId: string,
|
||||||
|
): Promise<ImportStatusResponse> {
|
||||||
|
const req = await api.post<ImportStatusResponse>(
|
||||||
|
"/confluence-import/status",
|
||||||
|
{ fileTaskId },
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listConfluenceImports(): Promise<ListImportsResponse> {
|
||||||
|
const req = await api.post<ListImportsResponse>("/confluence-import/history");
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function cancelConfluenceImport(
|
||||||
|
fileTaskId: string,
|
||||||
|
): Promise<{ success: boolean }> {
|
||||||
|
const req = await api.post<{ success: boolean }>(
|
||||||
|
"/confluence-import/cancel",
|
||||||
|
{ fileTaskId },
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
export type ConfluenceAuthType = "cloud_token" | "pat" | "basic";
|
||||||
|
|
||||||
|
export type ConfluenceCredentials = {
|
||||||
|
siteUrl: string;
|
||||||
|
authType: ConfluenceAuthType;
|
||||||
|
email?: string;
|
||||||
|
token?: string;
|
||||||
|
username?: string;
|
||||||
|
password?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ConfluenceSpaceSummary = {
|
||||||
|
id: string;
|
||||||
|
key: string;
|
||||||
|
name: string;
|
||||||
|
type?: string;
|
||||||
|
status?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TestConnectionResponse = {
|
||||||
|
success: boolean;
|
||||||
|
edition?: string;
|
||||||
|
spaceCount?: number;
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ListSpacesResponse = {
|
||||||
|
success: boolean;
|
||||||
|
spaces?: ConfluenceSpaceSummary[];
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StartImportResponse = {
|
||||||
|
success: boolean;
|
||||||
|
fileTaskId?: string;
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ConfluenceImportStatus = "processing" | "success" | "failed";
|
||||||
|
|
||||||
|
export type ImportStatusResponse = {
|
||||||
|
fileTaskId?: string;
|
||||||
|
status?: ConfluenceImportStatus;
|
||||||
|
errorMessage?: string | null;
|
||||||
|
currentPhase?: string | null;
|
||||||
|
totalSpaces?: number;
|
||||||
|
importedSpaces?: number;
|
||||||
|
totalPages?: number;
|
||||||
|
importedPages?: number;
|
||||||
|
totalUsers?: number;
|
||||||
|
importedUsers?: number;
|
||||||
|
totalGroups?: number;
|
||||||
|
importedGroups?: number;
|
||||||
|
totalRestrictedPages?: number;
|
||||||
|
importedRestrictedPages?: number;
|
||||||
|
createdAt?: string;
|
||||||
|
updatedAt?: string;
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ConfluenceImportHistoryItem = {
|
||||||
|
fileTaskId: string;
|
||||||
|
siteUrl: string;
|
||||||
|
status: ConfluenceImportStatus;
|
||||||
|
errorMessage: string | null;
|
||||||
|
currentPhase: string | null;
|
||||||
|
totalSpaces: number;
|
||||||
|
importedSpaces: number;
|
||||||
|
totalPages: number;
|
||||||
|
importedPages: number;
|
||||||
|
totalUsers: number;
|
||||||
|
importedUsers: number;
|
||||||
|
totalGroups: number;
|
||||||
|
importedGroups: number;
|
||||||
|
totalAttachments: number;
|
||||||
|
importedAttachments: number;
|
||||||
|
totalLabels: number;
|
||||||
|
importedLabels: number;
|
||||||
|
totalRestrictedPages: number;
|
||||||
|
importedRestrictedPages: number;
|
||||||
|
cancelled: boolean;
|
||||||
|
spaceKeys: string[];
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
creatorId: string | null;
|
||||||
|
creatorName: string | null;
|
||||||
|
creatorAvatarUrl: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ListImportsResponse = {
|
||||||
|
items: ConfluenceImportHistoryItem[];
|
||||||
|
};
|
||||||
@@ -7,6 +7,7 @@ export const Feature = {
|
|||||||
PAGE_PERMISSIONS: 'page:permissions',
|
PAGE_PERMISSIONS: 'page:permissions',
|
||||||
AI: 'ai',
|
AI: 'ai',
|
||||||
CONFLUENCE_IMPORT: 'import:confluence',
|
CONFLUENCE_IMPORT: 'import:confluence',
|
||||||
|
CONFLUENCE_API_IMPORT: 'import:confluence-api',
|
||||||
DOCX_IMPORT: 'import:docx',
|
DOCX_IMPORT: 'import:docx',
|
||||||
PDF_IMPORT: 'import:pdf',
|
PDF_IMPORT: 'import:pdf',
|
||||||
ATTACHMENT_INDEXING: 'attachment:indexing',
|
ATTACHMENT_INDEXING: 'attachment:indexing',
|
||||||
@@ -22,5 +23,4 @@ export const Feature = {
|
|||||||
PERSONAL_SPACES: 'spaces:personal',
|
PERSONAL_SPACES: 'spaces:personal',
|
||||||
DOCX_EXPORT: 'export:docx',
|
DOCX_EXPORT: 'export:docx',
|
||||||
BASES: 'bases',
|
BASES: 'bases',
|
||||||
AI_CONTROLS: 'ai:controls',
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -53,7 +53,14 @@ export function PagePermissionItem({
|
|||||||
{isCurrentUser && <Text span c="dimmed"> ({t("You")})</Text>}
|
{isCurrentUser && <Text span c="dimmed"> ({t("You")})</Text>}
|
||||||
</AutoTooltipText>
|
</AutoTooltipText>
|
||||||
<AutoTooltipText fz="xs" c="dimmed">
|
<AutoTooltipText fz="xs" c="dimmed">
|
||||||
{member.type === "user" ? member.email : formatMemberCount(member.memberCount, t)}
|
{member.type === "user"
|
||||||
|
? member.email
|
||||||
|
: member.isDefault
|
||||||
|
? // Page access still requires space membership, so the
|
||||||
|
// workspace-wide member count would overstate who can
|
||||||
|
// actually see the page.
|
||||||
|
t("Everyone with access to this space")
|
||||||
|
: formatMemberCount(member.memberCount, t)}
|
||||||
</AutoTooltipText>
|
</AutoTooltipText>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -166,6 +166,18 @@ export default function useAuth() {
|
|||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
setCurrentUser(RESET);
|
setCurrentUser(RESET);
|
||||||
await logout();
|
await logout();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (typeof indexedDB?.databases === "function") {
|
||||||
|
const dbs = await indexedDB.databases();
|
||||||
|
dbs
|
||||||
|
.filter((db) => db.name?.startsWith("page."))
|
||||||
|
.forEach((db) => indexedDB.deleteDatabase(db.name!));
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
window.location.replace(`${APP_ROUTE.AUTH.LOGIN}?logout=1`);
|
window.location.replace(`${APP_ROUTE.AUTH.LOGIN}?logout=1`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
} from "@/features/comment/atoms/comment-atom";
|
} from "@/features/comment/atoms/comment-atom";
|
||||||
import CommentEditor from "@/features/comment/components/comment-editor";
|
import CommentEditor from "@/features/comment/components/comment-editor";
|
||||||
import CommentActions from "@/features/comment/components/comment-actions";
|
import CommentActions from "@/features/comment/components/comment-actions";
|
||||||
|
import { CommentErrorBoundary } from "@/features/comment/components/comment-error-boundary";
|
||||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom";
|
import { currentUserAtom } from "@/features/user/atoms/current-user-atom";
|
||||||
import { useCreateCommentMutation } from "@/features/comment/queries/comment-query";
|
import { useCreateCommentMutation } from "@/features/comment/queries/comment-query";
|
||||||
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom";
|
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom";
|
||||||
@@ -170,14 +171,16 @@ function CommentDialog({ editor, pageId, readOnly }: CommentDialogProps) {
|
|||||||
</div>
|
</div>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<CommentEditor
|
<CommentErrorBoundary>
|
||||||
onUpdate={handleCommentEditorChange}
|
<CommentEditor
|
||||||
onSave={handleAddComment}
|
onUpdate={handleCommentEditorChange}
|
||||||
placeholder={t("Write a comment")}
|
onSave={handleAddComment}
|
||||||
editable={true}
|
placeholder={t("Write a comment")}
|
||||||
autofocus={true}
|
editable={true}
|
||||||
/>
|
autofocus={true}
|
||||||
<CommentActions onSave={handleAddComment} isLoading={isPending} />
|
/>
|
||||||
|
<CommentActions onSave={handleAddComment} isLoading={isPending} />
|
||||||
|
</CommentErrorBoundary>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { EditorContent, ReactNodeViewRenderer, useEditor } from "@tiptap/react";
|
import { EditorContent, ReactNodeViewRenderer, useEditor } from "@tiptap/react";
|
||||||
import { Placeholder } from "@tiptap/extension-placeholder";
|
import { Placeholder } from "@tiptap/extension-placeholder";
|
||||||
import { StarterKit } from "@tiptap/starter-kit";
|
import { StarterKit } from "@tiptap/starter-kit";
|
||||||
import { Mention, LinkExtension } from "@docmost/editor-ext";
|
import { TextStyle } from "@tiptap/extension-text-style";
|
||||||
|
import { Mention, LinkExtension, Color } from "@docmost/editor-ext";
|
||||||
import classes from "./comment.module.css";
|
import classes from "./comment.module.css";
|
||||||
import { useFocusWithin } from "@mantine/hooks";
|
import { useFocusWithin } from "@mantine/hooks";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
@@ -11,6 +12,8 @@ import EmojiCommand from "@/features/editor/extensions/emoji-command";
|
|||||||
import mentionRenderItems from "@/features/editor/components/mention/mention-suggestion";
|
import mentionRenderItems from "@/features/editor/components/mention/mention-suggestion";
|
||||||
import MentionView from "@/features/editor/components/mention/mention-view";
|
import MentionView from "@/features/editor/components/mention/mention-view";
|
||||||
import { platformModifierKey } from "@/lib";
|
import { platformModifierKey } from "@/lib";
|
||||||
|
import { TableKit } from "@tiptap/extension-table";
|
||||||
|
import { TaskList, TaskItem } from "@tiptap/extension-list";
|
||||||
|
|
||||||
interface CommentEditorProps {
|
interface CommentEditorProps {
|
||||||
defaultContent?: any;
|
defaultContent?: any;
|
||||||
@@ -49,6 +52,8 @@ const CommentEditor = forwardRef(
|
|||||||
placeholder: placeholder || t("Reply..."),
|
placeholder: placeholder || t("Reply..."),
|
||||||
}),
|
}),
|
||||||
LinkExtension,
|
LinkExtension,
|
||||||
|
TextStyle,
|
||||||
|
Color,
|
||||||
EmojiCommand,
|
EmojiCommand,
|
||||||
Mention.configure({
|
Mention.configure({
|
||||||
suggestion: {
|
suggestion: {
|
||||||
@@ -66,6 +71,11 @@ const CommentEditor = forwardRef(
|
|||||||
return ReactNodeViewRenderer(MentionView);
|
return ReactNodeViewRenderer(MentionView);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
TableKit,
|
||||||
|
TaskList,
|
||||||
|
TaskItem.configure({
|
||||||
|
nested: true,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
editorProps: {
|
editorProps: {
|
||||||
attributes: {
|
attributes: {
|
||||||
@@ -113,7 +123,12 @@ const CommentEditor = forwardRef(
|
|||||||
// websocket on another browser). Skip for editable editors to avoid
|
// websocket on another browser). Skip for editable editors to avoid
|
||||||
// resetting the cursor position on every keystroke.
|
// resetting the cursor position on every keystroke.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!editable && commentEditor && !commentEditor.isDestroyed && defaultContent) {
|
if (
|
||||||
|
!editable &&
|
||||||
|
commentEditor &&
|
||||||
|
!commentEditor.isDestroyed &&
|
||||||
|
defaultContent
|
||||||
|
) {
|
||||||
commentEditor.commands.setContent(defaultContent);
|
commentEditor.commands.setContent(defaultContent);
|
||||||
}
|
}
|
||||||
}, [defaultContent, editable, commentEditor]);
|
}, [defaultContent, editable, commentEditor]);
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { ReactNode } from "react";
|
||||||
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
import { Button } from "@mantine/core";
|
||||||
|
import { IconAlertTriangle } from "@tabler/icons-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { EmptyState } from "@/components/ui/empty-state.tsx";
|
||||||
|
|
||||||
|
type CommentErrorBoundaryProps = {
|
||||||
|
children: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Contain comment-editor render throws (e.g. schema errors) so they don't unmount the whole app.
|
||||||
|
export function CommentErrorBoundary({ children }: CommentErrorBoundaryProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ErrorBoundary
|
||||||
|
fallbackRender={({ resetErrorBoundary }) => (
|
||||||
|
<EmptyState
|
||||||
|
icon={IconAlertTriangle}
|
||||||
|
title={t("Failed to load comments. An error occurred.")}
|
||||||
|
action={
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
size="sm"
|
||||||
|
mt="xs"
|
||||||
|
onClick={resetErrorBoundary}
|
||||||
|
>
|
||||||
|
{t("Try again")}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</ErrorBoundary>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -53,6 +53,10 @@
|
|||||||
margin-block-end: 0;
|
margin-block-end: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ProseMirror :global(.tableWrapper) table {
|
||||||
|
min-width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,6 @@ export const showAiMenuAtom = atom(false);
|
|||||||
|
|
||||||
export const showLinkMenuAtom = atom(false);
|
export const showLinkMenuAtom = atom(false);
|
||||||
|
|
||||||
export type LightboxRequest = {
|
|
||||||
src: string;
|
|
||||||
type: "image" | "video";
|
|
||||||
} | null;
|
|
||||||
|
|
||||||
const initialLightboxRequest: LightboxRequest = null;
|
|
||||||
export const lightboxRequestAtom = atom(initialLightboxRequest);
|
|
||||||
|
|
||||||
// Current page's edit mode — initialized from the user's saved preference on
|
// Current page's edit mode — initialized from the user's saved preference on
|
||||||
// first load, can be toggled locally without persisting to the server.
|
// first load, can be toggled locally without persisting to the server.
|
||||||
export const currentPageEditModeAtom = atom<PageEditMode>(PageEditMode.Edit);
|
export const currentPageEditModeAtom = atom<PageEditMode>(PageEditMode.Edit);
|
||||||
|
|||||||
@@ -23,21 +23,11 @@ import {
|
|||||||
} from "@/features/comment/atoms/comment-atom";
|
} from "@/features/comment/atoms/comment-atom";
|
||||||
import { useAtom, useAtomValue } from "jotai";
|
import { useAtom, useAtomValue } from "jotai";
|
||||||
import { v7 as uuid7 } from "uuid";
|
import { v7 as uuid7 } from "uuid";
|
||||||
import {
|
import { isCellSelection, isEditorReady, isTextSelected } from "@docmost/editor-ext";
|
||||||
isCellSelection,
|
|
||||||
isEditorReady,
|
|
||||||
isTextSelected,
|
|
||||||
} from "@docmost/editor-ext";
|
|
||||||
import { LinkSelector } from "@/features/editor/components/bubble-menu/link-selector.tsx";
|
import { LinkSelector } from "@/features/editor/components/bubble-menu/link-selector.tsx";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import { showAiMenuAtom, showLinkMenuAtom } from "@/features/editor/atoms/editor-atoms";
|
||||||
showAiMenuAtom,
|
import { userAtom, workspaceAtom } from "@/features/user/atoms/current-user-atom";
|
||||||
showLinkMenuAtom,
|
|
||||||
} from "@/features/editor/atoms/editor-atoms";
|
|
||||||
import {
|
|
||||||
userAtom,
|
|
||||||
workspaceAtom,
|
|
||||||
} from "@/features/user/atoms/current-user-atom";
|
|
||||||
|
|
||||||
export interface BubbleMenuItem {
|
export interface BubbleMenuItem {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -227,12 +217,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
|
|
||||||
<ActionIcon.Group>
|
<ActionIcon.Group>
|
||||||
{items.map((item, index) => (
|
{items.map((item, index) => (
|
||||||
<Tooltip
|
<Tooltip key={index} label={t(item.name)} withArrow>
|
||||||
key={index}
|
|
||||||
label={t(item.name)}
|
|
||||||
withArrow
|
|
||||||
withinPortal={false}
|
|
||||||
>
|
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
key={index}
|
key={index}
|
||||||
variant="default"
|
variant="default"
|
||||||
@@ -241,9 +226,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
aria-label={t(item.name)}
|
aria-label={t(item.name)}
|
||||||
className={clsx({ [classes.active]: item.isActive() })}
|
className={clsx({ [classes.active]: item.isActive() })}
|
||||||
style={{ border: "none" }}
|
style={{ border: "none" }}
|
||||||
onClick={() =>
|
onClick={() => isEditorReady(props.editor) && item.command()}
|
||||||
isEditorReady(props.editor) && item.command()
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<item.icon style={{ width: rem(16) }} stroke={2} />
|
<item.icon style={{ width: rem(16) }} stroke={2} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -273,9 +256,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
radius="6px"
|
radius="6px"
|
||||||
aria-label={t(commentItem.name)}
|
aria-label={t(commentItem.name)}
|
||||||
style={{ border: "none" }}
|
style={{ border: "none" }}
|
||||||
onClick={() =>
|
onClick={() => isEditorReady(props.editor) && commentItem.command()}
|
||||||
isEditorReady(props.editor) && commentItem.command()
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<IconMessage size={16} stroke={2} />
|
<IconMessage size={16} stroke={2} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ function handleColorKeyNav(
|
|||||||
grid: "text" | "highlight",
|
grid: "text" | "highlight",
|
||||||
) {
|
) {
|
||||||
const cols = COLOR_GRID_COLS;
|
const cols = COLOR_GRID_COLS;
|
||||||
const total = grid === "text" ? TEXT_COLORS.length : HIGHLIGHT_COLORS.length;
|
const total =
|
||||||
|
grid === "text" ? TEXT_COLORS.length : HIGHLIGHT_COLORS.length;
|
||||||
const col = index % cols;
|
const col = index % cols;
|
||||||
|
|
||||||
if (e.key === "ArrowRight") {
|
if (e.key === "ArrowRight") {
|
||||||
@@ -162,7 +163,8 @@ function handleColorKeyNav(
|
|||||||
if (prev >= 0) {
|
if (prev >= 0) {
|
||||||
focusSwatch(grid, prev);
|
focusSwatch(grid, prev);
|
||||||
} else if (grid === "highlight") {
|
} else if (grid === "highlight") {
|
||||||
const lastRowStart = Math.floor((TEXT_COLORS.length - 1) / cols) * cols;
|
const lastRowStart =
|
||||||
|
Math.floor((TEXT_COLORS.length - 1) / cols) * cols;
|
||||||
focusSwatch("text", Math.min(lastRowStart + col, TEXT_COLORS.length - 1));
|
focusSwatch("text", Math.min(lastRowStart + col, TEXT_COLORS.length - 1));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -220,7 +222,7 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
|
|||||||
withArrow
|
withArrow
|
||||||
>
|
>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
<Tooltip label={t("Text color")} withArrow withinPortal={false}>
|
<Tooltip label={t("Text color")} withArrow>
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
radius="0"
|
radius="0"
|
||||||
@@ -245,26 +247,26 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
|
|||||||
|
|
||||||
<Popover.Dropdown onMouseDown={(e) => e.preventDefault()}>
|
<Popover.Dropdown onMouseDown={(e) => e.preventDefault()}>
|
||||||
<Stack gap="md" p="2px">
|
<Stack gap="md" p="2px">
|
||||||
<Box>
|
<Box>
|
||||||
<Text size="sm" fw={600} mb="xs">
|
<Text size="sm" fw={600} mb="xs">
|
||||||
{t("Text color")}
|
{t("Text color")}
|
||||||
</Text>
|
</Text>
|
||||||
<SimpleGrid cols={5} spacing="xs">
|
<SimpleGrid cols={5} spacing="xs">
|
||||||
{TEXT_COLORS.map(({ name, color }, index) => {
|
{TEXT_COLORS.map(({ name, color }, index) => {
|
||||||
const applyTextColor = () => {
|
const applyTextColor = () => {
|
||||||
if (!isEditorReady(editor)) return;
|
if (!isEditorReady(editor)) return;
|
||||||
if (name === "Default") {
|
if (name === "Default") {
|
||||||
editor.commands.unsetColor();
|
editor.commands.unsetColor();
|
||||||
} else {
|
} else {
|
||||||
editor
|
editor
|
||||||
.chain()
|
.chain()
|
||||||
.focus()
|
.focus()
|
||||||
.setColor(color || "")
|
.setColor(color || "")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Tooltip key={index} label={t(name)} withArrow>
|
<Tooltip key={index} label={t(name)} withArrow>
|
||||||
<Box
|
<Box
|
||||||
role="button"
|
role="button"
|
||||||
@@ -304,34 +306,34 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
|
|||||||
A
|
A
|
||||||
</Box>
|
</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<Text size="sm" fw={600} mb="xs">
|
<Text size="sm" fw={600} mb="xs">
|
||||||
{t("Highlight color")}
|
{t("Highlight color")}
|
||||||
</Text>
|
</Text>
|
||||||
<SimpleGrid cols={5} spacing="xs">
|
<SimpleGrid cols={5} spacing="xs">
|
||||||
{HIGHLIGHT_COLORS.map(({ name, color }, index) => {
|
{HIGHLIGHT_COLORS.map(({ name, color }, index) => {
|
||||||
const applyHighlight = () => {
|
const applyHighlight = () => {
|
||||||
if (!isEditorReady(editor)) return;
|
if (!isEditorReady(editor)) return;
|
||||||
if (name === "Default") {
|
if (name === "Default") {
|
||||||
editor.commands.unsetHighlight();
|
editor.commands.unsetHighlight();
|
||||||
} else {
|
} else {
|
||||||
editor
|
editor
|
||||||
.chain()
|
.chain()
|
||||||
.focus()
|
.focus()
|
||||||
.toggleMark("highlight", {
|
.toggleMark("highlight", {
|
||||||
color: color || "",
|
color: color || "",
|
||||||
colorName: name.toLowerCase() || "",
|
colorName: name.toLowerCase() || "",
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Tooltip key={index} label={t(name)} withArrow>
|
<Tooltip key={index} label={t(name)} withArrow>
|
||||||
<Box
|
<Box
|
||||||
role="button"
|
role="button"
|
||||||
@@ -376,36 +378,37 @@ export const ColorSelector: FC<ColorSelectorProps> = ({
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
fullWidth
|
fullWidth
|
||||||
data-color-grid="remove"
|
data-color-grid="remove"
|
||||||
className={classes.removeColor}
|
className={classes.removeColor}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (isEditorReady(editor)) {
|
if (isEditorReady(editor)) {
|
||||||
editor.commands.unsetColor();
|
editor.commands.unsetColor();
|
||||||
editor.commands.unsetHighlight();
|
editor.commands.unsetHighlight();
|
||||||
}
|
}
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}}
|
}}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === "ArrowUp") {
|
if (e.key === "ArrowUp") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const lastRowStart =
|
const lastRowStart =
|
||||||
Math.floor((HIGHLIGHT_COLORS.length - 1) / COLOR_GRID_COLS) *
|
Math.floor(
|
||||||
COLOR_GRID_COLS;
|
(HIGHLIGHT_COLORS.length - 1) / COLOR_GRID_COLS,
|
||||||
focusSwatch("highlight", lastRowStart);
|
) * COLOR_GRID_COLS;
|
||||||
}
|
focusSwatch("highlight", lastRowStart);
|
||||||
}}
|
}
|
||||||
>
|
}}
|
||||||
{t("Remove color")}
|
>
|
||||||
</Button>
|
{t("Remove color")}
|
||||||
</Stack>
|
</Button>
|
||||||
|
</Stack>
|
||||||
</Popover.Dropdown>
|
</Popover.Dropdown>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const LinkSelector: FC = () => {
|
|||||||
const setShowLinkMenu = useSetAtom(showLinkMenuAtom);
|
const setShowLinkMenu = useSetAtom(showLinkMenuAtom);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip label={t("Add link")} withArrow withinPortal={false}>
|
<Tooltip label={t("Add link")} withArrow>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
variant="default"
|
variant="default"
|
||||||
size="lg"
|
size="lg"
|
||||||
|
|||||||
@@ -91,12 +91,7 @@ export const TextAlignmentSelector: FC<TextAlignmentProps> = ({
|
|||||||
onChange={setIsOpen}
|
onChange={setIsOpen}
|
||||||
>
|
>
|
||||||
<Menu.Target>
|
<Menu.Target>
|
||||||
<Tooltip
|
<Tooltip label={t("Text align")} withArrow disabled={isOpen}>
|
||||||
label={t("Text align")}
|
|
||||||
withArrow
|
|
||||||
disabled={isOpen}
|
|
||||||
withinPortal={false}
|
|
||||||
>
|
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
style={{ border: "none", height: "34px" }}
|
style={{ border: "none", height: "34px" }}
|
||||||
|
|||||||
@@ -1,176 +0,0 @@
|
|||||||
import type { Editor } from "@tiptap/react";
|
|
||||||
import type { Node as PMNode } from "@tiptap/pm/model";
|
|
||||||
import Lightbox, { type Slide } from "yet-another-react-lightbox";
|
|
||||||
import type { LightboxRequest } from "@/features/editor/atoms/editor-atoms";
|
|
||||||
import { getFileUrl } from "@/lib/config.ts";
|
|
||||||
import "yet-another-react-lightbox/styles.css";
|
|
||||||
import "yet-another-react-lightbox/plugins/captions.css";
|
|
||||||
import Captions from "yet-another-react-lightbox/plugins/captions";
|
|
||||||
import Download from "yet-another-react-lightbox/plugins/download";
|
|
||||||
import Fullscreen from "yet-another-react-lightbox/plugins/fullscreen";
|
|
||||||
import Video from "yet-another-react-lightbox/plugins/video";
|
|
||||||
import Zoom from "yet-another-react-lightbox/plugins/zoom";
|
|
||||||
import { useEffect, useMemo, useState } from "react";
|
|
||||||
import i18n from "@/i18n.ts";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
type LightboxViewProps = {
|
|
||||||
editor: Editor;
|
|
||||||
open: boolean;
|
|
||||||
src: string;
|
|
||||||
type: "image" | "video";
|
|
||||||
onClose: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
function getVideoMimeType(src: string) {
|
|
||||||
const extension = src.split(/[?#]/, 1)[0].split(".").pop()?.toLowerCase();
|
|
||||||
|
|
||||||
switch (extension) {
|
|
||||||
case "webm":
|
|
||||||
return "video/webm";
|
|
||||||
case "ogv":
|
|
||||||
return "video/ogg";
|
|
||||||
case "mov":
|
|
||||||
return "video/quicktime";
|
|
||||||
case "m4v":
|
|
||||||
return "video/x-m4v";
|
|
||||||
default:
|
|
||||||
return "video/mp4";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFilename(src: string) {
|
|
||||||
const filename = src.split(/[?#]/, 1)[0].split("/").pop();
|
|
||||||
if (!filename) return i18n.t("Media");
|
|
||||||
|
|
||||||
try {
|
|
||||||
return decodeURIComponent(filename);
|
|
||||||
} catch {
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMedia(rawSrc: string, type?: string, alt?: string): Slide {
|
|
||||||
const src = getFileUrl(rawSrc);
|
|
||||||
const filename = getFilename(rawSrc);
|
|
||||||
const caption = alt || filename;
|
|
||||||
|
|
||||||
if (type === "video") {
|
|
||||||
return {
|
|
||||||
type: "video",
|
|
||||||
sources: [{ src, type: getVideoMimeType(rawSrc) }],
|
|
||||||
title: caption,
|
|
||||||
download: { url: src, filename },
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
type: "image",
|
|
||||||
src,
|
|
||||||
alt: alt || undefined,
|
|
||||||
title: caption,
|
|
||||||
download: { url: src, filename },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const LIGHTBOX_NODE_TYPES: Record<string, "image" | "video"> = {
|
|
||||||
image: "image",
|
|
||||||
video: "video",
|
|
||||||
drawio: "image",
|
|
||||||
excalidraw: "image",
|
|
||||||
};
|
|
||||||
|
|
||||||
// video is excluded: clicks there operate the native controls
|
|
||||||
const CLICK_TO_EXPAND_NODE_TYPES = new Set(["image", "drawio", "excalidraw"]);
|
|
||||||
|
|
||||||
export function getLightboxClickRequest(node: PMNode): LightboxRequest {
|
|
||||||
if (!CLICK_TO_EXPAND_NODE_TYPES.has(node.type.name)) return null;
|
|
||||||
|
|
||||||
const src = typeof node.attrs.src === "string" ? node.attrs.src : "";
|
|
||||||
if (!src) return null;
|
|
||||||
|
|
||||||
return { src: getFileUrl(src), type: "image" };
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPageMedia(editor: Editor): Slide[] {
|
|
||||||
const media: Slide[] = [];
|
|
||||||
|
|
||||||
editor.state.doc.descendants((node) => {
|
|
||||||
const type = LIGHTBOX_NODE_TYPES[node.type.name];
|
|
||||||
if (!type) return;
|
|
||||||
|
|
||||||
const rawSrc = typeof node.attrs.src === "string" ? node.attrs.src : "";
|
|
||||||
if (!rawSrc) return;
|
|
||||||
|
|
||||||
media.push(getMedia(rawSrc, type, node.attrs.alt));
|
|
||||||
});
|
|
||||||
|
|
||||||
return media;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function LightboxView({
|
|
||||||
editor,
|
|
||||||
open,
|
|
||||||
src,
|
|
||||||
type,
|
|
||||||
onClose,
|
|
||||||
}: LightboxViewProps) {
|
|
||||||
const { i18n: i18nInstance } = useTranslation();
|
|
||||||
|
|
||||||
const selectedSlide = useMemo(
|
|
||||||
() => getMedia(src, type),
|
|
||||||
[src, type, i18nInstance.language]
|
|
||||||
);
|
|
||||||
|
|
||||||
const [pageSlides, setPageSlides] = useState<Slide[]>([]);
|
|
||||||
const [loadedMediaKey, setLoadedMediaKey] = useState<string | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!open) return;
|
|
||||||
|
|
||||||
setLoadedMediaKey(null);
|
|
||||||
|
|
||||||
const frame = requestAnimationFrame(() => {
|
|
||||||
const slides = getPageMedia(editor);
|
|
||||||
|
|
||||||
setPageSlides(slides);
|
|
||||||
setLoadedMediaKey(`${type}:${src}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => cancelAnimationFrame(frame);
|
|
||||||
}, [editor, open, type, src]);
|
|
||||||
|
|
||||||
const slides = loadedMediaKey === `${type}:${src}` ? pageSlides : [selectedSlide];
|
|
||||||
|
|
||||||
const index = useMemo(() => {
|
|
||||||
if (!(pageSlides.length > 0)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const idx = slides.findIndex((slide) =>
|
|
||||||
type === "video"
|
|
||||||
? "sources" in slide && slide.sources.some((s) => s.src === src)
|
|
||||||
: "src" in slide && slide.src === src
|
|
||||||
);
|
|
||||||
return idx >= 0 ? idx : 0;
|
|
||||||
}, [slides, src, type]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Lightbox
|
|
||||||
open={open}
|
|
||||||
close={onClose}
|
|
||||||
index={index}
|
|
||||||
slides={slides}
|
|
||||||
plugins={[Captions, Download, Fullscreen, Video, Zoom]}
|
|
||||||
styles={{ container: { backgroundColor: "rgba(0, 0, 0, 0.8)" } }}
|
|
||||||
captions={{ descriptionTextAlign: "center" }}
|
|
||||||
video={{ controls: true, playsInline: true }}
|
|
||||||
zoom={{
|
|
||||||
scrollToZoom: true,
|
|
||||||
maxZoomPixelRatio: 4,
|
|
||||||
maxZoom: 4,
|
|
||||||
supports: ["video"],
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { useSetAtom } from "jotai";
|
|
||||||
import { Node as PMNode } from "@tiptap/pm/model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import { isEditorReady } from "@docmost/editor-ext";
|
import { isEditorReady } from "@docmost/editor-ext";
|
||||||
import {
|
import {
|
||||||
@@ -25,7 +24,6 @@ import {
|
|||||||
IconDownload,
|
IconDownload,
|
||||||
IconEdit,
|
IconEdit,
|
||||||
IconTrash,
|
IconTrash,
|
||||||
IconZoomIn,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { getDrawioUrl, getFileUrl } from "@/lib/config.ts";
|
import { getDrawioUrl, getFileUrl } from "@/lib/config.ts";
|
||||||
@@ -41,12 +39,10 @@ import { decodeBase64ToSvgString, svgStringToFile } from "@/lib/utils";
|
|||||||
import { IAttachment } from "@/features/attachments/types/attachment.types";
|
import { IAttachment } from "@/features/attachments/types/attachment.types";
|
||||||
import { modals } from "@mantine/modals";
|
import { modals } from "@mantine/modals";
|
||||||
import { useAltTextControl } from "@/features/editor/components/common/use-alt-text-control.tsx";
|
import { useAltTextControl } from "@/features/editor/components/common/use-alt-text-control.tsx";
|
||||||
import { lightboxRequestAtom } from "@/features/editor/atoms/editor-atoms";
|
|
||||||
import classes from "../common/toolbar-menu.module.css";
|
import classes from "../common/toolbar-menu.module.css";
|
||||||
|
|
||||||
export function DrawioMenu({ editor }: EditorMenuProps) {
|
export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const setLightboxRequest = useSetAtom(lightboxRequestAtom);
|
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [initialXML, setInitialXML] = useState<string>("");
|
const [initialXML, setInitialXML] = useState<string>("");
|
||||||
const drawioRef = useRef<DrawIoEmbedRef>(null);
|
const drawioRef = useRef<DrawIoEmbedRef>(null);
|
||||||
@@ -332,23 +328,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
|
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Expand")} withinPortal={false}>
|
|
||||||
<ActionIcon
|
|
||||||
onClick={() =>
|
|
||||||
editorState?.src &&
|
|
||||||
setLightboxRequest({
|
|
||||||
src: getFileUrl(editorState.src),
|
|
||||||
type: "image",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
size="lg"
|
|
||||||
aria-label={t("Expand")}
|
|
||||||
variant="subtle"
|
|
||||||
>
|
|
||||||
<IconZoomIn size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Edit")} withinPortal={false}>
|
<Tooltip position="top" label={t("Edit")} withinPortal={false}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onClick={handleOpen}
|
onClick={handleOpen}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
|
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { useSetAtom } from "jotai";
|
|
||||||
import { Node as PMNode } from "@tiptap/pm/model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import { isEditorReady } from "@docmost/editor-ext";
|
import { isEditorReady } from "@docmost/editor-ext";
|
||||||
import {
|
import {
|
||||||
@@ -26,7 +25,6 @@ import {
|
|||||||
IconDownload,
|
IconDownload,
|
||||||
IconEdit,
|
IconEdit,
|
||||||
IconTrash,
|
IconTrash,
|
||||||
IconZoomIn,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { getFileUrl } from "@/lib/config.ts";
|
import { getFileUrl } from "@/lib/config.ts";
|
||||||
@@ -39,7 +37,6 @@ import ReactClearModal from "react-clear-modal";
|
|||||||
import { useHandleLibrary } from "@excalidraw/excalidraw";
|
import { useHandleLibrary } from "@excalidraw/excalidraw";
|
||||||
import { localStorageLibraryAdapter } from "@/features/editor/components/excalidraw/excalidraw-utils.ts";
|
import { localStorageLibraryAdapter } from "@/features/editor/components/excalidraw/excalidraw-utils.ts";
|
||||||
import { useAltTextControl } from "@/features/editor/components/common/use-alt-text-control.tsx";
|
import { useAltTextControl } from "@/features/editor/components/common/use-alt-text-control.tsx";
|
||||||
import { lightboxRequestAtom } from "@/features/editor/atoms/editor-atoms";
|
|
||||||
import classes from "../common/toolbar-menu.module.css";
|
import classes from "../common/toolbar-menu.module.css";
|
||||||
|
|
||||||
const ExcalidrawComponent = lazy(() =>
|
const ExcalidrawComponent = lazy(() =>
|
||||||
@@ -50,7 +47,6 @@ const ExcalidrawComponent = lazy(() =>
|
|||||||
|
|
||||||
export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const setLightboxRequest = useSetAtom(lightboxRequestAtom);
|
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [excalidrawAPI, setExcalidrawAPI] =
|
const [excalidrawAPI, setExcalidrawAPI] =
|
||||||
useState<ExcalidrawImperativeAPI>(null);
|
useState<ExcalidrawImperativeAPI>(null);
|
||||||
@@ -363,23 +359,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
|
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Expand")} withinPortal={false}>
|
|
||||||
<ActionIcon
|
|
||||||
onClick={() =>
|
|
||||||
editorState?.src &&
|
|
||||||
setLightboxRequest({
|
|
||||||
src: getFileUrl(editorState.src),
|
|
||||||
type: "image",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
size="lg"
|
|
||||||
aria-label={t("Expand")}
|
|
||||||
variant="subtle"
|
|
||||||
>
|
|
||||||
<IconZoomIn size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Edit")} withinPortal={false}>
|
<Tooltip position="top" label={t("Edit")} withinPortal={false}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onClick={handleOpen}
|
onClick={handleOpen}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import React, { useCallback, useRef } from "react";
|
import React, { useCallback, useRef } from "react";
|
||||||
import { useSetAtom } from "jotai";
|
|
||||||
import { Node as PMNode } from "@tiptap/pm/model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import { isEditorReady } from "@docmost/editor-ext";
|
import { isEditorReady } from "@docmost/editor-ext";
|
||||||
import {
|
import {
|
||||||
@@ -17,19 +16,16 @@ import {
|
|||||||
IconDownload,
|
IconDownload,
|
||||||
IconRefresh,
|
IconRefresh,
|
||||||
IconTrash,
|
IconTrash,
|
||||||
IconZoomIn,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { getFileUrl } from "@/lib/config.ts";
|
import { getFileUrl } from "@/lib/config.ts";
|
||||||
import { uploadImageAction } from "@/features/editor/components/image/upload-image-action.tsx";
|
import { uploadImageAction } from "@/features/editor/components/image/upload-image-action.tsx";
|
||||||
import { useAltTextControl } from "@/features/editor/components/common/use-alt-text-control.tsx";
|
import { useAltTextControl } from "@/features/editor/components/common/use-alt-text-control.tsx";
|
||||||
import { lightboxRequestAtom } from "@/features/editor/atoms/editor-atoms";
|
|
||||||
import classes from "../common/toolbar-menu.module.css";
|
import classes from "../common/toolbar-menu.module.css";
|
||||||
|
|
||||||
export function ImageMenu({ editor }: EditorMenuProps) {
|
export function ImageMenu({ editor }: EditorMenuProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const setLightboxRequest = useSetAtom(lightboxRequestAtom);
|
|
||||||
|
|
||||||
const editorState = useEditorState({
|
const editorState = useEditorState({
|
||||||
editor,
|
editor,
|
||||||
@@ -211,23 +207,6 @@ export function ImageMenu({ editor }: EditorMenuProps) {
|
|||||||
|
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Expand")} withinPortal={false}>
|
|
||||||
<ActionIcon
|
|
||||||
onClick={() =>
|
|
||||||
editorState?.src &&
|
|
||||||
setLightboxRequest({
|
|
||||||
src: getFileUrl(editorState.src),
|
|
||||||
type: "image",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
size="lg"
|
|
||||||
aria-label={t("Expand")}
|
|
||||||
variant="subtle"
|
|
||||||
>
|
|
||||||
<IconZoomIn size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Download")} withinPortal={false}>
|
<Tooltip position="top" label={t("Download")} withinPortal={false}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onClick={handleDownload}
|
onClick={handleDownload}
|
||||||
|
|||||||
@@ -13,21 +13,14 @@ import {
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { sortPositionKeys } from "@/features/page/tree/utils/utils";
|
import { sortPositionKeys } from "@/features/page/tree/utils/utils";
|
||||||
import { useSharedPageSubpages } from "@/features/share/hooks/use-shared-page-subpages";
|
import { useSharedPageSubpages } from "@/features/share/hooks/use-shared-page-subpages";
|
||||||
import { extractPageSlugId } from "@/lib";
|
|
||||||
|
|
||||||
export default function SubpagesView(props: NodeViewProps) {
|
export default function SubpagesView(props: NodeViewProps) {
|
||||||
const { editor } = props;
|
const { editor } = props;
|
||||||
const { spaceSlug, shareId, pageSlug } = useParams();
|
const { spaceSlug, shareId } = useParams();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
// @ts-ignore
|
//@ts-ignore
|
||||||
const storagePageId = editor.storage.pageId;
|
const currentPageId = editor.storage.pageId;
|
||||||
const routePageId = extractPageSlugId(pageSlug);
|
|
||||||
let currentPageId = storagePageId;
|
|
||||||
|
|
||||||
if (shareId){
|
|
||||||
currentPageId = routePageId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get subpages from shared tree if we're in a shared context
|
// Get subpages from shared tree if we're in a shared context
|
||||||
const sharedSubpages = useSharedPageSubpages(currentPageId);
|
const sharedSubpages = useSharedPageSubpages(currentPageId);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { useSetAtom } from "jotai";
|
|
||||||
import { Node as PMNode } from "@tiptap/pm/model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import { isEditorReady } from "@docmost/editor-ext";
|
import { isEditorReady } from "@docmost/editor-ext";
|
||||||
import {
|
import {
|
||||||
@@ -16,17 +15,14 @@ import {
|
|||||||
IconLayoutAlignRight,
|
IconLayoutAlignRight,
|
||||||
IconDownload,
|
IconDownload,
|
||||||
IconTrash,
|
IconTrash,
|
||||||
IconZoomIn,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { getFileUrl } from "@/lib/config.ts";
|
import { getFileUrl } from "@/lib/config.ts";
|
||||||
import { useAltTextControl } from "@/features/editor/components/common/use-alt-text-control.tsx";
|
import { useAltTextControl } from "@/features/editor/components/common/use-alt-text-control.tsx";
|
||||||
import { lightboxRequestAtom } from "@/features/editor/atoms/editor-atoms";
|
|
||||||
import classes from "../common/toolbar-menu.module.css";
|
import classes from "../common/toolbar-menu.module.css";
|
||||||
|
|
||||||
export function VideoMenu({ editor }: EditorMenuProps) {
|
export function VideoMenu({ editor }: EditorMenuProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const setLightboxRequest = useSetAtom(lightboxRequestAtom);
|
|
||||||
|
|
||||||
const editorState = useEditorState({
|
const editorState = useEditorState({
|
||||||
editor,
|
editor,
|
||||||
@@ -187,23 +183,6 @@ export function VideoMenu({ editor }: EditorMenuProps) {
|
|||||||
|
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Expand")} withinPortal={false}>
|
|
||||||
<ActionIcon
|
|
||||||
onClick={() =>
|
|
||||||
editorState?.src &&
|
|
||||||
setLightboxRequest({
|
|
||||||
src: getFileUrl(editorState.src),
|
|
||||||
type: "video",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
size="lg"
|
|
||||||
aria-label={t("Expand")}
|
|
||||||
variant="subtle"
|
|
||||||
>
|
|
||||||
<IconZoomIn size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Download")} withinPortal={false}>
|
<Tooltip position="top" label={t("Download")} withinPortal={false}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onClick={handleDownload}
|
onClick={handleDownload}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { Superscript } from "@tiptap/extension-superscript";
|
|||||||
import SubScript from "@tiptap/extension-subscript";
|
import SubScript from "@tiptap/extension-subscript";
|
||||||
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 { Youtube } from "@tiptap/extension-youtube";
|
import { Youtube } from "@tiptap/extension-youtube";
|
||||||
import SlashCommand, {
|
import SlashCommand, {
|
||||||
SlashCommandExtension as Command,
|
SlashCommandExtension as Command,
|
||||||
@@ -54,6 +53,7 @@ import {
|
|||||||
Subpages,
|
Subpages,
|
||||||
Heading,
|
Heading,
|
||||||
Highlight,
|
Highlight,
|
||||||
|
Color,
|
||||||
Indent,
|
Indent,
|
||||||
UniqueID,
|
UniqueID,
|
||||||
SharedStorage,
|
SharedStorage,
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import { useAtom, useAtomValue } from "jotai";
|
|||||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom";
|
import { currentUserAtom } from "@/features/user/atoms/current-user-atom";
|
||||||
import {
|
import {
|
||||||
currentPageEditModeAtom,
|
currentPageEditModeAtom,
|
||||||
lightboxRequestAtom,
|
|
||||||
pageEditorAtom,
|
pageEditorAtom,
|
||||||
yjsConnectionStatusAtom,
|
yjsConnectionStatusAtom,
|
||||||
yjsSyncedAtom,
|
yjsSyncedAtom,
|
||||||
@@ -54,9 +53,6 @@ import CalloutMenu from "@/features/editor/components/callout/callout-menu.tsx";
|
|||||||
import VideoMenu from "@/features/editor/components/video/video-menu.tsx";
|
import VideoMenu from "@/features/editor/components/video/video-menu.tsx";
|
||||||
import PdfMenu from "@/features/editor/components/pdf/pdf-menu.tsx";
|
import PdfMenu from "@/features/editor/components/pdf/pdf-menu.tsx";
|
||||||
import SubpagesMenu from "@/features/editor/components/subpages/subpages-menu.tsx";
|
import SubpagesMenu from "@/features/editor/components/subpages/subpages-menu.tsx";
|
||||||
import LightboxView, {
|
|
||||||
getLightboxClickRequest,
|
|
||||||
} from "@/features/editor/components/common/lightbox-view";
|
|
||||||
import {
|
import {
|
||||||
handleFileDrop,
|
handleFileDrop,
|
||||||
handlePaste,
|
handlePaste,
|
||||||
@@ -188,7 +184,6 @@ function CollabPageEditor({
|
|||||||
const [, setActiveCommentId] = useAtom(activeCommentIdAtom);
|
const [, setActiveCommentId] = useAtom(activeCommentIdAtom);
|
||||||
const [showCommentPopup, setShowCommentPopup] = useAtom(showCommentPopupAtom);
|
const [showCommentPopup, setShowCommentPopup] = useAtom(showCommentPopupAtom);
|
||||||
const [showReadOnlyCommentPopup] = useAtom(showReadOnlyCommentPopupAtom);
|
const [showReadOnlyCommentPopup] = useAtom(showReadOnlyCommentPopupAtom);
|
||||||
const [lightboxRequest, setLightboxRequest] = useAtom(lightboxRequestAtom);
|
|
||||||
const [isLocalSynced, setIsLocalSynced] = useState(false);
|
const [isLocalSynced, setIsLocalSynced] = useState(false);
|
||||||
const [isRemoteSynced, setIsRemoteSynced] = useState(false);
|
const [isRemoteSynced, setIsRemoteSynced] = useState(false);
|
||||||
const [yjsConnectionStatus, setYjsConnectionStatus] = useAtom(
|
const [yjsConnectionStatus, setYjsConnectionStatus] = useAtom(
|
||||||
@@ -310,22 +305,6 @@ function CollabPageEditor({
|
|||||||
|
|
||||||
return handleFileDrop(editorRef.current, event, moved, pageId);
|
return handleFileDrop(editorRef.current, event, moved, pageId);
|
||||||
},
|
},
|
||||||
handleClickOn: (view, _pos, node) => {
|
|
||||||
if (view.editable) return false;
|
|
||||||
|
|
||||||
const request = getLightboxClickRequest(node);
|
|
||||||
if (!request) return false;
|
|
||||||
|
|
||||||
setLightboxRequest(request);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
handleDoubleClickOn: (_view, _pos, node) => {
|
|
||||||
const request = getLightboxClickRequest(node);
|
|
||||||
if (!request) return false;
|
|
||||||
|
|
||||||
setLightboxRequest(request);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
onCreate({ editor }) {
|
onCreate({ editor }) {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
@@ -407,7 +386,6 @@ function CollabPageEditor({
|
|||||||
setActiveCommentId(null);
|
setActiveCommentId(null);
|
||||||
setShowCommentPopup(false);
|
setShowCommentPopup(false);
|
||||||
setAsideState({ tab: "", isAsideOpen: false });
|
setAsideState({ tab: "", isAsideOpen: false });
|
||||||
setLightboxRequest(null);
|
|
||||||
}, [pageId]);
|
}, [pageId]);
|
||||||
|
|
||||||
const isSynced = isLocalSynced && isRemoteSynced;
|
const isSynced = isLocalSynced && isRemoteSynced;
|
||||||
@@ -481,15 +459,6 @@ function CollabPageEditor({
|
|||||||
{editor && !editorIsEditable && (editable || canComment) && (
|
{editor && !editorIsEditable && (editable || canComment) && (
|
||||||
<ReadonlyBubbleMenu editor={editor} />
|
<ReadonlyBubbleMenu editor={editor} />
|
||||||
)}
|
)}
|
||||||
{editor && (
|
|
||||||
<LightboxView
|
|
||||||
editor={editor}
|
|
||||||
open={!!lightboxRequest}
|
|
||||||
src={lightboxRequest?.src ?? ""}
|
|
||||||
type={lightboxRequest?.type ?? "image"}
|
|
||||||
onClose={() => setLightboxRequest(null)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{showCommentPopup && <CommentDialog editor={editor} pageId={pageId} />}
|
{showCommentPopup && <CommentDialog editor={editor} pageId={pageId} />}
|
||||||
{showReadOnlyCommentPopup && (
|
{showReadOnlyCommentPopup && (
|
||||||
<CommentDialog editor={editor} pageId={pageId} readOnly />
|
<CommentDialog editor={editor} pageId={pageId} readOnly />
|
||||||
|
|||||||
@@ -1,27 +1,15 @@
|
|||||||
import "@/features/editor/styles/index.css";
|
import "@/features/editor/styles/index.css";
|
||||||
import React, {
|
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
||||||
useCallback,
|
import { EditorProvider } from "@tiptap/react";
|
||||||
useEffect,
|
|
||||||
useMemo,
|
|
||||||
useRef,
|
|
||||||
useState,
|
|
||||||
} from "react";
|
|
||||||
import { Editor, 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, UniqueID } from "@docmost/editor-ext";
|
import { Heading, 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 {
|
import { readOnlyEditorAtom } from "@/features/editor/atoms/editor-atoms.ts";
|
||||||
lightboxRequestAtom,
|
|
||||||
readOnlyEditorAtom,
|
|
||||||
} from "@/features/editor/atoms/editor-atoms.ts";
|
|
||||||
import { useEditorScroll } from "./hooks/use-editor-scroll";
|
import { useEditorScroll } from "./hooks/use-editor-scroll";
|
||||||
import { TransclusionLookupProvider } from "@/features/editor/components/transclusion/transclusion-lookup-context";
|
import { TransclusionLookupProvider } from "@/features/editor/components/transclusion/transclusion-lookup-context";
|
||||||
import LightboxView, {
|
|
||||||
getLightboxClickRequest,
|
|
||||||
} from "@/features/editor/components/common/lightbox-view";
|
|
||||||
|
|
||||||
interface PageEditorProps {
|
interface PageEditorProps {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -45,8 +33,6 @@ export default function ReadonlyPageEditor({
|
|||||||
shareId,
|
shareId,
|
||||||
}: PageEditorProps) {
|
}: PageEditorProps) {
|
||||||
const [, setReadOnlyEditor] = useAtom(readOnlyEditorAtom);
|
const [, setReadOnlyEditor] = useAtom(readOnlyEditorAtom);
|
||||||
const [lightboxRequest, setLightboxRequest] = useAtom(lightboxRequestAtom);
|
|
||||||
const [contentEditor, setContentEditor] = useState<Editor | null>(null);
|
|
||||||
const isComponentMounted = useRef(false);
|
const isComponentMounted = useRef(false);
|
||||||
const editorCreated = useRef(false);
|
const editorCreated = useRef(false);
|
||||||
|
|
||||||
@@ -63,11 +49,6 @@ export default function ReadonlyPageEditor({
|
|||||||
isComponentMounted.current = true;
|
isComponentMounted.current = true;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!shareId) return;
|
|
||||||
setLightboxRequest(null);
|
|
||||||
}, [pageId, shareId]);
|
|
||||||
|
|
||||||
const extensions = useMemo(() => {
|
const extensions = useMemo(() => {
|
||||||
const excludedExtensions = new Set([
|
const excludedExtensions = new Set([
|
||||||
"uniqueID",
|
"uniqueID",
|
||||||
@@ -116,19 +97,6 @@ export default function ReadonlyPageEditor({
|
|||||||
textDirection="auto"
|
textDirection="auto"
|
||||||
extensions={extensions}
|
extensions={extensions}
|
||||||
content={content}
|
content={content}
|
||||||
editorProps={
|
|
||||||
shareId
|
|
||||||
? {
|
|
||||||
handleClickOn: (_view, _pos, node) => {
|
|
||||||
const request = getLightboxClickRequest(node);
|
|
||||||
if (!request) return false;
|
|
||||||
|
|
||||||
setLightboxRequest(request);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
onCreate={({ editor }) => {
|
onCreate={({ editor }) => {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
if (pageId) {
|
if (pageId) {
|
||||||
@@ -137,22 +105,12 @@ export default function ReadonlyPageEditor({
|
|||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
setReadOnlyEditor(editor);
|
setReadOnlyEditor(editor);
|
||||||
setContentEditor(editor);
|
|
||||||
|
|
||||||
handleScrollTo(editor);
|
handleScrollTo(editor);
|
||||||
editorCreated.current = true;
|
editorCreated.current = true;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
></EditorProvider>
|
></EditorProvider>
|
||||||
{shareId && contentEditor && (
|
|
||||||
<LightboxView
|
|
||||||
editor={contentEditor}
|
|
||||||
open={!!lightboxRequest}
|
|
||||||
src={lightboxRequest?.src ?? ""}
|
|
||||||
type={lightboxRequest?.type ?? "image"}
|
|
||||||
onClose={() => setLightboxRequest(null)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div style={{ paddingBottom: "20vh" }}></div>
|
<div style={{ paddingBottom: "20vh" }}></div>
|
||||||
</TransclusionLookupProvider>
|
</TransclusionLookupProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,46 @@
|
|||||||
/* Highlight colors with dark mode support */
|
/* Highlight colors with dark mode support */
|
||||||
|
|
||||||
.ProseMirror {
|
.ProseMirror {
|
||||||
|
@mixin dark {
|
||||||
|
/* Arbitrary (imported) colors have no hand-tuned dark variant, so derive
|
||||||
|
one: cap lightness and chroma so the fill sits on the dark surface.
|
||||||
|
Our own palette opts out and keeps the values below. */
|
||||||
|
mark[data-color]:not(
|
||||||
|
[data-color="#98d8f2" i],
|
||||||
|
[data-color="#7edb6c" i],
|
||||||
|
[data-color="#e0d6ed" i],
|
||||||
|
[data-color="#ffc6c2" i],
|
||||||
|
[data-color="#faf594" i],
|
||||||
|
[data-color="#f5c8a9" i],
|
||||||
|
[data-color="#f5cfe0" i],
|
||||||
|
[data-color="#dfdfd7" i],
|
||||||
|
[data-color="#d7c4b7" i]
|
||||||
|
) {
|
||||||
|
background-color: oklch(
|
||||||
|
from var(--mark-bg, #fff) min(l, clamp(0.28, calc(1.22 - l), 0.45))
|
||||||
|
min(calc(c * 1.8), 0.09) h
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Imported text colors are picked for a light page and go unreadable on
|
||||||
|
the dark surface, so lift their lightness. */
|
||||||
|
span[data-text-color]:not(
|
||||||
|
[data-text-color="#2563EB" i],
|
||||||
|
[data-text-color="#008A00" i],
|
||||||
|
[data-text-color="#9333EA" i],
|
||||||
|
[data-text-color="#E00000" i],
|
||||||
|
[data-text-color="#EAB308" i],
|
||||||
|
[data-text-color="#FFA500" i],
|
||||||
|
[data-text-color="#BA4081" i],
|
||||||
|
[data-text-color="#A8A29E" i],
|
||||||
|
[data-text-color="#92400E" i]
|
||||||
|
) {
|
||||||
|
color: oklch(
|
||||||
|
from var(--text-color, currentcolor) max(l, 0.72) min(c, 0.16) h
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Blue */
|
/* Blue */
|
||||||
mark[data-color="#98d8f2"] {
|
mark[data-color="#98d8f2"] {
|
||||||
background-color: light-dark(
|
background-color: light-dark(
|
||||||
|
|||||||
@@ -86,6 +86,16 @@
|
|||||||
.ProseMirror {
|
.ProseMirror {
|
||||||
table {
|
table {
|
||||||
@mixin dark {
|
@mixin dark {
|
||||||
|
/* Arbitrary (imported) colors: derive a dark variant; the hand-tuned
|
||||||
|
palette rules below override this for native colors. */
|
||||||
|
td[data-background-color],
|
||||||
|
th[data-background-color] {
|
||||||
|
background-color: oklch(
|
||||||
|
from var(--cell-bg, #fff) min(l, clamp(0.28, calc(1.22 - l), 0.45))
|
||||||
|
min(calc(c * 1.8), 0.09) h
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* Blue */
|
/* Blue */
|
||||||
td[data-background-color="#b4d5ff"],
|
td[data-background-color="#b4d5ff"],
|
||||||
th[data-background-color="#b4d5ff"] {
|
th[data-background-color="#b4d5ff"] {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export function useWorkspaceLabelsQuery(query: string, enabled: boolean) {
|
|||||||
queryFn: () => getWorkspaceLabels({ type: "page", query, limit: 50 }),
|
queryFn: () => getWorkspaceLabels({ type: "page", query, limit: 50 }),
|
||||||
enabled,
|
enabled,
|
||||||
staleTime: 30 * 1000,
|
staleTime: 30 * 1000,
|
||||||
placeholderData: keepPreviousData
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,152 +0,0 @@
|
|||||||
import { ReactNode, useMemo, useState } from "react";
|
|
||||||
import { Divider, Group, Menu, ScrollArea, Text, TextInput } from "@mantine/core";
|
|
||||||
import { useDebouncedValue } from "@mantine/hooks";
|
|
||||||
import { IconCheck, IconSearch } from "@tabler/icons-react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { useSearchSuggestionsQuery } from "@/features/search/queries/search-query";
|
|
||||||
import { RadioMenuItem } from "@/components/ui/radio-menu-item";
|
|
||||||
import { CustomAvatar } from "@/components/ui/custom-avatar.tsx";
|
|
||||||
import { IUser } from "@/features/user/types/user.types.ts";
|
|
||||||
import { useAtomValue } from "jotai";
|
|
||||||
import { userAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
|
|
||||||
type CreatorFilterMenuProps = {
|
|
||||||
value: string | null;
|
|
||||||
onChange: (user: IUser | null) => void;
|
|
||||||
children: ReactNode;
|
|
||||||
width?: number;
|
|
||||||
position?:
|
|
||||||
| "bottom-start"
|
|
||||||
| "bottom-end"
|
|
||||||
| "bottom"
|
|
||||||
| "top-start"
|
|
||||||
| "top-end"
|
|
||||||
| "top";
|
|
||||||
zIndex?: number;
|
|
||||||
opened?: boolean;
|
|
||||||
onOpenChange?: (opened: boolean) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function CreatorFilterMenu({
|
|
||||||
value,
|
|
||||||
onChange,
|
|
||||||
children,
|
|
||||||
width = 280,
|
|
||||||
position = "bottom-end",
|
|
||||||
zIndex,
|
|
||||||
opened,
|
|
||||||
onOpenChange,
|
|
||||||
}: CreatorFilterMenuProps) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
|
||||||
const [debouncedQuery] = useDebouncedValue(searchQuery, 300);
|
|
||||||
|
|
||||||
const { data: suggestion, isLoading } = useSearchSuggestionsQuery({
|
|
||||||
query: debouncedQuery,
|
|
||||||
includeUsers: true,
|
|
||||||
includeGroups: false,
|
|
||||||
includePages: false,
|
|
||||||
preload: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const users: IUser[] = (suggestion?.users as IUser[]) ?? [];
|
|
||||||
const currentUser = useAtomValue(userAtom);
|
|
||||||
|
|
||||||
// pin the signed-in user on top so they never have to search themselves
|
|
||||||
const displayUsers = useMemo(() => {
|
|
||||||
if (!currentUser) return users;
|
|
||||||
const others = users.filter((user) => user.id !== currentUser.id);
|
|
||||||
const q = debouncedQuery.trim().toLowerCase();
|
|
||||||
const matchesQuery =
|
|
||||||
!q ||
|
|
||||||
currentUser.name?.toLowerCase().includes(q) ||
|
|
||||||
currentUser.email?.toLowerCase().includes(q);
|
|
||||||
return matchesQuery ? [currentUser as IUser, ...others] : users;
|
|
||||||
}, [users, currentUser, debouncedQuery]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Menu
|
|
||||||
shadow="md"
|
|
||||||
width={width}
|
|
||||||
position={position}
|
|
||||||
zIndex={zIndex}
|
|
||||||
opened={opened}
|
|
||||||
onChange={onOpenChange}
|
|
||||||
>
|
|
||||||
<Menu.Target>{children}</Menu.Target>
|
|
||||||
<Menu.Dropdown>
|
|
||||||
<TextInput
|
|
||||||
placeholder={t("Find a user")}
|
|
||||||
data-autofocus
|
|
||||||
autoFocus
|
|
||||||
leftSection={<IconSearch size={16} />}
|
|
||||||
value={searchQuery}
|
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
|
||||||
size="sm"
|
|
||||||
variant="filled"
|
|
||||||
radius="sm"
|
|
||||||
styles={{ input: { marginBottom: 8 } }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ScrollArea.Autosize mah={280}>
|
|
||||||
<Menu.Item
|
|
||||||
component={RadioMenuItem}
|
|
||||||
aria-checked={!value}
|
|
||||||
onClick={() => onChange(null)}
|
|
||||||
>
|
|
||||||
<Group flex="1" gap="xs">
|
|
||||||
<div style={{ flex: 1 }}>
|
|
||||||
<Text size="sm" fw={500}>
|
|
||||||
{t("Anyone")}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
{!value && <IconCheck size={20} aria-hidden />}
|
|
||||||
</Group>
|
|
||||||
</Menu.Item>
|
|
||||||
|
|
||||||
<Divider my="xs" />
|
|
||||||
|
|
||||||
{displayUsers.length === 0 && (
|
|
||||||
<Text size="xs" c="dimmed" px="xs" py="sm">
|
|
||||||
{isLoading ? t("Loading...") : t("No users found")}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{displayUsers.map((user) => (
|
|
||||||
<Menu.Item
|
|
||||||
key={user.id}
|
|
||||||
component={RadioMenuItem}
|
|
||||||
aria-checked={value === user.id}
|
|
||||||
onClick={() => onChange(user)}
|
|
||||||
>
|
|
||||||
<Group flex="1" gap="xs">
|
|
||||||
<CustomAvatar
|
|
||||||
avatarUrl={user.avatarUrl}
|
|
||||||
size={20}
|
|
||||||
name={user.name}
|
|
||||||
/>
|
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
|
||||||
<Text size="sm" fw={500} truncate>
|
|
||||||
{user.name}
|
|
||||||
{user.id === currentUser?.id && (
|
|
||||||
<Text span size="sm" c="dimmed" fw={400}>
|
|
||||||
{" "}
|
|
||||||
({t("you")})
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</Text>
|
|
||||||
{user.email && (
|
|
||||||
<Text size="xs" c="dimmed" truncate>
|
|
||||||
{user.email}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{value === user.id && <IconCheck size={20} aria-hidden />}
|
|
||||||
</Group>
|
|
||||||
</Menu.Item>
|
|
||||||
))}
|
|
||||||
</ScrollArea.Autosize>
|
|
||||||
</Menu.Dropdown>
|
|
||||||
</Menu>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
import { ReactNode, useMemo, useState } from "react";
|
|
||||||
import {
|
|
||||||
Group,
|
|
||||||
Menu,
|
|
||||||
ScrollArea,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
useComputedColorScheme,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { useDebouncedValue } from "@mantine/hooks";
|
|
||||||
import { IconCheck, IconSearch } from "@tabler/icons-react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { useWorkspaceLabelsQuery } from "@/features/label/queries/label-query.ts";
|
|
||||||
import { getLabelColor } from "@/features/label/utils/label-colors.ts";
|
|
||||||
import { CheckboxMenuItem } from "@/components/ui/checkbox-menu-item";
|
|
||||||
|
|
||||||
type LabelFilterMenuProps = {
|
|
||||||
value: string[];
|
|
||||||
onChange: (labelIds: string[]) => void;
|
|
||||||
children: ReactNode;
|
|
||||||
width?: number;
|
|
||||||
position?:
|
|
||||||
| "bottom-start"
|
|
||||||
| "bottom-end"
|
|
||||||
| "bottom"
|
|
||||||
| "top-start"
|
|
||||||
| "top-end"
|
|
||||||
| "top";
|
|
||||||
zIndex?: number;
|
|
||||||
opened?: boolean;
|
|
||||||
onOpenChange?: (opened: boolean) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function LabelFilterMenu({
|
|
||||||
value,
|
|
||||||
onChange,
|
|
||||||
children,
|
|
||||||
width = 280,
|
|
||||||
position = "bottom-end",
|
|
||||||
zIndex,
|
|
||||||
opened,
|
|
||||||
onOpenChange,
|
|
||||||
}: LabelFilterMenuProps) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const scheme = useComputedColorScheme("light");
|
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
|
||||||
const [debouncedQuery] = useDebouncedValue(searchQuery, 300);
|
|
||||||
|
|
||||||
const { data, isLoading } = useWorkspaceLabelsQuery(debouncedQuery, true);
|
|
||||||
const labels = data?.items ?? [];
|
|
||||||
|
|
||||||
const selectedSet = useMemo(() => new Set(value), [value]);
|
|
||||||
|
|
||||||
const toggleLabel = (labelId: string) => {
|
|
||||||
if (selectedSet.has(labelId)) {
|
|
||||||
onChange(value.filter((id) => id !== labelId));
|
|
||||||
} else {
|
|
||||||
onChange([...value, labelId]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Menu
|
|
||||||
shadow="md"
|
|
||||||
width={width}
|
|
||||||
position={position}
|
|
||||||
zIndex={zIndex}
|
|
||||||
opened={opened}
|
|
||||||
onChange={onOpenChange}
|
|
||||||
closeOnItemClick={false}
|
|
||||||
>
|
|
||||||
<Menu.Target>{children}</Menu.Target>
|
|
||||||
<Menu.Dropdown>
|
|
||||||
<TextInput
|
|
||||||
placeholder={t("Find a label")}
|
|
||||||
data-autofocus
|
|
||||||
autoFocus
|
|
||||||
leftSection={<IconSearch size={16} />}
|
|
||||||
value={searchQuery}
|
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
|
||||||
size="sm"
|
|
||||||
variant="filled"
|
|
||||||
radius="sm"
|
|
||||||
styles={{ input: { marginBottom: 8 } }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ScrollArea.Autosize mah={280}>
|
|
||||||
{labels.length === 0 && (
|
|
||||||
<Text size="xs" c="dimmed" px="xs" py="sm">
|
|
||||||
{isLoading ? t("Loading...") : t("No labels found")}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{labels.map((label) => {
|
|
||||||
const isChecked = selectedSet.has(label.id);
|
|
||||||
const color = getLabelColor(label.name, scheme);
|
|
||||||
return (
|
|
||||||
<Menu.Item
|
|
||||||
key={label.id}
|
|
||||||
type="button"
|
|
||||||
component={CheckboxMenuItem}
|
|
||||||
aria-checked={isChecked}
|
|
||||||
onClick={() => toggleLabel(label.id)}
|
|
||||||
>
|
|
||||||
<Group flex="1" gap="xs">
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
width: 8,
|
|
||||||
height: 8,
|
|
||||||
borderRadius: "50%",
|
|
||||||
background: color.dot,
|
|
||||||
flexShrink: 0,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text size="sm" fw={500} style={{ flex: 1 }} truncate>
|
|
||||||
{label.name}
|
|
||||||
</Text>
|
|
||||||
{isChecked && <IconCheck size={20} aria-hidden />}
|
|
||||||
</Group>
|
|
||||||
</Menu.Item>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ScrollArea.Autosize>
|
|
||||||
</Menu.Dropdown>
|
|
||||||
</Menu>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,6 @@ import {
|
|||||||
} from "@/features/search/types/search.types";
|
} from "@/features/search/types/search.types";
|
||||||
import DOMPurify from "dompurify";
|
import DOMPurify from "dompurify";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { timeAgo } from "@/lib/time.ts";
|
|
||||||
|
|
||||||
interface SearchResultItemProps {
|
interface SearchResultItemProps {
|
||||||
result: IPageSearch | IAttachmentSearch;
|
result: IPageSearch | IAttachmentSearch;
|
||||||
@@ -27,14 +26,6 @@ interface SearchResultItemProps {
|
|||||||
showSpace?: boolean;
|
showSpace?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spotlight hardcodes tabIndex={-1} after spreading props; a ref wins and
|
|
||||||
// React never writes -1 back because the prop value never changes
|
|
||||||
const makeActionTabbable = (el: HTMLElement | null) => {
|
|
||||||
if (el) {
|
|
||||||
el.tabIndex = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export function SearchResultItem({
|
export function SearchResultItem({
|
||||||
result,
|
result,
|
||||||
isAttachmentResult,
|
isAttachmentResult,
|
||||||
@@ -55,7 +46,6 @@ export function SearchResultItem({
|
|||||||
return (
|
return (
|
||||||
<Spotlight.Action
|
<Spotlight.Action
|
||||||
component={Link}
|
component={Link}
|
||||||
ref={makeActionTabbable}
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
to={buildPageUrl(
|
to={buildPageUrl(
|
||||||
attachmentResult.space.slug,
|
attachmentResult.space.slug,
|
||||||
@@ -69,13 +59,8 @@ export function SearchResultItem({
|
|||||||
<IconFile size={16} />
|
<IconFile size={16} />
|
||||||
</Center>
|
</Center>
|
||||||
|
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
<div style={{ flex: 1 }}>
|
||||||
<Group justify="space-between" wrap="nowrap" gap="xs">
|
<Text>{attachmentResult.fileName}</Text>
|
||||||
<Text truncate>{attachmentResult.fileName}</Text>
|
|
||||||
<Text size="xs" c="dimmed" style={{ flexShrink: 0 }}>
|
|
||||||
{timeAgo(attachmentResult.updatedAt)}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
<Text size="xs" opacity={0.6}>
|
<Text size="xs" opacity={0.6}>
|
||||||
{attachmentResult.space.name} • {attachmentResult.page.title}
|
{attachmentResult.space.name} • {attachmentResult.page.title}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -111,7 +96,6 @@ export function SearchResultItem({
|
|||||||
return (
|
return (
|
||||||
<Spotlight.Action
|
<Spotlight.Action
|
||||||
component={Link}
|
component={Link}
|
||||||
ref={makeActionTabbable}
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
to={buildPageUrl(
|
to={buildPageUrl(
|
||||||
pageResult.space.slug,
|
pageResult.space.slug,
|
||||||
@@ -123,13 +107,8 @@ export function SearchResultItem({
|
|||||||
<Group wrap="nowrap" w="100%">
|
<Group wrap="nowrap" w="100%">
|
||||||
<Center>{getPageIcon(pageResult?.icon)}</Center>
|
<Center>{getPageIcon(pageResult?.icon)}</Center>
|
||||||
|
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
<div style={{ flex: 1 }}>
|
||||||
<Group justify="space-between" wrap="nowrap" gap="xs">
|
<Text>{pageResult.title}</Text>
|
||||||
<Text truncate>{pageResult.title || t("Untitled")}</Text>
|
|
||||||
<Text size="xs" c="dimmed" style={{ flexShrink: 0 }}>
|
|
||||||
{timeAgo(pageResult.updatedAt)}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
|
|
||||||
{showSpace && pageResult.space && (
|
{showSpace && pageResult.space && (
|
||||||
<Badge variant="light" size="xs" color="gray">
|
<Badge variant="light" size="xs" color="gray">
|
||||||
|
|||||||
@@ -17,10 +17,3 @@
|
|||||||
color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-gray-6));
|
color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-gray-6));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.filterButtonActive {
|
|
||||||
color: var(--mantine-color-blue-light-color);
|
|
||||||
&:hover {
|
|
||||||
color: var(--mantine-color-blue-light-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import cx from "clsx";
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Menu,
|
Menu,
|
||||||
@@ -12,24 +11,18 @@ import {
|
|||||||
import {
|
import {
|
||||||
IconChevronDown,
|
IconChevronDown,
|
||||||
IconBuilding,
|
IconBuilding,
|
||||||
IconPlus,
|
|
||||||
IconFileDescription,
|
IconFileDescription,
|
||||||
IconCheck,
|
IconCheck,
|
||||||
IconUser,
|
|
||||||
IconTag,
|
|
||||||
IconLetterCase,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
||||||
import { SpaceFilterMenu } from "@/features/space/components/space-filter-menu";
|
import { SpaceFilterMenu } from "@/features/space/components/space-filter-menu";
|
||||||
import { CreatorFilterMenu } from "@/features/search/components/creator-filter-menu";
|
|
||||||
import { RadioMenuItem } from "@/components/ui/radio-menu-item";
|
import { RadioMenuItem } from "@/components/ui/radio-menu-item";
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
import { Feature } from "@/ee/features";
|
import { Feature } from "@/ee/features";
|
||||||
import classes from "./search-spotlight-filters.module.css";
|
import classes from "./search-spotlight-filters.module.css";
|
||||||
import { useAtom } from "jotai";
|
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 { LabelFilterMenu } from "./label-filter-menu";
|
|
||||||
|
|
||||||
interface SearchSpotlightFiltersProps {
|
interface SearchSpotlightFiltersProps {
|
||||||
onFiltersChange?: (filters: any) => void;
|
onFiltersChange?: (filters: any) => void;
|
||||||
@@ -47,17 +40,9 @@ export function SearchSpotlightFilters({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
||||||
const [selectedSpaceId, setSelectedSpaceId] = useState<string | null>(
|
const [selectedSpaceId, setSelectedSpaceId] = useState<string | null>(
|
||||||
spaceId || null
|
spaceId || null,
|
||||||
);
|
);
|
||||||
const [contentType, setContentType] = useState<string | null>("page");
|
const [contentType, setContentType] = useState<string | null>("page");
|
||||||
const [selectedCreatorId, setSelectedCreatorId] = useState<string | null>(null);
|
|
||||||
const [selectedCreatorName, setSelectedCreatorName] = useState<string | null>(
|
|
||||||
null
|
|
||||||
);
|
|
||||||
const [selectedLabelIds, setSelectedLabelIds] = useState<string[]>([]);
|
|
||||||
const [titleOnly, setTitleOnly] = useState(false);
|
|
||||||
const [openedFilter, setOpenedFilter] = useState<string | null>(null);
|
|
||||||
const [visibleFilters, setVisibleFilters] = useState<string[]>([]);
|
|
||||||
const [workspace] = useAtom(workspaceAtom);
|
const [workspace] = useAtom(workspaceAtom);
|
||||||
|
|
||||||
const { data: spacesData } = useGetSpacesQuery({ limit: 100 });
|
const { data: spacesData } = useGetSpacesQuery({ limit: 100 });
|
||||||
@@ -65,6 +50,15 @@ export function SearchSpotlightFilters({
|
|||||||
? spacesData?.items.find((space) => space.id === selectedSpaceId)
|
? spacesData?.items.find((space) => space.id === selectedSpaceId)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (onFiltersChange) {
|
||||||
|
onFiltersChange({
|
||||||
|
spaceId: selectedSpaceId,
|
||||||
|
contentType,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const contentTypeOptions = [
|
const contentTypeOptions = [
|
||||||
{ value: "page", label: t("Pages") },
|
{ value: "page", label: t("Pages") },
|
||||||
{
|
{
|
||||||
@@ -74,70 +68,38 @@ export function SearchSpotlightFilters({
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
onFiltersChange?.({
|
|
||||||
spaceId: selectedSpaceId,
|
|
||||||
contentType,
|
|
||||||
creatorId: selectedCreatorId,
|
|
||||||
labelIds: selectedLabelIds,
|
|
||||||
titleOnly,
|
|
||||||
});
|
|
||||||
}, [
|
|
||||||
selectedSpaceId,
|
|
||||||
contentType,
|
|
||||||
selectedCreatorId,
|
|
||||||
selectedLabelIds,
|
|
||||||
titleOnly,
|
|
||||||
onFiltersChange,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const handleSpaceSelect = (spaceId: string | null) => {
|
const handleSpaceSelect = (spaceId: string | null) => {
|
||||||
setSelectedSpaceId(spaceId);
|
setSelectedSpaceId(spaceId);
|
||||||
};
|
|
||||||
|
|
||||||
const handleCreatorSelect = (user: { id: string; name: string } | null) => {
|
if (onFiltersChange) {
|
||||||
setSelectedCreatorId(user?.id ?? null);
|
onFiltersChange({
|
||||||
setSelectedCreatorName(user?.name ?? null);
|
spaceId: spaceId,
|
||||||
};
|
contentType,
|
||||||
|
});
|
||||||
const handleLabelsSelect = (labelIds: string[]) => {
|
|
||||||
setSelectedLabelIds(labelIds);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleChangeContentType = (value: string) => {
|
|
||||||
setContentType(value);
|
|
||||||
|
|
||||||
if (value === "attachment") {
|
|
||||||
setSelectedLabelIds([]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDemandFilters = [
|
const handleFilterChange = (filterType: string, value: any) => {
|
||||||
{ key: "creator", label: t("Created by"), icon: IconUser, available: true },
|
let newSelectedSpaceId = selectedSpaceId;
|
||||||
{
|
let newContentType = contentType;
|
||||||
key: "labels",
|
|
||||||
label: t("Labels"),
|
|
||||||
icon: IconTag,
|
|
||||||
available: contentType !== "attachment",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const isFilterVisible = (key: string) => {
|
switch (filterType) {
|
||||||
if (openedFilter === key) return true;
|
case "spaceId":
|
||||||
if (key === "creator") return !!selectedCreatorId;
|
newSelectedSpaceId = value;
|
||||||
if (key === "labels")
|
setSelectedSpaceId(value);
|
||||||
return contentType !== "attachment" && selectedLabelIds.length > 0;
|
break;
|
||||||
return false;
|
case "contentType":
|
||||||
};
|
newContentType = value;
|
||||||
|
setContentType(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
const orderedVisibleFilters = visibleFilters.filter(isFilterVisible);
|
if (onFiltersChange) {
|
||||||
const addableFilters = onDemandFilters.filter(
|
onFiltersChange({
|
||||||
(filter) => filter.available && !isFilterVisible(filter.key),
|
spaceId: newSelectedSpaceId,
|
||||||
);
|
contentType: newContentType,
|
||||||
|
});
|
||||||
const revealFilter = (key: string) => {
|
}
|
||||||
setVisibleFilters((prev) => [...prev.filter((k) => k !== key), key]);
|
|
||||||
setOpenedFilter(key);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -160,17 +122,8 @@ export function SearchSpotlightFilters({
|
|||||||
color="blue"
|
color="blue"
|
||||||
labelPosition="left"
|
labelPosition="left"
|
||||||
styles={{
|
styles={{
|
||||||
root: {
|
root: { display: "flex", alignItems: "center" },
|
||||||
display: "flex",
|
label: { paddingRight: "8px", fontSize: "13px", fontWeight: 500 },
|
||||||
alignItems: "center",
|
|
||||||
flexShrink: 0,
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
whiteSpace: "nowrap",
|
|
||||||
paddingRight: "8px",
|
|
||||||
fontSize: "13px",
|
|
||||||
fontWeight: 500,
|
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -228,7 +181,7 @@ export function SearchSpotlightFilters({
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
!option.disabled &&
|
!option.disabled &&
|
||||||
contentType !== option.value &&
|
contentType !== option.value &&
|
||||||
handleChangeContentType(option.value)
|
handleFilterChange("contentType", option.value)
|
||||||
}
|
}
|
||||||
disabled={
|
disabled={
|
||||||
option.disabled || (isAiMode && option.value === "attachment")
|
option.disabled || (isAiMode && option.value === "attachment")
|
||||||
@@ -242,11 +195,13 @@ export function SearchSpotlightFilters({
|
|||||||
{t("Enterprise")}
|
{t("Enterprise")}
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
{!option.disabled && isAiMode && option.value === "attachment" && (
|
{!option.disabled &&
|
||||||
<Text size="xs" mt={4}>
|
isAiMode &&
|
||||||
{t("AI Answers not available for attachments")}
|
option.value === "attachment" && (
|
||||||
</Text>
|
<Text size="xs" mt={4}>
|
||||||
)}
|
{t("AI Answers not available for attachments")}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{contentType === option.value && <IconCheck size={20} aria-hidden />}
|
{contentType === option.value && <IconCheck size={20} aria-hidden />}
|
||||||
</Group>
|
</Group>
|
||||||
@@ -254,126 +209,6 @@ export function SearchSpotlightFilters({
|
|||||||
))}
|
))}
|
||||||
</Menu.Dropdown>
|
</Menu.Dropdown>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
{!isAiMode && (
|
|
||||||
<Button
|
|
||||||
variant={titleOnly ? "light" : "subtle"}
|
|
||||||
color={titleOnly ? "blue" : "gray"}
|
|
||||||
size="sm"
|
|
||||||
radius="xl"
|
|
||||||
leftSection={<IconLetterCase size={16} />}
|
|
||||||
className={cx(
|
|
||||||
classes.filterButton,
|
|
||||||
titleOnly && classes.filterButtonActive,
|
|
||||||
)}
|
|
||||||
fw={500}
|
|
||||||
aria-pressed={titleOnly}
|
|
||||||
onClick={() => setTitleOnly(!titleOnly)}
|
|
||||||
>
|
|
||||||
{t("Title only")}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isAiMode &&
|
|
||||||
orderedVisibleFilters.map((filterKey) => {
|
|
||||||
if (filterKey === "creator") {
|
|
||||||
return (
|
|
||||||
<CreatorFilterMenu
|
|
||||||
key="creator"
|
|
||||||
value={selectedCreatorId}
|
|
||||||
onChange={handleCreatorSelect}
|
|
||||||
position="bottom-start"
|
|
||||||
width={250}
|
|
||||||
zIndex={getDefaultZIndex("max")}
|
|
||||||
opened={openedFilter === "creator"}
|
|
||||||
onOpenChange={(opened) =>
|
|
||||||
setOpenedFilter(opened ? "creator" : null)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="subtle"
|
|
||||||
color="gray"
|
|
||||||
size="sm"
|
|
||||||
rightSection={<IconChevronDown size={14} />}
|
|
||||||
leftSection={<IconUser size={16} />}
|
|
||||||
className={classes.filterButton}
|
|
||||||
fw={500}
|
|
||||||
>
|
|
||||||
{selectedCreatorId
|
|
||||||
? `${t("Created by")}: ${selectedCreatorName || t("Unknown")}`
|
|
||||||
: `${t("Created by")}: ${t("Anyone")}`}
|
|
||||||
</Button>
|
|
||||||
</CreatorFilterMenu>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filterKey === "labels") {
|
|
||||||
return (
|
|
||||||
<LabelFilterMenu
|
|
||||||
key="labels"
|
|
||||||
value={selectedLabelIds}
|
|
||||||
onChange={handleLabelsSelect}
|
|
||||||
position="bottom-start"
|
|
||||||
width={250}
|
|
||||||
zIndex={getDefaultZIndex("max")}
|
|
||||||
opened={openedFilter === "labels"}
|
|
||||||
onOpenChange={(opened) =>
|
|
||||||
setOpenedFilter(opened ? "labels" : null)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="subtle"
|
|
||||||
color="gray"
|
|
||||||
size="sm"
|
|
||||||
rightSection={<IconChevronDown size={14} />}
|
|
||||||
leftSection={<IconTag size={16} />}
|
|
||||||
className={classes.filterButton}
|
|
||||||
fw={500}
|
|
||||||
>
|
|
||||||
{selectedLabelIds.length > 0
|
|
||||||
? `${t("Labels")} (${selectedLabelIds.length})`
|
|
||||||
: t("Labels")}
|
|
||||||
</Button>
|
|
||||||
</LabelFilterMenu>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
})}
|
|
||||||
|
|
||||||
{!isAiMode && addableFilters.length > 0 && (
|
|
||||||
<Menu
|
|
||||||
shadow="md"
|
|
||||||
width={200}
|
|
||||||
position="bottom-end"
|
|
||||||
zIndex={getDefaultZIndex("max")}
|
|
||||||
>
|
|
||||||
<Menu.Target>
|
|
||||||
<Button
|
|
||||||
variant="subtle"
|
|
||||||
color="gray"
|
|
||||||
size="sm"
|
|
||||||
leftSection={<IconPlus size={16} />}
|
|
||||||
className={classes.filterButton}
|
|
||||||
style={{ marginLeft: "auto" }}
|
|
||||||
fw={500}
|
|
||||||
>
|
|
||||||
{t("Filter")}
|
|
||||||
</Button>
|
|
||||||
</Menu.Target>
|
|
||||||
<Menu.Dropdown>
|
|
||||||
{addableFilters.map((filter) => (
|
|
||||||
<Menu.Item
|
|
||||||
key={filter.key}
|
|
||||||
leftSection={<filter.icon size={16} />}
|
|
||||||
onClick={() => revealFilter(filter.key)}
|
|
||||||
>
|
|
||||||
{filter.label}
|
|
||||||
</Menu.Item>
|
|
||||||
))}
|
|
||||||
</Menu.Dropdown>
|
|
||||||
</Menu>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Spotlight } from "@mantine/spotlight";
|
import { Spotlight } from "@mantine/spotlight";
|
||||||
import { IconSearch, IconSparkles } from "@tabler/icons-react";
|
import { IconSearch, IconSparkles } from "@tabler/icons-react";
|
||||||
import { Group, Button, VisuallyHidden, Text } from "@mantine/core";
|
import { Group, Button, VisuallyHidden } from "@mantine/core";
|
||||||
import React, { useState, useMemo, useEffect, useCallback } from "react";
|
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 { notifications } from "@mantine/notifications";
|
||||||
@@ -13,16 +13,11 @@ import { SearchResultItem } from "./search-result-item.tsx";
|
|||||||
import { AiSearchResult } from "../../../ee/ai/components/ai-search-result.tsx";
|
import { AiSearchResult } from "../../../ee/ai/components/ai-search-result.tsx";
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
import { Feature } from "@/ee/features";
|
import { Feature } from "@/ee/features";
|
||||||
import { useAtomValue } from "jotai";
|
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
import { hintVectorCache } from "@/ee/ai/services/ai-search-service.ts";
|
|
||||||
import { getAiVectorDriver } from "@/lib/config.ts";
|
|
||||||
|
|
||||||
interface SearchSpotlightProps {
|
interface SearchSpotlightProps {
|
||||||
spaceId?: string;
|
spaceId?: string;
|
||||||
}
|
}
|
||||||
export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
||||||
const workspace = useAtomValue(workspaceAtom);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const hasAiFeature = useHasFeature(Feature.AI);
|
const hasAiFeature = useHasFeature(Feature.AI);
|
||||||
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
||||||
@@ -31,9 +26,6 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
const [filters, setFilters] = useState<{
|
const [filters, setFilters] = useState<{
|
||||||
spaceId?: string | null;
|
spaceId?: string | null;
|
||||||
contentType?: string;
|
contentType?: string;
|
||||||
creatorId?: string | null;
|
|
||||||
labelIds?: string[];
|
|
||||||
titleOnly?: boolean;
|
|
||||||
}>({
|
}>({
|
||||||
contentType: "page",
|
contentType: "page",
|
||||||
});
|
});
|
||||||
@@ -51,25 +43,10 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
params.spaceId = filters.spaceId;
|
params.spaceId = filters.spaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filters.creatorId) {
|
|
||||||
params.creatorId = filters.creatorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filters.labelIds?.length) {
|
|
||||||
params.labelIds = filters.labelIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filters.titleOnly) {
|
|
||||||
params.titleOnly = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}, [debouncedSearchQuery, filters]);
|
}, [debouncedSearchQuery, filters]);
|
||||||
|
|
||||||
const {
|
const { data: searchResults, isLoading } = useUnifiedSearch(
|
||||||
data: searchResults,
|
|
||||||
isFetching,
|
|
||||||
} = useUnifiedSearch(
|
|
||||||
searchParams,
|
searchParams,
|
||||||
!isAiMode // Disable regular search when in AI mode
|
!isAiMode // Disable regular search when in AI mode
|
||||||
);
|
);
|
||||||
@@ -106,11 +83,6 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
}
|
}
|
||||||
}, [aiSearchError, t]);
|
}, [aiSearchError, t]);
|
||||||
|
|
||||||
const isFilterBrowse =
|
|
||||||
(filters.labelIds?.length ?? 0) > 0 || !!filters.creatorId;
|
|
||||||
// while the debounce is pending the empty list is not a settled "no results"
|
|
||||||
const isQuerySettled = query === debouncedSearchQuery;
|
|
||||||
|
|
||||||
// Determine result type for rendering
|
// Determine result type for rendering
|
||||||
const isAttachmentSearch =
|
const isAttachmentSearch =
|
||||||
filters.contentType === "attachment" && hasAttachmentIndexing;
|
filters.contentType === "attachment" && hasAttachmentIndexing;
|
||||||
@@ -124,18 +96,9 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
const handleSpotlightOpen = () => {
|
const handleFiltersChange = (newFilters: any) => {
|
||||||
if (
|
|
||||||
workspace?.settings?.ai?.search === true &&
|
|
||||||
getAiVectorDriver() === "turbopuffer"
|
|
||||||
) {
|
|
||||||
hintVectorCache();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleFiltersChange = useCallback((newFilters: any) => {
|
|
||||||
setFilters(newFilters);
|
setFilters(newFilters);
|
||||||
}, [setFilters]);
|
};
|
||||||
|
|
||||||
const handleAskClick = () => {
|
const handleAskClick = () => {
|
||||||
setIsAiMode(!isAiMode);
|
setIsAiMode(!isAiMode);
|
||||||
@@ -152,7 +115,6 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
<Spotlight.Root
|
<Spotlight.Root
|
||||||
size="xl"
|
size="xl"
|
||||||
maxHeight={600}
|
maxHeight={600}
|
||||||
onSpotlightOpen={handleSpotlightOpen}
|
|
||||||
store={searchSpotlightStore}
|
store={searchSpotlightStore}
|
||||||
query={query}
|
query={query}
|
||||||
onQueryChange={setQuery}
|
onQueryChange={setQuery}
|
||||||
@@ -205,7 +167,7 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
? query.length > 0 && !isAiLoading && !aiSearchResult
|
? query.length > 0 && !isAiLoading && !aiSearchResult
|
||||||
? t("No answer available")
|
? t("No answer available")
|
||||||
: ""
|
: ""
|
||||||
: (query.length > 0 || isFilterBrowse) && !isFetching
|
: query.length > 0 && !isLoading
|
||||||
? resultItems.length === 0
|
? resultItems.length === 0
|
||||||
? t("No results found")
|
? t("No results found")
|
||||||
: t("{{count}} results found", { count: resultItems.length })
|
: t("{{count}} results found", { count: resultItems.length })
|
||||||
@@ -232,28 +194,15 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{query.length === 0 && !isFilterBrowse && resultItems.length === 0 && (
|
{query.length === 0 && resultItems.length === 0 && (
|
||||||
<Spotlight.Empty>{t("Start typing to search...")}</Spotlight.Empty>
|
<Spotlight.Empty>{t("Start typing to search...")}</Spotlight.Empty>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(query.length > 0 || isFilterBrowse) &&
|
{query.length > 0 && !isLoading && resultItems.length === 0 && (
|
||||||
!isFetching &&
|
<Spotlight.Empty>{t("No results found...")}</Spotlight.Empty>
|
||||||
isQuerySettled &&
|
)}
|
||||||
resultItems.length === 0 && (
|
|
||||||
<Spotlight.Empty>{t("No results found...")}</Spotlight.Empty>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{resultItems.length > 0 && <>{resultItems}</>}
|
{resultItems.length > 0 && <>{resultItems}</>}
|
||||||
|
|
||||||
{(query.length > 0 || isFilterBrowse) &&
|
|
||||||
isFetching &&
|
|
||||||
resultItems.length === 0 && (
|
|
||||||
<Spotlight.Empty>
|
|
||||||
<Text size="sm" style={{ marginTop: 10 }}>
|
|
||||||
{t("Searching...")}
|
|
||||||
</Text>
|
|
||||||
</Spotlight.Empty>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Spotlight.ActionsList>
|
</Spotlight.ActionsList>
|
||||||
|
|||||||
@@ -39,20 +39,6 @@ export function useUnifiedSearch(
|
|||||||
return await searchPage(backendParams);
|
return await searchPage(backendParams);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled:
|
enabled: !!params.query && enabled,
|
||||||
(!!params.query ||
|
|
||||||
(params.labelIds?.length ?? 0) > 0 ||
|
|
||||||
!!params.creatorId) &&
|
|
||||||
enabled,
|
|
||||||
// keep previous results only within the same search type; page results
|
|
||||||
// rendered as attachments (or vice versa) crash on missing fields
|
|
||||||
placeholderData: (previousData, previousQuery) => {
|
|
||||||
if (!params.query && !params.labelIds?.length && !params.creatorId)
|
|
||||||
return undefined;
|
|
||||||
if (previousQuery && previousQuery.queryKey[1] !== searchType) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return previousData;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ export interface IPageSearchParams {
|
|||||||
query: string;
|
query: string;
|
||||||
spaceId?: string;
|
spaceId?: string;
|
||||||
shareId?: string;
|
shareId?: string;
|
||||||
creatorId?: string;
|
|
||||||
labelIds?: string[];
|
|
||||||
titleOnly?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAttachmentSearch {
|
export interface IAttachmentSearch {
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ export interface IWorkspace {
|
|||||||
generativeAi?: boolean;
|
generativeAi?: boolean;
|
||||||
disablePublicSharing?: boolean;
|
disablePublicSharing?: boolean;
|
||||||
mcpEnabled?: boolean;
|
mcpEnabled?: boolean;
|
||||||
aiChatReadOnly?: boolean;
|
|
||||||
aiChatWorkspaceKnowledgeOnly?: boolean;
|
|
||||||
trashRetentionDays?: number;
|
trashRetentionDays?: number;
|
||||||
restrictApiToAdmins?: boolean;
|
restrictApiToAdmins?: boolean;
|
||||||
allowMemberTemplates?: boolean;
|
allowMemberTemplates?: boolean;
|
||||||
@@ -53,8 +51,6 @@ export interface IWorkspaceAiSettings {
|
|||||||
generative?: boolean;
|
generative?: boolean;
|
||||||
mcp?: boolean;
|
mcp?: boolean;
|
||||||
chat?: boolean;
|
chat?: boolean;
|
||||||
chatReadOnly?: boolean;
|
|
||||||
chatWorkspaceKnowledgeOnly?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IWorkspaceSharingSettings {
|
export interface IWorkspaceSharingSettings {
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ export function isCloud(): boolean {
|
|||||||
return castToBoolean(getConfigValue("CLOUD"));
|
return castToBoolean(getConfigValue("CLOUD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAiVectorDriver(): string {
|
export function isBetaConfluenceImporter(): boolean {
|
||||||
return getConfigValue("AI_VECTOR_DRIVER");
|
return castToBoolean(getConfigValue("BETA_CONFLUENCE_IMPORTER"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAvatarUrl(
|
export function getAvatarUrl(
|
||||||
|
|||||||
@@ -33,31 +33,3 @@
|
|||||||
color: var(--mantine-color-dimmed);
|
color: var(--mantine-color-dimmed);
|
||||||
-webkit-text-fill-color: var(--mantine-color-dimmed);
|
-webkit-text-fill-color: var(--mantine-color-dimmed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Spotlight's selected action ships as primary-filled blue with white text,
|
|
||||||
* but our custom action children (gray badge, dimmed snippet, gray icons)
|
|
||||||
* keep their light-surface colors on it and drop below WCAG AA 4.5:1
|
|
||||||
* (WCAG 1.4.3). Use a gray selection one step above the gray-0/dark-6
|
|
||||||
* hover instead - it matches the app's selection styling (we use no blue
|
|
||||||
* fills) and keeps every child at its already-passing resting contrast.
|
|
||||||
*/
|
|
||||||
.mantine-Spotlight-action[data-selected] {
|
|
||||||
background-color: light-dark(
|
|
||||||
var(--mantine-color-gray-1),
|
|
||||||
var(--mantine-color-dark-5)
|
|
||||||
);
|
|
||||||
color: var(--mantine-color-text);
|
|
||||||
--action-description-color: var(--mantine-color-dimmed);
|
|
||||||
--action-description-opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Result actions are tab stops (tabIndex restored via ref); give keyboard
|
|
||||||
* focus the same gray treatment as arrow-key selection so both navigation
|
|
||||||
* modes read identically (WCAG 2.4.7 focus visible).
|
|
||||||
*/
|
|
||||||
.mantine-Spotlight-action:focus-visible {
|
|
||||||
background-color: light-dark(
|
|
||||||
var(--mantine-color-gray-1),
|
|
||||||
var(--mantine-color-dark-5)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
BILLING_TRIAL_DAYS,
|
BILLING_TRIAL_DAYS,
|
||||||
POSTHOG_HOST,
|
POSTHOG_HOST,
|
||||||
POSTHOG_KEY,
|
POSTHOG_KEY,
|
||||||
AI_VECTOR_DRIVER,
|
BETA_CONFLUENCE_IMPORTER,
|
||||||
} = loadEnv(mode, envPath, "");
|
} = loadEnv(mode, envPath, "");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -32,7 +32,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
BILLING_TRIAL_DAYS,
|
BILLING_TRIAL_DAYS,
|
||||||
POSTHOG_HOST,
|
POSTHOG_HOST,
|
||||||
POSTHOG_KEY,
|
POSTHOG_KEY,
|
||||||
AI_VECTOR_DRIVER,
|
BETA_CONFLUENCE_IMPORTER
|
||||||
},
|
},
|
||||||
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
||||||
},
|
},
|
||||||
@@ -57,6 +57,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
allowedHosts: ['docmost.nz'],
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api": {
|
"/api": {
|
||||||
target: APP_URL,
|
target: APP_URL,
|
||||||
|
|||||||
+11
-11
@@ -40,33 +40,32 @@
|
|||||||
"@clickhouse/client": "1.18.2",
|
"@clickhouse/client": "1.18.2",
|
||||||
"@docmost/base-formula": "workspace:*",
|
"@docmost/base-formula": "workspace:*",
|
||||||
"@docmost/pdf-inspector": "1.9.6",
|
"@docmost/pdf-inspector": "1.9.6",
|
||||||
"@fastify/cookie": "11.1.2",
|
"@fastify/cookie": "11.0.2",
|
||||||
"@fastify/multipart": "10.1.1",
|
"@fastify/multipart": "10.0.0",
|
||||||
"@fastify/static": "10.1.3",
|
"@fastify/static": "10.1.2",
|
||||||
"@keyv/redis": "5.1.6",
|
"@keyv/redis": "5.1.6",
|
||||||
"@langchain/core": "1.1.46",
|
"@langchain/core": "1.1.46",
|
||||||
"@langchain/textsplitters": "1.0.1",
|
"@langchain/textsplitters": "1.0.1",
|
||||||
"@modelcontextprotocol/sdk": "1.30.0",
|
"@modelcontextprotocol/sdk": "1.30.0",
|
||||||
"@nest-lab/throttler-storage-redis": "1.2.0",
|
"@nest-lab/throttler-storage-redis": "1.2.0",
|
||||||
"@nestjs-labs/nestjs-ioredis": "11.0.4",
|
"@nestjs-labs/nestjs-ioredis": "11.0.4",
|
||||||
"@nestjs/bullmq": "11.0.5",
|
"@nestjs/bullmq": "11.0.4",
|
||||||
"@nestjs/cache-manager": "3.1.3",
|
"@nestjs/cache-manager": "3.1.3",
|
||||||
"@nestjs/common": "11.2.1",
|
"@nestjs/common": "11.1.28",
|
||||||
"@nestjs/config": "4.0.4",
|
"@nestjs/config": "4.0.4",
|
||||||
"@nestjs/core": "11.2.1",
|
"@nestjs/core": "11.1.27",
|
||||||
"@nestjs/event-emitter": "3.1.0",
|
"@nestjs/event-emitter": "3.1.0",
|
||||||
"@nestjs/jwt": "11.0.2",
|
"@nestjs/jwt": "11.0.2",
|
||||||
"@nestjs/mapped-types": "2.1.1",
|
"@nestjs/mapped-types": "2.1.1",
|
||||||
"@nestjs/passport": "11.0.5",
|
"@nestjs/passport": "11.0.5",
|
||||||
"@nestjs/platform-fastify": "11.2.1",
|
"@nestjs/platform-fastify": "11.1.28",
|
||||||
"@nestjs/platform-socket.io": "11.2.1",
|
"@nestjs/platform-socket.io": "11.1.28",
|
||||||
"@nestjs/schedule": "6.1.3",
|
"@nestjs/schedule": "6.1.3",
|
||||||
"@nestjs/terminus": "11.1.1",
|
"@nestjs/terminus": "11.1.1",
|
||||||
"@nestjs/throttler": "6.5.0",
|
"@nestjs/throttler": "6.5.0",
|
||||||
"@nestjs/websockets": "11.2.1",
|
"@nestjs/websockets": "11.1.28",
|
||||||
"@node-saml/passport-saml": "5.1.0",
|
"@node-saml/passport-saml": "5.1.0",
|
||||||
"@socket.io/redis-adapter": "8.3.0",
|
"@socket.io/redis-adapter": "8.3.0",
|
||||||
"@turbopuffer/turbopuffer": "^2.8.0",
|
|
||||||
"ai": "6.0.134",
|
"ai": "6.0.134",
|
||||||
"ai-sdk-ollama": "3.8.1",
|
"ai-sdk-ollama": "3.8.1",
|
||||||
"bcrypt": "6.0.0",
|
"bcrypt": "6.0.0",
|
||||||
@@ -78,6 +77,7 @@
|
|||||||
"class-validator": "0.15.1",
|
"class-validator": "0.15.1",
|
||||||
"cookie": "1.1.1",
|
"cookie": "1.1.1",
|
||||||
"csv-stringify": "6.8.0",
|
"csv-stringify": "6.8.0",
|
||||||
|
"entities": "7.0.1",
|
||||||
"fast-bm25": "0.0.5",
|
"fast-bm25": "0.0.5",
|
||||||
"fastify-ip": "2.0.0",
|
"fastify-ip": "2.0.0",
|
||||||
"fs-extra": "11.3.4",
|
"fs-extra": "11.3.4",
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
"tmp-promise": "3.0.3",
|
"tmp-promise": "3.0.3",
|
||||||
"typesense": "3.0.5",
|
"typesense": "3.0.5",
|
||||||
"undici": "7.29.0",
|
"undici": "7.29.0",
|
||||||
"ws": "8.21.3",
|
"ws": "8.21.0",
|
||||||
"yauzl": "3.4.0",
|
"yauzl": "3.4.0",
|
||||||
"zod": "4.3.6"
|
"zod": "4.3.6"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
|
|||||||
import { HealthModule } from './integrations/health/health.module';
|
import { HealthModule } from './integrations/health/health.module';
|
||||||
import { ExportModule } from './integrations/export/export.module';
|
import { ExportModule } from './integrations/export/export.module';
|
||||||
import { ImportModule } from './integrations/import/import.module';
|
import { ImportModule } from './integrations/import/import.module';
|
||||||
|
import { ImportProcessorModule } from './integrations/import/import-processor.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 { RedisModule } from '@nestjs-labs/nestjs-ioredis';
|
||||||
import { RedisConfigService } from './integrations/redis/redis-config.service';
|
import { RedisConfigService } from './integrations/redis/redis-config.service';
|
||||||
import { CacheModule } from '@nestjs/cache-manager';
|
import { CacheModule } from '@nestjs/cache-manager';
|
||||||
import KeyvRedis, { defaultReconnectStrategy } from '@keyv/redis';
|
import KeyvRedis from '@keyv/redis';
|
||||||
import { parseRedisUrl } from './common/helpers';
|
|
||||||
import { LoggerModule } from './common/logger/logger.module';
|
import { LoggerModule } from './common/logger/logger.module';
|
||||||
import { ClsModule } from 'nestjs-cls';
|
import { ClsModule } from 'nestjs-cls';
|
||||||
import { NoopAuditModule } from './integrations/audit/audit.module';
|
import { NoopAuditModule } from './integrations/audit/audit.module';
|
||||||
@@ -63,20 +63,10 @@ try {
|
|||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
useFactory: async (environmentService: EnvironmentService) => {
|
useFactory: async (environmentService: EnvironmentService) => {
|
||||||
const redisUrl = environmentService.getRedisUrl();
|
const redisUrl = environmentService.getRedisUrl();
|
||||||
const { family, tls } = parseRedisUrl(redisUrl);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ttl: 5 * 1000,
|
ttl: 5 * 1000,
|
||||||
stores: [
|
stores: [new KeyvRedis(redisUrl)],
|
||||||
new KeyvRedis({
|
|
||||||
url: redisUrl,
|
|
||||||
socket: {
|
|
||||||
family,
|
|
||||||
reconnectStrategy: defaultReconnectStrategy,
|
|
||||||
...tls,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
inject: [EnvironmentService],
|
inject: [EnvironmentService],
|
||||||
@@ -87,6 +77,7 @@ try {
|
|||||||
StaticModule,
|
StaticModule,
|
||||||
HealthModule,
|
HealthModule,
|
||||||
ImportModule,
|
ImportModule,
|
||||||
|
ImportProcessorModule,
|
||||||
ExportModule,
|
ExportModule,
|
||||||
StorageModule.forRootAsync({
|
StorageModule.forRootAsync({
|
||||||
imports: [EnvironmentModule],
|
imports: [EnvironmentModule],
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ export class CollaborationGateway {
|
|||||||
password: this.redisConfig.password,
|
password: this.redisConfig.password,
|
||||||
db: this.redisConfig.db,
|
db: this.redisConfig.db,
|
||||||
family: this.redisConfig.family,
|
family: this.redisConfig.family,
|
||||||
tls: this.redisConfig.tls,
|
|
||||||
retryStrategy: createRetryStrategy(),
|
retryStrategy: createRetryStrategy(),
|
||||||
}),
|
}),
|
||||||
serverId: `collab-${os?.hostname()}-${nanoid(10)}`,
|
serverId: `collab-${os?.hostname()}-${nanoid(10)}`,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { Superscript } from '@tiptap/extension-superscript';
|
|||||||
import SubScript from '@tiptap/extension-subscript';
|
import SubScript from '@tiptap/extension-subscript';
|
||||||
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 { Youtube } from '@tiptap/extension-youtube';
|
import { Youtube } from '@tiptap/extension-youtube';
|
||||||
import { TaskList, TaskItem } from '@tiptap/extension-list';
|
import { TaskList, TaskItem } from '@tiptap/extension-list';
|
||||||
import {
|
import {
|
||||||
@@ -36,6 +35,7 @@ import {
|
|||||||
Mention,
|
Mention,
|
||||||
Subpages,
|
Subpages,
|
||||||
Highlight,
|
Highlight,
|
||||||
|
Color,
|
||||||
Indent,
|
Indent,
|
||||||
UniqueID,
|
UniqueID,
|
||||||
Columns,
|
Columns,
|
||||||
@@ -57,7 +57,6 @@ import {
|
|||||||
JSONContent,
|
JSONContent,
|
||||||
} from '@tiptap/core';
|
} from '@tiptap/core';
|
||||||
import { generateHTML, generateJSON } from '../common/helpers/prosemirror/html';
|
import { generateHTML, generateJSON } from '../common/helpers/prosemirror/html';
|
||||||
import { collapseBlankLines } from '../common/helpers';
|
|
||||||
// @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
|
||||||
@@ -147,7 +146,7 @@ export function htmlToJson(html: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function jsonToText(tiptapJson: JSONContent) {
|
export function jsonToText(tiptapJson: JSONContent) {
|
||||||
return collapseBlankLines(generateText(tiptapJson, tiptapExtensions));
|
return generateText(tiptapJson, tiptapExtensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function jsonToNode(tiptapJson: JSONContent) {
|
export function jsonToNode(tiptapJson: JSONContent) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export const Feature = {
|
|||||||
PAGE_PERMISSIONS: 'page:permissions',
|
PAGE_PERMISSIONS: 'page:permissions',
|
||||||
AI: 'ai',
|
AI: 'ai',
|
||||||
CONFLUENCE_IMPORT: 'import:confluence',
|
CONFLUENCE_IMPORT: 'import:confluence',
|
||||||
|
CONFLUENCE_API_IMPORT: 'import:confluence-api',
|
||||||
DOCX_IMPORT: 'import:docx',
|
DOCX_IMPORT: 'import:docx',
|
||||||
PDF_IMPORT: 'import:pdf',
|
PDF_IMPORT: 'import:pdf',
|
||||||
ATTACHMENT_INDEXING: 'attachment:indexing',
|
ATTACHMENT_INDEXING: 'attachment:indexing',
|
||||||
@@ -23,7 +24,6 @@ export const Feature = {
|
|||||||
PERSONAL_SPACES: 'spaces:personal',
|
PERSONAL_SPACES: 'spaces:personal',
|
||||||
DOCX_EXPORT: 'export:docx',
|
DOCX_EXPORT: 'export:docx',
|
||||||
BASES: 'bases',
|
BASES: 'bases',
|
||||||
AI_CONTROLS: 'ai:controls',
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type FeatureKey = (typeof Feature)[keyof typeof Feature];
|
export type FeatureKey = (typeof Feature)[keyof typeof Feature];
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './text.utils';
|
|
||||||
export * from './nanoid.utils';
|
export * from './nanoid.utils';
|
||||||
export * from './file.helper';
|
export * from './file.helper';
|
||||||
export * from './constants';
|
export * from './constants';
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import { collapseBlankLines } from './text.utils';
|
|
||||||
|
|
||||||
describe('collapseBlankLines', () => {
|
|
||||||
it.each([
|
|
||||||
['a\n\n\n\nb', 'a\n\nb'],
|
|
||||||
['a\n\nb', 'a\n\nb'],
|
|
||||||
['a\nb', 'a\nb'],
|
|
||||||
['\n\n\n\na\n\n\n', '\n\na\n\n'],
|
|
||||||
['no newlines', 'no newlines'],
|
|
||||||
['', ''],
|
|
||||||
])('collapses %j to %j', (input, expected) => {
|
|
||||||
expect(collapseBlankLines(input)).toBe(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export function collapseBlankLines(text: string): string {
|
|
||||||
return text.replace(/\n{2,}/g, '\n\n');
|
|
||||||
}
|
|
||||||
@@ -30,14 +30,13 @@ export type RedisConfig = {
|
|||||||
db: number;
|
db: number;
|
||||||
password?: string;
|
password?: string;
|
||||||
family?: number;
|
family?: number;
|
||||||
tls?: { rejectUnauthorized?: boolean };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function parseRedisUrl(redisUrl: string): RedisConfig {
|
export function parseRedisUrl(redisUrl: string): RedisConfig {
|
||||||
// format - redis[s]://[[username][:password]@][host][:port][/db-number][?family=4|6][&rejectUnauthorized=false]
|
// format - redis[s]://[[username][:password]@][host][:port][/db-number][?family=4|6]
|
||||||
const url = new URL(redisUrl);
|
const url = new URL(redisUrl);
|
||||||
const { hostname, port, password, pathname, protocol, searchParams } = url;
|
const { hostname, port, password, pathname, searchParams } = url;
|
||||||
const portInt = port ? parseInt(port, 10) : 6379;
|
const portInt = parseInt(port, 10);
|
||||||
|
|
||||||
let db: number = 0;
|
let db: number = 0;
|
||||||
// extract db value if present
|
// extract db value if present
|
||||||
@@ -55,14 +54,7 @@ export function parseRedisUrl(redisUrl: string): RedisConfig {
|
|||||||
family = parseInt(familyParam, 10);
|
family = parseInt(familyParam, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tls =
|
return { host: hostname, port: portInt, password, db, family };
|
||||||
protocol === 'rediss:'
|
|
||||||
? searchParams.get('rejectUnauthorized') === 'false'
|
|
||||||
? { rejectUnauthorized: false }
|
|
||||||
: {}
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return { host: hostname, port: portInt, password: password || undefined, db, family, tls };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createRetryStrategy() {
|
export function createRetryStrategy() {
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ export class AttachmentService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only index PDF, DOCX and TXT files
|
// Only index PDFs and DOCX files
|
||||||
if (['.pdf', '.docx', '.txt'].includes(attachment.fileExt.toLowerCase())) {
|
if (['.pdf', '.docx'].includes(attachment.fileExt.toLowerCase())) {
|
||||||
await this.attachmentQueue.add(
|
await this.attachmentQueue.add(
|
||||||
QueueJob.ATTACHMENT_INDEX_CONTENT,
|
QueueJob.ATTACHMENT_INDEX_CONTENT,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class CommentController {
|
|||||||
@AuthWorkspace() workspace: Workspace,
|
@AuthWorkspace() workspace: Workspace,
|
||||||
) {
|
) {
|
||||||
const page = await this.pageRepo.findById(createCommentDto.pageId);
|
const page = await this.pageRepo.findById(createCommentDto.pageId);
|
||||||
if (!page || page.workspaceId !== workspace.id || page.deletedAt) {
|
if (!page || page.deletedAt) {
|
||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,10 +89,9 @@ export class CommentController {
|
|||||||
@Body()
|
@Body()
|
||||||
pagination: PaginationOptions,
|
pagination: PaginationOptions,
|
||||||
@AuthUser() user: User,
|
@AuthUser() user: User,
|
||||||
@AuthWorkspace() workspace: Workspace,
|
|
||||||
) {
|
) {
|
||||||
const page = await this.pageRepo.findById(input.pageId);
|
const page = await this.pageRepo.findById(input.pageId);
|
||||||
if (!page || page.workspaceId !== workspace.id || page.deletedAt) {
|
if (!page) {
|
||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,18 +102,14 @@ export class CommentController {
|
|||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Post('info')
|
@Post('info')
|
||||||
async findOne(
|
async findOne(@Body() input: CommentIdDto, @AuthUser() user: User) {
|
||||||
@Body() input: CommentIdDto,
|
|
||||||
@AuthUser() user: User,
|
|
||||||
@AuthWorkspace() workspace: Workspace,
|
|
||||||
) {
|
|
||||||
const comment = await this.commentRepo.findById(input.commentId);
|
const comment = await this.commentRepo.findById(input.commentId);
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
throw new NotFoundException('Comment not found');
|
throw new NotFoundException('Comment not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const page = await this.pageRepo.findById(comment.pageId);
|
const page = await this.pageRepo.findById(comment.pageId);
|
||||||
if (!page || page.workspaceId !== workspace.id || page.deletedAt) {
|
if (!page) {
|
||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +130,7 @@ export class CommentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const page = await this.pageRepo.findById(comment.pageId);
|
const page = await this.pageRepo.findById(comment.pageId);
|
||||||
if (!page || page.workspaceId !== workspace.id || page.deletedAt) {
|
if (!page) {
|
||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +148,7 @@ export class CommentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const page = await this.pageRepo.findById(comment.pageId);
|
const page = await this.pageRepo.findById(comment.pageId);
|
||||||
if (!page || page.workspaceId !== workspace.id || page.deletedAt) {
|
if (!page) {
|
||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,15 +7,12 @@ import { executeTx } from '@docmost/db/utils';
|
|||||||
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
||||||
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
||||||
import { normalizeLabelName } from './utils';
|
import { normalizeLabelName } from './utils';
|
||||||
import { EventEmitter2 } from "@nestjs/event-emitter";
|
|
||||||
import { EventName } from "src/common/events/event.contants";
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LabelService {
|
export class LabelService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly labelRepo: LabelRepo,
|
private readonly labelRepo: LabelRepo,
|
||||||
private readonly pagePermissionRepo: PagePermissionRepo,
|
private readonly pagePermissionRepo: PagePermissionRepo,
|
||||||
private readonly eventEmitter: EventEmitter2,
|
|
||||||
@InjectKysely() private readonly db: KyselyDB,
|
@InjectKysely() private readonly db: KyselyDB,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -37,12 +34,6 @@ export class LabelService {
|
|||||||
attached.push(label);
|
attached.push(label);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.eventEmitter.emit(EventName.PAGE_UPDATED, {
|
|
||||||
pageIds: [pageId],
|
|
||||||
workspaceId: workspaceId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return attached;
|
return attached;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,11 +64,6 @@ export class LabelService {
|
|||||||
await this.labelRepo.deleteLabel(labelId, workspaceId, trx);
|
await this.labelRepo.deleteLabel(labelId, workspaceId, trx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.eventEmitter.emit(EventName.PAGE_UPDATED, {
|
|
||||||
pageIds: [pageId],
|
|
||||||
workspaceId: workspaceId,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPageLabels(pageId: string, pagination: PaginationOptions) {
|
async getPageLabels(pageId: string, pagination: PaginationOptions) {
|
||||||
|
|||||||
@@ -175,44 +175,7 @@ export class PageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async nextPagePosition(spaceId: string, parentPageId?: string) {
|
async nextPagePosition(spaceId: string, parentPageId?: string) {
|
||||||
let pagePosition: string;
|
return this.pageRepo.nextPagePosition(spaceId, parentPageId);
|
||||||
|
|
||||||
const lastPageQuery = this.db
|
|
||||||
.selectFrom('pages')
|
|
||||||
.select(['position'])
|
|
||||||
.where('spaceId', '=', spaceId)
|
|
||||||
.where('deletedAt', 'is', null)
|
|
||||||
.orderBy('position', (ob) => ob.collate('C').desc())
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
if (parentPageId) {
|
|
||||||
// check for children of this page
|
|
||||||
const lastPage = await lastPageQuery
|
|
||||||
.where('parentPageId', '=', parentPageId)
|
|
||||||
.executeTakeFirst();
|
|
||||||
|
|
||||||
if (!lastPage) {
|
|
||||||
pagePosition = generateJitteredKeyBetween(null, null);
|
|
||||||
} else {
|
|
||||||
// if there is an existing page, we should get a position below it
|
|
||||||
pagePosition = generateJitteredKeyBetween(lastPage.position, null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// for root page
|
|
||||||
const lastPage = await lastPageQuery
|
|
||||||
.where('parentPageId', 'is', null)
|
|
||||||
.executeTakeFirst();
|
|
||||||
|
|
||||||
// if no existing page, make this the first
|
|
||||||
if (!lastPage) {
|
|
||||||
pagePosition = generateJitteredKeyBetween(null, null); // we expect "a0"
|
|
||||||
} else {
|
|
||||||
// if there is an existing page, we should get a position below it
|
|
||||||
pagePosition = generateJitteredKeyBetween(lastPage.position, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pagePosition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(
|
async update(
|
||||||
@@ -496,21 +459,10 @@ export class PageService {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.aiQueue.add(
|
await this.aiQueue.add(QueueJob.PAGE_MOVED_TO_SPACE, {
|
||||||
QueueJob.PAGE_MOVED_TO_SPACE,
|
pageIds: pageIdsToMove,
|
||||||
{
|
workspaceId: rootPage.workspaceId,
|
||||||
pageIds: pageIdsToMove,
|
});
|
||||||
spaceId,
|
|
||||||
workspaceId: rootPage.workspaceId,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
attempts: 2,
|
|
||||||
backoff: {
|
|
||||||
type: 'fixed',
|
|
||||||
delay: 2 * 60 * 1000,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
IsArray,
|
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsNotEmpty,
|
IsNotEmpty,
|
||||||
IsNumber,
|
IsNumber,
|
||||||
@@ -9,9 +8,9 @@ import {
|
|||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
|
||||||
export class SearchDTO {
|
export class SearchDTO {
|
||||||
@IsOptional()
|
@IsNotEmpty()
|
||||||
@IsString()
|
@IsString()
|
||||||
query?: string;
|
query: string;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsUUID()
|
@IsUUID()
|
||||||
@@ -25,15 +24,6 @@ export class SearchDTO {
|
|||||||
@IsUUID()
|
@IsUUID()
|
||||||
creatorId?: string;
|
creatorId?: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsArray()
|
|
||||||
@IsUUID('all', { each: true })
|
|
||||||
labelIds?: string[];
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
titleOnly?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
limit?: number;
|
limit?: number;
|
||||||
|
|||||||
@@ -29,36 +29,12 @@ export class SearchService {
|
|||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
},
|
},
|
||||||
): Promise<{ items: SearchResponseDto[] }> {
|
): Promise<{ items: SearchResponseDto[] }> {
|
||||||
const query = searchParams.query?.trim() ?? '';
|
const { query } = searchParams;
|
||||||
const labelIds = [...new Set(searchParams.labelIds ?? [])];
|
|
||||||
// selected filters (labels, creator) are browsable without a query
|
|
||||||
const browseByFilters =
|
|
||||||
query.length < 1 &&
|
|
||||||
(labelIds.length > 0 || Boolean(searchParams.creatorId));
|
|
||||||
|
|
||||||
if (query.length < 1 && !browseByFilters) {
|
if (query.length < 1) {
|
||||||
return { items: [] };
|
return { items: [] };
|
||||||
}
|
}
|
||||||
const searchQuery = tsquery(query + '*');
|
const searchQuery = tsquery(query.trim() + '*');
|
||||||
const titleOnly = searchParams.titleOnly === true;
|
|
||||||
const titleQuery = query;
|
|
||||||
// escape LIKE wildcards; ranking keeps the raw query
|
|
||||||
const titleLikeQuery = query.replace(/[\\%_]/g, '\\$&');
|
|
||||||
|
|
||||||
const rankColumn = browseByFilters
|
|
||||||
? sql<number>`0`.as('rank')
|
|
||||||
: titleOnly
|
|
||||||
? sql<number>`word_similarity(lower(f_unaccent(${titleQuery})), lower(f_unaccent(pages.title)))`.as(
|
|
||||||
'rank',
|
|
||||||
)
|
|
||||||
: sql<number>`ts_rank(tsv, to_tsquery('english', f_unaccent(${searchQuery})))`.as(
|
|
||||||
'rank',
|
|
||||||
);
|
|
||||||
const highlightColumn = browseByFilters || titleOnly
|
|
||||||
? sql<string>`''`.as('highlight')
|
|
||||||
: sql<string>`ts_headline('english', text_content, to_tsquery('english', f_unaccent(${searchQuery})),'MinWords=9, MaxWords=10, MaxFragments=3')`.as(
|
|
||||||
'highlight',
|
|
||||||
);
|
|
||||||
|
|
||||||
let queryResults = this.db
|
let queryResults = this.db
|
||||||
.selectFrom('pages')
|
.selectFrom('pages')
|
||||||
@@ -71,41 +47,23 @@ export class SearchService {
|
|||||||
'creatorId',
|
'creatorId',
|
||||||
'createdAt',
|
'createdAt',
|
||||||
'updatedAt',
|
'updatedAt',
|
||||||
rankColumn,
|
sql<number>`ts_rank(tsv, to_tsquery('english', f_unaccent(${searchQuery})))`.as(
|
||||||
highlightColumn,
|
'rank',
|
||||||
|
),
|
||||||
|
sql<string>`ts_headline('english', text_content, to_tsquery('english', f_unaccent(${searchQuery})),'MinWords=9, MaxWords=10, MaxFragments=3')`.as(
|
||||||
|
'highlight',
|
||||||
|
),
|
||||||
])
|
])
|
||||||
.$if(!browseByFilters && !titleOnly, (qb) =>
|
.where(
|
||||||
qb.where(
|
'tsv',
|
||||||
'tsv',
|
'@@',
|
||||||
'@@',
|
sql<string>`to_tsquery('english', f_unaccent(${searchQuery}))`,
|
||||||
sql<string>`to_tsquery('english', f_unaccent(${searchQuery}))`,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.$if(!browseByFilters && titleOnly, (qb) =>
|
|
||||||
qb.where((eb) =>
|
|
||||||
eb(
|
|
||||||
sql`lower(f_unaccent(pages.title))`,
|
|
||||||
'like',
|
|
||||||
sql`lower(f_unaccent(${`%${titleLikeQuery}%`}))`,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.$if(Boolean(searchParams.creatorId), (qb) =>
|
.$if(Boolean(searchParams.creatorId), (qb) =>
|
||||||
qb.where('creatorId', '=', searchParams.creatorId),
|
qb.where('creatorId', '=', searchParams.creatorId),
|
||||||
)
|
)
|
||||||
.$if(labelIds?.length > 0, (qb) =>
|
|
||||||
qb.where(
|
|
||||||
'id',
|
|
||||||
'in',
|
|
||||||
this.db
|
|
||||||
.selectFrom('pageLabels')
|
|
||||||
.select('pageId')
|
|
||||||
.where('labelId', 'in', labelIds),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.where('deletedAt', 'is', null)
|
.where('deletedAt', 'is', null)
|
||||||
.$if(browseByFilters, (qb) => qb.orderBy('updatedAt', 'desc'))
|
.orderBy('rank', 'desc')
|
||||||
.$if(!browseByFilters, (qb) => qb.orderBy('rank', 'desc'))
|
|
||||||
.limit(searchParams.limit || 25)
|
.limit(searchParams.limit || 25)
|
||||||
.offset(searchParams.offset || 0);
|
.offset(searchParams.offset || 0);
|
||||||
|
|
||||||
@@ -113,7 +71,8 @@ export class SearchService {
|
|||||||
queryResults = queryResults.select((eb) => this.pageRepo.withSpace(eb));
|
queryResults = queryResults.select((eb) => this.pageRepo.withSpace(eb));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams.spaceId && opts.userId) {
|
if (searchParams.spaceId) {
|
||||||
|
// search by spaceId
|
||||||
queryResults = queryResults.where('spaceId', '=', searchParams.spaceId);
|
queryResults = queryResults.where('spaceId', '=', searchParams.spaceId);
|
||||||
} else if (opts.userId && !searchParams.spaceId) {
|
} else if (opts.userId && !searchParams.spaceId) {
|
||||||
// only search spaces the user is a member of
|
// only search spaces the user is a member of
|
||||||
|
|||||||
@@ -46,9 +46,8 @@ export class ShareService {
|
|||||||
throw new NotFoundException('Share not found');
|
throw new NotFoundException('Share not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const isRestricted = await this.pagePermissionRepo.hasRestrictedAncestor(
|
const isRestricted =
|
||||||
share.pageId,
|
await this.pagePermissionRepo.hasRestrictedAncestor(share.pageId);
|
||||||
);
|
|
||||||
if (isRestricted) {
|
if (isRestricted) {
|
||||||
throw new NotFoundException('Share not found');
|
throw new NotFoundException('Share not found');
|
||||||
}
|
}
|
||||||
@@ -111,9 +110,6 @@ export class ShareService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getSharedPage(dto: ShareInfoDto, workspaceId: string) {
|
async getSharedPage(dto: ShareInfoDto, workspaceId: string) {
|
||||||
//TODO: we should resolve the page from the share id
|
|
||||||
if (!dto.pageId) throw new NotFoundException('Shared page not found');
|
|
||||||
|
|
||||||
const share = await this.getShareForPage(dto.pageId, workspaceId);
|
const share = await this.getShareForPage(dto.pageId, workspaceId);
|
||||||
|
|
||||||
if (!share) {
|
if (!share) {
|
||||||
@@ -130,9 +126,8 @@ export class ShareService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Block access to restricted pages
|
// Block access to restricted pages
|
||||||
const isRestricted = await this.pagePermissionRepo.hasRestrictedAncestor(
|
const isRestricted =
|
||||||
page.id,
|
await this.pagePermissionRepo.hasRestrictedAncestor(page.id);
|
||||||
);
|
|
||||||
if (isRestricted) {
|
if (isRestricted) {
|
||||||
throw new NotFoundException('Shared page not found');
|
throw new NotFoundException('Shared page not found');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,25 +339,15 @@ export class SpaceMemberService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await executeTx(this.db, async (trx) => {
|
if (spaceMember.role === SpaceRole.ADMIN) {
|
||||||
await trx
|
await this.validateLastAdmin(dto.spaceId);
|
||||||
.selectFrom('spaces')
|
}
|
||||||
.select('id')
|
|
||||||
.where('id', '=', dto.spaceId)
|
|
||||||
.forUpdate()
|
|
||||||
.executeTakeFirst();
|
|
||||||
|
|
||||||
if (spaceMember.role === SpaceRole.ADMIN) {
|
await this.spaceMemberRepo.updateSpaceMember(
|
||||||
await this.validateLastAdmin(dto.spaceId, trx);
|
{ role: dto.role },
|
||||||
}
|
spaceMember.id,
|
||||||
|
dto.spaceId,
|
||||||
await this.spaceMemberRepo.updateSpaceMember(
|
);
|
||||||
{ role: dto.role },
|
|
||||||
spaceMember.id,
|
|
||||||
dto.spaceId,
|
|
||||||
trx,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
event: AuditEvent.SPACE_MEMBER_ROLE_CHANGED,
|
event: AuditEvent.SPACE_MEMBER_ROLE_CHANGED,
|
||||||
@@ -378,14 +368,10 @@ export class SpaceMemberService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateLastAdmin(
|
async validateLastAdmin(spaceId: string): Promise<void> {
|
||||||
spaceId: string,
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
): Promise<void> {
|
|
||||||
const spaceOwnerCount = await this.spaceMemberRepo.roleCountBySpaceId(
|
const spaceOwnerCount = await this.spaceMemberRepo.roleCountBySpaceId(
|
||||||
SpaceRole.ADMIN,
|
SpaceRole.ADMIN,
|
||||||
spaceId,
|
spaceId,
|
||||||
trx,
|
|
||||||
);
|
);
|
||||||
if (spaceOwnerCount === 1) {
|
if (spaceOwnerCount === 1) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
|
|||||||
@@ -68,12 +68,4 @@ export class UpdateWorkspaceDto extends PartialType(CreateWorkspaceDto) {
|
|||||||
@IsString()
|
@IsString()
|
||||||
@IsIn(['read', 'edit'])
|
@IsIn(['read', 'edit'])
|
||||||
defaultPageEditMode: string;
|
defaultPageEditMode: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
aiChatReadOnly: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
aiChatWorkspaceKnowledgeOnly: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,9 +334,7 @@ export class WorkspaceService {
|
|||||||
typeof updateWorkspaceDto.restrictApiToAdmins !== 'undefined' ||
|
typeof updateWorkspaceDto.restrictApiToAdmins !== 'undefined' ||
|
||||||
typeof updateWorkspaceDto.allowMemberTemplates !== 'undefined' ||
|
typeof updateWorkspaceDto.allowMemberTemplates !== 'undefined' ||
|
||||||
typeof updateWorkspaceDto.isScimEnabled !== 'undefined' ||
|
typeof updateWorkspaceDto.isScimEnabled !== 'undefined' ||
|
||||||
typeof updateWorkspaceDto.allowPersonalSpaces !== 'undefined' ||
|
typeof updateWorkspaceDto.allowPersonalSpaces !== 'undefined'
|
||||||
typeof updateWorkspaceDto.aiChatReadOnly !== 'undefined' ||
|
|
||||||
typeof updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly !== 'undefined'
|
|
||||||
) {
|
) {
|
||||||
const ws = await this.db
|
const ws = await this.db
|
||||||
.selectFrom('workspaces')
|
.selectFrom('workspaces')
|
||||||
@@ -376,21 +374,6 @@ export class WorkspaceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
typeof updateWorkspaceDto.aiChatReadOnly !== 'undefined' ||
|
|
||||||
typeof updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly !== 'undefined'
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
!this.licenseCheckService.hasFeature(
|
|
||||||
ws.licenseKey,
|
|
||||||
Feature.AI_CONTROLS,
|
|
||||||
ws.plan,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new ForbiddenException('This feature requires a valid license');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof updateWorkspaceDto.disablePublicSharing !== 'undefined' ||
|
typeof updateWorkspaceDto.disablePublicSharing !== 'undefined' ||
|
||||||
typeof updateWorkspaceDto.trashRetentionDays !== 'undefined' ||
|
typeof updateWorkspaceDto.trashRetentionDays !== 'undefined' ||
|
||||||
@@ -413,10 +396,7 @@ export class WorkspaceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (updateWorkspaceDto.aiSearch) {
|
||||||
updateWorkspaceDto.aiSearch &&
|
|
||||||
this.environmentService.getAiVectorDriver() !== 'turbopuffer'
|
|
||||||
) {
|
|
||||||
const tableExists = await isPageEmbeddingsTableExists(this.db);
|
const tableExists = await isPageEmbeddingsTableExists(this.db);
|
||||||
if (!tableExists) {
|
if (!tableExists) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
@@ -533,34 +513,6 @@ export class WorkspaceService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof updateWorkspaceDto.aiChatReadOnly !== 'undefined') {
|
|
||||||
const prev = settingsBefore?.ai?.chatReadOnly ?? false;
|
|
||||||
if (prev !== updateWorkspaceDto.aiChatReadOnly) {
|
|
||||||
before.aiChatReadOnly = prev;
|
|
||||||
after.aiChatReadOnly = updateWorkspaceDto.aiChatReadOnly;
|
|
||||||
}
|
|
||||||
await this.workspaceRepo.updateAiSettings(
|
|
||||||
workspaceId,
|
|
||||||
'chatReadOnly',
|
|
||||||
updateWorkspaceDto.aiChatReadOnly,
|
|
||||||
trx,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly !== 'undefined') {
|
|
||||||
const prev = settingsBefore?.ai?.chatWorkspaceKnowledgeOnly ?? false;
|
|
||||||
if (prev !== updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly) {
|
|
||||||
before.aiChatWorkspaceKnowledgeOnly = prev;
|
|
||||||
after.aiChatWorkspaceKnowledgeOnly = updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly;
|
|
||||||
}
|
|
||||||
await this.workspaceRepo.updateAiSettings(
|
|
||||||
workspaceId,
|
|
||||||
'chatWorkspaceKnowledgeOnly',
|
|
||||||
updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly,
|
|
||||||
trx,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof updateWorkspaceDto.allowPersonalSpaces !== 'undefined') {
|
if (typeof updateWorkspaceDto.allowPersonalSpaces !== 'undefined') {
|
||||||
const prev = settingsBefore?.spaces?.allowPersonal ?? false;
|
const prev = settingsBefore?.spaces?.allowPersonal ?? false;
|
||||||
if (prev !== updateWorkspaceDto.allowPersonalSpaces) {
|
if (prev !== updateWorkspaceDto.allowPersonalSpaces) {
|
||||||
@@ -598,8 +550,6 @@ export class WorkspaceService {
|
|||||||
delete updateWorkspaceDto.aiChat;
|
delete updateWorkspaceDto.aiChat;
|
||||||
delete updateWorkspaceDto.allowPersonalSpaces;
|
delete updateWorkspaceDto.allowPersonalSpaces;
|
||||||
delete updateWorkspaceDto.defaultPageEditMode;
|
delete updateWorkspaceDto.defaultPageEditMode;
|
||||||
delete updateWorkspaceDto.aiChatReadOnly;
|
|
||||||
delete updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly;
|
|
||||||
|
|
||||||
await this.workspaceRepo.updateWorkspace(
|
await this.workspaceRepo.updateWorkspace(
|
||||||
updateWorkspaceDto,
|
updateWorkspaceDto,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { EnvironmentService } from '../../integrations/environment/environment.s
|
|||||||
|
|
||||||
export class SpaceEvent {
|
export class SpaceEvent {
|
||||||
spaceId: string;
|
spaceId: string;
|
||||||
workspaceId: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -23,12 +22,12 @@ export class SpaceListener {
|
|||||||
|
|
||||||
@OnEvent(EventName.SPACE_DELETED)
|
@OnEvent(EventName.SPACE_DELETED)
|
||||||
async handleSpaceDeleted(event: SpaceEvent) {
|
async handleSpaceDeleted(event: SpaceEvent) {
|
||||||
const { spaceId, workspaceId } = event;
|
const { spaceId } = event;
|
||||||
if (this.isTypesense()) {
|
if (this.isTypesense()) {
|
||||||
await this.searchQueue.add(QueueJob.SPACE_DELETED, { spaceId });
|
await this.searchQueue.add(QueueJob.SPACE_DELETED, { spaceId });
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.aiQueue.add(QueueJob.SPACE_DELETED, { spaceId, workspaceId });
|
await this.aiQueue.add(QueueJob.SPACE_DELETED, { spaceId });
|
||||||
}
|
}
|
||||||
|
|
||||||
isTypesense(): boolean {
|
isTypesense(): boolean {
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
import { type Kysely, sql } from 'kysely';
|
|
||||||
|
|
||||||
export async function up(db: Kysely<any>): Promise<void> {
|
|
||||||
await sql`CREATE INDEX IF NOT EXISTS pages_title_trgm_idx ON pages USING gin (lower(f_unaccent(title)) gin_trgm_ops)`.execute(
|
|
||||||
db,
|
|
||||||
);
|
|
||||||
|
|
||||||
// separators normalized to spaces so space-typed queries match How_to_export.pdf
|
|
||||||
await sql`CREATE INDEX IF NOT EXISTS attachments_file_name_trgm_idx ON attachments USING gin (lower(f_unaccent(translate(file_name, '_.-', ' '))) gin_trgm_ops)`.execute(
|
|
||||||
db,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(db: Kysely<any>): Promise<void> {
|
|
||||||
await sql`DROP INDEX IF EXISTS attachments_file_name_trgm_idx`.execute(db);
|
|
||||||
await sql`DROP INDEX IF EXISTS pages_title_trgm_idx`.execute(db);
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,7 @@ import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
|||||||
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
||||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||||
import { EventName } from '../../../common/events/event.contants';
|
import { EventName } from '../../../common/events/event.contants';
|
||||||
|
import { generateJitteredKeyBetween } from 'fractional-indexing-jittered';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PageRepo {
|
export class PageRepo {
|
||||||
@@ -605,4 +606,27 @@ export class PageRepo {
|
|||||||
.execute()
|
.execute()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async nextPagePosition(
|
||||||
|
spaceId: string,
|
||||||
|
parentPageId?: string,
|
||||||
|
): Promise<string> {
|
||||||
|
const lastPageQuery = this.db
|
||||||
|
.selectFrom('pages')
|
||||||
|
.select(['position'])
|
||||||
|
.where('spaceId', '=', spaceId)
|
||||||
|
.where('deletedAt', 'is', null)
|
||||||
|
.orderBy('position', (ob) => ob.collate('C').desc())
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
const lastPage = parentPageId
|
||||||
|
? await lastPageQuery
|
||||||
|
.where('parentPageId', '=', parentPageId)
|
||||||
|
.executeTakeFirst()
|
||||||
|
: await lastPageQuery
|
||||||
|
.where('parentPageId', 'is', null)
|
||||||
|
.executeTakeFirst();
|
||||||
|
|
||||||
|
return generateJitteredKeyBetween(lastPage?.position ?? null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,8 @@ export class SpaceMemberRepo {
|
|||||||
updatableSpaceMember: UpdatableSpaceMember,
|
updatableSpaceMember: UpdatableSpaceMember,
|
||||||
spaceMemberId: string,
|
spaceMemberId: string,
|
||||||
spaceId: string,
|
spaceId: string,
|
||||||
trx?: KyselyTransaction,
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const db = dbOrTx(this.db, trx);
|
await this.db
|
||||||
await db
|
|
||||||
.updateTable('spaceMembers')
|
.updateTable('spaceMembers')
|
||||||
.set(updatableSpaceMember)
|
.set(updatableSpaceMember)
|
||||||
.where('id', '=', spaceMemberId)
|
.where('id', '=', spaceMemberId)
|
||||||
@@ -94,13 +92,8 @@ export class SpaceMemberRepo {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
async roleCountBySpaceId(
|
async roleCountBySpaceId(role: string, spaceId: string): Promise<number> {
|
||||||
role: string,
|
const { count } = await this.db
|
||||||
spaceId: string,
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
): Promise<number> {
|
|
||||||
const db = dbOrTx(this.db, trx);
|
|
||||||
const { count } = await db
|
|
||||||
.selectFrom('spaceMembers')
|
.selectFrom('spaceMembers')
|
||||||
.select((eb) => eb.fn.count('role').as('count'))
|
.select((eb) => eb.fn.count('role').as('count'))
|
||||||
.where('role', '=', role)
|
.where('role', '=', role)
|
||||||
|
|||||||
@@ -230,7 +230,6 @@ export class SpaceRepo {
|
|||||||
|
|
||||||
this.eventEmitter.emit(EventName.SPACE_DELETED, {
|
this.eventEmitter.emit(EventName.SPACE_DELETED, {
|
||||||
spaceId,
|
spaceId,
|
||||||
workspaceId,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,24 +211,6 @@ export class WorkspaceRepo {
|
|||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateAiEmbeddingFingerprint(
|
|
||||||
workspaceId: string,
|
|
||||||
fingerprint: { driver: string; model: string; dimensions: number },
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
) {
|
|
||||||
const db = dbOrTx(this.db, trx);
|
|
||||||
return db
|
|
||||||
.updateTable('workspaces')
|
|
||||||
.set({
|
|
||||||
settings: sql`COALESCE(settings, '{}'::jsonb)
|
|
||||||
|| jsonb_build_object('ai', COALESCE(settings->'ai', '{}'::jsonb)
|
|
||||||
|| jsonb_build_object('embedding', ${JSON.stringify(fingerprint)}::text::jsonb))`,
|
|
||||||
updatedAt: new Date(),
|
|
||||||
})
|
|
||||||
.where('id', '=', workspaceId)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateSharingSettings(
|
async updateSharingSettings(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
prefKey: string,
|
prefKey: string,
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Json, Timestamp, Generated } from '@docmost/db/types/db';
|
||||||
|
|
||||||
|
export interface ConfluenceApiImports {
|
||||||
|
id: Generated<string>;
|
||||||
|
fileTaskId: string;
|
||||||
|
siteUrl: string;
|
||||||
|
authType: string;
|
||||||
|
authEmail: string | null;
|
||||||
|
authToken: string | null;
|
||||||
|
authUsername: string | null;
|
||||||
|
totalSpaces: Generated<number>;
|
||||||
|
importedSpaces: Generated<number>;
|
||||||
|
totalPages: Generated<number>;
|
||||||
|
importedPages: Generated<number>;
|
||||||
|
totalUsers: Generated<number>;
|
||||||
|
importedUsers: Generated<number>;
|
||||||
|
totalAttachments: Generated<number>;
|
||||||
|
importedAttachments: Generated<number>;
|
||||||
|
totalLabels: Generated<number>;
|
||||||
|
importedLabels: Generated<number>;
|
||||||
|
totalGroups: Generated<number>;
|
||||||
|
importedGroups: Generated<number>;
|
||||||
|
totalRestrictedPages: Generated<number>;
|
||||||
|
importedRestrictedPages: Generated<number>;
|
||||||
|
idMapping: Generated<Json>;
|
||||||
|
warnings: Generated<Json>;
|
||||||
|
currentPhase: string | null;
|
||||||
|
cancelled: Generated<boolean>;
|
||||||
|
spaceKeys: Generated<Json>;
|
||||||
|
workspaceId: string;
|
||||||
|
creatorId: string | null;
|
||||||
|
createdAt: Generated<Timestamp>;
|
||||||
|
updatedAt: Generated<Timestamp>;
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { DB } from '@docmost/db/types/db';
|
import { DB } from '@docmost/db/types/db';
|
||||||
import { PageEmbeddings } from '@docmost/db/types/embeddings.types';
|
import { PageEmbeddings } from '@docmost/db/types/embeddings.types';
|
||||||
|
import { ConfluenceApiImports } from './custom.types';
|
||||||
|
|
||||||
export interface DbInterface extends DB {
|
export interface DbInterface extends DB {
|
||||||
pageEmbeddings: PageEmbeddings;
|
pageEmbeddings: PageEmbeddings;
|
||||||
|
confluenceApiImports: ConfluenceApiImports;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: 10f6cff199...3a5ead292e
@@ -214,6 +214,13 @@ export class EnvironmentService {
|
|||||||
return !this.isCloud();
|
return !this.isCloud();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isBetaConfluenceImporter(): boolean {
|
||||||
|
const flag = this.configService
|
||||||
|
.get<string>('BETA_CONFLUENCE_IMPORTER', 'false')
|
||||||
|
.toLowerCase();
|
||||||
|
return flag === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
getStripePublishableKey(): string {
|
getStripePublishableKey(): string {
|
||||||
return this.configService.get<string>('STRIPE_PUBLISHABLE_KEY');
|
return this.configService.get<string>('STRIPE_PUBLISHABLE_KEY');
|
||||||
}
|
}
|
||||||
@@ -310,31 +317,6 @@ export class EnvironmentService {
|
|||||||
return val === 'true';
|
return val === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
getAiVectorDriver(): string {
|
|
||||||
return this.configService
|
|
||||||
.get<string>('AI_VECTOR_DRIVER', 'pgvector')
|
|
||||||
.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
getTurbopufferApiKey(): string {
|
|
||||||
return this.configService.get<string>('TURBOPUFFER_API_KEY');
|
|
||||||
}
|
|
||||||
|
|
||||||
getTurbopufferRegion(): string {
|
|
||||||
return this.configService.get<string>('TURBOPUFFER_REGION');
|
|
||||||
}
|
|
||||||
|
|
||||||
getTurbopufferBaseUrl(): string {
|
|
||||||
return this.configService.get<string>('TURBOPUFFER_BASE_URL');
|
|
||||||
}
|
|
||||||
|
|
||||||
getTurbopufferNamespacePrefix(): string {
|
|
||||||
return this.configService.get<string>(
|
|
||||||
'TURBOPUFFER_NAMESPACE_PREFIX',
|
|
||||||
'docmost',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getOpenAiApiKey(): string {
|
getOpenAiApiKey(): string {
|
||||||
return this.configService.get<string>('OPENAI_API_KEY');
|
return this.configService.get<string>('OPENAI_API_KEY');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
IsUrl,
|
IsUrl,
|
||||||
Matches,
|
|
||||||
MinLength,
|
MinLength,
|
||||||
ValidateIf,
|
ValidateIf,
|
||||||
validateSync,
|
validateSync,
|
||||||
@@ -109,41 +108,6 @@ export class EnvironmentVariables {
|
|||||||
@IsString()
|
@IsString()
|
||||||
AI_DRIVER: string;
|
AI_DRIVER: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@ValidateIf((obj) => obj.AI_VECTOR_DRIVER)
|
|
||||||
@IsIn(['pgvector', 'turbopuffer'])
|
|
||||||
@IsString()
|
|
||||||
AI_VECTOR_DRIVER: string;
|
|
||||||
|
|
||||||
@ValidateIf((obj) => obj.AI_VECTOR_DRIVER === 'turbopuffer')
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
|
||||||
TURBOPUFFER_API_KEY: string;
|
|
||||||
|
|
||||||
@ValidateIf(
|
|
||||||
(obj) =>
|
|
||||||
obj.AI_VECTOR_DRIVER === 'turbopuffer' && !obj.TURBOPUFFER_BASE_URL,
|
|
||||||
)
|
|
||||||
@IsNotEmpty({
|
|
||||||
message:
|
|
||||||
'TURBOPUFFER_REGION is required when AI_VECTOR_DRIVER is turbopuffer, unless TURBOPUFFER_BASE_URL is set',
|
|
||||||
})
|
|
||||||
@IsString()
|
|
||||||
TURBOPUFFER_REGION: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@ValidateIf((obj) => obj.TURBOPUFFER_BASE_URL != '' && obj.TURBOPUFFER_BASE_URL != null)
|
|
||||||
@IsUrl({ protocols: ['http', 'https'], require_tld: false })
|
|
||||||
TURBOPUFFER_BASE_URL: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsString()
|
|
||||||
@Matches(/^[A-Za-z0-9\-_.]{1,90}$/, {
|
|
||||||
message:
|
|
||||||
'TURBOPUFFER_NAMESPACE_PREFIX may only contain letters, digits, dot, dash, underscore (max 90 chars)',
|
|
||||||
})
|
|
||||||
TURBOPUFFER_NAMESPACE_PREFIX: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
AI_EMBEDDING_MODEL: string;
|
AI_EMBEDDING_MODEL: string;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { EnvironmentService } from '../environment/environment.service';
|
import { EnvironmentService } from '../environment/environment.service';
|
||||||
import { Redis } from 'ioredis';
|
import { Redis } from 'ioredis';
|
||||||
import { parseRedisUrl } from '../../common/helpers';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RedisHealthIndicator {
|
export class RedisHealthIndicator {
|
||||||
@@ -20,10 +19,8 @@ export class RedisHealthIndicator {
|
|||||||
const indicator = this.healthIndicatorService.check(key);
|
const indicator = this.healthIndicatorService.check(key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const redisUrl = this.environmentService.getRedisUrl();
|
const redis = new Redis(this.environmentService.getRedisUrl(), {
|
||||||
const redis = new Redis(redisUrl, {
|
|
||||||
maxRetriesPerRequest: 15,
|
maxRetriesPerRequest: 15,
|
||||||
tls: parseRedisUrl(redisUrl).tls,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await redis.ping();
|
await redis.ping();
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ImportModule } from './import.module';
|
||||||
|
import { FileTaskProcessor } from './processors/file-task.processor';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [ImportModule],
|
||||||
|
providers: [FileTaskProcessor],
|
||||||
|
})
|
||||||
|
export class ImportProcessorModule {}
|
||||||
@@ -3,19 +3,13 @@ import { ImportService } from './services/import.service';
|
|||||||
import { ImportController } from './import.controller';
|
import { ImportController } from './import.controller';
|
||||||
import { StorageModule } from '../storage/storage.module';
|
import { StorageModule } from '../storage/storage.module';
|
||||||
import { FileImportTaskService } from './services/file-import-task.service';
|
import { FileImportTaskService } from './services/file-import-task.service';
|
||||||
import { FileTaskProcessor } from './processors/file-task.processor';
|
|
||||||
import { ImportAttachmentService } from './services/import-attachment.service';
|
import { ImportAttachmentService } from './services/import-attachment.service';
|
||||||
import { FileTaskController } from './file-task.controller';
|
import { FileTaskController } from './file-task.controller';
|
||||||
import { PageModule } from '../../core/page/page.module';
|
import { PageModule } from '../../core/page/page.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [
|
providers: [ImportService, FileImportTaskService, ImportAttachmentService],
|
||||||
ImportService,
|
exports: [ImportService, ImportAttachmentService, FileImportTaskService],
|
||||||
FileImportTaskService,
|
|
||||||
FileTaskProcessor,
|
|
||||||
ImportAttachmentService,
|
|
||||||
],
|
|
||||||
exports: [ImportService, ImportAttachmentService],
|
|
||||||
controllers: [ImportController, FileTaskController],
|
controllers: [ImportController, FileTaskController],
|
||||||
imports: [StorageModule, PageModule],
|
imports: [StorageModule, PageModule],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ export class FileTaskProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
case QueueJob.IMPORT_TASK:
|
case QueueJob.IMPORT_TASK:
|
||||||
await this.fileTaskService.processZIpImport(job.data.fileTaskId);
|
await this.fileTaskService.processZIpImport(job.data.fileTaskId);
|
||||||
break;
|
break;
|
||||||
|
case QueueJob.CONFLUENCE_API_IMPORT:
|
||||||
|
await this.processConfluenceApiImport(job.data.fileTaskId);
|
||||||
|
break;
|
||||||
case QueueJob.PDF_EXPORT_TASK:
|
case QueueJob.PDF_EXPORT_TASK:
|
||||||
await this.processExportTask(job.data.fileTaskId);
|
await this.processExportTask(job.data.fileTaskId);
|
||||||
break;
|
break;
|
||||||
@@ -49,6 +52,19 @@ export class FileTaskProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getConfluenceApiImportService() {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
const mod = require('./../../../ee/confluence-api-import/confluence-api-import.service');
|
||||||
|
return this.moduleRef.get(mod.ConfluenceApiImportService, {
|
||||||
|
strict: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async processConfluenceApiImport(fileTaskId: string): Promise<void> {
|
||||||
|
const service = this.getConfluenceApiImportService();
|
||||||
|
await service.processImport(fileTaskId);
|
||||||
|
}
|
||||||
|
|
||||||
private async processExportTask(fileTaskId: string): Promise<void> {
|
private async processExportTask(fileTaskId: string): Promise<void> {
|
||||||
const pdfExportService = this.getPdfExportService();
|
const pdfExportService = this.getPdfExportService();
|
||||||
await pdfExportService.generateAndStorePdf(fileTaskId);
|
await pdfExportService.generateAndStorePdf(fileTaskId);
|
||||||
@@ -77,6 +93,8 @@ export class FileTaskProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
await this.handleFailedImportJob(job);
|
await this.handleFailedImportJob(job);
|
||||||
} else if (job.name === QueueJob.PDF_EXPORT_TASK) {
|
} else if (job.name === QueueJob.PDF_EXPORT_TASK) {
|
||||||
await this.handleFailedExportJob(job);
|
await this.handleFailedExportJob(job);
|
||||||
|
} else if (job.name === QueueJob.CONFLUENCE_API_IMPORT) {
|
||||||
|
await this.handleFailedExportJob(job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user