See https://www.woltlab.com/community/thread/301681-medien-einf%C3%BCgen-im-acp-funktioniert-nicht/
this.element = document.getElementById(elementId)!;
const insertButton = document.getElementById(`codemirror-${elementId}-page`)!;
- insertButton.addEventListener("click", (ev) => this._click(ev));
+ insertButton.addEventListener("click", () => this._click());
}
- private _click(event: MouseEvent): void {
- event.preventDefault();
-
+ private _click(): void {
UiPageSearch.open((pageID) => this._insert(pageID));
}
this._forceClipboard = true;
- if (this._options.ckeditor !== undefined) {
+ if (this._options.ckeditor === undefined) {
+ if (typeof this._options.buttonClass === "string") {
+ document.querySelectorAll<HTMLElement>(`.${this._options.buttonClass}`).forEach((button) => {
+ button.addEventListener("click", (event) => {
+ this._click(event);
+ });
+ });
+ }
+ } else {
const ckeditor = this._options.ckeditor;
listenToCkeditor(ckeditor.sourceElement).bbcode(({ bbcode }) => {
if (bbcode !== "media") {
<dd>
<div class="inputAddon">
<input type="text" id="wcfUiPageSearchInput" class="long">
- <a href="#" class="inputSuffix"><fa-icon name="search" solid></fa-icon></a>
+ <button type="button" class="button inputSuffix"><fa-icon name="search" solid></fa-icon></button>
</div>
</dd>
</dl>
background-color: var(--wcfEditorButtonBackground);
display: flex;
flex-wrap: wrap;
+ gap: 2px;
+ padding: 2px;
- > li {
+ li {
+ display: flex;
flex: 0 0 auto;
- margin-bottom: 1px;
+ }
- > a {
- color: var(--wcfEditorButtonText);
- display: block;
- font-size: 12px;
- outline: none;
- padding: 10px;
- text-align: center;
- font-weight: 400;
-
- &:hover {
- background-color: var(--wcfEditorButtonBackgroundActive);
- color: var(--wcfEditorButtonTextActive);
- }
+ :is(a, button) {
+ border-radius: var(--wcfBorderRadius);
+ color: var(--wcfEditorButtonText);
+ display: block;
+ font-size: 12px;
+ outline: none;
+ padding: 8px;
+ text-align: center;
+ font-weight: 400;
- .icon {
- color: inherit;
- }
+ &:hover {
+ background-color: var(--wcfEditorButtonBackgroundActive);
+ color: var(--wcfEditorButtonTextActive);
}
}
}
{if $boxType == 'html' || $boxType == 'tpl'}
<ul class="codemirrorToolbar">
- <li><a href="#" id="codemirror-content{@$languageID}-media" class="jsTooltip" title="{lang}wcf.editor.button.media{/lang}">{icon name='file'}</a></li>
- <li><a href="#" id="codemirror-content{@$languageID}-page" class="jsTooltip" title="{lang}wcf.editor.button.page{/lang}">{icon name='file-lines'}</a></li>
+ <li><button type="button" id="codemirror-content{@$languageID}-media" class="jsTooltip" title="{lang}wcf.editor.button.media{/lang}">{icon name='file'}</button></li>
+ <li><button type="button" id="codemirror-content{@$languageID}-page" class="jsTooltip" title="{lang}wcf.editor.button.page{/lang}">{icon name='file-lines'}</button></li>
</ul>
<script data-relocate="true">
require([
{if $pageType == 'html' || $pageType == 'tpl'}
<ul class="codemirrorToolbar">
- <li><a href="#" id="codemirror-{@$__pageContentID}-media" class="jsTooltip" title="{lang}wcf.editor.button.media{/lang}">{icon name='file'}</a></li>
- <li><a href="#" id="codemirror-{@$__pageContentID}-page" class="jsTooltip" title="{lang}wcf.editor.button.page{/lang}">{icon name='file-lines'}</a></li>
+ <li><button type="button" id="codemirror-{@$__pageContentID}-media" class="jsTooltip" title="{lang}wcf.editor.button.media{/lang}">{icon name='file'}</button></li>
+ <li><button type="button" id="codemirror-{@$__pageContentID}-page" class="jsTooltip" title="{lang}wcf.editor.button.page{/lang}">{icon name='file-lines'}</button></li>
</ul>
<script data-relocate="true">
{include file='mediaJavaScript'}
constructor(elementId) {
this.element = document.getElementById(elementId);
const insertButton = document.getElementById(`codemirror-${elementId}-page`);
- insertButton.addEventListener("click", (ev) => this._click(ev));
+ insertButton.addEventListener("click", () => this._click());
}
- _click(event) {
- event.preventDefault();
+ _click() {
UiPageSearch.open((pageID) => this._insert(pageID));
}
_insert(pageID) {
}, options);
super(options);
this._forceClipboard = true;
- if (this._options.ckeditor !== undefined) {
+ if (this._options.ckeditor === undefined) {
+ if (typeof this._options.buttonClass === "string") {
+ document.querySelectorAll(`.${this._options.buttonClass}`).forEach((button) => {
+ button.addEventListener("click", (event) => {
+ this._click(event);
+ });
+ });
+ }
+ }
+ else {
const ckeditor = this._options.ckeditor;
(0, Event_1.listenToCkeditor)(ckeditor.sourceElement).bbcode(({ bbcode }) => {
if (bbcode !== "media") {
<dd>
<div class="inputAddon">
<input type="text" id="wcfUiPageSearchInput" class="long">
- <a href="#" class="inputSuffix"><fa-icon name="search" solid></fa-icon></a>
+ <button type="button" class="button inputSuffix"><fa-icon name="search" solid></fa-icon></button>
</div>
</dd>
</dl>