Commit 656f8148 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to create code block + title

parent 52e06ce2
......@@ -70,6 +70,7 @@ void MarkdownInterface::createAction(KActionCollection *ac)
mardownMenu->addAction(i18n("Horizontal Rule"), this, &MarkdownInterface::addHorizontalRule);
mardownMenu->addAction(i18n("Change as Bold"), this, &MarkdownInterface::addBold);
mardownMenu->addAction(i18n("Change as Italic"), this, &MarkdownInterface::addItalic);
mardownMenu->addAction(i18n("Change as Code"), this, &MarkdownInterface::addCode);
mardownMenu->addAction(i18n("Add Link"), this, &MarkdownInterface::addLink);
MessageComposer::PluginActionType typePopup(mPopupMenuAction, MessageComposer::PluginActionType::PopupMenu);
addActionType(typePopup);
......@@ -88,6 +89,14 @@ void MarkdownInterface::addBold()
}
}
void MarkdownInterface::addCode()
{
const QString selectedText = richTextEditor()->textCursor().selectedText();
if (!selectedText.isEmpty()) {
richTextEditor()->textCursor().insertText(QStringLiteral("`%1`").arg(selectedText));
}
}
void MarkdownInterface::addItalic()
{
const QString selectedText = richTextEditor()->textCursor().selectedText();
......@@ -110,7 +119,10 @@ void MarkdownInterface::addLink()
void MarkdownInterface::addTitle()
{
const QString selectedText = richTextEditor()->textCursor().selectedText();
if (!selectedText.isEmpty()) {
richTextEditor()->textCursor().insertText(QStringLiteral("#%1#").arg(selectedText));
}
}
bool MarkdownInterface::reformatText()
......
......@@ -48,6 +48,7 @@ private:
void addLink();
void addHorizontalRule();
void slotActivated(bool checked);
void addCode();
QAction *mAction = nullptr;
QAction *mPopupMenuAction = nullptr;
QPointer<MarkdownPreviewDialog> mDialog;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment