فهرست منبع

feat: Expose `window.EXCALIDRAW_EXPORT_SOURCE` which host can use to overwrite the source field in exports (#5095)

* Expose `window.EXCALIDRAW_EXPORT_SOURCE` which host can use to overwrite the source field in exports

* Update src/packages/excalidraw/CHANGELOG.md

Co-authored-by: David Luzar <luzar.david@gmail.com>

* address review comments

* Update src/packages/excalidraw/README_NEXT.md

Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>

* Update src/packages/excalidraw/README_NEXT.md

Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>

* EXCALIDRAW_EXPORT_SOURCE -> EXCALIDRAW_EXPORT_SOURCE_PATH

Co-authored-by: David Luzar <luzar.david@gmail.com>
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
Achille Lacoin 3 سال پیش
والد
کامیت
b6a6f2d465
4فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 2 1
      src/constants.ts
  2. 1 0
      src/global.d.ts
  3. 1 0
      src/packages/excalidraw/CHANGELOG.md
  4. 4 0
      src/packages/excalidraw/README_NEXT.md

+ 2 - 1
src/constants.ts

@@ -108,7 +108,8 @@ export const EXPORT_DATA_TYPES = {
   excalidrawLibrary: "excalidrawlib",
   excalidrawLibrary: "excalidrawlib",
 } as const;
 } as const;
 
 
-export const EXPORT_SOURCE = window.location.origin;
+export const EXPORT_SOURCE =
+  window.EXCALIDRAW_EXPORT_SOURCE_PATH || window.location.origin;
 
 
 // time in milliseconds
 // time in milliseconds
 export const IMAGE_RENDER_TIMEOUT = 500;
 export const IMAGE_RENDER_TIMEOUT = 500;

+ 1 - 0
src/global.d.ts

@@ -13,6 +13,7 @@ interface Window {
   ClipboardItem: any;
   ClipboardItem: any;
   __EXCALIDRAW_SHA__: string | undefined;
   __EXCALIDRAW_SHA__: string | undefined;
   EXCALIDRAW_ASSET_PATH: string | undefined;
   EXCALIDRAW_ASSET_PATH: string | undefined;
+  EXCALIDRAW_EXPORT_SOURCE_PATH: string;
   gtag: Function;
   gtag: Function;
 }
 }
 
 

+ 1 - 0
src/packages/excalidraw/CHANGELOG.md

@@ -17,6 +17,7 @@ Please add the latest change on the top under the correct section.
 
 
 #### Features
 #### Features
 
 
+- Expose `window.EXCALIDRAW_EXPORT_SOURCE_PATH` which you can use to overwrite the `source` field in exported data [#5095](https://github.com/excalidraw/excalidraw/pull/5095).
 - The `exportToBlob` utility now supports the `exportEmbedScene` option when generating a png image [#5047](https://github.com/excalidraw/excalidraw/pull/5047).
 - The `exportToBlob` utility now supports the `exportEmbedScene` option when generating a png image [#5047](https://github.com/excalidraw/excalidraw/pull/5047).
 - Exported [`restoreLibraryItems`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#restoreLibraryItems) API [#4995](https://github.com/excalidraw/excalidraw/pull/4995).
 - Exported [`restoreLibraryItems`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#restoreLibraryItems) API [#4995](https://github.com/excalidraw/excalidraw/pull/4995).
 
 

+ 4 - 0
src/packages/excalidraw/README_NEXT.md

@@ -924,6 +924,8 @@ serializeAsJSON({
 
 
 Takes the scene elements and state and returns a JSON string. Deleted `elements`as well as most properties from `AppState` are removed from the resulting JSON. (see [`serializeAsJSON()`](https://github.com/excalidraw/excalidraw/blob/master/src/data/json.ts#L16) source for details).
 Takes the scene elements and state and returns a JSON string. Deleted `elements`as well as most properties from `AppState` are removed from the resulting JSON. (see [`serializeAsJSON()`](https://github.com/excalidraw/excalidraw/blob/master/src/data/json.ts#L16) source for details).
 
 
+If you want to overwrite the source field in the JSON string, you can set `window.EXCALIDRAW_EXPORT_SOURCE_PATH` to the desired value.
+
 #### `serializeLibraryAsJSON`
 #### `serializeLibraryAsJSON`
 
 
 **_Signature_**
 **_Signature_**
@@ -935,6 +937,8 @@ serializeLibraryAsJSON({
 
 
 Takes the library items and returns a JSON string.
 Takes the library items and returns a JSON string.
 
 
+If you want to overwrite the source field in the JSON string, you can set `window.EXCALIDRAW_EXPORT_SOURCE_PATH` to the desired value.
+
 #### `getSceneVersion`
 #### `getSceneVersion`
 
 
 **How to use**
 **How to use**