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,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 };