mirror of
https://github.com/excalidraw/excalidraw.git
synced 2024-11-10 11:35:52 +01:00
feat: supply version
param when installing libraries (#4305)
This commit is contained in:
parent
b6ef953dc9
commit
cc4b0c2932
@ -21,6 +21,7 @@ import { ToolButton } from "./ToolButton";
|
|||||||
import { Tooltip } from "./Tooltip";
|
import { Tooltip } from "./Tooltip";
|
||||||
|
|
||||||
import "./LibraryMenuItems.scss";
|
import "./LibraryMenuItems.scss";
|
||||||
|
import { VERSIONS } from "../constants";
|
||||||
|
|
||||||
const LibraryMenuItems = ({
|
const LibraryMenuItems = ({
|
||||||
libraryItems,
|
libraryItems,
|
||||||
@ -293,7 +294,9 @@ const LibraryMenuItems = ({
|
|||||||
<a
|
<a
|
||||||
href={`${process.env.REACT_APP_LIBRARY_URL}?target=${
|
href={`${process.env.REACT_APP_LIBRARY_URL}?target=${
|
||||||
window.name || "_blank"
|
window.name || "_blank"
|
||||||
}&referrer=${referrer}&useHash=true&token=${id}&theme=${theme}`}
|
}&referrer=${referrer}&useHash=true&token=${id}&theme=${theme}&version=${
|
||||||
|
VERSIONS.excalidrawLibrary
|
||||||
|
}`}
|
||||||
target="_excalidraw_libraries"
|
target="_excalidraw_libraries"
|
||||||
>
|
>
|
||||||
{t("labels.libraries")}
|
{t("labels.libraries")}
|
||||||
|
@ -8,7 +8,7 @@ import { ToolButton } from "./ToolButton";
|
|||||||
|
|
||||||
import { AppState, LibraryItems, LibraryItem } from "../types";
|
import { AppState, LibraryItems, LibraryItem } from "../types";
|
||||||
import { exportToBlob } from "../packages/utils";
|
import { exportToBlob } from "../packages/utils";
|
||||||
import { EXPORT_DATA_TYPES, EXPORT_SOURCE } from "../constants";
|
import { EXPORT_DATA_TYPES, EXPORT_SOURCE, VERSIONS } from "../constants";
|
||||||
import { ExportedLibraryData } from "../data/types";
|
import { ExportedLibraryData } from "../data/types";
|
||||||
|
|
||||||
import "./PublishLibrary.scss";
|
import "./PublishLibrary.scss";
|
||||||
@ -181,7 +181,7 @@ const PublishLibrary = ({
|
|||||||
|
|
||||||
const libContent: ExportedLibraryData = {
|
const libContent: ExportedLibraryData = {
|
||||||
type: EXPORT_DATA_TYPES.excalidrawLibrary,
|
type: EXPORT_DATA_TYPES.excalidrawLibrary,
|
||||||
version: 2,
|
version: VERSIONS.excalidrawLibrary,
|
||||||
source: EXPORT_SOURCE,
|
source: EXPORT_SOURCE,
|
||||||
libraryItems: clonedLibItems,
|
libraryItems: clonedLibItems,
|
||||||
};
|
};
|
||||||
|
@ -176,3 +176,8 @@ export const MAX_ALLOWED_FILE_BYTES = 2 * 1024 * 1024;
|
|||||||
export const SVG_NS = "http://www.w3.org/2000/svg";
|
export const SVG_NS = "http://www.w3.org/2000/svg";
|
||||||
|
|
||||||
export const ENCRYPTION_KEY_BITS = 128;
|
export const ENCRYPTION_KEY_BITS = 128;
|
||||||
|
|
||||||
|
export const VERSIONS = {
|
||||||
|
excalidraw: 2,
|
||||||
|
excalidrawLibrary: 2,
|
||||||
|
} as const;
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { fileOpen, fileSave } from "./filesystem";
|
import { fileOpen, fileSave } from "./filesystem";
|
||||||
import { cleanAppStateForExport, clearAppStateForDatabase } from "../appState";
|
import { cleanAppStateForExport, clearAppStateForDatabase } from "../appState";
|
||||||
import { EXPORT_DATA_TYPES, EXPORT_SOURCE, MIME_TYPES } from "../constants";
|
import {
|
||||||
|
EXPORT_DATA_TYPES,
|
||||||
|
EXPORT_SOURCE,
|
||||||
|
MIME_TYPES,
|
||||||
|
VERSIONS,
|
||||||
|
} from "../constants";
|
||||||
import { clearElementsForDatabase, clearElementsForExport } from "../element";
|
import { clearElementsForDatabase, clearElementsForExport } from "../element";
|
||||||
import { ExcalidrawElement } from "../element/types";
|
import { ExcalidrawElement } from "../element/types";
|
||||||
import { AppState, BinaryFiles, LibraryItems } from "../types";
|
import { AppState, BinaryFiles, LibraryItems } from "../types";
|
||||||
@ -42,7 +47,7 @@ export const serializeAsJSON = (
|
|||||||
): string => {
|
): string => {
|
||||||
const data: ExportedDataState = {
|
const data: ExportedDataState = {
|
||||||
type: EXPORT_DATA_TYPES.excalidraw,
|
type: EXPORT_DATA_TYPES.excalidraw,
|
||||||
version: 2,
|
version: VERSIONS.excalidraw,
|
||||||
source: EXPORT_SOURCE,
|
source: EXPORT_SOURCE,
|
||||||
elements:
|
elements:
|
||||||
type === "local"
|
type === "local"
|
||||||
@ -121,7 +126,7 @@ export const isValidLibrary = (json: any) => {
|
|||||||
export const saveLibraryAsJSON = async (libraryItems: LibraryItems) => {
|
export const saveLibraryAsJSON = async (libraryItems: LibraryItems) => {
|
||||||
const data: ExportedLibraryData = {
|
const data: ExportedLibraryData = {
|
||||||
type: EXPORT_DATA_TYPES.excalidrawLibrary,
|
type: EXPORT_DATA_TYPES.excalidrawLibrary,
|
||||||
version: 2,
|
version: VERSIONS.excalidrawLibrary,
|
||||||
source: EXPORT_SOURCE,
|
source: EXPORT_SOURCE,
|
||||||
libraryItems,
|
libraryItems,
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { ExcalidrawElement } from "../element/types";
|
import { ExcalidrawElement } from "../element/types";
|
||||||
import { AppState, BinaryFiles, LibraryItems, LibraryItems_v1 } from "../types";
|
import { AppState, BinaryFiles, LibraryItems, LibraryItems_v1 } from "../types";
|
||||||
import type { cleanAppStateForExport } from "../appState";
|
import type { cleanAppStateForExport } from "../appState";
|
||||||
|
import { VERSIONS } from "../constants";
|
||||||
|
|
||||||
export interface ExportedDataState {
|
export interface ExportedDataState {
|
||||||
type: string;
|
type: string;
|
||||||
@ -24,7 +25,7 @@ export interface ImportedDataState {
|
|||||||
|
|
||||||
export interface ExportedLibraryData {
|
export interface ExportedLibraryData {
|
||||||
type: string;
|
type: string;
|
||||||
version: 2;
|
version: typeof VERSIONS.excalidrawLibrary;
|
||||||
source: string;
|
source: string;
|
||||||
libraryItems: LibraryItems;
|
libraryItems: LibraryItems;
|
||||||
}
|
}
|
||||||
|
3
src/tests/fixtures/diagramFixture.ts
vendored
3
src/tests/fixtures/diagramFixture.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
|
import { VERSIONS } from "../../constants";
|
||||||
import {
|
import {
|
||||||
diamondFixture,
|
diamondFixture,
|
||||||
ellipseFixture,
|
ellipseFixture,
|
||||||
@ -6,7 +7,7 @@ import {
|
|||||||
|
|
||||||
export const diagramFixture = {
|
export const diagramFixture = {
|
||||||
type: "excalidraw",
|
type: "excalidraw",
|
||||||
version: 2,
|
version: VERSIONS.excalidraw,
|
||||||
source: "https://excalidraw.com",
|
source: "https://excalidraw.com",
|
||||||
elements: [diamondFixture, ellipseFixture, rectangleFixture],
|
elements: [diamondFixture, ellipseFixture, rectangleFixture],
|
||||||
appState: {
|
appState: {
|
||||||
|
Loading…
Reference in New Issue
Block a user