mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix: attachment bugs in safari(#1908)
* use widely available arrayBuffer * fix stream fails in safari * fix hasFocus bug * fix safari upload bug * feat: add HTTP range request support for file serving
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { imageDimensionsFromStream } from "image-dimensions";
|
||||
import { MediaUploadOptions, UploadFn } from "../media-utils";
|
||||
import { IAttachment } from "../types";
|
||||
import { generateNodeId } from "../utils";
|
||||
import { Node } from "@tiptap/pm/model";
|
||||
import { Command } from "@tiptap/core";
|
||||
import { imageDimensionsFromData } from 'image-dimensions';
|
||||
import { MediaUploadOptions, UploadFn } from '../media-utils';
|
||||
import { IAttachment } from '../types';
|
||||
import { generateNodeId } from '../utils';
|
||||
import { Node } from '@tiptap/pm/model';
|
||||
import { Command } from '@tiptap/core';
|
||||
|
||||
const findImageNodeByPlaceholderId = (
|
||||
doc: Node,
|
||||
@@ -14,7 +14,7 @@ const findImageNodeByPlaceholderId = (
|
||||
doc.descendants((node, pos) => {
|
||||
if (result) return false;
|
||||
if (
|
||||
node.type.name === "image" &&
|
||||
node.type.name === 'image' &&
|
||||
node.attrs.placeholder?.id === placeholderId
|
||||
) {
|
||||
result = { node, pos };
|
||||
@@ -34,7 +34,11 @@ const handleImageUpload =
|
||||
if (!validated) return;
|
||||
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
const imageDimensions = await imageDimensionsFromStream(file.stream());
|
||||
|
||||
const imageDimensions = imageDimensionsFromData(
|
||||
new Uint8Array(await file.arrayBuffer()),
|
||||
);
|
||||
|
||||
const placeholderId = generateNodeId();
|
||||
const aspectRatio = imageDimensions
|
||||
? imageDimensions.width / imageDimensions.height
|
||||
|
||||
Reference in New Issue
Block a user