Skip to content

Commit ee6af5c

Browse files
committed
Add formatting help
1 parent 325cd24 commit ee6af5c

File tree

8 files changed

+43
-11
lines changed

8 files changed

+43
-11
lines changed

frontend/src/editor/editor.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import htmx from "htmx.org"
12
import {
23
MarkupEditorCodeModal,
34
MarkupEditorImageModal,
@@ -46,12 +47,14 @@ class MarkupEditor {
4647

4748
element.querySelectorAll("[misago-editor-action]").forEach((control) => {
4849
const actionName = control.getAttribute("misago-editor-action")
49-
control.addEventListener("click", ({ target }) => {
50+
control.addEventListener("click", (event) => {
51+
event.preventDefault()
52+
5053
const action = this.actions[actionName]
5154
if (action) {
5255
action({
5356
input,
54-
target,
57+
target: event.target,
5558
editor: this,
5659
selection: new MarkupEditorSelection(input),
5760
})
@@ -264,3 +267,17 @@ editor.setAction("spoiler", function ({ selection }) {
264267
editor.setAction("code", function ({ editor, selection }) {
265268
editor.showCodeModal(selection)
266269
})
270+
271+
editor.setAction("formatting-help", function ({ target }) {
272+
const modal = document.getElementById("markup-editor-formatting-help")
273+
const element = target.closest("a")
274+
275+
htmx
276+
.ajax("GET", element.href, {
277+
target: modal,
278+
swap: "innerHTML",
279+
})
280+
.then(() => {
281+
$(modal).modal("show")
282+
})
283+
})

frontend/src/style/misago/formatting-help.less

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
.formatting-help {
1+
.modal-formatting-help {
22
padding-bottom: 0;
3+
}
34

4-
& > h4 {
5-
margin-bottom: @line-height-computed;
6-
}
5+
.formatting-help > h4 {
6+
margin-bottom: @line-height-computed;
77
}
88

99
.formatting-help-item,

misago/static/misago/css/misago.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misago/static/misago/css/misago.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misago/static/misago/js/misago.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misago/static/misago/js/misago.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% load i18n %}
2+
<div class="modal-dialog modal-lg" role="document">
3+
<div class="modal-content">
4+
<div class="modal-header">
5+
<button type="button" class="close" data-dismiss="modal" aria-label="{% trans 'Close' context 'modal' %}"><span aria-hidden="true">&times;</span></button>
6+
<h4 class="modal-title">
7+
{% trans "Formatting help" context "formatting help modal "%}
8+
</h4>
9+
</div>
10+
<div class="modal-body modal-formatting-help">
11+
{% include "misago/formatting_help/help.html" %}
12+
</div>
13+
</div>
14+
</div>

misago/templates/misago/posting/post_form.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
title="{% trans 'Upload file' context 'markup editor' %}"
9999
type="button"
100100
misago-editor-action="upload"
101-
>
101+
>
102102
<span class="material-icon">file_upload</span>
103103
</button>
104104
</div>
@@ -108,6 +108,7 @@
108108
href="{% url 'misago:formatting-help' %}"
109109
title="{% trans 'Formatting help' context 'markup editor' %}"
110110
target="_blank"
111+
misago-editor-action="formatting-help"
111112
>
112113
<span class="material-icon">help_outline</span>
113114
</a>

0 commit comments

Comments
 (0)