jodit 4.1.14 → 4.2.5
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.
- package/CHANGELOG.md +22 -5
- package/es2015/jodit.css +82 -31
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +2 -2
- package/es2015/jodit.js +1364 -560
- package/es2015/jodit.min.css +1 -1
- package/es2015/jodit.min.js +2 -2
- package/es2015/plugins/debug/debug.js +1 -1
- package/es2015/plugins/debug/debug.min.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2018/jodit.css +82 -31
- package/es2018/jodit.fat.min.css +1 -1
- package/es2018/jodit.fat.min.js +2 -2
- package/es2018/jodit.js +1350 -560
- package/es2018/jodit.min.css +1 -1
- package/es2018/jodit.min.js +2 -2
- package/es2018/plugins/debug/debug.js +1 -1
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +82 -31
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +2 -2
- package/es2021/jodit.js +1346 -560
- package/es2021/jodit.min.css +1 -1
- package/es2021/jodit.min.js +2 -2
- package/es2021/plugins/debug/debug.js +1 -1
- package/es2021/plugins/debug/debug.min.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021.en/jodit.css +82 -31
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +2 -2
- package/es2021.en/jodit.js +1346 -560
- package/es2021.en/jodit.min.css +1 -1
- package/es2021.en/jodit.min.js +2 -2
- package/es2021.en/plugins/debug/debug.js +1 -1
- package/es2021.en/plugins/debug/debug.min.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es5/jodit.css +131 -35
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +1388 -496
- package/es5/jodit.min.css +3 -3
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/debug/debug.js +1 -1
- package/es5/plugins/debug/debug.min.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/esm/core/constants.js +1 -1
- package/esm/core/decorators/cache/cache.d.ts +2 -1
- package/esm/core/decorators/cache/cache.js +7 -0
- package/esm/core/helpers/size/position.js +2 -2
- package/esm/core/helpers/utils/selector.d.ts +3 -1
- package/esm/core/helpers/utils/selector.js +3 -3
- package/esm/core/ui/button/tooltip/tooltip.js +3 -4
- package/esm/core/ui/popup/popup.js +1 -1
- package/esm/modules/dialog/dialog.js +1 -0
- package/esm/modules/file-browser/file-browser.js +8 -1
- package/esm/modules/image-editor/templates/form.js +6 -5
- package/esm/modules/toolbar/button/button.d.ts +1 -1
- package/esm/modules/widget/tabs/tabs.d.ts +4 -4
- package/esm/modules/widget/tabs/tabs.js +9 -7
- package/esm/plugins/ai-assistant/ai-assistant.d.ts +1 -1
- package/esm/plugins/ai-assistant/ai-assistant.js +6 -6
- package/esm/plugins/image-properties/config.d.ts +5 -83
- package/esm/plugins/image-properties/config.js +0 -3
- package/esm/plugins/image-properties/image-properties.d.ts +22 -32
- package/esm/plugins/image-properties/image-properties.js +129 -402
- package/{types/plugins/image-properties/templates/form.d.ts → esm/plugins/image-properties/readers/align.d.ts} +3 -5
- package/esm/plugins/image-properties/readers/align.js +24 -0
- package/esm/plugins/image-properties/readers/index.d.ts +12 -0
- package/esm/plugins/image-properties/readers/index.js +38 -0
- package/esm/plugins/image-properties/readers/link.d.ts +9 -0
- package/esm/plugins/image-properties/readers/link.js +19 -0
- package/esm/plugins/image-properties/readers/margin.d.ts +8 -0
- package/esm/plugins/image-properties/readers/margin.js +28 -0
- package/esm/plugins/image-properties/readers/size.d.ts +8 -0
- package/esm/plugins/image-properties/readers/size.js +36 -0
- package/esm/plugins/image-properties/ui/ui-image-form.d.ts +29 -0
- package/esm/plugins/image-properties/ui/ui-image-form.js +171 -0
- package/esm/plugins/image-properties/ui/ui-image-main-tab.d.ts +36 -0
- package/esm/plugins/image-properties/ui/ui-image-main-tab.js +179 -0
- package/esm/plugins/image-properties/ui/ui-image-position-tab.d.ts +36 -0
- package/esm/plugins/image-properties/ui/ui-image-position-tab.js +261 -0
- package/esm/plugins/image-properties/{templates/main-tab.d.ts → utils/open-image-editor.d.ts} +5 -3
- package/esm/plugins/image-properties/utils/open-image-editor.js +52 -0
- package/esm/plugins/image-properties/utils/open-image-popup.d.ts +9 -0
- package/esm/plugins/image-properties/utils/open-image-popup.js +34 -0
- package/esm/plugins/image-properties/utils/utils.d.ts +9 -0
- package/esm/plugins/image-properties/utils/utils.js +21 -0
- package/esm/plugins/image-properties/writers/index.d.ts +12 -0
- package/esm/plugins/image-properties/writers/index.js +53 -0
- package/esm/plugins/image-properties/{templates/form.d.ts → writers/link.d.ts} +2 -4
- package/esm/plugins/image-properties/writers/link.js +24 -0
- package/esm/plugins/image-properties/writers/margin.d.ts +8 -0
- package/esm/plugins/image-properties/writers/margin.js +33 -0
- package/esm/plugins/image-properties/writers/size.d.ts +7 -0
- package/esm/plugins/image-properties/writers/size.js +28 -0
- package/esm/plugins/select/config.d.ts +7 -0
- package/esm/plugins/select/config.js +2 -1
- package/esm/plugins/select/select.d.ts +7 -3
- package/esm/plugins/select/select.js +21 -4
- package/esm/types/ui.d.ts +1 -1
- package/package.json +1 -1
- package/types/core/decorators/cache/cache.d.ts +2 -1
- package/types/core/helpers/utils/selector.d.ts +3 -1
- package/types/modules/toolbar/button/button.d.ts +1 -1
- package/types/modules/widget/tabs/tabs.d.ts +4 -4
- package/types/plugins/ai-assistant/ai-assistant.d.ts +1 -1
- package/types/plugins/image-properties/config.d.ts +5 -83
- package/types/plugins/image-properties/image-properties.d.ts +22 -32
- package/types/plugins/image-properties/{templates/main-tab.d.ts → readers/align.d.ts} +3 -5
- package/types/plugins/image-properties/readers/index.d.ts +12 -0
- package/types/plugins/image-properties/readers/link.d.ts +9 -0
- package/types/plugins/image-properties/readers/margin.d.ts +8 -0
- package/types/plugins/image-properties/readers/size.d.ts +8 -0
- package/types/plugins/image-properties/ui/ui-image-form.d.ts +29 -0
- package/types/plugins/image-properties/ui/ui-image-main-tab.d.ts +36 -0
- package/types/plugins/image-properties/ui/ui-image-position-tab.d.ts +36 -0
- package/types/plugins/image-properties/utils/open-image-editor.d.ts +12 -0
- package/types/plugins/image-properties/utils/open-image-popup.d.ts +9 -0
- package/types/plugins/image-properties/utils/utils.d.ts +9 -0
- package/types/plugins/image-properties/writers/index.d.ts +12 -0
- package/{esm/plugins/image-properties/templates/position-tab.d.ts → types/plugins/image-properties/writers/link.d.ts} +2 -4
- package/types/plugins/image-properties/writers/margin.d.ts +8 -0
- package/types/plugins/image-properties/writers/size.d.ts +7 -0
- package/types/plugins/select/config.d.ts +7 -0
- package/types/plugins/select/select.d.ts +7 -3
- package/types/types/ui.d.ts +1 -1
- package/esm/plugins/image-properties/templates/form.js +0 -26
- package/esm/plugins/image-properties/templates/main-tab.js +0 -47
- package/esm/plugins/image-properties/templates/position-tab.js +0 -66
- package/types/plugins/image-properties/templates/position-tab.d.ts +0 -10
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import { attr } from "jodit/esm/core/helpers/utils/attr.js";
|
|
7
|
+
import { readAlign } from "./align";
|
|
8
|
+
import { readLink } from "./link";
|
|
9
|
+
import { readMargins } from "./margin";
|
|
10
|
+
import { readSizes } from "./size";
|
|
11
|
+
/**
|
|
12
|
+
* Read values from image and set it to state
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
export async function readValuesFromImage(j, state) {
|
|
16
|
+
const { sourceImage: image, values } = state;
|
|
17
|
+
readAlign(image, values);
|
|
18
|
+
// Border radius
|
|
19
|
+
values.borderRadius = parseInt(image.style.borderRadius || '0', 10) || 0;
|
|
20
|
+
// Id
|
|
21
|
+
values.id = attr(image, 'id') || '';
|
|
22
|
+
// Title
|
|
23
|
+
values.imageTitle = attr(image, 'title') || '';
|
|
24
|
+
// Alt
|
|
25
|
+
values.imageAlt = attr(image, 'alt') || '';
|
|
26
|
+
// Style
|
|
27
|
+
values.style = attr(image, 'style') || '';
|
|
28
|
+
// Classes
|
|
29
|
+
values.classes = (attr(image, 'class') || '').replace(/jodit_focused_image[\s]*/, '');
|
|
30
|
+
// Margins
|
|
31
|
+
readMargins(image, values, state);
|
|
32
|
+
// Link
|
|
33
|
+
readLink(state, j, values);
|
|
34
|
+
// Src
|
|
35
|
+
values.imageSrc = attr(image, 'src') || '';
|
|
36
|
+
// Image size
|
|
37
|
+
return readSizes(image, values, state);
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import type { IJodit } from "jodit/esm/types";
|
|
7
|
+
import type { EditValues, ImagePropertiesState } from "../interface";
|
|
8
|
+
/** @private */
|
|
9
|
+
export declare function readLink(state: ImagePropertiesState, j: IJodit, values: EditValues): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import { Dom } from "jodit/esm/core/dom/dom.js";
|
|
7
|
+
import { attr } from "jodit/esm/core/helpers/utils/attr.js";
|
|
8
|
+
/** @private */
|
|
9
|
+
export function readLink(state, j, values) {
|
|
10
|
+
const a = Dom.closest(state.sourceImage, 'a', j.editor);
|
|
11
|
+
if (a) {
|
|
12
|
+
values.imageLink = attr(a, 'href') || '';
|
|
13
|
+
values.imageLinkOpenInNewTab = attr(a, 'target') === '_blank';
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
values.imageLink = '';
|
|
17
|
+
values.imageLinkOpenInNewTab = false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import type { EditValues, ImagePropertiesState } from "../interface";
|
|
7
|
+
/** @private */
|
|
8
|
+
export declare function readMargins(image: HTMLImageElement, values: EditValues, state: ImagePropertiesState): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import { kebabCase } from "jodit/esm/core/helpers/string/kebab-case.js";
|
|
7
|
+
/** @private */
|
|
8
|
+
export function readMargins(image, values, state) {
|
|
9
|
+
// Margins
|
|
10
|
+
let equal = true, wasEmptyField = false;
|
|
11
|
+
['marginTop', 'marginRight', 'marginBottom', 'marginLeft'].forEach(id => {
|
|
12
|
+
let value = image.style.getPropertyValue(kebabCase(id));
|
|
13
|
+
if (!value) {
|
|
14
|
+
wasEmptyField = true;
|
|
15
|
+
values[id] = 0;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (/^[0-9]+(px)?$/.test(value)) {
|
|
19
|
+
value = parseInt(value, 10);
|
|
20
|
+
}
|
|
21
|
+
values[id] = value;
|
|
22
|
+
if ((wasEmptyField && values[id]) ||
|
|
23
|
+
(equal && id !== 'marginTop' && values[id] !== values.marginTop)) {
|
|
24
|
+
equal = false;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
state.marginIsLocked = equal;
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import type { EditValues, ImagePropertiesState } from "../interface";
|
|
7
|
+
/** @private */
|
|
8
|
+
export declare function readSizes(image: HTMLImageElement, values: EditValues, state: ImagePropertiesState): Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import { isNumeric } from "jodit/esm/core/helpers/checker/is-numeric.js";
|
|
7
|
+
import { attr } from "jodit/esm/core/helpers/utils/attr.js";
|
|
8
|
+
import { css } from "jodit/esm/core/helpers/utils/css.js";
|
|
9
|
+
import { normalSizeFromString } from "../utils/utils";
|
|
10
|
+
/** @private */
|
|
11
|
+
export async function readSizes(image, values, state) {
|
|
12
|
+
await image.decode();
|
|
13
|
+
const width = attr(image, 'width') || css(image, 'width', true) || false;
|
|
14
|
+
const height = attr(image, 'height') || css(image, 'height', true) || false;
|
|
15
|
+
values.imageWidth =
|
|
16
|
+
width !== false
|
|
17
|
+
? normalSizeFromString(width)
|
|
18
|
+
: image.offsetWidth || image.naturalWidth;
|
|
19
|
+
values.imageHeight =
|
|
20
|
+
height !== false
|
|
21
|
+
? normalSizeFromString(height)
|
|
22
|
+
: image.offsetHeight || image.naturalHeight;
|
|
23
|
+
const { imageWidth, imageHeight } = values;
|
|
24
|
+
const w = parseFloat(imageWidth.toString());
|
|
25
|
+
if (!isNumeric(imageWidth) || !isNumeric(imageHeight)) {
|
|
26
|
+
state.sizeIsLocked = false;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (height === false) {
|
|
30
|
+
values.imageHeight = Math.round(w / state.ratio);
|
|
31
|
+
state.sizeIsLocked = true;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const h = parseFloat(imageHeight.toString());
|
|
35
|
+
state.sizeIsLocked = Math.abs(w - h * state.ratio) < 1;
|
|
36
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import type { IComponent, IContainer, IElms, IJodit, Nullable } from "jodit/esm/types";
|
|
7
|
+
import { UIGroup } from "jodit/esm/core/ui/group/group";
|
|
8
|
+
import type { ImagePropertiesAPI, ImagePropertiesState } from "../interface";
|
|
9
|
+
|
|
10
|
+
/** @private */
|
|
11
|
+
export declare class UIImagePropertiesForm extends UIGroup<IJodit> {
|
|
12
|
+
private state;
|
|
13
|
+
private handlers;
|
|
14
|
+
className(): string;
|
|
15
|
+
appendChildToContainer(): void;
|
|
16
|
+
getElm<T extends IComponent & IContainer & IElms>(elementName: string): Nullable<HTMLElement>;
|
|
17
|
+
private __mainTab;
|
|
18
|
+
private __positionTab;
|
|
19
|
+
constructor(jodit: IJodit, state: ImagePropertiesState, activeTabState: {
|
|
20
|
+
activeTab: 'Image' | 'Advanced';
|
|
21
|
+
}, handlers: ImagePropertiesAPI);
|
|
22
|
+
protected render(): string;
|
|
23
|
+
protected onChangeSizeIsLocked(): void;
|
|
24
|
+
protected onLockSizeClick(): void;
|
|
25
|
+
protected onStateValuesSizeChange(): void;
|
|
26
|
+
protected onImageWidthChange(e: Event): void;
|
|
27
|
+
protected onStateValuesImageSrcChange(): void;
|
|
28
|
+
protected hideFieldByOptions(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
9
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
else
|
|
11
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
12
|
+
if (d = decorators[i])
|
|
13
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
};
|
|
16
|
+
import { debounce, hook, watch } from "jodit/esm/core/decorators/index.js";
|
|
17
|
+
import { component } from "jodit/esm/core/decorators/component/component.js";
|
|
18
|
+
import { attr, css, isNumeric } from "jodit/esm/core/helpers/index.js";
|
|
19
|
+
import { UIGroup } from "jodit/esm/core/ui/group/group.js";
|
|
20
|
+
import { Icon } from "jodit/esm/core/ui/icon.js";
|
|
21
|
+
import { TabsWidget } from "jodit/esm/modules/widget/index.js";
|
|
22
|
+
import { UIImageMainTab } from "./ui-image-main-tab";
|
|
23
|
+
import { UIImagePositionTab } from "./ui-image-position-tab";
|
|
24
|
+
/** @private */
|
|
25
|
+
let UIImagePropertiesForm = class UIImagePropertiesForm extends UIGroup {
|
|
26
|
+
className() {
|
|
27
|
+
return 'UIImagePropertiesForm';
|
|
28
|
+
}
|
|
29
|
+
appendChildToContainer() { }
|
|
30
|
+
getElm(elementName) {
|
|
31
|
+
const selfElm = super.getElm(elementName);
|
|
32
|
+
if (selfElm) {
|
|
33
|
+
return selfElm;
|
|
34
|
+
}
|
|
35
|
+
for (const child of this.elements) {
|
|
36
|
+
const elm = child.getElm(elementName);
|
|
37
|
+
if (elm) {
|
|
38
|
+
return elm;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
constructor(jodit, state, activeTabState, handlers) {
|
|
44
|
+
super(jodit);
|
|
45
|
+
this.state = state;
|
|
46
|
+
this.handlers = handlers;
|
|
47
|
+
this.__mainTab = new UIImageMainTab(this.jodit, this.state, this.handlers);
|
|
48
|
+
this.__positionTab = new UIImagePositionTab(this.jodit, this.state, this.handlers);
|
|
49
|
+
this.getElm('tabsBox').appendChild(TabsWidget(jodit, [
|
|
50
|
+
{ name: 'Image', content: this.__mainTab },
|
|
51
|
+
{ name: 'Advanced', content: this.__positionTab }
|
|
52
|
+
], activeTabState));
|
|
53
|
+
this.setMod('lock-size', this.state.sizeIsLocked);
|
|
54
|
+
this.append(this.__mainTab).append(this.__positionTab);
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
return `<form>
|
|
58
|
+
<div class="jodit-grid jodit-grid_xs-column">
|
|
59
|
+
<div class="jodit_col-lg-2-5 jodit_col-xs-5-5">
|
|
60
|
+
<div class="&__view-box">
|
|
61
|
+
<div class="&__imageView">
|
|
62
|
+
<img class="&__imageViewSrc" src="" alt=""/>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="jodit-form__group &__imageSizes">
|
|
65
|
+
<input type="text" class="jodit-input &__imageWidth"/>
|
|
66
|
+
<a class="&__lockSize">${Icon.get('lock')}</a>
|
|
67
|
+
<input type="text" class="&__imageHeight jodit-input"/>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="jodit_col-lg-3-5 jodit_col-xs-5-5 &__tabsBox"></div>
|
|
72
|
+
</div>
|
|
73
|
+
</form>`;
|
|
74
|
+
}
|
|
75
|
+
onChangeSizeIsLocked() {
|
|
76
|
+
const lockSize = this.getElm('lockSize');
|
|
77
|
+
const imageWidth = this.getElm('imageWidth');
|
|
78
|
+
lockSize.innerHTML = Icon.get(this.state.sizeIsLocked ? 'lock' : 'unlock');
|
|
79
|
+
this.setMod('lock-size', this.state.sizeIsLocked);
|
|
80
|
+
this.j.e.fire(imageWidth, 'change');
|
|
81
|
+
}
|
|
82
|
+
onLockSizeClick() {
|
|
83
|
+
this.state.sizeIsLocked = !this.state.sizeIsLocked;
|
|
84
|
+
}
|
|
85
|
+
onStateValuesSizeChange() {
|
|
86
|
+
const imageWidth = this.getElm('imageWidth');
|
|
87
|
+
const imageHeight = this.getElm('imageHeight');
|
|
88
|
+
if (imageWidth !== this.j.od.activeElement) {
|
|
89
|
+
imageWidth.value = this.state.values.imageWidth.toString();
|
|
90
|
+
}
|
|
91
|
+
if (imageHeight !== this.j.od.activeElement) {
|
|
92
|
+
imageHeight.value = this.state.values.imageHeight.toString();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
onImageWidthChange(e) {
|
|
96
|
+
const imageWidth = this.getElm('imageWidth');
|
|
97
|
+
const imageHeight = this.getElm('imageHeight');
|
|
98
|
+
if (!this.state.sizeIsLocked ||
|
|
99
|
+
!isNumeric(imageWidth.value) ||
|
|
100
|
+
!isNumeric(imageHeight.value)) {
|
|
101
|
+
this.state.values.imageWidth = imageWidth.value;
|
|
102
|
+
this.state.values.imageHeight = imageHeight.value;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const w = parseFloat(imageWidth.value), h = parseFloat(imageHeight.value);
|
|
106
|
+
if (e.target === imageWidth) {
|
|
107
|
+
this.state.values.imageWidth = w;
|
|
108
|
+
this.state.values.imageHeight = Math.round(w / this.state.ratio);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this.state.values.imageWidth = Math.round(h * this.state.ratio);
|
|
112
|
+
this.state.values.imageHeight = h;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
onStateValuesImageSrcChange() {
|
|
116
|
+
const { imageSrc } = this.state.values;
|
|
117
|
+
if (!imageSrc) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const imageViewSrc = this.getElm('imageViewSrc');
|
|
121
|
+
attr(imageViewSrc, 'src', imageSrc);
|
|
122
|
+
const image = new Image();
|
|
123
|
+
image.src = imageSrc;
|
|
124
|
+
this.state.image = image;
|
|
125
|
+
}
|
|
126
|
+
hideFieldByOptions() {
|
|
127
|
+
const opt = this.j.o.image;
|
|
128
|
+
[
|
|
129
|
+
['editSize', 'imageSizes'],
|
|
130
|
+
['showPreview', 'imageView']
|
|
131
|
+
].forEach(([optKey, elmKey]) => {
|
|
132
|
+
const elm = this.getElm(elmKey);
|
|
133
|
+
css(elm, 'display', opt[optKey] ? null : 'none');
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
__decorate([
|
|
138
|
+
hook('ready'),
|
|
139
|
+
watch('state.sizeIsLocked')
|
|
140
|
+
], UIImagePropertiesForm.prototype, "onChangeSizeIsLocked", null);
|
|
141
|
+
__decorate([
|
|
142
|
+
watch('lockSize:click')
|
|
143
|
+
], UIImagePropertiesForm.prototype, "onLockSizeClick", null);
|
|
144
|
+
__decorate([
|
|
145
|
+
hook('ready'),
|
|
146
|
+
watch(['state.values.imageWidth', 'state.values.imageHeight'])
|
|
147
|
+
], UIImagePropertiesForm.prototype, "onStateValuesSizeChange", null);
|
|
148
|
+
__decorate([
|
|
149
|
+
watch([
|
|
150
|
+
'imageWidth:change',
|
|
151
|
+
'imageHeight:change',
|
|
152
|
+
'imageWidth:keydown',
|
|
153
|
+
'imageHeight:keydown',
|
|
154
|
+
'imageWidth:mousedown',
|
|
155
|
+
'imageHeight:mousedown',
|
|
156
|
+
'imageWidth:paste',
|
|
157
|
+
'imageHeight:paste'
|
|
158
|
+
]),
|
|
159
|
+
debounce()
|
|
160
|
+
], UIImagePropertiesForm.prototype, "onImageWidthChange", null);
|
|
161
|
+
__decorate([
|
|
162
|
+
hook('ready'),
|
|
163
|
+
watch('state.values.imageSrc')
|
|
164
|
+
], UIImagePropertiesForm.prototype, "onStateValuesImageSrcChange", null);
|
|
165
|
+
__decorate([
|
|
166
|
+
hook('ready')
|
|
167
|
+
], UIImagePropertiesForm.prototype, "hideFieldByOptions", null);
|
|
168
|
+
UIImagePropertiesForm = __decorate([
|
|
169
|
+
component
|
|
170
|
+
], UIImagePropertiesForm);
|
|
171
|
+
export { UIImagePropertiesForm };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import type { IJodit } from "jodit/esm/types";
|
|
7
|
+
import { UIGroup } from "jodit/esm/core/ui/group/group";
|
|
8
|
+
import type { ImagePropertiesAPI, ImagePropertiesState } from "../interface";
|
|
9
|
+
/** @private */
|
|
10
|
+
export declare class UIImageMainTab extends UIGroup<IJodit> {
|
|
11
|
+
private state;
|
|
12
|
+
private handlers;
|
|
13
|
+
className(): string;
|
|
14
|
+
appendChildToContainer(): void;
|
|
15
|
+
constructor(view: IJodit, state: ImagePropertiesState, handlers: ImagePropertiesAPI);
|
|
16
|
+
protected render(): string;
|
|
17
|
+
protected onStateImageSrcChange(): Promise<void>;
|
|
18
|
+
protected onImageSrcChange(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Open image editor
|
|
21
|
+
*/
|
|
22
|
+
protected onEditImageClick(e: MouseEvent): void;
|
|
23
|
+
/**
|
|
24
|
+
* Open popup with filebrowser/uploader buttons for image
|
|
25
|
+
*/
|
|
26
|
+
protected onChangeImageClick(e: MouseEvent): void;
|
|
27
|
+
protected onStateTitleChange(): void;
|
|
28
|
+
protected onTitleChange(): void;
|
|
29
|
+
protected onStateAltChange(): void;
|
|
30
|
+
protected onAltChange(): void;
|
|
31
|
+
protected onStateImageLinkChange(): void;
|
|
32
|
+
protected onImageLinkChange(): void;
|
|
33
|
+
protected onStateImageLinkOpenInNewTabChange(): void;
|
|
34
|
+
protected onImageLinkOpenInNewTabChange(): void;
|
|
35
|
+
protected hideFieldByOptions(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
9
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
else
|
|
11
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
12
|
+
if (d = decorators[i])
|
|
13
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
};
|
|
16
|
+
import { component } from "jodit/esm/core/decorators/component/component.js";
|
|
17
|
+
import { hook } from "jodit/esm/core/decorators/hook/hook.js";
|
|
18
|
+
import { watch } from "jodit/esm/core/decorators/watch/watch.js";
|
|
19
|
+
import { css } from "jodit/esm/core/helpers/index.js";
|
|
20
|
+
import { UIGroup } from "jodit/esm/core/ui/group/group.js";
|
|
21
|
+
/** @private */
|
|
22
|
+
let UIImageMainTab = class UIImageMainTab extends UIGroup {
|
|
23
|
+
className() {
|
|
24
|
+
return 'UIImageMainTab';
|
|
25
|
+
}
|
|
26
|
+
appendChildToContainer() {
|
|
27
|
+
// Do nothing
|
|
28
|
+
}
|
|
29
|
+
constructor(view, state, handlers) {
|
|
30
|
+
super(view);
|
|
31
|
+
this.state = state;
|
|
32
|
+
this.handlers = handlers;
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
return `<div class="jodit-form__group &__editSrc">
|
|
36
|
+
<label>~Src~</label>
|
|
37
|
+
<div class="jodit-input_group">
|
|
38
|
+
<input class="jodit-input &__imageSrc" type="text"/>
|
|
39
|
+
<div class="jodit-input_group-buttons &__fixImage">
|
|
40
|
+
<a class="jodit-button &__changeImage">*image*</a>
|
|
41
|
+
<a class="jodit-button &__editImage">*crop*</a>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="jodit-form__group &__editTitle">
|
|
46
|
+
<label>~Title~</label>
|
|
47
|
+
<input type="text" class="jodit-input &__imageTitle"/>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="jodit-form__group &__editAlt">
|
|
50
|
+
<label>~Alternative~</label>
|
|
51
|
+
<input type="text" class="jodit-input &__imageAlt"/>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="jodit-form__group &__editLink">
|
|
54
|
+
<label>~Link~</label>
|
|
55
|
+
<input type="text" class="jodit-input &__imageLink"/>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="jodit-form__group &__editLinkTarget">
|
|
58
|
+
<label class="jodit_vertical_middle">
|
|
59
|
+
<input type="checkbox" class="jodit-checkbox &__imageLinkOpenInNewTab"/>
|
|
60
|
+
<span>~Open link in new tab~</span>
|
|
61
|
+
</label>
|
|
62
|
+
</div>`;
|
|
63
|
+
}
|
|
64
|
+
async onStateImageSrcChange() {
|
|
65
|
+
const imageSrc = this.getElm('imageSrc');
|
|
66
|
+
imageSrc.value = this.state.values.imageSrc;
|
|
67
|
+
}
|
|
68
|
+
onImageSrcChange() {
|
|
69
|
+
this.state.values.imageSrc = this.getElm('imageSrc').value;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Open image editor
|
|
73
|
+
*/
|
|
74
|
+
onEditImageClick(e) {
|
|
75
|
+
this.handlers.openImageEditor();
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Open popup with filebrowser/uploader buttons for image
|
|
80
|
+
*/
|
|
81
|
+
onChangeImageClick(e) {
|
|
82
|
+
this.handlers.openImagePopup(this.getElm('changeImage'));
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
}
|
|
85
|
+
onStateTitleChange() {
|
|
86
|
+
const title = this.getElm('imageTitle');
|
|
87
|
+
title.value = this.state.values.imageTitle;
|
|
88
|
+
}
|
|
89
|
+
onTitleChange() {
|
|
90
|
+
this.state.values.imageTitle = this.getElm('imageTitle').value;
|
|
91
|
+
}
|
|
92
|
+
onStateAltChange() {
|
|
93
|
+
const alt = this.getElm('imageAlt');
|
|
94
|
+
alt.value = this.state.values.imageAlt;
|
|
95
|
+
}
|
|
96
|
+
onAltChange() {
|
|
97
|
+
this.state.values.imageAlt = this.getElm('imageAlt').value;
|
|
98
|
+
}
|
|
99
|
+
onStateImageLinkChange() {
|
|
100
|
+
const imageLink = this.getElm('imageLink');
|
|
101
|
+
imageLink.value = this.state.values.imageLink;
|
|
102
|
+
}
|
|
103
|
+
onImageLinkChange() {
|
|
104
|
+
this.state.values.imageLink = this.getElm('imageLink').value;
|
|
105
|
+
}
|
|
106
|
+
onStateImageLinkOpenInNewTabChange() {
|
|
107
|
+
const imageLinkOpenInNewTab = this.getElm('imageLinkOpenInNewTab');
|
|
108
|
+
imageLinkOpenInNewTab.checked = this.state.values.imageLinkOpenInNewTab;
|
|
109
|
+
}
|
|
110
|
+
onImageLinkOpenInNewTabChange() {
|
|
111
|
+
this.state.values.imageLinkOpenInNewTab = this.getElm('imageLinkOpenInNewTab').checked;
|
|
112
|
+
}
|
|
113
|
+
hideFieldByOptions() {
|
|
114
|
+
const o = this.j.o;
|
|
115
|
+
const opt = o.image;
|
|
116
|
+
[
|
|
117
|
+
['editSrc', 'editSrc'],
|
|
118
|
+
['editTitle', 'editTitle'],
|
|
119
|
+
['editAlt', 'editAlt'],
|
|
120
|
+
['editLink', 'editLink'],
|
|
121
|
+
['editLink', 'editLinkTarget'],
|
|
122
|
+
['useImageEditor', 'editImage']
|
|
123
|
+
].forEach(([optKey, elmKey]) => {
|
|
124
|
+
const elm = this.getElm(elmKey);
|
|
125
|
+
css(elm, 'display', opt[optKey] ? null : 'none');
|
|
126
|
+
});
|
|
127
|
+
const changeImage = this.getElm('changeImage');
|
|
128
|
+
const needShowChangeImage = Boolean(o.filebrowser.ajax.url || o.uploader.url);
|
|
129
|
+
css(changeImage, 'display', needShowChangeImage ? null : 'none');
|
|
130
|
+
const editImage = this.getElm('editImage');
|
|
131
|
+
const needShowEditImage = Boolean(o.filebrowser.ajax.url) && opt.useImageEditor;
|
|
132
|
+
css(editImage, 'display', needShowEditImage ? null : 'none');
|
|
133
|
+
const fixImage = this.getElm('fixImage');
|
|
134
|
+
css(fixImage, 'display', needShowChangeImage || needShowEditImage ? null : 'none');
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
__decorate([
|
|
138
|
+
watch('state.values.imageSrc')
|
|
139
|
+
], UIImageMainTab.prototype, "onStateImageSrcChange", null);
|
|
140
|
+
__decorate([
|
|
141
|
+
watch('imageSrc:change')
|
|
142
|
+
], UIImageMainTab.prototype, "onImageSrcChange", null);
|
|
143
|
+
__decorate([
|
|
144
|
+
watch('editImage:click')
|
|
145
|
+
], UIImageMainTab.prototype, "onEditImageClick", null);
|
|
146
|
+
__decorate([
|
|
147
|
+
watch('changeImage:click')
|
|
148
|
+
], UIImageMainTab.prototype, "onChangeImageClick", null);
|
|
149
|
+
__decorate([
|
|
150
|
+
watch('state.values.imageTitle')
|
|
151
|
+
], UIImageMainTab.prototype, "onStateTitleChange", null);
|
|
152
|
+
__decorate([
|
|
153
|
+
watch('imageTitle:change')
|
|
154
|
+
], UIImageMainTab.prototype, "onTitleChange", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
watch('state.values.imageAlt')
|
|
157
|
+
], UIImageMainTab.prototype, "onStateAltChange", null);
|
|
158
|
+
__decorate([
|
|
159
|
+
watch('imageAlt:change')
|
|
160
|
+
], UIImageMainTab.prototype, "onAltChange", null);
|
|
161
|
+
__decorate([
|
|
162
|
+
watch('state.values.imageLink')
|
|
163
|
+
], UIImageMainTab.prototype, "onStateImageLinkChange", null);
|
|
164
|
+
__decorate([
|
|
165
|
+
watch('imageLink:change')
|
|
166
|
+
], UIImageMainTab.prototype, "onImageLinkChange", null);
|
|
167
|
+
__decorate([
|
|
168
|
+
watch('state.values.imageLinkOpenInNewTab')
|
|
169
|
+
], UIImageMainTab.prototype, "onStateImageLinkOpenInNewTabChange", null);
|
|
170
|
+
__decorate([
|
|
171
|
+
watch('imageLinkOpenInNewTab:change')
|
|
172
|
+
], UIImageMainTab.prototype, "onImageLinkOpenInNewTabChange", null);
|
|
173
|
+
__decorate([
|
|
174
|
+
hook('ready')
|
|
175
|
+
], UIImageMainTab.prototype, "hideFieldByOptions", null);
|
|
176
|
+
UIImageMainTab = __decorate([
|
|
177
|
+
component
|
|
178
|
+
], UIImageMainTab);
|
|
179
|
+
export { UIImageMainTab };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import type { IJodit } from "jodit/esm/types";
|
|
7
|
+
import { UIElement } from "jodit/esm/core/ui/element";
|
|
8
|
+
import type { ImagePropertiesAPI, ImagePropertiesState } from "../interface";
|
|
9
|
+
/** @private */
|
|
10
|
+
export declare class UIImagePositionTab extends UIElement<IJodit> {
|
|
11
|
+
private state;
|
|
12
|
+
protected handlers: ImagePropertiesAPI;
|
|
13
|
+
className(): string;
|
|
14
|
+
constructor(jodit: IJodit, state: ImagePropertiesState, handlers: ImagePropertiesAPI);
|
|
15
|
+
protected render({ availableClasses }: {
|
|
16
|
+
availableClasses?: string[] | Array<[
|
|
17
|
+
string,
|
|
18
|
+
string
|
|
19
|
+
]>;
|
|
20
|
+
}): string;
|
|
21
|
+
protected onStateAlignChange(): void;
|
|
22
|
+
protected onChangeAlign(): void;
|
|
23
|
+
protected onStateValuesBorderRadiusChange(): void;
|
|
24
|
+
protected onChangeBorderRadius(): void;
|
|
25
|
+
protected onStateValuesIdChange(): void;
|
|
26
|
+
protected onChangeId(): void;
|
|
27
|
+
protected onStateValuesStyleChange(): void;
|
|
28
|
+
protected onChangeStyle(): void;
|
|
29
|
+
protected onStateValuesClassesChange(): void;
|
|
30
|
+
protected onChangClasses(): void;
|
|
31
|
+
protected onLockMarginClick(e: MouseEvent): void;
|
|
32
|
+
protected onChangeMarginIsLocked(): void;
|
|
33
|
+
protected onStateValuesMarginChange(): void;
|
|
34
|
+
protected onChangeMargin(): void;
|
|
35
|
+
protected hideFieldByOptions(): void;
|
|
36
|
+
}
|