Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

PRJ-58 Fix Markdown and JCEF client components couldn't be shrunk #142

Open
wants to merge 1 commit into
base: jcef
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ package org.jetbrains.projector.client.web.component

import kotlinx.browser.document
import org.w3c.dom.HTMLIFrameElement
import org.w3c.dom.events.EventListener

abstract class ClientComponent(
protected val id: Int,
) {

private val documentListeners = mutableMapOf<String, EventListener>()

val iFrame: HTMLIFrameElement = createIFrame(id)

var windowId: Int? = null

fun dispose() {
documentListeners.forEach { document.removeEventListener(it.key, it.value) }
iFrame.remove()
}

Expand All @@ -60,6 +64,15 @@ abstract class ClientComponent(
}

contentDocument!!.oncontextmenu = { false }

documentListeners["mousedown"] = EventListener {
style.asDynamic().pointerEvents = "none"
}
documentListeners["mouseup"] = EventListener {
style.asDynamic().pointerEvents = "auto"
}

documentListeners.forEach { document.addEventListener(it.key, it.value) }
}

protected fun setLinkProcessor(linkProcessor: (String) -> Unit) {
Expand Down