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

Upstream sync #234

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
43b1b3d
Introduce font-picker
Mrazator Apr 30, 2024
ef0714f
Flag for showing deprecated fonts inside the available fonts
Mrazator Jul 8, 2024
bba7eb3
Switch to Excalifont for initialData example
Mrazator Jul 8, 2024
18b282c
Remove new badges
Mrazator Jul 9, 2024
3898edb
Fix empty: protocol error, unify css font-weights
Mrazator Jul 15, 2024
07b7ac9
Clear the dev docs
Mrazator Jul 18, 2024
927804e
Lazy load registered fonts
Mrazator Jul 18, 2024
08af93d
Use DO CDN for prod
Mrazator Jul 18, 2024
ce7ab91
Normalize asset & bbase url paths, allow root-relative EXCALIDRAW_ASS…
Mrazator Jul 18, 2024
23e8202
Assistant to-be include in the package
Mrazator Jul 18, 2024
ca3dd65
Replacing Bangers with Lilita one
Mrazator Jul 18, 2024
8afb307
Add Assistant font-face back into the export
Mrazator Jul 18, 2024
54e65ab
Test & lint fixes
Mrazator Jul 18, 2024
5ce713c
Fix regression with no fonts found
Mrazator Jul 18, 2024
957e2ea
Use actual width only when TextMetrics is available
Mrazator Jul 19, 2024
611d8a6
Allow shift + f shortcut on text tool selection
Mrazator Jul 19, 2024
740a924
Nunito 530 sweet spot
Mrazator Jul 22, 2024
5686bfd
Fix issue with inability to choose a current item font family
Mrazator Jul 22, 2024
bd8fbe8
Remove Geist
Mrazator Jul 22, 2024
9aad9e1
Switch to Nunito 500 to avoid loading variable font (for now)
Mrazator Jul 22, 2024
a83c713
Preload all default fonts
Mrazator Jul 22, 2024
926935a
Redraw text once all the font faces loaded on font change action
Mrazator Jul 23, 2024
1d11d53
preload from cdn
dwelle Jul 23, 2024
baacc8d
handle `./` in baseUrl path
dwelle Jul 23, 2024
333db2b
Eliminate document.fonts.check bottleneck
Mrazator Jul 23, 2024
0acbfd0
Replace Assistant frame labels with Helvetica
Mrazator Jul 23, 2024
a3f9b77
Disable wysiwyg padding in Safari
Mrazator Jul 23, 2024
6dd39ae
Lint fix
Mrazator Jul 23, 2024
d3eef9e
Lower the max chars bound for on hover re-render to 5k
Mrazator Jul 23, 2024
4929534
Merge remote-tracking branch 'upstream/mrazator/font-picker' into ups…
zsviczian Jul 23, 2024
888d979
Merge branch 'font-picker-test' of https://github.com/zsviczian/excal…
zsviczian Jul 23, 2024
f5f040a
Temp changes
zsviczian Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev-docs/src/css/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pre a {
padding: 5px;
background: #70b1ec;
color: white;
font-weight: bold;
font-weight: 700;
border: none;
}

Expand Down
2 changes: 2 additions & 0 deletions examples/excalidraw/with-script-in-browser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# copied assets
public/*.woff2
26 changes: 22 additions & 4 deletions excalidraw-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@
) {
window.location.href = "https://app.excalidraw.com";
}

// point into our CDN in prod
window.EXCALIDRAW_ASSET_PATH =
"https://excalidraw.nyc3.cdn.digitaloceanspaces.com/oss/";
</script>
<% } else { %>
<script>
window.EXCALIDRAW_ASSET_PATH = window.origin;
</script>
<% } %>

Expand All @@ -124,22 +132,33 @@
<!-- Excalidraw version -->
<meta name="version" content="{version}" />

<!-- Preload all the default fonts and Virgil (backwards compatibility) to avoid swap and incorrect metrics measurements after init -->
<link
rel="preload"
href="/Virgil.woff2"
href="https://excalidraw.nyc3.cdn.digitaloceanspaces.com/oss/assets/fonts/Excalifont-Regular.woff2"
as="font"
type="font/woff2"
crossorigin="anonymous"
/>
<link
rel="preload"
href="/Cascadia.woff2"
href="https://excalidraw.nyc3.cdn.digitaloceanspaces.com/oss/assets/fonts/Virgil-Regular.woff2"
as="font"
type="font/woff2"
crossorigin="anonymous"
/>

<link rel="stylesheet" href="/fonts/fonts.css" type="text/css" />
<!-- Register Assistant as the UI font, before the scene inits -->
<link
rel="stylesheet"
href="../packages/excalidraw/fonts/assets/fonts.css"
type="text/css"
/>

<!-- Warmup the connection for Google fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

<% if (typeof VITE_APP_DEV_DISABLE_LIVE_RELOAD != 'undefined' &&
VITE_APP_DEV_DISABLE_LIVE_RELOAD == true) { %>
<script>
Expand All @@ -158,7 +177,6 @@
</script>
<% } %>
<script>
window.EXCALIDRAW_ASSET_PATH = "/";
// setting this so that libraries installation reuses this window tab.
window.name = "_excalidraw";
</script>
Expand Down
3 changes: 2 additions & 1 deletion excalidraw-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"build:version": "node ../scripts/build-version.js",
"build": "yarn build:app && yarn build:version",
"start": "yarn && vite",
"start:production": "npm run build && npx http-server build -a localhost -p 5001 -o",
"start:production": "yarn build && yarn serve",
"serve": "npx http-server build -a localhost -p 5001 -o",
"build:preview": "yarn build && vite preview --port 5000"
}
}
4 changes: 2 additions & 2 deletions excalidraw-app/tests/__snapshots__/MobileMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`Test MobileMenu > should initialize with welcome screen and hide once u
class="welcome-screen-center"
>
<div
class="welcome-screen-center__logo virgil welcome-screen-decor"
class="welcome-screen-center__logo excalifont welcome-screen-decor"
>
<div
class="ExcalidrawLogo is-small"
Expand Down Expand Up @@ -48,7 +48,7 @@ exports[`Test MobileMenu > should initialize with welcome screen and hide once u
</div>
</div>
<div
class="welcome-screen-center__heading welcome-screen-decor virgil"
class="welcome-screen-center__heading welcome-screen-decor excalifont"
>
All your data is saved locally in your browser.
</div>
Expand Down
11 changes: 10 additions & 1 deletion excalidraw-app/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ViteEjsPlugin } from "vite-plugin-ejs";
import { VitePWA } from "vite-plugin-pwa";
import checker from "vite-plugin-checker";
import { createHtmlPlugin } from "vite-plugin-html";
import { woff2BrowserPlugin } from "../scripts/woff2/woff2-vite-plugins";

// To load .env.local variables
const envVars = loadEnv("", `../`);
Expand All @@ -22,6 +23,13 @@ export default defineConfig({
outDir: "build",
rollupOptions: {
output: {
assetFileNames(chunkInfo) {
if (chunkInfo?.name?.endsWith(".woff2")) {
return 'assets/fonts/[name]-[hash][extname]';
}

return 'assets/[name]-[hash][extname]';
},
// Creating separate chunk for locales except for en and percentages.json so they
// can be cached at runtime and not merged with
// app precache. en.json and percentages.json are needed for first load
Expand All @@ -35,12 +43,13 @@ export default defineConfig({
// Taking the substring after "locales/"
return `locales/${id.substring(index + 8)}`;
}
},
}
},
},
sourcemap: true,
},
plugins: [
woff2BrowserPlugin(),
react(),
checker({
typescript: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/excalidraw/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Please add the latest change on the top under the correct section.

- Added support for multiplayer undo/redo, by calculating invertible increments and storing them inside the local-only undo/redo stacks. [#7348](https://github.com/excalidraw/excalidraw/pull/7348)

- Added font picker component to have the ability to choose from a range of different fonts. Also, changed the default fonts to `Excalifont`, `Nunito` and `Comic Shanns` and deprecated `Virgil`, `Helvetica` and `Cascadia`.

- `MainMenu.DefaultItems.ToggleTheme` now supports `onSelect(theme: string)` callback, and optionally `allowSystemTheme: boolean` alongside `theme: string` to indicate you want to allow users to set to system theme (you need to handle this yourself). [#7853](https://github.com/excalidraw/excalidraw/pull/7853)

- Add `useHandleLibrary`'s `opts.adapter` as the new recommended pattern to handle library initialization and persistence on library updates. [#7655](https://github.com/excalidraw/excalidraw/pull/7655)
Expand Down
6 changes: 4 additions & 2 deletions packages/excalidraw/actions/actionProperties.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ describe("element locking", () => {
});
const text = API.createElement({
type: "text",
fontFamily: FONT_FAMILY.Cascadia,
fontFamily: FONT_FAMILY["Comic Shanns"],
});
h.elements = [rect, text];
API.setSelectedElements([rect, text]);

expect(queryByTestId(document.body, `strokeWidth-bold`)).toBeChecked();
expect(queryByTestId(document.body, `font-family-code`)).toBeChecked();
expect(queryByTestId(document.body, `font-family-code`)).toHaveClass(
"active",
);
});
});
});
Loading
Loading