JackPyro / daggerheart

Other
3 stars 2 forks source link

Errors on various items #25

Open Rorrenoa opened 2 weeks ago

Rorrenoa commented 2 weeks ago

Hi, I just noticed that there is an error with some item classes. error

I suspect that this is because in the handlebars which call {{editor}} a class element is created which is separated by spaces. For example in item-card-sheet.hbs handlebars

Unfortunately I don't know enough about handlebars, but this probably affects the following files. leveling.hbs stats.hbs item-domain-sheet.hbs item-item-sheet.hbs item-weapon-sheet.hbs item-card-sheet.hbs

I tested the whole thing on v12 with the outstanding v12 PR. Maybe it will help you. Cheers

Rorrenoa commented 2 weeks ago

It seems that the Handlebars Helper from Foundry for the editor itself unfortunately does not allow you to define multiple CSS classes. I have now overwritten them with my own. That seems to work. Although I don't know if that is the best way to do it. Maybe it will help.

Handlebars.registerHelper("editor", function(content, options) {
  const { target, editable=true, button, engine="tinymce", collaborate=false, class: cssClass } = options.hash;
  const config = {name: target, value: content, button, collaborate, editable, engine};
  const element = foundry.applications.fields.createEditorInput(config);
  if ( cssClass ) {
    const classList = cssClass.split(" ");
    element.querySelector(".editor-content").classList.add(...classList);
    return new Handlebars.SafeString(element.outerHTML);
  }
});

Cheers