getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

[v4] Selecting spesific custom `writerMarks` doesn't work #5731

Closed afbora closed 1 year ago

afbora commented 1 year ago

I'm not sure this is a bug or I'm missing some setup. Selecting spesific custom writerMarks doesn't work for writer field.

Plugin

panel.plugin("my/writer-mark", {
  writerMarks: {
    smile: {
      get button() {
        return {
          icon: "smile",
          label: "Smile"
        }
      }
    }
  }
});

Blueprint

fields:
  writer:
    type: writer
    marks:
      - bold
      - smile
    toolbar:
      inline: false
      marks:
        - bold
        - smile

Result

screen-capture-1691-Test - Mægazine-localhost

Additional Context

I can see the button when marks: true

fields:
  writer:
    type: writer
    marks: true
    toolbar:
      inline: false

screen-capture-1692-Test - Mægazine-localhost

Kirby 4.0.0-beta.2

afbora commented 1 year ago

As workaround, all custom writer mark plugin should has name getter like following. I've fixed in this PR https://github.com/getkirby/kirby/pull/5733

panel.plugin("my/writer-mark", {
  writerMarks: {
    smile: {
      get name() {
        return "smile"
      },
      get button() {
        return {
          icon: "smile",
          label: "Smile"
        }
      }
    }
  }
});
distantnative commented 1 year ago

@afbora The fix could also be in our plugin registry to inject this getter for any custom Maribor node that does not define it itself

afbora commented 1 year ago

@distantnative I don't know exactly what you mean by "Maribor node". Do you mean the writerNodes extension where we register the custom nodes for writer field?

distantnative commented 1 year ago

I shouldn't write from y phone 🙈 "for any custom mark or node"