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

46
node_modules/jodit/esm/plugins/source/config.d.ts generated vendored Normal file
View File

@@ -0,0 +1,46 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/source
*/
import type { IJodit, ISourceEditor } from "../../types/index";
declare module 'jodit/config' {
interface Config {
sourceEditor: 'area' | 'ace' | ((jodit: IJodit) => ISourceEditor);
/**
* Options for [ace](https://ace.c9.io/#config) editor
* @example
* ```js
* Jodit.make('#editor', {
* showGutter: true,
* theme: 'ace/theme/idle_fingers',
* mode: 'ace/mode/html',
* wrap: true,
§ * highlightActiveLine: true
* })
* ```
*/
sourceEditorNativeOptions: {
showGutter: boolean;
theme: string;
mode: string;
wrap: string | boolean | number;
highlightActiveLine: boolean;
};
/**
* Beautify HTML then it possible
*/
beautifyHTML: boolean;
/**
* CDN URLs for HTML Beautifier
*/
beautifyHTMLCDNUrlsJS: string[];
/**
* CDN URLs for ACE editor
*/
sourceEditorCDNUrlsJS: string[];
}
}

51
node_modules/jodit/esm/plugins/source/config.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
/*!
* 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 { IS_IE, MODE_SOURCE, MODE_SPLIT } from "../../core/constants.js";
import { Icon } from "../../core/ui/icon.js";
import { Config } from "../../config.js";
import sourceIcon from "./source.svg.js";
Config.prototype.beautifyHTML = !IS_IE;
Config.prototype.sourceEditor = 'ace';
Config.prototype.sourceEditorNativeOptions = {
/**
* Show gutter
*/
showGutter: true,
/**
* Default theme
*/
theme: 'ace/theme/idle_fingers',
/**
* Default mode
*/
mode: 'ace/mode/html',
/**
* Wrap lines. Possible values - "off", 80-100..., true, "free"
*/
wrap: true,
/**
* Highlight active line
*/
highlightActiveLine: true
};
Config.prototype.sourceEditorCDNUrlsJS = [
'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.2/ace.js'
];
Config.prototype.beautifyHTMLCDNUrlsJS = [
'https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.4/beautify.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.4/beautify-html.min.js'
];
Icon.set('source', sourceIcon);
Config.prototype.controls.source = {
mode: MODE_SPLIT,
exec: (editor) => {
editor.toggleMode();
},
isActive: (editor) => {
return editor.getRealMode() === MODE_SOURCE;
},
tooltip: 'Change mode'
};

View File

@@ -0,0 +1,40 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/source
*/
import type { IJodit, ISourceEditor } from "../../../../types/index";
import { SourceEditor } from "../sourceEditor";
export declare class AceEditor extends SourceEditor<AceAjax.Editor> implements ISourceEditor {
className: string;
private aceExists;
/**
* Proxy Method
*/
private proxyOnBlur;
private proxyOnFocus;
private proxyOnMouseDown;
private getLastColumnIndex;
private getLastColumnIndices;
private getRowColumnIndices;
private setSelectionRangeIndices;
private getIndexByRowColumn;
init(editor: IJodit): any;
destruct(): any;
setValue(value: string): void;
getValue(): string;
setReadOnly(isReadOnly: boolean): void;
get isFocused(): boolean;
focus(): void;
blur(): void;
getSelectionStart(): number;
getSelectionEnd(): number;
selectAll(): void;
insertRaw(html: string): void;
setSelectionRange(start: number, end: number): void;
setPlaceHolder(title: string): void;
replaceUndoManager(): void;
}

View File

@@ -0,0 +1,220 @@
/*!
* 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 * as constants from "../../../../core/constants.js";
import { isString, loadNext } from "../../../../core/helpers/index.js";
import { SourceEditor } from "../sourceEditor.js";
export class AceEditor extends SourceEditor {
constructor() {
super(...arguments);
this.className = 'jodit_ace_editor';
/**
* Proxy Method
*/
this.proxyOnBlur = (e) => {
this.j.e.fire('blur', e);
};
this.proxyOnFocus = (e) => {
this.j.e.fire('focus', e);
};
this.proxyOnMouseDown = (e) => {
this.j.e.fire('mousedown', e);
};
}
aceExists() {
return this.j.ow.ace !== undefined;
}
getLastColumnIndex(row) {
return this.instance.session.getLine(row).length;
}
getLastColumnIndices() {
const rows = this.instance.session.getLength();
const lastColumnIndices = [];
let lastColIndex = 0;
for (let i = 0; i < rows; i++) {
lastColIndex += this.getLastColumnIndex(i);
if (i > 0) {
lastColIndex += 1;
}
lastColumnIndices[i] = lastColIndex;
}
return lastColumnIndices;
}
getRowColumnIndices(characterIndex) {
const lastColumnIndices = this.getLastColumnIndices();
if (characterIndex <= lastColumnIndices[0]) {
return { row: 0, column: characterIndex };
}
let row = 1;
for (let i = 1; i < lastColumnIndices.length; i++) {
if (characterIndex > lastColumnIndices[i]) {
row = i + 1;
}
}
const column = characterIndex - lastColumnIndices[row - 1] - 1;
return { row, column };
}
setSelectionRangeIndices(start, end) {
const startRowColumn = this.getRowColumnIndices(start);
const endRowColumn = this.getRowColumnIndices(end);
this.instance.getSelection().setSelectionRange({
start: startRowColumn,
end: endRowColumn
});
}
getIndexByRowColumn(row, column) {
const lastColumnIndices = this.getLastColumnIndices();
return lastColumnIndices[row] - this.getLastColumnIndex(row) + column;
}
init(editor) {
const tryInitAceEditor = () => {
if (this.instance !== undefined || !this.aceExists()) {
return;
}
const fakeMirror = this.j.c.div('jodit-source__mirror-fake');
this.container.appendChild(fakeMirror);
const ace = editor.ow.ace;
this.instance = ace.edit(fakeMirror);
if (editor.o.direction === 'rtl') {
this.instance.setOption('rtlText', true);
this.instance.setOption('rtl', true);
}
this.instance.setTheme(editor.o.sourceEditorNativeOptions.theme);
this.instance.renderer.setShowGutter(editor.o.sourceEditorNativeOptions.showGutter);
this.instance
.getSession()
.setMode(editor.o.sourceEditorNativeOptions.mode);
this.instance.setHighlightActiveLine(editor.o.sourceEditorNativeOptions.highlightActiveLine);
this.instance.getSession().setUseWrapMode(true);
this.instance.setOption('indentedSoftWrap', false);
this.instance.setOption('wrap', editor.o.sourceEditorNativeOptions.wrap);
this.instance.getSession().setUseWorker(false);
this.instance.$blockScrolling = Infinity;
this.instance.on('change', this.toWYSIWYG);
this.instance.on('focus', this.proxyOnFocus);
this.instance.on('mousedown', this.proxyOnMouseDown);
this.instance.on('blur', this.proxyOnBlur);
if (editor.getRealMode() !== constants.MODE_WYSIWYG) {
this.setValue(this.getValue());
}
const onResize = this.j.async.throttle(() => {
if (editor.isInDestruct ||
editor.getMode() === constants.MODE_WYSIWYG) {
return;
}
const hasFocus = this.instance.isFocused();
if (editor.o.height !== 'auto') {
this.instance.setOption('maxLines', editor.workplace.offsetHeight /
this.instance.renderer.lineHeight);
}
else {
this.instance.setOption('maxLines', Infinity);
}
this.instance.resize();
hasFocus && this.focus();
}, this.j.defaultTimeout * 2);
editor.e
.on(editor, 'resize', onResize)
.on('afterResize afterSetMode', onResize);
onResize();
this.onReady();
};
editor.e.on('afterSetMode', () => {
if (editor.getRealMode() !== constants.MODE_SOURCE &&
editor.getMode() !== constants.MODE_SPLIT) {
return;
}
this.fromWYSIWYG();
tryInitAceEditor();
});
tryInitAceEditor();
// global add ace editor in browser
if (!this.aceExists()) {
loadNext(editor, editor.o.sourceEditorCDNUrlsJS)
.then(() => {
if (!editor.isInDestruct) {
tryInitAceEditor();
}
})
.catch(() => null);
}
}
destruct() {
var _a, _b;
this.instance.off('change', this.toWYSIWYG);
this.instance.off('focus', this.proxyOnFocus);
this.instance.off('mousedown', this.proxyOnMouseDown);
this.instance.destroy();
(_b = (_a = this.j) === null || _a === void 0 ? void 0 : _a.events) === null || _b === void 0 ? void 0 : _b.off('aceInited.source');
}
setValue(value) {
if (!this.j.o.editHTMLDocumentMode && this.j.o.beautifyHTML) {
const html = this.j.e.fire('beautifyHTML', value);
if (isString(html)) {
value = html;
}
}
this.instance.setValue(value);
this.instance.clearSelection();
}
getValue() {
return this.instance.getValue();
}
setReadOnly(isReadOnly) {
this.instance.setReadOnly(isReadOnly);
}
get isFocused() {
return this.instance.isFocused();
}
focus() {
this.instance.container.focus();
this.instance.focus();
}
blur() {
this.instance.blur();
}
getSelectionStart() {
const range = this.instance.selection.getRange();
return this.getIndexByRowColumn(range.start.row, range.start.column);
}
getSelectionEnd() {
const range = this.instance.selection.getRange();
return this.getIndexByRowColumn(range.end.row, range.end.column);
}
selectAll() {
this.instance.selection.selectAll();
}
insertRaw(html) {
const start = this.instance.selection.getCursor(), end = this.instance.session.insert(start, html);
this.instance.selection.setRange({
start,
end
}, false);
}
setSelectionRange(start, end) {
this.setSelectionRangeIndices(start, end);
}
setPlaceHolder(title) {
// ACE does not support placeholder
// title
}
replaceUndoManager() {
const { history } = this.jodit;
this.instance.commands.addCommand({
name: 'Undo',
bindKey: { win: 'Ctrl-Z', mac: 'Command-Z' },
exec: () => {
history.undo();
}
});
this.instance.commands.addCommand({
name: 'Redo',
bindKey: { win: 'Ctrl-Shift-Z', mac: 'Command-Shift-Z' },
exec: () => {
history.redo();
}
});
}
}

View File

@@ -0,0 +1,28 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/source
*/
import type { IJodit, ISourceEditor } from "../../../../types/index";
import { SourceEditor } from "../sourceEditor";
export declare class TextAreaEditor extends SourceEditor<HTMLTextAreaElement> implements ISourceEditor {
private autosize;
init(editor: IJodit): any;
destruct(): any;
getValue(): string;
setValue(raw: string): void;
insertRaw(raw: string): void;
getSelectionStart(): number;
getSelectionEnd(): number;
setSelectionRange(start: number, end?: number): void;
get isFocused(): boolean;
focus(): void;
blur(): void;
setPlaceHolder(title: string): void;
setReadOnly(isReadOnly: boolean): void;
selectAll(): void;
replaceUndoManager(): void;
}

View File

@@ -0,0 +1,104 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { Dom } from "../../../../core/dom/dom.js";
import { css } from "../../../../core/helpers/utils/css.js";
import { SourceEditor } from "../sourceEditor.js";
export class TextAreaEditor extends SourceEditor {
constructor() {
super(...arguments);
this.autosize = this.j.async.debounce(() => {
this.instance.style.height = 'auto';
this.instance.style.height = this.instance.scrollHeight + 'px';
}, this.j.defaultTimeout);
}
init(editor) {
this.instance = editor.c.element('textarea', {
class: 'jodit-source__mirror',
dir: editor.o.direction === 'rtl' ? 'rtl' : undefined
});
this.container.appendChild(this.instance);
editor.e
.on(this.instance, 'mousedown keydown touchstart input', editor.async.debounce(this.toWYSIWYG, editor.defaultTimeout))
.on('setMinHeight.source', (minHeightD) => {
css(this.instance, 'minHeight', minHeightD);
})
.on(this.instance, 'change keydown mousedown touchstart input', this.autosize)
.on('afterSetMode.source', this.autosize)
.on(this.instance, 'mousedown focus', (e) => {
editor.e.fire(e.type, e);
});
this.autosize();
this.onReady();
}
destruct() {
Dom.safeRemove(this.instance);
}
getValue() {
return this.instance.value;
}
setValue(raw) {
this.instance.value = raw;
}
insertRaw(raw) {
const value = this.getValue();
if (this.getSelectionStart() >= 0) {
const startPos = this.getSelectionStart(), endPos = this.getSelectionEnd();
this.setValue(value.substring(0, startPos) +
raw +
value.substring(endPos, value.length));
}
else {
this.setValue(value + raw);
}
}
getSelectionStart() {
return this.instance.selectionStart;
}
getSelectionEnd() {
return this.instance.selectionEnd;
}
setSelectionRange(start, end = start) {
this.instance.setSelectionRange(start, end);
}
get isFocused() {
return this.instance === this.j.od.activeElement;
}
focus() {
this.instance.focus();
}
blur() {
this.instance.blur();
}
setPlaceHolder(title) {
this.instance.setAttribute('placeholder', title);
}
setReadOnly(isReadOnly) {
if (isReadOnly) {
this.instance.setAttribute('readonly', 'true');
}
else {
this.instance.removeAttribute('readonly');
}
}
selectAll() {
this.instance.select();
}
replaceUndoManager() {
const { history } = this.jodit;
this.j.e.on(this.instance, 'keydown', (e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'z') {
if (e.shiftKey) {
history.redo();
}
else {
history.undo();
}
this.setSelectionRange(this.getValue().length);
return false;
}
});
}
}

View File

@@ -0,0 +1,10 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/source
*/
export * from "./ace";
export * from "./area";

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 plugins/source
*/
export * from "./ace.js";
export * from "./area.js";
// export * from "./custom"; // You can add here another source editor

View File

@@ -0,0 +1,10 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/source
*/
import type { CallbackFunction, IJodit, ISourceEditor } from "../../../types/index";
export declare function createSourceEditor(type: 'ace' | 'mirror' | 'area' | ((jodit: IJodit) => ISourceEditor), editor: IJodit, container: HTMLElement, toWYSIWYG: CallbackFunction, fromWYSIWYG: CallbackFunction): ISourceEditor;

View File

@@ -0,0 +1,29 @@
/*!
* 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 } from "../../../core/helpers/index.js";
import { AceEditor, TextAreaEditor } from "./engines/index.js";
export function createSourceEditor(type, editor, container, toWYSIWYG, fromWYSIWYG) {
let sourceEditor;
if (isFunction(type)) {
sourceEditor = type(editor);
}
else {
switch (type) {
case 'ace':
if (!editor.o.shadowRoot) {
sourceEditor = new AceEditor(editor, container, toWYSIWYG, fromWYSIWYG);
break;
}
default:
sourceEditor = new TextAreaEditor(editor, container, toWYSIWYG, fromWYSIWYG);
}
}
sourceEditor.init(editor);
sourceEditor.onReadyAlways(() => {
sourceEditor.setReadOnly(editor.o.readonly);
});
return sourceEditor;
}

View File

@@ -0,0 +1,27 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/source
*/
import type { CallbackFunction, IJodit } from "../../../types/index";
export declare abstract class SourceEditor<T> {
readonly jodit: IJodit;
readonly container: HTMLElement;
readonly toWYSIWYG: CallbackFunction;
readonly fromWYSIWYG: CallbackFunction;
instance: T;
className: string;
constructor(jodit: IJodit, container: HTMLElement, toWYSIWYG: CallbackFunction, fromWYSIWYG: CallbackFunction);
/**
* Short alias for this.jodit
*/
get j(): this['jodit'];
abstract init(editor: IJodit): void;
abstract replaceUndoManager(): void;
isReady: boolean;
protected onReady(): void;
onReadyAlways(onReady: CallbackFunction): void;
}

View File

@@ -0,0 +1,35 @@
/*!
* 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 SourceEditor {
constructor(jodit, container, toWYSIWYG, fromWYSIWYG) {
this.jodit = jodit;
this.container = container;
this.toWYSIWYG = toWYSIWYG;
this.fromWYSIWYG = fromWYSIWYG;
this.className = '';
this.isReady = false;
}
/**
* Short alias for this.jodit
*/
get j() {
return this.jodit;
}
onReady() {
this.replaceUndoManager();
this.isReady = true;
this.j.e.fire(this, 'ready');
}
onReadyAlways(onReady) {
var _a;
if (!this.isReady) {
(_a = this.j.events) === null || _a === void 0 ? void 0 : _a.on(this, 'ready', onReady);
}
else {
onReady();
}
}
}

55
node_modules/jodit/esm/plugins/source/source.d.ts generated vendored Normal file
View File

@@ -0,0 +1,55 @@
/*!
* 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:plugins/source/README.md]]
* @packageDocumentation
* @module plugins/source
*/
import type { IJodit, ISourceEditor } from "../../types/index";
import { Plugin } from "../../core/plugin/index";
import "./config";
/**
* Plug-in change simple textarea on CodeMirror editor in Source code mode
*/
export declare class source extends Plugin {
/** @override */
buttons: Plugin['buttons'];
sourceEditor?: ISourceEditor;
private mirrorContainer;
private __lock;
private __oldMirrorValue;
private tempMarkerStart;
private tempMarkerStartReg;
private tempMarkerEnd;
private tempMarkerEndReg;
protected onInsertHTML(html: string): void | false;
/**
* Update source editor from WYSIWYG area
*/
private fromWYSIWYG;
/**
* Update WYSIWYG area from source editor
*/
private toWYSIWYG;
private getNormalPosition;
private clnInv;
protected onSelectAll(command: string): void | false;
private getSelectionStart;
private getSelectionEnd;
private getMirrorValue;
private setMirrorValue;
private setFocusToMirror;
protected saveSelection(): void;
protected removeSelection(): void;
private setMirrorSelectionRange;
private onReadonlyReact;
/** @override */
afterInit(editor: IJodit): void;
private syncValueFromWYSIWYG;
private initSourceEditor;
/** @override */
beforeDestruct(): void;
}

327
node_modules/jodit/esm/plugins/source/source.js generated vendored Normal file
View File

@@ -0,0 +1,327 @@
/*!
* 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 { INVISIBLE_SPACE, KEY_ESC, MODE_SOURCE, MODE_SPLIT, SOURCE_CONSUMER } from "../../core/constants.js";
import { autobind, watch } from "../../core/decorators/index.js";
import { Dom } from "../../core/dom/dom.js";
import { pluginSystem } from "../../core/global.js";
import { isString, loadNext } from "../../core/helpers/index.js";
import { Plugin } from "../../core/plugin/index.js";
import "./config.js";
import { createSourceEditor } from "./editor/factory.js";
/**
* Plug-in change simple textarea on CodeMirror editor in Source code mode
*/
export class source extends Plugin {
constructor() {
super(...arguments);
/** @override */
this.buttons = [
{
name: 'source',
group: 'source'
}
];
this.__lock = false;
this.__oldMirrorValue = '';
this.tempMarkerStart = '{start-jodit-selection}';
this.tempMarkerStartReg = /{start-jodit-selection}/g;
this.tempMarkerEnd = '{end-jodit-selection}';
this.tempMarkerEndReg = /{end-jodit-selection}/g;
// override it for ace editors
this.getSelectionStart = () => {
var _a, _b;
return (_b = (_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.getSelectionStart()) !== null && _b !== void 0 ? _b : 0;
};
this.getSelectionEnd = () => {
var _a, _b;
return (_b = (_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.getSelectionEnd()) !== null && _b !== void 0 ? _b : 0;
};
}
onInsertHTML(html) {
var _a;
if (!this.j.o.readonly && !this.j.isEditorMode()) {
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.insertRaw(html);
this.toWYSIWYG();
return false;
}
}
/**
* Update source editor from WYSIWYG area
*/
fromWYSIWYG(force = false) {
if (!this.__lock || force === true) {
this.__lock = true;
const new_value = this.j.getEditorValue(false, SOURCE_CONSUMER);
if (new_value !== this.getMirrorValue()) {
this.setMirrorValue(new_value);
}
this.__lock = false;
}
}
/**
* Update WYSIWYG area from source editor
*/
toWYSIWYG() {
if (this.__lock) {
return;
}
const value = this.getMirrorValue();
if (value === this.__oldMirrorValue) {
return;
}
this.__lock = true;
this.j.value = value;
this.__lock = false;
this.__oldMirrorValue = value;
}
getNormalPosition(pos, str) {
str = str.replace(/<(script|style|iframe)[^>]*>[^]*?<\/\1>/im, m => {
let res = '';
for (let i = 0; i < m.length; i += 1) {
res += INVISIBLE_SPACE;
}
return res;
});
while (pos > 0 && str[pos] === INVISIBLE_SPACE) {
pos--;
}
let start = pos;
while (start > 0) {
start--;
if (str[start] === '<' &&
str[start + 1] !== undefined &&
str[start + 1].match(/[\w/]+/i)) {
return start;
}
if (str[start] === '>') {
return pos;
}
}
return pos;
}
clnInv(str) {
return str.replace(consts.INVISIBLE_SPACE_REG_EXP(), '');
}
onSelectAll(command) {
var _a;
if (command.toLowerCase() === 'selectall' &&
this.j.getRealMode() === MODE_SOURCE) {
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.selectAll();
return false;
}
}
getMirrorValue() {
var _a;
return ((_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.getValue()) || '';
}
setMirrorValue(value) {
var _a;
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.setValue(value);
}
setFocusToMirror() {
var _a;
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.focus();
}
saveSelection() {
if (this.j.getRealMode() === consts.MODE_WYSIWYG) {
this.j.s.save();
this.j.synchronizeValues();
this.fromWYSIWYG(true);
}
else {
if (this.j.o.editHTMLDocumentMode) {
return;
}
const value = this.getMirrorValue();
if (this.getSelectionStart() === this.getSelectionEnd()) {
const marker = this.j.s.marker(true);
const selectionStart = this.getNormalPosition(this.getSelectionStart(), this.getMirrorValue());
this.setMirrorValue(value.substring(0, selectionStart) +
this.clnInv(marker.outerHTML) +
value.substring(selectionStart));
}
else {
const markerStart = this.j.s.marker(true);
const markerEnd = this.j.s.marker(false);
const selectionStart = this.getNormalPosition(this.getSelectionStart(), value);
const selectionEnd = this.getNormalPosition(this.getSelectionEnd(), value);
this.setMirrorValue(value.slice(0, selectionStart) +
this.clnInv(markerStart.outerHTML) +
value.slice(selectionStart, selectionEnd) +
this.clnInv(markerEnd.outerHTML) +
value.slice(selectionEnd));
}
this.toWYSIWYG();
}
}
removeSelection() {
if (this.j.getRealMode() === consts.MODE_WYSIWYG) {
this.__lock = true;
this.j.s.restore();
this.__lock = false;
return;
}
let value = this.getMirrorValue();
let selectionStart = 0, selectionEnd = 0;
try {
value = value
.replace(/<span[^>]+data-jodit-selection_marker=(["'])start\1[^>]*>[<>]*?<\/span>/gim, this.tempMarkerStart)
.replace(/<span[^>]+data-jodit-selection_marker=(["'])end\1[^>]*>[<>]*?<\/span>/gim, this.tempMarkerEnd);
if (!this.j.o.editHTMLDocumentMode && this.j.o.beautifyHTML) {
const html = this.j.e.fire('beautifyHTML', value);
if (isString(html)) {
value = html;
}
}
selectionStart = value.indexOf(this.tempMarkerStart);
selectionEnd = selectionStart;
value = value.replace(this.tempMarkerStartReg, '');
if (selectionStart !== -1) {
const selectionEndCursor = value.indexOf(this.tempMarkerEnd);
if (selectionEndCursor !== -1) {
selectionEnd = selectionEndCursor;
}
}
value = value.replace(this.tempMarkerEndReg, '');
}
finally {
value = value
.replace(this.tempMarkerEndReg, '')
.replace(this.tempMarkerStartReg, '');
}
this.setMirrorValue(value);
this.setMirrorSelectionRange(selectionStart, selectionEnd);
this.toWYSIWYG();
this.setFocusToMirror(); // need for setting focus after change mode
}
setMirrorSelectionRange(start, end) {
var _a;
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
}
onReadonlyReact() {
var _a;
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.setReadOnly(this.j.o.readonly);
}
/** @override */
afterInit(editor) {
this.mirrorContainer = editor.c.div('jodit-source');
editor.workplace.appendChild(this.mirrorContainer);
editor.e.on('afterAddPlace changePlace afterInit', () => {
editor.workplace.appendChild(this.mirrorContainer);
});
this.sourceEditor = createSourceEditor('area', editor, this.mirrorContainer, this.toWYSIWYG, this.fromWYSIWYG);
editor.e.on(editor.ow, 'keydown', (e) => {
var _a;
if (e.key === KEY_ESC && ((_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.isFocused)) {
this.sourceEditor.blur();
}
});
this.onReadonlyReact();
editor.e
.on('placeholder.source', (text) => {
var _a;
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.setPlaceHolder(text);
})
.on('change.source', this.syncValueFromWYSIWYG)
.on('beautifyHTML', html => html);
if (editor.o.beautifyHTML) {
const addEventListener = () => {
var _a;
if (editor.isInDestruct) {
return false;
}
const html_beautify = editor.ow.html_beautify;
if (html_beautify && !editor.isInDestruct) {
(_a = editor.events) === null || _a === void 0 ? void 0 : _a.off('beautifyHTML').on('beautifyHTML', html => html_beautify(html));
return true;
}
return false;
};
if (!addEventListener()) {
loadNext(editor, editor.o.beautifyHTMLCDNUrlsJS).then(addEventListener, () => null);
}
}
this.syncValueFromWYSIWYG(true);
this.initSourceEditor(editor);
}
syncValueFromWYSIWYG(force = false) {
const editor = this.j;
if (editor.getMode() === MODE_SPLIT ||
editor.getMode() === MODE_SOURCE) {
this.fromWYSIWYG(force);
}
}
initSourceEditor(editor) {
var _a;
if (editor.o.sourceEditor !== 'area') {
const sourceEditor = createSourceEditor(editor.o.sourceEditor, editor, this.mirrorContainer, this.toWYSIWYG, this.fromWYSIWYG);
sourceEditor.onReadyAlways(() => {
var _a, _b;
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.destruct();
this.sourceEditor = sourceEditor;
this.syncValueFromWYSIWYG(true);
(_b = editor.events) === null || _b === void 0 ? void 0 : _b.fire('sourceEditorReady', editor);
});
}
else {
(_a = this.sourceEditor) === null || _a === void 0 ? void 0 : _a.onReadyAlways(() => {
var _a;
this.syncValueFromWYSIWYG(true);
(_a = editor.events) === null || _a === void 0 ? void 0 : _a.fire('sourceEditorReady', editor);
});
}
}
/** @override */
beforeDestruct() {
if (this.sourceEditor) {
this.sourceEditor.destruct();
delete this.sourceEditor;
}
Dom.safeRemove(this.mirrorContainer);
}
}
__decorate([
watch(':insertHTML.source')
], source.prototype, "onInsertHTML", null);
__decorate([
autobind
], source.prototype, "fromWYSIWYG", null);
__decorate([
autobind
], source.prototype, "toWYSIWYG", null);
__decorate([
autobind
], source.prototype, "getNormalPosition", null);
__decorate([
watch(':beforeCommand.source')
], source.prototype, "onSelectAll", null);
__decorate([
watch(':beforeSetMode.source')
], source.prototype, "saveSelection", null);
__decorate([
watch(':afterSetMode.source')
], source.prototype, "removeSelection", null);
__decorate([
autobind
], source.prototype, "setMirrorSelectionRange", null);
__decorate([
watch(':readonly.source')
], source.prototype, "onReadonlyReact", null);
__decorate([
autobind
], source.prototype, "syncValueFromWYSIWYG", null);
pluginSystem.add('source', source);

1
node_modules/jodit/esm/plugins/source/source.svg.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 1792 1792\"> <path d=\"M553 1399l-50 50q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l466-466q10-10 23-10t23 10l50 50q10 10 10 23t-10 23l-393 393 393 393q10 10 10 23t-10 23zm591-1067l-373 1291q-4 13-15.5 19.5t-23.5 2.5l-62-17q-13-4-19.5-15.5t-2.5-24.5l373-1291q4-13 15.5-19.5t23.5-2.5l62 17q13 4 19.5 15.5t2.5 24.5zm657 651l-466 466q-10 10-23 10t-23-10l-50-50q-10-10-10-23t10-23l393-393-393-393q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l466 466q10 10 10 23t-10 23z\"/> </svg> ";