mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 03:14:40 +03:00
UBERF-8200 Show codeblock lang selector on hover only (#6749)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
8ac0555654
commit
d284414f2b
@ -368,6 +368,18 @@ pre.proseCodeBlock {
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
pre.proseCodeBlock {
|
||||
button:not(.hovered) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
button {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fixes for MessageViewer
|
||||
pre.proseCodeBlock > pre.proseCode {
|
||||
padding: 0;
|
||||
|
@ -141,7 +141,7 @@ function createDecorations (doc: ProseMirrorNode, options: CodeBlockLowlightOpti
|
||||
button.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
handleLangButtonClick(e, node, pos, view, options)
|
||||
handleLangButtonClick(e, node, pos, view, button, options)
|
||||
})
|
||||
} else {
|
||||
button.disabled = true
|
||||
@ -181,6 +181,7 @@ function handleLangButtonClick (
|
||||
node: ProseMirrorNode,
|
||||
pos: number,
|
||||
view: EditorView,
|
||||
button: HTMLButtonElement,
|
||||
options: CodeBlockLowlightOptions
|
||||
): void {
|
||||
const language = node.attrs.language
|
||||
@ -191,6 +192,8 @@ function handleLangButtonClick (
|
||||
label: language
|
||||
}))
|
||||
|
||||
button.classList.add('hovered')
|
||||
|
||||
showPopup(
|
||||
DropdownLabelsPopup,
|
||||
{
|
||||
@ -199,6 +202,7 @@ function handleLangButtonClick (
|
||||
},
|
||||
getEventPositionElement(evt),
|
||||
(result) => {
|
||||
button.classList.remove('hovered')
|
||||
if (result != null) {
|
||||
const tr = view.state.tr.setNodeAttribute(pos, 'language', result)
|
||||
view.dispatch(tr)
|
||||
|
Loading…
Reference in New Issue
Block a user