Mediawiki - добавить кнопку СОЗДАНИЕ СТРАНИЦЫ в WikiEditor редаторе

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2026
Перейти к:навигация, поиск

Mediawiki - добавить кнопку СОЗДАНИЕ СТРАНИЦЫ в WikiEditor редаторе

Добавить в MediaWiki:Common.js:

mw.loader.using('ext.wikiEditor').then(function () {
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'insert',
        tools: {
            newarticle: {
                label: 'Статья',
                type: 'button',
                icon: 'data:image/svg+xml;utf8,' + encodeURIComponent(
                    '<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22">' +
                    '<rect x="4" y="3" width="14" height="16" rx="2" fill="#36c"/>' +
                    '<path d="M8 7h6M8 10h6M8 13h4" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/>' +
                    '<path d="M14.5 15.5l2-2 1 1-2 2-1.5.5z" fill="#fff"/>' +
                    '</svg>'
                ),
                action: {
                    type: 'callback',
                    execute: function () {
                        var d = new Date();
                        var day = String(d.getDate()).padStart(2, '0');
                        var month = String(d.getMonth() + 1).padStart(2, '0');
                        var year = d.getFullYear();

                        $('#wpTextbox1').textSelection('encapsulateSelection', {
                            pre: '💬 [[',
                            peri: 'НАЗВАНИЕ',
                            post: ' - ' + day + '/' + month + '/' + year + ']] <br>'
                        });
                    }
                }
            }
        }
    });
});
×
Реклама
ИКС