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,84 @@
/*!
* 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/toolbar/button/README.md]]
* @packageDocumentation
* @module modules/toolbar/button
*/
import type { IControlTypeStrong, IToolbarButton, IToolbarCollection, IViewBased, Nullable } from "../../../types/index";
import { UIButton } from "../../../core/ui/button/index";
export declare class ToolbarButton<T extends IViewBased = IViewBased> extends UIButton implements IToolbarButton {
readonly control: IControlTypeStrong;
readonly target: Nullable<HTMLElement>;
/** @override */
className(): string;
readonly state: {
theme: string;
currentValue: string;
hasTrigger: boolean;
size: "tiny" | "xsmall" | "small" | "middle" | "large";
name: string;
value: string | number | boolean;
variant: import("../../../types/index").ButtonVariant;
type: "button" | "submit";
role: "button" | "tab";
disabled: boolean;
activated: boolean;
icon: import("../../../types/index").IUIIconState;
text: string;
tooltip: string;
tabIndex: import("../../../types/index").CanUndef<number>;
};
protected trigger: HTMLElement;
/**
* Get parent toolbar
*/
protected get toolbar(): Nullable<IToolbarCollection>;
/** @override **/
update(): void;
/**
* Calculates whether the button is active
*/
private __calculateActivatedStatus;
/**
* Calculates whether an element is blocked for the user
*/
private __calculateDisabledStatus;
/** @override */
protected onChangeActivated(): void;
/** @override */
protected onChangeText(): void;
/** @override */
protected onChangeTabIndex(): void;
protected createContainer(): HTMLElement;
/** @override */
focus(): void;
protected onChangeHasTrigger(): void;
/** @override */
protected onChangeDisabled(): void;
constructor(jodit: T, control: IControlTypeStrong, target?: Nullable<HTMLElement>);
/**
* Init constant data from control
*/
protected __initFromControl(): void;
/**
* Click on trigger button
*/
protected onTriggerClick(e: MouseEvent): void;
private openedPopup;
/**
* Create an open popup list
*/
private __openControlList;
protected onOutsideClick(e: MouseEvent): void;
private openPopup;
private __closePopup;
/**
* Click handler
*/
protected onClick(originalEvent: MouseEvent): void;
destruct(): any;
}

415
node_modules/jodit/esm/modules/toolbar/button/button.js generated vendored Normal file
View File

@@ -0,0 +1,415 @@
/*!
* 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
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { STATUSES } from "../../../core/component/statuses.js";
import { autobind, cacheHTML, component, watch } from "../../../core/decorators/index.js";
import { Dom } from "../../../core/dom/index.js";
import { assert, attr, call, camelCase, isArray, isFunction, isJoditObject, isPlainObject, isString, keys, position } from "../../../core/helpers/index.js";
import { UIButton, UIButtonState } from "../../../core/ui/button/index.js";
import { findControlType } from "../../../core/ui/helpers/get-control-type.js";
import { Icon } from "../../../core/ui/icon.js";
import { Popup } from "../../../core/ui/popup/popup.js";
import { ToolbarCollection } from "../collection/collection.js";
import { makeCollection } from "../factory.js";
let ToolbarButton = class ToolbarButton extends UIButton {
/** @override */
className() {
return 'ToolbarButton';
}
/**
* Get parent toolbar
*/
get toolbar() {
return this.closest(ToolbarCollection);
}
/** @override **/
update() {
var _a, _b;
const { control, state } = this, tc = this.closest(ToolbarCollection);
if (!tc) {
return;
}
const value = (_a = control.value) === null || _a === void 0 ? void 0 : _a.call(control, tc.jodit, this);
if (value !== undefined) {
state.value = value;
}
state.disabled = this.__calculateDisabledStatus(tc);
state.activated = this.__calculateActivatedStatus(tc);
(_b = control.update) === null || _b === void 0 ? void 0 : _b.call(control, tc.jodit, this);
}
/**
* Calculates whether the button is active
*/
__calculateActivatedStatus(tc) {
var _a, _b;
if (isJoditObject(this.j) && !this.j.editorIsActive) {
return false;
}
if ((_b = (_a = this.control).isActive) === null || _b === void 0 ? void 0 : _b.call(_a, this.j, this)) {
return true;
}
return Boolean(tc && tc.shouldBeActive(this));
}
/**
* Calculates whether an element is blocked for the user
*/
__calculateDisabledStatus(tc) {
var _a, _b;
if (this.j.o.disabled) {
return true;
}
if (this.j.o.readonly &&
(!this.j.o.activeButtonsInReadOnly ||
!this.j.o.activeButtonsInReadOnly.includes(this.control.name))) {
return true;
}
if ((_b = (_a = this.control).isDisabled) === null || _b === void 0 ? void 0 : _b.call(_a, this.j, this)) {
return true;
}
return Boolean(tc && tc.shouldBeDisabled(this));
}
/** @override */
onChangeActivated() {
attr(this.button, 'aria-pressed', this.state.activated);
super.onChangeActivated();
}
/** @override */
onChangeText() {
if (isFunction(this.control.template)) {
this.text.innerHTML = this.control.template(this.j, this.control.name, this.j.i18n(this.state.text));
}
else {
super.onChangeText();
}
this.setMod('text-icons', Boolean(this.text.innerText.trim().length));
}
/** @override */
onChangeTabIndex() {
attr(this.button, 'tabindex', this.state.tabIndex);
}
createContainer() {
const cn = this.componentName;
const container = this.j.c.span(cn);
const button = super.createContainer();
attr(container, 'role', 'listitem');
button.classList.remove(cn);
button.classList.add(cn + '__button');
Object.defineProperty(button, 'component', {
value: this
});
container.appendChild(button);
const trigger = this.j.c.fromHTML(`<span role="trigger" class="${cn}__trigger">${Icon.get('chevron')}</span>`);
// For caching
button.appendChild(trigger);
return container;
}
/** @override */
focus() {
var _a;
(_a = this.container.querySelector('button')) === null || _a === void 0 ? void 0 : _a.focus();
}
onChangeHasTrigger() {
if (this.state.hasTrigger) {
this.container.appendChild(this.trigger);
}
else {
Dom.safeRemove(this.trigger);
}
this.setMod('with-trigger', this.state.hasTrigger || null);
}
/** @override */
onChangeDisabled() {
const disabled = this.state.disabled ? 'disabled' : null;
attr(this.trigger, 'disabled', disabled);
attr(this.button, 'disabled', disabled);
attr(this.container, 'disabled', disabled);
}
constructor(jodit, control, target = null) {
super(jodit);
this.control = control;
this.target = target;
this.state = {
...UIButtonState(),
theme: 'toolbar',
currentValue: '',
hasTrigger: false
};
this.openedPopup = null;
const button = this.getElm('button');
assert(button, 'Element button should exists');
this.button = button;
Object.defineProperty(button, 'component', {
value: this,
configurable: true
});
const trigger = this.getElm('trigger');
assert(trigger, 'Element trigger should exists');
this.trigger = trigger;
trigger.remove();
// Prevent lost focus
jodit.e.on([this.button, this.trigger], 'mousedown', (e) => e.preventDefault());
this.onAction(this.onClick);
this.hookStatus(STATUSES.ready, () => {
this.__initFromControl();
this.update();
});
if (control.mods) {
Object.keys(control.mods).forEach(mod => {
control.mods && this.setMod(mod, control.mods[mod]);
});
}
}
/**
* Init constant data from control
*/
__initFromControl() {
var _a;
const { control: ctr, state } = this;
this.updateSize();
state.name = ctr.name;
const { textIcons } = this.j.o;
if (textIcons === true ||
(isFunction(textIcons) && textIcons(ctr.name)) ||
ctr.template) {
state.icon = UIButtonState().icon;
state.text = ctr.text || ctr.name;
}
else {
if (ctr.iconURL) {
state.icon.iconURL = ctr.iconURL;
}
else {
const name = ctr.icon || ctr.name;
state.icon.name =
Icon.exists(name) || ((_a = this.j.o.extraIcons) === null || _a === void 0 ? void 0 : _a[name])
? name
: '';
}
if (!ctr.iconURL && !state.icon.name) {
state.text = ctr.text || ctr.name;
}
}
if (ctr.tooltip) {
state.tooltip = this.j.i18n(isFunction(ctr.tooltip)
? ctr.tooltip(this.j, ctr, this)
: ctr.tooltip);
}
state.hasTrigger = Boolean(ctr.list || (ctr.popup && ctr.exec));
}
/**
* Click on trigger button
*/
onTriggerClick(e) {
var _a, _b, _c;
if (this.openedPopup) {
this.__closePopup();
return;
}
const { control: ctr } = this;
e.buffer = {
actionTrigger: this
};
if (ctr.list) {
return this.__openControlList(ctr);
}
if (isFunction(ctr.popup)) {
const popup = this.openPopup();
popup.parentElement = this;
try {
if (this.j.e.fire(camelCase(`before-${ctr.name}-open-popup`), this.target, ctr, popup) !== false) {
const target = (_c = (_b = (_a = this.toolbar) === null || _a === void 0 ? void 0 : _a.getTarget(this)) !== null && _b !== void 0 ? _b : this.target) !== null && _c !== void 0 ? _c : null;
const elm = ctr.popup(this.j, target, this.__closePopup, this);
if (elm) {
popup
.setContent(isString(elm) ? this.j.c.fromHTML(elm) : elm)
.open(() => position(this.container), false, this.j.o.allowTabNavigation
? this.container
: undefined);
}
else {
this.__closePopup();
}
}
}
catch (e) {
this.__closePopup();
throw e;
}
/**
* Fired after the popup was opened for some control button
*/
/**
* Close all opened popups
*/
this.j.e.fire(camelCase(`after-${ctr.name}-open-popup`), popup.container);
}
}
/**
* Create an open popup list
*/
__openControlList(control) {
var _a;
const controls = (_a = this.jodit.options.controls) !== null && _a !== void 0 ? _a : {}, getControl = (key) => findControlType(key, controls);
const list = control.list, menu = this.openPopup(), toolbar = makeCollection(this.j);
menu.parentElement = this;
toolbar.parentElement = menu;
toolbar.mode = 'vertical';
const isListItem = (key) => isPlainObject(key) && 'title' in key && 'value' in key;
const getButton = (key, value) => {
if (isString(value) && getControl(value)) {
return {
name: value.toString(),
...getControl(value)
};
}
if (isString(key) && getControl(key)) {
return {
name: key.toString(),
...getControl(key),
...(typeof value === 'object' ? value : {})
};
}
if (isListItem(key)) {
value = key.value;
key = key.title;
}
const { childTemplate } = control;
const childControl = {
name: key.toString(),
template: childTemplate &&
((j, k, v) => childTemplate(j, k, v, this)),
exec: control.childExec
? (view, current, options) => {
var _a;
return (_a = control.childExec) === null || _a === void 0 ? void 0 : _a.call(control, view, current, {
...options,
parentControl: control
});
}
: control.exec,
data: control.data,
command: control.command,
isActive: control.isChildActive,
value: control.value,
isDisabled: control.isChildDisabled,
mode: control.mode,
args: [...(control.args ? control.args : []), key, value]
};
if (isString(value)) {
childControl.text = value;
}
return childControl;
};
toolbar.build(isArray(list)
? list.map(getButton)
: keys(list, false).map(key => getButton(key, list[key])), this.target);
menu.setContent(toolbar).open(() => position(this.container), false, this.j.o.allowTabNavigation ? this.container : undefined);
this.state.activated = true;
}
onOutsideClick(e) {
if (!this.openedPopup) {
return;
}
if (!e ||
!Dom.isNode(e.target) ||
(!Dom.isOrContains(this.container, e.target) &&
!this.openedPopup.isOwnClick(e))) {
this.__closePopup();
}
}
openPopup() {
this.__closePopup();
this.openedPopup = new Popup(this.j, false);
this.j.e
.on(this.ow, 'mousedown touchstart', this.onOutsideClick)
.on('escape closeAllPopups', this.onOutsideClick);
return this.openedPopup;
}
__closePopup() {
if (this.openedPopup) {
this.j.e
.off(this.ow, 'mousedown touchstart', this.onOutsideClick)
.off('escape closeAllPopups', this.onOutsideClick);
this.state.activated = false;
this.openedPopup.close();
this.openedPopup.destruct();
this.openedPopup = null;
}
}
/**
* Click handler
*/
onClick(originalEvent) {
var _a, _b, _c, _d, _e, _f, _g;
const { control: ctr } = this;
if (isFunction(ctr.exec)) {
const target = (_c = (_b = (_a = this.toolbar) === null || _a === void 0 ? void 0 : _a.getTarget(this)) !== null && _b !== void 0 ? _b : this.target) !== null && _c !== void 0 ? _c : null;
const result = ctr.exec(this.j, target, {
control: ctr,
originalEvent,
button: this
});
// For memorise exec
if (result !== false && result !== true) {
(_e = (_d = this.j) === null || _d === void 0 ? void 0 : _d.e) === null || _e === void 0 ? void 0 : _e.fire('synchro');
if (this.parentElement) {
this.parentElement.update();
}
/**
* Fired after calling `button.exec` function
*/
(_g = (_f = this.j) === null || _f === void 0 ? void 0 : _f.e) === null || _g === void 0 ? void 0 : _g.fire('closeAllPopups afterExec');
}
if (result !== false) {
return;
}
}
if (ctr.list) {
return this.__openControlList(ctr);
}
if (isFunction(ctr.popup)) {
return this.onTriggerClick(originalEvent);
}
if (ctr.command || ctr.name) {
call(isJoditObject(this.j)
? this.j.execCommand.bind(this.j)
: this.j.od.execCommand.bind(this.j.od), ctr.command || ctr.name, false, ctr.args && ctr.args[0]);
this.j.e.fire('closeAllPopups');
}
}
destruct() {
this.__closePopup();
return super.destruct();
}
};
__decorate([
cacheHTML
], ToolbarButton.prototype, "createContainer", null);
__decorate([
watch('state.hasTrigger', { immediately: false })
], ToolbarButton.prototype, "onChangeHasTrigger", null);
__decorate([
watch('trigger:click')
], ToolbarButton.prototype, "onTriggerClick", null);
__decorate([
autobind
], ToolbarButton.prototype, "onOutsideClick", null);
__decorate([
autobind
], ToolbarButton.prototype, "__closePopup", null);
ToolbarButton = __decorate([
component
], ToolbarButton);
export { ToolbarButton };

View File

@@ -0,0 +1,21 @@
/*!
* 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/toolbar/button
*/
import type { IControlTypeContent, IToolbarButton, IViewBased, Nullable } from "../../../types/index";
import { UIButton } from "../../../core/ui/button/index";
export declare class ToolbarContent<T extends IViewBased = IViewBased> extends UIButton implements IToolbarButton {
readonly control: IControlTypeContent;
readonly target: Nullable<HTMLElement>;
/** @override */
className(): string;
/** @override */
update(): void;
/** @override */
protected createContainer(): HTMLElement;
constructor(jodit: T, control: IControlTypeContent, target?: Nullable<HTMLElement>);
}

View File

@@ -0,0 +1,49 @@
/*!
* 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
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { component } from "../../../core/decorators/index.js";
import { Dom } from "../../../core/dom/index.js";
import { attr, isString } from "../../../core/helpers/index.js";
import { UIButton } from "../../../core/ui/button/index.js";
let ToolbarContent = class ToolbarContent extends UIButton {
/** @override */
className() {
return 'ToolbarContent';
}
/** @override */
update() {
const content = this.control.getContent(this.j, this);
if (isString(content) || content.parentNode !== this.container) {
Dom.detach(this.container);
this.container.appendChild(isString(content) ? this.j.create.fromHTML(content) : content);
}
super.update();
}
/** @override */
createContainer() {
return this.j.c.span(this.componentName);
}
constructor(jodit, control, target = null) {
super(jodit);
this.control = control;
this.target = target;
this.container.classList.add(`${this.componentName}_${this.clearName(control.name)}`);
attr(this.container, 'role', 'content');
}
};
ToolbarContent = __decorate([
component
], ToolbarContent);
export { ToolbarContent };

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 modules/toolbar/button
*/
export * from "./button";
export * from "./content";
export * from "./select/select";

11
node_modules/jodit/esm/modules/toolbar/button/index.js generated vendored Normal file
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 modules/toolbar/button
*/
export * from "./button.js";
export * from "./content.js";
export * from "./select/select.js";

View File

@@ -0,0 +1,14 @@
/*!
* 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/toolbar/button
*/
import type { IViewBased } from "../../../../types/index";
import { ToolbarButton } from "../button";
export declare class ToolbarSelect<T extends IViewBased = IViewBased> extends ToolbarButton<T> {
className(): string;
update(): void;
}

View File

@@ -0,0 +1,47 @@
/*!
* 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
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { component } from "../../../../core/decorators/index.js";
import { isPlainObject } from "../../../../core/helpers/checker/is-plain-object.js";
import { isString } from "../../../../core/helpers/checker/is-string.js";
import { ToolbarButton } from "../button.js";
let ToolbarSelect = class ToolbarSelect extends ToolbarButton {
className() {
return 'ToolbarSelect';
}
update() {
var _a, _b, _c;
super.update();
this.state.icon.name = '';
const { list, data } = this.control;
if (list) {
let key = this.state.value ||
(data && isString(data.currentValue)
? data.currentValue
: undefined);
if (!key) {
const keys = Object.keys(list);
key = keys[0];
}
const text = (isPlainObject(list) ? list[key.toString()] || key : key).toString();
this.state.text =
(_c = (_b = (_a = this.control).textTemplate) === null || _b === void 0 ? void 0 : _b.call(_a, this.jodit, text)) !== null && _c !== void 0 ? _c : text;
}
}
};
ToolbarSelect = __decorate([
component
], ToolbarSelect);
export { ToolbarSelect };

View File

@@ -0,0 +1,50 @@
/*!
* 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/toolbar/collection/README.md]]
* @packageDocumentation
* @module modules/toolbar/collection
*/
import type { ButtonsGroups, IBound, IControlTypeStrong, IToolbarButton, IToolbarCollection, IUIButton, IViewBased, IViewWithToolbar, Nullable } from "../../../types/index";
import { UIList } from "../../../core/ui/index";
export declare class ToolbarCollection<T extends IViewWithToolbar = IViewWithToolbar> extends UIList<T> implements IToolbarCollection {
/** @override */
className(): string;
private readonly __listenEvents;
/**
* First button in a list
*/
get firstButton(): Nullable<IToolbarButton>;
protected makeButton(control: IControlTypeStrong, target?: Nullable<HTMLElement>): IUIButton;
protected makeSelect(control: IControlTypeStrong, target?: Nullable<HTMLElement>): IUIButton;
/**
* Button should be active
*/
shouldBeActive(button: IToolbarButton): boolean | undefined;
/**
* The Button should be disabled
*/
shouldBeDisabled(button: IToolbarButton): boolean | undefined;
/**
* Returns current target for button
*/
getTarget(button: IToolbarButton): Node | null;
private __immediateUpdate;
update(): void;
/**
* Set direction
*/
setDirection(direction: 'rtl' | 'ltr'): void;
constructor(jodit: IViewBased);
protected __initEvents(): void;
hide(): void;
show(): void;
showInline(bound?: IBound): void;
/** @override **/
build(items: ButtonsGroups, target?: Nullable<HTMLElement>): this;
/** @override **/
destruct(): void;
}

View File

@@ -0,0 +1,124 @@
/*!
* 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
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { autobind, component, debounce, hook } from "../../../core/decorators/index.js";
import { error } from "../../../core/helpers/utils/error/error.js";
import { UIList } from "../../../core/ui/index.js";
import { makeButton, makeSelect } from "../factory.js";
let ToolbarCollection = class ToolbarCollection extends UIList {
/** @override */
className() {
return 'ToolbarCollection';
}
/**
* First button in a list
*/
get firstButton() {
const [button] = this.buttons;
return button || null;
}
makeButton(control, target = null) {
return makeButton(this.j, control, target);
}
makeSelect(control, target = null) {
return makeSelect(this.j, control, target);
}
/**
* Button should be active
*/
shouldBeActive(button) {
return undefined;
}
/**
* The Button should be disabled
*/
shouldBeDisabled(button) {
return undefined;
}
/**
* Returns current target for button
*/
getTarget(button) {
return button.target || null;
}
__immediateUpdate() {
if (this.isDestructed || this.j.isLocked) {
return;
}
super.update();
this.j.e.fire('afterUpdateToolbar', this);
}
update() {
this.__immediateUpdate();
}
/**
* Set direction
*/
setDirection(direction) {
this.container.style.direction = direction;
this.container.setAttribute('dir', direction);
}
constructor(jodit) {
super(jodit);
this.__listenEvents = 'updatePlugins updateToolbar changeStack mousedown mouseup keydown change afterInit readonly afterResize ' +
'selectionchange changeSelection focus afterSetMode touchstart focus blur';
}
__initEvents() {
this.j.e
.on(this.__listenEvents, this.update)
.on('afterSetMode focus', this.__immediateUpdate);
}
hide() {
this.container.remove();
}
show() {
this.appendTo(this.j.toolbarContainer);
}
showInline(bound) {
throw error('The method is not implemented for this class.');
}
/** @override **/
build(items, target = null) {
const itemsWithGroupps = this.j.e.fire('beforeToolbarBuild', items);
if (itemsWithGroupps) {
items = itemsWithGroupps;
}
super.build(items, target);
return this;
}
/** @override **/
destruct() {
if (this.isDestructed) {
return;
}
this.j.e
.off(this.__listenEvents, this.update)
.off('afterSetMode focus', this.__immediateUpdate);
super.destruct();
}
};
__decorate([
autobind
], ToolbarCollection.prototype, "__immediateUpdate", null);
__decorate([
debounce(ctx => ctx.j.defaultTimeout, true)
], ToolbarCollection.prototype, "update", null);
__decorate([
hook('ready')
], ToolbarCollection.prototype, "__initEvents", null);
ToolbarCollection = __decorate([
component
], ToolbarCollection);
export { ToolbarCollection };

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
*/
/**
* @module modules/toolbar/collection
*/
import type { IBound, IJodit, IToolbarButton } from "../../../types/index";
import { ToolbarCollection } from "./collection";
export declare class ToolbarEditorCollection extends ToolbarCollection<IJodit> {
/** @override */
className(): string;
/** @override */
shouldBeDisabled(button: IToolbarButton): boolean;
/** @override */
shouldBeActive(button: IToolbarButton): boolean;
private checkActiveStatus;
/** @override */
getTarget(button: IToolbarButton): Node | null;
/** @override */
constructor(jodit: IJodit);
/**
* Adds an invisible element to the container that can handle the
* situation when the editor is inside the <label>
*
* @see https://github.com/jodit/jodit-react/issues/138
*/
private prependInvisibleInput;
/**
* Show the inline toolbar inside WYSIWYG editor.
* @param bound - you can set the place for displaying the toolbar,
* or the place will be in the place of the cursor
*/
showInline(bound?: IBound): void;
hide(): void;
show(): void;
}

View File

@@ -0,0 +1,136 @@
/*!
* 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
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import * as consts from "../../../core/constants.js";
import { component } from "../../../core/decorators/index.js";
import { Dom } from "../../../core/dom/index.js";
import { css, isFunction } from "../../../core/helpers/index.js";
import { ToolbarCollection } from "./collection.js";
let ToolbarEditorCollection = class ToolbarEditorCollection extends ToolbarCollection {
/** @override */
className() {
return 'ToolbarEditorCollection';
}
/** @override */
shouldBeDisabled(button) {
const disabled = super.shouldBeDisabled(button);
if (disabled !== undefined) {
return disabled;
}
const mode = button.control.mode === undefined
? consts.MODE_WYSIWYG
: button.control.mode;
return !(mode === consts.MODE_SPLIT || mode === this.j.getRealMode());
}
/** @override */
shouldBeActive(button) {
const active = super.shouldBeActive(button);
if (active !== undefined) {
return active;
}
const element = this.j.selection ? this.j.s.current() : null;
if (!element) {
return false;
}
let elm;
if (button.control.tags) {
const tags = button.control.tags;
elm = element;
if (Dom.up(elm, (node) => {
if (node &&
tags.indexOf(node.nodeName.toLowerCase()) !== -1) {
return true;
}
}, this.j.editor)) {
return true;
}
}
// activate by supposed css
if (button.control.css) {
const css = button.control.css;
elm = element;
if (Dom.up(elm, (node) => {
if (node && !Dom.isText(node) && !Dom.isComment(node)) {
return this.checkActiveStatus(css, node);
}
}, this.j.editor)) {
return true;
}
}
return false;
}
/** @override */
getTarget(button) {
return button.target || this.j.s.current() || null;
}
/** @override */
constructor(jodit) {
super(jodit);
this.checkActiveStatus = (cssObject, node) => {
let matches = 0, total = 0;
Object.keys(cssObject).forEach((cssProperty) => {
const cssValue = cssObject[cssProperty];
if (isFunction(cssValue)) {
if (cssValue(this.j, css(node, cssProperty).toString())) {
matches += 1;
}
}
else {
if (cssValue.indexOf(css(node, cssProperty).toString()) !== -1) {
matches += 1;
}
}
total += 1;
});
return total === matches;
};
this.prependInvisibleInput(this.container);
}
/**
* Adds an invisible element to the container that can handle the
* situation when the editor is inside the <label>
*
* @see https://github.com/jodit/jodit-react/issues/138
*/
prependInvisibleInput(container) {
const input = this.j.create.element('input', {
tabIndex: -1,
disabled: true, // Because <label> can trigger click
style: 'width: 0; height:0; position: absolute; visibility: hidden;'
});
Dom.appendChildFirst(container, input);
}
/**
* Show the inline toolbar inside WYSIWYG editor.
* @param bound - you can set the place for displaying the toolbar,
* or the place will be in the place of the cursor
*/
showInline(bound) {
this.jodit.e.fire('showInlineToolbar', bound);
}
hide() {
this.jodit.e.fire('hidePopup');
super.hide();
this.jodit.e.fire('toggleToolbar');
}
show() {
super.show();
this.jodit.e.fire('toggleToolbar');
}
};
ToolbarEditorCollection = __decorate([
component
], ToolbarEditorCollection);
export { ToolbarEditorCollection };

20
node_modules/jodit/esm/modules/toolbar/factory.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
/*!
* 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/toolbar/README.md]]
* @packageDocumentation
* @module modules/toolbar
*/
import type { IControlTypeStrong, IToolbarButton, IToolbarCollection, IUIElement, IViewBased, Nullable } from "../../types/index";
/**
* Collection factory
*/
export declare function makeCollection(jodit: IViewBased, parentElement?: IUIElement): IToolbarCollection;
/**
* Button factory
*/
export declare function makeButton(jodit: IViewBased, control: IControlTypeStrong, target?: Nullable<HTMLElement>): IToolbarButton;
export declare function makeSelect(view: IViewBased, control: IControlTypeStrong, target?: Nullable<HTMLElement>): IToolbarButton;

43
node_modules/jodit/esm/modules/toolbar/factory.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
/*!
* 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, isJoditObject } from "../../core/helpers/index.js";
import { ToolbarButton } from "./button/button.js";
import { ToolbarContent } from "./button/content.js";
import { ToolbarSelect } from "./button/select/select.js";
import { ToolbarCollection } from "./collection/collection.js";
import { ToolbarEditorCollection } from "./collection/editor-collection.js";
/**
* Collection factory
*/
export function makeCollection(jodit, parentElement) {
const collection = isJoditObject(jodit)
? new ToolbarEditorCollection(jodit)
: new ToolbarCollection(jodit);
if (jodit.o.textIcons) {
collection.container.classList.add('jodit_text_icons');
}
if (parentElement) {
collection.parentElement = parentElement;
}
if (jodit.o.toolbarButtonSize) {
collection.buttonSize = jodit.o.toolbarButtonSize;
}
return collection;
}
/**
* Button factory
*/
export function makeButton(jodit, control, target = null) {
if (isFunction(control.getContent)) {
return new ToolbarContent(jodit, control, target);
}
const button = new ToolbarButton(jodit, control, target);
button.state.tabIndex = jodit.o.allowTabNavigation ? 0 : -1;
return button;
}
export function makeSelect(view, control, target = null) {
return new ToolbarSelect(view, control, target);
}