@servicetitan/dte-unlayer 0.47.0 → 0.49.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.
@@ -36,3 +36,8 @@ export interface UnlayerEventRegister {
36
36
  }[];
37
37
  toolTwins?: UnlayerEditorTwin[];
38
38
  }
39
+
40
+ export interface UnlayerToolMetaData {
41
+ title: string;
42
+ description?: string;
43
+ }
package/src/tools.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { constGenericsEditor } from './shared/const';
1
+ import { constGenericsEditor, UnlayerToolMetaData } from './shared/const';
2
2
  import { unlayerToolsParseUnitKey } from './shared/tools';
3
3
  import { versions } from './unlayer';
4
4
  import {
@@ -221,3 +221,17 @@ export const unlayerCustomToolsGetRegisterUrls = (tools: UnlayerEditorCustomTool
221
221
  Array.from(
222
222
  new Set(tools.map(tool => (tool.groupUrl ? `${tool.groupUrl}/index.js` : tool.url)))
223
223
  );
224
+
225
+ export const unlayerCustomToolMetaData = (tools: UnlayerEditorCustomTool[]): string => {
226
+ const toolMetaData = tools.reduce((acc: Record<string, UnlayerToolMetaData>, tool) => {
227
+ acc[tool.key] = {
228
+ title: tool.title,
229
+ description: tool.description,
230
+ };
231
+ return acc;
232
+ }, {});
233
+
234
+ return `
235
+ window.dteStore.setToolMetaData(${JSON.stringify(toolMetaData)});
236
+ `;
237
+ };
@@ -47,6 +47,7 @@ export interface UnlayerEditorMergeTagInfo {
47
47
  export interface UnlayerEditorCustomTool {
48
48
  key: string;
49
49
  title: string;
50
+ description?: string;
50
51
  url: string;
51
52
  groupUrl?: string;
52
53
  }
package/src/unlayer.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { editorCoreScript, editorCoreStyles, editorCoreTools } from './editor-core';
2
2
  import { constGenericsEditor } from './shared/const';
3
3
  import { unlayerSupportedFonts } from './shared/fonts';
4
- import { unlayerCustomToolsGetRegisterUrls } from './tools';
4
+ import { unlayerCustomToolMetaData, unlayerCustomToolsGetRegisterUrls } from './tools';
5
5
  import { CreateUnlayerEditorProps } from './unlayer-interface';
6
6
 
7
7
  export interface UnlayerExport {
@@ -96,6 +96,7 @@ export const createUnlayerEditor = (
96
96
  editorCoreTools,
97
97
  'window.dteStore.sendData("--core-loaded")',
98
98
  ...unlayerCustomToolsGetRegisterUrls(tools),
99
+ unlayerCustomToolMetaData(tools),
99
100
  ...(customJS ? (Array.isArray(customJS) ? customJS : [customJS]) : []),
100
101
  'window.dteStore.sendData("--data-loaded")',
101
102
  ].filter(js => !!js?.trim());