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

Bump the version of the elements when a scene is loaded from a blob #7

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@
</p>
<p align="center"><i>Enabling society to collaborate. Building a better future, together.</i></p>
# Alkemio fork of Excalidraw v0.17.0
- Upgraded from Excalidraw v0.16.1 to v0.17.0
- Procedure is very similar to previous versions below:
```

### Upgrade procedure
```
git fetch --tags upstream
git checkout 0.16.1-alkemio-1
git merge v0.17.0
git push --set-upstream origin 0.17.0-alkemio-1
```
- Applied the new styles of the buttons to Alkemio's ZoomToFit added button.
- Modified the paste functionality to avoid pasting elements (such as images) as JSON when editing text.
```

### For testing you can link the new package from the local client
### List of differences with standard Excalidraw
- ZoomToFit feature exposed through the external API
- Added ZoomToFit button to the zoom toolbar
- Added ZoomToFit flag to initialData to fit items on load
- Modified the paste functionality to avoid pasting elements (such as images) as JSON when editing text.
- Added `hideLibraryButton` to the appState to be able to hide the button from outside.
- Changed the toolbar Lock button behavior. Now it locks/unlocks elements instead of the tool in use
- Changed the load from file behavior to fix multi-user collaboration bug. Now elements loaded will have version number > currentScene version number

### Testing locally inside Alkemio client
```
npm link
cd ../client-web
npm link @alkemio/excalidraw --save
```

### Build and publish the new npm package:

Find in json files any `'alkemio-XX'` and set the version you want to publish
```
yarn
cd src/packages/excalidraw
Expand All @@ -32,20 +38,25 @@ yarn build:umd
yarn pack
yarn publish
```
# Alkemio fork of Excalidraw v0.17.0-alkemio-4

## Change Log
### Alkemio fork of Excalidraw v0.17.0-alkemio-5
- Changed the load from file behavior to fix multi-user collaboration bug. Now elements loaded will have version number > currentScene version number
- WARNING: This is a test, and it is not going to work, further changes are needed.

### Alkemio fork of Excalidraw v0.17.0-alkemio-4
- Added `hideLibraryButton` to the appState to be able to hide the button from outside.
- Changed the toolbar Lock button behavior. Now it locks/unlocks elements instead of the tool in use

# Alkemio fork of Excalidraw v0.17.0-alkemio-3-beta
### Alkemio fork of Excalidraw v0.17.0-alkemio-3-beta
- Changed behavior. Pasting elements is better handled and now it doesn't end up as a big text node with JSON inside.


# Alkemio fork of Excalidraw v0.17.0

### Alkemio fork of Excalidraw v0.17.0
- Upgraded from Excalidraw v0.16.1 to v0.17.0
- Applied the new styles of the buttons to Alkemio's ZoomToFit added button.


# Alkemio fork of Excalidraw v0.16.1
### Alkemio fork of Excalidraw v0.16.1

- Upgraded from Excalidraw v0.15.2 to v0.16.1

Expand All @@ -69,15 +80,15 @@ yarn publish

- Fixed merge conflicts and a small issue with the zoomToFit icon, they have added a function with the same name.

# Alkemio fork of Excalidraw v0.15.2
### Alkemio fork of Excalidraw v0.15.2

### Modifications:
#### Modifications:

- ZoomToFit feature exposed through the external API
- Added ZoomToFit button to the zoom toolbar
- Added ZoomToFit flag to initialData to fit items on load

### Development guidelines
#### Development guidelines

- First of all, Excalidraw uses yarn as package manager, so first thing to do is make sure you have yarn installed in your system. `npm install --global yarn`.
- Clone the repository to a local folder: `git clone [email protected]:alkem-io/excalidraw.git` and create a feature branch to store your work.
Expand All @@ -89,7 +100,7 @@ yarn publish
- Once is merged to `develop`, checkout `develop` branch and see below how to build and publish the package to NPM repository.
- Make sure you switch back the package in your client-web to use the published @alkemio/excalidraw package's new version instead of the old one or the linked one if you changed it.

### Build and publish a new npm package:
#### Build and publish a new npm package:

```
yarn
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
},
"homepage": "https://github.com/alkem-io/excalidraw",
"name": "@alkemio/excalidraw",
"version": "0.17.0-alkemio-4",
"version": "0.17.0-alkemio-5",
"prettier": "@excalidraw/prettier-config",
"private": false,
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/data/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ImportedDataState, LegacyAppState } from "./types";
import {
getNonDeletedElements,
getNormalizedDimensions,
getSceneVersion,
isInvisiblySmallElement,
refreshTextDimensions,
} from "../element";
Expand Down Expand Up @@ -422,6 +423,7 @@ export const restoreElements = (
// used to detect duplicate top-level element ids
const existingIds = new Set<string>();
const localElementsMap = localElements ? arrayToMap(localElements) : null;
const sceneVersion = getSceneVersion(localElements ?? []);
const restoredElements = (elements || []).reduce((elements, element) => {
// filtering out selection, which is legacy, no longer kept in elements,
// and causing issues if retained
Expand All @@ -434,6 +436,8 @@ export const restoreElements = (
const localElement = localElementsMap?.get(element.id);
if (localElement && localElement.version > migratedElement.version) {
migratedElement = bumpVersion(migratedElement, localElement.version);
} else {
migratedElement = bumpVersion(migratedElement, sceneVersion);
}
if (existingIds.has(migratedElement.id)) {
migratedElement = { ...migratedElement, id: randomId() };
Expand Down
2 changes: 1 addition & 1 deletion src/packages/excalidraw/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alkemio/excalidraw",
"version": "0.17.0-alkemio-4",
"version": "0.17.0-alkemio-5",
"main": "main.js",
"types": "types/packages/excalidraw/index.d.ts",
"files": [
Expand Down
Loading