MediaWiki: Editor.js: Unterschied zwischen den Versionen

Aus Joachim Camerarius (1500-1574)
Wechseln zu: Navigation, Suche
Keine Bearbeitungszusammenfassung
Markierungen: Manuelle Zurücksetzung Zurückgesetzt
Keine Bearbeitungszusammenfassung
Markierung: Manuelle Zurücksetzung
Zeile 1: Zeile 1:
// Check if we're in edit mode
let customizeToolbar = function () {
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
$('#wpTextbox1').wikiEditor('addToToolbar', {
     // Add a hook handler for WikiEditor toolbar
     //Create new toolbar section Camerarius which is itself a toolbar              
     mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
     sections: {
        $textarea.wikiEditor( 'addToToolbar', {
        camerarius: {
            sections: {
            type: 'toolbar',
                camerarius: {
            label: 'Camerarius-Attribute',
                    type: 'section',
            //Create dropdown part of the toolbar
                    label: 'Camerarius-Attribute',
            'groups': {
                    groups: {
                'format': {
                        attributes: {
                    'tools': {
                            tools: {
                        'Attribute': {
                                // Attribute Dropdown
                            'label': 'Attribute-Allgemein',
                                 attributeSelect: {
                            'type': 'select',
                                     type: 'element',
                            'list': {
                                     element: function ( context ) {
                                 'Auftraggeber': {
                                         var $select = $( '<select>' ).attr( 'id', 'camerarius-attribute-select' );
                                     'label': 'Auftraggeber',
                                          
                                     'action': {
                                         // Populate dropdown with attributes
                                         'type': 'encapsulate',
                                         var attributes = [
                                        'options': {
                                             { value: 'Auftraggeber', label: 'Auftraggeber' },
                                            'pre': '[[Auftraggeber::',
                                            { value: 'Beeinflusser', label: 'Beeinflusser' },
                                            'periMsg': 'Auftragsgeber',
                                             { value: 'Briefpartner', label: 'Briefpartner' },
                                            'post': ']]'
                                            { value: 'Erwähnte Körperschaft', label: 'Erwähnte Körperschaft' },
                                         }
                                            { value: 'Erwähnte Person', label: 'Erwähnte Person' },
                                    }
                                             { value: 'Erwähnter Ort', label: 'Erwähnter Ort' },
                                },
                                            { value: 'Erwähntes Werk', label: 'Erwähntes Werk' },
                                'Beeinflusser': {
                                             { value: 'Forschungsliteratur', label: 'Forschungsliteratur' },
                                    'label': 'Beeinflusser',
                                            { value: 'Gesprächspartner', label: 'Gesprächspartner' },
                                    'action': {
                                             { value: 'Initiator', label: 'Initiator' },
                                         'type': 'encapsulate',
                                             { value: 'Lehrer', label: 'Lehrer' },
                                         'options': {
                                            { value: 'Schüler', label: 'Schüler' },
                                            'pre': '[[Beeinflusser::',
                                             { value: 'Student', label: 'Student' },
                                             'periMsg': 'Beeinflusser',
                                            { value: 'Unterstützer', label: 'Unterstützer' },
                                            'post': ']]'
                                             { value: 'Werkadressat', label: 'Werkadressat' },
                                        }
                                             { value: 'Widmender', label: 'Widmender' },
                                    }
                                            { value: 'Widmungsempfänger', label: 'Widmungsempfänger' },
                                },
                                             { value: 'Nachrufempfänger', label: 'Nachrufempfänger' }
                                'Briefpartner': {
                                        ];
                                    'label': 'Briefpartner',
                                       
                                    'action': {
                                        attributes.forEach( function( attr ) {
                                        'type': 'encapsulate',
                                            $select.append( $( '<option>' ).val( attr.value ).text( attr.label ) );
                                        'options': {
                                        });
                                             'pre': '[[Briefpartner::',
                                          
                                            'periMsg': 'Briefpartner',
                                         // Add button to insert selected attribute
                                            'post': ']]'
                                        var insertButton = new OO.ui.ButtonWidget( {
                                        }
                                             label: 'Insert Attribute',
                                    }
                                             flags: [ 'progressive' ]
                                },
                                         });
                                'Erwähnte Körperschaft': {
                                          
                                    'label': 'Erwähnte Körperschaft',
                                         insertButton.on( 'click', function() {
                                    'action': {
                                             var selectedAttr = $select.val();
                                        'type': 'encapsulate',
                                            var insertText = '[[' + selectedAttr + '::]]';
                                        'options': {
                                            context.fn.insertText( insertText );
                                            'pre': '[[Erwähnte Körperschaft::',
                                        });
                                            'periMsg': 'Körperschaft',
                                          
                                            'post': ']]'
                                         return $( '<div>' )
                                        }
                                             .append( $select )
                                    }
                                             .append( insertButton.$element );
                                },
                                'Erwähnte Person': {
                                    'label': 'Erwähnte Person',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Erwähnte Person::',
                                            'periMsg': 'Adressat',
                                             'post': ']]'
                                        }
                                    }
                                },
                                'Erwähnter Ort': {
                                    'label': 'Erwähnter Ort',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Erwähnter Ort::',
                                             'periMsg': 'Ort',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Erwähntes Werk': {
                                    'label': 'Erwähntes Werk',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                             'pre': '[[Erwähntes Werk::',
                                            'periMsg': 'Erwähntes Werk',
                                             'post': ']]'
                                        }
                                    }
                                },
                                'Forschungsliteratur': {
                                    'label': 'Forschungsliteratur',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Forschungsliteratur::',
                                             'periMsg': 'Forschungsliteratur',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Gesprächspartner': {
                                    'label': 'Gesprächspartner',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                             'pre': '[[Gesprächspartner::',
                                            'periMsg': 'Gesprächspartner',
                                             'post': ']]'
                                        }
                                    }
                                },
                                'Initiator': {
                                    'label': 'Initiator',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Initiator::',
                                             'periMsg': 'Initiator',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Lehrer': {
                                    'label': 'Lehrer',
                                    'action': {
                                         'type': 'encapsulate',
                                         'options': {
                                             'pre': '[[Lehrer::',
                                             'periMsg': 'Lehrer',
                                            'post': ']]'
                                         }
                                    }
                                },
                                'Schüler': {
                                    'label': 'Schüler',
                                    'action': {
                                         'type': 'encapsulate',
                                         'options': {
                                             'pre': '[[Schüler::',
                                            'periMsg': 'Schüler',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Student': {
                                    'label': 'Student',
                                    'action': {
                                         'type': 'encapsulate',
                                         'options': {
                                            'pre': '[[Student::',
                                             'periMsg': 'Student',
                                             'post': ']]'
                                        }
                                     }
                                     }
                                 }
                                 },
                            }
                                'Unterstützer': {
                        },
                                    'label': 'Unterstützer',
                        specialButtons: {
                                    'action': {
                            tools: {
                                        'type': 'encapsulate',
                                // Beschreibungen Button
                                        'options': {
                                beschreibungenButton: {
                                            'pre': '[[Unterstützer::',
                                    type: 'button',
                                            'periMsg': 'Unterstützer',
                                    label: 'Beschreibungen',
                                            'post': ']]'
                                     icon: 'bold',
                                        }
                                     action: {
                                    }
                                         type: 'encapsulate',
                                },
                                         options: {
                                'Werkadressat': {
                                             pre: '{{Beschreibungen|',
                                     'label': 'Werkadressat',
                                             post: '}}'
                                     'action': {
                                         'type': 'encapsulate',
                                         'options': {
                                             'pre': '[[Werkadressat::',
                                            'periMsg': 'Adressat',
                                             'post': ']]'
                                         }
                                         }
                                     }
                                     }
                                 },
                                 },
                                 // MBW Button
                                 'Widmender': {
                                mbwButton: {
                                     'label': 'Widmender',
                                     type: 'button',
                                     'action': {
                                    label: 'MBW',
                                         'type': 'encapsulate',
                                     icon: 'link',
                                         'options': {
                                    action: {
                                             'pre': '[[Widmender::',
                                         type: 'encapsulate',
                                            'periMsg': 'Widmender',
                                         options: {
                                             'post': ']]'
                                             pre: '[https://melanchthon.hadw-bw.de/regesten.html MBW - Regesten online], Nr. ',
                                             post: ''
                                         }
                                         }
                                     }
                                     }
                                 },
                                 },
                                 // Link Button
                                 'Widmungsempfänger': {
                                linkButton: {
                                     'label': 'Widmungsempfänger',
                                     type: 'button',
                                     'action': {
                                    label: 'Verlinkung',
                                         'type': 'encapsulate',
                                     icon: 'linkExternal',
                                         'options': {
                                    action: {
                                             'pre': '[[Widmungsempfänger::',
                                         type: 'encapsulate',
                                             'periMsg': 'Widmungsempfänger',
                                         options: {
                                            'post': ']]'
                                             pre: '[[',
                                             post: ']]'
                                         }
                                         }
                                     }
                                     }
                                 },
                                 },
                                 // Binnenverweis Button
                                 'Nachrufempfänger': {
                                binnenverweisButton: {
                                     'label': 'Nachrufempfänger',
                                     type: 'button',
                                     'action': {
                                    label: 'Binnenverweis',
                                         'type': 'encapsulate',
                                     icon: 'redirect',
                                         'options': {
                                    action: {
                                             'pre': '[[Nachruf auf::',
                                         type: 'encapsulate',
                                             'periMsg': 'Nachruf auf',
                                         options: {
                                            'post': ']]'
                                             pre: '[[',
                                             post: ']]'
                                         }
                                         }
                                     }
                                     }
                                },
                            }
                        },
                        //Create the button parts
                        'Beschreibungen': {
                            'label': 'Beschreibungen',
                            'type': 'button',
                            'icon': {
                                'default': 'format-bold-B.png',
                                'en': 'format-bold-B.png',
                                'de': 'format-bold-B.png'
                            },
                            'action': {
                                'type': 'encapsulate',
                                'options': {
                                    'pre': "{{Beschreibungen|",
                                    'periMsg': 'Seitenname',
                                    'post': "}}"
                                }
                            }
                        },
                        'MBW': {
                            'label': 'MBW',
                            'type': 'button',
                            'icon': {
                                'default': 'https://upload.wikimedia.org/wikipedia/commons/5/54/Mbutton.png',
                                'en': 'https://upload.wikimedia.org/wikipedia/commons/5/54/Mbutton.png',
                                'de': 'https://upload.wikimedia.org/wikipedia/commons/5/54/Mbutton.png'
                            },
                            'action': {
                                'type': 'encapsulate',
                                'options': {
                                    'pre': "[https://melanchthon.hadw-bw.de/regesten.html MBW - Regesten online], Nr. ",
                                    'periMsg': 'Regestnr.'
                                }
                            }
                        },
                        'Link': {
                            'label': 'Verlinkung',
                            'type': 'button',
                            'icon': {
                                'default': 'insert-ilink.png',
                                'en': 'insert-ilink.png',
                                'de': 'insert-ilink.png'
                            },
                            'action': {
                                'type': 'encapsulate',
                                'options': {
                                    'pre': "[[",
                                    'periMsg': 'Text',
                                    'post': "]]"
                                }
                            }
                        },
                        'Binnenverweis': {
                            'label': 'Binnenverweis auf Lexikonseiten',
                            'type': 'button',
                            'icon': {
                                'default': 'https://upload.wikimedia.org/wikipedia/commons/1/13/Vector_toolbar_redirect_button.png',
                                'en': 'https://upload.wikimedia.org/wikipedia/commons/1/13/Vector_toolbar_redirect_button.png',
                                'de': 'https://upload.wikimedia.org/wikipedia/commons/1/13/Vector_toolbar_redirect_button.png'
                            },
                            'action': {
                                'type': 'encapsulate',
                                'options': {
                                    'pre': '[[',
                                    'periMsg': 'Lexikonseite#Kapitelname unformatiert|Kapitelname',
                                    'post': "]]"
                                 }
                                 }
                             }
                             }
Zeile 121: Zeile 285:
                 }
                 }
             }
             }
         });
         }
    });
    }
});
};
 
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options' ).then( function () {
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
).then( customizeToolbar );
}
} );
}
}

Version vom 6. Dezember 2024, 10:40 Uhr

let customizeToolbar = function () {
$('#wpTextbox1').wikiEditor('addToToolbar', {
    //Create new toolbar section Camerarius which is itself a toolbar               
    sections: {
        camerarius: {
            type: 'toolbar',
            label: 'Camerarius-Attribute',
            //Create dropdown part of the toolbar
            'groups': {
                'format': {
                    'tools': {
                        'Attribute': {
                            'label': 'Attribute-Allgemein',
                            'type': 'select',
                            'list': {
                                'Auftraggeber': {
                                    'label': 'Auftraggeber',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Auftraggeber::',
                                            'periMsg': 'Auftragsgeber',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Beeinflusser': {
                                    'label': 'Beeinflusser',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Beeinflusser::',
                                            'periMsg': 'Beeinflusser',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Briefpartner': {
                                    'label': 'Briefpartner',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Briefpartner::',
                                            'periMsg': 'Briefpartner',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Erwähnte Körperschaft': {
                                    'label': 'Erwähnte Körperschaft',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Erwähnte Körperschaft::',
                                            'periMsg': 'Körperschaft',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Erwähnte Person': {
                                    'label': 'Erwähnte Person',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Erwähnte Person::',
                                            'periMsg': 'Adressat',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Erwähnter Ort': {
                                    'label': 'Erwähnter Ort',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Erwähnter Ort::',
                                            'periMsg': 'Ort',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Erwähntes Werk': {
                                    'label': 'Erwähntes Werk',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Erwähntes Werk::',
                                            'periMsg': 'Erwähntes Werk',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Forschungsliteratur': {
                                    'label': 'Forschungsliteratur',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Forschungsliteratur::',
                                            'periMsg': 'Forschungsliteratur',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Gesprächspartner': {
                                    'label': 'Gesprächspartner',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Gesprächspartner::',
                                            'periMsg': 'Gesprächspartner',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Initiator': {
                                    'label': 'Initiator',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Initiator::',
                                            'periMsg': 'Initiator',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Lehrer': {
                                    'label': 'Lehrer',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Lehrer::',
                                            'periMsg': 'Lehrer',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Schüler': {
                                    'label': 'Schüler',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Schüler::',
                                            'periMsg': 'Schüler',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Student': {
                                    'label': 'Student',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Student::',
                                            'periMsg': 'Student',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Unterstützer': {
                                    'label': 'Unterstützer',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Unterstützer::',
                                            'periMsg': 'Unterstützer',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Werkadressat': {
                                    'label': 'Werkadressat',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Werkadressat::',
                                            'periMsg': 'Adressat',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Widmender': {
                                    'label': 'Widmender',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Widmender::',
                                            'periMsg': 'Widmender',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Widmungsempfänger': {
                                    'label': 'Widmungsempfänger',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Widmungsempfänger::',
                                            'periMsg': 'Widmungsempfänger',
                                            'post': ']]'
                                        }
                                    }
                                },
                                'Nachrufempfänger': {
                                    'label': 'Nachrufempfänger',
                                    'action': {
                                        'type': 'encapsulate',
                                        'options': {
                                            'pre': '[[Nachruf auf::',
                                            'periMsg': 'Nachruf auf',
                                            'post': ']]'
                                        }
                                    }
                                },
                            }
                        },
                        //Create the button parts
                        'Beschreibungen': {
                            'label': 'Beschreibungen',
                            'type': 'button',
                            'icon': {
                                'default': 'format-bold-B.png',
                                'en': 'format-bold-B.png',
                                'de': 'format-bold-B.png'
                            },
                            'action': {
                                'type': 'encapsulate',
                                'options': {
                                    'pre': "{{Beschreibungen|",
                                    'periMsg': 'Seitenname',
                                    'post': "}}"
                                }
                            }
                        },
                        'MBW': {
                            'label': 'MBW',
                            'type': 'button',
                            'icon': {
                                'default': 'https://upload.wikimedia.org/wikipedia/commons/5/54/Mbutton.png',
                                'en': 'https://upload.wikimedia.org/wikipedia/commons/5/54/Mbutton.png',
                                'de': 'https://upload.wikimedia.org/wikipedia/commons/5/54/Mbutton.png'
                            },
                            'action': {
                                'type': 'encapsulate',
                                'options': {
                                    'pre': "[https://melanchthon.hadw-bw.de/regesten.html MBW - Regesten online], Nr. ",
                                    'periMsg': 'Regestnr.'
                                }
                            }
                        },
                        'Link': {
                            'label': 'Verlinkung',
                            'type': 'button',
                            'icon': {
                                'default': 'insert-ilink.png',
                                'en': 'insert-ilink.png',
                                'de': 'insert-ilink.png'
                            },
                            'action': {
                                'type': 'encapsulate',
                                'options': {
                                    'pre': "[[",
                                    'periMsg': 'Text',
                                    'post': "]]"
                                }
                            }
                        },
                        'Binnenverweis': {
                            'label': 'Binnenverweis auf Lexikonseiten',
                            'type': 'button',
                            'icon': {
                                'default': 'https://upload.wikimedia.org/wikipedia/commons/1/13/Vector_toolbar_redirect_button.png',
                                'en': 'https://upload.wikimedia.org/wikipedia/commons/1/13/Vector_toolbar_redirect_button.png',
                                'de': 'https://upload.wikimedia.org/wikipedia/commons/1/13/Vector_toolbar_redirect_button.png'
                            },
                            'action': {
                                'type': 'encapsulate',
                                'options': {
                                    'pre': '[[',
                                    'periMsg': 'Lexikonseite#Kapitelname unformatiert|Kapitelname',
                                    'post': "]]"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
});
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
			).then( customizeToolbar );
		}
	} );
}