Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added Attachment of files as Block to Documents #3391

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ function Editor(props: Props, ref: React.Ref<SharedEditor>) {
[id]
);

const onUpload = React.useCallback(
async (file: File) => {
const result = await uploadFile(file, {
documentId: id,
});
return result.url;
},
[id]
);

const onClickLink = React.useCallback(
(href: string, event: MouseEvent) => {
// on page hash
Expand Down
12 changes: 10 additions & 2 deletions app/scenes/Document/components/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ class DocumentScene extends React.Component<Props> {
this.isUploading = false;
};

onFileUploadStart = () => {
this.isUploading = true;
};

onFileUploadStop = () => {
this.isUploading = false;
};

onChange = (getEditorText: () => string) => {
const { document, auth } = this.props;
this.getEditorText = getEditorText;
Expand Down Expand Up @@ -428,7 +436,7 @@ class DocumentScene extends React.Component<Props> {

const headings = this.editor.current
? // @ts-expect-error ts-migrate(2571) FIXME: Object is of type 'unknown'.
this.editor.current.getHeadings()
this.editor.current.getHeadings()
: [];

const hasHeadings = headings.length > 0;
Expand Down Expand Up @@ -647,7 +655,7 @@ type MaxWidthProps = {
showContents?: boolean;
};

const MaxWidth = styled(Flex)<MaxWidthProps>`
const MaxWidth = styled(Flex) <MaxWidthProps>`
// Adds space to the gutter to make room for heading annotations
padding: 0 32px;
transition: padding 100ms;
Expand Down
6 changes: 5 additions & 1 deletion app/utils/urls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export function isHash(href: string) {
if (href[0] === "#") {
const attachment = "/api/attachments.redirect?";
if (href.includes(attachment)) {
return false;
}
if (href[0] === "/") {
return true;
}

Expand Down