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,18 @@
/*!
* 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/inline-popup
*/
import type { IControlType, IDictionary, IJodit } from "../../../types/index";
declare module 'jodit/config' {
interface Config {
popup: IDictionary<Array<IControlType | string> | ((editor: IJodit, target: HTMLElement | undefined, close: () => void) => Array<IControlType | string> | HTMLElement | string)>;
toolbarInlineDisabledButtons: string[];
toolbarInline: boolean;
toolbarInlineForSelection: boolean;
toolbarInlineDisableFor: string | string[];
}
}

View File

@@ -0,0 +1,57 @@
/*!
* 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 { Icon } from "../../../core/ui/icon.js";
import { Config } from "../../../config.js";
import a from "./items/a.js";
import cells from "./items/cells.js";
import jodit from "./items/iframe.js";
import img from "./items/img.js";
import toolbar from "./items/toolbar.js";
import * as addcolumn from "../icons/addcolumn.svg.js";
import * as addrow from "../icons/addrow.svg.js";
import * as merge from "../icons/merge.svg.js";
import * as splitg from "../icons/splitg.svg.js";
import * as splitv from "../icons/splitv.svg.js";
import * as th from "../icons/th.svg.js";
import * as thList from "../icons/th-list.svg.js";
Config.prototype.toolbarInline = true;
Config.prototype.toolbarInlineForSelection = false;
Config.prototype.toolbarInlineDisableFor = [];
Config.prototype.toolbarInlineDisabledButtons = ['source'];
Icon.set('addcolumn', addcolumn.default)
.set('addrow', addrow.default)
.set('merge', merge.default)
.set('th', th.default)
.set('splitg', splitg.default)
.set('splitv', splitv.default)
.set('th-list', thList.default);
Config.prototype.popup = {
a,
img,
cells,
toolbar,
jodit,
iframe: jodit,
'jodit-media': jodit,
selection: [
'bold',
'underline',
'italic',
'ul',
'ol',
'\n',
'outdent',
'indent',
'fontsize',
'brush',
'cut',
'\n',
'paragraph',
'link',
'align',
'dots'
]
};

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/inline-popup
*/
import type { IControlType } from "../../../../types/index";
declare const _default: Array<IControlType | string>;
export default _default;

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
*/
import { attr } from "../../../../core/helpers/utils/attr.js";
export default [
{
name: 'eye',
tooltip: 'Open link',
exec: (editor, current) => {
const href = attr(current, 'href');
if (current && href) {
editor.ow.open(href);
}
}
},
{
name: 'link',
tooltip: 'Edit link',
icon: 'pencil'
},
'unlink',
'brush',
'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 plugins/inline-popup
*/
import type { IControlType } from "../../../../types/index";
declare const _default: Array<IControlType | string>;
export default _default;

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 { isJoditObject, isString } from "../../../../core/helpers/checker/index.js";
import { css } from "../../../../core/helpers/utils/css.js";
const cmd = (control) => control.args && isString(control.args[0])
? control.args[0].toLowerCase()
: '';
export default [
'brushCell',
{
name: 'valign',
list: ['Top', 'Middle', 'Bottom', 'Normal'],
childTemplate: (_, __, value) => value,
exec: (editor, table, { control }) => {
const command = cmd(control);
editor
.getInstance('Table', editor.o)
.getAllSelectedCells()
.forEach((cell) => {
css(cell, 'vertical-align', command === 'normal' ? '' : command);
});
},
tooltip: 'Vertical align'
},
{
name: 'splitv',
list: {
tablesplitv: 'Split vertical',
tablesplitg: 'Split horizontal'
},
tooltip: 'Split'
},
{
name: 'align',
icon: 'left'
},
'\n',
{
name: 'merge',
command: 'tablemerge',
tooltip: 'Merge'
},
{
name: 'addcolumn',
list: {
tableaddcolumnbefore: 'Insert column before',
tableaddcolumnafter: 'Insert column after'
},
exec: (editor, table, { control }) => {
if (!isJoditObject(editor)) {
return;
}
if (!control.args) {
return false;
}
const command = cmd(control);
editor.execCommand(command, false, table);
},
tooltip: 'Add column'
},
{
name: 'addrow',
list: {
tableaddrowbefore: 'Insert row above',
tableaddrowafter: 'Insert row below'
},
exec: (editor, table, { control }) => {
if (!isJoditObject(editor)) {
return;
}
if (!control.args) {
return false;
}
const command = cmd(control);
editor.execCommand(command, false, table);
},
tooltip: 'Add row'
},
{
name: 'delete',
icon: 'bin',
list: {
tablebin: 'Delete table',
tablebinrow: 'Delete row',
tablebincolumn: 'Delete column',
tableempty: 'Empty cell'
},
exec: (editor, table, { control }) => {
if (!isJoditObject(editor)) {
return;
}
if (!control.args) {
return false;
}
const command = cmd(control);
editor.execCommand(command, false, table);
editor.e.fire('hidePopup');
},
tooltip: 'Delete'
}
];

View File

@@ -0,0 +1,15 @@
/*!
* 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/inline-popup
*/
import type { IJodit } from "../../../../types/index";
declare const _default: (import("../../../../types/index").IControlType<IJodit, import("../../../../types/index").IToolbarButton> | {
name: string;
tooltip: string;
exec: (editor: IJodit, image: HTMLImageElement) => void;
})[];
export default _default;

View File

@@ -0,0 +1,16 @@
/*!
* 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 { align } from "./img.js";
export default [
{
name: 'bin',
tooltip: 'Delete',
exec: (editor, image) => {
image && editor.s.removeNode(image);
}
},
align
];

View File

@@ -0,0 +1,12 @@
/*!
* 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/inline-popup
*/
import type { IControlType, IJodit } from "../../../../types/index";
export declare const align: IControlType<IJodit>;
declare const _default: Array<IControlType | string>;
export default _default;

View File

@@ -0,0 +1,72 @@
/*!
* 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/index.js";
import { isString } from "../../../../core/helpers/checker/is-string.js";
import { hAlignElement } from "../../../../core/helpers/utils/align.js";
import { css } from "../../../../core/helpers/utils/css.js";
export const align = {
name: 'left',
childTemplate: (_, __, value) => value,
list: ['Left', 'Right', 'Center', 'Normal'],
exec: (editor, elm, { control }) => {
if (!Dom.isTag(elm, new Set(['img', 'jodit', 'jodit-media']))) {
return;
}
const command = control.args && isString(control.args[0])
? control.args[0].toLowerCase()
: '';
if (!command) {
return false;
}
hAlignElement(elm, command);
if (Dom.isTag(elm, new Set(['jodit', 'jodit-media'])) &&
elm.firstElementChild) {
hAlignElement(elm.firstElementChild, command);
}
editor.synchronizeValues();
editor.e.fire('recalcPositionPopup');
},
tooltip: 'Horizontal align'
};
export default [
{
name: 'delete',
icon: 'bin',
tooltip: 'Delete',
exec: (editor, image) => {
image && editor.s.removeNode(image);
}
},
{
name: 'pencil',
exec(editor, current) {
const tagName = current.tagName.toLowerCase();
if (tagName === 'img') {
editor.e.fire('openImageProperties', current);
}
},
tooltip: 'Edit'
},
{
name: 'valign',
list: ['Top', 'Middle', 'Bottom', 'Normal'],
tooltip: 'Vertical align',
exec: (editor, image, { control }) => {
if (!Dom.isTag(image, 'img')) {
return;
}
const command = control.args && isString(control.args[0])
? control.args[0].toLowerCase()
: '';
if (!command) {
return false;
}
css(image, 'vertical-align', command === 'normal' ? '' : command);
editor.e.fire('recalcPositionPopup');
}
},
align
];

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/inline-popup
*/
declare const _default: string[];
export default _default;

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
*/
/**
* @module plugins/inline-popup
*/
export default [
'bold',
'italic',
'|',
'ul',
'ol',
'eraser',
'|',
'fontsize',
'brush',
'paragraph',
'---',
'image',
'table',
'\n',
'link',
'|',
'align',
'|',
'undo',
'redo',
'|',
'copyformat',
'fullsize',
'---',
'dots'
];

View File

@@ -0,0 +1 @@
export default "<svg viewBox=\"0 0 18.151 18.151\" xmlns=\"http://www.w3.org/2000/svg\"> <g> <path stroke-width=\"0\" d=\"M6.237,16.546H3.649V1.604h5.916v5.728c0.474-0.122,0.968-0.194,1.479-0.194 c0.042,0,0.083,0.006,0.125,0.006V0H2.044v18.15h5.934C7.295,17.736,6.704,17.19,6.237,16.546z\"/> <path stroke-width=\"0\" d=\"M11.169,8.275c-2.723,0-4.938,2.215-4.938,4.938s2.215,4.938,4.938,4.938s4.938-2.215,4.938-4.938 S13.892,8.275,11.169,8.275z M11.169,16.81c-1.983,0-3.598-1.612-3.598-3.598c0-1.983,1.614-3.597,3.598-3.597 s3.597,1.613,3.597,3.597C14.766,15.198,13.153,16.81,11.169,16.81z\"/> <polygon stroke-width=\"0\" points=\"11.792,11.073 10.502,11.073 10.502,12.578 9.03,12.578 9.03,13.868 10.502,13.868 10.502,15.352 11.792,15.352 11.792,13.868 13.309,13.868 13.309,12.578 11.792,12.578 \"/> </g> </svg> ";

View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 432 432\"> <g> <polygon points=\"203.688,96 0,96 0,144 155.688,144 \"/> <polygon points=\"155.719,288 0,288 0,336 203.719,336 \"/> <path d=\"M97.844,230.125c-3.701-3.703-5.856-8.906-5.856-14.141s2.154-10.438,5.856-14.141l9.844-9.844H0v48h107.719 L97.844,230.125z\"/> <polygon points=\"232,176 232,96 112,216 232,336 232,256 432,256 432,176\"/> </g> </svg> ";

View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 312 312\"> <g transform=\"translate(0.000000,312.000000) scale(0.100000,-0.100000)\" stroke=\"none\"> <path d=\"M50 3109 c0 -7 -11 -22 -25 -35 l-25 -23 0 -961 0 -961 32 -29 32 -30 501 -2 500 -3 3 -502 2 -502 31 -30 31 -31 958 0 958 0 23 25 c13 13 30 25 37 25 9 0 12 199 12 960 0 686 -3 960 -11 960 -6 0 -24 12 -40 28 l-29 27 -503 5 -502 5 -5 502 -5 503 -28 29 c-15 16 -27 34 -27 40 0 8 -274 11 -960 11 -710 0 -960 -3 -960 -11z m1738 -698 l2 -453 -40 -40 c-22 -22 -40 -43 -40 -47 0 -4 36 -42 79 -85 88 -87 82 -87 141 -23 l26 27 455 -2 454 -3 0 -775 0 -775 -775 0 -775 0 -3 450 -2 449 47 48 47 48 -82 80 c-44 44 -84 80 -87 80 -3 0 -25 -18 -48 -40 l-41 -40 -456 2 -455 3 -3 765 c-1 421 0 771 3 778 3 10 164 12 777 10 l773 -3 3 -454z\"/> <path d=\"M607 2492 c-42 -42 -77 -82 -77 -87 0 -6 86 -96 190 -200 105 -104 190 -197 190 -205 0 -8 -41 -56 -92 -107 -65 -65 -87 -94 -77 -98 8 -3 138 -4 289 -3 l275 3 3 275 c1 151 0 281 -3 289 -4 10 -35 -14 -103 -82 -54 -53 -103 -97 -109 -97 -7 0 -99 88 -206 195 -107 107 -196 195 -198 195 -3 0 -39 -35 -82 -78z\"/> <path d=\"M1470 1639 c-47 -49 -87 -91 -89 -94 -5 -6 149 -165 160 -165 9 0 189 179 189 188 0 12 -154 162 -165 161 -6 0 -48 -41 -95 -90z\"/> <path d=\"M1797 1303 c-9 -8 -9 -568 0 -576 4 -4 50 36 103 88 54 52 101 95 106 95 5 0 95 -85 199 -190 104 -104 194 -190 200 -190 6 0 46 36 90 80 l79 79 -197 196 c-108 108 -197 199 -197 203 0 4 45 52 99 106 55 55 98 103 95 108 -6 10 -568 11 -577 1z\"/> </g> </svg> ";

View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 48 48\"> <path d=\"M6 42h4v-4h-4v4zm4-28h-4v4h4v-4zm-4 20h4v-4h-4v4zm8 8h4v-4h-4v4zm-4-36h-4v4h4v-4zm8 0h-4v4h4v-4zm16 0h-4v4h4v-4zm-8 8h-4v4h4v-4zm0-8h-4v4h4v-4zm12 28h4v-4h-4v4zm-16 8h4v-4h-4v4zm-16-16h36v-4h-36v4zm32-20v4h4v-4h-4zm0 12h4v-4h-4v4zm-16 16h4v-4h-4v4zm8 8h4v-4h-4v4zm8 0h4v-4h-4v4z\"/> <path d=\"M0 0h48v48h-48z\" fill=\"none\"/> </svg> ";

View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 48 48\"> <path d=\"M6 18h4v-4h-4v4zm0-8h4v-4h-4v4zm8 32h4v-4h-4v4zm0-16h4v-4h-4v4zm-8 0h4v-4h-4v4zm0 16h4v-4h-4v4zm0-8h4v-4h-4v4zm8-24h4v-4h-4v4zm24 24h4v-4h-4v4zm-16 8h4v-36h-4v36zm16 0h4v-4h-4v4zm0-16h4v-4h-4v4zm0-20v4h4v-4h-4zm0 12h4v-4h-4v4zm-8-8h4v-4h-4v4zm0 32h4v-4h-4v4zm0-16h4v-4h-4v4z\"/> <path d=\"M0 0h48v48h-48z\" fill=\"none\"/> </svg> ";

View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 1792 1792\"> <path d=\"M512 1248v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm1280 512v192q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h960q40 0 68 28t28 68zm-1280-1024v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm1280 512v192q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h960q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h960q40 0 68 28t28 68z\"/> </svg> ";

View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 1792 1792\"> <path d=\"M512 1248v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm640 512v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm-640-1024v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm640 512v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm640 512v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm-640-1024v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm640 512v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-320q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h320q40 0 68 28t28 68z\"/> </svg> ";

View File

@@ -0,0 +1,69 @@
/*!
* 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/inline-popup/README.md]]
* @packageDocumentation
* @module plugins/inline-popup
*/
import type { IJodit } from "../../types/index";
import { Plugin } from "../../core/plugin/index";
import "./config/config";
/**
* Plugin for show inline popup dialog
*/
export declare class inlinePopup extends Plugin {
static requires: string[];
private type;
private get popup();
private get toolbar();
private onClick;
/**
* Show inline popup with some toolbar
*
* @param type - selection, img, a etc.
*/
private showPopup;
private previousTarget?;
/**
* Hide opened popup
*/
private hidePopup;
protected onOutsideClick(): void;
/**
* Can show popup for this type
*/
private canShowPopupForType;
/**
* For some elements do not show popup
*/
private isExcludedTarget;
/** @override **/
protected afterInit(jodit: IJodit): void;
private snapRange;
private onSelectionStart;
private onSelectionEnd;
/**
* Selection change handler
*/
private onSelectionChange;
/**
* In not collapsed selection - only one image
*/
private isSelectedTarget;
/**
* Shortcut for Table module
*/
/** @override **/
protected beforeDestruct(jodit: IJodit): void;
private elmsList;
private _eventsList;
private addListenersForElements;
private removeListenersForElements;
/**
* Show the inline WYSIWYG toolbar editor.
*/
private showInlineToolbar;
}

View File

@@ -0,0 +1,266 @@
/*!
* 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, cache, debounce, wait, watch } from "../../core/decorators/index.js";
import { Dom } from "../../core/dom/index.js";
import { pluginSystem } from "../../core/global.js";
import { camelCase, isArray, isFunction, isString, keys, position, splitArray, toArray } from "../../core/helpers/index.js";
import { Plugin } from "../../core/plugin/index.js";
import { UIElement } from "../../core/ui/index.js";
import { Popup } from "../../core/ui/popup/index.js";
import { makeCollection } from "../../modules/toolbar/factory.js";
import "./config/config.js";
/**
* Plugin for show inline popup dialog
*/
export class inlinePopup extends Plugin {
constructor() {
super(...arguments);
this.type = null;
this.snapRange = null;
this.elmsList = keys(this.j.o.popup, false).filter(s => !this.isExcludedTarget(s));
}
get popup() {
return new Popup(this.jodit, false);
}
get toolbar() {
return makeCollection(this.jodit, this.popup);
}
onClick(node) {
const elements = this.elmsList, target = Dom.isTag(node, 'img')
? node
: Dom.closest(node, elements, this.j.editor);
if (target && this.canShowPopupForType(target.nodeName.toLowerCase())) {
this.showPopup(() => position(target, this.j), target.nodeName.toLowerCase(), target);
return false;
}
}
/**
* Show inline popup with some toolbar
*
* @param type - selection, img, a etc.
*/
showPopup(rect, type, target) {
type = type.toLowerCase();
if (!this.canShowPopupForType(type)) {
return false;
}
if (this.type !== type || target !== this.previousTarget) {
this.previousTarget = target;
const data = this.j.o.popup[type];
let content;
if (isFunction(data)) {
content = data(this.j, target, this.popup.close);
}
else {
content = data;
}
if (isArray(content)) {
this.toolbar.build(content, target);
this.toolbar.buttonSize = this.j.o.toolbarButtonSize;
content = this.toolbar.container;
}
this.popup.setContent(content);
this.type = type;
}
this.popup.open(rect);
return true;
}
/**
* Hide opened popup
*/
hidePopup(type) {
if (this.popup.isOpened && (!isString(type) || type === this.type)) {
this.popup.close();
}
}
onOutsideClick() {
this.popup.close();
}
/**
* Can show popup for this type
*/
canShowPopupForType(type) {
const data = this.j.o.popup[type.toLowerCase()];
if (this.j.o.readonly || !this.j.o.toolbarInline || !data) {
return false;
}
return !this.isExcludedTarget(type);
}
/**
* For some elements do not show popup
*/
isExcludedTarget(type) {
return splitArray(this.j.o.toolbarInlineDisableFor)
.map(a => a.toLowerCase())
.includes(type.toLowerCase());
}
/** @override **/
afterInit(jodit) {
this.j.e
.on('getDiffButtons.mobile', (toolbar) => {
if (this.toolbar === toolbar) {
const names = this.toolbar.getButtonsNames();
return toArray(jodit.registeredButtons)
.filter(btn => !this.j.o.toolbarInlineDisabledButtons.includes(btn.name))
.filter(item => {
const name = isString(item) ? item : item.name;
return (name &&
name !== '|' &&
name !== '\n' &&
!names.includes(name));
});
}
})
.on('hidePopup', this.hidePopup)
.on('showInlineToolbar', this.showInlineToolbar)
.on('showPopup', (elm, rect, type) => {
this.showPopup(rect, type || (isString(elm) ? elm : elm.nodeName), isString(elm) ? undefined : elm);
})
.on('mousedown keydown', this.onSelectionStart)
.on('change', () => {
if (this.popup.isOpened &&
this.previousTarget &&
!this.previousTarget.parentNode) {
this.hidePopup();
this.previousTarget = undefined;
}
})
.on([this.j.ew, this.j.ow], 'mouseup keyup', this.onSelectionEnd);
this.addListenersForElements();
}
onSelectionStart() {
this.snapRange = this.j.s.range.cloneRange();
}
onSelectionEnd(e) {
if (e &&
e.target &&
UIElement.closestElement(e.target, Popup)) {
return;
}
const { snapRange } = this, { range } = this.j.s;
if (!snapRange ||
range.collapsed ||
range.startContainer !== snapRange.startContainer ||
range.startOffset !== snapRange.startOffset ||
range.endContainer !== snapRange.endContainer ||
range.endOffset !== snapRange.endOffset) {
this.onSelectionChange();
}
}
/**
* Selection change handler
*/
onSelectionChange() {
if (!this.j.o.toolbarInlineForSelection) {
return;
}
const type = 'selection';
const sel = this.j.s.sel;
const range = this.j.s.range;
if ((sel === null || sel === void 0 ? void 0 : sel.isCollapsed) || this.isSelectedTarget(range)) {
if (this.type === type && this.popup.isOpened) {
this.hidePopup();
}
return;
}
const node = this.j.s.current();
if (!node) {
return;
}
this.showPopup(() => range.getBoundingClientRect(), type);
}
/**
* In not collapsed selection - only one image
*/
isSelectedTarget(r) {
const sc = r.startContainer;
return (Dom.isElement(sc) &&
sc === r.endContainer &&
Dom.isTag(sc.childNodes[r.startOffset], new Set(keys(this.j.o.popup, false))) &&
r.startOffset === r.endOffset - 1);
}
/**
* Shortcut for Table module
*/
// private get tableModule(): Table {
// return this.j.getInstance<Table>('Table', this.j.o);
// }
/** @override **/
beforeDestruct(jodit) {
jodit.e
.off('showPopup')
.off([this.j.ew, this.j.ow], 'mouseup keyup', this.onSelectionEnd);
this.removeListenersForElements();
}
_eventsList() {
const el = this.elmsList;
return el
.map(e => camelCase(`click_${e}`))
.concat(el.map(e => camelCase(`touchstart_${e}`)))
.join(' ');
}
addListenersForElements() {
this.j.e.on(this._eventsList(), this.onClick);
}
removeListenersForElements() {
this.j.e.off(this._eventsList(), this.onClick);
}
/**
* Show the inline WYSIWYG toolbar editor.
*/
showInlineToolbar(bound) {
this.showPopup(() => {
if (bound) {
return bound;
}
const { range } = this.j.s;
return range.getBoundingClientRect();
}, 'toolbar');
}
}
inlinePopup.requires = ['select'];
__decorate([
cache
], inlinePopup.prototype, "popup", null);
__decorate([
cache
], inlinePopup.prototype, "toolbar", null);
__decorate([
autobind
], inlinePopup.prototype, "onClick", null);
__decorate([
wait((ctx) => !ctx.j.isLocked)
], inlinePopup.prototype, "showPopup", null);
__decorate([
watch([':clickEditor', ':beforeCommandDelete', ':backSpaceAfterDelete']),
autobind
], inlinePopup.prototype, "hidePopup", null);
__decorate([
watch(':outsideClick')
], inlinePopup.prototype, "onOutsideClick", null);
__decorate([
autobind
], inlinePopup.prototype, "onSelectionStart", null);
__decorate([
autobind
], inlinePopup.prototype, "onSelectionEnd", null);
__decorate([
debounce(ctx => ctx.defaultTimeout)
], inlinePopup.prototype, "onSelectionChange", null);
__decorate([
autobind
], inlinePopup.prototype, "showInlineToolbar", null);
pluginSystem.add('inlinePopup', inlinePopup);