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,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
*/
import type { EditValues } from "../interface";
/**
* @private
*/
export declare function readAlign(image: HTMLImageElement, values: EditValues): void;

View File

@@ -0,0 +1,26 @@
/*!
* 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";
/**
* @private
*/
export function readAlign(image, values) {
// Align
if (image.style.cssFloat &&
['left', 'right'].indexOf(image.style.cssFloat.toLowerCase()) !== -1) {
values.align = css(image, 'float');
}
else {
if (css(image, 'display') === 'block' &&
image.style.marginLeft === 'auto' &&
image.style.marginRight === 'auto') {
values.align = 'center';
}
else {
values.align = '';
}
}
}

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";
/**
* Read values from image and set it to state
* @private
*/
export declare function readValuesFromImage(j: IJodit, state: ImagePropertiesState): Promise<void>;

View File

@@ -0,0 +1,38 @@
/*!
* 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 { attr } from "../../../core/helpers/utils/attr.js";
import { readAlign } from "./align.js";
import { readLink } from "./link.js";
import { readMargins } from "./margin.js";
import { readSizes } from "./size.js";
/**
* Read values from image and set it to state
* @private
*/
export async function readValuesFromImage(j, state) {
const { sourceImage: image, values } = state;
readAlign(image, values);
// Border radius
values.borderRadius = parseInt(image.style.borderRadius || '0', 10) || 0;
// Id
values.id = attr(image, 'id') || '';
// Title
values.imageTitle = attr(image, 'title') || '';
// Alt
values.imageAlt = attr(image, 'alt') || '';
// Style
values.style = attr(image, 'style') || '';
// Classes
values.classes = (attr(image, 'class') || '').replace(/jodit_focused_image[\s]*/, '');
// Margins
readMargins(image, values, state);
// Link
readLink(state, j, values);
// Src
values.imageSrc = attr(image, 'src') || '';
// Image size
return readSizes(image, values, state);
}

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 plugins/image-properties
*/
import type { IJodit } from "../../../types/index";
import type { EditValues, ImagePropertiesState } from "../interface";
/** @private */
export declare function readLink(state: ImagePropertiesState, j: IJodit, values: EditValues): void;

View File

@@ -0,0 +1,19 @@
/*!
* 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 readLink(state, j, values) {
const a = Dom.closest(state.sourceImage, 'a', j.editor);
if (a) {
values.imageLink = attr(a, 'href') || '';
values.imageLinkOpenInNewTab = attr(a, 'target') === '_blank';
}
else {
values.imageLink = '';
values.imageLinkOpenInNewTab = false;
}
}

View File

@@ -0,0 +1,8 @@
/*!
* 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 type { EditValues, ImagePropertiesState } from "../interface";
/** @private */
export declare function readMargins(image: HTMLImageElement, values: EditValues, state: ImagePropertiesState): void;

View File

@@ -0,0 +1,31 @@
/*!
* 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 { kebabCase } from "../../../core/helpers/string/kebab-case.js";
/** @private */
export function readMargins(image, values, state) {
// Margins
let equal = true, wasEmptyField = false;
['marginTop', 'marginRight', 'marginBottom', 'marginLeft'].forEach(id => {
let value = image.style.getPropertyValue(kebabCase(id));
if (!value) {
wasEmptyField = true;
values[id] = 0;
return;
}
if (/^[0-9]+(px)?$/.test(value)) {
value = parseInt(value, 10);
}
values[id] = value;
if ((wasEmptyField && values[id]) ||
(equal && id !== 'marginTop' && values[id] !== values.marginTop)) {
equal = false;
}
});
state.marginIsLocked = equal;
}

View File

@@ -0,0 +1,8 @@
/*!
* 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 type { EditValues, ImagePropertiesState } from "../interface";
/** @private */
export declare function readSizes(image: HTMLImageElement, values: EditValues, state: ImagePropertiesState): Promise<void>;

View File

@@ -0,0 +1,44 @@
/*!
* 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 { normalSizeFromString } from "../utils/utils.js";
/** @private */
export async function readSizes(image, values, state) {
await image.decode();
const width = css(image, 'width', true) || attr(image, 'width') || false;
const height = css(image, 'height', true) || attr(image, 'height') || false;
values.imageWidth =
width !== false
? normalSizeFromString(width)
: image.offsetWidth || image.naturalWidth;
if (isNumeric(values.imageWidth)) {
values.imageHeight =
height !== false
? normalSizeFromString(height)
: image.offsetHeight || image.naturalHeight;
}
else {
values.imageHeight = height || '';
}
const { imageWidth, imageHeight } = values;
const w = parseFloat(imageWidth.toString());
if (!isNumeric(imageWidth) || !isNumeric(imageHeight)) {
state.sizeIsLocked = false;
return;
}
if (height === false) {
values.imageHeight = Math.round(w / state.ratio);
state.sizeIsLocked = true;
return;
}
const h = parseFloat(imageHeight.toString());
state.sizeIsLocked = Math.abs(w - h * state.ratio) < 1;
}