mirror of
https://github.com/usememos/memos.git
synced 2026-11-19 10:29:11 +01:00
feat: add drawings with @usememos/canvas (#6533)
This commit is contained in:
@@ -177,6 +177,32 @@ func CheckUpload(ctx context.Context, s Store, userID int32, size int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckReplace returns a *Refusal when replacing a stored file of replacedSize
|
||||
// bytes with one of size bytes would break the per-file limit or the storage
|
||||
// limit of userID. Only the difference counts toward storage, so a replacement
|
||||
// no larger than the file it replaces is never refused for storage.
|
||||
func CheckReplace(ctx context.Context, s Store, userID int32, size, replacedSize int64) error {
|
||||
effective, err := EffectiveFor(ctx, s, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := effective.checkFileSize(size); err != nil {
|
||||
return err
|
||||
}
|
||||
limit := effective.Entry.GetStorageBytes()
|
||||
if limit <= 0 || size <= replacedSize {
|
||||
return nil
|
||||
}
|
||||
used, err := s.GetAttachmentStorageUsage(ctx, userID)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to sum storage usage")
|
||||
}
|
||||
if used-replacedSize+size > limit {
|
||||
return effective.refuse(MetricStorageBytes, limit, used)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Usage is a user's usage and the limit set in effect for the user.
|
||||
type Usage struct {
|
||||
MemoCount int64
|
||||
|
||||
@@ -119,6 +119,20 @@ func TestCheckUpload(t *testing.T) {
|
||||
require.Zero(t, s.sumCalls, "no storage limit in the user's entry, so no sum query")
|
||||
}
|
||||
|
||||
func TestCheckReplace(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
s := &fakeStore{storage: 900, setting: setting(&entry{AllUsers: true, StorageBytes: new(int64(1000)), UploadBytes: new(int64(300))})}
|
||||
|
||||
require.NoError(t, CheckReplace(ctx, s, 1, 250, 150), "only the 100 extra bytes count: 900 - 150 + 250 = 1000")
|
||||
require.Equal(t, &Refusal{Metric: MetricStorageBytes, Limit: 1000, Usage: 900, Index: 0}, AsRefusal(CheckReplace(ctx, s, 1, 251, 150)))
|
||||
require.Equal(t, &Refusal{Metric: MetricUploadBytes, Limit: 300, Usage: 301, Index: 0}, AsRefusal(CheckReplace(ctx, s, 1, 301, 400)))
|
||||
|
||||
s.sumCalls = 0
|
||||
s.storage = 5000
|
||||
require.NoError(t, CheckReplace(ctx, s, 1, 100, 200), "a smaller file is never refused for storage, even over the limit")
|
||||
require.Zero(t, s.sumCalls, "a file no larger than the one it replaces needs no sum query")
|
||||
}
|
||||
|
||||
func TestCheckFileSize(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
s := &fakeStore{storage: 1 << 40, setting: setting(&entry{AllUsers: true, StorageBytes: new(int64(1)), UploadBytes: new(int64(200))})}
|
||||
|
||||
@@ -5,16 +5,32 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/jpeg"
|
||||
"image/png"
|
||||
)
|
||||
|
||||
// BuildJPEG returns a solid-color width×height JPEG blob for tests.
|
||||
func BuildJPEG(width, height int) []byte {
|
||||
func solidImage(width, height int) *image.RGBA {
|
||||
img := image.NewRGBA(image.Rect(0, 0, width, height))
|
||||
for y := range height {
|
||||
for x := range width {
|
||||
img.Set(x, y, color.RGBA{R: 80, G: 120, B: 160, A: 255})
|
||||
}
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
// BuildPNG returns a solid-color width×height PNG blob for tests.
|
||||
func BuildPNG(width, height int) []byte {
|
||||
var buffer bytes.Buffer
|
||||
if err := png.Encode(&buffer, solidImage(width, height)); err != nil {
|
||||
// Encoding an in-memory RGBA image cannot fail with valid dimensions.
|
||||
panic(err)
|
||||
}
|
||||
return buffer.Bytes()
|
||||
}
|
||||
|
||||
// BuildJPEG returns a solid-color width×height JPEG blob for tests.
|
||||
func BuildJPEG(width, height int) []byte {
|
||||
img := solidImage(width, height)
|
||||
var buffer bytes.Buffer
|
||||
if err := jpeg.Encode(&buffer, img, &jpeg.Options{Quality: 90}); err != nil {
|
||||
// Encoding an in-memory RGBA image cannot fail with valid dimensions.
|
||||
|
||||
@@ -243,7 +243,7 @@ message UploadAttachmentResponse {
|
||||
Attachment attachment = 4;
|
||||
}
|
||||
|
||||
// UploadAttachmentSpec describes the attachment that a new upload creates.
|
||||
// UploadAttachmentSpec describes the attachment that a new upload creates, or whose content it replaces.
|
||||
message UploadAttachmentSpec {
|
||||
// Required. Metadata for the attachment to create. content must be empty; file bytes are sent in data.
|
||||
Attachment attachment = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
@@ -254,6 +254,16 @@ message UploadAttachmentSpec {
|
||||
|
||||
// Optional. Total size of the file in bytes before media processing. Zero represents an empty file.
|
||||
int64 total_size = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The name of an existing attachment whose content the finished upload replaces, instead of creating one.
|
||||
// The attachment keeps its name, memo and creation time; its filename, type, size and media metadata come from this
|
||||
// upload, and its cached thumbnail is dropped. attachment_id and attachment.memo must be empty. Only the uploader of
|
||||
// the attachment or an admin may replace it. An external link or part of a motion photo cannot be replaced.
|
||||
// Format: attachments/{attachment}
|
||||
string replace_attachment = 4 [
|
||||
(google.api.field_behavior) = OPTIONAL,
|
||||
(google.api.resource_reference) = {type: "memos.api/Attachment"}
|
||||
];
|
||||
}
|
||||
|
||||
// MotionMedia links the parts of a motion photo.
|
||||
|
||||
@@ -853,7 +853,7 @@ func (x *UploadAttachmentResponse) GetAttachment() *Attachment {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UploadAttachmentSpec describes the attachment that a new upload creates.
|
||||
// UploadAttachmentSpec describes the attachment that a new upload creates, or whose content it replaces.
|
||||
type UploadAttachmentSpec struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. Metadata for the attachment to create. content must be empty; file bytes are sent in data.
|
||||
@@ -863,6 +863,12 @@ type UploadAttachmentSpec struct {
|
||||
AttachmentId string `protobuf:"bytes,2,opt,name=attachment_id,json=attachmentId,proto3" json:"attachment_id,omitempty"`
|
||||
// Optional. Total size of the file in bytes before media processing. Zero represents an empty file.
|
||||
TotalSize int64 `protobuf:"varint,3,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"`
|
||||
// Optional. The name of an existing attachment whose content the finished upload replaces, instead of creating one.
|
||||
// The attachment keeps its name, memo and creation time; its filename, type, size and media metadata come from this
|
||||
// upload, and its cached thumbnail is dropped. attachment_id and attachment.memo must be empty. Only the uploader of
|
||||
// the attachment or an admin may replace it. An external link or part of a motion photo cannot be replaced.
|
||||
// Format: attachments/{attachment}
|
||||
ReplaceAttachment string `protobuf:"bytes,4,opt,name=replace_attachment,json=replaceAttachment,proto3" json:"replace_attachment,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -918,6 +924,13 @@ func (x *UploadAttachmentSpec) GetTotalSize() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentSpec) GetReplaceAttachment() string {
|
||||
if x != nil {
|
||||
return x.ReplaceAttachment
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// MotionMedia links the parts of a motion photo.
|
||||
type MotionMedia struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@@ -1466,14 +1479,16 @@ const file_api_attachment_service_proto_rawDesc = "" +
|
||||
"\x0emax_chunk_size\x18\x03 \x01(\x05R\fmaxChunkSize\x125\n" +
|
||||
"\n" +
|
||||
"attachment\x18\x04 \x01(\v2\x15.memos.api.AttachmentR\n" +
|
||||
"attachment\"\xa0\x01\n" +
|
||||
"attachment\"\xed\x01\n" +
|
||||
"\x14UploadAttachmentSpec\x12:\n" +
|
||||
"\n" +
|
||||
"attachment\x18\x01 \x01(\v2\x15.memos.api.AttachmentB\x03\xe0A\x02R\n" +
|
||||
"attachment\x12(\n" +
|
||||
"\rattachment_id\x18\x02 \x01(\tB\x03\xe0A\x01R\fattachmentId\x12\"\n" +
|
||||
"\n" +
|
||||
"total_size\x18\x03 \x01(\x03B\x03\xe0A\x01R\ttotalSize\"\xf8\x01\n" +
|
||||
"total_size\x18\x03 \x01(\x03B\x03\xe0A\x01R\ttotalSize\x12K\n" +
|
||||
"\x12replace_attachment\x18\x04 \x01(\tB\x1c\xe0A\x01\xfaA\x16\n" +
|
||||
"\x14memos.api/AttachmentR\x11replaceAttachment\"\xf8\x01\n" +
|
||||
"\vMotionMedia\x124\n" +
|
||||
"\x06family\x18\x01 \x01(\x0e2\x1c.memos.api.MotionMediaFamilyR\x06family\x12.\n" +
|
||||
"\x04role\x18\x02 \x01(\x0e2\x1a.memos.api.MotionMediaRoleR\x04role\x12\x19\n" +
|
||||
|
||||
@@ -5403,7 +5403,15 @@ components:
|
||||
totalSize:
|
||||
type: string
|
||||
description: Optional. Total size of the file in bytes before media processing. Zero represents an empty file.
|
||||
description: UploadAttachmentSpec describes the attachment that a new upload creates.
|
||||
replaceAttachment:
|
||||
type: string
|
||||
description: |-
|
||||
Optional. The name of an existing attachment whose content the finished upload replaces, instead of creating one.
|
||||
The attachment keeps its name, memo and creation time; its filename, type, size and media metadata come from this
|
||||
upload, and its cached thumbnail is dropped. attachment_id and attachment.memo must be empty. Only the uploader of
|
||||
the attachment or an admin may replace it. An external link or part of a motion photo cannot be replaced.
|
||||
Format: attachments/{attachment}
|
||||
description: UploadAttachmentSpec describes the attachment that a new upload creates, or whose content it replaces.
|
||||
UpsertMemoReactionRequest:
|
||||
required:
|
||||
- parent
|
||||
|
||||
@@ -92,6 +92,7 @@ type APIService struct {
|
||||
|
||||
linkMetadataFetcher linkMetadataFetcher
|
||||
attachmentUploads attachmentUploads
|
||||
attachmentReplaces attachmentReplaceLocks
|
||||
memoImports memoImports
|
||||
}
|
||||
|
||||
|
||||
@@ -191,10 +191,21 @@ type attachmentSource interface {
|
||||
// the content, and creates the database row. create.Size must hold the source
|
||||
// length on entry; it is updated when stripping re-encodes the image.
|
||||
func (s *APIService) processAndSaveAttachment(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting, source attachmentSource) (*apipb.Attachment, error) {
|
||||
if create.Payload.GetMotionMedia() == nil && (create.Type == "image/jpeg" || create.Type == "image/jpg") {
|
||||
if err := s.processAndStoreContent(ctx, create, instanceStorageSetting, source, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.persistAttachment(ctx, create, instanceStorageSetting)
|
||||
}
|
||||
|
||||
// processAndStoreContent strips EXIF metadata and writes the content to the
|
||||
// default storage, filling in create's storage fields. With detectMotion, a
|
||||
// JPEG that is an Android motion photo becomes a motion container and keeps
|
||||
// its embedded video unstripped. It creates no database row.
|
||||
func (s *APIService) processAndStoreContent(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting, source attachmentSource, detectMotion bool) error {
|
||||
if detectMotion && create.Payload.GetMotionMedia() == nil && (create.Type == "image/jpeg" || create.Type == "image/jpg") {
|
||||
detected, err := motionphoto.DetectJPEGReader(source, create.Size)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to inspect motion photo: %v", err)
|
||||
return status.Errorf(codes.Internal, "failed to inspect motion photo: %v", err)
|
||||
}
|
||||
if detected != nil {
|
||||
create.Payload = ensureAttachmentPayload(create.Payload)
|
||||
@@ -215,12 +226,12 @@ func (s *APIService) processAndSaveAttachment(ctx context.Context, create *store
|
||||
// client cannot skip stripping by labeling a JPEG as something else.
|
||||
needsExifStrip, err := shouldStripExifContent(source, create.Type)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to inspect attachment content: %v", err)
|
||||
return status.Errorf(codes.Internal, "failed to inspect attachment content: %v", err)
|
||||
}
|
||||
if needsExifStrip && !isAndroidMotionContainer(create.Payload.GetMotionMedia()) {
|
||||
release, err := s.acquireImageProcessingSlot(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "too many image processing requests")
|
||||
return status.Errorf(codes.ResourceExhausted, "too many image processing requests")
|
||||
}
|
||||
stripped, stripErr := stripImageExif(source, create.Type)
|
||||
release()
|
||||
@@ -237,12 +248,12 @@ func (s *APIService) processAndSaveAttachment(ctx context.Context, create *store
|
||||
}
|
||||
|
||||
if _, err := content.Seek(0, io.SeekStart); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to rewind attachment content: %v", err)
|
||||
return status.Errorf(codes.Internal, "failed to rewind attachment content: %v", err)
|
||||
}
|
||||
if err := saveAttachmentContent(ctx, s.Profile, s.Store, create, instanceStorageSetting, content); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to save attachment blob: %v", err)
|
||||
return status.Errorf(codes.Internal, "failed to save attachment blob: %v", err)
|
||||
}
|
||||
return s.persistAttachment(ctx, create, instanceStorageSetting)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *APIService) persistAttachment(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting) (*apipb.Attachment, error) {
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/usememos/memos/core/access"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
// Replacing an attachment's content (UploadAttachmentSpec.replace_attachment)
|
||||
// keeps the attachment's identity: its name, memo binding, creator and
|
||||
// creation time. The new file is written as a separate storage object first,
|
||||
// the row is pointed at it in one update, and only then is the previous object
|
||||
// deleted, so a failure at any step leaves one complete file behind. Thumbnails
|
||||
// and other derived files are keyed by the attachment UID and are dropped with
|
||||
// the previous object.
|
||||
|
||||
// attachmentReplaceLocks serializes replacements of one attachment within the
|
||||
// process, so each one deletes exactly the object the previous one left. Locks
|
||||
// are reference counted and dropped when no replacement of the UID is running.
|
||||
type attachmentReplaceLocks struct {
|
||||
mu sync.Mutex
|
||||
locks map[string]*attachmentReplaceLock
|
||||
}
|
||||
|
||||
type attachmentReplaceLock struct {
|
||||
sync.Mutex
|
||||
holders int
|
||||
}
|
||||
|
||||
// lock blocks until no other replacement of uid runs, and returns its release.
|
||||
func (l *attachmentReplaceLocks) lock(uid string) func() {
|
||||
l.mu.Lock()
|
||||
if l.locks == nil {
|
||||
l.locks = map[string]*attachmentReplaceLock{}
|
||||
}
|
||||
entry := l.locks[uid]
|
||||
if entry == nil {
|
||||
entry = &attachmentReplaceLock{}
|
||||
l.locks[uid] = entry
|
||||
}
|
||||
entry.holders++
|
||||
l.mu.Unlock()
|
||||
|
||||
entry.Lock()
|
||||
return func() {
|
||||
entry.Unlock()
|
||||
l.mu.Lock()
|
||||
if entry.holders--; entry.holders == 0 {
|
||||
delete(l.locks, uid)
|
||||
}
|
||||
l.mu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
// validateReplaceSpec checks the parts of an upload spec that a replacement
|
||||
// fixes: the identity and the memo binding come from the replaced attachment.
|
||||
func validateReplaceSpec(spec *apipb.UploadAttachmentSpec) error {
|
||||
if spec.AttachmentId != "" {
|
||||
return status.Errorf(codes.InvalidArgument, "attachment_id must be empty when replacing an attachment")
|
||||
}
|
||||
if spec.Attachment.GetMemo() != "" {
|
||||
return status.Errorf(codes.InvalidArgument, "attachment.memo must be empty when replacing an attachment")
|
||||
}
|
||||
if spec.Attachment.GetMotionMedia() != nil {
|
||||
return status.Errorf(codes.InvalidArgument, "a replacement cannot be part of a motion photo")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// findReplaceableAttachment loads the attachment a replacement targets and
|
||||
// checks that the current user may replace its content.
|
||||
func (s *APIService) findReplaceableAttachment(ctx context.Context, name string) (*store.Attachment, *store.User, error) {
|
||||
uid, err := ExtractAttachmentUIDFromName(name)
|
||||
if err != nil {
|
||||
return nil, nil, status.Errorf(codes.InvalidArgument, "invalid replace_attachment: %v", err)
|
||||
}
|
||||
user, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
||||
}
|
||||
if user == nil {
|
||||
return nil, nil, status.Errorf(codes.Unauthenticated, "user not authenticated")
|
||||
}
|
||||
attachment, err := s.Store.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
if err != nil {
|
||||
return nil, nil, status.Errorf(codes.Internal, "failed to get attachment: %v", err)
|
||||
}
|
||||
if attachment == nil {
|
||||
return nil, nil, status.Errorf(codes.NotFound, "attachment not found")
|
||||
}
|
||||
if !access.CanManageAttachment(user, attachment) {
|
||||
return nil, nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
if attachment.StorageType == storepb.AttachmentStorageType_EXTERNAL {
|
||||
return nil, nil, status.Errorf(codes.FailedPrecondition, "an external link has no stored content to replace")
|
||||
}
|
||||
if attachment.Payload.GetMotionMedia() != nil {
|
||||
return nil, nil, status.Errorf(codes.FailedPrecondition, "part of a motion photo cannot be replaced")
|
||||
}
|
||||
return attachment, user, nil
|
||||
}
|
||||
|
||||
// finishAttachmentReplace stores a finished upload as the new content of the
|
||||
// attachment it replaces.
|
||||
func (s *APIService) finishAttachmentReplace(ctx context.Context, upload *attachmentUpload) (*apipb.Attachment, error) {
|
||||
release := s.attachmentReplaces.lock(upload.state.uid)
|
||||
defer release()
|
||||
if upload.state.replaceCommitted {
|
||||
// An earlier finish committed but failed afterwards: report the attachment as
|
||||
// it is now, instead of applying this upload again. The previous file's
|
||||
// cleanup does not decide the result; when it fails, the next retry tries again.
|
||||
if leftover := upload.state.replacedLeftover; leftover != nil && s.deleteReplacedContent(ctx, leftover) {
|
||||
upload.state.replacedLeftover = nil
|
||||
}
|
||||
return s.GetAttachment(ctx, &apipb.GetAttachmentRequest{Name: "attachments/" + upload.state.uid})
|
||||
}
|
||||
// Check again at finish: the attachment may have been deleted, linked to a
|
||||
// memo the user can no longer write, or the limits may have changed.
|
||||
replaced, user, err := s.findReplaceableAttachment(ctx, "attachments/"+upload.state.uid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.checkReplaceQuota(ctx, replaced.CreatorID, upload.totalSize, replaced.Size); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
setting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get storage setting: %v", err)
|
||||
}
|
||||
file, err := os.Open(upload.path)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to open upload file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
metadata := proto.CloneOf(upload.state.metadata)
|
||||
metadata.Content = make([]byte, min(upload.totalSize, 512))
|
||||
if _, err := io.ReadFull(file, metadata.Content); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to read attachment header: %v", err)
|
||||
}
|
||||
// Validate the filename, type and media metadata with the actual MIME type.
|
||||
// The prepared attachment carries a fresh UID, which names the new storage
|
||||
// object apart from the one it replaces until the row points at it.
|
||||
content, err := s.prepareAttachment(ctx, &apipb.CreateAttachmentRequest{Attachment: metadata})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
content.Size = upload.totalSize
|
||||
upload.state.finalizeAttempted = true
|
||||
// A replacement is never part of a motion photo: a motion JPEG is stored as
|
||||
// a plain, EXIF-stripped image.
|
||||
if err := s.processAndStoreContent(ctx, content, setting, file, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// From here the new object is the attachment's, under the replaced UID.
|
||||
content.UID = replaced.UID
|
||||
// discardContent removes the new object when no row points at it. It checks
|
||||
// the row first, so an update that committed before failing keeps its object.
|
||||
discardContent := func(reason string) {
|
||||
if _, err := cleanupSavedAttachmentBlob(ctx, s.Store, content, setting); err != nil {
|
||||
slog.Error("failed to remove replacement content "+reason,
|
||||
slog.String("attachment_uid", replaced.UID),
|
||||
slog.Any("error", err),
|
||||
)
|
||||
}
|
||||
}
|
||||
payload := content.Payload
|
||||
if payload == nil {
|
||||
// The previous payload described the previous object; none of it carries over.
|
||||
payload = &storepb.AttachmentPayload{}
|
||||
}
|
||||
|
||||
nowSec := time.Now().Unix()
|
||||
if err := s.Store.UpdateAttachment(ctx, &store.UpdateAttachment{
|
||||
ID: replaced.ID,
|
||||
UpdatedTs: &nowSec,
|
||||
Filename: &content.Filename,
|
||||
Payload: payload,
|
||||
Content: &store.AttachmentContent{
|
||||
Type: content.Type,
|
||||
Size: content.Size,
|
||||
StorageType: content.StorageType,
|
||||
Reference: content.Reference,
|
||||
Blob: content.Blob,
|
||||
},
|
||||
Policy: memoWritePolicy(user.ID, false),
|
||||
}); err != nil {
|
||||
discardContent("after the update failed")
|
||||
return nil, mapMemoWriteError(err, "failed to replace attachment content")
|
||||
}
|
||||
upload.state.replaceCommitted = true
|
||||
|
||||
updated, err := s.Store.GetAttachment(ctx, &store.FindAttachment{UID: &replaced.UID})
|
||||
if err != nil {
|
||||
// The replacement committed; the previous object is left in place
|
||||
// rather than risk deleting the one the row now points at, and a retry
|
||||
// deletes it once the row can be read. Its thumbnail is keyed by the
|
||||
// UID, so it goes now.
|
||||
upload.state.replacedLeftover = replaced
|
||||
s.Store.DeleteAttachmentDerivedCaches(replaced)
|
||||
s.SSEHub.publishMemoChanged()
|
||||
return nil, status.Errorf(codes.Internal, "attachment content was replaced but failed to reload: %v", err)
|
||||
}
|
||||
if updated == nil {
|
||||
// The attachment was deleted while its content was being replaced: the
|
||||
// update matched no row, so nothing points at the new object.
|
||||
discardContent("of a deleted attachment")
|
||||
return nil, status.Errorf(codes.NotFound, "attachment not found")
|
||||
}
|
||||
if hasSameManagedStorageObject(replaced, updated) {
|
||||
s.Store.DeleteAttachmentDerivedCaches(replaced)
|
||||
} else if err := s.Store.DeleteAttachmentStorageWithInstanceSetting(ctx, replaced, setting); err != nil {
|
||||
// The attachment is consistent; the previous file is only orphaned.
|
||||
slog.Warn("failed to delete replaced attachment content",
|
||||
slog.String("attachment_uid", replaced.UID),
|
||||
slog.String("storage_type", replaced.StorageType.String()),
|
||||
slog.Any("error", err),
|
||||
)
|
||||
s.Store.DeleteAttachmentDerivedCaches(replaced)
|
||||
}
|
||||
if updated.MemoID != nil {
|
||||
s.SSEHub.publishMemoChanged()
|
||||
}
|
||||
return convertAttachmentFromStore(updated), nil
|
||||
}
|
||||
|
||||
// deleteReplacedContent deletes the file a committed replacement left behind,
|
||||
// unless the attachment's row still points at it (the replacement did not
|
||||
// commit after all). A row that is gone means the attachment was deleted, and
|
||||
// its file went with it. It reports whether the leftover needs no further
|
||||
// cleanup; a failure is logged and leaves the leftover for the next retry.
|
||||
func (s *APIService) deleteReplacedContent(ctx context.Context, leftover *store.Attachment) bool {
|
||||
logFailure := func(msg string, err error) bool {
|
||||
slog.Warn(msg,
|
||||
slog.String("attachment_uid", leftover.UID),
|
||||
slog.String("storage_type", leftover.StorageType.String()),
|
||||
slog.Any("error", err),
|
||||
)
|
||||
return false
|
||||
}
|
||||
current, err := s.Store.GetAttachment(ctx, &store.FindAttachment{UID: &leftover.UID})
|
||||
if err != nil {
|
||||
return logFailure("failed to get attachment before deleting replaced content", err)
|
||||
}
|
||||
if current == nil || hasSameManagedStorageObject(current, leftover) {
|
||||
return true
|
||||
}
|
||||
setting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return logFailure("failed to get storage setting before deleting replaced content", err)
|
||||
}
|
||||
if err := s.Store.DeleteAttachmentStorageWithInstanceSetting(ctx, leftover, setting); err != nil {
|
||||
return logFailure("failed to delete replaced attachment content", err)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/usememos/memos/internal/testutil"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
// A finish that committed a replacement but failed afterwards (the reload) can
|
||||
// be retried by the client. The retry must report the attachment as it is, and
|
||||
// never apply its upload again over a newer replacement.
|
||||
func TestReplaceAttachmentRetryAfterCommitKeepsNewerReplacement(t *testing.T) {
|
||||
svc := newIntegrationService(t)
|
||||
t.Cleanup(svc.CloseUploads)
|
||||
user := createSpaceTestUser(context.Background(), t, svc, "artist", store.RoleUser)
|
||||
ctx := userCtx(context.Background(), user.ID)
|
||||
attachment, err := svc.CreateAttachment(ctx, &apipb.CreateAttachmentRequest{Attachment: &apipb.Attachment{
|
||||
Filename: "drawing.canvas.png", Type: "image/png", Content: testutil.BuildPNG(4, 4),
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
|
||||
replace := func(filename string, content []byte) *apipb.UploadAttachmentResponse {
|
||||
response, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{
|
||||
Attachment: &apipb.Attachment{Filename: filename, Type: "image/png"},
|
||||
TotalSize: int64(len(content)),
|
||||
ReplaceAttachment: attachment.Name,
|
||||
}},
|
||||
Data: content,
|
||||
FinishWrite: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
return response
|
||||
}
|
||||
first := testutil.BuildPNG(6, 6)
|
||||
older := replace("drawing-older.canvas.png", first)
|
||||
newer := replace("drawing-newer.canvas.png", testutil.BuildPNG(8, 8))
|
||||
|
||||
// Make the older upload look like its finish failed after the commit.
|
||||
upload, err := svc.attachmentUploads.resume(older.UploadId, user.ID)
|
||||
require.NoError(t, err)
|
||||
upload.complete = false
|
||||
upload.mu.Unlock()
|
||||
|
||||
retried, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_UploadId{UploadId: older.UploadId},
|
||||
WriteOffset: int64(len(first)),
|
||||
FinishWrite: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, newer.Attachment.Filename, retried.Attachment.Filename, "the newer replacement stays")
|
||||
require.Equal(t, newer.Attachment.Size, retried.Attachment.Size)
|
||||
}
|
||||
|
||||
// When the reload after a committed replacement fails, the previous file is
|
||||
// kept for safety. The client's retry then deletes it, but never the file the
|
||||
// attachment's row points at.
|
||||
func TestReplaceAttachmentRetryDeletesLeftoverFile(t *testing.T) {
|
||||
svc := newIntegrationService(t)
|
||||
t.Cleanup(svc.CloseUploads)
|
||||
ctx := context.Background()
|
||||
_, err := svc.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{
|
||||
Storages: []*storepb.Storage{{Id: "local", Name: "Local", Type: storepb.StorageType_STORAGE_TYPE_LOCAL}},
|
||||
DefaultStorageId: "local",
|
||||
}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
user := createSpaceTestUser(ctx, t, svc, "artist", store.RoleUser)
|
||||
userCtx := userCtx(ctx, user.ID)
|
||||
content := testutil.BuildPNG(4, 4)
|
||||
attachment, err := svc.CreateAttachment(userCtx, &apipb.CreateAttachmentRequest{Attachment: &apipb.Attachment{
|
||||
Filename: "drawing.canvas.png", Type: "image/png", Content: content,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
uid, err := ExtractAttachmentUIDFromName(attachment.Name)
|
||||
require.NoError(t, err)
|
||||
current, err := svc.Store.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
require.NoError(t, err)
|
||||
currentFile := localPath(svc.Profile.Data, current.Reference)
|
||||
require.FileExists(t, currentFile)
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
leftover func() (*store.Attachment, string)
|
||||
wantExists bool
|
||||
}{
|
||||
{
|
||||
name: "a file the row no longer points at is deleted",
|
||||
leftover: func() (*store.Attachment, string) {
|
||||
path := filepath.Join(filepath.Dir(currentFile), "previous.canvas.png")
|
||||
require.NoError(t, os.WriteFile(path, content, 0o644))
|
||||
previous := *current
|
||||
previous.Reference = path
|
||||
return &previous, path
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "the file the row points at stays",
|
||||
leftover: func() (*store.Attachment, string) {
|
||||
return current, currentFile
|
||||
},
|
||||
wantExists: true,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
leftover, path := tc.leftover()
|
||||
started, err := svc.UploadAttachment(userCtx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{
|
||||
Attachment: &apipb.Attachment{Filename: "drawing.canvas.png", Type: "image/png"},
|
||||
TotalSize: int64(len(content)),
|
||||
ReplaceAttachment: attachment.Name,
|
||||
}},
|
||||
Data: content,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// The upload's first finish committed, then its reload failed.
|
||||
upload, err := svc.attachmentUploads.resume(started.UploadId, user.ID)
|
||||
require.NoError(t, err)
|
||||
upload.state.replaceCommitted = true
|
||||
upload.state.replacedLeftover = leftover
|
||||
upload.mu.Unlock()
|
||||
|
||||
retried, err := svc.UploadAttachment(userCtx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_UploadId{UploadId: started.UploadId},
|
||||
WriteOffset: int64(len(content)),
|
||||
FinishWrite: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, attachment.Name, retried.Attachment.Name)
|
||||
if tc.wantExists {
|
||||
require.FileExists(t, path)
|
||||
} else {
|
||||
require.NoFileExists(t, path)
|
||||
}
|
||||
require.FileExists(t, currentFile, "the attachment's own file is never deleted")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A retry whose cleanup of the previous file fails still reports the committed
|
||||
// replacement, and keeps the file queued so the next retry deletes it.
|
||||
func TestReplaceAttachmentRetryKeepsLeftoverWhenDeleteFails(t *testing.T) {
|
||||
svc := newIntegrationService(t)
|
||||
t.Cleanup(svc.CloseUploads)
|
||||
ctx := context.Background()
|
||||
_, err := svc.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{
|
||||
Storages: []*storepb.Storage{{Id: "local", Name: "Local", Type: storepb.StorageType_STORAGE_TYPE_LOCAL}},
|
||||
DefaultStorageId: "local",
|
||||
}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
user := createSpaceTestUser(ctx, t, svc, "artist", store.RoleUser)
|
||||
userCtx := userCtx(ctx, user.ID)
|
||||
content := testutil.BuildPNG(4, 4)
|
||||
attachment, err := svc.CreateAttachment(userCtx, &apipb.CreateAttachmentRequest{Attachment: &apipb.Attachment{
|
||||
Filename: "drawing.canvas.png", Type: "image/png", Content: content,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
uid, err := ExtractAttachmentUIDFromName(attachment.Name)
|
||||
require.NoError(t, err)
|
||||
current, err := svc.Store.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
require.NoError(t, err)
|
||||
|
||||
// A non-empty directory in place of the previous file: removing it fails.
|
||||
stuck := filepath.Join(filepath.Dir(localPath(svc.Profile.Data, current.Reference)), "previous.canvas.png")
|
||||
require.NoError(t, os.MkdirAll(stuck, 0o755))
|
||||
require.NoError(t, os.WriteFile(filepath.Join(stuck, "keep"), content, 0o644))
|
||||
leftover := *current
|
||||
leftover.Reference = stuck
|
||||
|
||||
started, err := svc.UploadAttachment(userCtx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{
|
||||
Attachment: &apipb.Attachment{Filename: "drawing.canvas.png", Type: "image/png"},
|
||||
TotalSize: int64(len(content)),
|
||||
ReplaceAttachment: attachment.Name,
|
||||
}},
|
||||
Data: content,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
upload, err := svc.attachmentUploads.resume(started.UploadId, user.ID)
|
||||
require.NoError(t, err)
|
||||
upload.state.replaceCommitted = true
|
||||
upload.state.replacedLeftover = &leftover
|
||||
upload.mu.Unlock()
|
||||
|
||||
retry := func() {
|
||||
upload, err := svc.attachmentUploads.resume(started.UploadId, user.ID)
|
||||
require.NoError(t, err)
|
||||
upload.complete = false
|
||||
upload.mu.Unlock()
|
||||
retried, err := svc.UploadAttachment(userCtx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_UploadId{UploadId: started.UploadId},
|
||||
WriteOffset: int64(len(content)),
|
||||
FinishWrite: true,
|
||||
})
|
||||
require.NoError(t, err, "a failed cleanup does not fail the committed replacement")
|
||||
require.Equal(t, attachment.Name, retried.Attachment.Name)
|
||||
}
|
||||
pendingLeftover := func() *store.Attachment {
|
||||
upload, err := svc.attachmentUploads.resume(started.UploadId, user.ID)
|
||||
require.NoError(t, err)
|
||||
defer upload.mu.Unlock()
|
||||
return upload.state.replacedLeftover
|
||||
}
|
||||
|
||||
retry()
|
||||
require.DirExists(t, stuck)
|
||||
require.NotNil(t, pendingLeftover(), "the previous file stays queued for the next retry")
|
||||
|
||||
require.NoError(t, os.Remove(filepath.Join(stuck, "keep")))
|
||||
retry()
|
||||
require.NoDirExists(t, stuck)
|
||||
require.Nil(t, pendingLeftover())
|
||||
}
|
||||
|
||||
func localPath(data, reference string) string {
|
||||
path := filepath.FromSlash(reference)
|
||||
if filepath.IsAbs(path) {
|
||||
return path
|
||||
}
|
||||
return filepath.Join(data, path)
|
||||
}
|
||||
@@ -26,6 +26,15 @@ const (
|
||||
type attachmentUploadState struct {
|
||||
metadata *apipb.Attachment
|
||||
uid string
|
||||
// replace is set when the upload replaces the content of the existing
|
||||
// attachment uid instead of creating it.
|
||||
replace bool
|
||||
// replaceCommitted is set once the replacement's row update committed, so
|
||||
// a retried finish never applies this upload over a newer replacement.
|
||||
replaceCommitted bool
|
||||
// replacedLeftover is the attachment as it was before a committed
|
||||
// replacement whose reload failed: its file still waits to be deleted.
|
||||
replacedLeftover *store.Attachment
|
||||
finalizeAttempted bool
|
||||
}
|
||||
|
||||
@@ -121,7 +130,20 @@ func (s *APIService) startAttachmentUpload(ctx context.Context, request *apipb.U
|
||||
if int64(len(request.Data)) > spec.TotalSize {
|
||||
return "", nil, status.Errorf(codes.InvalidArgument, "data exceeds total_size")
|
||||
}
|
||||
if err := s.checkUploadQuota(ctx, ownerID, spec.TotalSize); err != nil {
|
||||
var replaced *store.Attachment
|
||||
if spec.ReplaceAttachment != "" {
|
||||
if err := validateReplaceSpec(spec); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
target, _, err := s.findReplaceableAttachment(ctx, spec.ReplaceAttachment)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
if err := s.checkReplaceQuota(ctx, target.CreatorID, spec.TotalSize, target.Size); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
replaced = target
|
||||
} else if err := s.checkUploadQuota(ctx, ownerID, spec.TotalSize); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
// Validate before allocating a temporary file. Keep the original MIME type
|
||||
@@ -137,10 +159,16 @@ func (s *APIService) startAttachmentUpload(ctx context.Context, request *apipb.U
|
||||
return "", nil, err
|
||||
}
|
||||
state := attachmentUploadState{metadata: metadata, uid: create.UID}
|
||||
if replaced != nil {
|
||||
state.uid, state.replace = replaced.UID, true
|
||||
}
|
||||
return s.attachmentUploads.create(s.Profile.Data, attachmentUploadTempPrefix, ownerID, spec.TotalSize, state)
|
||||
}
|
||||
|
||||
func (s *APIService) finishAttachmentUpload(ctx context.Context, upload *attachmentUpload) (*apipb.Attachment, error) {
|
||||
if upload.state.replace {
|
||||
return s.finishAttachmentReplace(ctx, upload)
|
||||
}
|
||||
if upload.state.finalizeAttempted {
|
||||
// A database operation may commit before returning an error. Resolve that
|
||||
// outcome before saving another object under the upload's stable UID.
|
||||
|
||||
@@ -26,6 +26,12 @@ func (s *APIService) checkUploadQuota(ctx context.Context, userID int32, size in
|
||||
return s.quotaError(ctx, userID, usagelimit.CheckUpload(ctx, s.Store, userID, size))
|
||||
}
|
||||
|
||||
// checkReplaceQuota refuses replacing a stored file of replacedSize bytes with
|
||||
// one of size bytes when it breaks a limit of userID, the file's owner.
|
||||
func (s *APIService) checkReplaceQuota(ctx context.Context, userID int32, size, replacedSize int64) error {
|
||||
return s.quotaError(ctx, userID, usagelimit.CheckReplace(ctx, s.Store, userID, size, replacedSize))
|
||||
}
|
||||
|
||||
// checkFileSizeQuota refuses a file of size bytes that is larger than the
|
||||
// per-file limit of the user. It runs no count or sum query.
|
||||
func (s *APIService) checkFileSizeQuota(ctx context.Context, userID int32, size int64) error {
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
package fileserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/usememos/memos/internal/httphandler"
|
||||
"github.com/usememos/memos/internal/testutil"
|
||||
"github.com/usememos/memos/internal/testutil/fakes3"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/server/api"
|
||||
"github.com/usememos/memos/server/auth"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
// replaceContent uploads content in one call that replaces the attachment's file.
|
||||
func replaceContent(ctx context.Context, svc *api.APIService, name, filename string, content []byte) (*apipb.Attachment, error) {
|
||||
response, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{
|
||||
Attachment: &apipb.Attachment{Filename: filename, Type: "image/png"},
|
||||
TotalSize: int64(len(content)),
|
||||
ReplaceAttachment: name,
|
||||
}},
|
||||
Data: content,
|
||||
FinishWrite: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response.Attachment, nil
|
||||
}
|
||||
|
||||
// localFilePath resolves a LOCAL attachment reference the way the store does.
|
||||
func localFilePath(data, reference string) string {
|
||||
path := filepath.FromSlash(reference)
|
||||
if filepath.IsAbs(path) {
|
||||
return path
|
||||
}
|
||||
return filepath.Join(data, path)
|
||||
}
|
||||
|
||||
func TestReplaceAttachmentContent(t *testing.T) {
|
||||
original, err := os.ReadFile("testdata/v1.canvas.png")
|
||||
require.NoError(t, err)
|
||||
const bucket = "file-server-attachments"
|
||||
|
||||
for _, storageName := range []string{"database", "local", "s3"} {
|
||||
t.Run(storageName, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc, fs, stores, cleanup := newShareAttachmentTestServices(ctx, t)
|
||||
defer cleanup()
|
||||
var fake *fakes3.Server
|
||||
switch storageName {
|
||||
case "database":
|
||||
configureDatabaseStorage(ctx, t, stores)
|
||||
case "local":
|
||||
configureLocalStorage(ctx, t, stores)
|
||||
case "s3":
|
||||
fake = fakes3.New(t, bucket)
|
||||
configureFakeS3Storage(ctx, t, stores, fake)
|
||||
default:
|
||||
t.Fatalf("unknown storage %q", storageName)
|
||||
}
|
||||
|
||||
owner, err := stores.CreateUser(ctx, &store.User{Username: "artist", Role: store.RoleUser, Email: "artist@example.com"})
|
||||
require.NoError(t, err)
|
||||
ownerCtx := context.WithValue(ctx, auth.UserIDContextKey, owner.ID)
|
||||
attachment := createDrawingInline(ownerCtx, t, svc, original)
|
||||
memo, err := svc.CreateMemo(ownerCtx, &apipb.CreateMemoRequest{Memo: &apipb.Memo{
|
||||
Content: "a drawing",
|
||||
Visibility: apipb.Visibility_PUBLIC,
|
||||
Attachments: []*apipb.Attachment{{Name: attachment.Name}},
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
|
||||
uid, err := api.ExtractAttachmentUIDFromName(attachment.Name)
|
||||
require.NoError(t, err)
|
||||
before, err := stores.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
require.NoError(t, err)
|
||||
// A thumbnail the file server cached for the previous content. The
|
||||
// store and the file server share one data directory in a real server.
|
||||
thumbnail := filepath.Join(stores.GetDataDir(), ".thumbnail_cache", uid+".v2.jpeg")
|
||||
require.NoError(t, os.MkdirAll(filepath.Dir(thumbnail), 0o755))
|
||||
require.NoError(t, os.WriteFile(thumbnail, []byte("stale"), 0o644))
|
||||
|
||||
edited := testutil.BuildPNG(8, 8)
|
||||
replaced, err := replaceContent(ownerCtx, svc, attachment.Name, "drawing-20261106-130000.canvas.png", edited)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, attachment.Name, replaced.Name, "the attachment keeps its name")
|
||||
require.Equal(t, "drawing-20261106-130000.canvas.png", replaced.Filename)
|
||||
require.Equal(t, int64(len(edited)), replaced.Size)
|
||||
require.Equal(t, memo.Name, replaced.GetMemo(), "the attachment stays on its memo")
|
||||
require.Equal(t, attachment.CreateTime.AsTime(), replaced.CreateTime.AsTime())
|
||||
require.NoFileExists(t, thumbnail, "the cached thumbnail of the previous content is dropped")
|
||||
|
||||
mux := http.NewServeMux()
|
||||
fs.RegisterRoutes(mux, http.HandlerFunc(httphandler.NotFound))
|
||||
recorder := httptest.NewRecorder()
|
||||
mux.ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, fmt.Sprintf("/file/%s/%s", replaced.Name, replaced.Filename), nil))
|
||||
require.Equal(t, http.StatusOK, recorder.Code)
|
||||
require.Equal(t, edited, recorder.Body.Bytes())
|
||||
|
||||
after, err := stores.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, before.ID, after.ID)
|
||||
require.Equal(t, before.StorageType, after.StorageType)
|
||||
|
||||
// The previous file is gone from its storage; the new one is there.
|
||||
switch storageName {
|
||||
case "local":
|
||||
require.FileExists(t, localFilePath(svc.Profile.Data, after.Reference))
|
||||
require.NoFileExists(t, localFilePath(svc.Profile.Data, before.Reference))
|
||||
case "s3":
|
||||
_, err := fake.GetObject(bucket, before.Payload.GetS3Object().GetKey())
|
||||
require.Error(t, err)
|
||||
_, err = fake.GetObject(bucket, after.Payload.GetS3Object().GetKey())
|
||||
require.NoError(t, err)
|
||||
default:
|
||||
// A database blob is replaced in the row itself.
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplaceAttachmentContentRefusals(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc, _, stores, cleanup := newShareAttachmentTestServices(ctx, t)
|
||||
defer cleanup()
|
||||
content := testutil.BuildPNG(4, 4)
|
||||
|
||||
owner, err := stores.CreateUser(ctx, &store.User{Username: "owner", Role: store.RoleUser, Email: "owner@example.com"})
|
||||
require.NoError(t, err)
|
||||
other, err := stores.CreateUser(ctx, &store.User{Username: "other", Role: store.RoleUser, Email: "other@example.com"})
|
||||
require.NoError(t, err)
|
||||
admin, err := stores.CreateUser(ctx, &store.User{Username: "admin", Role: store.RoleAdmin, Email: "admin@example.com"})
|
||||
require.NoError(t, err)
|
||||
ownerCtx := context.WithValue(ctx, auth.UserIDContextKey, owner.ID)
|
||||
otherCtx := context.WithValue(ctx, auth.UserIDContextKey, other.ID)
|
||||
adminCtx := context.WithValue(ctx, auth.UserIDContextKey, admin.ID)
|
||||
attachment := createDrawingInline(ownerCtx, t, svc, content)
|
||||
|
||||
_, err = replaceContent(otherCtx, svc, attachment.Name, "drawing.canvas.png", content)
|
||||
require.Equal(t, codes.PermissionDenied, status.Code(err), "only the uploader or an admin may replace it")
|
||||
|
||||
_, err = replaceContent(ctx, svc, attachment.Name, "drawing.canvas.png", content)
|
||||
require.Equal(t, codes.Unauthenticated, status.Code(err))
|
||||
|
||||
_, err = replaceContent(ownerCtx, svc, "attachments/missing", "drawing.canvas.png", content)
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
|
||||
_, err = svc.UploadAttachment(ownerCtx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{
|
||||
Attachment: &apipb.Attachment{Filename: "drawing.canvas.png", Type: "image/png"},
|
||||
AttachmentId: "chosen-id",
|
||||
ReplaceAttachment: attachment.Name,
|
||||
}},
|
||||
})
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err), "a replacement keeps the attachment's ID")
|
||||
|
||||
linked, err := stores.CreateAttachment(ctx, &store.Attachment{
|
||||
UID: "remote-link",
|
||||
CreatorID: owner.ID,
|
||||
Filename: "remote.png",
|
||||
Type: "image/png",
|
||||
StorageType: storepb.AttachmentStorageType_EXTERNAL,
|
||||
Reference: "https://example.com/remote.png",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, err = replaceContent(ownerCtx, svc, "attachments/"+linked.UID, "drawing.canvas.png", content)
|
||||
require.Equal(t, codes.FailedPrecondition, status.Code(err), "an external link has no stored content")
|
||||
|
||||
// An admin may replace anyone's attachment; the owner keeps it.
|
||||
replaced, err := replaceContent(adminCtx, svc, attachment.Name, "drawing-2.canvas.png", content)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, attachment.Name, replaced.Name)
|
||||
uid, err := api.ExtractAttachmentUIDFromName(attachment.Name)
|
||||
require.NoError(t, err)
|
||||
stored, err := stores.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, owner.ID, stored.CreatorID)
|
||||
}
|
||||
|
||||
func TestReplaceAttachmentContentWithMotionPhotoStaysPlain(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc, _, stores, cleanup := newShareAttachmentTestServices(ctx, t)
|
||||
defer cleanup()
|
||||
owner, err := stores.CreateUser(ctx, &store.User{Username: "owner", Role: store.RoleUser, Email: "owner@example.com"})
|
||||
require.NoError(t, err)
|
||||
ownerCtx := context.WithValue(ctx, auth.UserIDContextKey, owner.ID)
|
||||
attachment := createDrawingInline(ownerCtx, t, svc, testutil.BuildPNG(4, 4))
|
||||
|
||||
motion := testutil.BuildMotionPhotoJPEG()
|
||||
response, err := svc.UploadAttachment(ownerCtx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{
|
||||
Attachment: &apipb.Attachment{Filename: "photo.jpg", Type: "image/jpeg"},
|
||||
TotalSize: int64(len(motion)),
|
||||
ReplaceAttachment: attachment.Name,
|
||||
}},
|
||||
Data: motion,
|
||||
FinishWrite: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, response.Attachment.MotionMedia, "a replacement is never part of a motion photo")
|
||||
|
||||
// So it can be replaced again.
|
||||
_, err = replaceContent(ownerCtx, svc, attachment.Name, "drawing.canvas.png", testutil.BuildPNG(4, 4))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestReplaceAttachmentContentConcurrently(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc, _, stores, cleanup := newShareAttachmentTestServices(ctx, t)
|
||||
defer cleanup()
|
||||
configureLocalStorage(ctx, t, stores)
|
||||
owner, err := stores.CreateUser(ctx, &store.User{Username: "owner", Role: store.RoleUser, Email: "owner@example.com"})
|
||||
require.NoError(t, err)
|
||||
ownerCtx := context.WithValue(ctx, auth.UserIDContextKey, owner.ID)
|
||||
attachment := createDrawingInline(ownerCtx, t, svc, testutil.BuildPNG(4, 4))
|
||||
|
||||
const replacements = 6
|
||||
errs := make(chan error, replacements)
|
||||
for i := range replacements {
|
||||
go func() {
|
||||
_, err := replaceContent(ownerCtx, svc, attachment.Name, fmt.Sprintf("drawing-%d.canvas.png", i), testutil.BuildPNG(4+i, 4+i))
|
||||
errs <- err
|
||||
}()
|
||||
}
|
||||
for range replacements {
|
||||
require.NoError(t, <-errs)
|
||||
}
|
||||
|
||||
// Only the file the row points at is left: no replacement orphaned another's.
|
||||
uid, err := api.ExtractAttachmentUIDFromName(attachment.Name)
|
||||
require.NoError(t, err)
|
||||
stored, err := stores.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
require.NoError(t, err)
|
||||
files, err := filepath.Glob(filepath.Join(svc.Profile.Data, "assets", "*"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{localFilePath(svc.Profile.Data, stored.Reference)}, files)
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package fileserver
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/usememos/memos/internal/httphandler"
|
||||
"github.com/usememos/memos/internal/testutil/fakes3"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/server/api"
|
||||
"github.com/usememos/memos/server/auth"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
// TestDrawingPNGRoundTripsUnchanged guards the drawing format of @usememos/canvas: a
|
||||
// drawing is a PNG whose editable scene sits in a zTXt chunk ("memos-canvas"). Uploads
|
||||
// of image/png must be stored and served byte for byte, never re-encoded or stripped
|
||||
// of metadata, or "Edit drawing" would find no scene. The fixture is
|
||||
// tests/fixtures/png/v1.canvas.png from usememos/canvas.
|
||||
func TestDrawingPNGRoundTripsUnchanged(t *testing.T) {
|
||||
fixture, err := os.ReadFile("testdata/v1.canvas.png")
|
||||
require.NoError(t, err)
|
||||
require.True(t, bytes.Contains(fixture, []byte("zTXtmemos-canvas\x00")), "fixture carries the scene chunk")
|
||||
|
||||
storages := map[string]func(context.Context, *testing.T, *store.Store){
|
||||
"database": configureDatabaseStorage,
|
||||
"local": configureLocalStorage,
|
||||
"s3": func(ctx context.Context, t *testing.T, stores *store.Store) {
|
||||
configureFakeS3Storage(ctx, t, stores, fakes3.New(t, "file-server-attachments"))
|
||||
},
|
||||
}
|
||||
uploads := map[string]func(context.Context, *testing.T, *api.APIService, []byte) *apipb.Attachment{
|
||||
"inline": createDrawingInline,
|
||||
"chunked": uploadDrawingInChunks,
|
||||
}
|
||||
|
||||
for storageName, configure := range storages {
|
||||
for uploadName, upload := range uploads {
|
||||
t.Run(storageName+"/"+uploadName, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc, fs, stores, cleanup := newShareAttachmentTestServices(ctx, t)
|
||||
defer cleanup()
|
||||
configure(ctx, t, stores)
|
||||
|
||||
creator, err := stores.CreateUser(ctx, &store.User{Username: "artist", Role: store.RoleUser, Email: "artist@example.com"})
|
||||
require.NoError(t, err)
|
||||
creatorCtx := context.WithValue(ctx, auth.UserIDContextKey, creator.ID)
|
||||
|
||||
attachment := upload(creatorCtx, t, svc, fixture)
|
||||
require.Equal(t, int64(len(fixture)), attachment.Size)
|
||||
_, err = svc.CreateMemo(creatorCtx, &apipb.CreateMemoRequest{Memo: &apipb.Memo{
|
||||
Content: "a drawing",
|
||||
Visibility: apipb.Visibility_PUBLIC,
|
||||
Attachments: []*apipb.Attachment{{Name: attachment.Name}},
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
fs.RegisterRoutes(mux, http.HandlerFunc(httphandler.NotFound))
|
||||
recorder := httptest.NewRecorder()
|
||||
mux.ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, fmt.Sprintf("/file/%s/%s", attachment.Name, attachment.Filename), nil))
|
||||
|
||||
require.Equal(t, http.StatusOK, recorder.Code)
|
||||
require.Equal(t, "image/png", recorder.Header().Get("Content-Type"))
|
||||
require.Equal(t, fixture, recorder.Body.Bytes(), "the original file is served byte for byte")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const drawingFilename = "drawing-20261106-101500.canvas.png"
|
||||
|
||||
// configureDatabaseStorage makes the database the instance's default
|
||||
// attachment storage. Without a setting the test harness stores locally.
|
||||
func configureDatabaseStorage(ctx context.Context, t *testing.T, stores *store.Store) {
|
||||
t.Helper()
|
||||
_, err := stores.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{
|
||||
Storages: []*storepb.Storage{{Id: "database", Name: "Database", Type: storepb.StorageType_STORAGE_TYPE_DATABASE}},
|
||||
DefaultStorageId: "database",
|
||||
}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func createDrawingInline(ctx context.Context, t *testing.T, svc *api.APIService, content []byte) *apipb.Attachment {
|
||||
t.Helper()
|
||||
attachment, err := svc.CreateAttachment(ctx, &apipb.CreateAttachmentRequest{Attachment: &apipb.Attachment{
|
||||
Filename: drawingFilename,
|
||||
Type: "image/png",
|
||||
Content: content,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
return attachment
|
||||
}
|
||||
|
||||
// uploadDrawingInChunks uses the chunked upload the web editor uses for drafts.
|
||||
func uploadDrawingInChunks(ctx context.Context, t *testing.T, svc *api.APIService, content []byte) *apipb.Attachment {
|
||||
t.Helper()
|
||||
half := len(content) / 2
|
||||
started, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{
|
||||
Attachment: &apipb.Attachment{Filename: drawingFilename, Type: "image/png"},
|
||||
TotalSize: int64(len(content)),
|
||||
}},
|
||||
Data: content[:half],
|
||||
})
|
||||
require.NoError(t, err)
|
||||
finished, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{
|
||||
Upload: &apipb.UploadAttachmentRequest_UploadId{UploadId: started.UploadId},
|
||||
WriteOffset: int64(half),
|
||||
Data: content[half:],
|
||||
FinishWrite: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, finished.Attachment)
|
||||
return finished.Attachment
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 242 B |
+17
-3
@@ -71,12 +71,26 @@ type UpdateAttachment struct {
|
||||
Filename *string
|
||||
MemoID *int32
|
||||
Payload *storepb.AttachmentPayload
|
||||
// Content replaces the stored file. The caller has already written the new
|
||||
// object; the previous one is the caller's to delete once this commits.
|
||||
Content *AttachmentContent
|
||||
// Policy is present for transport-facing updates. Drivers discover the
|
||||
// current attachment binding and authorize any linked memo in the same
|
||||
// transaction as the update.
|
||||
Policy *MemoWritePolicy
|
||||
}
|
||||
|
||||
// AttachmentContent is where an attachment's file is stored and what it is.
|
||||
type AttachmentContent struct {
|
||||
Type string
|
||||
Size int64
|
||||
StorageType storepb.AttachmentStorageType
|
||||
// Reference is the local path of a LOCAL file; empty otherwise.
|
||||
Reference string
|
||||
// Blob holds the file of a DATABASE attachment; nil otherwise.
|
||||
Blob []byte
|
||||
}
|
||||
|
||||
type DeleteAttachment struct {
|
||||
ID int32
|
||||
MemoID *int32
|
||||
@@ -324,7 +338,7 @@ func (s *Store) deleteAttachmentStorageImpl(ctx context.Context, attachment *Att
|
||||
}
|
||||
}
|
||||
|
||||
s.deleteAttachmentDerivedCaches(attachment)
|
||||
s.DeleteAttachmentDerivedCaches(attachment)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -382,11 +396,11 @@ func AttachmentNeedsInstanceStorageSetting(attachment *Attachment) bool {
|
||||
return attachment.Payload.GetS3Object() != nil
|
||||
}
|
||||
|
||||
// deleteAttachmentDerivedCaches removes every derived asset the file server
|
||||
// DeleteAttachmentDerivedCaches removes every derived asset the file server
|
||||
// may have written for the attachment: the current thumbnail, its failure
|
||||
// marker, the pre-v2 thumbnail name, and the extracted motion clip. The names
|
||||
// must match server/fileserver.
|
||||
func (s *Store) deleteAttachmentDerivedCaches(attachment *Attachment) {
|
||||
func (s *Store) DeleteAttachmentDerivedCaches(attachment *Attachment) {
|
||||
for _, cachePath := range []string{
|
||||
filepath.Join(s.profile.Data, thumbnailCacheFolder, attachment.UID+".v2.jpeg"),
|
||||
filepath.Join(s.profile.Data, thumbnailCacheFolder, attachment.UID+".v2.jpeg.failed"),
|
||||
|
||||
@@ -46,10 +46,7 @@ func (d *DB) CreateAttachment(ctx context.Context, create *store.Attachment) (*s
|
||||
func insertMySQLAttachment(ctx context.Context, executor memoUpdateExecer, create *store.Attachment) (int32, error) {
|
||||
fields := []string{"`uid`", "`filename`", "`blob`", "`type`", "`size`", "`creator_id`", "`memo_id`", "`storage_type`", "`reference`", "`payload`"}
|
||||
placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?", "?", "?"}
|
||||
storageType := ""
|
||||
if create.StorageType != storepb.AttachmentStorageType_ATTACHMENT_STORAGE_TYPE_UNSPECIFIED {
|
||||
storageType = create.StorageType.String()
|
||||
}
|
||||
storageType := attachmentStorageTypeString(create.StorageType)
|
||||
payloadString := "{}"
|
||||
if create.Payload != nil {
|
||||
bytes, err := protojson.Marshal(create.Payload)
|
||||
@@ -285,6 +282,10 @@ func applyMySQLAttachmentUpdate(ctx context.Context, executor memoUpdateExecer,
|
||||
}
|
||||
set, args = append(set, "`payload` = ?"), append(args, string(bytes))
|
||||
}
|
||||
if c := update.Content; c != nil {
|
||||
set = append(set, "`type` = ?", "`size` = ?", "`storage_type` = ?", "`reference` = ?", "`blob` = ?")
|
||||
args = append(args, c.Type, c.Size, attachmentStorageTypeString(c.StorageType), c.Reference, c.Blob)
|
||||
}
|
||||
|
||||
if len(set) == 0 {
|
||||
return nil
|
||||
@@ -354,3 +355,11 @@ func (d *DB) GetAttachmentStorageUsage(ctx context.Context, creatorID int32) (in
|
||||
}
|
||||
return size, nil
|
||||
}
|
||||
|
||||
// attachmentStorageTypeString is the storage_type column value: the enum name, or empty for unspecified.
|
||||
func attachmentStorageTypeString(storageType storepb.AttachmentStorageType) string {
|
||||
if storageType == storepb.AttachmentStorageType_ATTACHMENT_STORAGE_TYPE_UNSPECIFIED {
|
||||
return ""
|
||||
}
|
||||
return storageType.String()
|
||||
}
|
||||
|
||||
@@ -45,10 +45,7 @@ type postgresAttachmentQueryRower interface {
|
||||
|
||||
func insertPostgresAttachment(ctx context.Context, executor postgresAttachmentQueryRower, create *store.Attachment) (*store.Attachment, error) {
|
||||
fields := []string{"uid", "filename", "blob", "type", "size", "creator_id", "memo_id", "storage_type", "reference", "payload"}
|
||||
storageType := ""
|
||||
if create.StorageType != storepb.AttachmentStorageType_ATTACHMENT_STORAGE_TYPE_UNSPECIFIED {
|
||||
storageType = create.StorageType.String()
|
||||
}
|
||||
storageType := attachmentStorageTypeString(create.StorageType)
|
||||
payloadString := "{}"
|
||||
if create.Payload != nil {
|
||||
bytes, err := protojson.Marshal(create.Payload)
|
||||
@@ -271,6 +268,13 @@ func applyPostgresAttachmentUpdate(ctx context.Context, executor memoUpdateExece
|
||||
}
|
||||
set, args = append(set, "payload = "+placeholder(len(args)+1)), append(args, string(bytes))
|
||||
}
|
||||
if c := update.Content; c != nil {
|
||||
columns := []string{"type", "size", "storage_type", "reference", "blob"}
|
||||
values := []any{c.Type, c.Size, attachmentStorageTypeString(c.StorageType), c.Reference, c.Blob}
|
||||
for i, column := range columns {
|
||||
set, args = append(set, column+" = "+placeholder(len(args)+1)), append(args, values[i])
|
||||
}
|
||||
}
|
||||
|
||||
if len(set) == 0 {
|
||||
return nil
|
||||
@@ -331,3 +335,11 @@ func (d *DB) GetAttachmentStorageUsage(ctx context.Context, creatorID int32) (in
|
||||
}
|
||||
return size, nil
|
||||
}
|
||||
|
||||
// attachmentStorageTypeString is the storage_type column value: the enum name, or empty for unspecified.
|
||||
func attachmentStorageTypeString(storageType storepb.AttachmentStorageType) string {
|
||||
if storageType == storepb.AttachmentStorageType_ATTACHMENT_STORAGE_TYPE_UNSPECIFIED {
|
||||
return ""
|
||||
}
|
||||
return storageType.String()
|
||||
}
|
||||
|
||||
@@ -42,10 +42,7 @@ func (d *DB) CreateAttachment(ctx context.Context, create *store.Attachment) (*s
|
||||
func insertSQLiteAttachment(ctx context.Context, executor dbExecutor, create *store.Attachment) (*store.Attachment, error) {
|
||||
fields := []string{"`uid`", "`filename`", "`blob`", "`type`", "`size`", "`creator_id`", "`memo_id`", "`storage_type`", "`reference`", "`payload`"}
|
||||
placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?", "?", "?"}
|
||||
storageType := ""
|
||||
if create.StorageType != storepb.AttachmentStorageType_ATTACHMENT_STORAGE_TYPE_UNSPECIFIED {
|
||||
storageType = create.StorageType.String()
|
||||
}
|
||||
storageType := attachmentStorageTypeString(create.StorageType)
|
||||
payloadString := "{}"
|
||||
if create.Payload != nil {
|
||||
bytes, err := protojson.Marshal(create.Payload)
|
||||
@@ -264,6 +261,10 @@ func applySQLiteAttachmentUpdate(ctx context.Context, executor dbExecutor, updat
|
||||
}
|
||||
set, args = append(set, "`payload` = ?"), append(args, string(bytes))
|
||||
}
|
||||
if c := update.Content; c != nil {
|
||||
set = append(set, "`type` = ?", "`size` = ?", "`storage_type` = ?", "`reference` = ?", "`blob` = ?")
|
||||
args = append(args, c.Type, c.Size, attachmentStorageTypeString(c.StorageType), c.Reference, c.Blob)
|
||||
}
|
||||
|
||||
args = append(args, update.ID)
|
||||
stmt := "UPDATE `attachment` SET " + strings.Join(set, ", ") + " WHERE `id` = ?"
|
||||
@@ -316,3 +317,11 @@ func (d *DB) GetAttachmentStorageUsage(ctx context.Context, creatorID int32) (in
|
||||
}
|
||||
return size, nil
|
||||
}
|
||||
|
||||
// attachmentStorageTypeString is the storage_type column value: the enum name, or empty for unspecified.
|
||||
func attachmentStorageTypeString(storageType storepb.AttachmentStorageType) string {
|
||||
if storageType == storepb.AttachmentStorageType_ATTACHMENT_STORAGE_TYPE_UNSPECIFIED {
|
||||
return ""
|
||||
}
|
||||
return storageType.String()
|
||||
}
|
||||
|
||||
@@ -525,6 +525,56 @@ func TestAttachmentUpdate(t *testing.T) {
|
||||
ts.Close()
|
||||
}
|
||||
|
||||
func TestAttachmentUpdateContent(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ts := NewTestingStore(ctx, t)
|
||||
defer ts.Close()
|
||||
|
||||
attachment, err := ts.CreateAttachment(ctx, &store.Attachment{
|
||||
UID: shortuuid.New(),
|
||||
CreatorID: 101,
|
||||
Filename: "drawing.canvas.png",
|
||||
Blob: []byte("first drawing"),
|
||||
Type: "application/octet-stream",
|
||||
Size: 13,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// Database content moves to a local file: the blob is cleared.
|
||||
err = ts.UpdateAttachment(ctx, &store.UpdateAttachment{
|
||||
ID: attachment.ID,
|
||||
Content: &store.AttachmentContent{
|
||||
Type: "image/png",
|
||||
Size: 2048,
|
||||
StorageType: storepb.AttachmentStorageType_LOCAL,
|
||||
Reference: "assets/drawing.canvas.png",
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
found, err := ts.GetAttachment(ctx, &store.FindAttachment{ID: &attachment.ID, GetBlob: true})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, attachment.UID, found.UID)
|
||||
require.Equal(t, "image/png", found.Type)
|
||||
require.Equal(t, int64(2048), found.Size)
|
||||
require.Equal(t, storepb.AttachmentStorageType_LOCAL, found.StorageType)
|
||||
require.Equal(t, "assets/drawing.canvas.png", found.Reference)
|
||||
require.Empty(t, found.Blob)
|
||||
|
||||
// And back into the database: the reference is cleared.
|
||||
err = ts.UpdateAttachment(ctx, &store.UpdateAttachment{
|
||||
ID: attachment.ID,
|
||||
Content: &store.AttachmentContent{Type: "image/png", Size: 14, Blob: []byte("second drawing")},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
found, err = ts.GetAttachment(ctx, &store.FindAttachment{ID: &attachment.ID, GetBlob: true})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int64(14), found.Size)
|
||||
require.Equal(t, storepb.AttachmentStorageType_ATTACHMENT_STORAGE_TYPE_UNSPECIFIED, found.StorageType)
|
||||
require.Empty(t, found.Reference)
|
||||
require.Equal(t, []byte("second drawing"), found.Blob)
|
||||
}
|
||||
|
||||
func TestAttachmentGetByUID(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
+2
-1
@@ -26,8 +26,9 @@
|
||||
"@tailwindcss/vite": "^4.2.4",
|
||||
"@tanstack/react-query": "^5.100.9",
|
||||
"@tanstack/react-query-devtools": "^5.100.9",
|
||||
"@usememos/canvas": "26.11.2",
|
||||
"@usememos/editor": "26.11.0",
|
||||
"@usememos/ui": "26.11.7",
|
||||
"@usememos/ui": "26.11.9",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"copy-to-clipboard": "^4.0.2",
|
||||
|
||||
Generated
+24
-5
@@ -38,12 +38,15 @@ importers:
|
||||
'@tanstack/react-query-devtools':
|
||||
specifier: ^5.100.9
|
||||
version: 5.100.9(@tanstack/react-query@5.100.9(react@19.2.6))(react@19.2.6)
|
||||
'@usememos/canvas':
|
||||
specifier: 26.11.2
|
||||
version: 26.11.2(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
||||
'@usememos/editor':
|
||||
specifier: 26.11.0
|
||||
version: 26.11.0(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
||||
'@usememos/ui':
|
||||
specifier: 26.11.7
|
||||
version: 26.11.7(@base-ui/react@1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(lucide-react@1.34.0(react@19.2.6))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
||||
specifier: 26.11.9
|
||||
version: 26.11.9(@base-ui/react@1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(lucide-react@1.34.0(react@19.2.6))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
||||
class-variance-authority:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1
|
||||
@@ -948,6 +951,17 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@usememos/canvas@26.11.2':
|
||||
resolution: {integrity: sha512-sgFrRUSUz5qq3JMiVqPVsLd8NPL+nmWfuEG45mpjbvBbPRxHdKSzNVYc6DwokG/Z670zJI3gDc5Lfsi75QYvGw==}
|
||||
peerDependencies:
|
||||
react: '>=18'
|
||||
react-dom: '>=18'
|
||||
peerDependenciesMeta:
|
||||
react:
|
||||
optional: true
|
||||
react-dom:
|
||||
optional: true
|
||||
|
||||
'@usememos/editor@26.11.0':
|
||||
resolution: {integrity: sha512-8e0mcauyLH9ivn3oEKdwUO0cFeJdMjfMTfPgVvXf82D2IN4ekiBzaFjbVGjUbct4gDATVClywFPxQx9RreTbZw==}
|
||||
peerDependencies:
|
||||
@@ -959,8 +973,8 @@ packages:
|
||||
react-dom:
|
||||
optional: true
|
||||
|
||||
'@usememos/ui@26.11.7':
|
||||
resolution: {integrity: sha512-DwDZMoBSNLuPb841L9E6P9++URgAeoekKIRgqdPzDqZt7/gZsp8TtuaF6pkuQabC4yvXU4VsnPmU4/O0iwrB7g==}
|
||||
'@usememos/ui@26.11.9':
|
||||
resolution: {integrity: sha512-rO0rmjrSwjMO60ftTV6yrmzrctF0Xtdqd8iT77vTYtVhd2ehl2KIqwym46nCLeQcp44oYFFt8rjtI6+Eqj57Aw==}
|
||||
peerDependencies:
|
||||
'@base-ui/react': 1.9.0
|
||||
lucide-react: '>=1.0.0'
|
||||
@@ -2368,12 +2382,17 @@ snapshots:
|
||||
'@typescript/typescript-win32-x64@7.0.2':
|
||||
optional: true
|
||||
|
||||
'@usememos/canvas@26.11.2(react-dom@19.2.6(react@19.2.6))(react@19.2.6)':
|
||||
optionalDependencies:
|
||||
react: 19.2.6
|
||||
react-dom: 19.2.6(react@19.2.6)
|
||||
|
||||
'@usememos/editor@26.11.0(react-dom@19.2.6(react@19.2.6))(react@19.2.6)':
|
||||
optionalDependencies:
|
||||
react: 19.2.6
|
||||
react-dom: 19.2.6(react@19.2.6)
|
||||
|
||||
'@usememos/ui@26.11.7(@base-ui/react@1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(lucide-react@1.34.0(react@19.2.6))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)':
|
||||
'@usememos/ui@26.11.9(@base-ui/react@1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(lucide-react@1.34.0(react@19.2.6))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)':
|
||||
dependencies:
|
||||
'@base-ui/react': 1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
||||
lucide-react: 1.34.0(react@19.2.6)
|
||||
|
||||
@@ -108,7 +108,7 @@ const TagsSection = ({ tagCount, onSelect, scope }: Props) => {
|
||||
/>
|
||||
<Tooltip.Popup side="top">{t("common.more")}</Tooltip.Popup>
|
||||
</Tooltip.Root>
|
||||
<Menu.Popup align="end" className="w-44">
|
||||
<Menu.Popup align="end">
|
||||
<Menu.Group>
|
||||
<Menu.GroupLabel>{t("common.tags")}</Menu.GroupLabel>
|
||||
<Menu.CheckboxItem checked={treeMode} onCheckedChange={setTreeMode} closeOnClick icon={<ListTreeIcon />}>
|
||||
|
||||
@@ -42,6 +42,7 @@ export const sidebarSurfaceVariants = cva("min-w-0 items-center", {
|
||||
* The scope panel that opens from the sidebar title is a list Popover with `mu-compact`, so its
|
||||
* rows are the package's menu rows at 28px. Each keeps a 20px leading slot, so icons, the avatar
|
||||
* and Space marks share one column; a Popover sets no highlight, so the rows add their own hover.
|
||||
* A row whose own menu is open takes the package's highlight.
|
||||
*/
|
||||
export const SCOPE_PANEL_ROW_CLASSES = `${menuClasses().item} transition-colors hover:bg-mu-hover data-popup-open:bg-mu-hover aria-[current=page]:bg-mu-hover mu-focus`;
|
||||
export const SCOPE_PANEL_ROW_CLASSES = `${menuClasses().item} transition-colors hover:bg-mu-hover aria-[current=page]:bg-mu-hover mu-focus`;
|
||||
export const SCOPE_PANEL_ICON_CLASSES = "mu-icon text-mu-ink-muted";
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { Dialog } from "@usememos/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import useMediaQuery from "@/hooks/useMediaQuery";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/**
|
||||
* The dialog a drawing opens in, for viewing and editing alike. From `md` up it nearly fills
|
||||
* the window, 24px from each edge, so the memo stays in view around it; narrower, it fills the
|
||||
* screen. The drawing's paper fills it edge to edge, and the controls float on the paper.
|
||||
* One Popup with changing props, so crossing the breakpoint never remounts the canvas.
|
||||
*/
|
||||
export const DrawingDialogPopup = ({ label, children }: { label: string; children: ReactNode }) => {
|
||||
const isInset = useMediaQuery("md");
|
||||
return (
|
||||
<Dialog.Popup
|
||||
variant="bare"
|
||||
fullScreen={!isInset}
|
||||
sheet={false}
|
||||
aria-label={label}
|
||||
className={cn(isInset && "h-[calc(100dvh-48px)] max-h-none w-[calc(100vw-48px)] max-w-none overflow-hidden")}
|
||||
>
|
||||
{children}
|
||||
</Dialog.Popup>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* A row of floating bars along the paper's top or bottom edge, clear of a phone's safe areas.
|
||||
* Only the bars take pointer events; the paper between them stays drawable.
|
||||
*/
|
||||
export const FloatingRow = ({ edge, className, children }: { edge: "top" | "bottom"; className?: string; children: ReactNode }) => (
|
||||
<div
|
||||
className={cn(
|
||||
"pointer-events-none absolute inset-x-3 flex gap-2",
|
||||
edge === "top"
|
||||
? "top-[calc(12px+env(safe-area-inset-top))] items-center justify-between"
|
||||
: "bottom-[calc(12px+env(safe-area-inset-bottom))] justify-center",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
/**
|
||||
* A lone action on the paper, without a bar: the button is its own surface. Light in every
|
||||
* theme, like the paper under it.
|
||||
*/
|
||||
export const FloatingAction = ({ children }: { children: ReactNode }) => (
|
||||
<div data-theme="light" className="pointer-events-auto">
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
/**
|
||||
* A group of controls floating on the paper: one raised bar with flat controls inside, so no
|
||||
* shadow sits inside another. Light in every theme, like the paper under it.
|
||||
*/
|
||||
export const FloatingBar = ({ className, children }: { className?: string; children: ReactNode }) => (
|
||||
<div
|
||||
data-theme="light"
|
||||
className={cn("pointer-events-auto flex items-center gap-0.5 rounded-mu-lg bg-mu-surface p-1 shadow-mu-pop", className)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
@@ -0,0 +1,465 @@
|
||||
import { type CanvasError, type CanvasHandle, drawingFileName, type Scene, type ToolName } from "@usememos/canvas";
|
||||
import { Canvas } from "@usememos/canvas/react";
|
||||
import { AlertDialog, Button, Dialog, Popover, Toggle, ToggleGroup, Tooltip } from "@usememos/ui";
|
||||
import {
|
||||
CircleIcon,
|
||||
EraserIcon,
|
||||
ImagePlusIcon,
|
||||
MousePointer2Icon,
|
||||
MoveUpRightIcon,
|
||||
PencilIcon,
|
||||
Redo2Icon,
|
||||
ScanIcon,
|
||||
SquareIcon,
|
||||
TypeIcon,
|
||||
Undo2Icon,
|
||||
} from "lucide-react";
|
||||
import { type ClipboardEvent, type ReactElement, useEffect, useRef, useState } from "react";
|
||||
import useMediaQuery from "@/hooks/useMediaQuery";
|
||||
import { showErrorToast } from "@/lib/toast";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { type Translations, useTranslate } from "@/utils/i18n";
|
||||
import { primaryModifierGlyph } from "@/utils/platform";
|
||||
import { DrawingDialogPopup, FloatingAction, FloatingBar, FloatingRow } from "./DrawingFrame";
|
||||
import { DRAWING_HUES, useCanvasTheme } from "./useCanvasTheme";
|
||||
|
||||
const TOOLS: { name: ToolName; label: Translations; shortcut: string; icon: ReactElement }[] = [
|
||||
{ name: "select", label: "editor.drawing.tool-select", shortcut: "V", icon: <MousePointer2Icon /> },
|
||||
{ name: "pen", label: "editor.drawing.tool-pen", shortcut: "P", icon: <PencilIcon /> },
|
||||
{ name: "eraser", label: "editor.drawing.tool-eraser", shortcut: "E", icon: <EraserIcon /> },
|
||||
{ name: "rectangle", label: "editor.drawing.tool-rectangle", shortcut: "R", icon: <SquareIcon /> },
|
||||
{ name: "ellipse", label: "editor.drawing.tool-ellipse", shortcut: "O", icon: <CircleIcon /> },
|
||||
{ name: "arrow", label: "editor.drawing.tool-arrow", shortcut: "A", icon: <MoveUpRightIcon /> },
|
||||
{ name: "text", label: "editor.drawing.tool-text", shortcut: "T", icon: <TypeIcon /> },
|
||||
];
|
||||
// One stable list, so the canvas does not reset its tools on every render.
|
||||
const TOOL_NAMES = TOOLS.map((tool) => tool.name);
|
||||
|
||||
const WIDTHS: { value: number; label: Translations }[] = [
|
||||
{ value: 1, label: "editor.drawing.width-thin" },
|
||||
{ value: 2, label: "editor.drawing.width-medium" },
|
||||
{ value: 4, label: "editor.drawing.width-thick" },
|
||||
];
|
||||
|
||||
export interface DrawingSheetProps {
|
||||
/** `edit` reopens a saved drawing; it changes the sheet's name and the discard prompt. */
|
||||
mode: "new" | "edit";
|
||||
/** The scene read from the drawing's original file. */
|
||||
initialScene?: Scene;
|
||||
/** A picture to draw on: a file named like a drawing whose scene could not be read. */
|
||||
background?: Blob;
|
||||
/**
|
||||
* The finished drawing, a PNG with the scene embedded, named `drawing-YYYYMMDD-HHMMSS.canvas.png`.
|
||||
* A promise keeps Done busy until it settles; a rejection keeps the sheet open to retry.
|
||||
*/
|
||||
onDone: (file: File) => void | Promise<void>;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The drawing sheet: the paper fills the drawing dialog, with the controls floating on it.
|
||||
* `@usememos/canvas` draws and edits the scene; everything around it (the controls, strings,
|
||||
* theme, discard prompt) is memos'. On a phone the tools float at the bottom, in thumb
|
||||
* reach, with each control 44 px apart.
|
||||
*/
|
||||
const DrawingSheet = ({ mode, initialScene, background, onDone, onClose }: DrawingSheetProps) => {
|
||||
const t = useTranslate();
|
||||
const isWide = useMediaQuery("sm");
|
||||
// Small controls on a desktop; a phone keeps the 32px ones, 44px apart, for touch.
|
||||
const size = isWide ? "sm" : undefined;
|
||||
const { theme, ink, fontFamily } = useCanvasTheme();
|
||||
const canvasRef = useRef<CanvasHandle | null>(null);
|
||||
const surfaceRef = useRef<HTMLDivElement>(null);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const [tool, setTool] = useState<ToolName>("pen");
|
||||
const [history, setHistory] = useState({ undo: false, redo: false });
|
||||
// Null follows the theme's ink, so a drawing started in one theme keeps reading in the other.
|
||||
const [color, setColor] = useState<string | null>(null);
|
||||
const [width, setWidth] = useState(2);
|
||||
const [isExporting, setIsExporting] = useState(false);
|
||||
const [discardOpen, setDiscardOpen] = useState(false);
|
||||
// Drawing waits for a background picture, so no stroke can land before it and be marked saved with it.
|
||||
const [isPreparing, setIsPreparing] = useState(Boolean(background));
|
||||
const title = t(mode === "edit" ? "editor.drawing.edit" : "editor.drawing.new-title");
|
||||
const currentColor = color ?? ink;
|
||||
|
||||
// Runs once the canvas has mounted (see CanvasMounted): the pen is ready, and a
|
||||
// picture without a scene becomes the drawing's locked background.
|
||||
const setUpCanvas = () => {
|
||||
const canvas = canvasRef.current;
|
||||
if (!canvas) return;
|
||||
canvas.setTool("pen");
|
||||
if (!background) return;
|
||||
canvas
|
||||
.insertImage(background, { background: true })
|
||||
.then(() => {
|
||||
// The picture is where the drawing starts, not a change to discard.
|
||||
canvas.markSaved();
|
||||
canvas.zoomToFit();
|
||||
})
|
||||
.catch(() => showErrorToast(t("editor.drawing.image-failed")))
|
||||
.finally(() => setIsPreparing(false));
|
||||
};
|
||||
|
||||
const syncHistory = () => {
|
||||
const canvas = canvasRef.current;
|
||||
setHistory({ undo: Boolean(canvas?.canUndo()), redo: Boolean(canvas?.canRedo()) });
|
||||
};
|
||||
|
||||
const handleCanvasError = (error: CanvasError) => {
|
||||
if (error.operation === "insert-image" || error.operation === "load-image") showErrorToast(t("editor.drawing.image-failed"));
|
||||
else if (error.operation === "export-png") showErrorToast(t("editor.drawing.export-failed"));
|
||||
// A face of the UI font stack that cannot load (a local() alias, say) falls back to the
|
||||
// next one in the stack; nothing for the person to act on.
|
||||
};
|
||||
|
||||
const chooseTool = (next: ToolName) => {
|
||||
setTool(next);
|
||||
canvasRef.current?.setTool(next);
|
||||
};
|
||||
|
||||
const applyWidth = (strokeWidth: number) => {
|
||||
canvasRef.current?.setStyle({ strokeWidth });
|
||||
setWidth(strokeWidth);
|
||||
};
|
||||
|
||||
const insertImages = (files: File[]) => {
|
||||
for (const file of files.filter((candidate) => candidate.type.startsWith("image/"))) {
|
||||
canvasRef.current?.insertImage(file).catch(() => showErrorToast(t("editor.drawing.image-failed")));
|
||||
}
|
||||
};
|
||||
|
||||
// The drawing surface inserts pasted pictures itself; a paste anywhere else on the sheet lands there too.
|
||||
const handlePaste = (event: ClipboardEvent) => {
|
||||
if (surfaceRef.current?.contains(event.target as Node)) return;
|
||||
insertImages(Array.from(event.clipboardData.files));
|
||||
};
|
||||
|
||||
// Cancel, Escape and the system back gesture all ask first when the drawing has changes.
|
||||
const requestClose = () => {
|
||||
if (canvasRef.current?.isDirty()) {
|
||||
setDiscardOpen(true);
|
||||
return;
|
||||
}
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleDone = async () => {
|
||||
const canvas = canvasRef.current;
|
||||
if (!canvas || isExporting || isPreparing) return;
|
||||
// Text still being typed is part of the drawing.
|
||||
canvas.commitText();
|
||||
setIsExporting(true);
|
||||
try {
|
||||
const blob = await canvas.exportPng();
|
||||
await onDone(new File([blob], drawingFileName(), { type: "image/png" }));
|
||||
// Only once Done went through: after a failed save, Cancel still asks before discarding.
|
||||
// The host may have closed the sheet already.
|
||||
canvasRef.current?.markSaved();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
showErrorToast(t("editor.drawing.export-failed"));
|
||||
} finally {
|
||||
setIsExporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const toolRow = (
|
||||
<div role="group" aria-label={t("editor.drawing.tools")} className={cn("flex items-center", isWide ? "gap-0.5" : "gap-3")}>
|
||||
{TOOLS.map((item) => (
|
||||
<Tooltip.Root key={item.name}>
|
||||
<Tooltip.Trigger
|
||||
render={
|
||||
<Toggle
|
||||
size={size}
|
||||
aria-label={t(item.label)}
|
||||
icon={item.icon}
|
||||
pressed={tool === item.name}
|
||||
onPressedChange={() => chooseTool(item.name)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Tooltip.Popup shortcut={item.shortcut}>{t(item.label)}</Tooltip.Popup>
|
||||
</Tooltip.Root>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
const swatches = [{ key: "ink", value: ink }, ...DRAWING_HUES.map((hue) => ({ key: hue.key, value: hue.value }))] as const;
|
||||
const styleControl = (
|
||||
<Popover.Root>
|
||||
<Tooltip.Root>
|
||||
<Tooltip.Trigger
|
||||
render={
|
||||
<Popover.Trigger
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size={size}
|
||||
aria-label={t("editor.drawing.style")}
|
||||
icon={<CircleIcon style={{ color: currentColor, fill: currentColor }} />}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Tooltip.Popup>{t("editor.drawing.style")}</Tooltip.Popup>
|
||||
</Tooltip.Root>
|
||||
<Popover.Popup side={isWide ? "bottom" : "top"} aria-label={t("editor.drawing.style")}>
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="mu-label-sm text-mu-ink-muted">{t("editor.drawing.color")}</span>
|
||||
<div
|
||||
role="group"
|
||||
aria-label={t("editor.drawing.color")}
|
||||
className={cn("grid justify-items-start", isWide ? "grid-cols-8 gap-0.5" : "grid-cols-4 gap-3")}
|
||||
>
|
||||
{swatches.map((swatch) => (
|
||||
<Tooltip.Root key={swatch.key}>
|
||||
<Tooltip.Trigger
|
||||
render={
|
||||
<Toggle
|
||||
aria-label={t(`editor.drawing.color-${swatch.key}`)}
|
||||
pressed={currentColor.toLowerCase() === swatch.value.toLowerCase()}
|
||||
onPressedChange={() => {
|
||||
canvasRef.current?.setStyle({ strokeColor: swatch.value });
|
||||
setColor(swatch.key === "ink" ? null : swatch.value);
|
||||
}}
|
||||
icon={<CircleIcon style={{ color: swatch.value, fill: swatch.value }} />}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Tooltip.Popup>{t(`editor.drawing.color-${swatch.key}`)}</Tooltip.Popup>
|
||||
</Tooltip.Root>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="mu-label-sm text-mu-ink-muted">{t("editor.drawing.width")}</span>
|
||||
<ToggleGroup
|
||||
fullWidth
|
||||
aria-label={t("editor.drawing.width")}
|
||||
value={[String(width)]}
|
||||
onValueChange={([next]) => next && applyWidth(Number(next))}
|
||||
>
|
||||
{WIDTHS.map((option) => (
|
||||
<Toggle key={option.value} value={String(option.value)}>
|
||||
{t(option.label)}
|
||||
</Toggle>
|
||||
))}
|
||||
</ToggleGroup>
|
||||
</div>
|
||||
</Popover.Popup>
|
||||
</Popover.Root>
|
||||
);
|
||||
|
||||
const modifier = primaryModifierGlyph();
|
||||
const historyControls = (
|
||||
<>
|
||||
<IconAction
|
||||
size={size}
|
||||
label={t("editor.drawing.undo")}
|
||||
shortcut={`${modifier} Z`}
|
||||
icon={<Undo2Icon />}
|
||||
disabled={!history.undo}
|
||||
onClick={() => {
|
||||
canvasRef.current?.undo();
|
||||
syncHistory();
|
||||
}}
|
||||
/>
|
||||
<IconAction
|
||||
size={size}
|
||||
label={t("editor.drawing.redo")}
|
||||
shortcut={`⇧ ${modifier} Z`}
|
||||
icon={<Redo2Icon />}
|
||||
disabled={!history.redo}
|
||||
onClick={() => {
|
||||
canvasRef.current?.redo();
|
||||
syncHistory();
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
const viewControls = (
|
||||
<>
|
||||
<IconAction size={size} label={t("editor.drawing.zoom-to-fit")} icon={<ScanIcon />} onClick={() => canvasRef.current?.zoomToFit()} />
|
||||
<IconAction
|
||||
size={size}
|
||||
label={t("editor.insert-menu.insert-image")}
|
||||
icon={<ImagePlusIcon />}
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
const cancelButton = (
|
||||
<Button variant="ghost" size={size} onClick={requestClose}>
|
||||
{t("common.cancel")}
|
||||
</Button>
|
||||
);
|
||||
const doneButton = (
|
||||
<Button
|
||||
variant="primary"
|
||||
size={size}
|
||||
onClick={handleDone}
|
||||
disabled={isPreparing}
|
||||
loading={isExporting}
|
||||
loadingLabel={t("editor.drawing.done")}
|
||||
>
|
||||
{t("editor.drawing.done")}
|
||||
</Button>
|
||||
);
|
||||
|
||||
return (
|
||||
<Dialog.Root
|
||||
open
|
||||
onOpenChange={(open, eventDetails) => {
|
||||
if (open) return;
|
||||
// The sheet closes only through requestClose, which asks first when there are changes.
|
||||
eventDetails.cancel();
|
||||
// Escape on the drawing surface leaves the current tool or selection; it belongs to the canvas.
|
||||
const escapeOnSurface = eventDetails.reason === "escape-key" && surfaceRef.current?.contains(eventDetails.event.target as Node);
|
||||
if (!escapeOnSurface) requestClose();
|
||||
}}
|
||||
>
|
||||
<DrawingDialogPopup label={title}>
|
||||
<div className="relative h-full w-full" style={{ background: theme.paper }} onPaste={handlePaste}>
|
||||
<Dialog.Title className="mu-visually-hidden">{title}</Dialog.Title>
|
||||
|
||||
{/* Undo and redo follow every gesture and shortcut as it ends; onChange alone is debounced. */}
|
||||
<div
|
||||
ref={surfaceRef}
|
||||
className={cn("absolute inset-0", isPreparing && "pointer-events-none")}
|
||||
aria-busy={isPreparing || undefined}
|
||||
onPointerUp={syncHistory}
|
||||
onKeyUp={syncHistory}
|
||||
>
|
||||
<Canvas
|
||||
ref={canvasRef}
|
||||
className="absolute inset-0"
|
||||
autoFocus
|
||||
ariaLabel={title}
|
||||
initialScene={initialScene}
|
||||
theme={theme}
|
||||
tools={TOOL_NAMES}
|
||||
fontFamily={fontFamily}
|
||||
onChange={syncHistory}
|
||||
onToolChange={setTool}
|
||||
onError={handleCanvasError}
|
||||
/>
|
||||
<CanvasMounted onMounted={setUpCanvas} />
|
||||
</div>
|
||||
|
||||
{isWide ? (
|
||||
<FloatingRow edge="top">
|
||||
<FloatingAction>{cancelButton}</FloatingAction>
|
||||
<FloatingBar>
|
||||
{toolRow}
|
||||
<Divider />
|
||||
{styleControl}
|
||||
<Divider />
|
||||
{historyControls}
|
||||
<Divider />
|
||||
{viewControls}
|
||||
</FloatingBar>
|
||||
<FloatingAction>{doneButton}</FloatingAction>
|
||||
</FloatingRow>
|
||||
) : (
|
||||
<>
|
||||
<FloatingRow edge="top">
|
||||
<FloatingAction>{cancelButton}</FloatingAction>
|
||||
<FloatingBar className="gap-3">
|
||||
{historyControls}
|
||||
{viewControls}
|
||||
</FloatingBar>
|
||||
<FloatingAction>{doneButton}</FloatingAction>
|
||||
</FloatingRow>
|
||||
{/* The tools in thumb reach. Under 380px the divider goes and the bar nears the
|
||||
edges, so a 360px screen keeps 44px between targets. */}
|
||||
<FloatingRow edge="bottom" className="max-[380px]:inset-x-1.5">
|
||||
<FloatingBar className="gap-3">
|
||||
{toolRow}
|
||||
<Divider className="mx-0 max-[380px]:hidden" />
|
||||
{styleControl}
|
||||
</FloatingBar>
|
||||
</FloatingRow>
|
||||
</>
|
||||
)}
|
||||
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
className="hidden"
|
||||
onChange={(event) => {
|
||||
insertImages(Array.from(event.target.files ?? []));
|
||||
event.target.value = "";
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<AlertDialog.Root open={discardOpen} onOpenChange={setDiscardOpen}>
|
||||
<AlertDialog.Popup>
|
||||
<AlertDialog.Title>
|
||||
{t(mode === "edit" ? "editor.drawing.discard-edit-title" : "editor.drawing.discard-title")}
|
||||
</AlertDialog.Title>
|
||||
<AlertDialog.Description>
|
||||
{t(mode === "edit" ? "editor.drawing.discard-edit-description" : "editor.drawing.discard-description")}
|
||||
</AlertDialog.Description>
|
||||
<AlertDialog.Footer>
|
||||
<AlertDialog.Close render={<Button variant="ghost">{t("editor.drawing.keep-drawing")}</Button>} />
|
||||
<Button
|
||||
variant="danger"
|
||||
onClick={() => {
|
||||
setDiscardOpen(false);
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
{t("editor.drawing.discard")}
|
||||
</Button>
|
||||
</AlertDialog.Footer>
|
||||
</AlertDialog.Popup>
|
||||
</AlertDialog.Root>
|
||||
</DrawingDialogPopup>
|
||||
</Dialog.Root>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls back once, after the canvas beside it has mounted. The canvas creates its engine in
|
||||
* a layout effect inside the dialog's portal, which mounts after the sheet's own effects;
|
||||
* a sibling's passive effect runs after every layout effect, so the handle is live by then.
|
||||
*/
|
||||
const CanvasMounted = ({ onMounted }: { onMounted: () => void }) => {
|
||||
const callback = useRef(onMounted);
|
||||
useEffect(() => {
|
||||
callback.current();
|
||||
}, []);
|
||||
return null;
|
||||
};
|
||||
|
||||
/** An icon-only ghost Button named by its Tooltip, as every icon control in memos. */
|
||||
const IconAction = ({
|
||||
label,
|
||||
icon,
|
||||
size,
|
||||
shortcut,
|
||||
disabled,
|
||||
onClick,
|
||||
}: {
|
||||
label: string;
|
||||
icon: ReactElement;
|
||||
size?: "sm";
|
||||
shortcut?: string;
|
||||
disabled?: boolean;
|
||||
onClick: () => void;
|
||||
}) => (
|
||||
<Tooltip.Root>
|
||||
<Tooltip.Trigger render={<Button variant="ghost" size={size} aria-label={label} icon={icon} disabled={disabled} onClick={onClick} />} />
|
||||
<Tooltip.Popup shortcut={shortcut}>{label}</Tooltip.Popup>
|
||||
</Tooltip.Root>
|
||||
);
|
||||
|
||||
const Divider = ({ className }: { className?: string }) => (
|
||||
<span aria-hidden className={cn("mx-1 h-5 w-px shrink-0 bg-mu-line", className)} />
|
||||
);
|
||||
|
||||
export default DrawingSheet;
|
||||
@@ -0,0 +1,166 @@
|
||||
import type { CanvasHandle, Scene } from "@usememos/canvas";
|
||||
import { Canvas } from "@usememos/canvas/react";
|
||||
import { Button, Dialog, Spinner, Tooltip } from "@usememos/ui";
|
||||
import { PencilLineIcon, ScanIcon, XIcon } from "lucide-react";
|
||||
import { type ReactElement, useEffect, useEffectEvent, useRef, useState } from "react";
|
||||
import { uploadService } from "@/components/MemoEditor/edit/services/uploadService";
|
||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||
import useMediaQuery from "@/hooks/useMediaQuery";
|
||||
import { useUpdateMemo } from "@/hooks/useMemoQueries";
|
||||
import { showErrorToast } from "@/lib/toast";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { Attachment } from "@/types/proto/api/attachment_service_pb";
|
||||
import type { Memo } from "@/types/proto/api/memo_service_pb";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import { canManageAttachment } from "@/utils/user";
|
||||
import { DrawingDialogPopup, FloatingBar, FloatingRow } from "./DrawingFrame";
|
||||
import DrawingSheet from "./DrawingSheet";
|
||||
import { fetchDrawingFile, readDrawing } from "./drawing";
|
||||
import { useCanvasTheme } from "./useCanvasTheme";
|
||||
|
||||
export interface DrawingViewerProps {
|
||||
attachment: Attachment;
|
||||
/** The memo the drawing belongs to; with `canEdit`, Edit saves the drawing back to it. */
|
||||
memo: Pick<Memo, "name" | "attachments">;
|
||||
/** Whether the viewer may change the memo: its author or an admin. */
|
||||
canEdit: boolean;
|
||||
onClose: () => void;
|
||||
/** The file carries no readable scene: show it as the plain image it is. */
|
||||
onNoScene: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A drawing opened from a memo: the canvas in its read-only mode (pan, zoom, copy), with
|
||||
* Zoom to fit and, for whoever may change the memo, Edit. Edit turns the viewer
|
||||
* into the drawing sheet; Done replaces the drawing's file under the same name, stamps the
|
||||
* memo's update time and returns to viewing the new version. An edit of someone else's
|
||||
* drawing is added to the memo beside it.
|
||||
*/
|
||||
const DrawingViewer = ({ attachment: initialAttachment, memo, canEdit, onClose, onNoScene }: DrawingViewerProps) => {
|
||||
const t = useTranslate();
|
||||
const currentUser = useCurrentUser();
|
||||
const isWide = useMediaQuery("sm");
|
||||
// Small controls on a desktop; a phone keeps the 32px ones for touch.
|
||||
const size = isWide ? "sm" : undefined;
|
||||
const { theme, fontFamily } = useCanvasTheme();
|
||||
const { mutateAsync: updateMemo } = useUpdateMemo();
|
||||
const canvasRef = useRef<CanvasHandle>(null);
|
||||
const [attachment, setAttachment] = useState(initialAttachment);
|
||||
const [scene, setScene] = useState<Scene>();
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
// An edit saved as a copy whose memo update failed: the user's own, so a retry replaces it
|
||||
// instead of uploading another.
|
||||
const unlinkedCopy = useRef<Attachment>(undefined);
|
||||
// The load runs once per attachment; it reports through the host's committed callbacks.
|
||||
const showNoScene = useEffectEvent(onNoScene);
|
||||
const failToOpen = useEffectEvent(() => {
|
||||
showErrorToast(t("editor.drawing.open-failed"));
|
||||
onClose();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
fetchDrawingFile(initialAttachment, controller.signal)
|
||||
.then(readDrawing)
|
||||
.then((content) => {
|
||||
if (controller.signal.aborted) return;
|
||||
if (content.scene) setScene(content.scene);
|
||||
else showNoScene();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (controller.signal.aborted) return;
|
||||
console.error(error);
|
||||
failToOpen();
|
||||
});
|
||||
return () => controller.abort();
|
||||
}, [initialAttachment]);
|
||||
|
||||
// Done in the sheet: the edit replaces the drawing's file. A drawing someone else uploaded
|
||||
// stays, since only they or an admin may replace or remove it, and the edit joins the memo
|
||||
// beside it.
|
||||
const saveEdit = async (file: File) => {
|
||||
const replace = canManageAttachment(attachment, currentUser);
|
||||
const replaces = replace ? attachment.name : unlinkedCopy.current?.name;
|
||||
const saved = await uploadService.uploadFile({ file, previewUrl: "", replaces });
|
||||
if (replace) {
|
||||
await updateMemo({ update: { name: memo.name }, updateMask: ["update_time"] });
|
||||
} else {
|
||||
unlinkedCopy.current = saved;
|
||||
// Whole attachments, not names: the optimistic update shows them until the memo reloads.
|
||||
const attachments = memo.attachments.flatMap((item) => (item.name === attachment.name ? [item, saved] : [item]));
|
||||
await updateMemo({ update: { name: memo.name, attachments }, updateMask: ["attachments"] });
|
||||
unlinkedCopy.current = undefined;
|
||||
}
|
||||
const content = await readDrawing(file);
|
||||
setAttachment(saved);
|
||||
if (content.scene) setScene(content.scene);
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
if (isEditing && scene) {
|
||||
return <DrawingSheet mode="edit" initialScene={scene} onDone={saveEdit} onClose={() => setIsEditing(false)} />;
|
||||
}
|
||||
|
||||
const title = t("editor.insert-menu.drawing");
|
||||
return (
|
||||
<Dialog.Root
|
||||
open
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose();
|
||||
}}
|
||||
>
|
||||
<DrawingDialogPopup label={title}>
|
||||
<div className="relative h-full w-full" style={{ background: theme.paper }}>
|
||||
{scene ? (
|
||||
// No autofocus: a viewer should not draw a focus ring around the page as it opens.
|
||||
<Canvas
|
||||
ref={canvasRef}
|
||||
className="absolute inset-0"
|
||||
readOnly
|
||||
ariaLabel={title}
|
||||
initialScene={scene}
|
||||
theme={theme}
|
||||
fontFamily={fontFamily}
|
||||
/>
|
||||
) : (
|
||||
<div className="absolute inset-0 flex items-center justify-center">
|
||||
<Spinner label={t("editor.blocks.loading")} />
|
||||
</div>
|
||||
)}
|
||||
<FloatingRow edge="top">
|
||||
{/* The caption matches the bar's button text: 13px beside small controls, 14px on a phone.
|
||||
Not a Dialog.Title, whose heading type is 16px; the popup's aria-label names the dialog. */}
|
||||
<FloatingBar className={isWide ? "pr-2" : "pr-3"}>
|
||||
<IconAction size={size} label={t("common.close")} icon={<XIcon />} onClick={onClose} />
|
||||
<span className={cn("truncate text-mu-ink", isWide ? "mu-label-sm" : "mu-label")}>{title}</span>
|
||||
</FloatingBar>
|
||||
<FloatingBar className={isWide ? undefined : "gap-3"}>
|
||||
<IconAction
|
||||
size={size}
|
||||
label={t("editor.drawing.zoom-to-fit")}
|
||||
icon={<ScanIcon />}
|
||||
onClick={() => canvasRef.current?.zoomToFit()}
|
||||
/>
|
||||
{canEdit && (
|
||||
// Flat inside the bar: the bar is the one raised surface.
|
||||
<Button variant="ghost" size={size} icon={<PencilLineIcon />} disabled={!scene} onClick={() => setIsEditing(true)}>
|
||||
{t("common.edit")}
|
||||
</Button>
|
||||
)}
|
||||
</FloatingBar>
|
||||
</FloatingRow>
|
||||
</div>
|
||||
</DrawingDialogPopup>
|
||||
</Dialog.Root>
|
||||
);
|
||||
};
|
||||
|
||||
/** An icon-only ghost Button named by its Tooltip. */
|
||||
const IconAction = ({ label, icon, size, onClick }: { label: string; icon: ReactElement; size?: "sm"; onClick: () => void }) => (
|
||||
<Tooltip.Root>
|
||||
<Tooltip.Trigger render={<Button variant="ghost" size={size} aria-label={label} icon={icon} onClick={onClick} />} />
|
||||
<Tooltip.Popup>{label}</Tooltip.Popup>
|
||||
</Tooltip.Root>
|
||||
);
|
||||
|
||||
export default DrawingViewer;
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { Scene } from "@usememos/canvas";
|
||||
import type { Attachment } from "@/types/proto/api/attachment_service_pb";
|
||||
import { fetchAttachmentFile } from "@/utils/attachment";
|
||||
|
||||
/**
|
||||
* A drawing is a PNG attachment with its editable scene embedded. The name is a hint
|
||||
* (`drawing-YYYYMMDD-HHMMSS.canvas.png`); the scene chunk inside the file is the truth.
|
||||
*/
|
||||
export const DRAWING_FILENAME_SUFFIX = ".canvas.png";
|
||||
|
||||
export const isDrawingFilename = (filename: string): boolean => filename.toLowerCase().endsWith(DRAWING_FILENAME_SUFFIX);
|
||||
|
||||
/** What "Edit drawing" opens: the scene read from the file, or, without one, the file as a background picture. */
|
||||
export type DrawingContent = { scene: Scene; background?: undefined } | { scene?: undefined; background: Blob };
|
||||
|
||||
/**
|
||||
* Downloads the original file of a saved drawing. Never the thumbnail: that is a
|
||||
* re-encoded JPEG without the scene.
|
||||
*/
|
||||
export const fetchDrawingFile = async (attachment: Attachment, signal?: AbortSignal): Promise<Blob> =>
|
||||
(await fetchAttachmentFile(attachment, signal)).blob();
|
||||
|
||||
/** Reads the scene out of a drawing file. The canvas package loads only when a drawing is opened. */
|
||||
export const readDrawing = async (file: Blob): Promise<DrawingContent> => {
|
||||
const { readScenePng } = await import("@usememos/canvas");
|
||||
const { scene } = await readScenePng(file);
|
||||
return scene ? { scene } : { background: file };
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { lazy } from "react";
|
||||
|
||||
export type { DrawingSheetProps } from "./DrawingSheet";
|
||||
export type { DrawingViewerProps } from "./DrawingViewer";
|
||||
export { type DrawingContent, fetchDrawingFile, isDrawingFilename, readDrawing } from "./drawing";
|
||||
export { DRAWING_PAPER } from "./useCanvasTheme";
|
||||
|
||||
/** The sheet and the canvas engine load on the first drawing, not with the editor. */
|
||||
export const DrawingSheet = lazy(() => import("./DrawingSheet"));
|
||||
|
||||
/** The read-only viewer a drawing opens in from a memo; loads with the canvas engine on first use. */
|
||||
export const DrawingViewer = lazy(() => import("./DrawingViewer"));
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { CanvasTheme } from "@usememos/canvas";
|
||||
import { useState } from "react";
|
||||
|
||||
/**
|
||||
* Every drawing is a sheet of the same paper, whatever memos' theme: it reads the same on a
|
||||
* light or a dark card, and anywhere its PNG goes. The paper is stored in the drawing, so a
|
||||
* drawing made before keeps the paper it was made with.
|
||||
*/
|
||||
export const DRAWING_PAPER = "#fbfaf7";
|
||||
|
||||
/** Dark ink for the light paper: the default pen and the palette's first color. */
|
||||
export const DRAWING_INK = "#1a1a1a";
|
||||
|
||||
/** The light theme's accent, since selection and handles are drawn on the light paper. */
|
||||
const DRAWING_ACCENT = "oklch(0.5 0.13 255)";
|
||||
|
||||
/** Seven hues that read on the paper; the palette's first color is the ink. */
|
||||
export const DRAWING_HUES = [
|
||||
{ key: "gray", value: "#868e96" },
|
||||
{ key: "red", value: "#e03131" },
|
||||
{ key: "orange", value: "#f08c00" },
|
||||
{ key: "green", value: "#2f9e44" },
|
||||
{ key: "teal", value: "#0c8599" },
|
||||
{ key: "blue", value: "#1971c2" },
|
||||
{ key: "violet", value: "#7048e8" },
|
||||
] as const;
|
||||
|
||||
const DRAWING_THEME: CanvasTheme = {
|
||||
paper: DRAWING_PAPER,
|
||||
text: DRAWING_INK,
|
||||
selection: DRAWING_ACCENT,
|
||||
handle: DRAWING_ACCENT,
|
||||
palette: [DRAWING_INK, ...DRAWING_HUES.map((hue) => hue.value)],
|
||||
};
|
||||
|
||||
/**
|
||||
* The canvas theme: the fixed paper and ink, with text in memos' sans-serif stack as the
|
||||
* browser resolved it. The sheet's own bars still follow memos' theme around the paper.
|
||||
*/
|
||||
export const useCanvasTheme = () => {
|
||||
const [fontFamily] = useState(() => getComputedStyle(document.documentElement).getPropertyValue("--mu-font-sans").trim());
|
||||
return { theme: DRAWING_THEME, ink: DRAWING_INK, fontFamily };
|
||||
};
|
||||
@@ -230,7 +230,7 @@ const MemoDetailSidebar = ({
|
||||
<span className="min-w-0 flex-1 truncate text-start">{t("common.share")}</span>
|
||||
<ChevronDownIcon className="mu-icon-sm shrink-0 opacity-55" />
|
||||
</Menu.Trigger>
|
||||
<Menu.Popup align="start" className="w-48">
|
||||
<Menu.Popup align="start">
|
||||
<Menu.Item onClick={handleCopyLink} icon={<LinkIcon />}>
|
||||
{t("memo.copy-link")}
|
||||
</Menu.Item>
|
||||
|
||||
@@ -53,6 +53,10 @@ Formatting is the editor's own: its toolbar appears over selected text, the slas
|
||||
|
||||
`useMemoSave` validates the draft, uploads local files, and hands the save to `memoService.save` with the operations it runs: the server's current copy (fetched into the detail cache to diff against), `useUpdateMemo` and `useCreateMemo`. Hosts that close after saving (edit, comment) hold a brief "Saved" confirmation before the session resets; the in-place composer resets at once. Uploads that landed before a failed save stay on the draft as attachments so a retry does not upload them again.
|
||||
|
||||
### Drawings
|
||||
|
||||
A drawing is a PNG attachment made with [`@usememos/canvas`](https://github.com/usememos/canvas) (pinned to an exact version: it uses CalVer, so a version number does not signal breaking changes). The editable scene sits inside the file in a `zTXt` chunk named `memos-canvas`, and the name ends in `.canvas.png`. Everywhere outside the editor it is a plain image. The + menu's "Drawing" and the attachment row's "Edit drawing" open `components/DrawingSheet`, loaded on first use. It is a dialog that sits 24px inside the window from `md` up and fills the screen below that, with its controls floating on the paper (`DrawingFrame`). The package draws and edits the scene; the controls, strings, paper (`DRAWING_PAPER`, the same in every theme) and discard prompt are memos'. In a memo, a drawing opens in `DrawingViewer`, the same dialog with the canvas read-only, whose Edit saves in place. `useDrawing` owns the session: Done joins the draft through the same `LocalFile` path as a picked image, so the memo's save uploads it. "Edit drawing" reads the original file, never the thumbnail. Done on a file still in the draft swaps it in place. Done on a saved drawing keeps the attachment in the draft and queues the edit as a `LocalFile` with `replaces` set: the row shows the edit, and the save uploads it with `UploadAttachmentSpec.replace_attachment`, so the attachment keeps its name and place (`mergeUploadedAttachments`) while the server swaps the file and drops its thumbnail. Removing the pending row drops the edit. A saved drawing someone else uploaded stays, since only they or an admin may replace or remove it; its edit joins the draft as a new attachment. A file with the suffix but no readable scene opens as the background of a new drawing. The server must store `image/png` uploads unchanged, which `server/fileserver/drawing_png_test.go` checks.
|
||||
|
||||
### Suggestions
|
||||
|
||||
Hosts of a new top-level memo pass `useMemoSuggestions()` into `suggestions`; edits and comments show none. `EditorSuggestions` hides until the draft has text, drops suggestions already satisfied or accepted, and shows at most three. Acceptance history lives in the store so Undo does not immediately resuggest, and clears with the draft.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { DrawingSheet } from "@/components/DrawingSheet";
|
||||
import { useAuth } from "@/contexts/AuthContext";
|
||||
import { useInstance } from "@/contexts/InstanceContext";
|
||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||
@@ -20,6 +21,7 @@ import {
|
||||
useAudioRecorder,
|
||||
useAutoSave,
|
||||
useBlobUrls,
|
||||
useDrawing,
|
||||
useFocusMode,
|
||||
useInlineImageUpload,
|
||||
useMemoInit,
|
||||
@@ -80,6 +82,11 @@ export const EditSession: React.FC<EditSessionProps> = ({
|
||||
const { createBlobUrl } = useBlobUrls();
|
||||
const saveMediaMetadata = userGeneralSetting?.saveMediaMetadata ?? false;
|
||||
const inlineImageUpload = useInlineImageUpload(editorRef);
|
||||
const toDrawingFile = useCallback(
|
||||
(file: File) => toLocalFiles([file], { createBlobUrl, saveMediaMetadata })[0],
|
||||
[createBlobUrl, saveMediaMetadata],
|
||||
);
|
||||
const drawing = useDrawing(toDrawingFile);
|
||||
|
||||
const memoName = memo?.name;
|
||||
const showTimestamp = Boolean(memoName || (!memo && hasTimestamp));
|
||||
@@ -407,6 +414,8 @@ export const EditSession: React.FC<EditSessionProps> = ({
|
||||
onTranscribeAttachment={canTranscribe ? transcribeAttachment : undefined}
|
||||
transcribingAttachment={transcribingAttachment}
|
||||
transcriptionDisabled={isSaving || audioRecorder.isBusy || isTranscribingAudio}
|
||||
onEditDrawing={drawing.openExisting}
|
||||
openingDrawing={drawing.opening}
|
||||
/>
|
||||
{!memo && !parentMemoName && isInitialized && suggestions.length > 0 && (
|
||||
<EditorSuggestions suggestions={suggestions} controllerRef={editorRef} space={editorSpace} />
|
||||
@@ -422,9 +431,23 @@ export const EditSession: React.FC<EditSessionProps> = ({
|
||||
viewToggles={viewToggles}
|
||||
sourceMode={sourceMode}
|
||||
onInsertImages={handleInsertImages}
|
||||
onDrawingClick={drawing.openNew}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{drawing.session && (
|
||||
<Suspense fallback={null}>
|
||||
<DrawingSheet
|
||||
key={drawing.session.id}
|
||||
mode={drawing.session.mode}
|
||||
initialScene={drawing.session.scene}
|
||||
background={drawing.session.background}
|
||||
onDone={drawing.done}
|
||||
onClose={drawing.close}
|
||||
/>
|
||||
</Suspense>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ export const EditorToolbar: FC<EditorToolbarProps> = ({
|
||||
viewToggles,
|
||||
sourceMode,
|
||||
onInsertImages,
|
||||
onDrawingClick,
|
||||
}) => {
|
||||
const t = useTranslate();
|
||||
const { actions, dispatch } = useEditorContext();
|
||||
@@ -117,6 +118,7 @@ export const EditorToolbar: FC<EditorToolbarProps> = ({
|
||||
viewToggles={viewToggles}
|
||||
sourceMode={sourceMode}
|
||||
onInsertImages={onInsertImages}
|
||||
onDrawingClick={onDrawingClick}
|
||||
/>
|
||||
<AudienceMenu
|
||||
value={visibility}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
import { Button, Menu, Spinner, Tooltip } from "@usememos/ui";
|
||||
import { uniqBy } from "lodash-es";
|
||||
import { CodeXmlIcon, ImageIcon, LinkIcon, MapPinIcon, Maximize2Icon, MicIcon, PaperclipIcon, PlusIcon } from "lucide-react";
|
||||
import {
|
||||
CodeXmlIcon,
|
||||
ImageIcon,
|
||||
LinkIcon,
|
||||
MapPinIcon,
|
||||
Maximize2Icon,
|
||||
MicIcon,
|
||||
PaperclipIcon,
|
||||
PencilLineIcon,
|
||||
PlusIcon,
|
||||
} from "lucide-react";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { LinkMemoDialog, LocationDialog } from "@/components/MemoMetadata";
|
||||
import type { MapPoint } from "@/components/map/types";
|
||||
@@ -126,6 +136,9 @@ const InsertMenu = (props: InsertMenuProps) => {
|
||||
const insertItems = [
|
||||
{ key: "attachment", label: t("editor.insert-menu.add-attachment"), icon: PaperclipIcon, onClick: handleAttachmentUploadClick },
|
||||
{ key: "inline-image", label: t("editor.insert-menu.insert-image"), icon: ImageIcon, onClick: handleInlineImageUploadClick },
|
||||
...(props.onDrawingClick
|
||||
? [{ key: "drawing", label: t("editor.insert-menu.drawing"), icon: PencilLineIcon, onClick: props.onDrawingClick }]
|
||||
: []),
|
||||
{ key: "audio", label: t("editor.audio-recorder.trigger"), icon: MicIcon, onClick: props.onAudioRecorderClick },
|
||||
{ key: "link", label: t("editor.insert-menu.link-memo"), icon: LinkIcon, onClick: handleOpenLinkDialog },
|
||||
{ key: "location", label: t("editor.insert-menu.add-location"), icon: MapPinIcon, onClick: handleLocationClick },
|
||||
|
||||
@@ -13,6 +13,8 @@ export const EditorMetadata: FC<EditorMetadataProps> = ({
|
||||
onTranscribeAttachment,
|
||||
transcribingAttachment,
|
||||
transcriptionDisabled,
|
||||
onEditDrawing,
|
||||
openingDrawing,
|
||||
}) => {
|
||||
const { actions, dispatch } = useEditorContext();
|
||||
const attachments = useEditorSelector((s) => s.metadata.attachments);
|
||||
@@ -41,6 +43,8 @@ export const EditorMetadata: FC<EditorMetadataProps> = ({
|
||||
onTranscribeAttachment={onTranscribeAttachment}
|
||||
transcribingAttachment={transcribingAttachment}
|
||||
transcriptionDisabled={transcriptionDisabled}
|
||||
onEditDrawing={onEditDrawing}
|
||||
openingDrawing={openingDrawing}
|
||||
/>
|
||||
|
||||
<RelationListEditor
|
||||
|
||||
@@ -5,6 +5,7 @@ export { useAudioRecorder } from "./useAudioRecorder";
|
||||
export { useAudioWaveform } from "./useAudioWaveform";
|
||||
export { useAutoSave } from "./useAutoSave";
|
||||
export { useBlobUrls } from "./useBlobUrls";
|
||||
export { type DrawingSession, useDrawing } from "./useDrawing";
|
||||
export { pairAppleLivePhotoFiles, toLocalFiles, useFileUpload } from "./useFileUpload";
|
||||
export { useFocusMode } from "./useFocusMode";
|
||||
export { splitInlineLocalFiles, useInlineImageUpload } from "./useInlineImageUpload";
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
import type { Scene } from "@usememos/canvas";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { fetchDrawingFile, readDrawing } from "@/components/DrawingSheet";
|
||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||
import { showErrorToast } from "@/lib/toast";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import { canManageAttachment } from "@/utils/user";
|
||||
import { useEditorContext } from "../state";
|
||||
import type { DrawingSource, LocalFile } from "../types/attachment";
|
||||
|
||||
/**
|
||||
* Where the finished drawing goes: a new file in the draft, or in place of the one being
|
||||
* edited. A saved drawing the user may not replace (someone else uploaded it) stays, and
|
||||
* the edit is added as a new attachment.
|
||||
*/
|
||||
type DrawingTarget = { kind: "new" } | { kind: "local"; previewUrl: string } | { kind: "attachment"; name: string; canReplace: boolean };
|
||||
|
||||
export interface DrawingSession {
|
||||
/** A new session is a new sheet, so the canvas reads its first scene again. */
|
||||
id: number;
|
||||
mode: "new" | "edit";
|
||||
target: DrawingTarget;
|
||||
scene?: Scene;
|
||||
background?: Blob;
|
||||
}
|
||||
|
||||
/**
|
||||
* The drawing sheet's session in the editor: a new drawing from the + menu, or "Edit
|
||||
* drawing" on an attachment row. Done joins the draft through the same LocalFile path
|
||||
* as a picked image, so the memo's save uploads it. An edited drawing takes the place
|
||||
* of the one it came from: a local file is swapped in the draft; a saved attachment
|
||||
* stays, and the edit is a local file that replaces its content on save (the
|
||||
* attachment keeps its name, so links to it keep working).
|
||||
*/
|
||||
export const useDrawing = (toLocalFile: (file: File) => LocalFile) => {
|
||||
const t = useTranslate();
|
||||
const currentUser = useCurrentUser();
|
||||
const { actions, dispatch, getState } = useEditorContext();
|
||||
const [session, setSession] = useState<DrawingSession>();
|
||||
// The row whose drawing is being downloaded and read.
|
||||
const [opening, setOpening] = useState<string>();
|
||||
const request = useRef<AbortController | undefined>(undefined);
|
||||
const nextId = useRef(0);
|
||||
|
||||
useEffect(() => () => request.current?.abort(), []);
|
||||
|
||||
const openNew = useCallback(() => {
|
||||
// A drawing still downloading must not replace the new sheet when it arrives.
|
||||
request.current?.abort();
|
||||
request.current = undefined;
|
||||
setOpening(undefined);
|
||||
setSession({ id: ++nextId.current, mode: "new", target: { kind: "new" } });
|
||||
}, []);
|
||||
|
||||
const openExisting = useCallback(
|
||||
async (source: DrawingSource) => {
|
||||
if (request.current) return;
|
||||
const controller = new AbortController();
|
||||
request.current = controller;
|
||||
const sourceId = source.kind === "local" ? source.localFile.previewUrl : source.attachment.name;
|
||||
setOpening(sourceId);
|
||||
try {
|
||||
const file = source.kind === "local" ? source.localFile.file : await fetchDrawingFile(source.attachment, controller.signal);
|
||||
const content = await readDrawing(file);
|
||||
if (controller.signal.aborted) return;
|
||||
const target: DrawingTarget =
|
||||
source.kind === "local"
|
||||
? { kind: "local", previewUrl: sourceId }
|
||||
: { kind: "attachment", name: sourceId, canReplace: canManageAttachment(source.attachment, currentUser) };
|
||||
setSession(
|
||||
content.scene
|
||||
? { id: ++nextId.current, mode: "edit", target, scene: content.scene }
|
||||
: // No scene inside: draw on the picture as a new drawing and leave the original alone.
|
||||
{ id: ++nextId.current, mode: "new", target: { kind: "new" }, background: content.background },
|
||||
);
|
||||
} catch (error) {
|
||||
if (controller.signal.aborted) return;
|
||||
console.error(error);
|
||||
showErrorToast(t("editor.drawing.open-failed"));
|
||||
} finally {
|
||||
if (request.current === controller) request.current = undefined;
|
||||
if (!controller.signal.aborted) setOpening(undefined);
|
||||
}
|
||||
},
|
||||
[currentUser, t],
|
||||
);
|
||||
|
||||
const close = useCallback(() => setSession(undefined), []);
|
||||
|
||||
const done = useCallback(
|
||||
(file: File) => {
|
||||
const target = session?.target ?? { kind: "new" };
|
||||
const localFile = toLocalFile(file);
|
||||
const state = getState();
|
||||
if (target.kind === "local") {
|
||||
// A file that is itself an edit of a saved drawing stays one.
|
||||
dispatch(
|
||||
actions.setLocalFiles(
|
||||
state.localFiles.map((item) => (item.previewUrl === target.previewUrl ? { ...localFile, replaces: item.replaces } : item)),
|
||||
),
|
||||
);
|
||||
} else if (target.kind === "attachment" && target.canReplace) {
|
||||
// The saved drawing keeps its place; its edit uploads over it when the memo is saved.
|
||||
dispatch(
|
||||
actions.setLocalFiles([
|
||||
...state.localFiles.filter((item) => item.replaces !== target.name),
|
||||
{ ...localFile, replaces: target.name },
|
||||
]),
|
||||
);
|
||||
} else {
|
||||
// A new drawing, or an edit of one the user may not replace (someone else uploaded it,
|
||||
// and only they or an admin may remove it): the edit joins the memo beside it.
|
||||
dispatch(actions.addLocalFile(localFile));
|
||||
}
|
||||
setSession(undefined);
|
||||
},
|
||||
[actions, dispatch, getState, session, toLocalFile],
|
||||
);
|
||||
|
||||
return { session, opening, openNew, openExisting, close, done };
|
||||
};
|
||||
@@ -11,7 +11,7 @@ import type { Attachment } from "@/types/proto/api/attachment_service_pb";
|
||||
import type { Visibility } from "@/types/proto/api/memo_service_pb";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import { errorService, memoService, validationService } from "../services";
|
||||
import type { MemoSaveOperations } from "../services/memoService";
|
||||
import { DrawingNotSavedError, type MemoSaveOperations, mergeUploadedAttachments } from "../services/memoService";
|
||||
import { useEditorContext } from "../state";
|
||||
import { restampDefaultCreateTime } from "../utils/deriveDefaultCreateTime";
|
||||
|
||||
@@ -77,7 +77,10 @@ export function useMemoSave({
|
||||
if (moved.length === 0) return;
|
||||
dispatch(
|
||||
actions.setMetadata({
|
||||
attachments: [...current.metadata.attachments, ...moved.map((file) => uploaded.get(file.previewUrl) as Attachment)],
|
||||
attachments: mergeUploadedAttachments(
|
||||
current.metadata.attachments,
|
||||
moved.map((file) => uploaded.get(file.previewUrl) as Attachment),
|
||||
),
|
||||
}),
|
||||
);
|
||||
dispatch(actions.setLocalFiles(current.localFiles.filter((file) => !uploaded.has(file.previewUrl))));
|
||||
@@ -160,6 +163,12 @@ export function useMemoSave({
|
||||
void queryClient.invalidateQueries({ queryKey: attachmentKeys.lists() });
|
||||
void queryClient.invalidateQueries({ queryKey: userKeys.stats() });
|
||||
}
|
||||
if (error instanceof DrawingNotSavedError) {
|
||||
// The rest of the memo is saved; only the drawing waits for another save.
|
||||
console.error(error);
|
||||
showErrorToast(t("editor.drawing.saved-without-drawing"));
|
||||
return;
|
||||
}
|
||||
handleError(error, showErrorToast, {
|
||||
context: "Failed to save memo",
|
||||
fallbackMessage: errorService.getErrorMessage(error),
|
||||
|
||||
@@ -18,6 +18,17 @@ function toAttachmentReferences(attachments: Attachment[]): Attachment[] {
|
||||
return attachments.map((a) => create(AttachmentSchema, { name: a.name }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds uploaded attachments to the draft's. An upload that replaced an
|
||||
* attachment's content comes back under the same name and takes its place.
|
||||
*/
|
||||
export function mergeUploadedAttachments(attachments: Attachment[], uploaded: Attachment[]): Attachment[] {
|
||||
const byName = new Map(uploaded.map((attachment) => [attachment.name, attachment]));
|
||||
const merged = attachments.map((attachment) => byName.get(attachment.name) ?? attachment);
|
||||
const existing = new Set(attachments.map((attachment) => attachment.name));
|
||||
return [...merged, ...uploaded.filter((attachment) => !existing.has(attachment.name))];
|
||||
}
|
||||
|
||||
function buildUpdateMask(
|
||||
prevMemo: Memo,
|
||||
state: EditorState,
|
||||
@@ -84,6 +95,17 @@ function buildUpdateMask(
|
||||
return { mask, patch };
|
||||
}
|
||||
|
||||
/**
|
||||
* The memo's own changes saved, but uploading an edited drawing over its attachment
|
||||
* failed afterwards. The edit stays in the draft, so saving again retries only it.
|
||||
*/
|
||||
export class DrawingNotSavedError extends Error {
|
||||
constructor(cause: unknown) {
|
||||
super("The memo was saved, but an edited drawing was not", { cause });
|
||||
this.name = "DrawingNotSavedError";
|
||||
}
|
||||
}
|
||||
|
||||
/** The memo operations a save runs: the memo mutation hooks, so caches follow every save. */
|
||||
export interface MemoSaveOperations {
|
||||
/** The memo as the server has it now, to diff the draft against. */
|
||||
@@ -105,24 +127,45 @@ export const memoService = {
|
||||
},
|
||||
operations: MemoSaveOperations,
|
||||
): Promise<{ memoName: string; hasChanges: boolean; moved?: boolean }> {
|
||||
// 1. Upload local files first
|
||||
const newAttachments = await uploadService.uploadFiles(state.localFiles, options.onFileUploaded);
|
||||
const allAttachments = [...state.metadata.attachments, ...newAttachments];
|
||||
// 1. Upload new files first. Edits of saved drawings (`replaces`) upload over
|
||||
// their attachment, which is visible at once, so they wait until the memo
|
||||
// itself is saved: a refused save then leaves every saved drawing as it was.
|
||||
const additions = state.localFiles.filter((file) => !file.replaces);
|
||||
const replacements = state.localFiles.filter((file) => file.replaces);
|
||||
const newAttachments = await uploadService.uploadFiles(additions, options.onFileUploaded);
|
||||
let allAttachments = mergeUploadedAttachments(state.metadata.attachments, newAttachments);
|
||||
|
||||
// 2. Update existing memo
|
||||
if (options.memoName) {
|
||||
const prevMemo = await operations.getMemo(options.memoName);
|
||||
const { mask, patch } = buildUpdateMask(prevMemo, state, allAttachments);
|
||||
|
||||
if (mask.size === 0) {
|
||||
if (mask.size === 0 && replacements.length === 0) {
|
||||
return { memoName: prevMemo.name, hasChanges: false };
|
||||
}
|
||||
|
||||
const memo = await operations.updateMemo(patch, Array.from(mask));
|
||||
let memo = mask.size > 0 ? await operations.updateMemo(patch, Array.from(mask)) : prevMemo;
|
||||
if (replacements.length > 0) {
|
||||
try {
|
||||
await uploadService.uploadFiles(replacements, options.onFileUploaded);
|
||||
} catch (error) {
|
||||
// With nothing else to save, the save simply failed; otherwise say what did land.
|
||||
throw mask.size > 0 ? new DrawingNotSavedError(error) : error;
|
||||
}
|
||||
// A new drawing is an edit of the memo: stamp it, keeping a custom time the draft sets.
|
||||
// The update returns the memo with its replaced files, which refreshes every cached copy;
|
||||
// it sends no attachment list, so one added elsewhere meanwhile stays.
|
||||
memo = await operations.updateMemo({ name: memo.name, updateTime: patch.updateTime }, ["update_time"]);
|
||||
}
|
||||
return { memoName: memo.name, hasChanges: true, moved: mask.has("space") };
|
||||
}
|
||||
|
||||
// 3. Create new memo or comment
|
||||
// 3. Create new memo or comment. Its attachments are not visible to anyone
|
||||
// until it exists, so replacements land before it is created; a failure then
|
||||
// never leaves a created memo behind for a retry to duplicate.
|
||||
if (replacements.length > 0) {
|
||||
allAttachments = mergeUploadedAttachments(allAttachments, await uploadService.uploadFiles(replacements, options.onFileUploaded));
|
||||
}
|
||||
const memoData = create(MemoSchema, {
|
||||
content: state.content,
|
||||
visibility: state.metadata.visibility,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Code, ConnectError } from "@connectrpc/connect";
|
||||
import { aiServiceClient } from "@/connect";
|
||||
import { TranscribeRequestSchema, TranscriptionAudioSchema } from "@/types/proto/api/ai_service_pb";
|
||||
import type { Attachment } from "@/types/proto/api/attachment_service_pb";
|
||||
import { getAttachmentUrl } from "@/utils/attachment";
|
||||
import { fetchAttachmentFile } from "@/utils/attachment";
|
||||
|
||||
// Mirrors maxTranscriptionAudioSizeBytes in server/api/ai_service.go so an
|
||||
// oversized attachment is rejected before it is downloaded, with the server's error.
|
||||
@@ -35,8 +35,7 @@ const transcribe = async (content: Uint8Array, filename: string, contentType: st
|
||||
export const transcriptionService = {
|
||||
async transcribeAttachment(attachment: Attachment, signal?: AbortSignal): Promise<string> {
|
||||
checkAudioSize(Number(attachment.size));
|
||||
const response = await fetch(getAttachmentUrl(attachment), { signal, credentials: "same-origin" });
|
||||
if (!response.ok) throw new Error(`Failed to download audio (${response.status})`);
|
||||
const response = await fetchAttachmentFile(attachment, signal);
|
||||
checkAudioSize(Number(response.headers.get("Content-Length")));
|
||||
const content = new Uint8Array(await response.arrayBuffer());
|
||||
checkAudioSize(content.byteLength);
|
||||
|
||||
@@ -21,6 +21,7 @@ export const uploadService = {
|
||||
mediaMetadata,
|
||||
}),
|
||||
totalSize: BigInt(file.size),
|
||||
replaceAttachment: localFile.replaces ?? "",
|
||||
});
|
||||
// The spec call carries no data so that retrying it after a lost response
|
||||
// can at worst orphan an upload, never create a duplicate attachment.
|
||||
|
||||
@@ -33,6 +33,11 @@ export interface LocalFile {
|
||||
* from a source with nothing to extract). The promise never rejects.
|
||||
*/
|
||||
readonly mediaMetadata?: Promise<MediaMetadata | undefined>;
|
||||
/**
|
||||
* The saved attachment this file replaces the content of (an edited drawing).
|
||||
* The attachment keeps its name and place; the file uploads over it on save.
|
||||
*/
|
||||
readonly replaces?: string;
|
||||
}
|
||||
|
||||
const AUDIO_RECORDING_FILENAME_RE = /^(?:voice-(?:recording|note)|audio-recording)-(\d{8})-(\d{4,6})/i;
|
||||
@@ -203,3 +208,6 @@ export function separateMediaAndDocs(items: AttachmentItem[]): { media: Attachme
|
||||
|
||||
return { media, docs };
|
||||
}
|
||||
|
||||
/** A drawing "Edit drawing" opens: a file still in the draft, or a saved attachment. */
|
||||
export type DrawingSource = { kind: "local"; localFile: LocalFile } | { kind: "attachment"; attachment: Attachment };
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { Attachment } from "@/types/proto/api/attachment_service_pb";
|
||||
import type { Location, Memo, Visibility } from "@/types/proto/api/memo_service_pb";
|
||||
import type { EditorFileOrigin } from "../extensions";
|
||||
import type { AudioRecorderStatus } from "../hooks/useAudioRecorder";
|
||||
import type { LocalFile } from "./attachment";
|
||||
import type { DrawingSource, LocalFile } from "./attachment";
|
||||
|
||||
/** What MemoEditor hands an editing session: its subject, the host's defaults, and where the draft lives. */
|
||||
export interface EditSessionProps {
|
||||
@@ -88,6 +88,8 @@ export interface EditorToolbarProps {
|
||||
viewToggles?: EditorViewToggles;
|
||||
sourceMode: EditorSourceModeToggle;
|
||||
onInsertImages: (files: File[]) => void;
|
||||
/** Opens the drawing sheet for a new drawing. */
|
||||
onDrawingClick?: () => void;
|
||||
}
|
||||
|
||||
export interface EditorMetadataProps {
|
||||
@@ -98,6 +100,10 @@ export interface EditorMetadataProps {
|
||||
uploadingLocalFileURLs: ReadonlySet<string>;
|
||||
onInsertAttachments: (attachments: Attachment[]) => void;
|
||||
onInsertLocalFiles: (localFiles: LocalFile[]) => void;
|
||||
/** Opens a drawing attachment in the drawing sheet. */
|
||||
onEditDrawing?: (source: DrawingSource) => void;
|
||||
/** The attachment row whose drawing is being opened. */
|
||||
openingDrawing?: string;
|
||||
}
|
||||
|
||||
export interface AudioRecorderPanelProps {
|
||||
@@ -132,6 +138,7 @@ export interface InsertMenuProps {
|
||||
viewToggles?: EditorViewToggles;
|
||||
sourceMode: EditorSourceModeToggle;
|
||||
onInsertImages: (files: File[]) => void;
|
||||
onDrawingClick?: () => void;
|
||||
}
|
||||
|
||||
export interface AudienceMenuProps {
|
||||
|
||||
@@ -7,11 +7,13 @@ import {
|
||||
FileTextIcon,
|
||||
ImagePlusIcon,
|
||||
PauseIcon,
|
||||
PencilLineIcon,
|
||||
PlayIcon,
|
||||
XIcon,
|
||||
} from "lucide-react";
|
||||
import { type FC, type MouseEvent, useMemo, useRef, useState } from "react";
|
||||
import type { AttachmentItem, LocalFile } from "@/components/MemoEditor/edit/types/attachment";
|
||||
import { isDrawingFilename } from "@/components/DrawingSheet";
|
||||
import type { AttachmentItem, DrawingSource, LocalFile } from "@/components/MemoEditor/edit/types/attachment";
|
||||
import { getAudioRecordingTimeLabel, toAttachmentItems } from "@/components/MemoEditor/edit/types/attachment";
|
||||
import MetadataSection, {
|
||||
METADATA_ROW_BOX_CLASSES,
|
||||
@@ -22,6 +24,7 @@ import MetadataSection, {
|
||||
MetadataRowDetail,
|
||||
} from "@/components/MemoMetadata/MetadataSection";
|
||||
import PreviewImageDialog from "@/components/PreviewImageDialog";
|
||||
import useMediaQuery from "@/hooks/useMediaQuery";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { Attachment } from "@/types/proto/api/attachment_service_pb";
|
||||
import { formatFileSize, getFileTypeLabel } from "@/utils/format";
|
||||
@@ -47,22 +50,53 @@ interface AttachmentListEditorProps {
|
||||
onInsertLocalFiles?: (localFiles: LocalFile[]) => void;
|
||||
placementActionsDisabled?: boolean;
|
||||
uploadingLocalFileURLs?: ReadonlySet<string>;
|
||||
/** Opens a drawing (a `.canvas.png` image) in the drawing sheet. */
|
||||
onEditDrawing?: (source: DrawingSource) => void;
|
||||
/** The row whose drawing is being opened. */
|
||||
openingDrawing?: string;
|
||||
}
|
||||
|
||||
interface RowAction {
|
||||
label: string;
|
||||
onClick: () => void;
|
||||
disabled?: boolean;
|
||||
busy?: boolean;
|
||||
}
|
||||
|
||||
/** Trailing controls of an attachment row: quiet 24px squares that show once the row is engaged. */
|
||||
const AttachmentItemActions: FC<{
|
||||
transcriptionAction?: { label: string; onClick: () => void; disabled: boolean; busy: boolean };
|
||||
drawingAction?: RowAction;
|
||||
placementAction?: { label: string; onClick: () => void; disabled?: boolean };
|
||||
onRemove?: () => void;
|
||||
onMoveUp?: () => void;
|
||||
onMoveDown?: () => void;
|
||||
canMoveUp?: boolean;
|
||||
canMoveDown?: boolean;
|
||||
}> = ({ transcriptionAction, placementAction, onRemove, onMoveUp, onMoveDown, canMoveUp = true, canMoveDown = true }) => {
|
||||
}> = ({ transcriptionAction, drawingAction, placementAction, onRemove, onMoveUp, onMoveDown, canMoveUp = true, canMoveDown = true }) => {
|
||||
const t = useTranslate();
|
||||
// A drawing row already carries Insert image; on narrow rows its edit action keeps only the glyph.
|
||||
const isWide = useMediaQuery("md");
|
||||
const stopPropagation = (event: MouseEvent) => {
|
||||
event.stopPropagation();
|
||||
};
|
||||
const drawingButton = drawingAction && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size={isWide ? "sm" : "xs"}
|
||||
disabled={drawingAction.disabled}
|
||||
loading={drawingAction.busy}
|
||||
loadingLabel={drawingAction.label}
|
||||
onClick={(event) => {
|
||||
stopPropagation(event);
|
||||
drawingAction.onClick();
|
||||
}}
|
||||
aria-label={isWide ? undefined : drawingAction.label}
|
||||
icon={<PencilLineIcon />}
|
||||
>
|
||||
{isWide ? drawingAction.label : undefined}
|
||||
</Button>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={METADATA_ROW_CONTROLS_CLASSES}>
|
||||
@@ -82,6 +116,15 @@ const AttachmentItemActions: FC<{
|
||||
{transcriptionAction.label}
|
||||
</Button>
|
||||
)}
|
||||
{drawingButton &&
|
||||
(isWide ? (
|
||||
drawingButton
|
||||
) : (
|
||||
<Tooltip.Root>
|
||||
<Tooltip.Trigger render={drawingButton} />
|
||||
<Tooltip.Popup>{drawingAction?.label}</Tooltip.Popup>
|
||||
</Tooltip.Root>
|
||||
))}
|
||||
{placementAction && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -163,6 +206,7 @@ const AttachmentItemActions: FC<{
|
||||
|
||||
const AttachmentItemCard: FC<{
|
||||
transcriptionAction?: { label: string; onClick: () => void; disabled: boolean; busy: boolean };
|
||||
drawingAction?: RowAction;
|
||||
item: AttachmentItem;
|
||||
onPreview?: () => void;
|
||||
onRemove?: () => void;
|
||||
@@ -183,6 +227,7 @@ const AttachmentItemCard: FC<{
|
||||
isUploadingInline,
|
||||
placementAction,
|
||||
transcriptionAction,
|
||||
drawingAction,
|
||||
}) => {
|
||||
const t = useTranslate();
|
||||
const { category, filename, thumbnailUrl, mimeType, size, sourceUrl, isVoiceNote, audioMeta } = item;
|
||||
@@ -281,6 +326,7 @@ const AttachmentItemCard: FC<{
|
||||
|
||||
<AttachmentItemActions
|
||||
transcriptionAction={transcriptionAction}
|
||||
drawingAction={drawingAction}
|
||||
placementAction={placementAction}
|
||||
onRemove={onRemove}
|
||||
onMoveUp={onMoveUp}
|
||||
@@ -306,22 +352,28 @@ const AttachmentListEditor: FC<AttachmentListEditorProps> = ({
|
||||
onTranscribeAttachment,
|
||||
transcribingAttachment,
|
||||
transcriptionDisabled = false,
|
||||
onEditDrawing,
|
||||
openingDrawing,
|
||||
}) => {
|
||||
const t = useTranslate();
|
||||
const [previewState, setPreviewState] = useState<{ open: boolean; initialIndex: number }>({ open: false, initialIndex: 0 });
|
||||
const attachmentsByName = useMemo(() => new Map(attachments.map((attachment) => [attachment.name, attachment])), [attachments]);
|
||||
const allItems = toAttachmentItems(attachments, localFiles);
|
||||
const isInlineItem = (item: AttachmentItem) =>
|
||||
// Saved drawings with an edit waiting to upload over them: the edit's row stands in for them.
|
||||
const replacedAttachmentNames = new Set(localFiles.flatMap((localFile) => (localFile.replaces ? [localFile.replaces] : [])));
|
||||
const isHiddenItem = (item: AttachmentItem) =>
|
||||
!item.isLocal &&
|
||||
collectMembers(attachmentsByName, item.memberIds).some((attachment) => {
|
||||
if (replacedAttachmentNames.has(attachment.name)) return true;
|
||||
const uid = extractAttachmentUIDFromName(attachment.name);
|
||||
return uid ? inlineAttachmentUIDs.has(uid) : false;
|
||||
});
|
||||
// A managed image already has its placement represented in Markdown. Keep
|
||||
// the attachment bound to the memo, but do not repeat its logical media group
|
||||
// in the attachment section. Removing the Markdown reference makes it
|
||||
// visible here again on the next render.
|
||||
const items = allItems.filter((item) => !isInlineItem(item));
|
||||
// visible here again on the next render. A replaced drawing stays bound too,
|
||||
// and shows again if its pending edit is removed.
|
||||
const items = allItems.filter((item) => !isHiddenItem(item));
|
||||
const allAttachmentItems = allItems.filter((item) => !item.isLocal);
|
||||
const attachmentItems = items.filter((item) => !item.isLocal);
|
||||
const localItems = items.filter((item) => item.isLocal);
|
||||
@@ -387,7 +439,7 @@ const AttachmentListEditor: FC<AttachmentListEditorProps> = ({
|
||||
[reorderedItems[itemIndex], reorderedItems[targetIndex]] = [reorderedItems[targetIndex], reorderedItems[itemIndex]];
|
||||
|
||||
let visibleIndex = 0;
|
||||
const mergedItems = allAttachmentItems.map((item) => (isInlineItem(item) ? item : reorderedItems[visibleIndex++]!));
|
||||
const mergedItems = allAttachmentItems.map((item) => (isHiddenItem(item) ? item : reorderedItems[visibleIndex++]!));
|
||||
onAttachmentsChange(mergedItems.flatMap((item) => collectMembers(attachmentsByName, item.memberIds)));
|
||||
};
|
||||
|
||||
@@ -456,8 +508,30 @@ const AttachmentListEditor: FC<AttachmentListEditorProps> = ({
|
||||
busy: isTranscribing,
|
||||
}
|
||||
: undefined;
|
||||
// A drawing opens from the original file: a saved one is downloaded, so it must live on this server.
|
||||
const drawingSource: DrawingSource | undefined =
|
||||
item.category !== "image" || !isDrawingFilename(item.filename)
|
||||
? undefined
|
||||
: item.isLocal
|
||||
? itemLocalFiles[0] && { kind: "local", localFile: itemLocalFiles[0] }
|
||||
: itemAttachments[0] && !itemAttachments[0].externalLink
|
||||
? { kind: "attachment", attachment: itemAttachments[0] }
|
||||
: undefined;
|
||||
const isOpeningDrawing = openingDrawing !== undefined && item.memberIds.includes(openingDrawing);
|
||||
const drawingAction =
|
||||
drawingSource && onEditDrawing
|
||||
? {
|
||||
label: t("editor.drawing.edit"),
|
||||
onClick: () => onEditDrawing(drawingSource),
|
||||
disabled: placementActionsDisabled || Boolean(openingDrawing),
|
||||
busy: isOpeningDrawing,
|
||||
}
|
||||
: undefined;
|
||||
// Inserting uploads at once, so a pending edit of a saved drawing would overwrite it before the memo is saved.
|
||||
const isPendingReplacement = itemLocalFiles.some((localFile) => localFile.replaces);
|
||||
const canInsert =
|
||||
(item.category === "image" || item.category === "motion") && (item.isLocal || itemAttachments.some(canInlineAttachment));
|
||||
(item.category === "image" || item.category === "motion") &&
|
||||
(item.isLocal ? !isPendingReplacement : itemAttachments.some(canInlineAttachment));
|
||||
const placementAction = canInsert
|
||||
? {
|
||||
label: t("editor.insert-menu.insert-image"),
|
||||
@@ -474,6 +548,7 @@ const AttachmentListEditor: FC<AttachmentListEditorProps> = ({
|
||||
isUploadingInline={isUploadingInline}
|
||||
placementAction={placementAction}
|
||||
transcriptionAction={transcriptionAction}
|
||||
drawingAction={drawingAction}
|
||||
onPreview={
|
||||
item.category === "image" || item.category === "video" || item.category === "motion"
|
||||
? () => handlePreviewItem(item)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { buttonClasses } from "@usememos/ui";
|
||||
import { DownloadIcon, ExternalLinkIcon, FileIcon, PlayIcon } from "lucide-react";
|
||||
import type { KeyboardEvent, PropsWithChildren } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { Suspense, useMemo, useState } from "react";
|
||||
import { DRAWING_PAPER, DrawingViewer, isDrawingFilename } from "@/components/DrawingSheet";
|
||||
import MotionPhotoPreview from "@/components/MotionPhotoPreview";
|
||||
import VideoPoster from "@/components/VideoPoster";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { Attachment } from "@/types/proto/api/attachment_service_pb";
|
||||
import type { Memo } from "@/types/proto/api/memo_service_pb";
|
||||
import { getAttachmentUrl, isImage } from "@/utils/attachment";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import type { AttachmentVisualItem, PreviewMediaItem } from "@/utils/media-item";
|
||||
@@ -25,6 +27,10 @@ import { getAttachmentMetadata } from "./attachmentHelpers";
|
||||
import {
|
||||
COLLAGE_VIDEO_PLAY_BADGE_CLASS,
|
||||
COVER_MEDIA_CLASS,
|
||||
DRAWING_SHEET_CELL_MEDIA_CLASS,
|
||||
DRAWING_SHEET_MEDIA_CLASS,
|
||||
DRAWING_SHEET_SINGLE_CLASS,
|
||||
DRAWING_SHEET_TILE_CLASS,
|
||||
MEDIA_HOVER_GRADIENT_CLASS,
|
||||
MEDIA_HOVER_SURFACE_CLASS,
|
||||
NATURAL_MEDIA_CLASS,
|
||||
@@ -42,15 +48,15 @@ const getMotionPreviewProps = (item: VisualItem) => ({
|
||||
presentationTimestampUs: item.previewItem.kind === "motion" ? item.previewItem.presentationTimestampUs : undefined,
|
||||
});
|
||||
|
||||
const VisualTile = ({
|
||||
className,
|
||||
onPreview,
|
||||
overlayLabel,
|
||||
children,
|
||||
}: PropsWithChildren<{ className?: string; onPreview?: () => void; overlayLabel?: string }>) => {
|
||||
// A div, not a <button>: tiles hold block media. When it opens the viewer it takes the button
|
||||
// role and keys, so keyboard users reach it too; its name comes from the media's alt text.
|
||||
const interactive = onPreview
|
||||
/** A drawing (a `.canvas.png` image) shows as a sheet of paper instead of a framed photo. */
|
||||
const isDrawing = (item: VisualItem) => item.kind === "image" && isDrawingFilename(item.filename);
|
||||
|
||||
/**
|
||||
* A tile is a div, not a <button>: it holds block media. When it opens the viewer it takes the
|
||||
* button role and keys, so keyboard users reach it too; its name comes from the media's alt text.
|
||||
*/
|
||||
const tileInteraction = (onPreview?: () => void) =>
|
||||
onPreview
|
||||
? {
|
||||
role: "button",
|
||||
tabIndex: 0,
|
||||
@@ -63,8 +69,14 @@ const VisualTile = ({
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
return (
|
||||
<div className={cn(VISUAL_TILE_BUTTON_CLASS, className)} {...interactive}>
|
||||
|
||||
const VisualTile = ({
|
||||
className,
|
||||
onPreview,
|
||||
overlayLabel,
|
||||
children,
|
||||
}: PropsWithChildren<{ className?: string; onPreview?: () => void; overlayLabel?: string }>) => (
|
||||
<div className={cn(VISUAL_TILE_BUTTON_CLASS, className)} {...tileInteraction(onPreview)}>
|
||||
<div className={MEDIA_HOVER_SURFACE_CLASS}>
|
||||
{children}
|
||||
<div className={MEDIA_HOVER_GRADIENT_CLASS} aria-hidden />
|
||||
@@ -72,6 +84,57 @@ const VisualTile = ({
|
||||
{overlayLabel && <div className={OVERFLOW_TILE_OVERLAY_CLASS}>{overlayLabel}</div>}
|
||||
</div>
|
||||
);
|
||||
|
||||
/**
|
||||
* The paper a drawing was made on. An export is opaque with the paper filling it, so its corner
|
||||
* pixel is paper; a drawing made before the paper was fixed keeps its own. Undefined when the
|
||||
* image can't be read.
|
||||
*/
|
||||
const readPaperColor = (img: HTMLImageElement): string | undefined => {
|
||||
try {
|
||||
const context = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
|
||||
if (!context) return undefined;
|
||||
context.drawImage(img, 0, 0, 1, 1, 0, 0, 1, 1);
|
||||
const [r, g, b] = context.getImageData(0, 0, 1, 1).data;
|
||||
return `rgb(${r} ${g} ${b})`;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A drawing as a sheet of paper. The sheet extends the drawing's own paper beyond its edges, so
|
||||
* it can be any size. The image is the original file at 2x: exports carry 2 pixels per drawn
|
||||
* pixel, so it shows at the size it was drawn and keeps strokes and text sharp.
|
||||
*/
|
||||
const DrawingTile = ({
|
||||
item,
|
||||
className,
|
||||
mediaClassName,
|
||||
onPreview,
|
||||
overlayLabel,
|
||||
}: {
|
||||
item: VisualItem;
|
||||
className: string;
|
||||
mediaClassName: string;
|
||||
onPreview?: () => void;
|
||||
overlayLabel?: string;
|
||||
}) => {
|
||||
const [paper, setPaper] = useState(DRAWING_PAPER);
|
||||
return (
|
||||
<div className={cn(DRAWING_SHEET_TILE_CLASS, className)} style={{ background: paper }} {...tileInteraction(onPreview)}>
|
||||
<img
|
||||
src={item.sourceUrl}
|
||||
srcSet={`${item.sourceUrl} 2x`}
|
||||
alt={item.filename}
|
||||
className={mediaClassName}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
onLoad={(event) => setPaper(readPaperColor(event.currentTarget) ?? DRAWING_PAPER)}
|
||||
/>
|
||||
{overlayLabel && <div className={OVERFLOW_TILE_OVERLAY_CLASS}>{overlayLabel}</div>}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const VideoPlayBadge = ({ className, children }: PropsWithChildren<{ className?: string }>) => (
|
||||
@@ -97,6 +160,17 @@ const CollageVisualItem = ({
|
||||
onPreview?: () => void;
|
||||
}) => {
|
||||
const motionPreviewProps = item.kind === "motion" ? getMotionPreviewProps(item) : undefined;
|
||||
if (isDrawing(item)) {
|
||||
return (
|
||||
<DrawingTile
|
||||
item={item}
|
||||
className={cn("block h-full w-full", className)}
|
||||
mediaClassName={DRAWING_SHEET_CELL_MEDIA_CLASS}
|
||||
onPreview={onPreview}
|
||||
overlayLabel={overlayLabel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<VisualTile className={cn("block h-full w-full", className)} onPreview={onPreview} overlayLabel={overlayLabel}>
|
||||
{item.kind === "video" ? (
|
||||
@@ -128,6 +202,12 @@ const CollageVisualItem = ({
|
||||
const SingleVisualItem = ({ item, onPreview }: { item: VisualItem; onPreview?: () => void }) => {
|
||||
const motionPreviewProps = item.kind === "motion" ? getMotionPreviewProps(item) : undefined;
|
||||
|
||||
if (isDrawing(item)) {
|
||||
return (
|
||||
<DrawingTile item={item} className={DRAWING_SHEET_SINGLE_CLASS} mediaClassName={DRAWING_SHEET_MEDIA_CLASS} onPreview={onPreview} />
|
||||
);
|
||||
}
|
||||
|
||||
if (item.kind === "image") {
|
||||
return (
|
||||
<VisualTile className="inline-block max-w-full" onPreview={onPreview}>
|
||||
@@ -169,12 +249,15 @@ const SingleVisualItem = ({ item, onPreview }: { item: VisualItem; onPreview?: (
|
||||
interface AttachmentGalleryProps {
|
||||
visual: Attachment[];
|
||||
onImagePreview?: (items: PreviewMediaItem[], index: number) => void;
|
||||
/** Opens drawings in the drawing viewer instead of the image viewer, with Edit when `canEdit`. */
|
||||
drawings?: { memo: Pick<Memo, "name" | "attachments">; canEdit: boolean };
|
||||
}
|
||||
|
||||
/** The memo's images, motion photos and videos as the bare gallery, flush with the content. */
|
||||
export const AttachmentGallery = ({ visual, onImagePreview }: AttachmentGalleryProps) => {
|
||||
export const AttachmentGallery = ({ visual, onImagePreview, drawings }: AttachmentGalleryProps) => {
|
||||
const visualItems = useMemo(() => buildAttachmentVisualItems(visual), [visual]);
|
||||
const layout = resolveVisualGalleryLayout(visualItems);
|
||||
const [openDrawing, setOpenDrawing] = useState<VisualItem>();
|
||||
|
||||
if (!layout) {
|
||||
return null;
|
||||
@@ -186,10 +269,32 @@ export const AttachmentGallery = ({ visual, onImagePreview }: AttachmentGalleryP
|
||||
onImagePreview?.(previewItems, index >= 0 ? index : 0);
|
||||
};
|
||||
|
||||
// A drawing opens as a drawing: in the read-only canvas, not the image viewer.
|
||||
const openItem = (item: VisualItem) => {
|
||||
if (drawings && isDrawing(item) && item.attachments[0]) setOpenDrawing(item);
|
||||
else handlePreview(item.id);
|
||||
};
|
||||
|
||||
const drawingViewer = drawings && openDrawing?.attachments[0] && (
|
||||
<Suspense fallback={null}>
|
||||
<DrawingViewer
|
||||
attachment={openDrawing.attachments[0]}
|
||||
memo={drawings.memo}
|
||||
canEdit={drawings.canEdit}
|
||||
onClose={() => setOpenDrawing(undefined)}
|
||||
onNoScene={() => {
|
||||
setOpenDrawing(undefined);
|
||||
handlePreview(openDrawing.id);
|
||||
}}
|
||||
/>
|
||||
</Suspense>
|
||||
);
|
||||
|
||||
if (layout.mode === "single") {
|
||||
return (
|
||||
<div className="w-full">
|
||||
<SingleVisualItem item={layout.item} onPreview={() => handlePreview(layout.item.id)} />
|
||||
<SingleVisualItem item={layout.item} onPreview={() => openItem(layout.item)} />
|
||||
{drawingViewer}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -197,14 +302,9 @@ export const AttachmentGallery = ({ visual, onImagePreview }: AttachmentGalleryP
|
||||
return (
|
||||
<div className={cn("w-full", layout.containerClassName)}>
|
||||
{layout.cells.map(({ item, className, overlayLabel }) => (
|
||||
<CollageVisualItem
|
||||
key={item.id}
|
||||
item={item}
|
||||
className={className}
|
||||
overlayLabel={overlayLabel}
|
||||
onPreview={() => handlePreview(item.id)}
|
||||
/>
|
||||
<CollageVisualItem key={item.id} item={item} className={className} overlayLabel={overlayLabel} onPreview={() => openItem(item)} />
|
||||
))}
|
||||
{drawingViewer}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -7,6 +7,23 @@
|
||||
export const VISUAL_TILE_BUTTON_CLASS =
|
||||
"relative block overflow-hidden rounded-mu-md border border-mu-line/70 bg-mu-well/30 p-0 text-left transition-colors mu-focus";
|
||||
|
||||
/**
|
||||
* A drawing is a sheet of paper on the card rather than a photo in a frame: no tile border or
|
||||
* well, just the package's raised edge, the same in both themes. Hover lifts it a little more
|
||||
* instead of the photo scrim and zoom.
|
||||
*/
|
||||
export const DRAWING_SHEET_TILE_CLASS =
|
||||
"relative block overflow-hidden rounded-mu-md p-0 text-left shadow-mu-raised transition-shadow hover:shadow-mu-key mu-focus";
|
||||
|
||||
/** A lone drawing: the sheet spans the column, at least 160px tall, with the drawing centered on it. */
|
||||
export const DRAWING_SHEET_SINGLE_CLASS = "flex w-full min-h-40 items-center justify-center";
|
||||
|
||||
/** The drawing on a lone sheet: at the size it was drawn, shrunk only to fit the column and 400px. */
|
||||
export const DRAWING_SHEET_MEDIA_CLASS = "block h-auto max-h-100 w-auto max-w-full";
|
||||
|
||||
/** A drawing in a collage cell fits inside it on paper; cropping it like a photo would cut strokes off. */
|
||||
export const DRAWING_SHEET_CELL_MEDIA_CLASS = "h-full w-full object-contain p-2";
|
||||
|
||||
export const MEDIA_HOVER_SURFACE_CLASS = "group/media relative h-full min-h-0 w-full overflow-hidden";
|
||||
|
||||
export const COVER_MEDIA_CLASS = "h-full w-full rounded-none object-cover transition-transform duration-300 group-hover/media:scale-[1.02]";
|
||||
|
||||
@@ -6,9 +6,11 @@ import { MemoEditor } from "@/components/MemoEditor/MemoEditor";
|
||||
import { AttachmentGallery, MemoMetadataRows } from "@/components/MemoMetadata";
|
||||
import { separateAttachments } from "@/components/MemoMetadata/Attachment/attachmentHelpers";
|
||||
import { isReferenceRelation } from "@/components/MemoMetadata/Relation/relationHelpers";
|
||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import { filterInlineManagedAttachments } from "@/utils/managed-attachment";
|
||||
import { canManageMemo } from "@/utils/user";
|
||||
import { MemoReactionListView } from "../../MemoReactionListView";
|
||||
import { useMemoHandlers } from "../hooks";
|
||||
import { useMemoViewContext } from "../MemoViewContext";
|
||||
@@ -45,6 +47,8 @@ const MemoBody: React.FC<MemoBodyProps> = ({ compact, showCreator }) => {
|
||||
const { handleMemoContentClick, handleMemoContentDoubleClick } = useMemoHandlers({ readonly, openEditor, openPreview });
|
||||
|
||||
const referencedMemos = memo.relations.filter(isReferenceRelation);
|
||||
const hasText = memo.content.trim() !== "";
|
||||
const currentUser = useCurrentUser();
|
||||
// Memoized so AttachmentListView's own useMemo chain keeps its cache across body renders.
|
||||
const attachmentOnlyItems = useMemo(
|
||||
() => filterInlineManagedAttachments(memo.content, memo.attachments),
|
||||
@@ -85,6 +89,8 @@ const MemoBody: React.FC<MemoBodyProps> = ({ compact, showCreator }) => {
|
||||
{/* Compact bounds the whole body — attachments included — behind one Show more.
|
||||
Reactions stay outside so they never hide under the fade. */}
|
||||
<ClampedSection enabled={Boolean(compact)}>
|
||||
{/* A memo of attachments alone has no text: an empty editor would still take a line and a gap. */}
|
||||
{hasText && (
|
||||
<MemoEditor
|
||||
name={memo.name}
|
||||
parentPage={parentPage}
|
||||
@@ -92,7 +98,12 @@ const MemoBody: React.FC<MemoBodyProps> = ({ compact, showCreator }) => {
|
||||
onClick={handleMemoContentClick}
|
||||
onDoubleClick={handleMemoContentDoubleClick}
|
||||
/>
|
||||
<AttachmentGallery visual={visual} onImagePreview={openPreview} />
|
||||
)}
|
||||
<AttachmentGallery
|
||||
visual={visual}
|
||||
onImagePreview={openPreview}
|
||||
drawings={{ memo, canEdit: !readonly && canManageMemo(memo, currentUser) }}
|
||||
/>
|
||||
<MemoMetadataRows
|
||||
audio={audio}
|
||||
docs={docs}
|
||||
|
||||
@@ -112,7 +112,7 @@ const MemoHeader: React.FC<MemoHeaderProps> = ({ timeDisplay = "relative", showC
|
||||
<VisibilityIcon visibility={memo.visibility} className="text-current" />
|
||||
</Popover.Trigger>
|
||||
{visibilityOption && (
|
||||
<Popover.Popup align="end" variant="list" className="w-(--mu-menu-width)">
|
||||
<Popover.Popup align="end" variant="list" className="w-56">
|
||||
<Popover.Title>{t(visibilityOption.labelKey)}</Popover.Title>
|
||||
<Popover.Description>{t(visibilityOption.descriptionKey)}</Popover.Description>
|
||||
</Popover.Popup>
|
||||
|
||||
@@ -40,7 +40,7 @@ interface PreferenceSubmenuProps {
|
||||
|
||||
/** A row that opens its choices beside the panel, like a submenu, and applies one on select. */
|
||||
const PreferenceSubmenu = ({ icon: Icon, label, value, options, onChange, className }: PreferenceSubmenuProps) => (
|
||||
<Menu.Root modal={false} size="sm">
|
||||
<Menu.Root modal={false}>
|
||||
<Menu.Trigger openOnHover className={SCOPE_PANEL_ROW_CLASSES}>
|
||||
<ScopePanelRowIcon icon={Icon} />
|
||||
<span className="shrink-0">{label}</span>
|
||||
@@ -49,13 +49,14 @@ const PreferenceSubmenu = ({ icon: Icon, label, value, options, onChange, classN
|
||||
</span>
|
||||
<ChevronRightIcon aria-hidden="true" className={cn(SCOPE_PANEL_ICON_CLASSES, "rtl:rotate-180")} />
|
||||
</Menu.Trigger>
|
||||
{/* Like a nested submenu: when neither side has room (narrow screens), drop below the row instead of overflowing. */}
|
||||
{/* Like a nested submenu: its first row lines up with this one, and its rows match the panel's (`mu-compact`).
|
||||
When neither side has room (narrow screens), it drops below the row instead of overflowing. */}
|
||||
<Menu.Popup
|
||||
side="inline-end"
|
||||
align="start"
|
||||
collisionAvoidance={{ fallbackAxisSide: "end" }}
|
||||
positionMethod="fixed"
|
||||
className={className}
|
||||
className={cn("mu-compact", className)}
|
||||
>
|
||||
<Menu.RadioGroup value={value} onValueChange={onChange}>
|
||||
{options.map((option) => (
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
"link-memo": "مذكرة الارتباط",
|
||||
"image-upload-stopped": "توقف تحميل الصورة {{completed}}/{{total}}",
|
||||
"insert-image": "إدراج الصورة",
|
||||
"drawing": "رسم",
|
||||
"keep-as-attachments": "الاحتفاظ بها كمرفقات",
|
||||
"retry-image-upload": "إعادة المحاولة",
|
||||
"uploading-inline-image": "جارٍ التحميل إلى المحتوى",
|
||||
@@ -181,6 +182,46 @@
|
||||
"add-attachment": "إضافة مرفق",
|
||||
"image-upload-failed": "تعذر رفع بعض الصور. أعد المحاولة أو احتفظ بالملفات المرفوعة كمرفقات."
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "رسم جديد",
|
||||
"edit": "تعديل الرسم",
|
||||
"tools": "الأدوات",
|
||||
"tool-select": "تحديد",
|
||||
"tool-pen": "قلم",
|
||||
"tool-eraser": "ممحاة",
|
||||
"tool-rectangle": "مستطيل",
|
||||
"tool-ellipse": "قطع ناقص",
|
||||
"tool-arrow": "سهم",
|
||||
"tool-text": "نص",
|
||||
"style": "اللون والسُمك",
|
||||
"color": "اللون",
|
||||
"width": "السُمك",
|
||||
"width-thin": "رفيع",
|
||||
"width-medium": "متوسط",
|
||||
"width-thick": "سميك",
|
||||
"color-ink": "حبر",
|
||||
"color-gray": "رمادي",
|
||||
"color-red": "أحمر",
|
||||
"color-orange": "برتقالي",
|
||||
"color-green": "أخضر",
|
||||
"color-teal": "أزرق مخضر",
|
||||
"color-blue": "أزرق",
|
||||
"color-violet": "بنفسجي",
|
||||
"undo": "تراجع",
|
||||
"redo": "إعادة",
|
||||
"zoom-to-fit": "ملاءمة للنافذة",
|
||||
"done": "تم",
|
||||
"discard-title": "تجاهل هذا الرسم؟",
|
||||
"discard-description": "لم تتم إضافته إلى المذكرة بعد.",
|
||||
"discard-edit-title": "تجاهل التغييرات؟",
|
||||
"discard-edit-description": "سيبقى الرسم كما كان قبل فتحه.",
|
||||
"keep-drawing": "متابعة الرسم",
|
||||
"discard": "تجاهل",
|
||||
"open-failed": "تعذر فتح الرسم. حاول مرة أخرى.",
|
||||
"export-failed": "تعذر حفظ الرسم. حاول مرة أخرى.",
|
||||
"image-failed": "تعذرت إضافة الصورة إلى الرسم.",
|
||||
"saved-without-drawing": "تم حفظ المذكرة، لكن لم يتم حفظ الرسم. احفظ مرة أخرى لإعادة المحاولة."
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "تسجيل صوتي",
|
||||
"attachment-label-with-time": "تسجيل صوتي {{time}}",
|
||||
|
||||
@@ -293,12 +293,53 @@
|
||||
"image-upload-failed": "Bəzi şəkillər yüklənə bilmədi. Yenidən cəhd edin və ya yüklənmiş faylları qoşma kimi saxlayın.",
|
||||
"image-upload-stopped": "Şəkil yükləməsi dayandırıldı {{completed}}/{{total}}",
|
||||
"insert-image": "Şəkil daxil et",
|
||||
"drawing": "Rəsm",
|
||||
"keep-as-attachments": "Qoşma kimi saxla",
|
||||
"link-memo": "Qeydə keçid əlavə et",
|
||||
"retry-image-upload": "Yenidən cəhd et",
|
||||
"uploading-inline-image": "Məzmuna yüklənir",
|
||||
"uploading-images": "Şəkillər yüklənir {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Yeni rəsm",
|
||||
"edit": "Rəsmi redaktə et",
|
||||
"tools": "Alətlər",
|
||||
"tool-select": "Seç",
|
||||
"tool-pen": "Qələm",
|
||||
"tool-eraser": "Pozan",
|
||||
"tool-rectangle": "Düzbucaqlı",
|
||||
"tool-ellipse": "Ellips",
|
||||
"tool-arrow": "Ox",
|
||||
"tool-text": "Mətn",
|
||||
"style": "Rəng və qalınlıq",
|
||||
"color": "Rəng",
|
||||
"width": "Qalınlıq",
|
||||
"width-thin": "Nazik",
|
||||
"width-medium": "Orta",
|
||||
"width-thick": "Qalın",
|
||||
"color-ink": "Mürəkkəb",
|
||||
"color-gray": "Boz",
|
||||
"color-red": "Qırmızı",
|
||||
"color-orange": "Narıncı",
|
||||
"color-green": "Yaşıl",
|
||||
"color-teal": "Firuzəyi",
|
||||
"color-blue": "Mavi",
|
||||
"color-violet": "Bənövşəyi",
|
||||
"undo": "Geri al",
|
||||
"redo": "Təkrarla",
|
||||
"zoom-to-fit": "Pəncərəyə sığdır",
|
||||
"done": "Hazır",
|
||||
"discard-title": "Bu rəsm silinsin?",
|
||||
"discard-description": "Hələ qeydə əlavə edilməyib.",
|
||||
"discard-edit-title": "Dəyişikliklər silinsin?",
|
||||
"discard-edit-description": "Rəsm açılmazdan əvvəlki kimi qalacaq.",
|
||||
"keep-drawing": "Çəkməyə davam et",
|
||||
"discard": "Sil",
|
||||
"open-failed": "Rəsmi açmaq mümkün olmadı. Yenidən cəhd edin.",
|
||||
"export-failed": "Rəsmi saxlamaq mümkün olmadı. Yenidən cəhd edin.",
|
||||
"image-failed": "Şəkli rəsmə əlavə etmək mümkün olmadı.",
|
||||
"saved-without-drawing": "Qeyd yadda saxlanıldı, amma rəsm saxlanılmadı. Yenidən cəhd etmək üçün təkrar yadda saxlayın."
|
||||
},
|
||||
"new-memo": "Yeni qeyd",
|
||||
"no-changes-detected": "Dəyişiklik aşkarlanmadı",
|
||||
"save": "Yadda saxla",
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Някои изображения не можаха да бъдат качени. Опитайте отново или запазете качените файлове като прикачени файлове.",
|
||||
"image-upload-stopped": "Качването на изображение спря {{completed}}/{{total}}",
|
||||
"insert-image": "Вмъкване на изображение",
|
||||
"drawing": "Рисунка",
|
||||
"keep-as-attachments": "Запазване като прикачени файлове",
|
||||
"uploading-inline-image": "Качване в съдържание",
|
||||
"uploading-images": "Качване на изображения {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Нова рисунка",
|
||||
"edit": "Редактиране на рисунката",
|
||||
"tools": "Инструменти",
|
||||
"tool-select": "Избор",
|
||||
"tool-pen": "Писалка",
|
||||
"tool-eraser": "Гума",
|
||||
"tool-rectangle": "Правоъгълник",
|
||||
"tool-ellipse": "Елипса",
|
||||
"tool-arrow": "Стрелка",
|
||||
"tool-text": "Текст",
|
||||
"style": "Цвят и дебелина",
|
||||
"color": "Цвят",
|
||||
"width": "Дебелина",
|
||||
"width-thin": "Тънка",
|
||||
"width-medium": "Средна",
|
||||
"width-thick": "Дебела",
|
||||
"color-ink": "Мастило",
|
||||
"color-gray": "Сиво",
|
||||
"color-red": "Червено",
|
||||
"color-orange": "Оранжево",
|
||||
"color-green": "Зелено",
|
||||
"color-teal": "Синьозелено",
|
||||
"color-blue": "Синьо",
|
||||
"color-violet": "Виолетово",
|
||||
"undo": "Отмяна",
|
||||
"redo": "Повторение",
|
||||
"zoom-to-fit": "Побиране в прозореца",
|
||||
"done": "Готово",
|
||||
"discard-title": "Отхвърляне на тази рисунка?",
|
||||
"discard-description": "Все още не е добавена към бележката.",
|
||||
"discard-edit-title": "Отхвърляне на промените?",
|
||||
"discard-edit-description": "Рисунката остава такава, каквато беше, преди да я отворите.",
|
||||
"keep-drawing": "Продължаване на рисуването",
|
||||
"discard": "Отхвърляне",
|
||||
"open-failed": "Рисунката не можа да бъде отворена. Опитайте отново.",
|
||||
"export-failed": "Рисунката не можа да бъде запазена. Опитайте отново.",
|
||||
"image-failed": "Изображението не можа да бъде добавено към рисунката.",
|
||||
"saved-without-drawing": "Бележката е запазена, но рисунката не е. Запазете отново, за да опитате пак."
|
||||
},
|
||||
"no-changes-detected": "Не са открити промени",
|
||||
"save": "Запазване",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "No s'han pogut carregar algunes imatges. Torneu-ho a intentar o conserveu els fitxers carregats com a fitxers adjunts.",
|
||||
"image-upload-stopped": "La càrrega d'imatges s'ha aturat {{completed}}/{{total}}",
|
||||
"insert-image": "Insereix una imatge",
|
||||
"drawing": "Dibuix",
|
||||
"keep-as-attachments": "Desa com a fitxers adjunts",
|
||||
"uploading-inline-image": "S'està pujant al contingut",
|
||||
"uploading-images": "S'estan pujant imatges {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Dibuix nou",
|
||||
"edit": "Edita el dibuix",
|
||||
"tools": "Eines",
|
||||
"tool-select": "Selecciona",
|
||||
"tool-pen": "Llapis",
|
||||
"tool-eraser": "Goma",
|
||||
"tool-rectangle": "Rectangle",
|
||||
"tool-ellipse": "El·lipse",
|
||||
"tool-arrow": "Fletxa",
|
||||
"tool-text": "Text",
|
||||
"style": "Color i gruix",
|
||||
"color": "Color",
|
||||
"width": "Gruix",
|
||||
"width-thin": "Fi",
|
||||
"width-medium": "Mitjà",
|
||||
"width-thick": "Gruixut",
|
||||
"color-ink": "Tinta",
|
||||
"color-gray": "Gris",
|
||||
"color-red": "Vermell",
|
||||
"color-orange": "Taronja",
|
||||
"color-green": "Verd",
|
||||
"color-teal": "Verd blavós",
|
||||
"color-blue": "Blau",
|
||||
"color-violet": "Violeta",
|
||||
"undo": "Desfés",
|
||||
"redo": "Refés",
|
||||
"zoom-to-fit": "Ajusta a la pantalla",
|
||||
"done": "Fet",
|
||||
"discard-title": "Voleu descartar aquest dibuix?",
|
||||
"discard-description": "Encara no s'ha afegit a la nota.",
|
||||
"discard-edit-title": "Voleu descartar els canvis?",
|
||||
"discard-edit-description": "El dibuix es queda com estava abans d'obrir-lo.",
|
||||
"keep-drawing": "Continua dibuixant",
|
||||
"discard": "Descarta",
|
||||
"open-failed": "No s'ha pogut obrir el dibuix. Torneu-ho a intentar.",
|
||||
"export-failed": "No s'ha pogut desar el dibuix. Torneu-ho a intentar.",
|
||||
"image-failed": "No s'ha pogut afegir la imatge al dibuix.",
|
||||
"saved-without-drawing": "La nota s'ha desat, però el dibuix no. Torneu a desar per tornar-ho a intentar."
|
||||
},
|
||||
"no-changes-detected": "No s'han detectat canvis",
|
||||
"save": "Guarda",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Některé obrázky se nepodařilo nahrát. Zkuste to znovu nebo nahrané soubory ponechte jako přílohy.",
|
||||
"image-upload-stopped": "Nahrávání obrázku zastaveno {{completed}}/{{total}}",
|
||||
"insert-image": "Vložit obrázek",
|
||||
"drawing": "Kresba",
|
||||
"keep-as-attachments": "Ponechat jako přílohy",
|
||||
"uploading-inline-image": "Nahrávání do obsahu",
|
||||
"uploading-images": "Nahrávání obrázků {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Nová kresba",
|
||||
"edit": "Upravit kresbu",
|
||||
"tools": "Nástroje",
|
||||
"tool-select": "Výběr",
|
||||
"tool-pen": "Pero",
|
||||
"tool-eraser": "Guma",
|
||||
"tool-rectangle": "Obdélník",
|
||||
"tool-ellipse": "Elipsa",
|
||||
"tool-arrow": "Šipka",
|
||||
"tool-text": "Text",
|
||||
"style": "Barva a tloušťka",
|
||||
"color": "Barva",
|
||||
"width": "Tloušťka",
|
||||
"width-thin": "Tenká",
|
||||
"width-medium": "Střední",
|
||||
"width-thick": "Silná",
|
||||
"color-ink": "Inkoust",
|
||||
"color-gray": "Šedá",
|
||||
"color-red": "Červená",
|
||||
"color-orange": "Oranžová",
|
||||
"color-green": "Zelená",
|
||||
"color-teal": "Modrozelená",
|
||||
"color-blue": "Modrá",
|
||||
"color-violet": "Fialová",
|
||||
"undo": "Zpět",
|
||||
"redo": "Znovu",
|
||||
"zoom-to-fit": "Přizpůsobit oknu",
|
||||
"done": "Hotovo",
|
||||
"discard-title": "Zahodit tuto kresbu?",
|
||||
"discard-description": "Zatím nebyla přidána do poznámky.",
|
||||
"discard-edit-title": "Zahodit změny?",
|
||||
"discard-edit-description": "Kresba zůstane taková, jaká byla před otevřením.",
|
||||
"keep-drawing": "Pokračovat v kreslení",
|
||||
"discard": "Zahodit",
|
||||
"open-failed": "Kresbu se nepodařilo otevřít. Zkuste to znovu.",
|
||||
"export-failed": "Kresbu se nepodařilo uložit. Zkuste to znovu.",
|
||||
"image-failed": "Obrázek se nepodařilo přidat do kresby.",
|
||||
"saved-without-drawing": "Poznámka je uložena, ale kresba ne. Pro nový pokus uložte znovu."
|
||||
},
|
||||
"no-changes-detected": "Nebyly zjištěny žádné změny",
|
||||
"save": "Uložit",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Nogle billeder kunne ikke uploades. Prøv igen, eller behold de uploadede filer som vedhæftede filer.",
|
||||
"image-upload-stopped": "Billedupload stoppet {{completed}}/{{total}}",
|
||||
"insert-image": "Indsæt billede",
|
||||
"drawing": "Tegning",
|
||||
"keep-as-attachments": "Behold som vedhæftede filer",
|
||||
"uploading-inline-image": "Uploader til indhold",
|
||||
"uploading-images": "Uploader billeder {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Ny tegning",
|
||||
"edit": "Rediger tegning",
|
||||
"tools": "Værktøjer",
|
||||
"tool-select": "Vælg",
|
||||
"tool-pen": "Pen",
|
||||
"tool-eraser": "Viskelæder",
|
||||
"tool-rectangle": "Rektangel",
|
||||
"tool-ellipse": "Ellipse",
|
||||
"tool-arrow": "Pil",
|
||||
"tool-text": "Tekst",
|
||||
"style": "Farve og tykkelse",
|
||||
"color": "Farve",
|
||||
"width": "Tykkelse",
|
||||
"width-thin": "Tynd",
|
||||
"width-medium": "Mellem",
|
||||
"width-thick": "Tyk",
|
||||
"color-ink": "Blæk",
|
||||
"color-gray": "Grå",
|
||||
"color-red": "Rød",
|
||||
"color-orange": "Orange",
|
||||
"color-green": "Grøn",
|
||||
"color-teal": "Blågrøn",
|
||||
"color-blue": "Blå",
|
||||
"color-violet": "Violet",
|
||||
"undo": "Fortryd",
|
||||
"redo": "Gentag",
|
||||
"zoom-to-fit": "Tilpas til vindue",
|
||||
"done": "Færdig",
|
||||
"discard-title": "Kassér denne tegning?",
|
||||
"discard-description": "Den er endnu ikke føjet til notatet.",
|
||||
"discard-edit-title": "Kassér dine ændringer?",
|
||||
"discard-edit-description": "Tegningen forbliver, som den var, før du åbnede den.",
|
||||
"keep-drawing": "Fortsæt med at tegne",
|
||||
"discard": "Kassér",
|
||||
"open-failed": "Tegningen kunne ikke åbnes. Prøv igen.",
|
||||
"export-failed": "Tegningen kunne ikke gemmes. Prøv igen.",
|
||||
"image-failed": "Billedet kunne ikke føjes til tegningen.",
|
||||
"saved-without-drawing": "Notatet er gemt, men det er tegningen ikke. Gem igen for at prøve en gang til."
|
||||
},
|
||||
"no-changes-detected": "Ingen ændringer registreret",
|
||||
"save": "Spare",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Einige Bilder konnten nicht hochgeladen werden. Bitte versuchen Sie es erneut oder behalten Sie die hochgeladenen Dateien als Anhänge bei.",
|
||||
"image-upload-stopped": "Bild-Upload gestoppt {{completed}}/{{total}}",
|
||||
"insert-image": "Bild einfügen",
|
||||
"drawing": "Zeichnung",
|
||||
"keep-as-attachments": "Als Anhänge beibehalten",
|
||||
"uploading-inline-image": "Inhalt wird hochgeladen",
|
||||
"uploading-images": "Bilder werden hochgeladen {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Neue Zeichnung",
|
||||
"edit": "Zeichnung bearbeiten",
|
||||
"tools": "Werkzeuge",
|
||||
"tool-select": "Auswählen",
|
||||
"tool-pen": "Stift",
|
||||
"tool-eraser": "Radierer",
|
||||
"tool-rectangle": "Rechteck",
|
||||
"tool-ellipse": "Ellipse",
|
||||
"tool-arrow": "Pfeil",
|
||||
"tool-text": "Text",
|
||||
"style": "Farbe und Stärke",
|
||||
"color": "Farbe",
|
||||
"width": "Stärke",
|
||||
"width-thin": "Dünn",
|
||||
"width-medium": "Mittel",
|
||||
"width-thick": "Dick",
|
||||
"color-ink": "Tinte",
|
||||
"color-gray": "Grau",
|
||||
"color-red": "Rot",
|
||||
"color-orange": "Orange",
|
||||
"color-green": "Grün",
|
||||
"color-teal": "Türkis",
|
||||
"color-blue": "Blau",
|
||||
"color-violet": "Violett",
|
||||
"undo": "Rückgängig",
|
||||
"redo": "Wiederholen",
|
||||
"zoom-to-fit": "Einpassen",
|
||||
"done": "Fertig",
|
||||
"discard-title": "Diese Zeichnung verwerfen?",
|
||||
"discard-description": "Sie wurde der Notiz noch nicht hinzugefügt.",
|
||||
"discard-edit-title": "Änderungen verwerfen?",
|
||||
"discard-edit-description": "Die Zeichnung bleibt so, wie sie vor dem Öffnen war.",
|
||||
"keep-drawing": "Weiterzeichnen",
|
||||
"discard": "Verwerfen",
|
||||
"open-failed": "Die Zeichnung konnte nicht geöffnet werden. Bitte versuchen Sie es erneut.",
|
||||
"export-failed": "Die Zeichnung konnte nicht gespeichert werden. Bitte versuchen Sie es erneut.",
|
||||
"image-failed": "Das Bild konnte der Zeichnung nicht hinzugefügt werden.",
|
||||
"saved-without-drawing": "Die Notiz ist gespeichert, die Zeichnung jedoch nicht. Speichern Sie erneut, um es noch einmal zu versuchen."
|
||||
},
|
||||
"no-changes-detected": "Keine Änderungen erkannt",
|
||||
"save": "Speichern",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Δεν ήταν δυνατή η μεταφόρτωση ορισμένων εικόνων. Δοκιμάστε ξανά ή διατηρήστε τα μεταφορτωμένα αρχεία ως συνημμένα.",
|
||||
"image-upload-stopped": "Η μεταφόρτωση εικόνας διακόπηκε {{completed}}/{{total}}",
|
||||
"insert-image": "Εισαγωγή εικόνας",
|
||||
"drawing": "Σχέδιο",
|
||||
"keep-as-attachments": "Διατήρηση ως συνημμένα",
|
||||
"uploading-inline-image": "Μεταφόρτωση σε περιεχόμενο",
|
||||
"uploading-images": "Μεταφόρτωση εικόνων {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Νέο σχέδιο",
|
||||
"edit": "Επεξεργασία σχεδίου",
|
||||
"tools": "Εργαλεία",
|
||||
"tool-select": "Επιλογή",
|
||||
"tool-pen": "Στυλό",
|
||||
"tool-eraser": "Γόμα",
|
||||
"tool-rectangle": "Ορθογώνιο",
|
||||
"tool-ellipse": "Έλλειψη",
|
||||
"tool-arrow": "Βέλος",
|
||||
"tool-text": "Κείμενο",
|
||||
"style": "Χρώμα και πάχος",
|
||||
"color": "Χρώμα",
|
||||
"width": "Πάχος",
|
||||
"width-thin": "Λεπτό",
|
||||
"width-medium": "Μεσαίο",
|
||||
"width-thick": "Παχύ",
|
||||
"color-ink": "Μελάνι",
|
||||
"color-gray": "Γκρι",
|
||||
"color-red": "Κόκκινο",
|
||||
"color-orange": "Πορτοκαλί",
|
||||
"color-green": "Πράσινο",
|
||||
"color-teal": "Γαλαζοπράσινο",
|
||||
"color-blue": "Μπλε",
|
||||
"color-violet": "Βιολετί",
|
||||
"undo": "Αναίρεση",
|
||||
"redo": "Επανάληψη",
|
||||
"zoom-to-fit": "Προσαρμογή στο παράθυρο",
|
||||
"done": "Τέλος",
|
||||
"discard-title": "Απόρριψη αυτού του σχεδίου;",
|
||||
"discard-description": "Δεν έχει προστεθεί ακόμη στο σημείωμα.",
|
||||
"discard-edit-title": "Απόρριψη των αλλαγών;",
|
||||
"discard-edit-description": "Το σχέδιο θα παραμείνει όπως ήταν πριν το ανοίξετε.",
|
||||
"keep-drawing": "Συνέχεια σχεδίασης",
|
||||
"discard": "Απόρριψη",
|
||||
"open-failed": "Δεν ήταν δυνατό το άνοιγμα του σχεδίου. Δοκιμάστε ξανά.",
|
||||
"export-failed": "Δεν ήταν δυνατή η αποθήκευση του σχεδίου. Δοκιμάστε ξανά.",
|
||||
"image-failed": "Δεν ήταν δυνατή η προσθήκη της εικόνας στο σχέδιο.",
|
||||
"saved-without-drawing": "Το σημείωμα αποθηκεύτηκε, αλλά το σχέδιο όχι. Αποθηκεύστε ξανά για νέα προσπάθεια."
|
||||
},
|
||||
"no-changes-detected": "Δεν εντοπίστηκαν αλλαγές",
|
||||
"save": "Εκτός",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -174,11 +174,52 @@
|
||||
"image-upload-failed": "Some images could not be uploaded. Retry or keep the uploaded files as attachments.",
|
||||
"image-upload-stopped": "Image upload stopped {{completed}}/{{total}}",
|
||||
"insert-image": "Insert image",
|
||||
"drawing": "Drawing",
|
||||
"keep-as-attachments": "Keep as attachments",
|
||||
"retry-image-upload": "Retry",
|
||||
"uploading-inline-image": "Uploading to content",
|
||||
"uploading-images": "Uploading images {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "New drawing",
|
||||
"edit": "Edit drawing",
|
||||
"tools": "Tools",
|
||||
"tool-select": "Select",
|
||||
"tool-pen": "Pen",
|
||||
"tool-eraser": "Eraser",
|
||||
"tool-rectangle": "Rectangle",
|
||||
"tool-ellipse": "Ellipse",
|
||||
"tool-arrow": "Arrow",
|
||||
"tool-text": "Text",
|
||||
"style": "Colour and width",
|
||||
"color": "Colour",
|
||||
"width": "Width",
|
||||
"width-thin": "Thin",
|
||||
"width-medium": "Medium",
|
||||
"width-thick": "Thick",
|
||||
"color-ink": "Ink",
|
||||
"color-gray": "Grey",
|
||||
"color-red": "Red",
|
||||
"color-orange": "Orange",
|
||||
"color-green": "Green",
|
||||
"color-teal": "Teal",
|
||||
"color-blue": "Blue",
|
||||
"color-violet": "Violet",
|
||||
"undo": "Undo",
|
||||
"redo": "Redo",
|
||||
"zoom-to-fit": "Zoom to fit",
|
||||
"done": "Done",
|
||||
"discard-title": "Discard this drawing?",
|
||||
"discard-description": "It hasn't been added to the memo yet.",
|
||||
"discard-edit-title": "Discard your changes?",
|
||||
"discard-edit-description": "The drawing stays as it was before you opened it.",
|
||||
"keep-drawing": "Keep drawing",
|
||||
"discard": "Discard",
|
||||
"open-failed": "Couldn't open the drawing. Try again.",
|
||||
"export-failed": "Couldn't save the drawing. Try again.",
|
||||
"image-failed": "Couldn't add the image to the drawing.",
|
||||
"saved-without-drawing": "The memo is saved, but the drawing isn't. Save again to retry."
|
||||
},
|
||||
"no-changes-detected": "No changes detected",
|
||||
"save": "Save",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -293,12 +293,53 @@
|
||||
"image-upload-failed": "Some images could not be uploaded. Retry or keep the uploaded files as attachments.",
|
||||
"image-upload-stopped": "Image upload stopped {{completed}}/{{total}}",
|
||||
"insert-image": "Insert image",
|
||||
"drawing": "Drawing",
|
||||
"keep-as-attachments": "Keep as attachments",
|
||||
"link-memo": "Link memo",
|
||||
"retry-image-upload": "Retry",
|
||||
"uploading-inline-image": "Uploading to content",
|
||||
"uploading-images": "Uploading images {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "New drawing",
|
||||
"edit": "Edit drawing",
|
||||
"tools": "Tools",
|
||||
"tool-select": "Select",
|
||||
"tool-pen": "Pen",
|
||||
"tool-eraser": "Eraser",
|
||||
"tool-rectangle": "Rectangle",
|
||||
"tool-ellipse": "Ellipse",
|
||||
"tool-arrow": "Arrow",
|
||||
"tool-text": "Text",
|
||||
"style": "Color and width",
|
||||
"color": "Color",
|
||||
"width": "Width",
|
||||
"width-thin": "Thin",
|
||||
"width-medium": "Medium",
|
||||
"width-thick": "Thick",
|
||||
"color-ink": "Ink",
|
||||
"color-gray": "Gray",
|
||||
"color-red": "Red",
|
||||
"color-orange": "Orange",
|
||||
"color-green": "Green",
|
||||
"color-teal": "Teal",
|
||||
"color-blue": "Blue",
|
||||
"color-violet": "Violet",
|
||||
"undo": "Undo",
|
||||
"redo": "Redo",
|
||||
"zoom-to-fit": "Zoom to fit",
|
||||
"done": "Done",
|
||||
"discard-title": "Discard this drawing?",
|
||||
"discard-description": "It hasn't been added to the memo yet.",
|
||||
"discard-edit-title": "Discard your changes?",
|
||||
"discard-edit-description": "The drawing stays as it was before you opened it.",
|
||||
"keep-drawing": "Keep drawing",
|
||||
"discard": "Discard",
|
||||
"open-failed": "Couldn't open the drawing. Try again.",
|
||||
"export-failed": "Couldn't save the drawing. Try again.",
|
||||
"image-failed": "Couldn't add the image to the drawing.",
|
||||
"saved-without-drawing": "The memo is saved, but the drawing isn't. Save again to retry."
|
||||
},
|
||||
"new-memo": "New memo",
|
||||
"no-changes-detected": "No changes detected",
|
||||
"save": "Save",
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "No se pudieron cargar algunas imágenes. Inténtalo de nuevo o guarda los archivos cargados como adjuntos.",
|
||||
"image-upload-stopped": "Se detuvo la carga de la imagen {{completed}}/{{total}}",
|
||||
"insert-image": "Insertar imagen",
|
||||
"drawing": "Dibujo",
|
||||
"keep-as-attachments": "Guardar como adjuntos",
|
||||
"uploading-inline-image": "Cargando contenido",
|
||||
"uploading-images": "Cargando imágenes {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Nuevo dibujo",
|
||||
"edit": "Editar dibujo",
|
||||
"tools": "Herramientas",
|
||||
"tool-select": "Seleccionar",
|
||||
"tool-pen": "Lápiz",
|
||||
"tool-eraser": "Borrador",
|
||||
"tool-rectangle": "Rectángulo",
|
||||
"tool-ellipse": "Elipse",
|
||||
"tool-arrow": "Flecha",
|
||||
"tool-text": "Texto",
|
||||
"style": "Color y grosor",
|
||||
"color": "Color",
|
||||
"width": "Grosor",
|
||||
"width-thin": "Fino",
|
||||
"width-medium": "Medio",
|
||||
"width-thick": "Grueso",
|
||||
"color-ink": "Tinta",
|
||||
"color-gray": "Gris",
|
||||
"color-red": "Rojo",
|
||||
"color-orange": "Naranja",
|
||||
"color-green": "Verde",
|
||||
"color-teal": "Verde azulado",
|
||||
"color-blue": "Azul",
|
||||
"color-violet": "Violeta",
|
||||
"undo": "Deshacer",
|
||||
"redo": "Rehacer",
|
||||
"zoom-to-fit": "Ajustar a la pantalla",
|
||||
"done": "Listo",
|
||||
"discard-title": "¿Descartar este dibujo?",
|
||||
"discard-description": "Todavía no se ha añadido al memo.",
|
||||
"discard-edit-title": "¿Descartar los cambios?",
|
||||
"discard-edit-description": "El dibujo se quedará como estaba antes de abrirlo.",
|
||||
"keep-drawing": "Seguir dibujando",
|
||||
"discard": "Descartar",
|
||||
"open-failed": "No se pudo abrir el dibujo. Inténtalo de nuevo.",
|
||||
"export-failed": "No se pudo guardar el dibujo. Inténtalo de nuevo.",
|
||||
"image-failed": "No se pudo añadir la imagen al dibujo.",
|
||||
"saved-without-drawing": "El memo se ha guardado, pero el dibujo no. Guarda de nuevo para reintentarlo."
|
||||
},
|
||||
"no-changes-detected": "No se detectaron cambios",
|
||||
"save": "Guardar",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Mõnda pilti ei õnnestunud üles laadida. Proovige uuesti või hoidke üleslaaditud failid manusena.",
|
||||
"image-upload-stopped": "Pildi üleslaadimine peatatud {{completed}}/{{total}}",
|
||||
"insert-image": "Lisa pilt",
|
||||
"drawing": "Joonistus",
|
||||
"keep-as-attachments": "Säilita manusena",
|
||||
"uploading-inline-image": "Üleslaadimine sisusse",
|
||||
"uploading-images": "Piltide üleslaadimine {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Uus joonistus",
|
||||
"edit": "Muuda joonistust",
|
||||
"tools": "Tööriistad",
|
||||
"tool-select": "Vali",
|
||||
"tool-pen": "Pliiats",
|
||||
"tool-eraser": "Kustutuskumm",
|
||||
"tool-rectangle": "Ristkülik",
|
||||
"tool-ellipse": "Ellips",
|
||||
"tool-arrow": "Nool",
|
||||
"tool-text": "Tekst",
|
||||
"style": "Värv ja jämedus",
|
||||
"color": "Värv",
|
||||
"width": "Jämedus",
|
||||
"width-thin": "Peenike",
|
||||
"width-medium": "Keskmine",
|
||||
"width-thick": "Jäme",
|
||||
"color-ink": "Tint",
|
||||
"color-gray": "Hall",
|
||||
"color-red": "Punane",
|
||||
"color-orange": "Oranž",
|
||||
"color-green": "Roheline",
|
||||
"color-teal": "Sinakasroheline",
|
||||
"color-blue": "Sinine",
|
||||
"color-violet": "Violetne",
|
||||
"undo": "Võta tagasi",
|
||||
"redo": "Tee uuesti",
|
||||
"zoom-to-fit": "Sobita aknasse",
|
||||
"done": "Valmis",
|
||||
"discard-title": "Kas loobuda sellest joonistusest?",
|
||||
"discard-description": "Seda pole veel memole lisatud.",
|
||||
"discard-edit-title": "Kas loobuda muudatustest?",
|
||||
"discard-edit-description": "Joonistus jääb selliseks, nagu see oli enne avamist.",
|
||||
"keep-drawing": "Jätka joonistamist",
|
||||
"discard": "Loobu",
|
||||
"open-failed": "Joonistust ei õnnestunud avada. Proovige uuesti.",
|
||||
"export-failed": "Joonistust ei õnnestunud salvestada. Proovige uuesti.",
|
||||
"image-failed": "Pilti ei õnnestunud joonistusele lisada.",
|
||||
"saved-without-drawing": "Memo on salvestatud, kuid joonistus mitte. Salvestage veel kord, et uuesti proovida."
|
||||
},
|
||||
"no-changes-detected": "Muudatusi ei tuvastatud",
|
||||
"save": "Salvesta",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
"link-memo": "پیوند یادداشت",
|
||||
"image-upload-stopped": "آپلود تصویر متوقف شد {{completed}}/{{total}}",
|
||||
"insert-image": "درج تصویر",
|
||||
"drawing": "نقاشی",
|
||||
"keep-as-attachments": "به عنوان پیوست نگه دارید",
|
||||
"retry-image-upload": "دوباره امتحان کنید",
|
||||
"uploading-inline-image": "در حال آپلود به محتوا",
|
||||
@@ -181,6 +182,46 @@
|
||||
"add-attachment": "افزودن پیوست",
|
||||
"image-upload-failed": "برخی تصاویر بارگذاری نشدند. دوباره تلاش کنید یا فایلهای بارگذاریشده را بهعنوان پیوست نگه دارید."
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "نقاشی جدید",
|
||||
"edit": "ویرایش نقاشی",
|
||||
"tools": "ابزارها",
|
||||
"tool-select": "انتخاب",
|
||||
"tool-pen": "قلم",
|
||||
"tool-eraser": "پاککن",
|
||||
"tool-rectangle": "مستطیل",
|
||||
"tool-ellipse": "بیضی",
|
||||
"tool-arrow": "پیکان",
|
||||
"tool-text": "متن",
|
||||
"style": "رنگ و ضخامت",
|
||||
"color": "رنگ",
|
||||
"width": "ضخامت",
|
||||
"width-thin": "نازک",
|
||||
"width-medium": "متوسط",
|
||||
"width-thick": "ضخیم",
|
||||
"color-ink": "جوهر",
|
||||
"color-gray": "خاکستری",
|
||||
"color-red": "قرمز",
|
||||
"color-orange": "نارنجی",
|
||||
"color-green": "سبز",
|
||||
"color-teal": "سبزآبی",
|
||||
"color-blue": "آبی",
|
||||
"color-violet": "بنفش",
|
||||
"undo": "واگرد",
|
||||
"redo": "ازنو",
|
||||
"zoom-to-fit": "متناسب با پنجره",
|
||||
"done": "انجام شد",
|
||||
"discard-title": "این نقاشی دور ریخته شود؟",
|
||||
"discard-description": "هنوز به یادداشت افزوده نشده است.",
|
||||
"discard-edit-title": "تغییرات دور ریخته شود؟",
|
||||
"discard-edit-description": "نقاشی همانطور که پیش از باز کردن بود باقی میماند.",
|
||||
"keep-drawing": "ادامهٔ نقاشی",
|
||||
"discard": "دور ریختن",
|
||||
"open-failed": "باز کردن نقاشی ممکن نشد. دوباره تلاش کنید.",
|
||||
"export-failed": "ذخیرهٔ نقاشی ممکن نشد. دوباره تلاش کنید.",
|
||||
"image-failed": "افزودن تصویر به نقاشی ممکن نشد.",
|
||||
"saved-without-drawing": "یادداشت ذخیره شد، اما نقاشی ذخیره نشد. برای تلاش مجدد، دوباره ذخیره کنید."
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "ضبط صدا",
|
||||
"attachment-label-with-time": "ضبط صدا {{time}}",
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Joidenkin kuvien lataaminen epäonnistui. Yritä uudelleen tai säilytä ladatut tiedostot liitteinä.",
|
||||
"image-upload-stopped": "Kuvan lataus pysähtynyt {{completed}}/{{total}}",
|
||||
"insert-image": "Lisää kuva",
|
||||
"drawing": "Piirros",
|
||||
"keep-as-attachments": "Säilytä liitteinä",
|
||||
"uploading-inline-image": "Ladataan sisältöön",
|
||||
"uploading-images": "Kuvien lataus {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Uusi piirros",
|
||||
"edit": "Muokkaa piirrosta",
|
||||
"tools": "Työkalut",
|
||||
"tool-select": "Valitse",
|
||||
"tool-pen": "Kynä",
|
||||
"tool-eraser": "Pyyhekumi",
|
||||
"tool-rectangle": "Suorakulmio",
|
||||
"tool-ellipse": "Ellipsi",
|
||||
"tool-arrow": "Nuoli",
|
||||
"tool-text": "Teksti",
|
||||
"style": "Väri ja paksuus",
|
||||
"color": "Väri",
|
||||
"width": "Paksuus",
|
||||
"width-thin": "Ohut",
|
||||
"width-medium": "Keskipaksu",
|
||||
"width-thick": "Paksu",
|
||||
"color-ink": "Muste",
|
||||
"color-gray": "Harmaa",
|
||||
"color-red": "Punainen",
|
||||
"color-orange": "Oranssi",
|
||||
"color-green": "Vihreä",
|
||||
"color-teal": "Sinivihreä",
|
||||
"color-blue": "Sininen",
|
||||
"color-violet": "Violetti",
|
||||
"undo": "Kumoa",
|
||||
"redo": "Tee uudelleen",
|
||||
"zoom-to-fit": "Sovita näkymään",
|
||||
"done": "Valmis",
|
||||
"discard-title": "Hylätäänkö tämä piirros?",
|
||||
"discard-description": "Sitä ei ole vielä lisätty muistioon.",
|
||||
"discard-edit-title": "Hylätäänkö muutokset?",
|
||||
"discard-edit-description": "Piirros pysyy sellaisena kuin se oli ennen avaamista.",
|
||||
"keep-drawing": "Jatka piirtämistä",
|
||||
"discard": "Hylkää",
|
||||
"open-failed": "Piirroksen avaaminen epäonnistui. Yritä uudelleen.",
|
||||
"export-failed": "Piirroksen tallentaminen epäonnistui. Yritä uudelleen.",
|
||||
"image-failed": "Kuvan lisääminen piirrokseen epäonnistui.",
|
||||
"saved-without-drawing": "Muistio on tallennettu, mutta piirrosta ei. Tallenna uudelleen yrittääksesi uudestaan."
|
||||
},
|
||||
"no-changes-detected": "Muutoksia ei havaittu",
|
||||
"save": "Tallentaa",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Certaines images n'ont pas pu être chargées. Veuillez réessayer ou conserver les fichiers chargés en pièces jointes.",
|
||||
"image-upload-stopped": "Chargement d'image interrompu {{completed}}/{{total}}",
|
||||
"insert-image": "Insérer une image",
|
||||
"drawing": "Dessin",
|
||||
"keep-as-attachments": "Conserver en pièces jointes",
|
||||
"uploading-inline-image": "Chargement du contenu",
|
||||
"uploading-images": "Chargement des images {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Nouveau dessin",
|
||||
"edit": "Modifier le dessin",
|
||||
"tools": "Outils",
|
||||
"tool-select": "Sélection",
|
||||
"tool-pen": "Stylo",
|
||||
"tool-eraser": "Gomme",
|
||||
"tool-rectangle": "Rectangle",
|
||||
"tool-ellipse": "Ellipse",
|
||||
"tool-arrow": "Flèche",
|
||||
"tool-text": "Texte",
|
||||
"style": "Couleur et épaisseur",
|
||||
"color": "Couleur",
|
||||
"width": "Épaisseur",
|
||||
"width-thin": "Fine",
|
||||
"width-medium": "Moyenne",
|
||||
"width-thick": "Épaisse",
|
||||
"color-ink": "Encre",
|
||||
"color-gray": "Gris",
|
||||
"color-red": "Rouge",
|
||||
"color-orange": "Orange",
|
||||
"color-green": "Vert",
|
||||
"color-teal": "Sarcelle",
|
||||
"color-blue": "Bleu",
|
||||
"color-violet": "Violet",
|
||||
"undo": "Annuler",
|
||||
"redo": "Rétablir",
|
||||
"zoom-to-fit": "Ajuster à la fenêtre",
|
||||
"done": "Terminé",
|
||||
"discard-title": "Abandonner ce dessin ?",
|
||||
"discard-description": "Il n'a pas encore été ajouté au mémo.",
|
||||
"discard-edit-title": "Abandonner vos modifications ?",
|
||||
"discard-edit-description": "Le dessin reste tel qu'il était avant son ouverture.",
|
||||
"keep-drawing": "Continuer à dessiner",
|
||||
"discard": "Abandonner",
|
||||
"open-failed": "Impossible d'ouvrir le dessin. Veuillez réessayer.",
|
||||
"export-failed": "Impossible d'enregistrer le dessin. Veuillez réessayer.",
|
||||
"image-failed": "Impossible d'ajouter l'image au dessin.",
|
||||
"saved-without-drawing": "Le mémo est enregistré, mais pas le dessin. Enregistrez à nouveau pour réessayer."
|
||||
},
|
||||
"no-changes-detected": "Aucun changement détecté",
|
||||
"save": "Enregistrer",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Non se puideron cargar algunhas imaxes. Téntao de novo ou garda os ficheiros cargados como anexos.",
|
||||
"image-upload-stopped": "Detívose a subida de imaxes {{completed}}/{{total}}",
|
||||
"insert-image": "Inserir imaxe",
|
||||
"drawing": "Debuxo",
|
||||
"keep-as-attachments": "Gardar como anexos",
|
||||
"uploading-inline-image": "Subindo ao contido",
|
||||
"uploading-images": "Subindo imaxes {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Novo debuxo",
|
||||
"edit": "Editar debuxo",
|
||||
"tools": "Ferramentas",
|
||||
"tool-select": "Seleccionar",
|
||||
"tool-pen": "Lapis",
|
||||
"tool-eraser": "Goma",
|
||||
"tool-rectangle": "Rectángulo",
|
||||
"tool-ellipse": "Elipse",
|
||||
"tool-arrow": "Frecha",
|
||||
"tool-text": "Texto",
|
||||
"style": "Cor e grosor",
|
||||
"color": "Cor",
|
||||
"width": "Grosor",
|
||||
"width-thin": "Fino",
|
||||
"width-medium": "Medio",
|
||||
"width-thick": "Groso",
|
||||
"color-ink": "Tinta",
|
||||
"color-gray": "Gris",
|
||||
"color-red": "Vermello",
|
||||
"color-orange": "Laranxa",
|
||||
"color-green": "Verde",
|
||||
"color-teal": "Verde azulado",
|
||||
"color-blue": "Azul",
|
||||
"color-violet": "Violeta",
|
||||
"undo": "Desfacer",
|
||||
"redo": "Refacer",
|
||||
"zoom-to-fit": "Axustar á pantalla",
|
||||
"done": "Feito",
|
||||
"discard-title": "Descartar este debuxo?",
|
||||
"discard-description": "Aínda non se engadiu á nota.",
|
||||
"discard-edit-title": "Descartar os cambios?",
|
||||
"discard-edit-description": "O debuxo queda como estaba antes de abrilo.",
|
||||
"keep-drawing": "Seguir debuxando",
|
||||
"discard": "Descartar",
|
||||
"open-failed": "Non se puido abrir o debuxo. Téntao de novo.",
|
||||
"export-failed": "Non se puido gardar o debuxo. Téntao de novo.",
|
||||
"image-failed": "Non se puido engadir a imaxe ao debuxo.",
|
||||
"saved-without-drawing": "A nota gardouse, pero o debuxo non. Garda de novo para tentalo outra vez."
|
||||
},
|
||||
"no-changes-detected": "Non se detectaron cambios",
|
||||
"save": "Gardar",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -259,12 +259,53 @@
|
||||
"image-upload-failed": "לא ניתן להעלות חלק מהתמונות. נסו שוב או השאירו את התמונות שהועלו כקבצים מצורפים.",
|
||||
"image-upload-stopped": "העלאת התמונה נעצרה {{completed}}/{{total}}",
|
||||
"insert-image": "הוסף תמונה",
|
||||
"drawing": "ציור",
|
||||
"keep-as-attachments": "שמור כקבצים מצורפים",
|
||||
"link-memo": "קשר פתק",
|
||||
"retry-image-upload": "נסה שוב",
|
||||
"uploading-inline-image": "מעלה לתוכן",
|
||||
"uploading-images": "מעלה תמונות {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "ציור חדש",
|
||||
"edit": "עריכת ציור",
|
||||
"tools": "כלים",
|
||||
"tool-select": "בחירה",
|
||||
"tool-pen": "עט",
|
||||
"tool-eraser": "מחק",
|
||||
"tool-rectangle": "מלבן",
|
||||
"tool-ellipse": "אליפסה",
|
||||
"tool-arrow": "חץ",
|
||||
"tool-text": "טקסט",
|
||||
"style": "צבע ועובי",
|
||||
"color": "צבע",
|
||||
"width": "עובי",
|
||||
"width-thin": "דק",
|
||||
"width-medium": "בינוני",
|
||||
"width-thick": "עבה",
|
||||
"color-ink": "דיו",
|
||||
"color-gray": "אפור",
|
||||
"color-red": "אדום",
|
||||
"color-orange": "כתום",
|
||||
"color-green": "ירוק",
|
||||
"color-teal": "טורקיז",
|
||||
"color-blue": "כחול",
|
||||
"color-violet": "סגול",
|
||||
"undo": "ביטול פעולה",
|
||||
"redo": "ביצוע חוזר",
|
||||
"zoom-to-fit": "התאמה לחלון",
|
||||
"done": "סיום",
|
||||
"discard-title": "למחוק את הציור הזה?",
|
||||
"discard-description": "הוא עדיין לא נוסף לפתק.",
|
||||
"discard-edit-title": "לבטל את השינויים?",
|
||||
"discard-edit-description": "הציור יישאר כפי שהיה לפני הפתיחה.",
|
||||
"keep-drawing": "המשך לצייר",
|
||||
"discard": "מחיקה",
|
||||
"open-failed": "לא ניתן היה לפתוח את הציור. נסו שוב.",
|
||||
"export-failed": "לא ניתן היה לשמור את הציור. נסו שוב.",
|
||||
"image-failed": "לא ניתן היה להוסיף את התמונה לציור.",
|
||||
"saved-without-drawing": "הפתק נשמר, אבל הציור לא. שמרו שוב כדי לנסות מחדש."
|
||||
},
|
||||
"no-changes-detected": "לא זוהו שינויים",
|
||||
"save": "שמור",
|
||||
"validation": {
|
||||
|
||||
@@ -176,11 +176,52 @@
|
||||
"image-upload-failed": "कुछ इमेज अपलोड नहीं हो सकीं. दोबारा कोशिश करें या अपलोड की गई फ़ाइलों को अटैचमेंट के तौर पर रखें.",
|
||||
"image-upload-stopped": "इमेज अपलोड रुक गया {{completed}}/{{total}}",
|
||||
"insert-image": "इमेज डालें",
|
||||
"drawing": "ड्रॉइंग",
|
||||
"keep-as-attachments": "अटैचमेंट के तौर पर रखें",
|
||||
"retry-image-upload": "फिर से कोशिश करें",
|
||||
"uploading-inline-image": "कंटेंट में अपलोड हो रहा है",
|
||||
"uploading-images": "इमेज अपलोड हो रही हैं {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "नई ड्रॉइंग",
|
||||
"edit": "ड्रॉइंग संपादित करें",
|
||||
"tools": "टूल",
|
||||
"tool-select": "चुनें",
|
||||
"tool-pen": "पेन",
|
||||
"tool-eraser": "इरेज़र",
|
||||
"tool-rectangle": "आयत",
|
||||
"tool-ellipse": "दीर्घवृत्त",
|
||||
"tool-arrow": "तीर",
|
||||
"tool-text": "टेक्स्ट",
|
||||
"style": "रंग और मोटाई",
|
||||
"color": "रंग",
|
||||
"width": "मोटाई",
|
||||
"width-thin": "पतली",
|
||||
"width-medium": "मध्यम",
|
||||
"width-thick": "मोटी",
|
||||
"color-ink": "स्याही",
|
||||
"color-gray": "धूसर",
|
||||
"color-red": "लाल",
|
||||
"color-orange": "नारंगी",
|
||||
"color-green": "हरा",
|
||||
"color-teal": "हरित-नील",
|
||||
"color-blue": "नीला",
|
||||
"color-violet": "बैंगनी",
|
||||
"undo": "पूर्ववत करें",
|
||||
"redo": "फिर से करें",
|
||||
"zoom-to-fit": "विंडो में फ़िट करें",
|
||||
"done": "हो गया",
|
||||
"discard-title": "यह ड्रॉइंग हटाएँ?",
|
||||
"discard-description": "इसे अभी तक मेमो में नहीं जोड़ा गया है।",
|
||||
"discard-edit-title": "अपने बदलाव हटाएँ?",
|
||||
"discard-edit-description": "ड्रॉइंग वैसी ही रहेगी जैसी खोलने से पहले थी।",
|
||||
"keep-drawing": "ड्रॉइंग जारी रखें",
|
||||
"discard": "हटाएँ",
|
||||
"open-failed": "ड्रॉइंग नहीं खुल सकी। फिर से कोशिश करें।",
|
||||
"export-failed": "ड्रॉइंग सहेजी नहीं जा सकी। फिर से कोशिश करें।",
|
||||
"image-failed": "इमेज को ड्रॉइंग में नहीं जोड़ा जा सका।",
|
||||
"saved-without-drawing": "मेमो सहेज लिया गया, लेकिन ड्रॉइंग नहीं। फिर से कोशिश करने के लिए दोबारा सहेजें।"
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "ऑडियो रिकॉर्डिंग",
|
||||
"attachment-label-with-time": "ऑडियो रिकॉर्डिंग {{time}}",
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Neke slike nije moguće prenijeti. Pokušajte ponovno ili zadržite prenesene datoteke kao privitke.",
|
||||
"image-upload-stopped": "Prijenos slike zaustavljen {{completed}}/{{total}}",
|
||||
"insert-image": "Umetni sliku",
|
||||
"drawing": "Crtež",
|
||||
"keep-as-attachments": "Zadrži kao privitke",
|
||||
"uploading-inline-image": "Prijenos u sadržaj",
|
||||
"uploading-images": "Prijenos slika {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Novi crtež",
|
||||
"edit": "Uredi crtež",
|
||||
"tools": "Alati",
|
||||
"tool-select": "Odabir",
|
||||
"tool-pen": "Olovka",
|
||||
"tool-eraser": "Gumica",
|
||||
"tool-rectangle": "Pravokutnik",
|
||||
"tool-ellipse": "Elipsa",
|
||||
"tool-arrow": "Strelica",
|
||||
"tool-text": "Tekst",
|
||||
"style": "Boja i debljina",
|
||||
"color": "Boja",
|
||||
"width": "Debljina",
|
||||
"width-thin": "Tanka",
|
||||
"width-medium": "Srednja",
|
||||
"width-thick": "Debela",
|
||||
"color-ink": "Tinta",
|
||||
"color-gray": "Siva",
|
||||
"color-red": "Crvena",
|
||||
"color-orange": "Narančasta",
|
||||
"color-green": "Zelena",
|
||||
"color-teal": "Tirkizna",
|
||||
"color-blue": "Plava",
|
||||
"color-violet": "Ljubičasta",
|
||||
"undo": "Poništi",
|
||||
"redo": "Ponovi",
|
||||
"zoom-to-fit": "Prilagodi prozoru",
|
||||
"done": "Gotovo",
|
||||
"discard-title": "Odbaciti ovaj crtež?",
|
||||
"discard-description": "Još nije dodan u memo.",
|
||||
"discard-edit-title": "Odbaciti promjene?",
|
||||
"discard-edit-description": "Crtež ostaje kakav je bio prije nego što ste ga otvorili.",
|
||||
"keep-drawing": "Nastavi crtati",
|
||||
"discard": "Odbaci",
|
||||
"open-failed": "Crtež nije moguće otvoriti. Pokušajte ponovno.",
|
||||
"export-failed": "Crtež nije moguće spremiti. Pokušajte ponovno.",
|
||||
"image-failed": "Sliku nije moguće dodati u crtež.",
|
||||
"saved-without-drawing": "Memo je spremljen, ali crtež nije. Sačuvajte ponovno za novi pokušaj."
|
||||
},
|
||||
"no-changes-detected": "Nema promjena",
|
||||
"save": "Sačuvaj",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Néhány kép feltöltése sikertelen. Próbálja újra, vagy tartsa meg a feltöltött fájlokat mellékletként.",
|
||||
"image-upload-stopped": "Képfeltöltés leállítva {{completed}}/{{total}}",
|
||||
"insert-image": "Kép beszúrása",
|
||||
"drawing": "Rajz",
|
||||
"keep-as-attachments": "Megtartás mellékletként",
|
||||
"uploading-inline-image": "Feltöltés a tartalomhoz",
|
||||
"uploading-images": "Képek feltöltése {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Új rajz",
|
||||
"edit": "Rajz szerkesztése",
|
||||
"tools": "Eszközök",
|
||||
"tool-select": "Kijelölés",
|
||||
"tool-pen": "Toll",
|
||||
"tool-eraser": "Radír",
|
||||
"tool-rectangle": "Téglalap",
|
||||
"tool-ellipse": "Ellipszis",
|
||||
"tool-arrow": "Nyíl",
|
||||
"tool-text": "Szöveg",
|
||||
"style": "Szín és vastagság",
|
||||
"color": "Szín",
|
||||
"width": "Vastagság",
|
||||
"width-thin": "Vékony",
|
||||
"width-medium": "Közepes",
|
||||
"width-thick": "Vastag",
|
||||
"color-ink": "Tinta",
|
||||
"color-gray": "Szürke",
|
||||
"color-red": "Piros",
|
||||
"color-orange": "Narancs",
|
||||
"color-green": "Zöld",
|
||||
"color-teal": "Kékeszöld",
|
||||
"color-blue": "Kék",
|
||||
"color-violet": "Ibolya",
|
||||
"undo": "Visszavonás",
|
||||
"redo": "Újra",
|
||||
"zoom-to-fit": "Igazítás az ablakhoz",
|
||||
"done": "Kész",
|
||||
"discard-title": "Elveti ezt a rajzot?",
|
||||
"discard-description": "Még nincs hozzáadva a jegyzethez.",
|
||||
"discard-edit-title": "Elveti a módosításokat?",
|
||||
"discard-edit-description": "A rajz olyan marad, amilyen a megnyitása előtt volt.",
|
||||
"keep-drawing": "Rajzolás folytatása",
|
||||
"discard": "Elvetés",
|
||||
"open-failed": "Nem sikerült megnyitni a rajzot. Próbálja újra.",
|
||||
"export-failed": "Nem sikerült menteni a rajzot. Próbálja újra.",
|
||||
"image-failed": "Nem sikerült hozzáadni a képet a rajzhoz.",
|
||||
"saved-without-drawing": "A jegyzet mentve, de a rajz nem. Mentse újra az újrapróbálkozáshoz."
|
||||
},
|
||||
"no-changes-detected": "Nincs változás",
|
||||
"save": "Mentés",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -176,11 +176,52 @@
|
||||
"image-upload-failed": "Beberapa gambar tidak dapat diunggah. Coba lagi atau simpan file yang diunggah sebagai lampiran.",
|
||||
"image-upload-stopped": "Unggahan gambar dihentikan {{completed}}/{{total}}",
|
||||
"insert-image": "Sisipkan gambar",
|
||||
"drawing": "Sketsa",
|
||||
"keep-as-attachments": "Simpan sebagai lampiran",
|
||||
"retry-image-upload": "Coba lagi",
|
||||
"uploading-inline-image": "Mengunggah ke konten",
|
||||
"uploading-images": "Mengunggah gambar {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Sketsa baru",
|
||||
"edit": "Edit sketsa",
|
||||
"tools": "Alat",
|
||||
"tool-select": "Pilih",
|
||||
"tool-pen": "Pena",
|
||||
"tool-eraser": "Penghapus",
|
||||
"tool-rectangle": "Persegi panjang",
|
||||
"tool-ellipse": "Elips",
|
||||
"tool-arrow": "Panah",
|
||||
"tool-text": "Teks",
|
||||
"style": "Warna dan ketebalan",
|
||||
"color": "Warna",
|
||||
"width": "Ketebalan",
|
||||
"width-thin": "Tipis",
|
||||
"width-medium": "Sedang",
|
||||
"width-thick": "Tebal",
|
||||
"color-ink": "Tinta",
|
||||
"color-gray": "Abu-abu",
|
||||
"color-red": "Merah",
|
||||
"color-orange": "Oranye",
|
||||
"color-green": "Hijau",
|
||||
"color-teal": "Hijau kebiruan",
|
||||
"color-blue": "Biru",
|
||||
"color-violet": "Ungu",
|
||||
"undo": "Urungkan",
|
||||
"redo": "Ulangi",
|
||||
"zoom-to-fit": "Paskan ke jendela",
|
||||
"done": "Selesai",
|
||||
"discard-title": "Buang sketsa ini?",
|
||||
"discard-description": "Sketsa belum ditambahkan ke memo.",
|
||||
"discard-edit-title": "Buang perubahan Anda?",
|
||||
"discard-edit-description": "Sketsa akan tetap seperti sebelum Anda membukanya.",
|
||||
"keep-drawing": "Lanjutkan menggambar",
|
||||
"discard": "Buang",
|
||||
"open-failed": "Tidak dapat membuka sketsa. Coba lagi.",
|
||||
"export-failed": "Tidak dapat menyimpan sketsa. Coba lagi.",
|
||||
"image-failed": "Tidak dapat menambahkan gambar ke sketsa.",
|
||||
"saved-without-drawing": "Memo tersimpan, tetapi sketsa belum. Simpan lagi untuk mencoba ulang."
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "Rekaman audio",
|
||||
"attachment-label-with-time": "Rekaman audio {{time}}",
|
||||
|
||||
@@ -174,11 +174,52 @@
|
||||
"add-attachment": "Aggiungi allegato",
|
||||
"image-upload-stopped": "Caricamento immagine interrotto {{completed}}/{{total}}",
|
||||
"insert-image": "Inserisci immagine",
|
||||
"drawing": "Disegno",
|
||||
"keep-as-attachments": "Mantieni come allegati",
|
||||
"uploading-inline-image": "Caricamento nel contenuto",
|
||||
"uploading-images": "Caricamento immagini {{completed}}/{{total}}",
|
||||
"image-upload-failed": "Impossibile caricare alcune immagini. Riprova o mantieni i file caricati come allegati."
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Nuovo disegno",
|
||||
"edit": "Modifica disegno",
|
||||
"tools": "Strumenti",
|
||||
"tool-select": "Seleziona",
|
||||
"tool-pen": "Penna",
|
||||
"tool-eraser": "Gomma",
|
||||
"tool-rectangle": "Rettangolo",
|
||||
"tool-ellipse": "Ellisse",
|
||||
"tool-arrow": "Freccia",
|
||||
"tool-text": "Testo",
|
||||
"style": "Colore e spessore",
|
||||
"color": "Colore",
|
||||
"width": "Spessore",
|
||||
"width-thin": "Sottile",
|
||||
"width-medium": "Medio",
|
||||
"width-thick": "Spesso",
|
||||
"color-ink": "Inchiostro",
|
||||
"color-gray": "Grigio",
|
||||
"color-red": "Rosso",
|
||||
"color-orange": "Arancione",
|
||||
"color-green": "Verde",
|
||||
"color-teal": "Verde acqua",
|
||||
"color-blue": "Blu",
|
||||
"color-violet": "Viola",
|
||||
"undo": "Annulla",
|
||||
"redo": "Ripeti",
|
||||
"zoom-to-fit": "Adatta alla finestra",
|
||||
"done": "Fatto",
|
||||
"discard-title": "Eliminare questo disegno?",
|
||||
"discard-description": "Non è ancora stato aggiunto al memo.",
|
||||
"discard-edit-title": "Annullare le modifiche?",
|
||||
"discard-edit-description": "Il disegno resterà com'era prima di aprirlo.",
|
||||
"keep-drawing": "Continua a disegnare",
|
||||
"discard": "Elimina",
|
||||
"open-failed": "Impossibile aprire il disegno. Riprova.",
|
||||
"export-failed": "Impossibile salvare il disegno. Riprova.",
|
||||
"image-failed": "Impossibile aggiungere l'immagine al disegno.",
|
||||
"saved-without-drawing": "Il memo è stato salvato, ma il disegno no. Salva di nuovo per riprovare."
|
||||
},
|
||||
"no-changes-detected": "Nessuna modifica rilevata",
|
||||
"save": "Salva",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -177,10 +177,51 @@
|
||||
"image-upload-failed": "一部の画像はアップロードできませんでした。再試行するか、アップロード済みのファイルを添付ファイルとして保存してください。",
|
||||
"image-upload-stopped": "画像アップロードが停止しました {{completed}}/{{total}}",
|
||||
"insert-image": "画像を挿入",
|
||||
"drawing": "描画",
|
||||
"keep-as-attachments": "添付ファイルとして保存",
|
||||
"uploading-inline-image": "コンテンツにアップロード中",
|
||||
"uploading-images": "画像 {{completed}}/{{total}} をアップロード中"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "新しい描画",
|
||||
"edit": "描画を編集",
|
||||
"tools": "ツール",
|
||||
"tool-select": "選択",
|
||||
"tool-pen": "ペン",
|
||||
"tool-eraser": "消しゴム",
|
||||
"tool-rectangle": "長方形",
|
||||
"tool-ellipse": "楕円",
|
||||
"tool-arrow": "矢印",
|
||||
"tool-text": "テキスト",
|
||||
"style": "色と太さ",
|
||||
"color": "色",
|
||||
"width": "太さ",
|
||||
"width-thin": "細い",
|
||||
"width-medium": "普通",
|
||||
"width-thick": "太い",
|
||||
"color-ink": "インク",
|
||||
"color-gray": "グレー",
|
||||
"color-red": "赤",
|
||||
"color-orange": "オレンジ",
|
||||
"color-green": "緑",
|
||||
"color-teal": "ティール",
|
||||
"color-blue": "青",
|
||||
"color-violet": "紫",
|
||||
"undo": "元に戻す",
|
||||
"redo": "やり直す",
|
||||
"zoom-to-fit": "全体を表示",
|
||||
"done": "完了",
|
||||
"discard-title": "この描画を破棄しますか?",
|
||||
"discard-description": "まだメモに追加されていません。",
|
||||
"discard-edit-title": "変更を破棄しますか?",
|
||||
"discard-edit-description": "描画は開く前の状態のまま残ります。",
|
||||
"keep-drawing": "描画を続ける",
|
||||
"discard": "破棄",
|
||||
"open-failed": "描画を開けませんでした。もう一度お試しください。",
|
||||
"export-failed": "描画を保存できませんでした。もう一度お試しください。",
|
||||
"image-failed": "画像を描画に追加できませんでした。",
|
||||
"saved-without-drawing": "メモは保存されましたが、描画は保存されていません。再試行するには、もう一度保存してください。"
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "音声録音",
|
||||
"attachment-label-with-time": "音声録音 {{time}}",
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "ზოგიერთი სურათის ატვირთვა ვერ მოხერხდა. სცადეთ ხელახლა ან შეინახეთ ატვირთული ფაილები დანართებად.",
|
||||
"image-upload-stopped": "სურათის ატვირთვა შეჩერდა {{completed}}/{{total}}",
|
||||
"insert-image": "სურათის ჩასმა",
|
||||
"drawing": "ნახატი",
|
||||
"keep-as-attachments": "დანართებად შენახვა",
|
||||
"uploading-inline-image": "კონტენტში ატვირთვა",
|
||||
"uploading-images": "სურათების ატვირთვა {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "ახალი ნახატი",
|
||||
"edit": "ნახატის რედაქტირება",
|
||||
"tools": "ხელსაწყოები",
|
||||
"tool-select": "მონიშვნა",
|
||||
"tool-pen": "კალამი",
|
||||
"tool-eraser": "საშლელი",
|
||||
"tool-rectangle": "მართკუთხედი",
|
||||
"tool-ellipse": "ელიფსი",
|
||||
"tool-arrow": "ისარი",
|
||||
"tool-text": "ტექსტი",
|
||||
"style": "ფერი და სისქე",
|
||||
"color": "ფერი",
|
||||
"width": "სისქე",
|
||||
"width-thin": "თხელი",
|
||||
"width-medium": "საშუალო",
|
||||
"width-thick": "სქელი",
|
||||
"color-ink": "მელანი",
|
||||
"color-gray": "ნაცრისფერი",
|
||||
"color-red": "წითელი",
|
||||
"color-orange": "ნარინჯისფერი",
|
||||
"color-green": "მწვანე",
|
||||
"color-teal": "ზღვისფერი",
|
||||
"color-blue": "ლურჯი",
|
||||
"color-violet": "იისფერი",
|
||||
"undo": "გაუქმება",
|
||||
"redo": "გამეორება",
|
||||
"zoom-to-fit": "ფანჯარაში მორგება",
|
||||
"done": "მზადაა",
|
||||
"discard-title": "გსურთ ამ ნახატის უარყოფა?",
|
||||
"discard-description": "ის ჯერ არ დამატებულა მემოში.",
|
||||
"discard-edit-title": "გსურთ ცვლილებების უარყოფა?",
|
||||
"discard-edit-description": "ნახატი დარჩება ისეთი, როგორიც გახსნამდე იყო.",
|
||||
"keep-drawing": "ხატვის გაგრძელება",
|
||||
"discard": "უარყოფა",
|
||||
"open-failed": "ნახატის გახსნა ვერ მოხერხდა. სცადეთ ხელახლა.",
|
||||
"export-failed": "ნახატის შენახვა ვერ მოხერხდა. სცადეთ ხელახლა.",
|
||||
"image-failed": "სურათის ნახატში დამატება ვერ მოხერხდა.",
|
||||
"saved-without-drawing": "მემო შენახულია, ნახატი კი — არა. ხელახლა საცდელად ისევ შეინახეთ."
|
||||
},
|
||||
"no-changes-detected": "ცვლილებები არ აღმოჩენილა",
|
||||
"save": "შენახვა",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -176,11 +176,52 @@
|
||||
"image-upload-failed": "일부 이미지를 업로드할 수 없습니다. 다시 시도하거나 업로드된 파일을 첨부 파일로 유지하세요.",
|
||||
"image-upload-stopped": "이미지 업로드 중지됨 {{completed}}/{{total}}",
|
||||
"insert-image": "이미지 삽입",
|
||||
"drawing": "그리기",
|
||||
"keep-as-attachments": "첨부 파일로 유지",
|
||||
"retry-image-upload": "다시 시도",
|
||||
"uploading-inline-image": "콘텐츠에 업로드 중",
|
||||
"uploading-images": "이미지 업로드 중 {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "새 그림",
|
||||
"edit": "그림 편집",
|
||||
"tools": "도구",
|
||||
"tool-select": "선택",
|
||||
"tool-pen": "펜",
|
||||
"tool-eraser": "지우개",
|
||||
"tool-rectangle": "사각형",
|
||||
"tool-ellipse": "타원",
|
||||
"tool-arrow": "화살표",
|
||||
"tool-text": "텍스트",
|
||||
"style": "색상 및 굵기",
|
||||
"color": "색상",
|
||||
"width": "굵기",
|
||||
"width-thin": "얇음",
|
||||
"width-medium": "보통",
|
||||
"width-thick": "굵음",
|
||||
"color-ink": "잉크",
|
||||
"color-gray": "회색",
|
||||
"color-red": "빨간색",
|
||||
"color-orange": "주황색",
|
||||
"color-green": "초록색",
|
||||
"color-teal": "청록색",
|
||||
"color-blue": "파란색",
|
||||
"color-violet": "보라색",
|
||||
"undo": "실행 취소",
|
||||
"redo": "다시 실행",
|
||||
"zoom-to-fit": "화면에 맞추기",
|
||||
"done": "완료",
|
||||
"discard-title": "이 그림을 삭제할까요?",
|
||||
"discard-description": "아직 메모에 추가되지 않았습니다.",
|
||||
"discard-edit-title": "변경 사항을 삭제할까요?",
|
||||
"discard-edit-description": "그림은 열기 전 상태 그대로 유지됩니다.",
|
||||
"keep-drawing": "계속 그리기",
|
||||
"discard": "삭제",
|
||||
"open-failed": "그림을 열 수 없습니다. 다시 시도하세요.",
|
||||
"export-failed": "그림을 저장할 수 없습니다. 다시 시도하세요.",
|
||||
"image-failed": "이미지를 그림에 추가할 수 없습니다.",
|
||||
"saved-without-drawing": "메모는 저장되었지만 그림은 저장되지 않았습니다. 재시도하려면 다시 저장하세요."
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "오디오 녹음",
|
||||
"attachment-label-with-time": "오디오 녹음 {{time}}",
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Kai kurių vaizdų nepavyko įkelti. Bandykite dar kartą arba išsaugokite įkeltus failus kaip priedus.",
|
||||
"image-upload-stopped": "Vaizdo įkėlimas sustabdytas {{completed}}/{{total}}",
|
||||
"insert-image": "Įterpti vaizdą",
|
||||
"drawing": "Piešinys",
|
||||
"keep-as-attachments": "Išsaugoti kaip priedus",
|
||||
"uploading-inline-image": "Įkeliama į turinį",
|
||||
"uploading-images": "Įkeliami vaizdai {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Naujas piešinys",
|
||||
"edit": "Redaguoti piešinį",
|
||||
"tools": "Įrankiai",
|
||||
"tool-select": "Žymėti",
|
||||
"tool-pen": "Rašiklis",
|
||||
"tool-eraser": "Trintukas",
|
||||
"tool-rectangle": "Stačiakampis",
|
||||
"tool-ellipse": "Elipsė",
|
||||
"tool-arrow": "Rodyklė",
|
||||
"tool-text": "Tekstas",
|
||||
"style": "Spalva ir storis",
|
||||
"color": "Spalva",
|
||||
"width": "Storis",
|
||||
"width-thin": "Plona",
|
||||
"width-medium": "Vidutinė",
|
||||
"width-thick": "Stora",
|
||||
"color-ink": "Rašalas",
|
||||
"color-gray": "Pilka",
|
||||
"color-red": "Raudona",
|
||||
"color-orange": "Oranžinė",
|
||||
"color-green": "Žalia",
|
||||
"color-teal": "Žalsvai mėlyna",
|
||||
"color-blue": "Mėlyna",
|
||||
"color-violet": "Violetinė",
|
||||
"undo": "Anuliuoti",
|
||||
"redo": "Grąžinti",
|
||||
"zoom-to-fit": "Talpinti lange",
|
||||
"done": "Atlikta",
|
||||
"discard-title": "Atmesti šį piešinį?",
|
||||
"discard-description": "Jis dar nepridėtas prie atmintinės.",
|
||||
"discard-edit-title": "Atmesti pakeitimus?",
|
||||
"discard-edit-description": "Piešinys liks toks, koks buvo prieš jį atidarant.",
|
||||
"keep-drawing": "Toliau piešti",
|
||||
"discard": "Atmesti",
|
||||
"open-failed": "Nepavyko atidaryti piešinio. Bandykite dar kartą.",
|
||||
"export-failed": "Nepavyko išsaugoti piešinio. Bandykite dar kartą.",
|
||||
"image-failed": "Nepavyko pridėti vaizdo prie piešinio.",
|
||||
"saved-without-drawing": "Atmintinė išsaugota, bet piešinys – ne. Išsaugokite dar kartą, kad bandytumėte iš naujo."
|
||||
},
|
||||
"no-changes-detected": "Pakeitimų neaptikta",
|
||||
"save": "Išsaugoti",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Dažus attēlus nevarēja augšupielādēt. Mēģiniet vēlreiz vai saglabājiet augšupielādētos failus kā pielikumus.",
|
||||
"image-upload-stopped": "Attēla augšupielāde apturēta {{completed}}/{{total}}",
|
||||
"insert-image": "Ievietot attēlu",
|
||||
"drawing": "Zīmējums",
|
||||
"keep-as-attachments": "Saglabāt kā pielikumus",
|
||||
"uploading-inline-image": "Augšupielādē saturu",
|
||||
"uploading-images": "Attēlu augšupielāde {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Jauns zīmējums",
|
||||
"edit": "Rediģēt zīmējumu",
|
||||
"tools": "Rīki",
|
||||
"tool-select": "Atlasīt",
|
||||
"tool-pen": "Pildspalva",
|
||||
"tool-eraser": "Dzēšgumija",
|
||||
"tool-rectangle": "Taisnstūris",
|
||||
"tool-ellipse": "Elipse",
|
||||
"tool-arrow": "Bulta",
|
||||
"tool-text": "Teksts",
|
||||
"style": "Krāsa un biezums",
|
||||
"color": "Krāsa",
|
||||
"width": "Biezums",
|
||||
"width-thin": "Plāna",
|
||||
"width-medium": "Vidēja",
|
||||
"width-thick": "Bieza",
|
||||
"color-ink": "Tinte",
|
||||
"color-gray": "Pelēka",
|
||||
"color-red": "Sarkana",
|
||||
"color-orange": "Oranža",
|
||||
"color-green": "Zaļa",
|
||||
"color-teal": "Zilganzaļa",
|
||||
"color-blue": "Zila",
|
||||
"color-violet": "Violeta",
|
||||
"undo": "Atsaukt",
|
||||
"redo": "Atcelt atsaukšanu",
|
||||
"zoom-to-fit": "Ietilpināt logā",
|
||||
"done": "Gatavs",
|
||||
"discard-title": "Atmest šo zīmējumu?",
|
||||
"discard-description": "Tas vēl nav pievienots piezīmei.",
|
||||
"discard-edit-title": "Atmest izmaiņas?",
|
||||
"discard-edit-description": "Zīmējums paliks tāds, kāds tas bija pirms atvēršanas.",
|
||||
"keep-drawing": "Turpināt zīmēt",
|
||||
"discard": "Atmest",
|
||||
"open-failed": "Neizdevās atvērt zīmējumu. Mēģiniet vēlreiz.",
|
||||
"export-failed": "Neizdevās saglabāt zīmējumu. Mēģiniet vēlreiz.",
|
||||
"image-failed": "Neizdevās pievienot attēlu zīmējumam.",
|
||||
"saved-without-drawing": "Piezīme ir saglabāta, bet zīmējums nav. Saglabājiet vēlreiz, lai mēģinātu atkārtoti."
|
||||
},
|
||||
"no-changes-detected": "Izmaiņas nav konstatētas",
|
||||
"save": "Saglabāt",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
"link-memo": "लिंक मेमो",
|
||||
"image-upload-stopped": "प्रतिमा अपलोड थांबले {{completed}}/{{total}}",
|
||||
"insert-image": "प्रतिमा घाला",
|
||||
"drawing": "रेखाचित्र",
|
||||
"keep-as-attachments": "संलग्नक म्हणून ठेवा",
|
||||
"retry-image-upload": "पुन्हा प्रयत्न करा",
|
||||
"uploading-inline-image": "सामग्रीवर अपलोड करत आहे",
|
||||
@@ -181,6 +182,46 @@
|
||||
"add-attachment": "जोडपत्र जोडा",
|
||||
"image-upload-failed": "काही प्रतिमा अपलोड होऊ शकल्या नाहीत. पुन्हा प्रयत्न करा किंवा अपलोड केलेल्या फाइल्स जोडपत्रे म्हणून ठेवा."
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "नवीन रेखाचित्र",
|
||||
"edit": "रेखाचित्र संपादित करा",
|
||||
"tools": "साधने",
|
||||
"tool-select": "निवडा",
|
||||
"tool-pen": "पेन",
|
||||
"tool-eraser": "खोडरबर",
|
||||
"tool-rectangle": "आयत",
|
||||
"tool-ellipse": "लंबवर्तुळ",
|
||||
"tool-arrow": "बाण",
|
||||
"tool-text": "मजकूर",
|
||||
"style": "रंग आणि जाडी",
|
||||
"color": "रंग",
|
||||
"width": "जाडी",
|
||||
"width-thin": "पातळ",
|
||||
"width-medium": "मध्यम",
|
||||
"width-thick": "जाड",
|
||||
"color-ink": "शाई",
|
||||
"color-gray": "राखाडी",
|
||||
"color-red": "लाल",
|
||||
"color-orange": "नारिंगी",
|
||||
"color-green": "हिरवा",
|
||||
"color-teal": "निळसर हिरवा",
|
||||
"color-blue": "निळा",
|
||||
"color-violet": "जांभळा",
|
||||
"undo": "पूर्ववत करा",
|
||||
"redo": "पुन्हा करा",
|
||||
"zoom-to-fit": "विंडोमध्ये बसवा",
|
||||
"done": "झाले",
|
||||
"discard-title": "हे रेखाचित्र टाकून द्यायचे?",
|
||||
"discard-description": "ते अजून मेमोमध्ये जोडलेले नाही.",
|
||||
"discard-edit-title": "तुमचे बदल टाकून द्यायचे?",
|
||||
"discard-edit-description": "रेखाचित्र उघडण्यापूर्वी जसे होते तसेच राहील.",
|
||||
"keep-drawing": "रेखाचित्र सुरू ठेवा",
|
||||
"discard": "टाकून द्या",
|
||||
"open-failed": "रेखाचित्र उघडता आले नाही. पुन्हा प्रयत्न करा.",
|
||||
"export-failed": "रेखाचित्र जतन करता आले नाही. पुन्हा प्रयत्न करा.",
|
||||
"image-failed": "प्रतिमा रेखाचित्रात जोडता आली नाही.",
|
||||
"saved-without-drawing": "मेमो जतन केला, पण रेखाचित्र जतन झाले नाही. पुन्हा प्रयत्नासाठी परत जतन करा."
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "ऑडिओ रेकॉर्डिंग",
|
||||
"attachment-label-with-time": "ऑडिओ रेकॉर्डिंग {{time}}",
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Noen bilder kunne ikke lastes opp. Prøv på nytt eller behold de opplastede filene som vedlegg.",
|
||||
"image-upload-stopped": "Bildeopplasting stoppet {{completed}}/{{total}}",
|
||||
"insert-image": "Sett inn bilde",
|
||||
"drawing": "Tegning",
|
||||
"keep-as-attachments": "Behold som vedlegg",
|
||||
"uploading-inline-image": "Laster opp til innhold",
|
||||
"uploading-images": "Laster opp bilder {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Ny tegning",
|
||||
"edit": "Rediger tegning",
|
||||
"tools": "Verktøy",
|
||||
"tool-select": "Velg",
|
||||
"tool-pen": "Penn",
|
||||
"tool-eraser": "Viskelær",
|
||||
"tool-rectangle": "Rektangel",
|
||||
"tool-ellipse": "Ellipse",
|
||||
"tool-arrow": "Pil",
|
||||
"tool-text": "Tekst",
|
||||
"style": "Farge og tykkelse",
|
||||
"color": "Farge",
|
||||
"width": "Tykkelse",
|
||||
"width-thin": "Tynn",
|
||||
"width-medium": "Middels",
|
||||
"width-thick": "Tykk",
|
||||
"color-ink": "Blekk",
|
||||
"color-gray": "Grå",
|
||||
"color-red": "Rød",
|
||||
"color-orange": "Oransje",
|
||||
"color-green": "Grønn",
|
||||
"color-teal": "Blågrønn",
|
||||
"color-blue": "Blå",
|
||||
"color-violet": "Fiolett",
|
||||
"undo": "Angre",
|
||||
"redo": "Gjør om",
|
||||
"zoom-to-fit": "Tilpass til vinduet",
|
||||
"done": "Ferdig",
|
||||
"discard-title": "Forkaste denne tegningen?",
|
||||
"discard-description": "Den er ikke lagt til i memoen ennå.",
|
||||
"discard-edit-title": "Forkaste endringene?",
|
||||
"discard-edit-description": "Tegningen forblir slik den var før du åpnet den.",
|
||||
"keep-drawing": "Fortsett å tegne",
|
||||
"discard": "Forkast",
|
||||
"open-failed": "Kunne ikke åpne tegningen. Prøv på nytt.",
|
||||
"export-failed": "Kunne ikke lagre tegningen. Prøv på nytt.",
|
||||
"image-failed": "Kunne ikke legge bildet til i tegningen.",
|
||||
"saved-without-drawing": "Memoen er lagret, men tegningen er ikke det. Lagre på nytt for å prøve igjen."
|
||||
},
|
||||
"no-changes-detected": "Ingen endringer oppdaget",
|
||||
"save": "Lagre",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Sommige afbeeldingen konden niet worden geüpload. Probeer het opnieuw of bewaar de geüploade bestanden als bijlagen.",
|
||||
"image-upload-stopped": "Afbeelding uploaden gestopt {{completed}}/{{total}}",
|
||||
"insert-image": "Afbeelding invoegen",
|
||||
"drawing": "Tekening",
|
||||
"keep-as-attachments": "Bewaren als bijlagen",
|
||||
"uploading-inline-image": "Uploaden naar inhoud",
|
||||
"uploading-images": "Afbeeldingen uploaden {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Nieuwe tekening",
|
||||
"edit": "Tekening bewerken",
|
||||
"tools": "Gereedschap",
|
||||
"tool-select": "Selecteren",
|
||||
"tool-pen": "Pen",
|
||||
"tool-eraser": "Gum",
|
||||
"tool-rectangle": "Rechthoek",
|
||||
"tool-ellipse": "Ellips",
|
||||
"tool-arrow": "Pijl",
|
||||
"tool-text": "Tekst",
|
||||
"style": "Kleur en dikte",
|
||||
"color": "Kleur",
|
||||
"width": "Dikte",
|
||||
"width-thin": "Dun",
|
||||
"width-medium": "Gemiddeld",
|
||||
"width-thick": "Dik",
|
||||
"color-ink": "Inkt",
|
||||
"color-gray": "Grijs",
|
||||
"color-red": "Rood",
|
||||
"color-orange": "Oranje",
|
||||
"color-green": "Groen",
|
||||
"color-teal": "Blauwgroen",
|
||||
"color-blue": "Blauw",
|
||||
"color-violet": "Violet",
|
||||
"undo": "Ongedaan maken",
|
||||
"redo": "Opnieuw",
|
||||
"zoom-to-fit": "Passend maken",
|
||||
"done": "Klaar",
|
||||
"discard-title": "Deze tekening weggooien?",
|
||||
"discard-description": "Hij is nog niet aan de memo toegevoegd.",
|
||||
"discard-edit-title": "Wijzigingen weggooien?",
|
||||
"discard-edit-description": "De tekening blijft zoals hij was voordat je hem opende.",
|
||||
"keep-drawing": "Verder tekenen",
|
||||
"discard": "Weggooien",
|
||||
"open-failed": "Kan de tekening niet openen. Probeer het opnieuw.",
|
||||
"export-failed": "Kan de tekening niet opslaan. Probeer het opnieuw.",
|
||||
"image-failed": "Kan de afbeelding niet aan de tekening toevoegen.",
|
||||
"saved-without-drawing": "De memo is opgeslagen, maar de tekening niet. Sla opnieuw op om het nog eens te proberen."
|
||||
},
|
||||
"no-changes-detected": "Geen wijzigingen gedetecteerd",
|
||||
"save": "Opslaan",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -282,12 +282,53 @@
|
||||
"image-upload-failed": "Somme bilete kunne diverre ikkje lastast opp. Prøv att, eller hald på dei opplasta filene som vedlegg.",
|
||||
"image-upload-stopped": "Biletopplastinga stogga {{completed}}/{{total}}",
|
||||
"insert-image": "Set inn bilete",
|
||||
"drawing": "Teikning",
|
||||
"keep-as-attachments": "Hald på som vedlegg",
|
||||
"link-memo": "Knyt til notat",
|
||||
"retry-image-upload": "Prøv att",
|
||||
"uploading-images": "Lastar opp bilete {{completed}}/{{total}}",
|
||||
"uploading-inline-image": "Lastar opp til innhaldet"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Ny teikning",
|
||||
"edit": "Rediger teikning",
|
||||
"tools": "Verktøy",
|
||||
"tool-select": "Vel",
|
||||
"tool-pen": "Penn",
|
||||
"tool-eraser": "Viskelêr",
|
||||
"tool-rectangle": "Rektangel",
|
||||
"tool-ellipse": "Ellipse",
|
||||
"tool-arrow": "Pil",
|
||||
"tool-text": "Tekst",
|
||||
"style": "Farge og tjukkleik",
|
||||
"color": "Farge",
|
||||
"width": "Tjukkleik",
|
||||
"width-thin": "Tynn",
|
||||
"width-medium": "Middels",
|
||||
"width-thick": "Tjukk",
|
||||
"color-ink": "Blekk",
|
||||
"color-gray": "Grå",
|
||||
"color-red": "Raud",
|
||||
"color-orange": "Oransje",
|
||||
"color-green": "Grøn",
|
||||
"color-teal": "Blågrøn",
|
||||
"color-blue": "Blå",
|
||||
"color-violet": "Fiolett",
|
||||
"undo": "Angre",
|
||||
"redo": "Gjer om",
|
||||
"zoom-to-fit": "Tilpass til vindauget",
|
||||
"done": "Ferdig",
|
||||
"discard-title": "Forkaste denne teikninga?",
|
||||
"discard-description": "Ho er ikkje lagd til i notatet enno.",
|
||||
"discard-edit-title": "Forkaste endringane?",
|
||||
"discard-edit-description": "Teikninga blir verande slik ho var før du opna ho.",
|
||||
"keep-drawing": "Hald fram med å teikne",
|
||||
"discard": "Forkast",
|
||||
"open-failed": "Kunne ikkje opne teikninga. Prøv på nytt.",
|
||||
"export-failed": "Kunne ikkje lagre teikninga. Prøv på nytt.",
|
||||
"image-failed": "Kunne ikkje leggje biletet til i teikninga.",
|
||||
"saved-without-drawing": "Notatet er lagra, men teikninga er ikkje det. Lagre på nytt for å prøve igjen."
|
||||
},
|
||||
"new-memo": "Nytt notat",
|
||||
"no-changes-detected": "Ingen endringar funne",
|
||||
"save": "Lagre",
|
||||
|
||||
@@ -190,10 +190,51 @@
|
||||
"image-upload-failed": "Niektórych obrazów nie udało się przesłać. Spróbuj ponownie lub zachowaj przesłane pliki jako załączniki.",
|
||||
"image-upload-stopped": "Zatrzymano przesyłanie obrazu {{completed}}/{{total}}",
|
||||
"insert-image": "Wstaw obraz",
|
||||
"drawing": "Rysunek",
|
||||
"keep-as-attachments": "Zachowaj jako załącznik",
|
||||
"uploading-inline-image": "Przesyłanie do treści",
|
||||
"uploading-images": "Przesyłanie obrazów {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Nowy rysunek",
|
||||
"edit": "Edytuj rysunek",
|
||||
"tools": "Narzędzia",
|
||||
"tool-select": "Zaznacz",
|
||||
"tool-pen": "Pióro",
|
||||
"tool-eraser": "Gumka",
|
||||
"tool-rectangle": "Prostokąt",
|
||||
"tool-ellipse": "Elipsa",
|
||||
"tool-arrow": "Strzałka",
|
||||
"tool-text": "Tekst",
|
||||
"style": "Kolor i grubość",
|
||||
"color": "Kolor",
|
||||
"width": "Grubość",
|
||||
"width-thin": "Cienka",
|
||||
"width-medium": "Średnia",
|
||||
"width-thick": "Gruba",
|
||||
"color-ink": "Atrament",
|
||||
"color-gray": "Szary",
|
||||
"color-red": "Czerwony",
|
||||
"color-orange": "Pomarańczowy",
|
||||
"color-green": "Zielony",
|
||||
"color-teal": "Morski",
|
||||
"color-blue": "Niebieski",
|
||||
"color-violet": "Fioletowy",
|
||||
"undo": "Cofnij",
|
||||
"redo": "Ponów",
|
||||
"zoom-to-fit": "Dopasuj do ekranu",
|
||||
"done": "Gotowe",
|
||||
"discard-title": "Odrzucić ten rysunek?",
|
||||
"discard-description": "Nie został jeszcze dodany do notatki.",
|
||||
"discard-edit-title": "Odrzucić zmiany?",
|
||||
"discard-edit-description": "Rysunek pozostanie taki, jak przed otwarciem.",
|
||||
"keep-drawing": "Rysuj dalej",
|
||||
"discard": "Odrzuć",
|
||||
"open-failed": "Nie udało się otworzyć rysunku. Spróbuj ponownie.",
|
||||
"export-failed": "Nie udało się zapisać rysunku. Spróbuj ponownie.",
|
||||
"image-failed": "Nie udało się dodać obrazu do rysunku.",
|
||||
"saved-without-drawing": "Notatka została zapisana, ale rysunek nie. Zapisz ponownie, aby spróbować jeszcze raz."
|
||||
},
|
||||
"no-changes-detected": "Brak wykrytych zmian",
|
||||
"save": "Zapisz",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -176,11 +176,52 @@
|
||||
"image-upload-failed": "Algumas imagens não puderam ser carregadas. Tente novamente ou mantenha os arquivos carregados como anexos.",
|
||||
"image-upload-stopped": "Upload de imagem interrompido {{completed}}/{{total}}",
|
||||
"insert-image": "Inserir imagem",
|
||||
"drawing": "Desenho",
|
||||
"keep-as-attachments": "Manter como anexos",
|
||||
"retry-image-upload": "Tentar novamente",
|
||||
"uploading-inline-image": "Carregando conteúdo",
|
||||
"uploading-images": "Carregando imagens {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Novo desenho",
|
||||
"edit": "Editar desenho",
|
||||
"tools": "Ferramentas",
|
||||
"tool-select": "Selecionar",
|
||||
"tool-pen": "Caneta",
|
||||
"tool-eraser": "Borracha",
|
||||
"tool-rectangle": "Retângulo",
|
||||
"tool-ellipse": "Elipse",
|
||||
"tool-arrow": "Seta",
|
||||
"tool-text": "Texto",
|
||||
"style": "Cor e espessura",
|
||||
"color": "Cor",
|
||||
"width": "Espessura",
|
||||
"width-thin": "Fina",
|
||||
"width-medium": "Média",
|
||||
"width-thick": "Grossa",
|
||||
"color-ink": "Tinta",
|
||||
"color-gray": "Cinza",
|
||||
"color-red": "Vermelho",
|
||||
"color-orange": "Laranja",
|
||||
"color-green": "Verde",
|
||||
"color-teal": "Verde-azulado",
|
||||
"color-blue": "Azul",
|
||||
"color-violet": "Violeta",
|
||||
"undo": "Desfazer",
|
||||
"redo": "Refazer",
|
||||
"zoom-to-fit": "Ajustar à tela",
|
||||
"done": "Concluído",
|
||||
"discard-title": "Descartar este desenho?",
|
||||
"discard-description": "Ele ainda não foi adicionado ao memo.",
|
||||
"discard-edit-title": "Descartar as alterações?",
|
||||
"discard-edit-description": "O desenho continuará como estava antes de você abri-lo.",
|
||||
"keep-drawing": "Continuar desenhando",
|
||||
"discard": "Descartar",
|
||||
"open-failed": "Não foi possível abrir o desenho. Tente novamente.",
|
||||
"export-failed": "Não foi possível salvar o desenho. Tente novamente.",
|
||||
"image-failed": "Não foi possível adicionar a imagem ao desenho.",
|
||||
"saved-without-drawing": "O memo foi salvo, mas o desenho não. Salve novamente para tentar de novo."
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "Gravação de áudio",
|
||||
"attachment-label-with-time": "Gravação de áudio {{time}}",
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Algumas imagens não puderam ser carregadas. Tente novamente ou mantenha os ficheiros carregados como anexos.",
|
||||
"image-upload-stopped": "Upload de imagem interrompido {{completed}}/{{total}}",
|
||||
"insert-image": "Inserir imagem",
|
||||
"drawing": "Desenho",
|
||||
"keep-as-attachments": "Manter como anexos",
|
||||
"uploading-inline-image": "A carregar conteúdo",
|
||||
"uploading-images": "A carregar imagens {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Novo desenho",
|
||||
"edit": "Editar desenho",
|
||||
"tools": "Ferramentas",
|
||||
"tool-select": "Selecionar",
|
||||
"tool-pen": "Caneta",
|
||||
"tool-eraser": "Borracha",
|
||||
"tool-rectangle": "Retângulo",
|
||||
"tool-ellipse": "Elipse",
|
||||
"tool-arrow": "Seta",
|
||||
"tool-text": "Texto",
|
||||
"style": "Cor e espessura",
|
||||
"color": "Cor",
|
||||
"width": "Espessura",
|
||||
"width-thin": "Fina",
|
||||
"width-medium": "Média",
|
||||
"width-thick": "Grossa",
|
||||
"color-ink": "Tinta",
|
||||
"color-gray": "Cinzento",
|
||||
"color-red": "Vermelho",
|
||||
"color-orange": "Laranja",
|
||||
"color-green": "Verde",
|
||||
"color-teal": "Azul-petróleo",
|
||||
"color-blue": "Azul",
|
||||
"color-violet": "Violeta",
|
||||
"undo": "Anular",
|
||||
"redo": "Refazer",
|
||||
"zoom-to-fit": "Ajustar ao ecrã",
|
||||
"done": "Concluído",
|
||||
"discard-title": "Descartar este desenho?",
|
||||
"discard-description": "Ainda não foi adicionado ao memo.",
|
||||
"discard-edit-title": "Descartar as alterações?",
|
||||
"discard-edit-description": "O desenho fica como estava antes de o abrir.",
|
||||
"keep-drawing": "Continuar a desenhar",
|
||||
"discard": "Descartar",
|
||||
"open-failed": "Não foi possível abrir o desenho. Tente novamente.",
|
||||
"export-failed": "Não foi possível guardar o desenho. Tente novamente.",
|
||||
"image-failed": "Não foi possível adicionar a imagem ao desenho.",
|
||||
"saved-without-drawing": "O memo foi guardado, mas o desenho não. Guarde novamente para tentar de novo."
|
||||
},
|
||||
"no-changes-detected": "Nenhuma alteração detetada",
|
||||
"save": "Guardar",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Unele imagini nu au putut fi încărcate. Încercați din nou sau păstrați fișierele încărcate ca atașamente.",
|
||||
"image-upload-stopped": "Încărcarea imaginii a fost oprită {{completed}}/{{total}}",
|
||||
"insert-image": "Inserare imagine",
|
||||
"drawing": "Desen",
|
||||
"keep-as-attachments": "Păstrare ca atașamente",
|
||||
"uploading-inline-image": "Se încarcă în conținut",
|
||||
"uploading-images": "Se încarcă imagini {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Desen nou",
|
||||
"edit": "Editați desenul",
|
||||
"tools": "Instrumente",
|
||||
"tool-select": "Selectare",
|
||||
"tool-pen": "Stilou",
|
||||
"tool-eraser": "Radieră",
|
||||
"tool-rectangle": "Dreptunghi",
|
||||
"tool-ellipse": "Elipsă",
|
||||
"tool-arrow": "Săgeată",
|
||||
"tool-text": "Text",
|
||||
"style": "Culoare și grosime",
|
||||
"color": "Culoare",
|
||||
"width": "Grosime",
|
||||
"width-thin": "Subțire",
|
||||
"width-medium": "Medie",
|
||||
"width-thick": "Groasă",
|
||||
"color-ink": "Cerneală",
|
||||
"color-gray": "Gri",
|
||||
"color-red": "Roșu",
|
||||
"color-orange": "Portocaliu",
|
||||
"color-green": "Verde",
|
||||
"color-teal": "Turcoaz",
|
||||
"color-blue": "Albastru",
|
||||
"color-violet": "Violet",
|
||||
"undo": "Anulare",
|
||||
"redo": "Refacere",
|
||||
"zoom-to-fit": "Încadrare în fereastră",
|
||||
"done": "Gata",
|
||||
"discard-title": "Renunțați la acest desen?",
|
||||
"discard-description": "Nu a fost încă adăugat la notă.",
|
||||
"discard-edit-title": "Renunțați la modificări?",
|
||||
"discard-edit-description": "Desenul rămâne așa cum era înainte să îl deschideți.",
|
||||
"keep-drawing": "Continuați să desenați",
|
||||
"discard": "Renunțați",
|
||||
"open-failed": "Desenul nu a putut fi deschis. Încercați din nou.",
|
||||
"export-failed": "Desenul nu a putut fi salvat. Încercați din nou.",
|
||||
"image-failed": "Imaginea nu a putut fi adăugată la desen.",
|
||||
"saved-without-drawing": "Nota a fost salvată, dar desenul nu. Salvați din nou pentru a reîncerca."
|
||||
},
|
||||
"no-changes-detected": "Nu au fost detectate modificări",
|
||||
"save": "Salva",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -174,11 +174,52 @@
|
||||
"image-upload-failed": "Не удалось загрузить некоторые изображения. Повторите попытку или сохраните загруженные файлы как вложения.",
|
||||
"image-upload-stopped": "Загрузка изображений остановлена: {{completed}}/{{total}}",
|
||||
"insert-image": "Вставить изображение",
|
||||
"drawing": "Рисунок",
|
||||
"keep-as-attachments": "Сохранить как вложения",
|
||||
"retry-image-upload": "Повторить",
|
||||
"uploading-inline-image": "Загрузка в содержимое",
|
||||
"uploading-images": "Загрузка изображений: {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Новый рисунок",
|
||||
"edit": "Изменить рисунок",
|
||||
"tools": "Инструменты",
|
||||
"tool-select": "Выделение",
|
||||
"tool-pen": "Перо",
|
||||
"tool-eraser": "Ластик",
|
||||
"tool-rectangle": "Прямоугольник",
|
||||
"tool-ellipse": "Эллипс",
|
||||
"tool-arrow": "Стрелка",
|
||||
"tool-text": "Текст",
|
||||
"style": "Цвет и толщина",
|
||||
"color": "Цвет",
|
||||
"width": "Толщина",
|
||||
"width-thin": "Тонкая",
|
||||
"width-medium": "Средняя",
|
||||
"width-thick": "Толстая",
|
||||
"color-ink": "Чернила",
|
||||
"color-gray": "Серый",
|
||||
"color-red": "Красный",
|
||||
"color-orange": "Оранжевый",
|
||||
"color-green": "Зелёный",
|
||||
"color-teal": "Бирюзовый",
|
||||
"color-blue": "Синий",
|
||||
"color-violet": "Фиолетовый",
|
||||
"undo": "Отменить",
|
||||
"redo": "Повторить",
|
||||
"zoom-to-fit": "Вписать в окно",
|
||||
"done": "Готово",
|
||||
"discard-title": "Удалить этот рисунок?",
|
||||
"discard-description": "Он ещё не добавлен в заметку.",
|
||||
"discard-edit-title": "Отменить изменения?",
|
||||
"discard-edit-description": "Рисунок останется таким, каким был до открытия.",
|
||||
"keep-drawing": "Продолжить рисовать",
|
||||
"discard": "Удалить",
|
||||
"open-failed": "Не удалось открыть рисунок. Повторите попытку.",
|
||||
"export-failed": "Не удалось сохранить рисунок. Повторите попытку.",
|
||||
"image-failed": "Не удалось добавить изображение в рисунок.",
|
||||
"saved-without-drawing": "Заметка сохранена, а рисунок — нет. Сохраните ещё раз, чтобы повторить попытку."
|
||||
},
|
||||
"no-changes-detected": "Изменений не обнаружено",
|
||||
"save": "Сохранить",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Niektoré obrázky sa nepodarilo nahrať. Skúste to znova alebo ponechajte nahrané súbory ako prílohy.",
|
||||
"image-upload-stopped": "Nahrávanie obrázka zastavené {{completed}}/{{total}}",
|
||||
"insert-image": "Vložiť obrázok",
|
||||
"drawing": "Kresba",
|
||||
"keep-as-attachments": "Ponechať ako prílohy",
|
||||
"uploading-inline-image": "Nahrávanie do obsahu",
|
||||
"uploading-images": "Nahrávanie obrázkov {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Nová kresba",
|
||||
"edit": "Upraviť kresbu",
|
||||
"tools": "Nástroje",
|
||||
"tool-select": "Výber",
|
||||
"tool-pen": "Pero",
|
||||
"tool-eraser": "Guma",
|
||||
"tool-rectangle": "Obdĺžnik",
|
||||
"tool-ellipse": "Elipsa",
|
||||
"tool-arrow": "Šípka",
|
||||
"tool-text": "Text",
|
||||
"style": "Farba a hrúbka",
|
||||
"color": "Farba",
|
||||
"width": "Hrúbka",
|
||||
"width-thin": "Tenká",
|
||||
"width-medium": "Stredná",
|
||||
"width-thick": "Hrubá",
|
||||
"color-ink": "Atrament",
|
||||
"color-gray": "Sivá",
|
||||
"color-red": "Červená",
|
||||
"color-orange": "Oranžová",
|
||||
"color-green": "Zelená",
|
||||
"color-teal": "Modrozelená",
|
||||
"color-blue": "Modrá",
|
||||
"color-violet": "Fialová",
|
||||
"undo": "Späť",
|
||||
"redo": "Znova",
|
||||
"zoom-to-fit": "Prispôsobiť oknu",
|
||||
"done": "Hotovo",
|
||||
"discard-title": "Zahodiť túto kresbu?",
|
||||
"discard-description": "Zatiaľ nebola pridaná do poznámky.",
|
||||
"discard-edit-title": "Zahodiť zmeny?",
|
||||
"discard-edit-description": "Kresba zostane taká, aká bola pred otvorením.",
|
||||
"keep-drawing": "Pokračovať v kreslení",
|
||||
"discard": "Zahodiť",
|
||||
"open-failed": "Kresbu sa nepodarilo otvoriť. Skúste to znova.",
|
||||
"export-failed": "Kresbu sa nepodarilo uložiť. Skúste to znova.",
|
||||
"image-failed": "Obrázok sa nepodarilo pridať do kresby.",
|
||||
"saved-without-drawing": "Poznámka je uložená, ale kresba nie. Pre nový pokus uložte znova."
|
||||
},
|
||||
"no-changes-detected": "Nezistili sa žiadne zmeny",
|
||||
"save": "Uložiť",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Nekaterih slik ni bilo mogoče naložiti. Poskusite znova ali pa naložene datoteke shranite kot priloge.",
|
||||
"image-upload-stopped": "Nalaganje slike ustavljeno {{completed}}/{{total}}",
|
||||
"insert-image": "Vstavi sliko",
|
||||
"drawing": "Risba",
|
||||
"keep-as-attachments": "Obdrži kot priloge",
|
||||
"uploading-inline-image": "Nalaganje v vsebino",
|
||||
"uploading-images": "Nalaganje slik {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Nova risba",
|
||||
"edit": "Uredi risbo",
|
||||
"tools": "Orodja",
|
||||
"tool-select": "Izbor",
|
||||
"tool-pen": "Pero",
|
||||
"tool-eraser": "Radirka",
|
||||
"tool-rectangle": "Pravokotnik",
|
||||
"tool-ellipse": "Elipsa",
|
||||
"tool-arrow": "Puščica",
|
||||
"tool-text": "Besedilo",
|
||||
"style": "Barva in debelina",
|
||||
"color": "Barva",
|
||||
"width": "Debelina",
|
||||
"width-thin": "Tanka",
|
||||
"width-medium": "Srednja",
|
||||
"width-thick": "Debela",
|
||||
"color-ink": "Črnilo",
|
||||
"color-gray": "Siva",
|
||||
"color-red": "Rdeča",
|
||||
"color-orange": "Oranžna",
|
||||
"color-green": "Zelena",
|
||||
"color-teal": "Modrozelena",
|
||||
"color-blue": "Modra",
|
||||
"color-violet": "Vijolična",
|
||||
"undo": "Razveljavi",
|
||||
"redo": "Uveljavi",
|
||||
"zoom-to-fit": "Prilagodi oknu",
|
||||
"done": "Končano",
|
||||
"discard-title": "Zavrzi to risbo?",
|
||||
"discard-description": "Beležki še ni bila dodana.",
|
||||
"discard-edit-title": "Zavrzi spremembe?",
|
||||
"discard-edit-description": "Risba ostane takšna, kot je bila pred odprtjem.",
|
||||
"keep-drawing": "Nadaljuj z risanjem",
|
||||
"discard": "Zavrzi",
|
||||
"open-failed": "Risbe ni bilo mogoče odpreti. Poskusite znova.",
|
||||
"export-failed": "Risbe ni bilo mogoče shraniti. Poskusite znova.",
|
||||
"image-failed": "Slike ni bilo mogoče dodati risbi.",
|
||||
"saved-without-drawing": "Beležka je shranjena, risba pa ne. Za ponoven poskus znova shranite."
|
||||
},
|
||||
"no-changes-detected": "Ni zaznanih sprememb",
|
||||
"save": "Shrani",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -213,10 +213,51 @@
|
||||
"image-upload-failed": "Неке слике нису могле бити отпремљене. Покушајте поново или задржите отпремљене датотеке као прилоге.",
|
||||
"image-upload-stopped": "Отпремање слике је заустављено {{completed}}/{{total}}",
|
||||
"insert-image": "Уметни слику",
|
||||
"drawing": "Цртеж",
|
||||
"keep-as-attachments": "Сачувај као прилоге",
|
||||
"uploading-inline-image": "Отпремање у садржај",
|
||||
"uploading-images": "Отпремање слика {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Нови цртеж",
|
||||
"edit": "Уреди цртеж",
|
||||
"tools": "Алатке",
|
||||
"tool-select": "Избор",
|
||||
"tool-pen": "Оловка",
|
||||
"tool-eraser": "Гумица",
|
||||
"tool-rectangle": "Правоугаоник",
|
||||
"tool-ellipse": "Елипса",
|
||||
"tool-arrow": "Стрелица",
|
||||
"tool-text": "Текст",
|
||||
"style": "Боја и дебљина",
|
||||
"color": "Боја",
|
||||
"width": "Дебљина",
|
||||
"width-thin": "Танка",
|
||||
"width-medium": "Средња",
|
||||
"width-thick": "Дебела",
|
||||
"color-ink": "Мастило",
|
||||
"color-gray": "Сива",
|
||||
"color-red": "Црвена",
|
||||
"color-orange": "Наранџаста",
|
||||
"color-green": "Зелена",
|
||||
"color-teal": "Тиркизна",
|
||||
"color-blue": "Плава",
|
||||
"color-violet": "Љубичаста",
|
||||
"undo": "Опозови",
|
||||
"redo": "Понови",
|
||||
"zoom-to-fit": "Уклопи у прозор",
|
||||
"done": "Готово",
|
||||
"discard-title": "Одбацити овај цртеж?",
|
||||
"discard-description": "Још није додат у белешку.",
|
||||
"discard-edit-title": "Одбацити измене?",
|
||||
"discard-edit-description": "Цртеж остаје какав је био пре него што сте га отворили.",
|
||||
"keep-drawing": "Настави цртање",
|
||||
"discard": "Одбаци",
|
||||
"open-failed": "Цртеж није могуће отворити. Покушајте поново.",
|
||||
"export-failed": "Цртеж није могуће сачувати. Покушајте поново.",
|
||||
"image-failed": "Слику није могуће додати у цртеж.",
|
||||
"saved-without-drawing": "Белешка је сачувана, али цртеж није. Сачувајте поново за нови покушај."
|
||||
},
|
||||
"no-changes-detected": "Нису откривене промене",
|
||||
"save": "Сачувај",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Vissa bilder kunde inte laddas upp. Försök igen eller behåll de uppladdade filerna som bilagor.",
|
||||
"image-upload-stopped": "Bilduppladdning stoppad {{completed}}/{{total}}",
|
||||
"insert-image": "Infoga bild",
|
||||
"drawing": "Teckning",
|
||||
"keep-as-attachments": "Behåll som bilagor",
|
||||
"uploading-inline-image": "Uppladdning till innehåll",
|
||||
"uploading-images": "Uppladdning av bilder {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Ny teckning",
|
||||
"edit": "Redigera teckning",
|
||||
"tools": "Verktyg",
|
||||
"tool-select": "Markera",
|
||||
"tool-pen": "Penna",
|
||||
"tool-eraser": "Suddgummi",
|
||||
"tool-rectangle": "Rektangel",
|
||||
"tool-ellipse": "Ellips",
|
||||
"tool-arrow": "Pil",
|
||||
"tool-text": "Text",
|
||||
"style": "Färg och tjocklek",
|
||||
"color": "Färg",
|
||||
"width": "Tjocklek",
|
||||
"width-thin": "Tunn",
|
||||
"width-medium": "Medel",
|
||||
"width-thick": "Tjock",
|
||||
"color-ink": "Bläck",
|
||||
"color-gray": "Grå",
|
||||
"color-red": "Röd",
|
||||
"color-orange": "Orange",
|
||||
"color-green": "Grön",
|
||||
"color-teal": "Blågrön",
|
||||
"color-blue": "Blå",
|
||||
"color-violet": "Violett",
|
||||
"undo": "Ångra",
|
||||
"redo": "Gör om",
|
||||
"zoom-to-fit": "Anpassa till fönstret",
|
||||
"done": "Klar",
|
||||
"discard-title": "Vill du slänga teckningen?",
|
||||
"discard-description": "Den har inte lagts till i anteckningen än.",
|
||||
"discard-edit-title": "Vill du slänga ändringarna?",
|
||||
"discard-edit-description": "Teckningen förblir som den var innan du öppnade den.",
|
||||
"keep-drawing": "Fortsätt rita",
|
||||
"discard": "Släng",
|
||||
"open-failed": "Det gick inte att öppna teckningen. Försök igen.",
|
||||
"export-failed": "Det gick inte att spara teckningen. Försök igen.",
|
||||
"image-failed": "Det gick inte att lägga till bilden i teckningen.",
|
||||
"saved-without-drawing": "Anteckningen har sparats, men inte teckningen. Spara igen för att försöka på nytt."
|
||||
},
|
||||
"no-changes-detected": "Inga ändringar upptäckta",
|
||||
"save": "Spara",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -176,11 +176,52 @@
|
||||
"image-upload-failed": "ไม่สามารถอัปโหลดรูปภาพบางรูปได้ ลองใหม่อีกครั้งหรือเก็บไฟล์ที่อัปโหลดไว้เป็นไฟล์แนบ",
|
||||
"image-upload-stopped": "การอัปโหลดรูปภาพหยุดลง {{completed}}/{{total}}",
|
||||
"insert-image": "แทรกรูปภาพ",
|
||||
"drawing": "ภาพวาด",
|
||||
"keep-as-attachments": "เก็บเป็นไฟล์แนบ",
|
||||
"retry-image-upload": "ลองใหม่",
|
||||
"uploading-inline-image": "กำลังอัปโหลดไปยังเนื้อหา",
|
||||
"uploading-images": "กำลังอัปโหลดรูปภาพ {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "ภาพวาดใหม่",
|
||||
"edit": "แก้ไขภาพวาด",
|
||||
"tools": "เครื่องมือ",
|
||||
"tool-select": "เลือก",
|
||||
"tool-pen": "ปากกา",
|
||||
"tool-eraser": "ยางลบ",
|
||||
"tool-rectangle": "สี่เหลี่ยมผืนผ้า",
|
||||
"tool-ellipse": "วงรี",
|
||||
"tool-arrow": "ลูกศร",
|
||||
"tool-text": "ข้อความ",
|
||||
"style": "สีและความหนา",
|
||||
"color": "สี",
|
||||
"width": "ความหนา",
|
||||
"width-thin": "บาง",
|
||||
"width-medium": "ปานกลาง",
|
||||
"width-thick": "หนา",
|
||||
"color-ink": "หมึก",
|
||||
"color-gray": "เทา",
|
||||
"color-red": "แดง",
|
||||
"color-orange": "ส้ม",
|
||||
"color-green": "เขียว",
|
||||
"color-teal": "เขียวอมฟ้า",
|
||||
"color-blue": "น้ำเงิน",
|
||||
"color-violet": "ม่วง",
|
||||
"undo": "เลิกทำ",
|
||||
"redo": "ทำซ้ำ",
|
||||
"zoom-to-fit": "ปรับให้พอดีหน้าต่าง",
|
||||
"done": "เสร็จสิ้น",
|
||||
"discard-title": "ทิ้งภาพวาดนี้หรือไม่?",
|
||||
"discard-description": "ยังไม่ได้เพิ่มลงในบันทึก",
|
||||
"discard-edit-title": "ทิ้งการเปลี่ยนแปลงหรือไม่?",
|
||||
"discard-edit-description": "ภาพวาดจะยังคงเหมือนก่อนที่คุณเปิด",
|
||||
"keep-drawing": "วาดต่อ",
|
||||
"discard": "ทิ้ง",
|
||||
"open-failed": "ไม่สามารถเปิดภาพวาดได้ ลองอีกครั้ง",
|
||||
"export-failed": "ไม่สามารถบันทึกภาพวาดได้ ลองอีกครั้ง",
|
||||
"image-failed": "ไม่สามารถเพิ่มรูปภาพลงในภาพวาดได้",
|
||||
"saved-without-drawing": "บันทึกช่วยจำถูกบันทึกแล้ว แต่ภาพวาดยังไม่ได้บันทึก บันทึกอีกครั้งเพื่อลองใหม่"
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "การบันทึกเสียง",
|
||||
"attachment-label-with-time": "บันทึกเสียง {{time}}",
|
||||
|
||||
@@ -222,12 +222,53 @@
|
||||
"image-upload-failed": "Bazı görseller yüklenemedi. Yeniden deneyin ya da yüklenen dosyaları ek olarak tutun.",
|
||||
"image-upload-stopped": "Görsel yükleme durdu {{completed}}/{{total}}",
|
||||
"insert-image": "Görsel ekle",
|
||||
"drawing": "Çizim",
|
||||
"keep-as-attachments": "Ek olarak tut",
|
||||
"link-memo": "Not bağla",
|
||||
"retry-image-upload": "Yeniden dene",
|
||||
"uploading-inline-image": "İçeriğe yükleniyor",
|
||||
"uploading-images": "Görseller yükleniyor {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Yeni çizim",
|
||||
"edit": "Çizimi düzenle",
|
||||
"tools": "Araçlar",
|
||||
"tool-select": "Seç",
|
||||
"tool-pen": "Kalem",
|
||||
"tool-eraser": "Silgi",
|
||||
"tool-rectangle": "Dikdörtgen",
|
||||
"tool-ellipse": "Elips",
|
||||
"tool-arrow": "Ok",
|
||||
"tool-text": "Metin",
|
||||
"style": "Renk ve kalınlık",
|
||||
"color": "Renk",
|
||||
"width": "Kalınlık",
|
||||
"width-thin": "İnce",
|
||||
"width-medium": "Orta",
|
||||
"width-thick": "Kalın",
|
||||
"color-ink": "Mürekkep",
|
||||
"color-gray": "Gri",
|
||||
"color-red": "Kırmızı",
|
||||
"color-orange": "Turuncu",
|
||||
"color-green": "Yeşil",
|
||||
"color-teal": "Camgöbeği",
|
||||
"color-blue": "Mavi",
|
||||
"color-violet": "Mor",
|
||||
"undo": "Geri al",
|
||||
"redo": "Yinele",
|
||||
"zoom-to-fit": "Pencereye sığdır",
|
||||
"done": "Bitti",
|
||||
"discard-title": "Bu çizim silinsin mi?",
|
||||
"discard-description": "Henüz nota eklenmedi.",
|
||||
"discard-edit-title": "Değişiklikler silinsin mi?",
|
||||
"discard-edit-description": "Çizim, açmadan önceki hâliyle kalır.",
|
||||
"keep-drawing": "Çizmeye devam et",
|
||||
"discard": "Sil",
|
||||
"open-failed": "Çizim açılamadı. Yeniden deneyin.",
|
||||
"export-failed": "Çizim kaydedilemedi. Yeniden deneyin.",
|
||||
"image-failed": "Görsel çizime eklenemedi.",
|
||||
"saved-without-drawing": "Not kaydedildi ancak çizim kaydedilmedi. Yeniden denemek için tekrar kaydedin."
|
||||
},
|
||||
"new-memo": "Yeni not",
|
||||
"no-changes-detected": "Değişiklik yok",
|
||||
"save": "Kaydet",
|
||||
|
||||
@@ -175,10 +175,51 @@
|
||||
"image-upload-failed": "Не вдалося завантажити деякі зображення. Повторіть спробу або збережіть завантажені файли як вкладення.",
|
||||
"image-upload-stopped": "Завантаження зображення зупинено {{completed}}/{{total}}",
|
||||
"insert-image": "Вставити зображення",
|
||||
"drawing": "Малюнок",
|
||||
"keep-as-attachments": "Зберегти як вкладення",
|
||||
"uploading-inline-image": "Завантаження до контенту",
|
||||
"uploading-images": "Завантаження зображень {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Новий малюнок",
|
||||
"edit": "Редагувати малюнок",
|
||||
"tools": "Інструменти",
|
||||
"tool-select": "Виділення",
|
||||
"tool-pen": "Перо",
|
||||
"tool-eraser": "Гумка",
|
||||
"tool-rectangle": "Прямокутник",
|
||||
"tool-ellipse": "Еліпс",
|
||||
"tool-arrow": "Стрілка",
|
||||
"tool-text": "Текст",
|
||||
"style": "Колір і товщина",
|
||||
"color": "Колір",
|
||||
"width": "Товщина",
|
||||
"width-thin": "Тонка",
|
||||
"width-medium": "Середня",
|
||||
"width-thick": "Товста",
|
||||
"color-ink": "Чорнило",
|
||||
"color-gray": "Сірий",
|
||||
"color-red": "Червоний",
|
||||
"color-orange": "Помаранчевий",
|
||||
"color-green": "Зелений",
|
||||
"color-teal": "Бірюзовий",
|
||||
"color-blue": "Синій",
|
||||
"color-violet": "Фіолетовий",
|
||||
"undo": "Скасувати",
|
||||
"redo": "Повторити",
|
||||
"zoom-to-fit": "Вмістити у вікно",
|
||||
"done": "Готово",
|
||||
"discard-title": "Відкинути цей малюнок?",
|
||||
"discard-description": "Його ще не додано до нотатки.",
|
||||
"discard-edit-title": "Відкинути зміни?",
|
||||
"discard-edit-description": "Малюнок залишиться таким, яким був до відкриття.",
|
||||
"keep-drawing": "Продовжити малювати",
|
||||
"discard": "Відкинути",
|
||||
"open-failed": "Не вдалося відкрити малюнок. Повторіть спробу.",
|
||||
"export-failed": "Не вдалося зберегти малюнок. Повторіть спробу.",
|
||||
"image-failed": "Не вдалося додати зображення до малюнка.",
|
||||
"saved-without-drawing": "Нотатку збережено, а малюнок — ні. Збережіть ще раз, щоб повторити спробу."
|
||||
},
|
||||
"no-changes-detected": "Змін не виявлено",
|
||||
"save": "Зберегти",
|
||||
"audio-recorder": {
|
||||
|
||||
@@ -176,11 +176,52 @@
|
||||
"image-upload-failed": "Một số hình ảnh không thể tải lên. Hãy thử lại hoặc giữ các tệp đã tải lên dưới dạng tệp đính kèm.",
|
||||
"image-upload-stopped": "Quá trình tải ảnh dừng lại {{completed}}/{{total}}",
|
||||
"insert-image": "Chèn ảnh",
|
||||
"drawing": "Bản vẽ",
|
||||
"keep-as-attachments": "Giữ nguyên dưới dạng tệp đính kèm",
|
||||
"retry-image-upload": "Thử lại",
|
||||
"uploading-inline-image": "Đang tải nội dung lên",
|
||||
"uploading-images": "Đang tải ảnh {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "Bản vẽ mới",
|
||||
"edit": "Chỉnh sửa bản vẽ",
|
||||
"tools": "Công cụ",
|
||||
"tool-select": "Chọn",
|
||||
"tool-pen": "Bút",
|
||||
"tool-eraser": "Tẩy",
|
||||
"tool-rectangle": "Hình chữ nhật",
|
||||
"tool-ellipse": "Hình elip",
|
||||
"tool-arrow": "Mũi tên",
|
||||
"tool-text": "Văn bản",
|
||||
"style": "Màu và độ dày",
|
||||
"color": "Màu",
|
||||
"width": "Độ dày",
|
||||
"width-thin": "Mảnh",
|
||||
"width-medium": "Vừa",
|
||||
"width-thick": "Dày",
|
||||
"color-ink": "Mực",
|
||||
"color-gray": "Xám",
|
||||
"color-red": "Đỏ",
|
||||
"color-orange": "Cam",
|
||||
"color-green": "Lục",
|
||||
"color-teal": "Xanh mòng két",
|
||||
"color-blue": "Lam",
|
||||
"color-violet": "Tím",
|
||||
"undo": "Hoàn tác",
|
||||
"redo": "Làm lại",
|
||||
"zoom-to-fit": "Vừa với cửa sổ",
|
||||
"done": "Xong",
|
||||
"discard-title": "Loại bỏ bản vẽ này?",
|
||||
"discard-description": "Bản vẽ chưa được thêm vào ghi chú.",
|
||||
"discard-edit-title": "Loại bỏ các thay đổi?",
|
||||
"discard-edit-description": "Bản vẽ sẽ giữ nguyên như trước khi bạn mở.",
|
||||
"keep-drawing": "Tiếp tục vẽ",
|
||||
"discard": "Loại bỏ",
|
||||
"open-failed": "Không thể mở bản vẽ. Hãy thử lại.",
|
||||
"export-failed": "Không thể lưu bản vẽ. Hãy thử lại.",
|
||||
"image-failed": "Không thể thêm ảnh vào bản vẽ.",
|
||||
"saved-without-drawing": "Đã lưu ghi chú, nhưng chưa lưu bản vẽ. Hãy lưu lần nữa để thử lại."
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "Ghi âm",
|
||||
"attachment-label-with-time": "Ghi âm {{time}}",
|
||||
|
||||
@@ -237,12 +237,53 @@
|
||||
"image-upload-failed": "部分图片上传失败,请重试或将已上传文件保留为附件。",
|
||||
"image-upload-stopped": "图片上传已暂停 {{completed}}/{{total}}",
|
||||
"insert-image": "插入图片",
|
||||
"drawing": "绘图",
|
||||
"keep-as-attachments": "保留为附件",
|
||||
"link-memo": "链接备忘录",
|
||||
"retry-image-upload": "重试",
|
||||
"uploading-inline-image": "正在上传到正文",
|
||||
"uploading-images": "正在上传图片 {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "新建绘图",
|
||||
"edit": "编辑绘图",
|
||||
"tools": "工具",
|
||||
"tool-select": "选择",
|
||||
"tool-pen": "画笔",
|
||||
"tool-eraser": "橡皮擦",
|
||||
"tool-rectangle": "矩形",
|
||||
"tool-ellipse": "椭圆",
|
||||
"tool-arrow": "箭头",
|
||||
"tool-text": "文本",
|
||||
"style": "颜色和粗细",
|
||||
"color": "颜色",
|
||||
"width": "粗细",
|
||||
"width-thin": "细",
|
||||
"width-medium": "中",
|
||||
"width-thick": "粗",
|
||||
"color-ink": "墨色",
|
||||
"color-gray": "灰色",
|
||||
"color-red": "红色",
|
||||
"color-orange": "橙色",
|
||||
"color-green": "绿色",
|
||||
"color-teal": "青色",
|
||||
"color-blue": "蓝色",
|
||||
"color-violet": "紫色",
|
||||
"undo": "撤销",
|
||||
"redo": "重做",
|
||||
"zoom-to-fit": "缩放至适合",
|
||||
"done": "完成",
|
||||
"discard-title": "放弃此绘图?",
|
||||
"discard-description": "它尚未添加到备忘录中。",
|
||||
"discard-edit-title": "放弃所做的更改?",
|
||||
"discard-edit-description": "绘图将保持打开前的状态。",
|
||||
"keep-drawing": "继续绘图",
|
||||
"discard": "放弃",
|
||||
"open-failed": "无法打开绘图,请重试。",
|
||||
"export-failed": "无法保存绘图,请重试。",
|
||||
"image-failed": "无法将图片添加到绘图中。",
|
||||
"saved-without-drawing": "备忘录已保存,但绘图未保存。请再次保存以重试。"
|
||||
},
|
||||
"audio-recorder": {
|
||||
"attachment-label": "录音",
|
||||
"attachment-label-with-time": "录音 {{time}}",
|
||||
|
||||
@@ -267,12 +267,53 @@
|
||||
"image-upload-failed": "部分圖片上傳失敗,請重試或將已上傳檔案保留為附件。",
|
||||
"image-upload-stopped": "圖片上傳已暫停 {{completed}}/{{total}}",
|
||||
"insert-image": "插入圖片",
|
||||
"drawing": "繪圖",
|
||||
"keep-as-attachments": "保留為附件",
|
||||
"link-memo": "連結備忘錄",
|
||||
"retry-image-upload": "重試",
|
||||
"uploading-inline-image": "正在上傳到正文",
|
||||
"uploading-images": "正在上傳圖片 {{completed}}/{{total}}"
|
||||
},
|
||||
"drawing": {
|
||||
"new-title": "新增繪圖",
|
||||
"edit": "編輯繪圖",
|
||||
"tools": "工具",
|
||||
"tool-select": "選取",
|
||||
"tool-pen": "畫筆",
|
||||
"tool-eraser": "橡皮擦",
|
||||
"tool-rectangle": "矩形",
|
||||
"tool-ellipse": "橢圓",
|
||||
"tool-arrow": "箭頭",
|
||||
"tool-text": "文字",
|
||||
"style": "顏色與粗細",
|
||||
"color": "顏色",
|
||||
"width": "粗細",
|
||||
"width-thin": "細",
|
||||
"width-medium": "中",
|
||||
"width-thick": "粗",
|
||||
"color-ink": "墨色",
|
||||
"color-gray": "灰色",
|
||||
"color-red": "紅色",
|
||||
"color-orange": "橙色",
|
||||
"color-green": "綠色",
|
||||
"color-teal": "青色",
|
||||
"color-blue": "藍色",
|
||||
"color-violet": "紫色",
|
||||
"undo": "復原",
|
||||
"redo": "重做",
|
||||
"zoom-to-fit": "縮放至適當大小",
|
||||
"done": "完成",
|
||||
"discard-title": "要捨棄此繪圖嗎?",
|
||||
"discard-description": "它尚未加入備忘錄。",
|
||||
"discard-edit-title": "要捨棄變更嗎?",
|
||||
"discard-edit-description": "繪圖會維持開啟前的狀態。",
|
||||
"keep-drawing": "繼續繪圖",
|
||||
"discard": "捨棄",
|
||||
"open-failed": "無法開啟繪圖,請再試一次。",
|
||||
"export-failed": "無法儲存繪圖,請再試一次。",
|
||||
"image-failed": "無法將圖片加入繪圖。",
|
||||
"saved-without-drawing": "備忘錄已儲存,但繪圖尚未儲存。請再次儲存以重試。"
|
||||
},
|
||||
"new-memo": "新增備忘錄",
|
||||
"no-changes-detected": "未發現變更",
|
||||
"save": "儲存",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -8,6 +8,16 @@ export const getAttachmentUrl = (attachment: Attachment) => {
|
||||
return `${window.location.origin}/file/${attachment.name}/${encodeURIComponent(attachment.filename)}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Downloads an attachment's original file (never the thumbnail) with the session's
|
||||
* credentials. Rejects when the server refuses it.
|
||||
*/
|
||||
export const fetchAttachmentFile = async (attachment: Attachment, signal?: AbortSignal): Promise<Response> => {
|
||||
const response = await fetch(getAttachmentUrl(attachment), { signal, credentials: "same-origin" });
|
||||
if (!response.ok) throw new Error(`Failed to download ${attachment.filename} (${response.status})`);
|
||||
return response;
|
||||
};
|
||||
|
||||
// Appends a thumbnail or motion selector only to share-mode links; other external links fall back to the server-managed attachment URL.
|
||||
const withShareTokenParam = (externalLink: string | undefined, key: string): string | undefined => {
|
||||
if (!externalLink) {
|
||||
|
||||
@@ -11,3 +11,6 @@ export const isSuperUser = (user: User | undefined) => {
|
||||
export const canManageMemo = (memo: { creator: string }, user: User | undefined): boolean => {
|
||||
return !!user && (memo.creator === user.name || !!isSuperUser(user));
|
||||
};
|
||||
|
||||
/** Whether the user may change an attachment's content: its uploader, or an instance admin. */
|
||||
export const canManageAttachment = (attachment: { creator: string }, user: User | undefined): boolean => canManageMemo(attachment, user);
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { LocalFile } from "@/components/MemoEditor/edit/types/attachment";
|
||||
import { AttachmentSchema } from "@/types/proto/api/attachment_service_pb";
|
||||
|
||||
const mocks = vi.hoisted(() => ({ uploadAttachment: vi.fn() }));
|
||||
|
||||
vi.mock("@/connect", () => ({
|
||||
attachmentServiceClient: { uploadAttachment: mocks.uploadAttachment },
|
||||
}));
|
||||
|
||||
import {
|
||||
DrawingNotSavedError,
|
||||
type MemoSaveOperations,
|
||||
memoService,
|
||||
mergeUploadedAttachments,
|
||||
} from "@/components/MemoEditor/edit/services/memoService";
|
||||
import { uploadService } from "@/components/MemoEditor/edit/services/uploadService";
|
||||
import { createInitialState } from "@/components/MemoEditor/edit/state/types";
|
||||
import { type Memo, MemoSchema } from "@/types/proto/api/memo_service_pb";
|
||||
|
||||
const attachment = (name: string, filename = `${name}.png`) => create(AttachmentSchema, { name, filename, type: "image/png" });
|
||||
|
||||
describe("replacing an attachment's content", () => {
|
||||
it("uploads an edit over the attachment it replaces", async () => {
|
||||
const replaced = attachment("attachments/drawing", "drawing-2.canvas.png");
|
||||
mocks.uploadAttachment
|
||||
.mockResolvedValueOnce({ uploadId: "u1", committedSize: 0n, maxChunkSize: 1024 })
|
||||
.mockResolvedValueOnce({ uploadId: "u1", committedSize: 4n, attachment: replaced });
|
||||
const edit: LocalFile = {
|
||||
file: new File(["edit"], "drawing-2.canvas.png", { type: "image/png" }),
|
||||
previewUrl: "blob:edit",
|
||||
replaces: "attachments/drawing",
|
||||
};
|
||||
|
||||
await expect(uploadService.uploadFile(edit)).resolves.toBe(replaced);
|
||||
|
||||
const [request] = mocks.uploadAttachment.mock.calls[0];
|
||||
expect(request.upload.case).toBe("spec");
|
||||
expect(request.upload.value.replaceAttachment).toBe("attachments/drawing");
|
||||
});
|
||||
|
||||
it("starts a new attachment when nothing is replaced", async () => {
|
||||
mocks.uploadAttachment
|
||||
.mockResolvedValueOnce({ uploadId: "u2", committedSize: 0n, maxChunkSize: 1024 })
|
||||
.mockResolvedValueOnce({ uploadId: "u2", committedSize: 5n, attachment: attachment("attachments/new") });
|
||||
|
||||
await uploadService.uploadFile({ file: new File(["photo"], "photo.png", { type: "image/png" }), previewUrl: "blob:photo" });
|
||||
|
||||
expect(mocks.uploadAttachment.mock.calls[0][0].upload.value.replaceAttachment).toBe("");
|
||||
});
|
||||
|
||||
it("puts a replaced attachment back in its place and appends new ones", () => {
|
||||
const first = attachment("attachments/first");
|
||||
const drawing = attachment("attachments/drawing", "drawing-1.canvas.png");
|
||||
const last = attachment("attachments/last");
|
||||
const edited = attachment("attachments/drawing", "drawing-2.canvas.png");
|
||||
const added = attachment("attachments/added");
|
||||
|
||||
expect(mergeUploadedAttachments([first, drawing, last], [edited, added])).toEqual([first, edited, last, added]);
|
||||
});
|
||||
|
||||
describe("saving a memo with an edited drawing", () => {
|
||||
const saved = attachment("attachments/drawing", "drawing-1.canvas.png");
|
||||
const edited = attachment("attachments/drawing", "drawing-2.canvas.png");
|
||||
const memo = create(MemoSchema, {
|
||||
name: "memos/m",
|
||||
content: "hello",
|
||||
visibility: createInitialState().metadata.visibility,
|
||||
attachments: [saved],
|
||||
});
|
||||
const edit: LocalFile = {
|
||||
file: new File(["edit"], "drawing-2.canvas.png", { type: "image/png" }),
|
||||
previewUrl: "blob:edit",
|
||||
replaces: saved.name,
|
||||
};
|
||||
const draft = (content: string) => {
|
||||
const state = createInitialState();
|
||||
return { ...state, content, localFiles: [edit], metadata: { ...state.metadata, attachments: [saved] } };
|
||||
};
|
||||
const order: string[] = [];
|
||||
const operations = (updateMemo: MemoSaveOperations["updateMemo"]): MemoSaveOperations => ({
|
||||
getMemo: vi.fn(async () => memo),
|
||||
updateMemo: vi.fn(async (update, mask) => {
|
||||
order.push(`update ${mask.join(",")}`);
|
||||
return updateMemo(update, mask);
|
||||
}),
|
||||
createMemo: vi.fn(async (data: Memo) => {
|
||||
order.push("create");
|
||||
return create(MemoSchema, { ...data, name: "memos/new" });
|
||||
}),
|
||||
});
|
||||
const mockReplacementUpload = () =>
|
||||
mocks.uploadAttachment.mockImplementation(async (request) => {
|
||||
if (request.upload.case === "spec") {
|
||||
order.push(`upload over ${request.upload.value.replaceAttachment}`);
|
||||
return { uploadId: "u", committedSize: 0n, maxChunkSize: 1024 };
|
||||
}
|
||||
return { uploadId: "u", committedSize: 4n, attachment: edited };
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
order.length = 0;
|
||||
mocks.uploadAttachment.mockReset();
|
||||
});
|
||||
|
||||
it("replaces the drawing only after the memo itself is saved", async () => {
|
||||
mockReplacementUpload();
|
||||
const ops = operations(async () => create(MemoSchema, { ...memo, content: "changed", attachments: [edited] }));
|
||||
|
||||
const result = await memoService.save(draft("changed"), { memoName: memo.name }, ops);
|
||||
|
||||
expect(order).toEqual(["update content,update_time", `upload over ${saved.name}`, "update update_time"]);
|
||||
expect(result.hasChanges).toBe(true);
|
||||
// The refresh sends no attachment list, so an attachment added elsewhere meanwhile stays.
|
||||
const [refresh] = vi.mocked(ops.updateMemo).mock.calls[1];
|
||||
expect(refresh.attachments).toBeUndefined();
|
||||
});
|
||||
|
||||
it("leaves the saved drawing untouched when the memo save is refused", async () => {
|
||||
mockReplacementUpload();
|
||||
const ops = operations(async () => {
|
||||
throw new Error("permission denied");
|
||||
});
|
||||
|
||||
await expect(memoService.save(draft("changed"), { memoName: memo.name }, ops)).rejects.toThrow("permission denied");
|
||||
|
||||
expect(order).toEqual(["update content,update_time"]);
|
||||
expect(mocks.uploadAttachment).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("saves a drawing edit on its own", async () => {
|
||||
mockReplacementUpload();
|
||||
const ops = operations(async () => create(MemoSchema, { ...memo, attachments: [edited] }));
|
||||
|
||||
const result = await memoService.save(draft("hello"), { memoName: memo.name }, ops);
|
||||
|
||||
expect(order).toEqual([`upload over ${saved.name}`, "update update_time"]);
|
||||
expect(result.hasChanges).toBe(true);
|
||||
});
|
||||
|
||||
it("reports a drawing that failed after the rest of the memo saved", async () => {
|
||||
mocks.uploadAttachment.mockRejectedValue(new Error("offline"));
|
||||
const ops = operations(async () => create(MemoSchema, { ...memo, content: "changed" }));
|
||||
|
||||
await expect(memoService.save(draft("changed"), { memoName: memo.name }, ops)).rejects.toBeInstanceOf(DrawingNotSavedError);
|
||||
expect(order).toEqual(["update content,update_time"]);
|
||||
});
|
||||
|
||||
it("reports a plain failure when the drawing was the only change", async () => {
|
||||
mocks.uploadAttachment.mockRejectedValue(new Error("offline"));
|
||||
const ops = operations(async () => memo);
|
||||
|
||||
const saving = memoService.save(draft("hello"), { memoName: memo.name }, ops);
|
||||
await expect(saving).rejects.toThrow("offline");
|
||||
await expect(saving).rejects.not.toBeInstanceOf(DrawingNotSavedError);
|
||||
});
|
||||
|
||||
it("replaces before creating a new memo, so a failed replacement creates nothing", async () => {
|
||||
mocks.uploadAttachment.mockRejectedValue(new Error("offline"));
|
||||
const ops = operations(async () => memo);
|
||||
|
||||
await expect(memoService.save(draft("hello"), {}, ops)).rejects.toThrow("offline");
|
||||
|
||||
expect(ops.createMemo).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user