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

19
node_modules/jodit/esm/modules/history/command.d.ts generated vendored Normal file
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
*/
/**
* @module modules/history
*/
import type { SnapshotType } from "../../types/index";
import type { History } from "./history";
export declare class Command {
readonly oldValue: SnapshotType;
readonly newValue: SnapshotType;
private readonly history;
readonly tick: number;
undo(): void;
redo(): void;
constructor(oldValue: SnapshotType, newValue: SnapshotType, history: History, tick: number);
}

19
node_modules/jodit/esm/modules/history/command.js generated vendored Normal file
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
*/
export class Command {
undo() {
this.history.snapshot.restore(this.oldValue);
}
redo() {
this.history.snapshot.restore(this.newValue);
}
constructor(oldValue, newValue, history, tick) {
this.oldValue = oldValue;
this.newValue = newValue;
this.history = history;
this.tick = tick;
}
}

74
node_modules/jodit/esm/modules/history/history.d.ts generated vendored Normal file
View File

@@ -0,0 +1,74 @@
/*!
* 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/history/README.md]]
* @packageDocumentation
* @module modules/history
*/
import type { IDestructible, IHistory, IJodit, ISnapshot, SnapshotType } from "../../types/index";
import { ViewComponent } from "../../core/component/index";
import { Snapshot } from "./snapshot";
import { Stack } from "./stack";
declare module 'jodit/config' {
interface Config {
history: {
enable: boolean;
/**
* Limit of history length
*/
maxHistoryLength: number;
/**
* Delay on every change
*/
timeout: number;
};
}
}
/**
* The module monitors the status of the editor and creates / deletes the required number of Undo / Redo shots .
*/
export declare class History extends ViewComponent<IJodit> implements IHistory {
/** @override */
className(): string;
/**
* Return state of the WYSIWYG editor to step back
*/
redo(): void;
canRedo(): boolean;
/**
* Return the state of the WYSIWYG editor to step forward
*/
undo(): void;
canUndo(): boolean;
clear(): void;
get length(): number;
private __startValue;
protected get startValue(): SnapshotType;
protected set startValue(value: SnapshotType);
private readonly __stack;
snapshot: ISnapshot & IDestructible;
constructor(editor: IJodit, stack?: Stack, snapshot?: Snapshot);
private updateTick;
/**
* Update change counter
* @internal
*/
protected __upTick(): void;
/**
* Push new command in stack on some changes
*/
private onChange;
/**
* @internal
*/
protected __processChanges(): void;
/**
* Update history stack
*/
private updateStack;
private fireChangeStack;
destruct(): void;
}

168
node_modules/jodit/esm/modules/history/history.js generated vendored Normal file
View File

@@ -0,0 +1,168 @@
/*!
* 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 { ViewComponent } from "../../core/component/index.js";
import { debounce } from "../../core/decorators/index.js";
import { Config } from "../../config.js";
import { Command } from "./command.js";
import { Snapshot } from "./snapshot.js";
import { Stack } from "./stack.js";
Config.prototype.history = {
enable: true,
maxHistoryLength: Infinity,
timeout: 1000
};
/**
* The module monitors the status of the editor and creates / deletes the required number of Undo / Redo shots .
*/
export class History extends ViewComponent {
/** @override */
className() {
return 'History';
}
/**
* Return state of the WYSIWYG editor to step back
*/
redo() {
if (this.__stack.redo()) {
this.startValue = this.snapshot.make();
this.fireChangeStack();
}
}
canRedo() {
return this.__stack.canRedo();
}
/**
* Return the state of the WYSIWYG editor to step forward
*/
undo() {
if (this.__stack.undo()) {
this.startValue = this.snapshot.make();
this.fireChangeStack();
}
}
canUndo() {
return this.__stack.canUndo();
}
clear() {
this.startValue = this.snapshot.make();
this.__stack.clear();
this.fireChangeStack();
}
get length() {
return this.__stack.length;
}
get startValue() {
return this.__startValue;
}
set startValue(value) {
this.__startValue = value;
}
constructor(editor, stack = new Stack(editor.o.history.maxHistoryLength), snapshot = new Snapshot(editor)) {
super(editor);
this.updateTick = 0;
this.__stack = stack;
this.snapshot = snapshot;
if (editor.o.history.enable) {
editor.e.on('afterAddPlace.history', () => {
if (this.isInDestruct) {
return;
}
this.startValue = this.snapshot.make();
editor.events
// save selection
.on('internalChange internalUpdate', () => {
this.startValue = this.snapshot.make();
})
.on(editor.editor, [
'changeSelection',
'selectionstart',
'selectionchange',
'mousedown',
'mouseup',
'keydown',
'keyup'
]
.map(f => f + '.history')
.join(' '), () => {
if (this.startValue.html ===
this.j.getNativeEditorValue()) {
this.startValue = this.snapshot.make();
}
})
.on(this, 'change.history', this.onChange);
});
}
}
/**
* Update change counter
* @internal
*/
__upTick() {
this.updateTick += 1;
}
/**
* Push new command in stack on some changes
*/
onChange() {
this.__processChanges();
}
/**
* @internal
*/
__processChanges() {
if (this.snapshot.isBlocked || !this.j.o.history.enable) {
return;
}
this.updateStack();
}
/**
* Update history stack
*/
updateStack(replace = false) {
const newValue = this.snapshot.make();
if (!Snapshot.equal(newValue, this.startValue)) {
const newCommand = new Command(this.startValue, newValue, this, this.updateTick);
if (replace) {
const command = this.__stack.current();
if (command && this.updateTick === command.tick) {
this.__stack.replace(newCommand);
}
}
else {
this.__stack.push(newCommand);
}
this.startValue = newValue;
this.fireChangeStack();
}
}
fireChangeStack() {
var _a;
this.j && !this.j.isInDestruct && ((_a = this.j.events) === null || _a === void 0 ? void 0 : _a.fire('changeStack'));
}
destruct() {
if (this.isInDestruct) {
return;
}
if (this.j.events) {
this.j.e.off('.history');
}
this.snapshot.destruct();
super.destruct();
}
}
__decorate([
debounce()
], History.prototype, "onChange", null);

68
node_modules/jodit/esm/modules/history/snapshot.d.ts generated vendored Normal file
View File

@@ -0,0 +1,68 @@
/*!
* 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/history
*/
import type { IJodit, ISnapshot, SnapshotType } from "../../types/index";
import { ViewComponent } from "../../core/component/index";
/**
* Module for creating snapshot of editor which includes html content and the current selection
*/
export declare class Snapshot extends ViewComponent<IJodit> implements ISnapshot {
/** @override */
className(): string;
/**
* Compare two snapshotes, if and htmls and selections match, then return true
*
* @param first - the first snapshote
* @param second - second shot
*/
static equal(first: SnapshotType, second: SnapshotType): boolean;
/**
* Calc count element before some node in parentNode. All text nodes are joined
*/
private static countNodesBeforeInParent;
/**
* Calc normal offset in joined text nodes
*/
private static strokeOffset;
/**
* Calc whole hierarchy path before some element in editor's tree
*/
private calcHierarchyLadder;
private getElementByLadder;
private __isBlocked;
get isBlocked(): boolean;
private __block;
private __levelOfTransaction;
transaction(changes: () => void): void;
/**
* Creates object a snapshot of editor: html and the current selection. Current selection calculate by
* offset by start document
* \{html: string, range: \{startContainer: int, startOffset: int, endContainer: int, endOffset: int\}\} or
* \{html: string\} without selection
*/
make(): SnapshotType;
/**
* Restores the state of the editor of the snapshot. Rebounding is not only html but selected text
*
* @param snapshot - snapshot of editor resulting from the `[[Snapshot.make]]` method
* @see make
*/
restore(snapshot: SnapshotType): void;
private storeScrollState;
private restoreScrollState;
/**
* Restore selection from snapshot
*
* @param snapshot - snapshot of editor resulting from the [[Snapshot.make]] method
* @see make
*/
restoreOnlySelection(snapshot: SnapshotType): void;
destruct(): void;
private static isIgnoredNode;
private __getCleanedEditorValue;
}

213
node_modules/jodit/esm/modules/history/snapshot.js generated vendored Normal file
View File

@@ -0,0 +1,213 @@
/*!
* 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 { ViewComponent } from "../../core/component/index.js";
import { IS_PROD } from "../../core/constants.js";
import { Dom } from "../../core/dom/dom.js";
/**
* Module for creating snapshot of editor which includes html content and the current selection
*/
export class Snapshot extends ViewComponent {
constructor() {
super(...arguments);
this.__isBlocked = false;
this.__levelOfTransaction = 0;
}
/** @override */
className() {
return 'Snapshot';
}
/**
* Compare two snapshotes, if and htmls and selections match, then return true
*
* @param first - the first snapshote
* @param second - second shot
*/
static equal(first, second) {
return (first.html === second.html &&
JSON.stringify(first.range) === JSON.stringify(second.range));
}
/**
* Calc count element before some node in parentNode. All text nodes are joined
*/
static countNodesBeforeInParent(elm) {
if (!elm.parentNode) {
return 0;
}
const elms = elm.parentNode.childNodes;
let count = 0, previous = null;
for (let j = 0; j < elms.length; j += 1) {
if (previous &&
!this.isIgnoredNode(elms[j]) &&
!(Dom.isText(previous) && Dom.isText(elms[j]))) {
count += 1;
}
if (elms[j] === elm) {
return count;
}
previous = elms[j];
}
return 0;
}
/**
* Calc normal offset in joined text nodes
*/
static strokeOffset(elm, offset) {
while (Dom.isText(elm)) {
elm = elm.previousSibling;
if (Dom.isText(elm) && elm.nodeValue) {
offset += elm.nodeValue.length;
}
}
return offset;
}
/**
* Calc whole hierarchy path before some element in editor's tree
*/
calcHierarchyLadder(elm) {
const counts = [];
if (!elm || !elm.parentNode || !Dom.isOrContains(this.j.editor, elm)) {
return [];
}
while (elm && elm !== this.j.editor) {
if (elm && !Snapshot.isIgnoredNode(elm)) {
counts.push(Snapshot.countNodesBeforeInParent(elm));
}
elm = elm.parentNode;
}
return counts.reverse();
}
getElementByLadder(ladder) {
let n = this.j.editor, i;
for (i = 0; n && i < ladder.length; i += 1) {
n = n.childNodes[ladder[i]];
}
return n;
}
get isBlocked() {
return this.__isBlocked;
}
__block(enable) {
this.__isBlocked = enable;
}
transaction(changes) {
this.__block(true);
this.__levelOfTransaction += 1;
try {
changes();
}
catch (e) {
if (!IS_PROD) {
throw e;
}
}
finally {
this.__levelOfTransaction -= 1;
if (this.__levelOfTransaction === 0) {
this.__block(false);
}
}
}
/**
* Creates object a snapshot of editor: html and the current selection. Current selection calculate by
* offset by start document
* \{html: string, range: \{startContainer: int, startOffset: int, endContainer: int, endOffset: int\}\} or
* \{html: string\} without selection
*/
make() {
const snapshot = {
html: '',
range: {
startContainer: [],
startOffset: 0,
endContainer: [],
endOffset: 0
}
};
snapshot.html = this.__getCleanedEditorValue(this.j.editor);
const sel = this.j.s.sel;
if (sel && sel.rangeCount) {
const range = sel.getRangeAt(0);
const startContainer = this.calcHierarchyLadder(range.startContainer);
const endContainer = this.calcHierarchyLadder(range.endContainer);
let startOffset = Snapshot.strokeOffset(range.startContainer, range.startOffset), endOffset = Snapshot.strokeOffset(range.endContainer, range.endOffset);
if (!startContainer.length &&
range.startContainer !== this.j.editor) {
startOffset = 0;
}
if (!endContainer.length && range.endContainer !== this.j.editor) {
endOffset = 0;
}
snapshot.range = {
startContainer,
startOffset,
endContainer,
endOffset
};
}
return snapshot;
}
/**
* Restores the state of the editor of the snapshot. Rebounding is not only html but selected text
*
* @param snapshot - snapshot of editor resulting from the `[[Snapshot.make]]` method
* @see make
*/
restore(snapshot) {
this.transaction(() => {
const scroll = this.storeScrollState();
const html = this.__getCleanedEditorValue(this.j.editor);
if (html !== snapshot.html) {
this.j.value = snapshot.html;
}
this.restoreOnlySelection(snapshot);
this.restoreScrollState(scroll);
});
}
storeScrollState() {
return [this.j.ow.scrollY, this.j.editor.scrollTop];
}
restoreScrollState(scrolls) {
const { j } = this, { ow } = j;
ow.scrollTo(ow.scrollX, scrolls[0]);
j.editor.scrollTop = scrolls[1];
}
/**
* Restore selection from snapshot
*
* @param snapshot - snapshot of editor resulting from the [[Snapshot.make]] method
* @see make
*/
restoreOnlySelection(snapshot) {
try {
if (snapshot.range) {
const range = this.j.ed.createRange();
range.setStart(this.getElementByLadder(snapshot.range.startContainer), snapshot.range.startOffset);
range.setEnd(this.getElementByLadder(snapshot.range.endContainer), snapshot.range.endOffset);
this.j.s.selectRange(range);
}
}
catch (__ignore) {
this.j.editor.lastChild &&
this.j.s.setCursorAfter(this.j.editor.lastChild);
if (!IS_PROD) {
// tslint:disable-next-line:no-console
console.warn('Broken snapshot', __ignore);
}
}
}
destruct() {
this.__block(false);
super.destruct();
}
static isIgnoredNode(node) {
return (Dom.isText(node) && !node.nodeValue) || Dom.isTemporary(node);
}
__getCleanedEditorValue(node) {
const clone = node.cloneNode(true);
Dom.temporaryList(clone).forEach(Dom.unwrap);
return clone.innerHTML;
}
}

26
node_modules/jodit/esm/modules/history/stack.d.ts generated vendored Normal file
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
*/
/**
* @module modules/history
*/
import type { CanUndef, IStack } from "../../types/index";
import type { Command } from "./command";
export declare class Stack implements IStack {
private readonly size;
private readonly commands;
private stackPosition;
constructor(size: number);
get length(): number;
private clearRedo;
clear(): void;
push(command: Command): void;
replace(command: Command): void;
current(): CanUndef<Command>;
undo(): boolean;
redo(): boolean;
canUndo(): boolean;
canRedo(): boolean;
}

63
node_modules/jodit/esm/modules/history/stack.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
/*!
* 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
*/
export class Stack {
constructor(size) {
this.size = size;
this.commands = [];
this.stackPosition = -1;
}
get length() {
return this.commands.length;
}
clearRedo() {
this.commands.length = this.stackPosition + 1;
}
clear() {
this.commands.length = 0;
this.stackPosition = -1;
}
push(command) {
this.clearRedo();
this.commands.push(command);
this.stackPosition += 1;
if (this.commands.length > this.size) {
this.commands.shift();
this.stackPosition -= 1;
}
}
replace(command) {
this.commands[this.stackPosition] = command;
}
current() {
return this.commands[this.stackPosition];
}
undo() {
if (this.canUndo()) {
if (this.commands[this.stackPosition]) {
this.commands[this.stackPosition].undo();
}
this.stackPosition -= 1;
return true;
}
return false;
}
redo() {
if (this.canRedo()) {
this.stackPosition += 1;
if (this.commands[this.stackPosition]) {
this.commands[this.stackPosition].redo();
}
return true;
}
return false;
}
canUndo() {
return this.stackPosition >= 0;
}
canRedo() {
return this.stackPosition < this.commands.length - 1;
}
}