Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cacfc7a0b0 |
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM node:18 AS build
|
FROM node:14-alpine AS build
|
||||||
|
|
||||||
WORKDIR /opt/node_app
|
WORKDIR /opt/node_app
|
||||||
|
|
||||||
|
|||||||
@@ -1843,6 +1843,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
componentDidUpdate(prevProps: AppProps, prevState: AppState) {
|
componentDidUpdate(prevProps: AppProps, prevState: AppState) {
|
||||||
this.updateEmbeddables();
|
this.updateEmbeddables();
|
||||||
|
console.log("HEYYY BEFORE VITE AUTOMATIC RELOAD!!");
|
||||||
if (
|
if (
|
||||||
!this.state.showWelcomeScreen &&
|
!this.state.showWelcomeScreen &&
|
||||||
!this.scene.getElementsIncludingDeleted().length
|
!this.scene.getElementsIncludingDeleted().length
|
||||||
|
|||||||
+11
-37
@@ -162,52 +162,23 @@ const fillCircle = (
|
|||||||
const strokeGrid = (
|
const strokeGrid = (
|
||||||
context: CanvasRenderingContext2D,
|
context: CanvasRenderingContext2D,
|
||||||
gridSize: number,
|
gridSize: number,
|
||||||
scrollX: number,
|
offsetX: number,
|
||||||
scrollY: number,
|
offsetY: number,
|
||||||
zoom: Zoom,
|
|
||||||
width: number,
|
width: number,
|
||||||
height: number,
|
height: number,
|
||||||
) => {
|
) => {
|
||||||
const BOLD_LINE_FREQUENCY = 5;
|
|
||||||
|
|
||||||
enum GridLineColor {
|
|
||||||
Bold = "#cccccc",
|
|
||||||
Regular = "#e5e5e5",
|
|
||||||
}
|
|
||||||
|
|
||||||
const offsetX =
|
|
||||||
-Math.round(zoom.value / gridSize) * gridSize + (scrollX % gridSize);
|
|
||||||
const offsetY =
|
|
||||||
-Math.round(zoom.value / gridSize) * gridSize + (scrollY % gridSize);
|
|
||||||
|
|
||||||
const lineWidth = Math.min(1 / zoom.value, 1);
|
|
||||||
|
|
||||||
const spaceWidth = 1 / zoom.value;
|
|
||||||
const lineDash = [lineWidth * 3, spaceWidth + (lineWidth + spaceWidth)];
|
|
||||||
|
|
||||||
context.save();
|
context.save();
|
||||||
context.lineWidth = lineWidth;
|
context.strokeStyle = "rgba(0,0,0,0.1)";
|
||||||
|
context.beginPath();
|
||||||
for (let x = offsetX; x < offsetX + width + gridSize * 2; x += gridSize) {
|
for (let x = offsetX; x < offsetX + width + gridSize * 2; x += gridSize) {
|
||||||
const isBold =
|
|
||||||
Math.round(x - scrollX) % (BOLD_LINE_FREQUENCY * gridSize) === 0;
|
|
||||||
context.beginPath();
|
|
||||||
context.setLineDash(isBold ? [] : lineDash);
|
|
||||||
context.strokeStyle = isBold ? GridLineColor.Bold : GridLineColor.Regular;
|
|
||||||
context.moveTo(x, offsetY - gridSize);
|
context.moveTo(x, offsetY - gridSize);
|
||||||
context.lineTo(x, offsetY + height + gridSize * 2);
|
context.lineTo(x, offsetY + height + gridSize * 2);
|
||||||
context.stroke();
|
|
||||||
}
|
}
|
||||||
for (let y = offsetY; y < offsetY + height + gridSize * 2; y += gridSize) {
|
for (let y = offsetY; y < offsetY + height + gridSize * 2; y += gridSize) {
|
||||||
const isBold =
|
|
||||||
Math.round(y - scrollY) % (BOLD_LINE_FREQUENCY * gridSize) === 0;
|
|
||||||
context.beginPath();
|
|
||||||
context.setLineDash(isBold ? [] : lineDash);
|
|
||||||
context.strokeStyle = isBold ? GridLineColor.Bold : GridLineColor.Regular;
|
|
||||||
context.moveTo(offsetX - gridSize, y);
|
context.moveTo(offsetX - gridSize, y);
|
||||||
context.lineTo(offsetX + width + gridSize * 2, y);
|
context.lineTo(offsetX + width + gridSize * 2, y);
|
||||||
context.stroke();
|
|
||||||
}
|
}
|
||||||
|
context.stroke();
|
||||||
context.restore();
|
context.restore();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -454,9 +425,12 @@ export const _renderScene = ({
|
|||||||
strokeGrid(
|
strokeGrid(
|
||||||
context,
|
context,
|
||||||
appState.gridSize,
|
appState.gridSize,
|
||||||
renderConfig.scrollX,
|
-Math.ceil(renderConfig.zoom.value / appState.gridSize) *
|
||||||
renderConfig.scrollY,
|
appState.gridSize +
|
||||||
renderConfig.zoom,
|
(renderConfig.scrollX % appState.gridSize),
|
||||||
|
-Math.ceil(renderConfig.zoom.value / appState.gridSize) *
|
||||||
|
appState.gridSize +
|
||||||
|
(renderConfig.scrollY % appState.gridSize),
|
||||||
normalizedCanvasWidth / renderConfig.zoom.value,
|
normalizedCanvasWidth / renderConfig.zoom.value,
|
||||||
normalizedCanvasHeight / renderConfig.zoom.value,
|
normalizedCanvasHeight / renderConfig.zoom.value,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,18 +15,6 @@ import Scene from "./Scene";
|
|||||||
|
|
||||||
export const SVG_EXPORT_TAG = `<!-- svg-source:excalidraw -->`;
|
export const SVG_EXPORT_TAG = `<!-- svg-source:excalidraw -->`;
|
||||||
|
|
||||||
const createScene = (
|
|
||||||
elements: readonly NonDeletedExcalidrawElement[],
|
|
||||||
): Scene | null => {
|
|
||||||
if (!elements || Scene.getScene(elements[0])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const scene = new Scene();
|
|
||||||
scene.replaceAllElements(elements);
|
|
||||||
elements?.forEach((el) => Scene.mapElementToScene(el, scene));
|
|
||||||
return scene;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const exportToCanvas = async (
|
export const exportToCanvas = async (
|
||||||
elements: readonly NonDeletedExcalidrawElement[],
|
elements: readonly NonDeletedExcalidrawElement[],
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
@@ -50,7 +38,6 @@ export const exportToCanvas = async (
|
|||||||
return { canvas, scale: appState.exportScale };
|
return { canvas, scale: appState.exportScale };
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
const scene = createScene(elements);
|
|
||||||
const [minX, minY, width, height] = getCanvasSize(elements, exportPadding);
|
const [minX, minY, width, height] = getCanvasSize(elements, exportPadding);
|
||||||
|
|
||||||
const { canvas, scale = 1 } = createCanvas(width, height);
|
const { canvas, scale = 1 } = createCanvas(width, height);
|
||||||
@@ -92,7 +79,6 @@ export const exportToCanvas = async (
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
scene?.destroy();
|
|
||||||
return canvas;
|
return canvas;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,7 +105,6 @@ export const exportToSvg = async (
|
|||||||
exportScale = 1,
|
exportScale = 1,
|
||||||
exportEmbedScene,
|
exportEmbedScene,
|
||||||
} = appState;
|
} = appState;
|
||||||
const scene = createScene(elements);
|
|
||||||
let metadata = "";
|
let metadata = "";
|
||||||
if (exportEmbedScene) {
|
if (exportEmbedScene) {
|
||||||
try {
|
try {
|
||||||
@@ -232,7 +217,6 @@ export const exportToSvg = async (
|
|||||||
renderEmbeddables: opts?.renderEmbeddables,
|
renderEmbeddables: opts?.renderEmbeddables,
|
||||||
});
|
});
|
||||||
|
|
||||||
scene?.destroy();
|
|
||||||
return svgRoot;
|
return svgRoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user