Skip to content

Commit

Permalink
Dialogs don't work inside Shadow DOM #866
Browse files Browse the repository at this point in the history
Issue: #866
  • Loading branch information
xdan committed Aug 14, 2022
1 parent 972336d commit 816d1db
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/core/event-emitter/event-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ export class EventEmitter implements IEventEmitter {
return;
}

// for Shadow Dom
if (e.composed && isFunction(e.composedPath) && e.composedPath()[0]) {
Object.defineProperty(e, 'target', {
value: e.composedPath()[0],
configurable: true,
enumerable: true
});
}

if (
event.type.match(/^touch/) &&
(event as TouchEvent).changedTouches &&
Expand Down
8 changes: 2 additions & 6 deletions src/core/ui/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
assert,
attr,
css,
isFunction,
isString,
kebabCase,
markOwner,
Expand Down Expand Up @@ -383,14 +382,11 @@ export class Popup extends UIElement implements IPopup {
}

isOwnClick(e: MouseEvent): boolean {
const target =
(isFunction(e.composedPath) && e.composedPath()[0]) || e.target;

if (!target) {
if (!e.target) {
return false;
}

const box = UIElement.closestElement(target as Node, Popup);
const box = UIElement.closestElement(e.target as Node, Popup);

return Boolean(box && (this === box || box.closest(this)));
}
Expand Down
1 change: 1 addition & 0 deletions src/jodit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ export class Jodit extends Panel implements IJodit {
language: jodit.o.language,
license: jodit.o.license,
theme: jodit.o.theme,
shadowRoot: jodit.o.shadowRoot,
defaultCallback(data: IFileBrowserCallBackData): void {
if (data.files && data.files.length) {
data.files.forEach((file, i) => {
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/fullsize/fullsize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ export function fullsize(editor: IViewWithToolbar): void {
if (editor.o.globalFullSize) {
let node = container.parentNode as HTMLElement;

while (node && node.nodeType !== Node.DOCUMENT_NODE) {
while (
node &&
node.nodeType !== Node.DOCUMENT_NODE &&
node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE
) {
node.classList.toggle('jodit_fullsize-box_true', enable);
node = node.parentNode as HTMLElement;
}
Expand Down
1 change: 0 additions & 1 deletion src/plugins/link/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
} from 'jodit/core/helpers';
import { Plugin } from 'jodit/core/plugin';
import { autobind } from 'jodit/core/decorators';
import { Dialog } from 'jodit/modules/dialog';
import { pluginSystem } from 'jodit/core/global';

import './config';
Expand Down

0 comments on commit 816d1db

Please sign in to comment.