mosaico icon indicating copy to clipboard operation
mosaico copied to clipboard

Console.error while i import a Mosaico JSON with the "importJSON" method

Open korosaitama opened this issue 8 years ago • 3 comments

Hi!

Im trying to import an email JSON content with the method .importJSON() of the mosaico view model (recovered by a Mosaico init custom plugin). It works but i receive the following error:

mosaico importjson error

The imported JSON is an export of a previous email. It's something like:

// Import the email
var old_email_json = old_mail_mosaico_view_model.exportJSON();

// Save the JSON on the Database and move to a new context (like a new page)...
...

// Import the saved email
new_mosaico_view_model.importJSON(old_email_json )

I have been trying many variation of the JSON to import like:

  • Import the JSON + metadata
  • Import the same init's JSON (with the JSON + metadata string format)
  • Import the JSON + metadata in string format

But none of them works...

What should i do? Thanks for the help!

korosaitama avatar Feb 10 '17 08:02 korosaitama

versafix-1? custom template? mosaico version? custom mosaico changes? is the error blocking? Or you get it loaded correctly beside the logged error?

bago avatar Feb 10 '17 10:02 bago

Yeah, versafix-1 with some little changes at the footer (I remove the sponsor part):

versafix-1 footer:

<!-- footerBlock -->
  <table width="100%" cellpadding="0" border="0" cellspacing="0" bgcolor="#3f3f3f"
    style="background-color: #3f3f3f; -ko-background-color: @backgroundColor; -ko-attr-bgcolor: @backgroundColor"  data-ko-block="footerBlock">
    <tr>
      <td align="center" valign="top" bgcolor="#3f3f3f" style="background-color: #3f3f3f;
        -ko-attr-bgcolor: @backgroundColor; -ko-background-color: @backgroundColor">

<!--[if (gte mso 9)|(lte ie 8)]><table align="center" border="0" cellspacing="0" cellpadding="0" width="570"><tr><td align="center" valign="top"><![endif]-->
        <div class="oldwebkit">
        <table width="570" style="width: 100%; max-width: 570px" border="0" cellpadding="0" cellspacing="9" class="vb-container halfpad" align="center">
          <tr>
            <td data-ko-editable="longText" class="long-text links-color" 
                style="text-align:center; font-size: 13px;color: #919191; font-weight: normal; text-align:center; font-family: Arial, Helvetica, sans-serif;
                -ko-font-size: @[longTextStyle.size]px; -ko-color: @longTextStyle.color; -ko-font-family: @longTextStyle.face"><p>Email sent to <a href="mailto:[mail]">[mail]</a></p></td>
          </tr>
          <tr>
            <td style="text-align: center;">
              <a style="text-decoration: underline; color: #ffffff; text-align: center; font-size: 13px; 
                font-weight: normal; font-family: Arial, Helvetica, sans-serif;
                -ko-text-decoration: @linkStyle.decoration; -ko-color: @[Color.readability(linkStyle.color, backgroundColor) gt 2 ? linkStyle.color : (Color.isReadable('#ffffff', backgroundColor) ? '#ffffff' : '#000000')]; -ko-font-size: @[linkStyle.size]px; -ko-font-family: @linkStyle.face"
                href="[unsubscribe_link]"><span data-ko-editable="disiscrivitiText">Unsubscribe</span></a>
            </td>
          </tr>

          <tr data-ko-display="_root_.sponsor.visible" style="display: none;text-align:center">
            <td align="center">
                <a href="" style="-ko-attr-href: @_root_.sponsor.url;"><img border="0" hspace="0" vspace="0" src="img/sponsor.gif" alt="sponsor"
                  style="Margin:auto;display:inline !important; -ko-attr-src: @_root_.sponsor.src; -ko-attr-alt: @_root_.sponsor.alt" /></a>
            </td>
          </tr>
        </table>
        </div>
<!--[if (gte mso 9)|(lte ie 8)]></td></tr></table><![endif]-->
      </td>
    </tr>
  </table>
  <!-- /footerBlock -->

My footer:

<!-- footerBlock -->
  <table width="100%" cellpadding="0" border="0" cellspacing="0" bgcolor="#3f3f3f"
    style="background-color: #3f3f3f; -ko-background-color: @backgroundColor; -ko-attr-bgcolor: @backgroundColor"  data-ko-block="footerBlock">
    <tr>
      <td align="center" valign="top" bgcolor="#3f3f3f" style="background-color: #3f3f3f;
        -ko-attr-bgcolor: @backgroundColor; -ko-background-color: @backgroundColor">

<!--[if (gte mso 9)|(lte ie 8)]><table align="center" border="0" cellspacing="0" cellpadding="0" width="570"><tr><td align="center" valign="top"><![endif]-->
        <div class="oldwebkit">
        <table width="570" style="width: 100%; max-width: 570px" border="0" cellpadding="0" cellspacing="9" class="vb-container halfpad" align="center">
          <tr>
            <td data-ko-editable="longText" class="long-text links-color" 
                style="text-align:center; font-size: 13px;color: #919191; font-weight: normal; text-align:center; font-family: Arial, Helvetica, sans-serif;
                -ko-font-size: @[longTextStyle.size]px; -ko-color: @longTextStyle.color; -ko-font-family: @longTextStyle.face"><p>Email sent to <a href="mailto:[mail]">[mail]</a></p></td>
          </tr>
          <tr>
            <td style="text-align: center;">
              <a style="text-decoration: underline; color: #ffffff; text-align: center; font-size: 13px; 
                font-weight: normal; font-family: Arial, Helvetica, sans-serif;
                -ko-text-decoration: @linkStyle.decoration; -ko-color: @[Color.readability(linkStyle.color, backgroundColor) gt 2 ? linkStyle.color : (Color.isReadable('#ffffff', backgroundColor) ? '#ffffff' : '#000000')]; -ko-font-size: @[linkStyle.size]px; -ko-font-family: @linkStyle.face"
                href="[unsubscribe_link]"><span data-ko-editable="disiscrivitiText">Unsubscribe</span></a>
            </td>
          </tr>

        </table>
        </div>
<!--[if (gte mso 9)|(lte ie 8)]></td></tr></table><![endif]-->
      </td>
    </tr>
  </table>
  <!-- /footerBlock -->

Other info:

  • Mosaico version: 0.16.0
  • No custom mosaico changes except for the Mosaico initialization: var ok = Mosaico.init({...}, plugins); for my Mosaico editor page
  • The error is not blocking
  • Despite the error, the JSON model is properly loaded and the editor still works (but i don't test all the Mosaico functions after the import)

korosaitama avatar Feb 10 '17 10:02 korosaitama

From my updated tests, the import works, but the undomanager doesn't work anymore and further editing on the model may show issues. Investigating...

bago avatar Aug 22 '17 15:08 bago