Implement utils

feat/readonly-editor
Arik Chakma 1 year ago
parent c107ce6d5d
commit 29f6298e2f
  1. 1
      .gitignore
  2. 15
      editor/utils/font.ts
  3. 8
      editor/utils/roadmap.ts
  4. 14
      scripts/generate-renderer.sh

1
.gitignore vendored

@ -33,6 +33,7 @@ tests-examples
!/editor/utils/
!/editor/readonly-editor.tsx
!/editor/utils/roadmap.ts
!/editor/utils/font.ts
!/editor/utils/is-mobile.ts
/renderer/*
!/renderer/index.tsx

@ -0,0 +1,15 @@
type LoadFont = (options: {
fontFamily: string;
fontURL: string;
}) => Promise<void>;
export const loadFont: LoadFont = async (options) => {
const { fontFamily, fontURL } = options;
const font = new FontFace(fontFamily!, `url(${fontURL})`);
await font.load();
if (document.fonts) {
document?.fonts?.add(font);
}
};

@ -4,10 +4,18 @@ export const INITIAL_DESKTOP_ZOOM = 1;
export const MINIMUM_DESKTOP_ZOOM = 0.75;
export function centerRoadmap(options: any) {
console.warn('centerRoadmap is not implemented');
console.warn('run the following command to generate the renderer:');
console.warn('> npm run generate-renderer');
return;
}
export function calculateDimensions(options: any) {
console.warn('calculateDimensions is not implemented');
console.warn('run the following command to generate the renderer:');
console.warn('> npm run generate-renderer');
return {
x: 0,
y: 0,

@ -8,17 +8,17 @@ if [ ! -d ".temp/web-draw" ]; then
git clone git@github.com:roadmapsh/web-draw.git .temp/web-draw
fi
rm -rf renderer
mkdir renderer
rm -rf editor
mkdir editor
# copy the files at /src/editor/renderer/* to /renderer
# copy the files at /src/editor/* to /editor
# while replacing any existing files
cp -rf .temp/web-draw/src/editor/renderer/* renderer
cp -rf .temp/web-draw/src/editor/* editor
# Add @ts-nocheck to the top of each ts and tsx file
# so that the typescript compiler doesn't complain
# about the missing types
find renderer -type f \( -name "*.ts" -o -name "*.tsx" \) -print0 | while IFS= read -r -d '' file; do
find editor -type f \( -name "*.ts" -o -name "*.tsx" \) -print0 | while IFS= read -r -d '' file; do
if [ -f "$file" ]; then
echo "// @ts-nocheck" > temp
cat "$file" >> temp
@ -29,5 +29,5 @@ done
# ignore the worktree changes for the renderer directory
git update-index --skip-worktree renderer/*
# ignore the worktree changes for the editor directory
git update-index --skip-worktree editor/*

Loading…
Cancel
Save