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

Set the default values of the editor on load #238

Closed
anargiris opened this issue Mar 16, 2022 · 8 comments
Closed

Set the default values of the editor on load #238

anargiris opened this issue Mar 16, 2022 · 8 comments

Comments

@anargiris
Copy link

I want to set the default background color to white and the content width to 100% but haven't found a good way to do this yet. I am using React v17.0.2

The following code doesn't seem to work:

unlayer.setBodyValues({
  backgroundColor: "#e7e7e7",
  contentWidth: "500px", // or percent "50%"
  fontFamily: {
    label: "Helvetica",
    value: "'Helvetica Neue', Helvetica, Arial, sans-serif"
  },
  preheaderText: "Hello World"
});

This code seems to work for 1 second, then the styles are reset to the email editor's defaults:

emailEditorRef.current.editor.loadBlank({
          backgroundColor: "#fff",
        });

Has anyone found a solution to this?

@nkrmr
Copy link

nkrmr commented Mar 17, 2022

I have the same issue it is not possible to set a default backgroundColor.
The loadBlank doesn't work

@ryan-xin
Copy link

ryan-xin commented Mar 22, 2022

Found a way to use Events

            unlayerEditor.loadBlank({
              backgroundColor: "#f5f5f5",
            });
            unlayerEditor.addEventListener("design:loaded", () => {
              unlayerEditor.setBodyValues({
                backgroundColor: "#f5f5f5",
                contentWidth: "100%",
              });
            });

@brunolemos
Copy link
Member

@anargiris: This code seems to work for 1 second, then the styles are reset to the email editor's defaults:

emailEditorRef.current.editor.loadBlank({
 backgroundColor: "#fff",
});

@nkrmr: I have the same issue it is not possible to set a default backgroundColor.
The loadBlank doesn't work

The loadBlank(bodyValues) issue has been fixed.

About setBodyValues, the current recommendation is to call it either on design:loaded or editor:ready.
Thanks!

@brunolemos
Copy link
Member

As of v1.2.160 you can call .setBodyValues normally right after .loadDesign without the need of using an event.

@babycourageous
Copy link

Sorry to ping an old issue - but I'm not able to call setBodyValues on my editor

It appears it doesn't exist in the type definitions so get typescript error trying to access a function that doesn't exist.

image

You can see in the screenshot it isn't listed along with the other editor options/functions.
I'm currently using loadBlank as a workaround but would love to access setBodyValues.

Happy to start a new one if you feel it's necessary
Thanks!

@brunolemos
Copy link
Member

@babycourageous please make sure you are using the latest version, which is currently 1.7.9:

image

@babycourageous
Copy link

AH! 🤦 how did i miss that. I read my 1.7.8 as 1.7.9
oh - you sneaky little number. Thanks so much!

@ankit-plivo
Copy link

How can i set the title tag in the exported html . I am using like this

editorRef?.current?.editor.setBodyValues({
      preheaderText: 'hello world'
    })

version 1.7.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants