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

Excalidraw , insertExcalidraw() is not creating the Excalidraw node according to Excalidraw Props #3105

Open
hkkvo opened this issue Apr 5, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@hkkvo
Copy link

hkkvo commented Apr 5, 2024

Description

I'm trying to insert the custom Excalidraw node into Editor, using insertExcalidraw() by passing relevant Excalidraw Props
https://docs.excalidraw.com/docs/@excalidraw/excalidraw/api/props/,

Even though I'm passing proper Excalidraw Props, default Excalidraw is getting inserted into editor

result

Steps to Reproduce

// 1. Excalidraw Props according into Excalidraw  website

  const excalidrawProps = {
    key: ELEMENT_EXCALIDRAW,
    initialData: {
      appState: { zenModeEnabled: true, viewBackgroundColor: "#a5d8ff" },
      scrollToContent: true,
    },
  };
  



// 2. Inserting Excalidraw node into Editor
  
   <ToolbarButton
                onClick={async () => {
                  await insertExcalidraw(editor, excalidrawProps, {});
                }}
              >
    <Icons.excalidraw />
    </ToolbarButton>
              

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@hkkvo hkkvo added the bug Something isn't working label Apr 5, 2024
@hkkvo
Copy link
Author

hkkvo commented Apr 6, 2024

I found the props which is passed to excalidraw in Plate.js playground

apps/www/src/lib/plate/demo/values/excalidrawInitialData.ts

which is

data: {
      elements: [
        {
          type: "rectangle",
          version: 141,
          versionNonce: 361_174_001,
          isDeleted: false,
          id: "oDVXy8D6rom3H1-LLH2-f",
          fillStyle: "hachure",
          strokeWidth: 1,
          strokeStyle: "solid",
          roughness: 1,
          opacity: 100,
          angle: 0,
          x: 100.503_906_25,
          y: 93.675_781_25,
          strokeColor: "#000000",
          backgroundColor: "transparent",
          width: 186.472_656_25,
          height: 141.976_562_5,
          seed: 1_968_410_350,
          groupIds: [],
        },
        {
          id: "-xMIs_0jIFqvpx-R9UnaG",
          type: "ellipse",
          x: 300.570_312_5,
          y: 190.691_406_25,
          width: 198.218_75,
          height: 129.511_718_75,
          angle: 0,
          strokeColor: "#000000",
          backgroundColor: "transparent",
          fillStyle: "hachure",
          strokeWidth: 1,
          strokeStyle: "solid",
          roughness: 1,
          opacity: 100,
          groupIds: [],
          seed: 957_947_807,
          version: 47,
          versionNonce: 1_128_618_623,
          isDeleted: false,
        },
      ],
      state: {
        viewBackgroundColor: "#AFEEEE",
        currentItemFontFamily: 1,
        zenModeEnabled: true,
      },
      scrollToContent: false,
    }

There is a mismatch in props name between the @excalidraw/excalidraw and @udecode/plate-excalidraw

upon closer inspection I found, @udecode/plate-excalidraw plugin uses 0.16.1 version of the

@excalidraw/excalidraw but current version of @excalidraw/excalidraw is 0.17.3

Is there any possibility to update the current version of @excalidraw/excalidraw in @udecode/plate-excalidraw

@zbeyens
Copy link
Member

zbeyens commented Apr 6, 2024

PR's welcome

@dylans
Copy link
Collaborator

dylans commented Apr 27, 2024

We have a fix for this, will contribute next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants