Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelle committed Dec 16, 2023
1 parent 967f2c8 commit 12f1885
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autorelease-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Auto release
run: |
yarn add @actions/core
yarn add -W @actions/core
yarn autorelease-fork
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"homepage": ".",
"prettier": "@excalidraw/prettier-config",
"scripts": {
"setup": "yarn && cd src/packages/excalidraw && yarn",
"build-node": "node ./scripts/build-node.js",
"build:app:docker": "cross-env VITE_APP_DISABLE_SENTRY=true VITE_APP_DISABLE_TRACKING=true vite build",
"build:app": "cross-env VITE_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA vite build",
Expand Down
57 changes: 30 additions & 27 deletions packages/excalidraw/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,6 @@ class App extends React.Component<AppProps, AppState> {
}
UIOptions={this.props.UIOptions}
onExportImage={this.onExportImage}
onImageAction={this.onImageAction}
renderWelcomeScreen={
!this.state.isLoading &&
this.state.showWelcomeScreen &&
Expand Down Expand Up @@ -1773,14 +1772,18 @@ class App extends React.Component<AppProps, AppState> {
});

const blob = await exportToBlob({
elements: this.scene.getNonDeletedElements(),
appState: {
...this.state,
exportBackground: true,
viewBackgroundColor: this.state.viewBackgroundColor,
data: {
elements: this.scene.getNonDeletedElements(),
appState: {
...this.state,
exportBackground: true,
viewBackgroundColor: this.state.viewBackgroundColor,
},
files: this.files,
},
config: {
exportingFrame: magicFrame,
},
exportingFrame: magicFrame,
files: this.files,
});

const dataURL = await getDataURL(blob);
Expand Down Expand Up @@ -2392,25 +2395,25 @@ class App extends React.Component<AppProps, AppState> {

this.onChangeEmitter.destroy();

this.scene = new Scene();
this.history = new History();
this.actionManager = new ActionManager(
this.syncActionResult,
() => this.state,
() => this.scene.getElementsIncludingDeleted(),
this,
);
this.library = new Library(this);
// @ts-ignore
this.canvas = null;
this.interactiveCanvas = null;
// @ts-ignore
this.rc = null;

// @ts-ignore
this.excalidrawContainerRef.current = undefined;
this.nearestScrollableContainer = undefined;
this.excalidrawContainerValue = { container: null, id: "unmounted" };
if (import.meta.env.mode === ENV.PRODUCTION) {
this.history = new History();
this.library = new Library(this);
this.actionManager = new ActionManager(
this.syncActionResult,
() => this.state,
() => this.scene.getElementsIncludingDeleted(),
this,
);
// @ts-ignore
this.canvas = null;
this.interactiveCanvas = null;
// @ts-ignore
this.rc = null;
// @ts-ignore
this.excalidrawContainerRef.current = undefined;
this.nearestScrollableContainer = undefined;
this.excalidrawContainerValue = { container: null, id: "unmounted" };
}

clearTimeout(touchTimeout);
isSomeElementSelected.clearCache();
Expand Down
16 changes: 10 additions & 6 deletions packages/excalidraw/components/TTDDialog/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,16 @@ export const convertMermaidToExcalidraw = async ({
};

const canvas = await exportToCanvas({
elements: data.current.elements,
files: data.current.files,
exportPadding: DEFAULT_EXPORT_PADDING,
maxWidthOrHeight:
Math.max(parent.offsetWidth, parent.offsetHeight) *
window.devicePixelRatio,
data: {
elements: data.current.elements,
files: data.current.files,
},
config: {
padding: DEFAULT_EXPORT_PADDING,
maxWidthOrHeight:
Math.max(parent.offsetWidth, parent.offsetHeight) *
window.devicePixelRatio,
},
});
// if converting to blob fails, there's some problem that will
// likely prevent preview and export (e.g. canvas too big)
Expand Down
4 changes: 4 additions & 0 deletions packages/excalidraw/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,7 @@ export { exportToCanvas } from "./scene/export";

export * as icons from "./components/icons";
export * as actions from "./actions/index";

export { duplicateElements, duplicateElement } from "./element/newElement";

export { parseMermaidToExcalidraw } from "@excalidraw/mermaid-to-excalidraw";
12 changes: 11 additions & 1 deletion packages/excalidraw/main.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
module.exports = require("./dist/excalidraw.production.min.js");
if (process.env.IS_PREACT === "true") {
if (process.env.NODE_ENV === "production") {
module.exports = require("./dist/excalidraw-with-preact.production.min.js");
} else {
module.exports = require("./dist/excalidraw-with-preact.development.js");
}
} else if (process.env.NODE_ENV === "production") {
module.exports = require("./dist/excalidraw.production.min.js");
} else {
module.exports = require("./dist/excalidraw.development.js");
}
3 changes: 2 additions & 1 deletion packages/utils/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import * as mockedSceneExportUtils from "../excalidraw/scene/export";

import { MIME_TYPES } from "../excalidraw/constants";

import { exportToCanvas } from "../../scene/export";
const { exportToCanvas } = mockedSceneExportUtils;

const exportToSvgSpy = vi.spyOn(mockedSceneExportUtils, "exportToSvg");

describe("exportToCanvas", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
copyTextToSystemClipboard,
copyToClipboard,
} from "../excalidraw/clipboard";
import { getNonDeletedElements } from "../excalidraw";
import { getNonDeletedElements } from "../excalidraw/element";

export { MIME_TYPES };

Expand Down
2 changes: 1 addition & 1 deletion scripts/autorelease-fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require("fs");
const { execSync } = require("child_process");
const core = require("@actions/core");

const excalidrawDir = `${__dirname}/../src/packages/excalidraw`;
const excalidrawDir = `${__dirname}/../packages/excalidraw`;
const excalidrawPackage = `${excalidrawDir}/package.json`;
const pkg = require(excalidrawPackage);

Expand Down

0 comments on commit 12f1885

Please sign in to comment.