A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add attachment progress
thecodrr2c17896150c4
diff --git a/packages/editor/dist/extensions/attachment/attachment.d.ts b/packages/editor/dist/extensions/attachment/attachment.d.tsindex 3d3acbe15..5fd736538 100644--- a/packages/editor/dist/extensions/attachment/attachment.d.ts+++ b/packages/editor/dist/extensions/attachment/attachment.d.ts@@ -2,17 +2,23 @@ import { Node } from "@tiptap/core";export interface AttachmentOptions {onDownloadAttachment: (attachment: Attachment) => boolean;}-export declare type Attachment = {+export declare type Attachment = AttachmentProgress & {hash: string;filename: string;type: string;size: number;};+export declare type AttachmentProgress = {+ progress: number;+ type: "upload" | "download";+ hash: string;+};declare module "@tiptap/core" {interface Commands<ReturnType> {attachment: {insertAttachment: (attachment: Attachment) => ReturnType;downloadAttachment: (attachment: Attachment) => ReturnType;+ setProgress: (progress: AttachmentProgress) => ReturnType;};}}diff --git a/packages/editor/dist/extensions/attachment/attachment.js b/packages/editor/dist/extensions/attachment/attachment.jsindex 79d300f74..af3599596 100644--- a/packages/editor/dist/extensions/attachment/attachment.js+++ b/packages/editor/dist/extensions/attachment/attachment.js@@ -1,5 +1,16 @@+var __values = (this && this.__values) || function(o) {+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;+ if (m) return m.call(o);+ if (o && typeof o.length === "number") return {+ next: function () {+ if (o && i >= o.length) o = void 0;+ return { value: o && o[i++], done: !o };+ }+ };+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");+};import { Node, mergeAttributes } from "@tiptap/core";-import { ReactNodeViewRenderer } from "@tiptap/react";+import { findChildren, ReactNodeViewRenderer } from "@tiptap/react";import { AttachmentComponent } from "./component";export var AttachmentNode = Node.create({name: "attachment",@@ -56,6 +67,36 @@ export var AttachmentNode = Node.create({return _this.options.onDownloadAttachment(attachment);};},+ setProgress: function (options) {+ return function (_a) {+ var e_1, _b;+ var state = _a.state, tr = _a.tr, dispatch = _a.dispatch;+ var hash = options.hash, progress = options.progress, type = options.type;+ var attachments = findChildren(state.doc, function (node) {+ return (node.type.name === "attachment" || node.type.name === "image") &&+ node.attrs.hash === hash;+ });+ try {+ for (var attachments_1 = __values(attachments), attachments_1_1 = attachments_1.next(); !attachments_1_1.done; attachments_1_1 = attachments_1.next()) {+ var attachment = attachments_1_1.value;+ tr.setNodeMarkup(attachment.pos, attachment.node.type, {+ progress: progress,+ type: type,+ });+ }+ }+ catch (e_1_1) { e_1 = { error: e_1_1 }; }+ finally {+ try {+ if (attachments_1_1 && !attachments_1_1.done && (_b = attachments_1.return)) _b.call(attachments_1);+ }+ finally { if (e_1) throw e_1.error; }+ }+ if (dispatch)+ dispatch(tr);+ return true;+ };+ },};},// addInputRules() {diff --git a/packages/editor/src/extensions/attachment/attachment.ts b/packages/editor/src/extensions/attachment/attachment.tsindex e7310cf23..00c8b8e22 100644--- a/packages/editor/src/extensions/attachment/attachment.ts+++ b/packages/editor/src/extensions/attachment/attachment.ts@@ -1,5 +1,5 @@import { Node, nodeInputRule, mergeAttributes } from "@tiptap/core";-import { ReactNodeViewRenderer } from "@tiptap/react";+import { findChildren, ReactNodeViewRenderer } from "@tiptap/react";import { Attribute } from "@tiptap/core";import { AttachmentComponent } from "./component";@@ -8,18 +8,25 @@ export interface AttachmentOptions {onDownloadAttachment: (attachment: Attachment) => boolean;}-export type Attachment = {+export type Attachment = AttachmentProgress & {hash: string;filename: string;type: string;size: number;};+export type AttachmentProgress = {+ progress: number;+ type: "upload" | "download";+ hash: string;+};+declare module "@tiptap/core" {interface Commands<ReturnType> {attachment: {insertAttachment: (attachment: Attachment) => ReturnType;downloadAttachment: (attachment: Attachment) => ReturnType;+ setProgress: (progress: AttachmentProgress) => ReturnType;};}}@@ -84,6 +91,25 @@ export const AttachmentNode = Node.create<AttachmentOptions>({({}) => {return this.options.onDownloadAttachment(attachment);},+ setProgress:+ (options) =>+ ({ state, tr, dispatch }) => {+ const { hash, progress, type } = options;+ const attachments = findChildren(+ state.doc,+ (node) =>+ (node.type.name === "attachment" || node.type.name === "image") &&+ node.attrs.hash === hash+ );+ for (const attachment of attachments) {+ tr.setNodeMarkup(attachment.pos, attachment.node.type, {+ progress,+ type,+ });+ }+ if (dispatch) dispatch(tr);+ return true;+ },};},diff --git a/packages/editor/toolbar.md b/packages/editor/toolbar.mdindex d57a22864..ae34223b4 100644--- a/packages/editor/toolbar.md+++ b/packages/editor/toolbar.md@@ -49,11 +49,11 @@ Interaction Elements:Total Tools:- [x] bold italic underline strikethrough inlinecode-- [x] fontselect (50% done)+- [x] fontselect- [x] blockquote (styling left)- [x] codeblock-- [x] fontsizeselect (50% done)-- [x] formatselect (50% done)+- [x] fontsizeselect+- [x] formatselect- [x] alignleft aligncenter alignright alignjustify- [] outdent indent- [x] subscript superscript@@ -69,4 +69,4 @@ Total Tools:- [] media- [x] table- [x] ltr rtl-- [] searchreplace+- [x] searchreplace