Compare commits

...

2 Commits

Author SHA1 Message Date
339e171ec7 Update edit button placement 2026-03-17 10:58:03 +01:00
e1e89b40fb Update section edit buttons 2026-03-17 10:51:30 +01:00
3 changed files with 92 additions and 5 deletions

View File

@@ -105,8 +105,6 @@ div.picker button.toolbutton {
margin-right: 0;
margin-left: 1em;
}
.dokuwiki .editBar .editButtons button {
}
/* summary input and minor changes checkbox */
.dokuwiki .editBar .summary {
@@ -140,9 +138,46 @@ div.picker button.toolbutton {
/* section edit buttons
********************************************************************/
/* Hidden for now - positioning was problematic */
.dokuwiki .secedit {
display: none;
.dokuwiki .section-heading-row {
display: flex;
align-items: baseline;
}
.dokuwiki .section-heading-row > .secedit {
flex-shrink: 0;
margin-left: .4em;
}
[dir=rtl] .dokuwiki .section-heading-row > .secedit {
margin-left: 0;
margin-right: .4em;
}
.dokuwiki .section-heading-row > .secedit form {
margin: 0;
}
.dokuwiki .section-heading-row > .secedit button {
border: 0;
padding: .15em;
min-width: 1.25em;
background: transparent;
color: @ini_icons;
font-size: 0;
line-height: 1;
cursor: pointer;
}
.dokuwiki .section-heading-row > .secedit button::before {
content: '\270E edit';
opacity: 0.75;
font-style: italic;
font-size: .95rem;
}
.dokuwiki .section-heading-row > .secedit button:hover,
.dokuwiki .section-heading-row > .secedit button:focus {
color: @ini_link;
}
/* Sidebar should never show section edit buttons */

View File

@@ -10,6 +10,37 @@
if (!defined('DOKU_INC')) die(); /* must be run from within DokuWiki */
// Replace default section edit buttons with a compact pencil icon
global $EVENT_HANDLER;
$EVENT_HANDLER->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', null, '_luxtools_secedit_button');
function _luxtools_secedit_button(\dokuwiki\Extension\Event $event, $param) {
global $ID, $INFO;
$data = $event->data;
if (!isset($data['name']) || $data['name'] === '') {
$event->preventDefault();
$event->result = '';
return;
}
$name = $data['name'];
$secid = $data['secid'];
unset($data['name'], $data['secid']);
$params = array_merge(
['do' => 'edit', 'rev' => $INFO['lastmod'], 'summary' => '[' . $name . '] '],
$data
);
$html = '<div class="secedit editbutton_' . hsc($data['target']) . ' editbutton_' . (int)$secid . '">';
$html .= html_btn('secedit', $ID, '', $params, 'post', $name);
$html .= '</div>';
$event->preventDefault();
$event->result = $html;
}
$hasSidebar = page_findnearest($conf['sidebar']);
$showSidebar = $hasSidebar && ($ACT == 'show');
?><!DOCTYPE html>

View File

@@ -139,6 +139,27 @@ jQuery(function(){
}
}());
// Relocate section edit buttons next to their headings.
// DokuWiki renders the edit marker after the section content div,
// so we match by secid: .editbutton_N belongs to h*.sectioneditN.
(function enhanceSectionEditButtons() {
jQuery('#dokuwiki__content .secedit[class*="editbutton_"]').each(function () {
var $btn = jQuery(this);
var match = $btn.attr('class').match(/editbutton_(\d+)/);
if (!match) return;
var $heading = jQuery('#dokuwiki__content .sectionedit' + match[1]);
if (!$heading.length || !$heading.is('h1,h2,h3,h4,h5,h6')) return;
// Skip if already relocated
if ($heading.parent().hasClass('section-heading-row')) return;
var $wrapper = jQuery('<div/>', {'class': 'section-heading-row'});
$heading.before($wrapper);
$wrapper.append($heading, $btn);
});
}());
// enhance header search with suggestions and keyboard navigation
(function enhanceSearch(){
var $input = jQuery('#qsearch__in');