简单修改 markdown 编辑

main
yang.yongquan 2023-07-04 10:17:07 +08:00
parent e141e79fe4
commit 3aeb07fbb2
3 changed files with 98 additions and 63 deletions

View File

@ -60,7 +60,7 @@ FluWindow {
Layout.topMargin: 45 Layout.topMargin: 45
Layout.bottomMargin: 4 Layout.bottomMargin: 4
Layout.rightMargin: 4 Layout.rightMargin: 4
type: "video" type: "md"
} }

View File

@ -6,6 +6,7 @@ import QtQuick.Controls.Basic
import QtWebEngine 1.2 import QtWebEngine 1.2
import FluentUI import FluentUI
import AicsKB.FileTransferManager import AicsKB.FileTransferManager
import "qrc:///AicsKnowledgeBase/qml/page"
FluArea { FluArea {
id: content_area id: content_area
@ -140,41 +141,6 @@ FluArea {
} }
} }
Loader {
id: content_view
Layout.fillWidth: true
sourceComponent: video_view
}
Component {
id: video_view
FluMediaPlayer {
Layout.fillWidth: true
implicitHeight: width * 9 / 16.
}
}
Component {
id: text_view
Text {
id: text_md
text: content_page.contentMd
textFormat: TextEdit.MarkdownText
focus: true
}
}
Component {
id: other_view
WebEngineView {
Layout.fillWidth: true
id: sitemonitory_view
backgroundColor: "transparent"
implicitHeight: 200
settings.javascriptEnabled: true
settings.pluginsEnabled: true
url: "https://www.baidu.com"
}
}
FluArea { FluArea {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 100 implicitHeight: 100
@ -220,28 +186,64 @@ FluArea {
} }
} }
} }
Item {
Loader {
id: content_view
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 50 sourceComponent: video_view
FluText { }
id: text_note
text: "笔记" Component {
padding: 10 id: video_view
font { FluMediaPlayer {
pointSize: 15 Layout.fillWidth: true
bold: true implicitHeight: width * 9 / 16.
} }
} }
FluTextButton { Component {
id: button_publish id: text_view
text: "发布笔记" NoteEditPage {
hoverColor: "blue" noteId: "255454"
normalColor: "black" Layout.fillWidth: true
anchors { implicitHeight: 400
verticalCenter: text_note.verticalCenter }
right: parent.right
} }
Component {
id: other_view
WebEngineView {
Layout.fillWidth: true
id: sitemonitory_view
backgroundColor: "transparent"
implicitHeight: 200
settings.javascriptEnabled: true
settings.pluginsEnabled: true
url: "https://www.baidu.com"
} }
} }
// Item {
// Layout.fillWidth: true
// implicitHeight: 50
// FluText {
// id: text_note
// text: ""
// padding: 10
// font {
// pointSize: 15
// bold: true
// }
// }
// FluTextButton {
// id: button_publish
// text: ""
// hoverColor: "blue"
// normalColor: "black"
// anchors {
// verticalCenter: text_note.verticalCenter
// right: parent.right
// }
// }
// }
} }
} }

View File

@ -15,9 +15,9 @@ FluArea {
FluScrollablePage { FluScrollablePage {
id: edit_page id: edit_page
anchors.fill: parent anchors.fill: parent
leftPadding: 10 leftPadding: 5
topPadding: 10 topPadding: 5
rightPadding: 10 rightPadding: 5
bottomPadding: 0 bottomPadding: 0
property string contentMd: "**ssijfdijgo**\ndfdgfdggggggggggggggggggggggggggggggggggggggggggggggggggg" property string contentMd: "**ssijfdijgo**\ndfdgfdggggggggggggggggggggggggggggggggggggggggggggggggggg"
@ -40,14 +40,16 @@ FluArea {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 50 implicitHeight: 30
FluIconButton { FluIconButton {
id: button_edit id: button_edit
iconSource: FluentIcons.Edit iconSource: FluentIcons.Edit
visible: true iconSize: 12
visible: edit_page.isEditable
anchors { anchors {
right: parent.right right: parent.right
verticalCenter: parent.verticalCenter
} }
onClicked: { onClicked: {
button_edit.visible = false button_edit.visible = false
@ -62,10 +64,12 @@ FluArea {
FluIconButton { FluIconButton {
id: button_cancel id: button_cancel
iconSource: FluentIcons.Cancel iconSource: FluentIcons.Cancel
iconSize: 12
text: "取消" text: "取消"
visible: false visible: false
anchors { anchors {
right: parent.right right: parent.right
verticalCenter: parent.verticalCenter
} }
onClicked: { onClicked: {
button_edit.visible = edit_page.isEditable button_edit.visible = edit_page.isEditable
@ -80,16 +84,19 @@ FluArea {
FluIconButton { FluIconButton {
id: button_save id: button_save
iconSource: FluentIcons.Save iconSource: FluentIcons.Save
iconSize: 12
text: "保存" text: "保存"
visible: false visible: false
anchors { anchors {
right: button_cancel.left right: button_cancel.left
verticalCenter: parent.verticalCenter
} }
} }
FluIconButton { FluIconButton {
id: button_preview id: button_preview
iconSource: FluentIcons.PreviewLink iconSource: FluentIcons.PreviewLink
iconSize: 12
text: "预览" text: "预览"
visible: false visible: false
onClicked: { onClicked: {
@ -99,26 +106,35 @@ FluArea {
anchors { anchors {
right: button_save.left right: button_save.left
verticalCenter: parent.verticalCenter
} }
} }
FluIconButton { FluIconButton {
id: button_subfield id: button_subfield
iconSource: md_show_view.isPreviewShowing ? FluentIcons.ClosePane: FluentIcons.OpenPane iconSource: md_show_view.isPreviewShowing ? FluentIcons.ClosePane: FluentIcons.OpenPane
iconSize: 12
text: "分栏" text: "分栏"
visible: false visible: false
onClicked: { onClicked: {
if(md_show_view.isEditShowing ^ md_show_view.isPreviewShowing) {
md_show_view.isEditShowing = true md_show_view.isEditShowing = true
md_show_view.isPreviewShowing = !md_show_view.isPreviewShowing md_show_view.isPreviewShowing = true
} else {
md_show_view.isEditShowing = true
md_show_view.isPreviewShowing = false
}
} }
anchors { anchors {
right: button_preview.left right: button_preview.left
verticalCenter: parent.verticalCenter
} }
} }
FluIconButton { FluIconButton {
id: button_editing id: button_editing
iconSource: FluentIcons.ClipboardList iconSource: FluentIcons.ClipboardList
iconSize: 12
text: "编辑" text: "编辑"
visible: false visible: false
onClicked: { onClicked: {
@ -127,6 +143,7 @@ FluArea {
} }
anchors { anchors {
right: button_subfield.left right: button_subfield.left
verticalCenter: parent.verticalCenter
} }
} }
} }
@ -137,6 +154,7 @@ FluArea {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 300 implicitHeight: 300
ScrollView { ScrollView {
id: edit_show_view id: edit_show_view
implicitWidth: parent.width / 2 implicitWidth: parent.width / 2
@ -145,6 +163,11 @@ FluArea {
TextArea { TextArea {
id: textArea_edit id: textArea_edit
wrapMode: TextEdit.Wrap wrapMode: TextEdit.Wrap
background: Rectangle {
color: customTextArea.focus ? "#E0E0E0" : "white"
border.color: FluColors.Grey30
radius: 10
}
} }
} }
@ -157,6 +180,16 @@ FluArea {
id: textArea_preview id: textArea_preview
wrapMode: TextEdit.Wrap wrapMode: TextEdit.Wrap
textFormat: TextEdit.MarkdownText textFormat: TextEdit.MarkdownText
background: Rectangle {
color: customTextArea.focus ? "#E0E0E0" : "white"
border.color: FluColors.Grey30
radius: 10
}
readOnly: true
MouseArea {
anchors.fill: parent
enabled: false
}
} }
} }
} }