Hi there,
I’m trying to create a custom textarea button. I just used the sample and it doesn’t work.
The plugin correctly appears in the system panel view.
index.js :
window.panel.plugin("adrienpayet/panel-text-comments", {
textareaButtons: {
highlight: {
label: "Highlight",
icon: "wand",
click: function () {
this.command("toggle", "<mark>", "</mark>");
},
shortcut: "m",
},
},
});
The blueprint :
fields:
edito:
type: textarea
buttons:
- highlight
I also declared the plugin in its index.php :
<?php
Kirby::plugin('adrienpayet/panel-text-comments', []);
Is there any mistake ?
1 Like
The one thing I see that I don’t think is right is that you don’t need window.panel.plugin...
which should just be panel.plugin("adrienpayet/panel-text-comments", {
etc.
There’s an open bug about textareaButtons because if you use them in more than one textarea field in a single blueprint, it causes the page to endlessly spiral.
I’ve noticed that too.
As soon as I integrate my custom button, my backend freezes
I did it exactly the same way
Any Updates on this one?
edit:
The error occurs as soon as more than one text area contains a custom button.
Think that’s a bug.
I was browsing the forum today and found a similar issue, where the Kirby sanitizer needs to be prepared for the custom button.
Maybe it helps someone here:
The docs should probably mention this. But “unknown” (to Kirby) tags are filtered out by the sanitizer.
You can allow tags in your plugin’s index.php
<?php
Kirby\Sane\Html::$allowedTags['mark'] = true;
Kirby::plugin('mark/eg', [
// ...
]);