this._editor.button.toggle({}, 'woltlab-spoiler', 'func', 'block.format');
var spoiler = this._editor.selection.block();
- if (spoiler && spoiler.nodeName === 'WOLTLAB-SPOILER') {
- this._setTitle(spoiler);
-
- spoiler.addEventListener(WCF_CLICK_EVENT, this._callbackEdit);
-
- // work-around for Safari
- this._editor.caret.end(spoiler);
+ if (spoiler) {
+ // iOS Safari might set the caret inside the spoiler.
+ if (spoiler.nodeName === 'P') {
+ spoiler = spoiler.parentNode;
+ }
+
+ if (spoiler.nodeName === 'WOLTLAB-SPOILER') {
+ this._setTitle(spoiler);
+
+ spoiler.addEventListener(WCF_CLICK_EVENT, this._callbackEdit);
+
+ // work-around for Safari
+ this._editor.caret.end(spoiler);
+ }
}
},
};
return UiRedactorSpoiler;
-});
\ No newline at end of file
+});