Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
korosaitama opened this issue Feb 10, 2017 · 3 comments
Assignees
Labels

Comments

@korosaitama
Copy link

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!

@bago
Copy link
Member

bago commented Feb 10, 2017

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

@korosaitama
Copy link
Author

korosaitama commented Feb 10, 2017

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)

@bago bago added the bug label Feb 10, 2017
@bago bago added this to the 0.16 milestone Feb 10, 2017
@bago bago modified the milestones: 0.16, 0.17 Mar 20, 2017
@bago bago changed the title Error while i import a Mosaico JSON with the "importJSON" method Console.error while i import a Mosaico JSON with the "importJSON" method Jun 21, 2017
@bago bago self-assigned this Aug 22, 2017
@bago
Copy link
Member

bago commented Aug 22, 2017

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 bago modified the milestones: 0.17, 0.18 Feb 28, 2018
bago added a commit that referenced this issue Apr 9, 2019
Includes minor improvements to logging/error handling.
See #279 (does not fix that issue, but this was part of the problem)
@bago bago removed this from the 0.18 milestone Apr 27, 2022
bago added a commit that referenced this issue Jun 10, 2022
When mosaico is loaded it also support updating an obsolete model to a newer template with additional properties, but "viewModel.importJSON" throw an error when the model is different from what is expected. Now viewModel.importJSON uses "checkModel" to update it when needed.
See #279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants