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

View File

@@ -0,0 +1,15 @@
/*!
* 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 plugins/image-properties
*/
import type { IJodit } from "../../../types/index";
import type { ImagePropertiesState } from "../interface";
/**
* Apply form's values to image
* @private
*/
export declare function applyValuesToImage(j: IJodit, state: ImagePropertiesState, image: HTMLImageElement): void;

View File

@@ -0,0 +1,53 @@
/*!
* 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 { Dom } from "../../../core/dom/dom.js";
import { attr, hAlignElement } from "../../../core/helpers/utils/index.js";
import { applyLink } from "./link.js";
import { applyMargin } from "./margin.js";
import { applySize } from "./size.js";
/**
* Apply form's values to image
* @private
*/
export function applyValuesToImage(j, state, image) {
const { style, imageSrc, borderRadius, imageTitle, imageAlt, imageLink, imageWidth, imageHeight, marginTop, marginRight, marginBottom, marginLeft, imageLinkOpenInNewTab, align, classes, id } = state.values;
const opt = j.o;
// styles
if (opt.image.editStyle) {
attr(image, 'style', style || null);
}
// Src
if (imageSrc) {
attr(image, 'src', imageSrc);
}
else {
Dom.safeRemove(image);
return;
}
// Border radius
image.style.borderRadius = borderRadius ? borderRadius + 'px' : '';
// Title
attr(image, 'title', imageTitle || null);
// Alt
attr(image, 'alt', imageAlt || null);
// Link
applyLink(j, image, imageLink, imageLinkOpenInNewTab);
// Size
applySize(image, imageWidth, imageHeight, state.sizeIsLocked);
// Margin
if (j.o.image.editMargins) {
applyMargin(j, marginTop, marginRight, marginBottom, marginLeft, image, state.marginIsLocked);
}
if (opt.image.editClass) {
attr(image, 'class', classes || null);
}
if (opt.image.editId) {
attr(image, 'id', id || null);
}
if (opt.image.editAlign) {
hAlignElement(image, align);
}
}

View File

@@ -0,0 +1,11 @@
/*!
* 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 plugins/image-properties
*/
import type { IJodit } from "../../../types/index";
/** @private */
export declare function applyLink(j: IJodit, image: HTMLImageElement, imageLink: string, imageLinkOpenInNewTab: boolean): void;

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
*/
import { Dom } from "../../../core/dom/dom.js";
import { attr } from "../../../core/helpers/utils/attr.js";
/** @private */
export function applyLink(j, image, imageLink, imageLinkOpenInNewTab) {
// Link
let link = Dom.closest(image, 'a', j.editor);
if (imageLink) {
if (!link) {
link = Dom.wrap(image, 'a', j.createInside);
}
attr(link, 'href', imageLink);
attr(link, 'target', imageLinkOpenInNewTab ? '_blank' : null);
}
else {
if (link && link.parentNode) {
link.parentNode.replaceChild(image, link);
}
}
}

View File

@@ -0,0 +1,11 @@
/*!
* 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 plugins/image-properties
*/
import type { IJodit } from "../../../types/index";
/** @private */
export declare function applyMargin(j: IJodit, marginTop: number | string, marginRight: number | string, marginBottom: number | string, marginLeft: number | string, image: HTMLImageElement, marginIsLocked: boolean): 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 { css } from "../../../core/helpers/utils/css.js";
import { normalSizeToString } from "../utils/utils.js";
/** @private */
export function applyMargin(j, marginTop, marginRight, marginBottom, marginLeft, image, marginIsLocked) {
const margins = [marginTop, marginRight, marginBottom, marginLeft];
const applyMargin = (key, value) => {
const oldValue = css(image, key);
const v = normalSizeToString(value);
if (oldValue.toString() !== v.toString()) {
css(image, key, v);
}
};
if (!marginIsLocked) {
const sides = [
'margin-top',
'margin-right',
'margin-bottom',
'margin-left'
];
margins.forEach((margin, index) => {
const side = sides[index];
applyMargin(side, margin);
});
}
else {
applyMargin('margin', marginTop);
}
}

View File

@@ -0,0 +1,7 @@
/*!
* 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
*/
/** @private */
export declare function applySize(image: HTMLImageElement, imageWidth: number | string, imageHeight: number | string, sizeIsLocked: boolean): void;

View File

@@ -0,0 +1,34 @@
/*!
* 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 plugins/image-properties
*/
import { isNumeric } from "../../../core/helpers/checker/is-numeric.js";
import { attr } from "../../../core/helpers/utils/attr.js";
import { css } from "../../../core/helpers/utils/css.js";
import { normalSizeToString } from "../utils/utils.js";
/** @private */
export function applySize(image, imageWidth, imageHeight, sizeIsLocked) {
// Size
if (imageWidth !== image.offsetWidth ||
imageHeight !== image.offsetHeight) {
const updatedWidth = imageWidth ? normalSizeToString(imageWidth) : null;
let updatedHeight = imageHeight
? normalSizeToString(imageHeight)
: null;
css(image, {
width: updatedWidth,
height: updatedWidth && sizeIsLocked ? null : updatedHeight
});
attr(image, 'width', updatedWidth && isNumeric(imageWidth) && attr(image, 'width')
? updatedWidth
: null);
if (!attr(image, 'width') || sizeIsLocked) {
updatedHeight = null;
}
attr(image, 'height', updatedHeight);
}
}