Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
this.pdfContainer.style.display = 'none';
this.frame.style.display = 'block';
this.frame.src = url;
// The load indicator will hide itself if the content of the iframe was loaded.
if (!preserveFocus) {
this.frame.addEventListener('load', () => {
const window = this.frame.contentWindow;
if (window) {
window.focus();
}
}, { once: true });
}
}
// Delegate all the `keypress` events from the `iframe` to the application.
this.toDisposeOnGo.push(addEventListener(this.frame, 'load', () => {
try {
const { contentDocument } = this.frame;
if (contentDocument) {
const keypressHandler = (e: KeyboardEvent) => this.keybindings.run(e);
contentDocument.addEventListener('keypress', keypressHandler, true);
this.toDisposeOnDetach.push(Disposable.create(() => contentDocument.removeEventListener('keypress', keypressHandler)));
}
} catch {
// There is not much we could do with the security exceptions due to CORS.
}
}));
} catch (e) {
clearTimeout(this.frameLoadTimeout);
this.hideLoadIndicator();
this.showErrorBar(String(e));
console.log(e);protected createIFrame(): HTMLIFrameElement {
const frame = document.createElement('iframe');
const sandbox = (this.props.sandbox || MiniBrowserProps.SandboxOptions.DEFAULT).map(name => MiniBrowserProps.SandboxOptions[name]);
frame.sandbox.add(...sandbox);
this.toDispose.push(addEventListener(frame, 'load', this.onFrameLoad.bind(this)));
this.toDispose.push(addEventListener(frame, 'error', this.onFrameError.bind(this)));
return frame;
}protected onClick(element: HTMLElement, emitter: Emitter): HTMLElement {
this.toDispose.push(addEventListener(element, 'click', () => {
if (!element.classList.contains(MiniBrowser.Styles.DISABLED)) {
emitter.fire(undefined);
}
}));
return element;
}protected createInput(parent: HTMLElement): HTMLInputElement {
const input = document.createElement('input');
input.type = 'text';
input.classList.add('theia-input');
this.toDispose.pushAll([
addEventListener(input, 'keydown', this.handleInputChange.bind(this)),
addEventListener(input, 'click', () => {
if (this.getToolbarProps() === 'read-only') {
this.handleOpen();
} else {
if (input.value) {
input.select();
}
}
})
]);
parent.appendChild(input);
return input;
}protected createInput(parent: HTMLElement): HTMLInputElement {
const input = document.createElement('input');
input.type = 'text';
input.classList.add('theia-input');
this.toDispose.pushAll([
addEventListener(input, 'keydown', this.handleInputChange.bind(this)),
addEventListener(input, 'click', () => {
if (this.getToolbarProps() === 'read-only') {
this.handleOpen();
} else {
if (input.value) {
input.select();
}
}
})
]);
parent.appendChild(input);
return input;
}protected createInput(parent: HTMLElement): HTMLInputElement {
const input = document.createElement('input');
input.type = 'text';
this.toDispose.pushAll([
addEventListener(input, 'keydown', this.handleInputChange.bind(this)),
addEventListener(input, 'click', () => {
if (this.getToolbarProps() === 'read-only') {
this.handleOpen();
} else {
if (input.value) {
input.select();
}
}
}),
]);
parent.appendChild(input);
return input;
} .map(panel => addEventListener(panel.node, 'mousedown', this.mousedownListener, true)));protected createIFrame(): HTMLIFrameElement {
const frame = document.createElement('iframe');
const sandbox = (this.props.sandbox || MiniBrowserProps.SandboxOptions.DEFAULT).map(name => MiniBrowserProps.SandboxOptions[name]);
frame.sandbox.add(...sandbox);
this.toDispose.push(addEventListener(frame, 'load', this.onFrameLoad.bind(this)));
return frame;
}