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/utils/
!/editor/readonly-editor.tsx !/editor/readonly-editor.tsx
!/editor/utils/roadmap.ts !/editor/utils/roadmap.ts
!/editor/utils/font.ts
!/editor/utils/is-mobile.ts !/editor/utils/is-mobile.ts
/renderer/* /renderer/*
!/renderer/index.tsx !/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 const MINIMUM_DESKTOP_ZOOM = 0.75;
export function centerRoadmap(options: any) { 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; return;
} }
export function calculateDimensions(options: any) { 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 { return {
x: 0, x: 0,
y: 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 git clone git@github.com:roadmapsh/web-draw.git .temp/web-draw
fi fi
rm -rf renderer rm -rf editor
mkdir renderer mkdir editor
# copy the files at /src/editor/renderer/* to /renderer # copy the files at /src/editor/* to /editor
# while replacing any existing files # 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 # Add @ts-nocheck to the top of each ts and tsx file
# so that the typescript compiler doesn't complain # so that the typescript compiler doesn't complain
# about the missing types # 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 if [ -f "$file" ]; then
echo "// @ts-nocheck" > temp echo "// @ts-nocheck" > temp
cat "$file" >> temp cat "$file" >> temp
@ -29,5 +29,5 @@ done
# ignore the worktree changes for the renderer directory # ignore the worktree changes for the editor directory
git update-index --skip-worktree renderer/* git update-index --skip-worktree editor/*

Loading…
Cancel
Save