|
1
|
|
|
jQuery(() => { |
|
2
|
|
|
|
|
3
|
|
|
const $toggleEditorButton = jQuery('.plugin_prosemirror_useWYSIWYG'); |
|
4
|
|
|
$toggleEditorButton.on('click', function() { |
|
5
|
|
|
const $current = DokuCookie.getValue('plugin_prosemirror_useWYSIWYG'); |
|
|
|
|
|
|
6
|
|
|
DokuCookie.setValue('plugin_prosemirror_useWYSIWYG', $current ? '' : '1'); |
|
7
|
|
|
}); |
|
8
|
|
|
|
|
9
|
|
|
const $jsonField = jQuery('#dw__editform').find('[name=prosemirror_json]'); |
|
10
|
|
|
if (!$jsonField.length) { |
|
11
|
|
|
return; |
|
12
|
|
|
} |
|
13
|
|
|
$jsonField.attr('id', 'prosemirror_json'); |
|
14
|
|
|
|
|
15
|
|
|
try { |
|
|
|
|
|
|
16
|
|
|
/* DOKUWIKI:include lib/bundle.js */ |
|
17
|
|
|
} catch (e) { |
|
|
|
|
|
|
18
|
|
|
const $textArea = jQuery('#wiki__text'); |
|
|
|
|
|
|
19
|
|
|
let message = 'There was an error in the WYSIWYG editor. You will be redirected to the syntax editor in 5 seconds.'; |
|
|
|
|
|
|
20
|
|
|
if (window.SentryPlugin) { |
|
21
|
|
|
SentryPlugin.logSentryException(e, { |
|
22
|
|
|
tags: { |
|
23
|
|
|
plugin: 'prosemirror', |
|
24
|
|
|
'id': JSINFO.id, |
|
25
|
|
|
}, |
|
26
|
|
|
extra: { |
|
27
|
|
|
'content': $textArea.val(), |
|
28
|
|
|
} |
|
29
|
|
|
}); |
|
30
|
|
|
message += ' The error has been logged to sentry.'; |
|
31
|
|
|
} |
|
32
|
|
|
$textArea.replaceWith('<div class="error">'+ message + '</div>'); |
|
33
|
|
|
setTimeout(function() { |
|
34
|
|
|
$toggleEditorButton.click(); |
|
|
|
|
|
|
35
|
|
|
}, 5000); |
|
36
|
|
|
return; |
|
37
|
|
|
} |
|
38
|
|
|
dw_locktimer.init(dw_locktimer.timeout, dw_locktimer.draft, 'prosemirror__editor'); |
|
|
|
|
|
|
39
|
|
|
dw_locktimer.addField('input[name=prosemirror_json]'); |
|
40
|
|
|
dw_locktimer.addRefreshCallback(function prosemirrorCallback() { |
|
41
|
|
|
const $errors = jQuery('#draft__status .js-prosemirror-draft-errors'); |
|
42
|
|
|
if ($errors.length) { |
|
43
|
|
|
jQuery('#draft__status').before($errors.html()); |
|
44
|
|
|
$errors.remove(); |
|
45
|
|
|
} |
|
46
|
|
|
}); |
|
47
|
|
|
|
|
48
|
|
|
jQuery('#wiki__text').hide(); |
|
49
|
|
|
jQuery('#size__ctl').hide(); |
|
50
|
|
|
jQuery('.editBox > .toolbar').hide(); |
|
51
|
|
|
}); |
|
52
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.