aboutsummaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ckeditor/plugins/studip-wiki/dialogs/wikilink.js
blob: 2e868483d0f641386201d089cd54efa2ce1722be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
CKEDITOR.dialog.add('wikiDialog', function (editor) {
    // studip wiki link specification
    // * allowed characters: a-z.-:()_§/@# äöüß
    // * enclose in double-brackets: [[wiki link]]
    // * leading or trailing whitespace is allowed!!
    // * extended: [[wiki link| displayed text]]
    // * displayed text characters can be anything but ]

    // dialog
    var lang = editor.lang['studip-wiki'];
    return {
        title: lang.dialogTitle,
        minWidth: 400,
        minHeight: 200,
        contents: [{
            id: 'tab-link',
            label: 'Stud.IP-Wiki Link',
            elements: [{
                type: 'text',
                id: 'wikipage',
                label: lang.pageNameLabel,
                // TODO regex encoding is not working correctly
                // ==> german umlauts cannot be entered using the wiki widget
                // ==> users have to manually enter wikilinks with umlauts atm.
                validate: CKEDITOR.dialog.validate.regex(
                    /^[\w\.\-\:\(\)§\/@# ÄÖÜäöüß]+$/i,
                    lang.invalidPageName
                ),
                setup: function(widget) {
                    this.setValue(widget.data.link);
                },
                commit: function(widget) {
                    widget.setData('link', this.getValue().trim());
                }
            }, {
                type: 'text',
                id: 'usertext',
                label: lang.displayTextLabel,
                validate: CKEDITOR.dialog.validate.regex(
                    /^[^\]]*$/i,
                    lang.invalidDisplayText
                ),
                setup: function(widget) {
                    this.setValue(widget.data.text);
                },
                commit: function(widget) {
                    widget.setData('text', this.getValue().trim());
                }
            }]
        }]
    };
});