@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.
- package/dist/api-core.d.ts +1 -10
- package/dist/api-core.d.ts.map +1 -1
- package/dist/api-core.js +8 -67
- package/dist/api-core.js.map +1 -1
- package/dist/editor-core-source.d.ts +4 -0
- package/dist/editor-core-source.d.ts.map +1 -0
- package/dist/editor-core-source.js +5 -0
- package/dist/editor-core-source.js.map +1 -0
- package/dist/editor-core.d.ts +9 -0
- package/dist/editor-core.d.ts.map +1 -0
- package/dist/editor-core.js +9 -0
- package/dist/editor-core.js.map +1 -0
- package/dist/loadScript.d.ts +1 -0
- package/dist/loadScript.d.ts.map +1 -1
- package/dist/loadScript.js +5 -0
- package/dist/loadScript.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +3 -2
- package/dist/store.js.map +1 -1
- package/dist/unlayer-interface.d.ts +0 -2
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer.d.ts +1 -1
- package/dist/unlayer.d.ts.map +1 -1
- package/dist/unlayer.js +5 -4
- package/dist/unlayer.js.map +1 -1
- package/package.json +1 -1
- package/src/api-core.ts +4 -35
- package/src/editor-core-source.ts +4 -0
- package/src/editor-core.ts +8 -0
- package/src/loadScript.ts +6 -0
- package/src/store.ts +4 -2
- package/src/unlayer-interface.tsx +0 -2
- package/src/unlayer.tsx +5 -13
- package/dist/editor-core/core.bundle.js +0 -17354
- package/dist/editor-core/custom.css +0 -1
- package/dist/editor-core/tools.bundle.js +0 -34761
|
@@ -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
|
-
.
|
|
194
|
-
.
|
|
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
|
-
|
|
77
|
-
|
|
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
|
-
|
|
76
|
+
editorCoreStyles,
|
|
85
77
|
...(customCSS ? (Array.isArray(customCSS) ? customCSS : [customCSS]) : []),
|
|
86
78
|
].filter(css => !!css?.trim());
|
|
87
79
|
|