@yoopta/file 4.9.9 → 6.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,18 @@
1
- import { YooEditor, YooptaPathIndex } from '@yoopta/editor';
2
- import { FileElement, FileElementProps } from '../types';
1
+ import type { YooEditor, YooptaPathIndex } from '@yoopta/editor';
2
+ import type { FileElement, FileElementProps } from '../types';
3
3
  type FileElementOptions = {
4
- props?: Omit<FileElementProps, 'nodeType'>;
4
+ props?: Partial<FileElementProps>;
5
5
  };
6
6
  type InsertFileOptions = FileElementOptions & {
7
7
  at?: YooptaPathIndex;
8
8
  focus?: boolean;
9
9
  };
10
- export type FileCommands = {
10
+ export type FileCommandsType = {
11
11
  buildFileElements: (editor: YooEditor, options?: Partial<FileElementOptions>) => FileElement;
12
12
  insertFile: (editor: YooEditor, options?: Partial<InsertFileOptions>) => void;
13
13
  deleteFile: (editor: YooEditor, blockId: string) => void;
14
14
  updateFile: (editor: YooEditor, blockId: string, props: Partial<FileElementProps>) => void;
15
15
  };
16
- export declare const FileCommands: FileCommands;
16
+ export declare const FileCommands: FileCommandsType;
17
17
  export {};
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEzD,KAAK,kBAAkB,GAAG;IACxB,KAAK,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;CAC5C,CAAC;AAEF,KAAK,iBAAiB,GAAG,kBAAkB,GAAG;IAC5C,EAAE,CAAC,EAAE,eAAe,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,WAAW,CAAC;IAC7F,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC9E,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC5F,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,YAiB1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE9D,KAAK,kBAAkB,GAAG;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACnC,CAAC;AAEF,KAAK,iBAAiB,GAAG,kBAAkB,GAAG;IAC5C,EAAE,CAAC,EAAE,eAAe,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,WAAW,CAAC;IAC7F,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC9E,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC5F,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,gBA6B1B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FileDeleteOptions, FileUploadOptions, UseFileDeleteReturn, UseFileUploadReturn } from '../types';
2
+ export declare const useFileDelete: (options: FileDeleteOptions | undefined) => UseFileDeleteReturn;
3
+ export declare const useFileUpload: (options: FileUploadOptions | undefined) => UseFileUploadReturn;
4
+ //# sourceMappingURL=use-upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,iBAAiB,EAKjB,iBAAiB,EAKjB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AA2FlB,eAAO,MAAM,aAAa,YAAa,iBAAiB,GAAG,SAAS,KAAG,mBAgHtE,CAAC;AAEF,eAAO,MAAM,aAAa,YAAa,iBAAiB,GAAG,SAAS,KAAG,mBAmHtE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { FileUploadProgress, FileUploadError, FileUploadResult, XHRRequestOptions } from '../types';
2
+ export declare const useXHRRequest: ({ onError, onSuccess, onProgress, accept, maxSize, method, endpoint, headers, }: XHRRequestOptions) => {
3
+ xhrFetch: (body: XMLHttpRequestBodyInit) => Promise<FileUploadResult>;
4
+ cancel: () => void;
5
+ reset: () => void;
6
+ loading: boolean;
7
+ progress: FileUploadProgress | null;
8
+ error: FileUploadError | null;
9
+ result: FileUploadResult | null;
10
+ };
11
+ //# sourceMappingURL=use-xhr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-xhr.d.ts","sourceRoot":"","sources":["../../src/hooks/use-xhr.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAEhB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAsClB,eAAO,MAAM,aAAa,oFASvB,iBAAiB;qBAUM,sBAAsB,KAAG,QAAQ,gBAAgB,CAAC;;;;;;;CA2K3E,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,9 @@
1
- import { File } from './plugin';
2
- import { FileElement, FileElementProps, FileUploadResponse } from './types';
3
- import './styles.css';
4
- declare module 'slate' {
5
- interface CustomTypes {
6
- Element: FileElement;
7
- }
8
- }
1
+ import { File } from './plugin/file-plugin';
2
+ export type { FileElement, FileElementMap, FileElementProps, FilePluginElements, FilePluginOptions, FileUploadResponse, FileUploadFn, FileDeleteFn, FileUploadEndpointOptions, FileDeleteEndpointOptions, FileUploadOptions, FileDeleteOptions, FileUploadProgress, FileUploadError, FileUploadResult, FileUploadState, UseFileUploadReturn, UseFileDeleteReturn, FileType, FileTypeConfig, } from './types';
9
3
  export { FileCommands } from './commands';
4
+ export type { FileCommandsType } from './commands';
5
+ export { useFileUpload, useFileDelete } from './hooks/use-upload';
6
+ export { getFileType, getFileTypeConfig, getFileTypeLabel, getFileExtension, isFileType, FILE_TYPE_CONFIGS, } from './utils/file-type';
7
+ export { formatFileSize, parseFileSize } from './utils/format-size';
10
8
  export default File;
11
- export { FileElement, FileElementProps, FileUploadResponse };
12
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,cAAc,CAAC;AAEtB,OAAO,QAAQ,OAAO,CAAC;IACrB,UAAU,WAAW;QACnB,OAAO,EAAE,WAAW,CAAC;KACtB;CACF;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,eAAe,IAAI,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG5C,YAAY,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,QAAQ,EACR,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGlE,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpE,eAAe,IAAI,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{generateId as e,buildBlockData as t,Blocks as o,Elements as n,useYooptaPluginOptions as i,useYooptaEditor as r,UI as l,useBlockData as a,useYooptaReadOnly as s,useBlockSelected as f,YooptaPlugin as c}from"@yoopta/editor";import{jsx as p,jsxs as d}from"react/jsx-runtime";import*as u from"react";import{forwardRef as y,createElement as g,useLayoutEffect as h,useEffect as m,useState as x}from"react";import*as b from"react-dom";const w={buildFileElements:(t,o={})=>{const n=Object.assign(Object.assign({},o.props),{nodeType:"void"});return{id:e(),type:"file",children:[{text:""}],props:n}},insertFile:(e,n={})=>{const{at:i,focus:r,props:l}=n,a=w.buildFileElements(e,{props:l}),s=t({value:[a],type:"File"});o.insertBlock(e,s.type,{focus:r,at:i,blockData:s})},deleteFile:(e,t)=>{o.deleteBlock(e,{blockId:t})},updateFile:(e,t,o)=>{n.updateElement(e,t,{props:o})}};function v(e,t,o,n){return new(o||(o=Promise))((function(i,r){function l(e){try{s(n.next(e))}catch(e){r(e)}}function a(e){try{s(n.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(l,a)}s((n=n.apply(e,t||[])).next())}))}function C(e,t){if(null==e)return{};var o,n,i={},r=Object.keys(e);for(n=0;n<r.length;n++)o=r[n],t.indexOf(o)>=0||(i[o]=e[o]);return i}"function"==typeof SuppressedError&&SuppressedError;var _=["color"],k=y((function(e,t){var o=e.color,n=void 0===o?"currentColor":o,i=C(e,_);return g("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),g("path",{d:"M3 2C2.44772 2 2 2.44772 2 3V12C2 12.5523 2.44772 13 3 13H12C12.5523 13 13 12.5523 13 12V8.5C13 8.22386 12.7761 8 12.5 8C12.2239 8 12 8.22386 12 8.5V12H3V3L6.5 3C6.77614 3 7 2.77614 7 2.5C7 2.22386 6.77614 2 6.5 2H3ZM12.8536 2.14645C12.9015 2.19439 12.9377 2.24964 12.9621 2.30861C12.9861 2.36669 12.9996 2.4303 13 2.497L13 2.5V2.50049V5.5C13 5.77614 12.7761 6 12.5 6C12.2239 6 12 5.77614 12 5.5V3.70711L6.85355 8.85355C6.65829 9.04882 6.34171 9.04882 6.14645 8.85355C5.95118 8.65829 5.95118 8.34171 6.14645 8.14645L11.2929 3H9.5C9.22386 3 9 2.77614 9 2.5C9 2.22386 9.22386 2 9.5 2H12.4999H12.5C12.5678 2 12.6324 2.01349 12.6914 2.03794C12.7504 2.06234 12.8056 2.09851 12.8536 2.14645Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))})),R=["color"],O=y((function(e,t){var o=e.color,n=void 0===o?"currentColor":o,i=C(e,R);return g("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),g("path",{d:"M3.5 2C3.22386 2 3 2.22386 3 2.5V12.5C3 12.7761 3.22386 13 3.5 13H11.5C11.7761 13 12 12.7761 12 12.5V6H8.5C8.22386 6 8 5.77614 8 5.5V2H3.5ZM9 2.70711L11.2929 5H9V2.70711ZM2 2.5C2 1.67157 2.67157 1 3.5 1H8.5C8.63261 1 8.75979 1.05268 8.85355 1.14645L12.8536 5.14645C12.9473 5.24021 13 5.36739 13 5.5V12.5C13 13.3284 12.3284 14 11.5 14H3.5C2.67157 14 2 13.3284 2 12.5V2.5Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))})),j=["color"],H=y((function(e,t){var o=e.color,n=void 0===o?"currentColor":o,i=C(e,j);return g("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),g("path",{d:"M3 2.5C3 2.22386 3.22386 2 3.5 2H9.08579C9.21839 2 9.34557 2.05268 9.43934 2.14645L11.8536 4.56066C11.9473 4.65443 12 4.78161 12 4.91421V12.5C12 12.7761 11.7761 13 11.5 13H3.5C3.22386 13 3 12.7761 3 12.5V2.5ZM3.5 1C2.67157 1 2 1.67157 2 2.5V12.5C2 13.3284 2.67157 14 3.5 14H11.5C12.3284 14 13 13.3284 13 12.5V4.91421C13 4.51639 12.842 4.13486 12.5607 3.85355L10.1464 1.43934C9.86514 1.15804 9.48361 1 9.08579 1H3.5ZM4.5 4C4.22386 4 4 4.22386 4 4.5C4 4.77614 4.22386 5 4.5 5H7.5C7.77614 5 8 4.77614 8 4.5C8 4.22386 7.77614 4 7.5 4H4.5ZM4.5 7C4.22386 7 4 7.22386 4 7.5C4 7.77614 4.22386 8 4.5 8H10.5C10.7761 8 11 7.77614 11 7.5C11 7.22386 10.7761 7 10.5 7H4.5ZM4.5 10C4.22386 10 4 10.2239 4 10.5C4 10.7761 4.22386 11 4.5 11H10.5C10.7761 11 11 10.7761 11 10.5C11 10.2239 10.7761 10 10.5 10H4.5Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))})),E=["color"],S=y((function(e,t){var o=e.color,n=void 0===o?"currentColor":o,i=C(e,E);return g("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),g("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM4 7.5C4 7.22386 4.22386 7 4.5 7H10.5C10.7761 7 11 7.22386 11 7.5C11 7.77614 10.7761 8 10.5 8H4.5C4.22386 8 4 7.77614 4 7.5ZM3 10.5C3 10.2239 3.22386 10 3.5 10H11.5C11.7761 10 12 10.2239 12 10.5C12 10.7761 11.7761 11 11.5 11H3.5C3.22386 11 3 10.7761 3 10.5Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))})),L=["color"],N=y((function(e,t){var o=e.color,n=void 0===o?"currentColor":o,i=C(e,L);return g("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),g("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM2 7.5C2 7.22386 2.22386 7 2.5 7H7.5C7.77614 7 8 7.22386 8 7.5C8 7.77614 7.77614 8 7.5 8H2.5C2.22386 8 2 7.77614 2 7.5ZM2 10.5C2 10.2239 2.22386 10 2.5 10H10.5C10.7761 10 11 10.2239 11 10.5C11 10.7761 10.7761 11 10.5 11H2.5C2.22386 11 2 10.7761 2 10.5Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))})),M=["color"],F=y((function(e,t){var o=e.color,n=void 0===o?"currentColor":o,i=C(e,M);return g("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),g("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM7 7.5C7 7.22386 7.22386 7 7.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H7.5C7.22386 8 7 7.77614 7 7.5ZM4 10.5C4 10.2239 4.22386 10 4.5 10H12.5C12.7761 10 13 10.2239 13 10.5C13 10.7761 12.7761 11 12.5 11H4.5C4.22386 11 4 10.7761 4 10.5Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))}));function T(e){if("number"!=typeof e||isNaN(e))return null;return(e/1024).toFixed(2)+" KB"}const $=({name:e,src:t,size:o,format:n,align:i})=>{if(!t)return null;const r=`yoopta-align-${i||"left"}`;return p("div",Object.assign({className:"yoo-file-w-full yoo-file-cursor-pointer",contentEditable:!1,onClick:e=>{t&&(e.preventDefault(),e.stopPropagation(),window.open(t,"_blank"))}},{children:d("div",Object.assign({className:`yoo-file-flex ${r} yoo-file-items-center yoo-file-rounded-[4px] yoo-file-py-[8px] yoo-file-px-2 hover:yoo-file-bg-[rgba(55,53,47,0.04)] yoo-file-border-b-[1px] hover:yoo-file-border-[rgba(55,53,47,0.16)] yoo-file-border-[transparent]`},{children:[d("div",Object.assign({className:"yoo-file-flex yoo-file-items-center yoo-file-leading-[1.2] yoo-file-font-medium yoo-file-text-[#000000]"},{children:[p(H,{width:16,height:16}),p("span",Object.assign({className:"yoo-file-ml-[6px] yoo-file-text-[14px]"},{children:n?`${e}.${n}`:`${e}`}))]})),p("div",Object.assign({className:"yoo-file-ml-[8px] yoo-file-text-[10px] yoo-file-font-normal yoo-file-text-[#37352fa6]"},{children:T(o)}))]}))}))};function z(e){return B(e)?(e.nodeName||"").toLowerCase():"#document"}function P(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function A(e){var t;return null==(t=(B(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function B(e){return e instanceof Node||e instanceof P(e).Node}function V(e){return e instanceof Element||e instanceof P(e).Element}function D(e){return e instanceof HTMLElement||e instanceof P(e).HTMLElement}function Z(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof P(e).ShadowRoot)}function I(e){const{overflow:t,overflowX:o,overflowY:n,display:i}=G(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+o)&&!["inline","contents"].includes(i)}function W(e){return["table","td","th"].includes(z(e))}function U(e){const t=X(),o=G(e);return"none"!==o.transform||"none"!==o.perspective||!!o.containerType&&"normal"!==o.containerType||!t&&!!o.backdropFilter&&"none"!==o.backdropFilter||!t&&!!o.filter&&"none"!==o.filter||["transform","perspective","filter"].some((e=>(o.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(o.contain||"").includes(e)))}function X(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Y(e){return["html","body","#document"].includes(z(e))}function G(e){return P(e).getComputedStyle(e)}function K(e){return V(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function q(e){if("html"===z(e))return e;const t=e.assignedSlot||e.parentNode||Z(e)&&e.host||A(e);return Z(t)?t.host:t}function J(e){const t=q(e);return Y(t)?e.ownerDocument?e.ownerDocument.body:e.body:D(t)&&I(t)?t:J(t)}function Q(e,t,o){var n;void 0===t&&(t=[]),void 0===o&&(o=!0);const i=J(e),r=i===(null==(n=e.ownerDocument)?void 0:n.body),l=P(i);return r?t.concat(l,l.visualViewport||[],I(i)?i:[],l.frameElement&&o?Q(l.frameElement):[]):t.concat(i,Q(i,[],o))}const ee=Math.min,te=Math.max,oe=Math.round,ne=e=>({x:e,y:e}),ie={left:"right",right:"left",bottom:"top",top:"bottom"},re={start:"end",end:"start"};function le(e,t,o){return te(e,ee(t,o))}function ae(e,t){return"function"==typeof e?e(t):e}function se(e){return e.split("-")[0]}function fe(e){return e.split("-")[1]}function ce(e){return"x"===e?"y":"x"}function pe(e){return"y"===e?"height":"width"}function de(e){return["top","bottom"].includes(se(e))?"y":"x"}function ue(e){return ce(de(e))}function ye(e){return e.replace(/start|end/g,(e=>re[e]))}function ge(e){return e.replace(/left|right|bottom|top/g,(e=>ie[e]))}function he(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function me(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function xe(e,t,o){let{reference:n,floating:i}=e;const r=de(t),l=ue(t),a=pe(l),s=se(t),f="y"===r,c=n.x+n.width/2-i.width/2,p=n.y+n.height/2-i.height/2,d=n[a]/2-i[a]/2;let u;switch(s){case"top":u={x:c,y:n.y-i.height};break;case"bottom":u={x:c,y:n.y+n.height};break;case"right":u={x:n.x+n.width,y:p};break;case"left":u={x:n.x-i.width,y:p};break;default:u={x:n.x,y:n.y}}switch(fe(t)){case"start":u[l]-=d*(o&&f?-1:1);break;case"end":u[l]+=d*(o&&f?-1:1)}return u}async function be(e,t){var o;void 0===t&&(t={});const{x:n,y:i,platform:r,rects:l,elements:a,strategy:s}=e,{boundary:f="clippingAncestors",rootBoundary:c="viewport",elementContext:p="floating",altBoundary:d=!1,padding:u=0}=ae(t,e),y=he(u),g=a[d?"floating"===p?"reference":"floating":p],h=me(await r.getClippingRect({element:null==(o=await(null==r.isElement?void 0:r.isElement(g)))||o?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(a.floating)),boundary:f,rootBoundary:c,strategy:s})),m="floating"===p?{...l.floating,x:n,y:i}:l.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(a.floating)),b=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},w=me(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:m,offsetParent:x,strategy:s}):m);return{top:(h.top-w.top+y.top)/b.y,bottom:(w.bottom-h.bottom+y.bottom)/b.y,left:(h.left-w.left+y.left)/b.x,right:(w.right-h.right+y.right)/b.x}}function we(e){const t=ee(...e.map((e=>e.left))),o=ee(...e.map((e=>e.top)));return{x:t,y:o,width:te(...e.map((e=>e.right)))-t,height:te(...e.map((e=>e.bottom)))-o}}const ve=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var o,n;const{x:i,y:r,placement:l,middlewareData:a}=t,s=await async function(e,t){const{placement:o,platform:n,elements:i}=e,r=await(null==n.isRTL?void 0:n.isRTL(i.floating)),l=se(o),a=fe(o),s="y"===de(o),f=["left","top"].includes(l)?-1:1,c=r&&s?-1:1,p=ae(t,e);let{mainAxis:d,crossAxis:u,alignmentAxis:y}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return a&&"number"==typeof y&&(u="end"===a?-1*y:y),s?{x:u*c,y:d*f}:{x:d*f,y:u*c}}(t,e);return l===(null==(o=a.offset)?void 0:o.placement)&&null!=(n=a.arrow)&&n.alignmentOffset?{}:{x:i+s.x,y:r+s.y,data:{...s,placement:l}}}}};function Ce(e){const t=G(e);let o=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const i=D(e),r=i?e.offsetWidth:o,l=i?e.offsetHeight:n,a=oe(o)!==r||oe(n)!==l;return a&&(o=r,n=l),{width:o,height:n,$:a}}function _e(e){return V(e)?e:e.contextElement}function ke(e){const t=_e(e);if(!D(t))return ne(1);const o=t.getBoundingClientRect(),{width:n,height:i,$:r}=Ce(t);let l=(r?oe(o.width):o.width)/n,a=(r?oe(o.height):o.height)/i;return l&&Number.isFinite(l)||(l=1),a&&Number.isFinite(a)||(a=1),{x:l,y:a}}const Re=ne(0);function Oe(e){const t=P(e);return X()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Re}function je(e,t,o,n){void 0===t&&(t=!1),void 0===o&&(o=!1);const i=e.getBoundingClientRect(),r=_e(e);let l=ne(1);t&&(n?V(n)&&(l=ke(n)):l=ke(e));const a=function(e,t,o){return void 0===t&&(t=!1),!(!o||t&&o!==P(e))&&t}(r,o,n)?Oe(r):ne(0);let s=(i.left+a.x)/l.x,f=(i.top+a.y)/l.y,c=i.width/l.x,p=i.height/l.y;if(r){const e=P(r),t=n&&V(n)?P(n):n;let o=e,i=o.frameElement;for(;i&&n&&t!==o;){const e=ke(i),t=i.getBoundingClientRect(),n=G(i),r=t.left+(i.clientLeft+parseFloat(n.paddingLeft))*e.x,l=t.top+(i.clientTop+parseFloat(n.paddingTop))*e.y;s*=e.x,f*=e.y,c*=e.x,p*=e.y,s+=r,f+=l,o=P(i),i=o.frameElement}}return me({width:c,height:p,x:s,y:f})}const He=[":popover-open",":modal"];function Ee(e){return He.some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function Se(e){return je(A(e)).left+K(e).scrollLeft}function Le(e,t,o){let n;if("viewport"===t)n=function(e,t){const o=P(e),n=A(e),i=o.visualViewport;let r=n.clientWidth,l=n.clientHeight,a=0,s=0;if(i){r=i.width,l=i.height;const e=X();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,s=i.offsetTop)}return{width:r,height:l,x:a,y:s}}(e,o);else if("document"===t)n=function(e){const t=A(e),o=K(e),n=e.ownerDocument.body,i=te(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),r=te(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let l=-o.scrollLeft+Se(e);const a=-o.scrollTop;return"rtl"===G(n).direction&&(l+=te(t.clientWidth,n.clientWidth)-i),{width:i,height:r,x:l,y:a}}(A(e));else if(V(t))n=function(e,t){const o=je(e,!0,"fixed"===t),n=o.top+e.clientTop,i=o.left+e.clientLeft,r=D(e)?ke(e):ne(1);return{width:e.clientWidth*r.x,height:e.clientHeight*r.y,x:i*r.x,y:n*r.y}}(t,o);else{const o=Oe(e);n={...t,x:t.x-o.x,y:t.y-o.y}}return me(n)}function Ne(e,t){const o=q(e);return!(o===t||!V(o)||Y(o))&&("fixed"===G(o).position||Ne(o,t))}function Me(e,t,o){const n=D(t),i=A(t),r="fixed"===o,l=je(e,!0,r,t);let a={scrollLeft:0,scrollTop:0};const s=ne(0);if(n||!n&&!r)if(("body"!==z(t)||I(i))&&(a=K(t)),n){const e=je(t,!0,r,t);s.x=e.x+t.clientLeft,s.y=e.y+t.clientTop}else i&&(s.x=Se(i));return{x:l.left+a.scrollLeft-s.x,y:l.top+a.scrollTop-s.y,width:l.width,height:l.height}}function Fe(e,t){return D(e)&&"fixed"!==G(e).position?t?t(e):e.offsetParent:null}function Te(e,t){const o=P(e);if(!D(e)||Ee(e))return o;let n=Fe(e,t);for(;n&&W(n)&&"static"===G(n).position;)n=Fe(n,t);return n&&("html"===z(n)||"body"===z(n)&&"static"===G(n).position&&!U(n))?o:n||function(e){let t=q(e);for(;D(t)&&!Y(t);){if(U(t))return t;t=q(t)}return null}(e)||o}const $e={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:o,offsetParent:n,strategy:i}=e;const r="fixed"===i,l=A(n),a=!!t&&Ee(t.floating);if(n===l||a&&r)return o;let s={scrollLeft:0,scrollTop:0},f=ne(1);const c=ne(0),p=D(n);if((p||!p&&!r)&&(("body"!==z(n)||I(l))&&(s=K(n)),D(n))){const e=je(n);f=ke(n),c.x=e.x+n.clientLeft,c.y=e.y+n.clientTop}return{width:o.width*f.x,height:o.height*f.y,x:o.x*f.x-s.scrollLeft*f.x+c.x,y:o.y*f.y-s.scrollTop*f.y+c.y}},getDocumentElement:A,getClippingRect:function(e){let{element:t,boundary:o,rootBoundary:n,strategy:i}=e;const r=[..."clippingAncestors"===o?function(e,t){const o=t.get(e);if(o)return o;let n=Q(e,[],!1).filter((e=>V(e)&&"body"!==z(e))),i=null;const r="fixed"===G(e).position;let l=r?q(e):e;for(;V(l)&&!Y(l);){const t=G(l),o=U(l);o||"fixed"!==t.position||(i=null),(r?!o&&!i:!o&&"static"===t.position&&i&&["absolute","fixed"].includes(i.position)||I(l)&&!o&&Ne(e,l))?n=n.filter((e=>e!==l)):i=t,l=q(l)}return t.set(e,n),n}(t,this._c):[].concat(o),n],l=r[0],a=r.reduce(((e,o)=>{const n=Le(t,o,i);return e.top=te(n.top,e.top),e.right=ee(n.right,e.right),e.bottom=ee(n.bottom,e.bottom),e.left=te(n.left,e.left),e}),Le(t,l,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:Te,getElementRects:async function(e){const t=this.getOffsetParent||Te,o=this.getDimensions;return{reference:Me(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,...await o(e.floating)}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:o}=Ce(e);return{width:t,height:o}},getScale:ke,isElement:V,isRTL:function(e){return"rtl"===G(e).direction}},ze=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:o,y:n,placement:i}=t,{mainAxis:r=!0,crossAxis:l=!1,limiter:a={fn:e=>{let{x:t,y:o}=e;return{x:t,y:o}}},...s}=ae(e,t),f={x:o,y:n},c=await be(t,s),p=de(se(i)),d=ce(p);let u=f[d],y=f[p];if(r){const e="y"===d?"bottom":"right";u=le(u+c["y"===d?"top":"left"],u,u-c[e])}if(l){const e="y"===p?"bottom":"right";y=le(y+c["y"===p?"top":"left"],y,y-c[e])}const g=a.fn({...t,[d]:u,[p]:y});return{...g,data:{x:g.x-o,y:g.y-n}}}}},Pe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var o,n;const{placement:i,middlewareData:r,rects:l,initialPlacement:a,platform:s,elements:f}=t,{mainAxis:c=!0,crossAxis:p=!0,fallbackPlacements:d,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:g=!0,...h}=ae(e,t);if(null!=(o=r.arrow)&&o.alignmentOffset)return{};const m=se(i),x=se(a)===a,b=await(null==s.isRTL?void 0:s.isRTL(f.floating)),w=d||(x||!g?[ge(a)]:function(e){const t=ge(e);return[ye(e),t,ye(t)]}(a));d||"none"===y||w.push(...function(e,t,o,n){const i=fe(e);let r=function(e,t,o){const n=["left","right"],i=["right","left"],r=["top","bottom"],l=["bottom","top"];switch(e){case"top":case"bottom":return o?t?i:n:t?n:i;case"left":case"right":return t?r:l;default:return[]}}(se(e),"start"===o,n);return i&&(r=r.map((e=>e+"-"+i)),t&&(r=r.concat(r.map(ye)))),r}(a,g,y,b));const v=[a,...w],C=await be(t,h),_=[];let k=(null==(n=r.flip)?void 0:n.overflows)||[];if(c&&_.push(C[m]),p){const e=function(e,t,o){void 0===o&&(o=!1);const n=fe(e),i=ue(e),r=pe(i);let l="x"===i?n===(o?"end":"start")?"right":"left":"start"===n?"bottom":"top";return t.reference[r]>t.floating[r]&&(l=ge(l)),[l,ge(l)]}(i,l,b);_.push(C[e[0]],C[e[1]])}if(k=[...k,{placement:i,overflows:_}],!_.every((e=>e<=0))){var R,O;const e=((null==(R=r.flip)?void 0:R.index)||0)+1,t=v[e];if(t)return{data:{index:e,overflows:k},reset:{placement:t}};let o=null==(O=k.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:O.placement;if(!o)switch(u){case"bestFit":{var j;const e=null==(j=k.map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)])).sort(((e,t)=>e[1]-t[1]))[0])?void 0:j[0];e&&(o=e);break}case"initialPlacement":o=a}if(i!==o)return{reset:{placement:o}}}return{}}}},Ae=function(e){return void 0===e&&(e={}),{name:"inline",options:e,async fn(t){const{placement:o,elements:n,rects:i,platform:r,strategy:l}=t,{padding:a=2,x:s,y:f}=ae(e,t),c=Array.from(await(null==r.getClientRects?void 0:r.getClientRects(n.reference))||[]),p=function(e){const t=e.slice().sort(((e,t)=>e.y-t.y)),o=[];let n=null;for(let e=0;e<t.length;e++){const i=t[e];!n||i.y-n.y>n.height/2?o.push([i]):o[o.length-1].push(i),n=i}return o.map((e=>me(we(e))))}(c),d=me(we(c)),u=he(a);const y=await r.getElementRects({reference:{getBoundingClientRect:function(){if(2===p.length&&p[0].left>p[1].right&&null!=s&&null!=f)return p.find((e=>s>e.left-u.left&&s<e.right+u.right&&f>e.top-u.top&&f<e.bottom+u.bottom))||d;if(p.length>=2){if("y"===de(o)){const e=p[0],t=p[p.length-1],n="top"===se(o),i=e.top,r=t.bottom,l=n?e.left:t.left,a=n?e.right:t.right;return{top:i,bottom:r,left:l,right:a,width:a-l,height:r-i,x:l,y:i}}const e="left"===se(o),t=te(...p.map((e=>e.right))),n=ee(...p.map((e=>e.left))),i=p.filter((o=>e?o.left===n:o.right===t)),r=i[0].top,l=i[i.length-1].bottom;return{top:r,bottom:l,left:n,right:t,width:t-n,height:l-r,x:n,y:r}}return d}},floating:n.floating,strategy:l});return i.reference.x!==y.reference.x||i.reference.y!==y.reference.y||i.reference.width!==y.reference.width||i.reference.height!==y.reference.height?{reset:{rects:y}}:{}}}},Be=(e,t,o)=>{const n=new Map,i={platform:$e,...o},r={...i.platform,_c:n};return(async(e,t,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:r=[],platform:l}=o,a=r.filter(Boolean),s=await(null==l.isRTL?void 0:l.isRTL(t));let f=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:p}=xe(f,n,s),d=n,u={},y=0;for(let o=0;o<a.length;o++){const{name:r,fn:g}=a[o],{x:h,y:m,data:x,reset:b}=await g({x:c,y:p,initialPlacement:n,placement:d,strategy:i,middlewareData:u,rects:f,platform:l,elements:{reference:e,floating:t}});c=null!=h?h:c,p=null!=m?m:p,u={...u,[r]:{...u[r],...x}},b&&y<=50&&(y++,"object"==typeof b&&(b.placement&&(d=b.placement),b.rects&&(f=!0===b.rects?await l.getElementRects({reference:e,floating:t,strategy:i}):b.rects),({x:c,y:p}=xe(f,d,s))),o=-1)}return{x:c,y:p,placement:d,strategy:i,middlewareData:u}})(e,t,{...i,platform:r})};var Ve="undefined"!=typeof document?h:m;function De(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let o,n,i;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(o=e.length,o!==t.length)return!1;for(n=o;0!=n--;)if(!De(e[n],t[n]))return!1;return!0}if(i=Object.keys(e),o=i.length,o!==Object.keys(t).length)return!1;for(n=o;0!=n--;)if(!{}.hasOwnProperty.call(t,i[n]))return!1;for(n=o;0!=n--;){const o=i[n];if(("_owner"!==o||!e.$$typeof)&&!De(e[o],t[o]))return!1}return!0}return e!=e&&t!=t}function Ze(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ie(e,t){const o=Ze(e);return Math.round(t*o)/o}function We(e){const t=u.useRef(e);return Ve((()=>{t.current=e})),t}const Ue=u["useInsertionEffect".toString()]||(e=>e());var Xe="undefined"!=typeof document?h:m;let Ye=!1,Ge=0;const Ke=()=>"floating-ui-"+Ge++;const qe=u["useId".toString()]||function(){const[e,t]=u.useState((()=>Ye?Ke():void 0));return Xe((()=>{null==e&&t(Ke())}),[]),u.useEffect((()=>{Ye||(Ye=!0)}),[]),e};const Je=u.createContext(null),Qe=u.createContext(null);function et(e){var t;void 0===e&&(e={});const{open:o=!1,onOpenChange:n,nodeId:i}=e,[r,l]=u.useState(null),a=(null==(t=e.elements)?void 0:t.reference)||r,s=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:o="absolute",middleware:n=[],platform:i,elements:{reference:r,floating:l}={},transform:a=!0,whileElementsMounted:s,open:f}=e,[c,p]=u.useState({x:0,y:0,strategy:o,placement:t,middlewareData:{},isPositioned:!1}),[d,y]=u.useState(n);De(d,n)||y(n);const[g,h]=u.useState(null),[m,x]=u.useState(null),w=u.useCallback((e=>{e!==k.current&&(k.current=e,h(e))}),[]),v=u.useCallback((e=>{e!==R.current&&(R.current=e,x(e))}),[]),C=r||g,_=l||m,k=u.useRef(null),R=u.useRef(null),O=u.useRef(c),j=null!=s,H=We(s),E=We(i),S=u.useCallback((()=>{if(!k.current||!R.current)return;const e={placement:t,strategy:o,middleware:d};E.current&&(e.platform=E.current),Be(k.current,R.current,e).then((e=>{const t={...e,isPositioned:!0};L.current&&!De(O.current,t)&&(O.current=t,b.flushSync((()=>{p(t)})))}))}),[d,t,o,E]);Ve((()=>{!1===f&&O.current.isPositioned&&(O.current.isPositioned=!1,p((e=>({...e,isPositioned:!1}))))}),[f]);const L=u.useRef(!1);Ve((()=>(L.current=!0,()=>{L.current=!1})),[]),Ve((()=>{if(C&&(k.current=C),_&&(R.current=_),C&&_){if(H.current)return H.current(C,_,S);S()}}),[C,_,S,H,j]);const N=u.useMemo((()=>({reference:k,floating:R,setReference:w,setFloating:v})),[w,v]),M=u.useMemo((()=>({reference:C,floating:_})),[C,_]),F=u.useMemo((()=>{const e={position:o,left:0,top:0};if(!M.floating)return e;const t=Ie(M.floating,c.x),n=Ie(M.floating,c.y);return a?{...e,transform:"translate("+t+"px, "+n+"px)",...Ze(M.floating)>=1.5&&{willChange:"transform"}}:{position:o,left:t,top:n}}),[o,a,M.floating,c.x,c.y]);return u.useMemo((()=>({...c,update:S,refs:N,elements:M,floatingStyles:F})),[c,S,N,M,F])}(e),f=u.useContext(Qe),c=null!=((null==(p=u.useContext(Je))?void 0:p.id)||null);var p;const d=function(e){const t=u.useRef((()=>{}));return Ue((()=>{t.current=e})),u.useCallback((function(){for(var e=arguments.length,o=new Array(e),n=0;n<e;n++)o[n]=arguments[n];return null==t.current?void 0:t.current(...o)}),[])}(((e,t,o)=>{e&&(g.current.openEvent=t),h.emit("openchange",{open:e,event:t,reason:o,nested:c}),null==n||n(e,t,o)})),y=u.useRef(null),g=u.useRef({}),h=u.useState((()=>function(){const e=new Map;return{emit(t,o){var n;null==(n=e.get(t))||n.forEach((e=>e(o)))},on(t,o){e.set(t,[...e.get(t)||[],o])},off(t,o){var n;e.set(t,(null==(n=e.get(t))?void 0:n.filter((e=>e!==o)))||[])}}}()))[0],m=qe(),x=u.useCallback((e=>{const t=V(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;s.refs.setReference(t)}),[s.refs]),w=u.useCallback((e=>{(V(e)||null===e)&&(y.current=e,l(e)),(V(s.refs.reference.current)||null===s.refs.reference.current||null!==e&&!V(e))&&s.refs.setReference(e)}),[s.refs]),v=u.useMemo((()=>({...s.refs,setReference:w,setPositionReference:x,domReference:y})),[s.refs,w,x]),C=u.useMemo((()=>({...s.elements,domReference:a})),[s.elements,a]),_=u.useMemo((()=>({...s,refs:v,elements:C,dataRef:g,nodeId:i,floatingId:m,events:h,open:o,onOpenChange:d})),[s,i,m,h,o,d,v,C]);return Xe((()=>{const e=null==f?void 0:f.nodesRef.current.find((e=>e.id===i));e&&(e.context=_)})),u.useMemo((()=>({...s,context:_,refs:v,elements:C})),[s,v,C,_])}const tt=({accept:e="",onClose:t,blockId:o,onSetLoading:l})=>{const a=i("File"),s=r();return p("div",Object.assign({className:"yoo-file-user-select-none yoo-file-transition-bg yoo-file-duration-20 yoo-file-ease-in yoo-file-white-space-nowrap yoo-file-rounded-[4px] yoo-file-h-[32px] yoo-file-px-[12px] yoo-file-border yoo-file-border-solid yoo-file-border-[rgba(55,53,47,0.16)] yoo-file-w-full yoo-file-cursor-pointer"},{children:d("label",Object.assign({htmlFor:"file-uploader",className:"yoo-file-text-[14px] yoo-file-leading-[1.2] yoo-file-font-medium yoo-file-cursor-pointer yoo-file-w-full yoo-file-flex yoo-file-items-center yoo-file-justify-center yoo-file-h-full"},{children:[p("input",{type:"file",id:"file-uploader",className:"yoo-file-absolute yoo-file-left-0 yoo-file-top-0 yoo-file-invisible",accept:(null==a?void 0:a.accept)||e,onChange:e=>{const i=e.target.files[0];i&&(e=>{v(void 0,void 0,void 0,(function*(){var i;if(!(null==a?void 0:a.onUpload))throw new Error("onUpload not provided in plugin options. Check File.extend({}) method");t(),l(!0);try{const t=yield null==a?void 0:a.onUpload(e);n.updateElement(s,o,{type:"file",props:{src:t.src,name:t.name||e.name,size:t.size||e.size,format:t.format}})}catch(e){null===(i=null==a?void 0:a.onError)||void 0===i||i.call(a,e)}finally{l(!1)}}))})(i)},multiple:!1}),"Upload file"]}))}))},{Overlay:ot,Portal:nt}=l,it=({floatingStyles:e,refs:t,onClose:o,blockId:n,onSetLoading:i})=>p(nt,Object.assign({id:"yoo-file-uploader-portal"},{children:p(ot,Object.assign({lockScroll:!0,className:"yoo-file-z-[100]",onClick:o},{children:p("div",Object.assign({ref:t.setFloating,style:e,onClick:e=>e.stopPropagation()},{children:d("div",Object.assign({className:"yoo-file-flex yoo-file-flex-col yoo-file-min-w-[540px] yoo-file-max-w-[calc(100vw-24px)] yoo-file-h-full yoo-file-max-h-[420px] yoo-file-bg-[#FFFFFF] yoo-file-shadow-[rgb(15_15_15_/5%)_0px_0px_0px_1px,_rgb(15_15_15_/10%)_0px_3px_6px,_rgb(15_15_15_/20%)_0px_9px_24px]"},{children:[p("div",Object.assign({className:"yoo-file-w-full yoo-file-flex yoo-file-text-[14px] yoo-file-p-[0_8px] yoo-file-shadow-[rgb(55_53_47_/9%)_0px_-1px_0px_inset] yoo-file-relative yoo-file-z-10 yoo-file-h-[40px]"},{children:p("button",Object.assign({type:"button",style:{borderBottom:"2px solid #2483e2"},className:"yoopta-button yoo-file-py-[6px] yoo-file-whitespace-nowrap yoo-file-min-w-0 yoo-file-flex-shrink-0 yoo-file-text-[rgb(55,53,47)] yoo-file-relative yoo-file-cursor-pointer yoo-file-user-select-none yoo-file-bg-inherit yoo-file-transition-[height_20ms_ease-in] yoo-file-inline-flex yoo-file-items-center yoo-file-h-full yoo-file-text-[14px] yoo-file-leading-[1.2] yoo-file-px-[8px]"},{children:"Upload"}))})),p("div",Object.assign({className:"yoo-file-pt-[6px] yoo-file-pb-[6px] yoo-file-mt-[4px] yoo-file-flex yoo-file-justify-center yoo-file-mr-[12px] yoo-file-ml-[12px]"},{children:p(tt,{onClose:o,blockId:n,onSetLoading:i})}))]}))}))}))})),rt=({className:e,width:t,height:o,children:n})=>d("div",Object.assign({className:e},{children:[n,p("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:t,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-loader-2 yoo-file-h-4 yoo-file-w-4 yoo-file-animate-spin"},{children:p("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}))]})),lt=({attributes:e,children:t,blockId:o})=>{const[n,i]=x(!1),[r,l]=x(!1),{refs:a,floatingStyles:s}=et({placement:"bottom",open:n,onOpenChange:i,middleware:[Ae(),Pe(),ze(),ve(10)]});return d("div",Object.assign({className:"yoo-file-w-full yoo-file-user-select-none yoo-file-m-[20px_0_10px] yoo-file-relative yoo-file-flex"},e,{contentEditable:!1},{children:[d("button",Object.assign({type:"button",className:"yoopta-button yoo-file-p-[12px_36px_12px_12px] yoo-file-flex yoo-file-items-center yoo-file-text-left yoo-file-w-full yoo-file-overflow-hidden yoo-file-rounded-[3px] yoo-file-text-[14px] yoo-file-text-[rgba(55,53,47,0.65)] yoo-file-relative yoo-file-cursor-pointer yoo-file-border-none yoo-file-bg-[#efefef] yoo-file-transition-[background-color_100ms_ease-in] hover:yoo-file-bg-[#e3e3e3]",onClick:()=>i(!0),ref:a.setReference},{children:[p(r?rt:O,{className:"yoo-file-mr-2 yoo-file-user-select-none",width:24,height:24}),p("span",Object.assign({className:"yoo-file-font-medium"},{children:r?"Loading...":"Click to add file"})),r&&p("div",{className:"yoopta-button yoo-file-absolute yoo-file-top-0 yoo-file-left-0 yoo-file-h-full yoo-file-bg-[rgba(55,53,47,0.16)]",style:{width:"100%",transition:"width 100ms ease-in"}})]})),n&&p(it,{blockId:o,floatingStyles:s,refs:a,onClose:()=>i(!1),onSetLoading:e=>l(e)}),t]}))},at={left:N,center:S,right:F},{ExtendedBlockActions:st,BlockOptionsMenuGroup:ft,BlockOptionsMenuItem:ct,BlockOptionsSeparator:pt}=l,dt=({editor:e,block:t,props:n})=>{var i;const r=(null===(i=null==t?void 0:t.meta)||void 0===i?void 0:i.align)||"center",l=at[r];return d(st,Object.assign({onClick:()=>e.setPath({current:t.meta.order})},{children:[p(pt,{}),d(ft,{children:[p(ct,{children:d("button",Object.assign({type:"button",className:"yoopta-block-options-button",onClick:()=>{const n=["left","center","right"];if(!t)return;const i=n[(n.indexOf(r)+1)%n.length];o.updateBlock(e,t.id,{meta:Object.assign(Object.assign({},t.meta),{align:i})})}},{children:[p(l,{width:16,height:16,className:"yoo-file-w-4 yoo-file-h-4 yoo-file-mr-2"}),"Alignment"]}))}),p(ct,{children:d("button",Object.assign({type:"button",className:"yoopta-block-options-button",onClick:()=>{(null==n?void 0:n.src)&&window.open(null==n?void 0:n.src,"_blank")}},{children:[p(k,{width:16,height:16,className:"yoo-file-w-4 yoo-file-h-4 yoo-file-mr-2"}),"Open"]}))})]})]}))},ut={left:"flex-start",center:"center",right:"flex-end"},yt=new c({type:"File",elements:{file:{render:e=>{var{extendRender:t}=e,o=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}(e,["extendRender"]);const{element:n,attributes:i,children:l,blockId:c}=o,{name:u,src:y,format:g,size:h}=n.props||{},m=a(c),x=r(),b=s(),w=f({blockId:c});return y?t?t(o):d("div",Object.assign({contentEditable:!1,draggable:!1,className:"yoo-file-mt-4 yoo-file-relative yoo-file-flex yoopta-file"},i,{children:[w&&p("div",{className:"yoo-file-absolute yoo-file-pointer-events-none yoo-file-inset-0 yoo-file-bg-[rgba(35,131,226,0.14)] yoo-file-z-[81] yoo-file-rounded-[3px] yoo-file-opacity-100 yoo-file-transition-opacity yoo-file-duration-150 yoo-file-ease-in"}),p($,{name:u,format:g,src:y,size:h,blockId:c,align:m.meta.align}),!b&&p(dt,{block:m,editor:x,props:n.props}),l]})):p(lt,Object.assign({attributes:i,blockId:c},{children:l}))},props:{size:0,name:null,src:null,format:null,nodeType:"void"}}},commands:w,options:{display:{title:"File",description:"For files and more"},accept:""},parsers:{html:{serialize:(e,t,o)=>{const{align:n="left",depth:i=0}=o||{};return`<div style="margin-left: ${20*i}px; display: flex; width: 100%; justify-content: ${ut[n]||"left"}"><a data-meta-align="${n}" data-meta-depth="${i}" href="${e.props.src}" data-size="${e.props.size}" download="${e.props.name}" target="_blank" rel="noopener noreferrer">${e.props.format?`${e.props.name}.${e.props.format}`:`${e.props.name}`}</a></div>`},deserialize:{nodeNames:["A"],parse:t=>{if("A"===t.nodeName){const o=!!t.getAttribute("download"),n=t.getAttribute("href");if(!o)return;if(!n)return;const i=new URL(n),r=t.textContent||"",l=r.split(".").pop(),a=i.href,s=Number(t.dataset.size||0);return{id:e(),type:"file",children:[{text:""}],props:{name:r,format:l,src:a,size:s}}}}}},markdown:{serialize:(e,t)=>`[${e.props.name}](${e.props.src})`},email:{serialize:(e,t,o)=>{const{align:n="left",depth:i=0}=o||{};return`\n <table style="width:100%;">\n <tbody style="width:100%;">\n <tr>\n <td>\n <div style="margin-left: ${20*i}px; display: flex; width: 100%; justify-content: ${ut[n]||"left"}"><a data-meta-align="${n}" data-meta-depth="${i}" href="${e.props.src}" data-size="${e.props.size}" download="${e.props.name}" target="_blank" rel="noopener noreferrer">${e.props.format?`${e.props.name}.${e.props.format}`:`${e.props.name}`}</a></div>\n </td>\n </tr>\n </tbody>\n </table> \n `}}}});!function(e,t){void 0===t&&(t={});var o=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===o&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}(".yoo-file-pointer-events-none{pointer-events:none}.yoo-file-invisible{visibility:hidden}.yoo-file-absolute{position:absolute}.yoo-file-relative{position:relative}.yoo-file-inset-0{inset:0}.yoo-file-left-0{left:0}.yoo-file-top-0{top:0}.yoo-file-z-10{z-index:10}.yoo-file-z-\\[100\\]{z-index:100}.yoo-file-z-\\[81\\]{z-index:81}.yoo-file-m-\\[20px_0_10px\\]{margin:20px 0 10px}.yoo-file-ml-\\[12px\\]{margin-left:12px}.yoo-file-ml-\\[6px\\]{margin-left:6px}.yoo-file-ml-\\[8px\\]{margin-left:8px}.yoo-file-mr-2{margin-right:.5rem}.yoo-file-mr-\\[12px\\]{margin-right:12px}.yoo-file-mt-4{margin-top:1rem}.yoo-file-mt-\\[4px\\]{margin-top:4px}.yoo-file-flex{display:flex}.yoo-file-inline-flex{display:inline-flex}.yoo-file-h-4{height:1rem}.yoo-file-h-\\[32px\\]{height:32px}.yoo-file-h-\\[40px\\]{height:40px}.yoo-file-h-full{height:100%}.yoo-file-max-h-\\[420px\\]{max-height:420px}.yoo-file-w-4{width:1rem}.yoo-file-w-full{width:100%}.yoo-file-min-w-0{min-width:0}.yoo-file-min-w-\\[540px\\]{min-width:540px}.yoo-file-max-w-\\[calc\\(100vw-24px\\)\\]{max-width:calc(100vw - 24px)}.yoo-file-flex-shrink-0{flex-shrink:0}@keyframes yoo-file-spin{to{transform:rotate(1turn)}}.yoo-file-animate-spin{animation:yoo-file-spin 1s linear infinite}.yoo-file-cursor-pointer{cursor:pointer}.yoo-file-flex-col{flex-direction:column}.yoo-file-items-center{align-items:center}.yoo-file-justify-center{justify-content:center}.yoo-file-overflow-hidden{overflow:hidden}.yoo-file-whitespace-nowrap{white-space:nowrap}.yoo-file-rounded-\\[3px\\]{border-radius:3px}.yoo-file-rounded-\\[4px\\]{border-radius:4px}.yoo-file-border{border-width:1px}.yoo-file-border-b-\\[1px\\]{border-bottom-width:1px}.yoo-file-border-solid{border-style:solid}.yoo-file-border-none{border-style:none}.yoo-file-border-\\[rgba\\(55\\,53\\,47\\,0\\.16\\)\\]{border-color:rgba(55,53,47,.16)}.yoo-file-border-\\[transparent\\]{border-color:transparent}.yoo-file-bg-\\[\\#FFFFFF\\]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.yoo-file-bg-\\[\\#efefef\\]{--tw-bg-opacity:1;background-color:rgb(239 239 239/var(--tw-bg-opacity))}.yoo-file-bg-\\[rgba\\(35\\,131\\,226\\,0\\.14\\)\\]{background-color:rgba(35,131,226,.14)}.yoo-file-bg-\\[rgba\\(55\\,53\\,47\\,0\\.16\\)\\]{background-color:rgba(55,53,47,.16)}.yoo-file-bg-inherit{background-color:inherit}.yoo-file-p-\\[0_8px\\]{padding:0 8px}.yoo-file-p-\\[12px_36px_12px_12px\\]{padding:12px 36px 12px 12px}.yoo-file-px-2{padding-left:.5rem;padding-right:.5rem}.yoo-file-px-\\[12px\\]{padding-left:12px;padding-right:12px}.yoo-file-px-\\[8px\\]{padding-left:8px;padding-right:8px}.yoo-file-py-\\[6px\\]{padding-bottom:6px;padding-top:6px}.yoo-file-py-\\[8px\\]{padding-bottom:8px;padding-top:8px}.yoo-file-pb-\\[6px\\]{padding-bottom:6px}.yoo-file-pt-\\[6px\\]{padding-top:6px}.yoo-file-text-left{text-align:left}.yoo-file-text-\\[10px\\]{font-size:10px}.yoo-file-text-\\[14px\\]{font-size:14px}.yoo-file-font-medium{font-weight:500}.yoo-file-font-normal{font-weight:400}.yoo-file-leading-\\[1\\.2\\]{line-height:1.2}.yoo-file-text-\\[\\#000000\\]{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.yoo-file-text-\\[\\#37352fa6\\]{color:#37352fa6}.yoo-file-text-\\[rgb\\(55\\,53\\,47\\)\\]{--tw-text-opacity:1;color:rgb(55 53 47/var(--tw-text-opacity))}.yoo-file-text-\\[rgba\\(55\\,53\\,47\\,0\\.65\\)\\]{color:rgba(55,53,47,.65)}.yoo-file-opacity-100{opacity:1}.yoo-file-shadow-\\[rgb\\(15_15_15_\\/5\\%\\)_0px_0px_0px_1px\\,_rgb\\(15_15_15_\\/10\\%\\)_0px_3px_6px\\,_rgb\\(15_15_15_\\/20\\%\\)_0px_9px_24px\\]{--tw-shadow:rgb(15 15 15/5%) 0px 0px 0px 1px,hsla(0,0%,6%,.1) 0px 3px 6px,hsla(0,0%,6%,.2) 0px 9px 24px;--tw-shadow-colored:0px 0px 0px 1px var(--tw-shadow-color),0px 3px 6px var(--tw-shadow-color),0px 9px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.yoo-file-shadow-\\[rgb\\(55_53_47_\\/9\\%\\)_0px_-1px_0px_inset\\]{--tw-shadow:rgb(55 53 47/9%) 0px -1px 0px inset;--tw-shadow-colored:inset 0px -1px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.yoo-file-transition-\\[background-color_100ms_ease-in\\]{transition-duration:.15s;transition-property:background-color .1s ease-in;transition-timing-function:cubic-bezier(.4,0,.2,1)}.yoo-file-transition-\\[height_20ms_ease-in\\]{transition-duration:.15s;transition-property:height 20ms ease-in;transition-timing-function:cubic-bezier(.4,0,.2,1)}.yoo-file-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.yoo-file-duration-150{transition-duration:.15s}.yoo-file-ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}.yoopta-file .yoopta-extended-block-actions{opacity:0;transition:opacity .15s ease-in-out}.yoopta-file:hover .yoopta-extended-block-actions{opacity:1}.hover\\:yoo-file-border-\\[rgba\\(55\\2c 53\\2c 47\\2c 0\\.16\\)\\]:hover{border-color:rgba(55,53,47,.16)}.hover\\:yoo-file-bg-\\[\\#e3e3e3\\]:hover{--tw-bg-opacity:1;background-color:rgb(227 227 227/var(--tw-bg-opacity))}.hover\\:yoo-file-bg-\\[rgba\\(55\\2c 53\\2c 47\\2c 0\\.04\\)\\]:hover{background-color:rgba(55,53,47,.04)}");export{w as FileCommands,yt as default};
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{generateId as t,buildBlockData as o,Blocks as i,Elements as r,YooptaPlugin as s}from"@yoopta/editor";import{useState as l,useRef as a,useCallback as p}from"react";const d={buildFileElements:(e,n={})=>{var o,i,r,s,l,a,p,d,c,u;const m={id:null!==(i=null===(o=n.props)||void 0===o?void 0:o.id)&&void 0!==i?i:null,src:null!==(s=null===(r=n.props)||void 0===r?void 0:r.src)&&void 0!==s?s:null,name:null!==(a=null===(l=n.props)||void 0===l?void 0:l.name)&&void 0!==a?a:null,size:null!==(d=null===(p=n.props)||void 0===p?void 0:p.size)&&void 0!==d?d:null,format:null!==(u=null===(c=n.props)||void 0===c?void 0:c.format)&&void 0!==u?u:null};return{id:t(),type:"file",children:[{text:""}],props:m}},insertFile:(e,n={})=>{const{at:t,focus:r,props:s}=n,l=d.buildFileElements(e,{props:s}),a=o({value:[l],type:"File"});i.insertBlock(e,a.type,{focus:r,at:t,blockData:a})},deleteFile:(e,n)=>{i.deleteBlock(e,{blockId:n})},updateFile:(e,n,t)=>{r.updateElement(e,{blockId:n,type:"file",props:t})}},c=e=>{if(null==e||0===e)return"0 B";const n=["B","KB","MB","GB","TB"],t=Math.floor(Math.log(Math.abs(e))/Math.log(1024));if(0===t)return`${e} ${n[0]}`;const o=e/Math.pow(1024,t),i=o<10?2:o<100?1:0;return`${o.toFixed(i)} ${n[t]}`},u=e=>{var n,t;const o=e.match(/^([\d.]+)\s*(B|KB|MB|GB|TB)?$/i);if(!o)return null;const i=parseFloat(o[1]),r=(null!==(n=o[2])&&void 0!==n?n:"B").toUpperCase();return Math.round(i*(null!==(t={B:1,KB:1024,MB:1048576,GB:1073741824,TB:1099511627776}[r])&&void 0!==t?t:1))},m={left:"flex-start",center:"center",right:"flex-end"},f=new s({type:"File",elements:e("file",{render:e=>{const{name:t,src:o,size:i,format:r}=e.element.props,s=r?`${t}.${r}`:t;return n("div",Object.assign({},e.attributes,{children:[n("a",Object.assign({href:null!=o?o:void 0,download:null!=t?t:void 0,target:"_blank",rel:"noopener noreferrer"},{children:[null!=s?s:"Untitled file",i?` (${c(i)})`:""]})),e.children]}))},nodeType:"void",props:{id:null,src:null,name:null,size:null,format:null}}),commands:d,options:{display:{title:"File",description:"Upload and attach files"},accept:""},parsers:{html:{serialize:(e,n,t)=>{var o,i,r,s;const{align:l="left",depth:a=0}=null!=t?t:{},p=null!==(o=m[l])&&void 0!==o?o:"left",d=e.props.format?`${e.props.name}.${e.props.format}`:e.props.name,u=e.props.size?` (${c(e.props.size)})`:"";return`<div style="margin-left: ${20*a}px; display: flex; width: 100%; justify-content: ${p}">\n <a \n data-yoopta-file\n data-meta-align="${l}" \n data-meta-depth="${a}" \n href="${e.props.src}" \n data-size="${null!==(i=e.props.size)&&void 0!==i?i:0}" \n data-format="${null!==(r=e.props.format)&&void 0!==r?r:""}"\n data-id="${null!==(s=e.props.id)&&void 0!==s?s:""}"\n download="${e.props.name}" \n target="_blank" \n rel="noopener noreferrer"\n >${d}${u}</a>\n </div>`},deserialize:{nodeNames:["A"],parse:e=>{var n,o,i;if("A"===e.nodeName){const r=!!e.getAttribute("download"),s=!!e.getAttribute("data-yoopta-file"),l=e.getAttribute("href");if(!r&&!s)return;if(!l)return;try{const r=new URL(l,window.location.origin),s=null!==(n=e.textContent)&&void 0!==n?n:"";let a=(null!==(o=e.getAttribute("download"))&&void 0!==o?o:"")||s.split(" (")[0]||"",p=null;const d=a.lastIndexOf(".");d>0&&(p=a.slice(d+1),a=a.slice(0,d));const c=e.getAttribute("data-size"),u=c?Number(c):null,m=null!==(i=e.getAttribute("data-id"))&&void 0!==i?i:null,f=e.getAttribute("data-format");return f&&(p=f),{id:t(),type:"file",children:[{text:""}],props:{id:m,name:a||null,format:p,src:r.href,size:u}}}catch(e){}}}}},markdown:{serialize:e=>`[${e.props.format?`${e.props.name}.${e.props.format}`:e.props.name}](${e.props.src})\n`},email:{serialize:(e,n,t)=>{var o;const{align:i="left",depth:r=0}=null!=t?t:{},s=null!==(o=m[i])&&void 0!==o?o:"left",l=e.props.format?`${e.props.name}.${e.props.format}`:e.props.name,a=e.props.size?` (${c(e.props.size)})`:"";return`\n <table style="width:100%;">\n <tbody style="width:100%;">\n <tr>\n <td style="margin-left: ${20*r}px; display: flex; width: 100%; justify-content: ${s}; padding: 8px 0;">\n <a \n href="${e.props.src}" \n download="${e.props.name}" \n target="_blank" \n rel="noopener noreferrer"\n style="\n display: inline-flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n background-color: #f5f5f5;\n border-radius: 8px;\n text-decoration: none;\n color: #333;\n font-size: 14px;\n "\n >\n <span style="font-size: 20px;">📎</span>\n <span>${l}${a}</span>\n </a>\n </td>\n </tr>\n </tbody>\n </table> \n `}}}});function g(e,n,t,o){return new(t||(t=Promise))(function(i,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function l(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(s,l)}a((o=o.apply(e,n||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const v=({onError:e,onSuccess:n,onProgress:t,accept:o,maxSize:i,method:r="POST",endpoint:s,headers:d})=>{const[c,u]=l({loading:!1,progress:null,error:null,result:null}),m=a(null),f=p(()=>{m.current&&(m.current.abort(),m.current=null)},[]),g=p(()=>{u({loading:!1,progress:null,error:null,result:null})},[]);return Object.assign(Object.assign({},c),{xhrFetch:l=>new Promise((a,p)=>{if(l instanceof File){const n=((e,n,t)=>{if(n&&!n.split(",").map(e=>e.trim()).some(n=>{if(n.startsWith("."))return e.name.toLowerCase().endsWith(n.toLowerCase());if(n.endsWith("/*")){const t=n.replace("/*","");return e.type.startsWith(t)}return e.type===n}))return{message:`Invalid file type. Allowed types: ${n}`,code:"INVALID_TYPE"};if(t&&e.size>t)return{message:`File size exceeds ${(t/1024/1024).toFixed(2)}MB`,code:"FILE_TOO_LARGE"};return null})(l,o,i);if(n)return u(e=>Object.assign(Object.assign({},e),{error:n})),null==e||e(n),void p(n)}u({loading:!0,progress:{loaded:0,total:l instanceof File?l.size:0,percentage:0},error:null,result:null});const c=new XMLHttpRequest;m.current=c,c.upload.addEventListener("progress",e=>{if(e.lengthComputable){const n={loaded:e.loaded,total:e.total,percentage:Math.round(e.loaded/e.total*100)};u(e=>Object.assign(Object.assign({},e),{progress:n})),null==t||t(n)}}),c.addEventListener("load",()=>{if(c.status>=200&&c.status<300)try{const e=JSON.parse(c.responseText);u(n=>Object.assign(Object.assign({},n),{loading:!1,result:e})),null==n||n(e),a(e)}catch(n){const t={message:"Failed to parse server response",code:"PARSE_ERROR",status:c.status};u(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),null==e||e(t),p(t)}else{const n={message:`Upload failed with status ${c.status}`,code:"HTTP_ERROR",status:c.status};u(e=>Object.assign(Object.assign({},e),{loading:!1,error:n})),null==e||e(n),p(n)}}),c.addEventListener("error",()=>{const n={message:"Network error occurred",code:"NETWORK_ERROR"};u(e=>Object.assign(Object.assign({},e),{loading:!1,error:n})),null==e||e(n),p(n)}),c.addEventListener("abort",()=>{const e={message:"Upload cancelled",code:"ABORT"};u(n=>Object.assign(Object.assign({},n),{loading:!1,error:e})),p(e)}),c.addEventListener("timeout",()=>{const n={message:"Upload timeout",code:"TIMEOUT"};u(e=>Object.assign(Object.assign({},e),{loading:!1,error:n})),null==e||e(n),p(n)}),c.open(r,s),d&&Object.entries(d).forEach(([e,n])=>{c.setRequestHeader(e,n)}),c.timeout=3e5,c.send(l)}),cancel:f,reset:g})},b="https://docs.yoopta.dev/plugins/file",x=e=>{var n,t,o;const i=(e=>{if(null==e)return!1;if("function"!=typeof e&&"object"!=typeof e)throw new Error(`[Yoopta File] Invalid delete options. Expected a function or endpoint configuration object.\n\nSee documentation: ${b}`);if("object"==typeof e&&!e.endpoint)throw new Error(`[Yoopta File] Missing 'endpoint' in delete options. When using endpoint-based delete, you must provide an 'endpoint' URL.\n\nExample:\nFile.extend({\n options: {\n delete: {\n endpoint: '/api/delete-file',\n },\n },\n})\n\nSee documentation: ${b}`);return!0})(e),r=i?e:null,s=!!r&&(e=>"function"==typeof e)(r),[a,d]=l({loading:!1,progress:null,error:null,result:null}),c=!r||s?{endpoint:""}:r,u=v({endpoint:c.endpoint,method:null!==(n=c.method)&&void 0!==n?n:"DELETE",headers:null!==(t=c.headers)&&void 0!==t?t:{},fieldName:null!==(o=c.fieldName)&&void 0!==o?o:"file",onSuccess:c.onSuccess,onError:c.onError,onProgress:c.onProgress}),m=p(e=>g(void 0,void 0,void 0,function*(){var n,t,o,i,l,a,p;if(!r){const r=null!==(t=null===(n=e.props)||void 0===n?void 0:n.src)&&void 0!==t?t:"";return{id:null!==(i=null===(o=e.props)||void 0===o?void 0:o.id)&&void 0!==i?i:"",url:r}}if(!s)throw new Error("Custom delete called but options is not a function");const c=null===(l=e.props)||void 0===l?void 0:l.src;if(!c)throw new Error("File src is required");d(e=>Object.assign(Object.assign({},e),{loading:!0,error:null}));try{yield r(e);const n={id:null!==(p=null===(a=e.props)||void 0===a?void 0:a.id)&&void 0!==p?p:"",url:c};return d(e=>Object.assign(Object.assign({},e),{loading:!1,result:n})),n}catch(e){const n={message:e instanceof Error?e.message:"Delete failed",code:"CUSTOM_DELETE_ERROR"};throw d(e=>Object.assign(Object.assign({},e),{loading:!1,error:n})),n}}),[r,s]),f=p(()=>{d({loading:!1,progress:null,error:null,result:null})},[]),x=p(e=>{var n;const t=null===(n=e.props)||void 0===n?void 0:n.id;if(!t)throw new Error("File id is required");return u.xhrFetch(JSON.stringify({fileId:t}))},[u]);return i?s?Object.assign(Object.assign({},a),{deleteFile:m,cancel:()=>{},reset:f}):{loading:u.loading,progress:u.progress,error:u.error,result:u.result,deleteFile:x,cancel:u.cancel,reset:u.reset}:Object.assign(Object.assign({},a),{deleteFile:m,cancel:()=>{},reset:f})},h=e=>{var n,t,o;(e=>{if(null==e)throw new Error(`[Yoopta File] Upload options are not configured. Please provide 'upload' option when extending the File plugin.\n\nExample:\nFile.extend({\n options: {\n upload: async (file) => {\n // Upload file to your storage and return file props\n return { src: '...', name: file.name, size: file.size };\n },\n },\n})\n\nSee documentation: ${b}`);if("function"!=typeof e&&"object"!=typeof e)throw new Error(`[Yoopta File] Invalid upload options. Expected a function or endpoint configuration object.\n\nSee documentation: ${b}`);if("object"==typeof e&&!e.endpoint)throw new Error(`[Yoopta File] Missing 'endpoint' in upload options. When using endpoint-based upload, you must provide an 'endpoint' URL.\n\nExample:\nFile.extend({\n options: {\n upload: {\n endpoint: '/api/upload-file',\n },\n },\n})\n\nSee documentation: ${b}`)})(e);const i=e,r=(e=>"function"==typeof e)(i),[s,a]=l({loading:!1,progress:null,error:null,result:null}),d=r?{endpoint:""}:i,c=v({endpoint:d.endpoint,method:null!==(n=d.method)&&void 0!==n?n:"POST",headers:null!==(t=d.headers)&&void 0!==t?t:{},fieldName:null!==(o=d.fieldName)&&void 0!==o?o:"file",maxSize:d.maxSize,accept:d.accept,onSuccess:d.onSuccess,onError:d.onError,onProgress:d.onProgress}),u=p(e=>g(void 0,void 0,void 0,function*(){var n,t,o,s;if(!r)throw new Error("Custom upload called but options is not a function");a(n=>Object.assign(Object.assign({},n),{loading:!0,progress:{loaded:0,total:e.size,percentage:0},error:null}));try{const r=e=>{a(n=>Object.assign(Object.assign({},n),{progress:e}))},l=yield i(e,r),p={id:null!==(n=l.id)&&void 0!==n?n:"",url:null!==(t=l.src)&&void 0!==t?t:"",name:null!==(o=l.name)&&void 0!==o?o:e.name,size:null!==(s=l.size)&&void 0!==s?s:e.size,format:l.format};return a(n=>Object.assign(Object.assign({},n),{loading:!1,progress:{loaded:e.size,total:e.size,percentage:100},result:p})),p}catch(e){const n={message:e instanceof Error?e.message:"Upload failed",code:"CUSTOM_UPLOAD_ERROR"};throw a(e=>Object.assign(Object.assign({},e),{loading:!1,error:n})),n}}),[i,r]),m=p(()=>{a({loading:!1,progress:null,error:null,result:null})},[]),f=p(e=>{var n;const t=new FormData;return t.append(null!==(n=d.fieldName)&&void 0!==n?n:"yoopta-file",e),c.xhrFetch(t)},[d.fieldName,c]);return r?Object.assign(Object.assign({},s),{upload:u,cancel:()=>{},reset:m}):{loading:c.loading,progress:c.progress,error:c.error,result:c.result,upload:f,cancel:c.cancel,reset:c.reset}},y=[{type:"pdf",extensions:[".pdf"],mimeTypes:["application/pdf"],label:"PDF"},{type:"document",extensions:[".doc",".docx",".odt",".rtf",".pages"],mimeTypes:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.oasis.opendocument.text","application/rtf","application/x-iwork-pages-sffpages"],label:"Document"},{type:"spreadsheet",extensions:[".xls",".xlsx",".csv",".ods",".numbers"],mimeTypes:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/csv","application/vnd.oasis.opendocument.spreadsheet","application/x-iwork-numbers-sffnumbers"],label:"Spreadsheet"},{type:"presentation",extensions:[".ppt",".pptx",".odp",".key"],mimeTypes:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.oasis.opendocument.presentation","application/x-iwork-keynote-sffkey"],label:"Presentation"},{type:"image",extensions:[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico",".tiff"],mimeTypes:["image/jpeg","image/png","image/gif","image/webp","image/svg+xml","image/bmp","image/x-icon","image/tiff"],label:"Image"},{type:"video",extensions:[".mp4",".webm",".mov",".avi",".mkv",".wmv",".flv"],mimeTypes:["video/mp4","video/webm","video/quicktime","video/x-msvideo","video/x-matroska","video/x-ms-wmv","video/x-flv"],label:"Video"},{type:"audio",extensions:[".mp3",".wav",".ogg",".flac",".aac",".m4a",".wma"],mimeTypes:["audio/mpeg","audio/wav","audio/ogg","audio/flac","audio/aac","audio/mp4","audio/x-ms-wma"],label:"Audio"},{type:"archive",extensions:[".zip",".rar",".7z",".tar",".gz",".bz2"],mimeTypes:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/gzip","application/x-bzip2"],label:"Archive"},{type:"code",extensions:[".js",".ts",".jsx",".tsx",".html",".css",".json",".xml",".py",".java",".c",".cpp",".h",".rb",".php",".go",".rs",".swift",".kt"],mimeTypes:["text/javascript","application/javascript","text/typescript","text/html","text/css","application/json","application/xml","text/x-python","text/x-java-source","text/x-c","text/x-c++"],label:"Code"},{type:"text",extensions:[".txt",".md",".log",".ini",".cfg"],mimeTypes:["text/plain","text/markdown"],label:"Text"}],w=(e,n)=>{var t;if(!e&&!n)return"unknown";const o=e?`.${null===(t=e.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`:null;for(const e of y){if(o&&e.extensions.includes(o))return e.type;if(n&&e.mimeTypes.includes(n))return e.type}return"unknown"},j=e=>y.find(n=>n.type===e),O=(e,n)=>{var t;const o=w(e,n),i=j(o);return null!==(t=null==i?void 0:i.label)&&void 0!==t?t:"File"},E=e=>{var n,t;if(!e)return null;const o=e.split(".");return o.length<2?null:null!==(t=null===(n=o.pop())||void 0===n?void 0:n.toLowerCase())&&void 0!==t?t:null},$=(e,n,t)=>w(n,t)===e;export{y as FILE_TYPE_CONFIGS,d as FileCommands,f as default,c as formatFileSize,E as getFileExtension,w as getFileType,j as getFileTypeConfig,O as getFileTypeLabel,$ as isFileType,u as parseFileSize,x as useFileDelete,h as useFileUpload};
@@ -1,5 +1,5 @@
1
1
  import { YooptaPlugin } from '@yoopta/editor';
2
- import { FileElementMap, FilePluginOptions } from '../types';
2
+ import type { FileElementMap, FilePluginOptions } from '../types';
3
3
  declare const File: YooptaPlugin<FileElementMap, FilePluginOptions>;
4
4
  export { File };
5
- //# sourceMappingURL=index.d.ts.map
5
+ //# sourceMappingURL=file-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/file-plugin.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAc,MAAM,gBAAgB,CAAC;AAG1D,OAAO,KAAK,EAAE,cAAc,EAAoB,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAiBpF,QAAA,MAAM,IAAI,iDAiKR,CAAC;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,21 +1,104 @@
1
1
  import { type SlateElement } from '@yoopta/editor';
2
2
  export type FileElementProps = {
3
- size: number | null;
4
- name: string | null;
3
+ id?: string | null;
5
4
  src: string | null;
5
+ name: string | null;
6
+ size: number | null;
6
7
  format?: string | null;
7
8
  };
8
9
  export type FilePluginElements = 'file';
9
10
  export type FileElement = SlateElement<'file', FileElementProps>;
10
- export type FileUploadResponse = Partial<FileElementProps> & {
11
+ export type FileElementMap = {
12
+ file: FileElement;
13
+ };
14
+ export type FileUploadResponse = {
15
+ id?: string;
11
16
  src: string;
17
+ name?: string;
18
+ size?: number;
19
+ format?: string;
20
+ };
21
+ export type FileUploadProgress = {
22
+ loaded: number;
23
+ total: number;
24
+ percentage: number;
25
+ };
26
+ export type FileUploadError = {
27
+ message: string;
28
+ code?: string;
29
+ status?: number;
30
+ };
31
+ export type FileUploadResult = {
32
+ id: string;
33
+ url: string;
34
+ name?: string;
35
+ size?: number;
36
+ format?: string;
37
+ [key: string]: unknown;
38
+ };
39
+ export type FileUploadState = {
40
+ loading: boolean;
41
+ progress: FileUploadProgress | null;
42
+ error: FileUploadError | null;
43
+ result: FileUploadResult | null;
44
+ };
45
+ export type FileUploadFn = (file: File, onProgress?: (progress: FileUploadProgress) => void) => Promise<FileUploadResponse>;
46
+ export type FileDeleteFn = (element: FileElement) => Promise<unknown>;
47
+ export type FileUploadEndpointOptions = {
48
+ endpoint: string;
49
+ method?: 'POST' | 'PUT' | 'PATCH';
50
+ headers?: Record<string, string>;
51
+ fieldName?: string;
52
+ maxSize?: number;
53
+ accept?: string;
54
+ onProgress?: (progress: FileUploadProgress) => void;
55
+ onSuccess?: (result: FileUploadResult) => void;
56
+ onError?: (error: FileUploadError) => void;
57
+ };
58
+ export type FileDeleteEndpointOptions = {
59
+ endpoint: string;
60
+ method?: 'DELETE' | 'PATCH';
61
+ headers?: Record<string, string>;
62
+ fieldName?: string;
63
+ onProgress?: (progress: FileUploadProgress) => void;
64
+ onSuccess?: (result: FileUploadResult) => void;
65
+ onError?: (error: FileUploadError) => void;
66
+ };
67
+ export type FileUploadOptions = FileUploadEndpointOptions | FileUploadFn;
68
+ export type FileDeleteOptions = FileDeleteEndpointOptions | FileDeleteFn;
69
+ export type UseFileUploadReturn = {
70
+ upload: (file: File) => Promise<FileUploadResult>;
71
+ cancel: () => void;
72
+ reset: () => void;
73
+ } & FileUploadState;
74
+ export type UseFileDeleteReturn = {
75
+ deleteFile: (element: FileElement) => Promise<unknown>;
76
+ cancel: () => void;
77
+ reset: () => void;
78
+ } & FileUploadState;
79
+ export type FileType = 'pdf' | 'document' | 'spreadsheet' | 'presentation' | 'image' | 'video' | 'audio' | 'archive' | 'code' | 'text' | 'unknown';
80
+ export type FileTypeConfig = {
81
+ type: FileType;
82
+ extensions: string[];
83
+ mimeTypes: string[];
84
+ label: string;
12
85
  };
13
86
  export type FilePluginOptions = {
14
- onUpload?: (file: File) => Promise<FileUploadResponse>;
15
- onError?: (error: any) => void;
87
+ upload?: FileUploadOptions;
88
+ delete?: FileDeleteOptions;
89
+ onError?: (error: FileUploadError) => void;
16
90
  accept?: string;
91
+ maxFileSize?: number;
17
92
  };
18
- export type FileElementMap = {
19
- file: FileElement;
93
+ export type XHRRequestOptions = {
94
+ endpoint: string;
95
+ method?: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
96
+ headers?: Record<string, string>;
97
+ fieldName?: string;
98
+ maxSize?: number;
99
+ accept?: string;
100
+ onProgress?: (progress: FileUploadProgress) => void;
101
+ onSuccess?: (result: FileUploadResult) => void;
102
+ onError?: (error: FileUploadError) => void;
20
103
  };
21
104
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACxC,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,23 @@
1
+ import type { FileType, FileTypeConfig } from '../types';
2
+ export declare const FILE_TYPE_CONFIGS: FileTypeConfig[];
3
+ /**
4
+ * Detect file type from filename or MIME type
5
+ */
6
+ export declare const getFileType: (filename?: string | null, mimeType?: string | null) => FileType;
7
+ /**
8
+ * Get file type configuration
9
+ */
10
+ export declare const getFileTypeConfig: (fileType: FileType) => FileTypeConfig | undefined;
11
+ /**
12
+ * Get file type label
13
+ */
14
+ export declare const getFileTypeLabel: (filename?: string | null, mimeType?: string | null) => string;
15
+ /**
16
+ * Get file extension from filename
17
+ */
18
+ export declare const getFileExtension: (filename?: string | null) => string | null;
19
+ /**
20
+ * Check if file is of a specific type
21
+ */
22
+ export declare const isFileType: (fileType: FileType, filename?: string | null, mimeType?: string | null) => boolean;
23
+ //# sourceMappingURL=file-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-type.d.ts","sourceRoot":"","sources":["../../src/utils/file-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGzD,eAAO,MAAM,iBAAiB,EAAE,cAAc,EA8I7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,cAAe,MAAM,GAAG,IAAI,aAAa,MAAM,GAAG,IAAI,KAAG,QAiBhF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,aAAc,QAAQ,KAAG,cAAc,GAAG,SACV,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,gBAAgB,cAAe,MAAM,GAAG,IAAI,aAAa,MAAM,GAAG,IAAI,KAAG,MAIrF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,cAAe,MAAM,GAAG,IAAI,KAAG,MAAM,GAAG,IAKpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,aACX,QAAQ,aACP,MAAM,GAAG,IAAI,aACb,MAAM,GAAG,IAAI,KACvB,OAAuD,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Format file size to human-readable string
3
+ */
4
+ export declare const formatFileSize: (bytes: number | null | undefined) => string;
5
+ /**
6
+ * Parse file size string to bytes
7
+ */
8
+ export declare const parseFileSize: (sizeString: string) => number | null;
9
+ //# sourceMappingURL=format-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-size.d.ts","sourceRoot":"","sources":["../../src/utils/format-size.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAajE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,eAAgB,MAAM,KAAG,MAAM,GAAG,IAgB3D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoopta/file",
3
- "version": "4.9.9",
3
+ "version": "6.0.0-beta.10",
4
4
  "description": "File plugin for Yoopta Editor",
5
5
  "author": "Darginec05 <devopsbanda@gmail.com>",
6
6
  "homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
@@ -14,12 +14,13 @@
14
14
  "dist/"
15
15
  ],
16
16
  "peerDependencies": {
17
- "@yoopta/editor": ">=4.0.0",
18
- "react": ">=17.0.2",
19
- "react-dom": ">=17.0.2"
17
+ "@yoopta/editor": "6.0.0-beta.4",
18
+ "react": ">=18.2.0",
19
+ "react-dom": ">=18.2.0"
20
20
  },
21
21
  "publishConfig": {
22
- "registry": "https://registry.npmjs.org"
22
+ "registry": "https://registry.npmjs.org",
23
+ "access": "public"
23
24
  },
24
25
  "repository": {
25
26
  "type": "git",
@@ -34,9 +35,5 @@
34
35
  "bugs": {
35
36
  "url": "https://github.com/Darginec05/Yoopta-Editor/issues"
36
37
  },
37
- "dependencies": {
38
- "@floating-ui/react": "^0.26.9",
39
- "@radix-ui/react-icons": "^1.3.0"
40
- },
41
- "gitHead": "e8260945d74e2b26e8c66a3ddf4da8ceb45bc74d"
38
+ "gitHead": "cab1b9a3d5f104c46da98df464f1806d968b12fd"
42
39
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAS7D,QAAA,MAAM,IAAI,iDAuGR,CAAC;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC"}
package/dist/ui/File.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { PluginElementRenderProps } from '@yoopta/editor';
2
- declare const FileRender: ({ extendRender, ...props }: PluginElementRenderProps) => import("react/jsx-runtime").JSX.Element;
3
- export { FileRender };
4
- //# sourceMappingURL=File.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../src/ui/File.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,wBAAwB,EAIzB,MAAM,gBAAgB,CAAC;AAIxB,QAAA,MAAM,UAAU,+BAAgC,wBAAwB,4CAkCvE,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,10 +0,0 @@
1
- import { YooEditor, YooptaBlockData } from '@yoopta/editor';
2
- import { FileElementProps } from '../types';
3
- type Props = {
4
- editor: YooEditor;
5
- block: YooptaBlockData;
6
- props?: FileElementProps;
7
- };
8
- declare const FileBlockOptions: ({ editor, block, props: fileProps }: Props) => import("react/jsx-runtime").JSX.Element;
9
- export { FileBlockOptions };
10
- //# sourceMappingURL=FileBlockOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileBlockOptions.d.ts","sourceRoot":"","sources":["../../src/ui/FileBlockOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAU5C,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,QAAA,MAAM,gBAAgB,wCAAyC,KAAK,4CAoCnE,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,8 +0,0 @@
1
- import { FileElementProps } from '../types';
2
- type FileComponentProps = Partial<FileElementProps> & {
3
- blockId: string;
4
- align?: 'left' | 'center' | 'right';
5
- };
6
- declare const FileComponent: ({ name, src, size, format, align }: FileComponentProps) => import("react/jsx-runtime").JSX.Element | null;
7
- export { FileComponent, FileComponentProps };
8
- //# sourceMappingURL=FileComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileComponent.d.ts","sourceRoot":"","sources":["../../src/ui/FileComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C,KAAK,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC,CAAC;AAUF,QAAA,MAAM,aAAa,uCAAwC,kBAAkB,mDA6B5E,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,11 +0,0 @@
1
- import { CSSProperties } from 'react';
2
- type Props = {
3
- floatingStyles: CSSProperties;
4
- refs: any;
5
- blockId: string;
6
- onClose: () => void;
7
- onSetLoading: (_s: boolean) => void;
8
- };
9
- declare const FilePlaceholderUploader: ({ floatingStyles, refs, onClose, blockId, onSetLoading }: Props) => import("react/jsx-runtime").JSX.Element;
10
- export { FilePlaceholderUploader };
11
- //# sourceMappingURL=FilePlaceholderUploader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilePlaceholderUploader.d.ts","sourceRoot":"","sources":["../../src/ui/FilePlaceholderUploader.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,KAAK,KAAK,GAAG;IACX,cAAc,EAAE,aAAa,CAAC;IAC9B,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,CAAC;AAIF,QAAA,MAAM,uBAAuB,6DAA8D,KAAK,4CA2B/F,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -1,9 +0,0 @@
1
- type Props = {
2
- onClose: () => void;
3
- blockId: string;
4
- accept?: string;
5
- onSetLoading: (_s: boolean) => void;
6
- };
7
- declare const FileUploader: ({ accept, onClose, blockId, onSetLoading }: Props) => import("react/jsx-runtime").JSX.Element;
8
- export { FileUploader };
9
- //# sourceMappingURL=FileUploader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileUploader.d.ts","sourceRoot":"","sources":["../../src/ui/FileUploader.tsx"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF,QAAA,MAAM,YAAY,+CAAqD,KAAK,4CAsD3E,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,10 +0,0 @@
1
- import { ReactNode } from 'react';
2
- type Props = {
3
- className?: string;
4
- children?: ReactNode;
5
- width?: number;
6
- height?: number;
7
- };
8
- declare const Loader: ({ className, width, height, children }: Props) => import("react/jsx-runtime").JSX.Element;
9
- export { Loader };
10
- //# sourceMappingURL=Loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Loader.d.ts","sourceRoot":"","sources":["../../src/ui/Loader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,QAAA,MAAM,MAAM,2CAA4C,KAAK,4CAoB5D,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -1,7 +0,0 @@
1
- declare const Placeholder: ({ attributes, children, blockId }: {
2
- attributes: any;
3
- children: any;
4
- blockId: any;
5
- }) => import("react/jsx-runtime").JSX.Element;
6
- export { Placeholder };
7
- //# sourceMappingURL=Placeholder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Placeholder.d.ts","sourceRoot":"","sources":["../../src/ui/Placeholder.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,WAAW;;;;6CAuDhB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}