@servicetitan/dte-unlayer 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * we need to pass code to unlayer and we have to pass it as source code (not as url to static file)
3
+ * because it is loaded from unlayer domain, so it has to pass authorization
4
+ * so when we build tools packages, we generate ./editor-core-source.ts file and include all tools bundles as strings
5
+ * then this code is passed to unlayer initializer
6
+ * (note that custom tools are imported differently as urls)
7
+ */
8
+ export { editorCoreScript, editorCoreTools, editorCoreStyles } from './editor-core-source';
package/src/loadScript.ts CHANGED
@@ -25,3 +25,9 @@ export const loadScript = (scriptUrl: string): Promise<void> => {
25
25
  document.head.appendChild(embedScript);
26
26
  });
27
27
  };
28
+
29
+ export const loadScriptSource = (source: string) => {
30
+ const embedScript = document.createElement('script');
31
+ embedScript.textContent = source;
32
+ document.head.appendChild(embedScript);
33
+ };
package/src/store.ts CHANGED
@@ -188,10 +188,12 @@ export class UnlayerStore {
188
188
  throw new Error('image upload is not implemented');
189
189
  }
190
190
 
191
+ done({ progress: 0 });
192
+
191
193
  if (data.attachments?.length) {
192
194
  this.onImageCB(data.attachments[0])
193
- .then(({ url }) => done({ progress: 100, url }))
194
- .catch(() => done({ progress: 100 }));
195
+ .catch(() => ({ url: '' }))
196
+ .then(({ url }) => done({ progress: 100, url }));
195
197
  }
196
198
  };
197
199
  }
@@ -1,4 +1,3 @@
1
- import { UnlayerCoreApi } from './api-core';
2
1
  import { SchemaObject } from './shared/schema';
3
2
 
4
3
  export interface UnlayerDesignTool {
@@ -67,5 +66,4 @@ export interface CreateUnlayerEditorProps {
67
66
  noCoreTools?: boolean;
68
67
  latest?: boolean;
69
68
  blocks?: boolean;
70
- coreApi: UnlayerCoreApi;
71
69
  }
package/src/unlayer.tsx CHANGED
@@ -1,3 +1,4 @@
1
+ import { editorCoreScript, editorCoreStyles, editorCoreTools } from './editor-core';
1
2
  import { constGenericsEditor } from './shared/const';
2
3
  import { unlayerSupportedFonts } from './shared/fonts';
3
4
  import { CreateUnlayerEditorProps } from './unlayer-interface';
@@ -61,27 +62,18 @@ export const versions = {
61
62
 
62
63
  export const createUnlayerEditor = (
63
64
  container: HTMLDivElement,
64
- {
65
- coreApi,
66
- customCSS,
67
- customJS,
68
- latest,
69
- mergeTags,
70
- noCoreTools,
71
- tools,
72
- units,
73
- }: CreateUnlayerEditorProps
65
+ { customCSS, customJS, latest, mergeTags, noCoreTools, tools, units }: CreateUnlayerEditorProps
74
66
  ): Unlayer => {
75
67
  const customScripts = [
76
- ...coreApi.pathsCore,
77
- ...coreApi.pathsCoreTools,
68
+ editorCoreScript,
69
+ editorCoreTools,
78
70
  'window.dteStore.sendData("--core-loaded")',
79
71
  ...tools.map(tool => tool.path),
80
72
  ...(customJS ? (Array.isArray(customJS) ? customJS : [customJS]) : []),
81
73
  'window.dteStore.sendData("--data-loaded")',
82
74
  ].filter(js => !!js?.trim());
83
75
  const customStyles = [
84
- coreApi.customCss,
76
+ editorCoreStyles,
85
77
  ...(customCSS ? (Array.isArray(customCSS) ? customCSS : [customCSS]) : []),
86
78
  ].filter(css => !!css?.trim());
87
79