mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 14:43:06 +08:00
6c422011ac
* Share - WIP * - public attachment links - WIP * WIP * WIP * Share - WIP * WIP * WIP * include userRole in space object * WIP * Server render shared page meta tags * disable user select * Close Navbar on outside click on mobile * update shared page spaceId * WIP * fix * close sidebar on click * close sidebar * defaults * update copy * Store share key in lowercase * refactor page breadcrumbs * Change copy * add link ref * open link button * add meta og:title * add twitter tags * WIP * make shares/info endpoint public * fix * * add /p/ segment to share urls * minore fixes * change mobile breadcrumb icon
23 lines
596 B
TypeScript
23 lines
596 B
TypeScript
import { Node } from '@tiptap/pm/model';
|
|
|
|
export function updateAttachmentAttr(
|
|
node: Node,
|
|
attr: 'src' | 'url',
|
|
token: string,
|
|
) {
|
|
const attrVal = node.attrs[attr];
|
|
if (
|
|
attrVal &&
|
|
(attrVal.startsWith('/files') || attrVal.startsWith('/api/files'))
|
|
) {
|
|
// @ts-ignore
|
|
node.attrs[attr] = updateAttachmentUrl(attrVal, token);
|
|
}
|
|
}
|
|
|
|
function updateAttachmentUrl(src: string, jwtToken: string) {
|
|
const updatedSrc = src.replace('/files/', '/files/public/');
|
|
const separator = updatedSrc.includes('?') ? '&' : '?';
|
|
return `${updatedSrc}${separator}jwt=${jwtToken}`;
|
|
}
|