1/*  DokuWiki MoaiEditor Bootstrap3.js file
2    Version : 0.5 (May 5, 2026)
3    Author  : MoaiTools <info@moaitools.org>
4    License : GPL 3 (http://www.gnu.org/licenses/gpl.html) */
5/*
6    This class extends 'MoaiEditor.Template' class and allows to override
7    some methods to support a specific template, in this case 'Bootstrap3'.
8
9    This is the list of methods you generally can override to support your
10    template:
11
12        detectTemplate
13        addStartButton
14
15        find_ElementsToHide
16        find_Messages()
17        find_Toolbar
18        find_Pagetools
19        find_EditSummary
20        find_Form
21        find_Textarea
22        find_EditButtons
23
24    See 'templates/default.js' to understand each of these methods.
25
26    See 'README' to learn how to support a new template.
27*/
28MoaiEditor.Template_bootstrap3 = class extends MoaiEditor.Template {
29
30    detectTemplate() {
31        if (DOKU_TPL.endsWith ('tpl/bootstrap3/'))
32            return true;
33        return false;
34    }
35    addStartButton() {
36        // Option 1: Add a proper button
37        const button = moaiEditor.start.button;
38        button.classList.add('btn');
39        button.classList.add('btn-default');
40        button.classList.add('mr-2');
41        this.elements.editButtons.appendChild(moaiEditor.start.button);
42        // Option 2: Add a small image (to blend well in the size control buttons area of the DokuWiki native editor)
43        //document.body.querySelector("#size__ctl").appendChild(moaiEditor.start.png);
44    }
45    find_ElementsToHide() {
46        // Find the elements which contain the old editor in order to be hidden
47        // This method can return a single element, or an array of elements
48        return document.body.querySelector("body > .dokuwiki")
49    }
50    find_Messages() {
51        // Find the displayed messages (info, error, success, notify) usually rendered by inc/html.php -> html_msgarea().
52        // Some templates like bootstrap3 implement their own message rendering function and don't use html_msgarea().
53        // In order to check how (and if) your template's messages are being displayed in this editor, you can simulate
54        // fake messages by either:
55        //    a) Adding '&fakemsg' to the browser's URL while in edit mode.
56        //    b) Set the MOAIED_FAKE_MESSAGES constant to true in: lib/plugins/moaieditor/action.php
57        var messages = document.body.querySelectorAll('#dw__msgarea div.alert');
58        return messages;
59    }
60
61}; // End Class
62
63
64
65