inital commit

This commit is contained in:
2026-01-01 15:25:19 +05:30
commit f0ae49465a
36361 changed files with 4894111 additions and 0 deletions

18
node_modules/jodit/esm/modules/uploader/config.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module modules/uploader
*/
import type { IUploader, IUploaderOptions } from "../../types/index";
declare module 'jodit/config' {
interface Config {
/**
* Enable drag and drop file editor
*/
enableDragAndDropFileToEditor: boolean;
uploader: IUploaderOptions<IUploader>;
}
}

86
node_modules/jodit/esm/modules/uploader/config.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { isArray } from "../../core/helpers/checker/is-array.js";
import { isJoditObject } from "../../core/helpers/checker/is-jodit-object.js";
import { Config } from "../../config.js";
/**
* Module for processing download documents and images by Drag and Drop
* Drag and Drop files
*/
Config.prototype.enableDragAndDropFileToEditor = true;
Config.prototype.uploader = {
url: '',
insertImageAsBase64URI: false,
imagesExtensions: ['jpg', 'png', 'jpeg', 'gif'],
headers: null,
data: null,
filesVariableName(i) {
return `files[${i}]`;
},
withCredentials: false,
pathVariableName: 'path',
format: 'json',
method: 'POST',
prepareData(formData) {
return formData;
},
isSuccess(resp) {
return resp.success;
},
getMessage(resp) {
return resp.data.messages !== undefined && isArray(resp.data.messages)
? resp.data.messages.join(' ')
: '';
},
/**
* @see [[IUploader.processFileName]]
*/
processFileName(key, file, name) {
return [key, file, name];
},
process(resp) {
return resp.data;
},
error(e) {
this.j.message.error(e.message, 4000);
},
getDisplayName(baseurl, filename) {
return baseurl + filename;
},
defaultHandlerSuccess(resp) {
const j = this.j || this;
if (!isJoditObject(j)) {
return;
}
if (resp.files && resp.files.length) {
resp.files.forEach((filename, index) => {
const [tagName, attr] = resp.isImages && resp.isImages[index]
? ['img', 'src']
: ['a', 'href'];
const elm = j.createInside.element(tagName);
elm.setAttribute(attr, resp.baseurl + filename);
if (tagName === 'a') {
elm.textContent = j.o.uploader.getDisplayName.call(this, resp.baseurl, filename);
}
if (tagName === 'img') {
j.s.insertImage(elm, null, j.o.imageDefaultWidth);
}
else {
j.s.insertNode(elm);
}
});
}
},
defaultHandlerError(e) {
this.j.message.error(e.message);
},
contentType(requestData) {
return this.ow.FormData !== undefined &&
typeof requestData !== 'string'
? false
: 'application/x-www-form-urlencoded; charset=UTF-8';
}
};

View File

@@ -0,0 +1,10 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module modules/uploader
*/
import type { BuildDataResult, IDictionary, IUploader } from "../../../types/index";
export declare function buildData(uploader: IUploader, data: FormData | IDictionary<string> | string): BuildDataResult;

View File

@@ -0,0 +1,27 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { isFunction, isString } from "../../../core/helpers/index.js";
export function buildData(uploader, data) {
if (isFunction(uploader.o.buildData)) {
return uploader.o.buildData.call(uploader, data);
}
const FD = uploader.ow.FormData;
if (FD !== undefined) {
if (data instanceof FD) {
return data;
}
if (isString(data)) {
return data;
}
const newData = new FD();
const dict = data;
Object.keys(dict).forEach(key => {
newData.append(key, dict[key]);
});
return newData;
}
return data;
}

View File

@@ -0,0 +1,12 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module modules/uploader
*/
/**
* Convert dataURI to Blob
*/
export declare function dataURItoBlob(dataURI: string): Blob;

View File

@@ -0,0 +1,24 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module modules/uploader
*/
/**
* Convert dataURI to Blob
*/
export function dataURItoBlob(dataURI) {
// convert base64 to raw binary data held in a string
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
const byteString = atob(dataURI.split(',')[1]),
// separate out the mime component
mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0],
// write the bytes of the string to an ArrayBuffer
ab = new ArrayBuffer(byteString.length), ia = new Uint8Array(ab);
for (let i = 0; i < byteString.length; i += 1) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ia.buffer], { type: mimeString });
}

View File

@@ -0,0 +1,16 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module modules/uploader
*/
import type { Nullable } from "../../../types/index";
export * from "./build-data";
export * from "./data-uri-to-blob";
export * from "./process-old-browser-drag";
export * from "./send";
export * from "./send-files";
export declare function hasFiles(data: Nullable<DataTransfer>): data is DataTransfer;
export declare function hasItems(data: Nullable<DataTransfer>): data is DataTransfer;

View File

@@ -0,0 +1,16 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
export * from "./build-data.js";
export * from "./data-uri-to-blob.js";
export * from "./process-old-browser-drag.js";
export * from "./send.js";
export * from "./send-files.js";
export function hasFiles(data) {
return Boolean(data && data.files && data.files.length > 0);
}
export function hasItems(data) {
return Boolean(data && data.items && data.items.length > 0);
}

View File

@@ -0,0 +1,10 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module modules/uploader
*/
import type { HandlerError, HandlerSuccess, IUploader } from "../../../types/index";
export declare function processOldBrowserDrag(self: IUploader, cData: DataTransfer | null, handlerSuccess?: HandlerSuccess, handlerError?: HandlerError, onFinally?: () => void): void;

View File

@@ -0,0 +1,33 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { TEXT_PLAIN } from "../../../core/constants.js";
import { Dom } from "../../../core/dom/index.js";
import { getContainer } from "../../../core/global.js";
import { attr, isJoditObject } from "../../../core/helpers/index.js";
import { dataURItoBlob } from "./data-uri-to-blob.js";
import { sendFiles } from "./send-files.js";
export function processOldBrowserDrag(self, cData, handlerSuccess, handlerError, onFinally) {
if (cData && (!cData.types.length || cData.types[0] !== TEXT_PLAIN)) {
const div = self.j.c.div('', {
tabindex: -1,
style: 'left: -9999px; top: 0; width: 0; height: 100%;line-height: 140%; ' +
'overflow: hidden; position: fixed; z-index: 2147483647; word-break: break-all;',
contenteditable: true
});
getContainer(self.j, self.constructor).appendChild(div);
const selection = isJoditObject(self.j) ? self.j.s.save() : null, restore = () => selection && isJoditObject(self.j) && self.j.s.restore();
div.focus();
self.j.async.setTimeout(() => {
const child = div.firstChild;
Dom.safeRemove(div);
if (child && child.hasAttribute('src')) {
const src = attr(child, 'src') || '';
restore();
sendFiles(self, [dataURItoBlob(src)], handlerSuccess, handlerError).finally(onFinally);
}
}, self.j.defaultTimeout);
}
}

View File

@@ -0,0 +1,13 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module modules/uploader
*/
import type { HandlerError, HandlerSuccess, IUploader } from "../../../types/index";
/**
* Send files to server
*/
export declare function sendFiles(uploader: IUploader, files: FileList | File[] | null, handlerSuccess?: HandlerSuccess, handlerError?: HandlerError, process?: (form: FormData) => void): Promise<any>;

View File

@@ -0,0 +1,112 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { error, isFunction, isPlainObject, toArray } from "../../../core/helpers/index.js";
import { send } from "./send.js";
/**
* Send files to server
*/
export function sendFiles(uploader, files, handlerSuccess, handlerError, process) {
if (!files) {
return Promise.reject(error('Need files'));
}
const { o } = uploader;
let fileList = toArray(files);
if (!fileList.length) {
return Promise.reject(error('Need files'));
}
const promises = [];
if (o.insertImageAsBase64URI) {
readImagesWithReader(fileList, o.imagesExtensions, promises, uploader, handlerSuccess, o.defaultHandlerSuccess);
}
fileList = fileList.filter(a => a);
if (fileList.length) {
const form = new FormData();
form.append(o.pathVariableName, uploader.path);
form.append('source', uploader.source);
let file;
for (let i = 0; i < fileList.length; i += 1) {
file = fileList[i];
if (file) {
const hasRealExtension = /\.\w+$/.test(file.name);
const mime = file.type.match(/\/([a-z0-9]+)/i);
const extension = mime && mime[1] ? mime[1].toLowerCase() : '';
let newName = fileList[i].name ||
Math.random().toString().replace('.', '');
if (!hasRealExtension && extension) {
let extForReg = extension;
if (['jpeg', 'jpg'].includes(extForReg)) {
extForReg = 'jpeg|jpg';
}
const reEnd = new RegExp('.(' + extForReg + ')$', 'i');
if (!reEnd.test(newName)) {
newName += '.' + extension;
}
}
const [key, iFile, name] = o.processFileName.call(uploader, o.filesVariableName(i), fileList[i], newName);
form.append(key, iFile, name);
}
}
if (process) {
process(form);
}
if (o.data && isPlainObject(o.data)) {
Object.keys(o.data).forEach((key) => {
form.append(key, o.data[key]);
});
}
o.prepareData.call(uploader, form);
promises.push(send(uploader, form)
.then(resp => {
if (o.isSuccess.call(uploader, resp)) {
const handler = isFunction(handlerSuccess)
? handlerSuccess
: o.defaultHandlerSuccess;
handler.call(uploader, o.process.call(uploader, resp));
return resp;
}
const handler = isFunction(handlerError)
? handlerError
: o.defaultHandlerError;
handler.call(uploader, error(o.getMessage.call(uploader, resp)));
return resp;
})
.then(() => {
uploader.j.events && uploader.j.e.fire('filesWereUploaded');
}));
}
return Promise.all(promises);
}
function readImagesWithReader(fileList, imagesExtensions, promises, uploader, handlerSuccess, defaultHandlerSuccess) {
let file, i;
for (i = 0; i < fileList.length; i += 1) {
file = fileList[i];
if (file && file.type) {
const mime = file.type.match(/\/([a-z0-9]+)/i);
const extension = mime[1] ? mime[1].toLowerCase() : '';
if (!imagesExtensions.includes(extension)) {
continue;
}
const reader = new FileReader();
promises.push(uploader.j.async.promise((resolve, reject) => {
reader.onerror = reject;
reader.onloadend = () => {
const resp = {
baseurl: '',
files: [reader.result],
isImages: [true]
};
const handler = isFunction(handlerSuccess)
? handlerSuccess
: defaultHandlerSuccess;
handler.call(uploader, resp);
resolve(resp);
};
reader.readAsDataURL(file);
}));
fileList[i] = null;
}
}
}

View File

@@ -0,0 +1,12 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module modules/uploader
*/
import type { IDictionary, IUploader, IUploaderAnswer } from "../../../types/index";
import { Ajax } from "../../../core/request/index";
export declare const ajaxInstances: WeakMap<IUploader, Set<Ajax>>;
export declare function send(uploader: IUploader, data: FormData | IDictionary<string>): Promise<IUploaderAnswer>;

View File

@@ -0,0 +1,82 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { isFunction, isPromise } from "../../../core/helpers/index.js";
import { Ajax } from "../../../core/request/index.js";
import { buildData } from "./build-data.js";
export const ajaxInstances = new WeakMap();
export function send(uploader, data) {
const requestData = buildData(uploader, data);
const showProgress = (progress) => {
uploader.j.progressbar.show().progress(progress);
if (progress >= 100) {
uploader.j.progressbar.hide();
}
};
let sendData = (request, showProgress) => {
const ajax = new Ajax({
xhr: () => {
const xhr = new XMLHttpRequest();
if (uploader.j.ow.FormData !== undefined &&
xhr.upload) {
showProgress(10);
xhr.upload.addEventListener('progress', evt => {
if (evt.lengthComputable) {
let percentComplete = evt.loaded / evt.total;
percentComplete *= 100;
showProgress(percentComplete);
}
}, false);
}
else {
showProgress(100);
}
return xhr;
},
method: uploader.o.method || 'POST',
data: request,
url: isFunction(uploader.o.url)
? uploader.o.url(request)
: uploader.o.url,
headers: uploader.o.headers,
queryBuild: uploader.o.queryBuild,
contentType: uploader.o.contentType.call(uploader, request),
withCredentials: uploader.o.withCredentials || false
});
let instances = ajaxInstances.get(uploader);
if (!instances) {
instances = new Set();
ajaxInstances.set(uploader, instances);
}
instances.add(ajax);
uploader.j.e.one('beforeDestruct', ajax.destruct);
return ajax
.send()
.then(resp => resp.json())
.catch(error => {
return {
success: false,
data: {
messages: [error]
}
};
})
.finally(() => {
ajax.destruct();
instances === null || instances === void 0 ? void 0 : instances.delete(ajax);
});
};
if (isFunction(uploader.o.customUploadFunction)) {
sendData = uploader.o.customUploadFunction;
}
if (isPromise(requestData)) {
return requestData
.then(data => sendData(data, showProgress))
.catch(error => {
uploader.o.error.call(uploader, error);
});
}
return sendData(requestData, showProgress);
}

59
node_modules/jodit/esm/modules/uploader/uploader.d.ts generated vendored Normal file
View File

@@ -0,0 +1,59 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* [[include:modules/uploader/README.md]]
* @packageDocumentation
* @module modules/uploader
*/
import type { HandlerError, HandlerSuccess, IUploader, IUploaderOptions, IViewBased } from "../../types/index";
import { ViewComponent } from "../../core/component/index";
import "./config";
export declare class Uploader extends ViewComponent implements IUploader {
readonly jodit: IViewBased;
get j(): IViewBased;
/** @override */
className(): string;
path: string;
source: string;
readonly options: IUploaderOptions<IUploader>;
get o(): this['options'];
/**
* It sets the path for uploading files
*/
setPath(path: string): this;
/**
* It sets the source for connector
*/
setSource(source: string): this;
/**
* Set the handlers Drag and Drop to `$form`
*
* @param form - Form or any Node on which you can drag and drop the file. In addition will be processed
* <code>&lt;input type="file" &gt;</code>
* @param handlerSuccess - The function be called when a successful uploading files
* to the server
* @param handlerError - The function that will be called during a failed download files a server
* @example
* ```javascript
* var $form = jQuery('<form><input type="text" typpe="file"></form>');
* jQuery('body').append($form);
* Jodit.editors.someidfoeditor.uploader.bind($form[0], function (files) {
* var i;
* for (i = 0; i < data.files.length; i += 1) {
* parent.s.insertImage(data.files[i])
* }
* });
* ```
*/
bind(form: HTMLElement, handlerSuccess?: HandlerSuccess, handlerError?: HandlerError): void;
private attachEvents;
/**
* Upload images to a server by its URL, making it through the connector server.
*/
uploadRemoteImage(url: string, handlerSuccess?: HandlerSuccess, handlerError?: HandlerError): void;
constructor(editor: IViewBased, options?: IUploaderOptions<Uploader>);
destruct(): any;
}

191
node_modules/jodit/esm/modules/uploader/uploader.js generated vendored Normal file
View File

@@ -0,0 +1,191 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { STATUSES, ViewComponent } from "../../core/component/index.js";
import { IS_ES_NEXT, IS_IE } from "../../core/constants.js";
import { ConfigProto, error, isFunction, isJoditObject } from "../../core/helpers/index.js";
import { Config } from "../../config.js";
import { ajaxInstances, hasFiles, hasItems, processOldBrowserDrag, send, sendFiles } from "./helpers/index.js";
import "./config.js";
export class Uploader extends ViewComponent {
get j() {
return this.jodit;
}
/** @override */
className() {
return 'Uploader';
}
get o() {
return this.options;
}
/**
* It sets the path for uploading files
*/
setPath(path) {
this.path = path;
return this;
}
/**
* It sets the source for connector
*/
setSource(source) {
this.source = source;
return this;
}
/**
* Set the handlers Drag and Drop to `$form`
*
* @param form - Form or any Node on which you can drag and drop the file. In addition will be processed
* <code>&lt;input type="file" &gt;</code>
* @param handlerSuccess - The function be called when a successful uploading files
* to the server
* @param handlerError - The function that will be called during a failed download files a server
* @example
* ```javascript
* var $form = jQuery('<form><input type="text" typpe="file"></form>');
* jQuery('body').append($form);
* Jodit.editors.someidfoeditor.uploader.bind($form[0], function (files) {
* var i;
* for (i = 0; i < data.files.length; i += 1) {
* parent.s.insertImage(data.files[i])
* }
* });
* ```
*/
bind(form, handlerSuccess, handlerError) {
const onFinally = () => {
form.classList.remove('jodit_drag_hover');
};
const self = this, onPaste = (e) => {
let i, file, extension;
const cData = e.clipboardData;
const processData = (formdata) => {
if (file) {
formdata.append('extension', extension);
formdata.append('mimetype', file.type);
}
};
// send data on server
if (!IS_IE && hasFiles(cData)) {
sendFiles(self, cData.files, handlerSuccess, handlerError).finally(onFinally);
return false;
}
if (IS_IE && !IS_ES_NEXT) {
return processOldBrowserDrag(self, cData, handlerSuccess, handlerError, onFinally);
}
if (hasItems(cData)) {
const { items } = cData;
for (i = 0; i < items.length; i += 1) {
if (items[i].kind === 'file' &&
items[i].type === 'image/png') {
file = items[i].getAsFile();
if (file) {
const mime = file.type.match(/\/([a-z0-9]+)/i);
extension = mime[1]
? mime[1].toLowerCase()
: '';
sendFiles(self, [file], handlerSuccess, handlerError, processData).finally(onFinally);
}
e.preventDefault();
break;
}
}
}
};
if (self.j && self.j.editor !== form) {
self.j.e.on(form, 'paste', onPaste);
}
else {
self.j.e.on('beforePaste', onPaste);
}
this.attachEvents(form, handlerSuccess, handlerError, onFinally);
}
attachEvents(form, handlerSuccess, handlerError, onFinally) {
const self = this;
self.j.e
.on(form, 'dragend dragover dragenter dragleave drop', (e) => {
e.preventDefault();
})
.on(form, 'dragover', (event) => {
if (hasFiles(event.dataTransfer) ||
hasItems(event.dataTransfer)) {
form.classList.add('jodit_drag_hover');
event.preventDefault();
}
})
.on(form, 'dragend dragleave', (event) => {
form.classList.remove('jodit_drag_hover');
if (hasFiles(event.dataTransfer)) {
event.preventDefault();
}
})
.on(form, 'drop', (event) => {
form.classList.remove('jodit_drag_hover');
if (hasFiles(event.dataTransfer)) {
event.preventDefault();
event.stopImmediatePropagation();
sendFiles(self, event.dataTransfer.files, handlerSuccess, handlerError).finally(onFinally);
}
});
const inputFile = form.querySelector('input[type=file]');
if (inputFile) {
self.j.e.on(inputFile, 'change', () => {
sendFiles(self, inputFile.files, handlerSuccess, handlerError)
.then(() => {
inputFile.value = '';
if (!/safari/i.test(navigator.userAgent)) {
inputFile.type = '';
inputFile.type = 'file';
}
})
.finally(onFinally);
});
}
}
/**
* Upload images to a server by its URL, making it through the connector server.
*/
uploadRemoteImage(url, handlerSuccess, handlerError) {
const uploader = this, { o } = uploader;
const handlerE = isFunction(handlerError)
? handlerError
: o.defaultHandlerError;
send(uploader, {
action: 'fileUploadRemote',
url
})
.then(resp => {
if (o.isSuccess.call(uploader, resp)) {
const handler = isFunction(handlerSuccess)
? handlerSuccess
: o.defaultHandlerSuccess;
handler.call(uploader, o.process.call(uploader, resp));
return;
}
handlerE.call(uploader, error(o.getMessage.call(uploader, resp)));
})
.catch(e => handlerE.call(uploader, e));
}
constructor(editor, options) {
super(editor);
this.path = '';
this.source = 'default';
this.options = ConfigProto(options || {}, ConfigProto(Config.defaultOptions.uploader, isJoditObject(editor) ? editor.o.uploader : {}));
}
destruct() {
this.setStatus(STATUSES.beforeDestruct);
const instances = ajaxInstances.get(this);
if (instances) {
instances.forEach(ajax => {
try {
ajax.destruct();
}
catch (_a) { }
});
instances.clear();
}
super.destruct();
}
}