e-Spirit / javascript-content-api-library

Apache License 2.0
7 stars 11 forks source link

CaaSMapper can't handle empty table cells #128

Closed samo4b closed 1 year ago

samo4b commented 1 year ago

Hi, we are having an issue with empty table cells after using the "merge" and "split" function of the CMS_INPUT_DOMTABLE (or basically also when leaving one cell empty). CMS Template:

<CMS_INPUT_DOMTABLE
    name="st_table"
    bold="yes"
    combine="yes"
    hFill="yes"
    italic="yes"
    list="no"
    properties="no"
    useLanguages="yes">
    <FORMATS>
      <TEMPLATE name="p"/>
    </FORMATS>
    <LANGINFOS>
      <LANGINFO lang="*" label="Table"/>
      <LANGINFO lang="DE_DE" label="Tabelle"/>
    </LANGINFOS>
  </CMS_INPUT_DOMTABLE>

When we access the page in the FSXA-PWA application on the front end we get this error:

ERROR   ERROR  CaaSMapper | [XMLParser]: Error parsing XML | {} | <table data-fs-style=""><tr><td>12</td><td>23</td><td>&nbsp;</td></tr><tr><td>ABC</td><td>B</td><td>C</td></tr><tr><td>X</td><td>YZ</td><td>Z</td></tr></table>  

I think the CaaSMapper cannot handle  

Steps to reproduce:

  1. Merge 2 cells into 1 by using the "Merge cells" function image

  2. Split one cell back into 2 cells (notice one of them is empty) image

  3. Result how it looks like in the FirstSpirit SiteArchitect image

As for the front end part I just passed the payload with st_table to my custom component and do the iteration myself because FSXARichText does include empty

elements where I don't want them. Below the example code which is not really needed because the error does happen within CaaSMapper before it reaches the front end. The example code does not resemble what is finally being used in the application because I removed additional functions and styling.

<template>
    <table>
      <tbody>
        <tr
          v-for="(row, rIndex) in table"
          :key="rIndex"
        >
          <td
            v-for="(cell, cIndex) in row.content"
            :key="`${rIndex}-${cIndex}`"
          >
            <component
              :is="elements[data.type]"
              v-for="(data, dIndex) in cell.content"
              :key="`${rIndex}-${cIndex}-${dIndex}`"
              v-bind="bindData(data)"
            />
          </td>
        </tr>
      </tbody>
    </table>
</template>

<script lang="ts">
get table () {
  return this.payload.st_table
}
</script>

Can you check if you can reproduce and fix the issue?

phillmund commented 1 year ago

We can reproduce this error as well. It seems the CaaS-Mapper is creating &nbsp; for empty table cells, that the sax parser, that is used under the hood, can't handle (it needs real XML entities) and throws an error. But we get the right structure to the frontend to display the table.

phillmund commented 1 year ago

@samo4b Maybe this is the error, that your frontend is not rendering: https://github.com/e-Spirit/fsxa-api/issues/129 ;-)

nico-mcalley commented 1 year ago

I agree, this behavior looks like a bug in the CaaSMapper. We created an internal ticket for this issue and will handle it. Any update on our internal Ticket will be synchronized here. Thank you @samo4b for your for the reproduction, that helped a lot 👍

lksmsr commented 1 year ago
nico-mcalley commented 1 year ago

PR #130 has been released. @samo4b it should fix your problem. Don't forget to update also the other fsxa dependencies accordingly.