@servicetitan/dte-unlayer 0.68.0 → 0.70.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/src/editor.tsx CHANGED
@@ -32,21 +32,20 @@ export interface UnlayerEditorProps {
32
32
  export const useUnlayerRef = () => useRef<UnlayerRef | null>(null);
33
33
 
34
34
  export const UnlayerEditor = forwardRef<UnlayerRef, UnlayerEditorProps>((props, ref) => {
35
- const [status, setStatus] = useState(0);
35
+ const [isReady, setIsReady] = useState(false);
36
36
  const containerRef = useRef<HTMLDivElement | null>(null);
37
37
  const store = useMemo(
38
38
  () => new UnlayerStore(props.opts),
39
39
  // eslint-disable-next-line react-hooks/exhaustive-deps
40
40
  []
41
41
  );
42
- const isReady = status === 2;
43
42
 
44
43
  useEffect(() => {
45
44
  if (containerRef.current) {
46
45
  store
47
46
  .init(containerRef.current)
48
- .then(() => setStatus(2))
49
- .catch(() => setStatus(1));
47
+ .then(() => setIsReady(true))
48
+ .catch(() => setIsReady(false));
50
49
  }
51
50
 
52
51
  return () => store.destroy();
@@ -99,7 +98,7 @@ export const UnlayerEditor = forwardRef<UnlayerRef, UnlayerEditorProps>((props,
99
98
 
100
99
  return (
101
100
  <div style={{ minHeight, display: 'flex' }}>
102
- {status === 1 && <p className="c-red-500">error loading editor</p>}
101
+ {!isReady && <p className="c-red-500">error loading editor</p>}
103
102
  <div id={props.id ?? 'editor'} style={style} ref={containerRef} />
104
103
  </div>
105
104
  );
package/src/store.ts CHANGED
@@ -70,7 +70,7 @@ export class UnlayerStore {
70
70
 
71
71
  this.isInit = true;
72
72
 
73
- window.addEventListener('message', this.onPostMessage);
73
+ setTimeout(() => window.addEventListener('message', this.onPostMessage));
74
74
 
75
75
  await loadScript(defaultScriptUrl);
76
76
 
package/src/tools.ts CHANGED
@@ -170,7 +170,7 @@ export const unlayerToolsCustomStat = (
170
170
  }
171
171
 
172
172
  if (
173
- (isUnit && !units?.some(unit => unit.id === isUnit.id)) ||
173
+ (isUnit && !units?.some(unit => unit.id === isUnit.id)) ??
174
174
  (!isUnit && !tools?.some(t => t.key === tool.slug))
175
175
  ) {
176
176
  notSupported.add(tool.slug);
@@ -70,4 +70,5 @@ export interface CreateUnlayerEditorProps {
70
70
  blocks?: boolean;
71
71
  hideAllTools?: boolean;
72
72
  hideContentControls?: boolean;
73
+ hideBodyMenuItem?: boolean;
73
74
  }
package/src/unlayer.tsx CHANGED
@@ -61,7 +61,7 @@ export interface EventDesignUpdated {
61
61
  * to know correct schema version, open unlayer editor and check output design ('schema' property)
62
62
  */
63
63
  export const versions = {
64
- unlayer: '1.9.0',
64
+ unlayer: '1.9.1',
65
65
  schema: 16,
66
66
  };
67
67
 
@@ -85,6 +85,15 @@ export const hideUnlayerContentsControls = () => {
85
85
  }
86
86
  `;
87
87
  };
88
+
89
+ export const hideUnlayerBodyMenuItem = () => {
90
+ return `
91
+ .nav-item.tab-body {
92
+ display: none !important;
93
+ }
94
+ `;
95
+ };
96
+
88
97
  export const hideUnlayerTools = () => {
89
98
  return `
90
99
  .blockbuilder-content-tools {
@@ -126,6 +135,7 @@ export const createUnlayerEditor = (
126
135
  customCSS,
127
136
  customJS,
128
137
  hideAllTools,
138
+ hideBodyMenuItem,
129
139
  hideContentControls,
130
140
  latest,
131
141
  mergeTags,
@@ -153,6 +163,7 @@ export const createUnlayerEditor = (
153
163
  */
154
164
  hideAllTools ? hideUnlayerTools() : '',
155
165
  hideContentControls ? hideUnlayerContentsControls() : '',
166
+ hideBodyMenuItem ? hideUnlayerBodyMenuItem() : '',
156
167
  ].filter(css => !!css?.trim());
157
168
 
158
169
  /**