| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import ".." |
| 6 |
import im.nheko |
| 7 |
|
| 8 |
MatrixText { |
| 9 |
required property string body |
| 10 |
required property bool isOnlyEmoji |
| 11 |
property bool isReply: EventDelegateChooser.isReply |
| 12 |
required property bool keepFullText |
| 13 |
required property string formatted |
| 14 |
|
| 15 |
property string copyText: selectedText ? getText(selectionStart, selectionEnd) : body |
| 16 |
property int metadataWidth: 100 |
| 17 |
property bool fitsMetadata: false //positionAt(width,height-4) == positionAt(width-metadataWidth-10, height-4) |
| 18 |
|
| 19 |
// table border-collapse doesn't seem to work |
| 20 |
text: ` |
| 21 |
<style type="text/css"> |
| 22 |
code { background-color: ` + palette.alternateBase + `; white-space: pre-wrap; } |
| 23 |
pre { background-color: ` + palette.alternateBase + `; white-space: pre-wrap; } |
| 24 |
table { |
| 25 |
border-width: 1px; |
| 26 |
border-collapse: collapse; |
| 27 |
border-style: solid; |
| 28 |
border-color: ` + palette.text + `; |
| 29 |
background-color: ` + palette.alternateBase + `; |
| 30 |
} |
| 31 |
table th, |
| 32 |
table td { |
| 33 |
padding: ` + Math.ceil(fontMetrics.lineSpacing/2) + `px; |
| 34 |
} |
| 35 |
blockquote { margin-left: 1em; } |
| 36 |
` + (!Settings.mobileMode ? `span[data-mx-spoiler] { |
| 37 |
color: transparent; |
| 38 |
background-color: ` + palette.text + `; |
| 39 |
}` : "") + // TODO(Nico): Figure out how to support mobile |
| 40 |
`</style> |
| 41 |
` + formatted.replace(/<del>/g, "<s>").replace(/<\/del>/g, "</s>").replace(/<strike>/g, "<s>").replace(/<\/strike>/g, "</s>") |
| 42 |
|
| 43 |
enabled: !isReply |
| 44 |
font.pointSize: (Settings.enlargeEmojiOnlyMessages && isOnlyEmoji > 0 && isOnlyEmoji < 4) ? Settings.fontSize * 3 : Settings.fontSize |
| 45 |
|
| 46 |
NhekoCursorShape { |
| 47 |
enabled: isReply |
| 48 |
anchors.fill: parent |
| 49 |
cursorShape: Qt.PointingHandCursor |
| 50 |
} |
| 51 |
|
| 52 |
} |