Merge remote-tracking branch 'origin/release' into danieljgeiger-mathjax

This commit is contained in:
Daniel J. Geiger 2023-04-20 18:52:45 -05:00
commit 12c651af6d
93 changed files with 3292 additions and 958 deletions

View file

@ -11,7 +11,39 @@ The change should be grouped under one of the below section and must contain PR
Please add the latest change on the top under the correct section.
-->
## Unreleased
## 0.15.2 (2023-04-20)
### Docs
- Fix docs link in readme [#6486](https://github.com/excalidraw/excalidraw/pull/6486)
## Excalidraw Library
**_This section lists the updates made to the excalidraw library and will not affect the integration._**
### Fixes
- Rotate the text element when binding to a rotated container [#6477](https://github.com/excalidraw/excalidraw/pull/6477)
- Support breaking words containing hyphen - [#6014](https://github.com/excalidraw/excalidraw/pull/6014)
- Incorrect background fill button active state [#6491](https://github.com/excalidraw/excalidraw/pull/6491)
---
## 0.15.1 (2023-04-18)
### Docs
- Add the readme back to the package which was mistakenly removed [#6484](https://github.com/excalidraw/excalidraw/pull/6484)
## Excalidraw Library
**_This section lists the updates made to the excalidraw library and will not affect the integration._**
---
## 0.15.0 (2023-04-18)
### Features
@ -37,6 +69,154 @@ For more details refer to the [docs](https://docs.excalidraw.com)
- Exporting labelled arrows via export utils [#6443](https://github.com/excalidraw/excalidraw/pull/6443)
## Excalidraw Library
**_This section lists the updates made to the excalidraw library and will not affect the integration._**
### Features
- Constrain export dialog preview size [#6475](https://github.com/excalidraw/excalidraw/pull/6475)
- Zigzag fill easter egg [#6439](https://github.com/excalidraw/excalidraw/pull/6439)
- Add container to multiple text elements [#6428](https://github.com/excalidraw/excalidraw/pull/6428)
- Starting migration from GA to Matomo for better privacy [#6398](https://github.com/excalidraw/excalidraw/pull/6398)
- Add line height attribute to text element [#6360](https://github.com/excalidraw/excalidraw/pull/6360)
- Add thai lang support [#6314](https://github.com/excalidraw/excalidraw/pull/6314)
- Create bound container from text [#6301](https://github.com/excalidraw/excalidraw/pull/6301)
- Improve text measurements in bound containers [#6187](https://github.com/excalidraw/excalidraw/pull/6187)
- Bind text to container if double clicked on filled shape or stroke [#6250](https://github.com/excalidraw/excalidraw/pull/6250)
- Make repair and refreshDimensions configurable in restoreElements [#6238](https://github.com/excalidraw/excalidraw/pull/6238)
- Show error message when not connected to internet while collabo… [#6165](https://github.com/excalidraw/excalidraw/pull/6165)
- Shortcut for clearCanvas confirmDialog [#6114](https://github.com/excalidraw/excalidraw/pull/6114)
- Disable canvas smoothing (antialiasing) for right-angled elements [#6186](https://github.com/excalidraw/excalidraw/pull/6186)Co-authored-by: Ignacio Cuadra <67276174+ignacio-cuadra@users.noreply.github.com>
### Fixes
- Center align text when wrapped in container via context menu [#6480](https://github.com/excalidraw/excalidraw/pull/6480)
- Restore original container height when unbinding text which was binded via context menu [#6444](https://github.com/excalidraw/excalidraw/pull/6444)
- Mark more props as optional for element [#6448](https://github.com/excalidraw/excalidraw/pull/6448)
- Improperly cache-busting on canvas scale instead of zoom [#6473](https://github.com/excalidraw/excalidraw/pull/6473)
- Incorrectly duplicating items on paste/library insert [#6467](https://github.com/excalidraw/excalidraw/pull/6467)
- Library ids cross-contamination on multiple insert [#6466](https://github.com/excalidraw/excalidraw/pull/6466)
- Color picker keyboard handling not working [#6464](https://github.com/excalidraw/excalidraw/pull/6464)
- Abort freedraw line if second touch is detected [#6440](https://github.com/excalidraw/excalidraw/pull/6440)
- Utils leaking Scene state [#6461](https://github.com/excalidraw/excalidraw/pull/6461)
- Split "Edit selected shape" shortcut [#6457](https://github.com/excalidraw/excalidraw/pull/6457)
- Center align text when bind to container via context menu [#6451](https://github.com/excalidraw/excalidraw/pull/6451)
- Update coords when text unbinded from its container [#6445](https://github.com/excalidraw/excalidraw/pull/6445)
- Autoredirect to plus in prod only [#6446](https://github.com/excalidraw/excalidraw/pull/6446)
- Fixing popover overflow on small screen [#6433](https://github.com/excalidraw/excalidraw/pull/6433)
- Introduce baseline to fix the layout shift when switching to text editor [#6397](https://github.com/excalidraw/excalidraw/pull/6397)
- Don't refresh dimensions for deleted text elements [#6438](https://github.com/excalidraw/excalidraw/pull/6438)
- Element vanishes when zoomed in [#6417](https://github.com/excalidraw/excalidraw/pull/6417)
- Don't jump text to end when out of viewport in safari [#6416](https://github.com/excalidraw/excalidraw/pull/6416)
- GetDefaultLineHeight should return default font family line height for unknown font [#6399](https://github.com/excalidraw/excalidraw/pull/6399)
- Revert use `ideographic` textBaseline to improve layout shift when editing text" [#6400](https://github.com/excalidraw/excalidraw/pull/6400)
- Call stack size exceeded when paste large text [#6373](https://github.com/excalidraw/excalidraw/pull/6373) (#6396)
- Use `ideographic` textBaseline to improve layout shift when editing text [#6384](https://github.com/excalidraw/excalidraw/pull/6384)
- Chrome crashing when embedding scene on chrome arm [#6383](https://github.com/excalidraw/excalidraw/pull/6383)
- Division by zero in findFocusPointForEllipse leads to infinite loop in wrapText freezing Excalidraw [#6377](https://github.com/excalidraw/excalidraw/pull/6377)
- Containerizing text incorrectly updates arrow bindings [#6369](https://github.com/excalidraw/excalidraw/pull/6369)
- Ensure export preview is centered [#6337](https://github.com/excalidraw/excalidraw/pull/6337)
- Hide text align for labelled arrows [#6339](https://github.com/excalidraw/excalidraw/pull/6339)
- Refresh dimensions when elements loaded from shareable link and blob [#6333](https://github.com/excalidraw/excalidraw/pull/6333)
- Show error message when measureText API breaks in brave [#6336](https://github.com/excalidraw/excalidraw/pull/6336)
- Add an offset of 0.5px for text editor in containers [#6328](https://github.com/excalidraw/excalidraw/pull/6328)
- Move utility types out of `.d.ts` file to fix exported declaration files [#6315](https://github.com/excalidraw/excalidraw/pull/6315)
- More jotai scopes missing [#6313](https://github.com/excalidraw/excalidraw/pull/6313)
- Provide HelpButton title prop [#6209](https://github.com/excalidraw/excalidraw/pull/6209)
- Respect text align when wrapping in a container [#6310](https://github.com/excalidraw/excalidraw/pull/6310)
- Compute bounding box correctly for text element when multiple element resizing [#6307](https://github.com/excalidraw/excalidraw/pull/6307)
- Use jotai scope for editor-specific atoms [#6308](https://github.com/excalidraw/excalidraw/pull/6308)
- Consider arrow for bound text element [#6297](https://github.com/excalidraw/excalidraw/pull/6297)
- Text never goes beyond max width for unbound text elements [#6288](https://github.com/excalidraw/excalidraw/pull/6288)
- Svg text baseline [#6285](https://github.com/excalidraw/excalidraw/pull/6273)
- Compute container height from bound text correctly [#6273](https://github.com/excalidraw/excalidraw/pull/6273)
- Fit mobile toolbar and make scrollable [#6270](https://github.com/excalidraw/excalidraw/pull/6270)
- Indenting via `tab` clashing with IME compositor [#6258](https://github.com/excalidraw/excalidraw/pull/6258)
- Improve text wrapping inside rhombus and more fixes [#6265](https://github.com/excalidraw/excalidraw/pull/6265)
- Improve text wrapping in ellipse and alignment [#6172](https://github.com/excalidraw/excalidraw/pull/6172)
- Don't allow blank space in collab name [#6211](https://github.com/excalidraw/excalidraw/pull/6211)
- Docker build architecture:linux/amd64 error occur on linux/arm64 instance [#6197](https://github.com/excalidraw/excalidraw/pull/6197)
- Sort bound text elements to fix text duplication z-index error [#5130](https://github.com/excalidraw/excalidraw/pull/5130)
- Hide welcome screen on mobile once user interacts [#6185](https://github.com/excalidraw/excalidraw/pull/6185)
- Edit link in docs [#6182](https://github.com/excalidraw/excalidraw/pull/6182)
### Refactor
- Inline `SingleLibraryItem` into `PublishLibrary` [#6462](https://github.com/excalidraw/excalidraw/pull/6462)
- Make the example React app reusable without duplication [#6188](https://github.com/excalidraw/excalidraw/pull/6188)
### Performance
- Break early if the line width <= max width of the container [#6347](https://github.com/excalidraw/excalidraw/pull/6347)
### Build
- Move TS and types to devDependencies [#6346](https://github.com/excalidraw/excalidraw/pull/6346)
---
## 0.14.2 (2023-02-01)
### Features

View file

@ -38,8 +38,8 @@ Excalidraw takes _100%_ of `width` and `height` of the containing block so make
## Integration
Head over to the [docs](https://docs.excalidraw.com/docs/package/integration)
Head over to the [docs](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/integration)
## API
Head over to the [docs](https://docs.excalidraw.com/docs/package/api)
Head over to the [docs](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/api)

View file

@ -1,6 +1,6 @@
{
"name": "@excalidraw/excalidraw",
"version": "0.14.2",
"version": "0.15.2",
"main": "main.js",
"types": "types/packages/excalidraw/index.d.ts",
"files": [

View file

@ -15,6 +15,23 @@ import {
copyToClipboard,
} from "../clipboard";
import Scene from "../scene/Scene";
import { duplicateElements } from "../element/newElement";
// getContainerElement and getBoundTextElement and potentially other helpers
// depend on `Scene` which will not be available when these pure utils are
// called outside initialized Excalidraw editor instance or even if called
// from inside Excalidraw if the elements were never cached by Scene (e.g.
// for library elements).
//
// As such, before passing the elements down, we need to initialize a custom
// Scene instance and assign them to it.
//
// FIXME This is a super hacky workaround and we'll need to rewrite this soon.
const passElementsSafely = (elements: readonly ExcalidrawElement[]) => {
const scene = new Scene();
scene.replaceAllElements(duplicateElements(elements));
return scene.getNonDeletedElements();
};
export { MIME_TYPES };
@ -44,17 +61,9 @@ export const exportToCanvas = ({
null,
null,
);
// The helper methods getContainerElement and getBoundTextElement are
// dependent on Scene which will not be available
// when these pure utils are called outside Excalidraw or even if called
// from inside Excalidraw when Scene isn't available eg when using library items from store, as a result the element cannot be extracted
// hence initailizing a new scene with the elements
// so its always available to helper methods
const scene = new Scene();
scene.replaceAllElements(restoredElements);
const { exportBackground, viewBackgroundColor } = restoredAppState;
return _exportToCanvas(
scene.getNonDeletedElements(),
passElementsSafely(restoredElements),
{ ...restoredAppState, offsetTop: 0, offsetLeft: 0, width: 0, height: 0 },
files || {},
{ exportBackground, exportPadding, viewBackgroundColor },
@ -70,7 +79,11 @@ export const exportToCanvas = ({
const max = Math.max(width, height);
const scale = maxWidthOrHeight / max;
// if content is less then maxWidthOrHeight, fallback on supplied scale
const scale =
maxWidthOrHeight < max
? maxWidthOrHeight / max
: appState?.exportScale ?? 1;
canvas.width = width * scale;
canvas.height = height * scale;
@ -122,17 +135,9 @@ export const exportToBlob = async (
};
}
// The helper methods getContainerElement and getBoundTextElement are
// dependent on Scene which will not be available
// when these pure utils are called outside Excalidraw or even if called
// from inside Excalidraw when Scene isn't available eg when using library items from store, as a result the element cannot be extracted
// hence initailizing a new scene with the elements
// so its always available to helper methods
const scene = new Scene();
scene.replaceAllElements(opts.elements);
const canvas = await exportToCanvas({
...opts,
elements: scene.getNonDeletedElements(),
elements: passElementsSafely(opts.elements),
});
quality = quality ? quality : /image\/jpe?g/.test(mimeType) ? 0.92 : 0.8;
@ -150,7 +155,10 @@ export const exportToBlob = async (
blob = await encodePngMetadata({
blob,
metadata: serializeAsJSON(
scene.getNonDeletedElements(),
// NOTE as long as we're using the Scene hack, we need to ensure
// we pass the original, uncloned elements when serializing
// so that we keep ids stable
opts.elements,
opts.appState,
opts.files || {},
"local",
@ -178,21 +186,24 @@ export const exportToSvg = async ({
null,
null,
);
// The helper methods getContainerElement and getBoundTextElement are
// dependent on Scene which will not be available
// when these pure utils are called outside Excalidraw or even if called
// from inside Excalidraw when Scene isn't available eg when using library items from store, as a result the element cannot be extracted
// hence initailizing a new scene with the elements
// so its always available to helper methods
const scene = new Scene();
scene.replaceAllElements(restoredElements);
const exportAppState = {
...restoredAppState,
exportPadding,
};
return _exportToSvg(
scene.getNonDeletedElements(),
{
...restoredAppState,
exportPadding,
},
passElementsSafely(restoredElements),
exportAppState,
files,
{
// NOTE as long as we're using the Scene hack, we need to ensure
// we pass the original, uncloned elements when serializing
// so that we keep ids stable. Hence adding the serializeAsJSON helper
// support into the downstream exportToSvg function.
serializeAsJSON: () =>
serializeAsJSON(restoredElements, exportAppState, files || {}, "local"),
},
);
};
@ -203,14 +214,6 @@ export const exportToClipboard = async (
type: "png" | "svg" | "json";
},
) => {
// The helper methods getContainerElement and getBoundTextElement are
// dependent on Scene which will not be available
// when these pure utils are called outside Excalidraw or even if called
// from inside Excalidraw when Scene isn't available eg when using library items from store, as a result the element cannot be extracted
// hence initailizing a new scene with the elements
// so its always available to helper methods
const scene = new Scene();
scene.replaceAllElements(opts.elements);
if (opts.type === "svg") {
const svg = await exportToSvg(opts);
await copyTextToSystemClipboard(svg.outerHTML);
@ -225,7 +228,7 @@ export const exportToClipboard = async (
...getDefaultAppState(),
...opts.appState,
};
await copyToClipboard(scene.getNonDeletedElements(), appState, opts.files);
await copyToClipboard(opts.elements, appState, opts.files);
} else {
throw new Error("Invalid export type");
}