diff --git a/assets/css/style.css b/assets/css/style.css
index a5a6e69..bf04cde 100644
--- a/assets/css/style.css
+++ b/assets/css/style.css
@@ -6922,6 +6922,18 @@ button.gear-guide-skill:hover { border-color: var(--gold); transform: translateY
.gear-description-text { max-width: 900px; line-height: 1.75; overflow-wrap: anywhere; }
.gear-description-text p { margin: 0 0 0.75rem; }
.gear-description-text p:last-child { margin-bottom: 0; }
+.gear-description-text > :last-child { margin-bottom: 0; }
+.gear-description-text .gear-format-heading { margin: 1rem 0 0.4rem; color: var(--gold); font-size: 1.05rem; line-height: 1.4; }
+.gear-description-text h5.gear-format-heading { font-size: 0.95rem; }
+.gear-description-text > .gear-format-heading:first-child { margin-top: 0; }
+.gear-description-text ul, .gear-description-text ol { margin: 0 0 0.75rem; padding-left: 1.4rem; }
+.gear-description-text li { margin: 0.15rem 0; }
+.gear-description-text blockquote { margin: 0 0 0.75rem; padding: 0.5rem 0.85rem; border-left: 3px solid var(--gold); border-radius: 0 6px 6px 0; background: rgba(201, 162, 39, 0.08); }
+.gear-description-text u { text-underline-offset: 2px; }
+.gear-description-text del { color: var(--text-muted); }
+.gear-description-text a { color: var(--gold); text-decoration: underline; text-underline-offset: 2px; }
+.format-toolbar { margin-top: 0.35rem; }
+textarea.has-format-toolbar { border-top-left-radius: 0; border-top-right-radius: 0; }
@media (max-width: 900px) {
.gear-guide-grid, .gear-guide-skills-layout { grid-template-columns: minmax(0, 1fr); }
}
diff --git a/assets/js/format-toolbar.js b/assets/js/format-toolbar.js
new file mode 100644
index 0000000..121a896
--- /dev/null
+++ b/assets/js/format-toolbar.js
@@ -0,0 +1,112 @@
+/**
+ * Formatierungs-Knoepfe ueber Textfeldern mit data-format-toolbar (z.B. Beschreibung im Guide des Gear-Planers).
+ * Sie setzen die Zeichen, die der Server beim Anzeigen umwandelt (gear_description_html in includes/gear.php):
+ * **fett**, *kursiv*, __unterstrichen__, ~~durchgestrichen~~, Zeilen mit "## ", "- ", "1. ", "> " und [Text](Adresse).
+ * Tastenkuerzel: Strg+B, Strg+I, Strg+U.
+ */
+(function () {
+ 'use strict';
+
+ var BUTTONS = [
+ { wrap: '**', label: 'F', title: 'Fett (Strg+B)', key: 'b' },
+ { wrap: '*', label: 'K', title: 'Kursiv (Strg+I)', key: 'i' },
+ { wrap: '__', label: 'U', title: 'Unterstrichen (Strg+U)', key: 'u' },
+ { wrap: '~~', label: 'S', title: 'Durchgestrichen' },
+ { line: '## ', label: 'Ü', title: 'Zwischenüberschrift' },
+ { line: '- ', label: '• Liste', title: 'Liste' },
+ { line: '1. ', label: '1. Liste', title: 'Nummerierte Liste' },
+ { line: '> ', label: 'Hinweis', title: 'Hinweis-Kasten' },
+ { link: true, label: 'Link', title: 'Link einfügen' }
+ ];
+
+ function changed(area) {
+ area.focus();
+ area.dispatchEvent(new Event('input', { bubbles: true }));
+ }
+
+ function wrap(area, mark) {
+ var start = area.selectionStart;
+ var end = area.selectionEnd;
+ var selected = area.value.slice(start, end);
+ var before = area.value.slice(start - mark.length, start);
+ var after = area.value.slice(end, end + mark.length);
+ // Ein * vor **fett** gehoert zum Fett, nicht zum Kursiv (***beides*** zaehlt als kursiv)
+ var partOfBold = mark === '*' && area.value.charAt(start - 2) === '*' && area.value.slice(start - 3, start) !== '***';
+ // Schon so formatiert (Zeichen direkt um die Auswahl)? Dann wieder entfernen
+ if (before === mark && after === mark && !partOfBold) {
+ area.setRangeText(selected, start - mark.length, end + mark.length, 'select');
+ return changed(area);
+ }
+ var text = selected || 'Text';
+ area.setRangeText(mark + text + mark, start, end, 'end');
+ // Text markiert lassen: Platzhalter laesst sich direkt ueberschreiben, ein zweiter Klick nimmt es zurueck
+ area.setSelectionRange(start + mark.length, start + mark.length + text.length);
+ changed(area);
+ }
+
+ function prefixLines(area, prefix) {
+ var start = area.value.lastIndexOf('\n', area.selectionStart - 1) + 1;
+ var end = area.selectionEnd;
+ var lines = area.value.slice(start, end).split('\n');
+ var all = lines.every(function (line, i) {
+ return line.indexOf(prefix === '1. ' ? (i + 1) + '. ' : prefix) === 0;
+ });
+ lines = lines.map(function (line, i) {
+ var p = prefix === '1. ' ? (i + 1) + '. ' : prefix;
+ // Haben schon alle Zeilen das Zeichen, nimmt ein zweiter Klick es wieder weg
+ return all ? line.slice(p.length) : (line.indexOf(p) === 0 ? line : p + line);
+ });
+ area.setRangeText(lines.join('\n'), start, end, 'end');
+ changed(area);
+ }
+
+ function insertLink(area) {
+ var start = area.selectionStart;
+ var end = area.selectionEnd;
+ var ask = window.luminaDialog
+ ? window.luminaDialog.prompt('Adresse des Links (https://…):', { title: 'Link einfügen', value: 'https://', okLabel: 'Einfügen' })
+ : Promise.resolve(window.prompt('Adresse des Links (https://…):', 'https://'));
+ ask.then(function (url) {
+ url = (url || '').trim();
+ if (!url || url === 'https://') return area.focus();
+ var text = area.value.slice(start, end) || 'Linktext';
+ area.setRangeText('[' + text + '](' + url + ')', start, end, 'end');
+ if (start === end) area.setSelectionRange(start + 1, start + 1 + text.length);
+ changed(area);
+ });
+ }
+
+ function run(area, btn) {
+ if (btn.wrap) wrap(area, btn.wrap);
+ else if (btn.line) prefixLines(area, btn.line);
+ else if (btn.link) insertLink(area);
+ }
+
+ document.querySelectorAll('textarea[data-format-toolbar]').forEach(function (area) {
+ var bar = document.createElement('div');
+ bar.className = 'wiki-toolbar format-toolbar';
+ bar.setAttribute('role', 'toolbar');
+ bar.setAttribute('aria-label', 'Formatierung');
+ BUTTONS.forEach(function (btn) {
+ var el = document.createElement('button');
+ el.type = 'button';
+ el.innerHTML = btn.label;
+ el.title = btn.title;
+ // Auswahl im Textfeld behalten - sonst verliert es beim Klick den Fokus
+ el.addEventListener('mousedown', function (e) { e.preventDefault(); });
+ el.addEventListener('click', function () { run(area, btn); });
+ bar.appendChild(el);
+ });
+ area.parentNode.insertBefore(bar, area);
+ area.classList.add('has-format-toolbar');
+
+ area.addEventListener('keydown', function (e) {
+ if (!(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey) return;
+ var btn = BUTTONS.filter(function (b) { return b.key === e.key.toLowerCase(); })[0];
+ if (btn) {
+ e.preventDefault();
+ run(area, btn);
+ }
+ });
+ });
+})();
diff --git a/gear.php b/gear.php
index baa3a23..0ca31eb 100644
--- a/gear.php
+++ b/gear.php
@@ -958,7 +958,7 @@ include __DIR__ . '/includes/header.php';
= gear_skills_mini_html($pSkills) ?>
= e($p['note']) ?>
- = e(mb_strimwidth(preg_replace('/\s+/u', ' ', (string) $p['description']) ?? '', 0, 180, ' …')) ?>
+ = e(mb_strimwidth(preg_replace('/\s+/u', ' ', gear_format_plain((string) $p['description'])) ?? '', 0, 180, ' …')) ?>
@@ -1052,4 +1052,5 @@ include __DIR__ . '/includes/header.php';
+
diff --git a/includes/gear.php b/includes/gear.php
index 53bde29..2f68c2c 100644
--- a/includes/gear.php
+++ b/includes/gear.php
@@ -809,10 +809,92 @@ function gear_public_class_counts(): array
const GEAR_DESCRIPTION_MAX = 10000;
/** Beschreibung als HTML: Absaetze bei Leerzeilen, sonst Zeilenumbrueche - nur Text, keine Links oder Formatierung. */
+/**
+ * Text mit Formatierung (Schreibweise wie im Wiki, Knoepfe: assets/js/format-toolbar.js) als HTML:
+ * **fett**, *kursiv*, __unterstrichen__, ~~durchgestrichen~~, [Linktext](https://...), Zeilen mit "## " (Ueberschrift),
+ * "- " (Liste), "1. " (nummerierte Liste) und "> " (Hinweis-Kasten). Absaetze mit einer Leerzeile.
+ */
function gear_description_html(string $text): string
{
- $paragraphs = preg_split('/\n\s*\n/u', trim($text)) ?: [];
- return implode('', array_map(static fn (string $p): string => '
' . nl2br(e(trim($p)), false) . '
', $paragraphs)); + $html = ''; + $paragraph = []; + $list = null; // ['ul'|'ol', [Eintraege]] + $quote = []; + $flush = static function () use (&$html, &$paragraph, &$list, &$quote): void { + if ($paragraph) { + $html .= '' . implode('
', array_map('gear_format_inline', $paragraph)) . '
' . implode(''; + } + $paragraph = $quote = []; + $list = null; + }; + foreach (explode("\n", str_replace(["\r\n", "\r"], "\n", trim($text))) as $line) { + $line = rtrim($line); + if (trim($line) === '') { + $flush(); + } elseif (preg_match('/^(#{1,3})\s+(.+)$/u', $line, $m)) { + $flush(); + $level = strlen($m[1]) + 2; // ## -> h4, damit es unter den Ueberschriften der Seite bleibt + $html .= '
', array_map('gear_format_inline', $quote)) . '
[[Skillname]] in Beschreibung, Begründungen, Tasten und Tipps wird zu einem Skill-Chip mit Icon= $hintSkill !== '' ? ', z.B. [[' . e($hintSkill) . ']]' : '' ?>.
Mit Nummer zeigt er eine Spezialisierung bzw. bei Stigmen einen Bonus: [[= e($hintSkill !== '' ? $hintSkill : 'Skillname') ?>:1]] für die erste (auch :II usw.).
Gegenstände wie Flügel: [[Flügel:Flügel des uralten Aulaus]] oder [[Item:…]] – Name wie im Spiel (deutsch oder englisch) bzw. die ID von aion2hub, mit Bild und Info beim Drüberfahren.
-