@servicetitan/dte-unlayer 0.41.0 → 0.43.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/editor-core-source.d.ts +1 -1
- package/dist/editor-core-source.d.ts.map +1 -1
- package/dist/editor-core-source.js +1 -1
- package/dist/editor-core-source.js.map +1 -1
- package/dist/unlayer-interface.d.ts +7 -0
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer.d.ts +4 -2
- package/dist/unlayer.d.ts.map +1 -1
- package/dist/unlayer.js +47 -1
- package/dist/unlayer.js.map +1 -1
- package/package.json +1 -1
- package/src/editor-core-source.ts +1 -1
- package/src/unlayer-interface.tsx +8 -0
- package/src/unlayer.tsx +67 -2
|
@@ -51,6 +51,12 @@ export interface UnlayerEditorCustomTool {
|
|
|
51
51
|
groupUrl?: string;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
export interface HideToolConfigActions {
|
|
55
|
+
deleteAction?: boolean;
|
|
56
|
+
duplicateAction?: boolean;
|
|
57
|
+
closeAction?: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
export interface CreateUnlayerEditorProps {
|
|
55
61
|
tools: UnlayerEditorCustomTool[];
|
|
56
62
|
newSnapshot?: UnlayerEditorTwin;
|
|
@@ -67,4 +73,6 @@ export interface CreateUnlayerEditorProps {
|
|
|
67
73
|
noCoreTools?: boolean;
|
|
68
74
|
latest?: boolean;
|
|
69
75
|
blocks?: boolean;
|
|
76
|
+
preselectToolSlug?: string;
|
|
77
|
+
hideToolConfigActions?: HideToolConfigActions;
|
|
70
78
|
}
|
package/src/unlayer.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { editorCoreScript, editorCoreStyles, editorCoreTools } from './editor-co
|
|
|
2
2
|
import { constGenericsEditor } from './shared/const';
|
|
3
3
|
import { unlayerSupportedFonts } from './shared/fonts';
|
|
4
4
|
import { unlayerCustomToolsGetRegisterUrls } from './tools';
|
|
5
|
-
import { CreateUnlayerEditorProps } from './unlayer-interface';
|
|
5
|
+
import { CreateUnlayerEditorProps, HideToolConfigActions } from './unlayer-interface';
|
|
6
6
|
|
|
7
7
|
export interface UnlayerExport {
|
|
8
8
|
html: string;
|
|
@@ -61,9 +61,64 @@ export const versions = {
|
|
|
61
61
|
schema: 5,
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
export const handlePreselectTool = (preselectToolSlug: string) => {
|
|
65
|
+
return `
|
|
66
|
+
const element = document.querySelector('.u_content_custom_${preselectToolSlug}');
|
|
67
|
+
if (element) {
|
|
68
|
+
element.click();
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const prepareToolConfigActionsVisibility = (
|
|
74
|
+
hideToolConfigActions?: HideToolConfigActions
|
|
75
|
+
) => {
|
|
76
|
+
if (!hideToolConfigActions) {
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let styles = '';
|
|
81
|
+
|
|
82
|
+
if (hideToolConfigActions.deleteAction) {
|
|
83
|
+
styles += `
|
|
84
|
+
.blockbuilder-options-header .icon-delete {
|
|
85
|
+
display: none !important;
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (hideToolConfigActions.duplicateAction) {
|
|
91
|
+
styles += `
|
|
92
|
+
.blockbuilder-options-header .icon-duplicate {
|
|
93
|
+
display: none !important;
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (hideToolConfigActions.closeAction) {
|
|
99
|
+
styles += `
|
|
100
|
+
.blockbuilder-options-header .icon-close {
|
|
101
|
+
display: none !important;
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return styles;
|
|
107
|
+
};
|
|
108
|
+
|
|
64
109
|
export const createUnlayerEditor = (
|
|
65
110
|
container: HTMLDivElement,
|
|
66
|
-
{
|
|
111
|
+
{
|
|
112
|
+
customCSS,
|
|
113
|
+
customJS,
|
|
114
|
+
hideToolConfigActions,
|
|
115
|
+
latest,
|
|
116
|
+
mergeTags,
|
|
117
|
+
noCoreTools,
|
|
118
|
+
preselectToolSlug,
|
|
119
|
+
tools,
|
|
120
|
+
units,
|
|
121
|
+
}: CreateUnlayerEditorProps
|
|
67
122
|
): Unlayer => {
|
|
68
123
|
const customScripts = [
|
|
69
124
|
editorCoreScript,
|
|
@@ -71,11 +126,21 @@ export const createUnlayerEditor = (
|
|
|
71
126
|
'window.dteStore.sendData("--core-loaded")',
|
|
72
127
|
...unlayerCustomToolsGetRegisterUrls(tools),
|
|
73
128
|
...(customJS ? (Array.isArray(customJS) ? customJS : [customJS]) : []),
|
|
129
|
+
/*
|
|
130
|
+
* @TODO this is workaround for preselecting tool, will be better to use unlayer functionality for this
|
|
131
|
+
* but it is not implemented yet
|
|
132
|
+
*/
|
|
133
|
+
preselectToolSlug ? handlePreselectTool(preselectToolSlug) : '',
|
|
74
134
|
'window.dteStore.sendData("--data-loaded")',
|
|
75
135
|
].filter(js => !!js?.trim());
|
|
76
136
|
const customStyles = [
|
|
77
137
|
editorCoreStyles,
|
|
78
138
|
...(customCSS ? (Array.isArray(customCSS) ? customCSS : [customCSS]) : []),
|
|
139
|
+
/*
|
|
140
|
+
* @TODO this is workaround for hiding delete, duplicate and close buttons from tool config.
|
|
141
|
+
* Will be better to use unlayer functionality for this but it is not implemented yet
|
|
142
|
+
*/
|
|
143
|
+
prepareToolConfigActionsVisibility(hideToolConfigActions),
|
|
79
144
|
].filter(css => !!css?.trim());
|
|
80
145
|
|
|
81
146
|
/**
|