Skip to content

Commit 46bdfab

Browse files
committed
Replace unlayer-types with @unlayer/types
Migrate from the deprecated unlayer-types package to the new @unlayer/types scoped package and update type imports accordingly.
1 parent 3e26711 commit 46bdfab

4 files changed

Lines changed: 40 additions & 33 deletions

File tree

package-lock.json

Lines changed: 24 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
},
3232
"dependencies": {
33-
"unlayer-types": "latest"
33+
"@unlayer/types": "latest"
3434
},
3535
"devDependencies": {
3636
"@rollup/plugin-replace": "^5.0.2",

src/EmailEditor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import React, {
44
useImperativeHandle,
55
useMemo,
66
} from 'react';
7+
import type { UnlayerEditor } from '@unlayer/types';
78

89
import pkg from '../package.json';
9-
import { Editor, EditorRef, EmailEditorProps } from './types';
10+
import { EditorRef, EmailEditorProps } from './types';
1011
import { loadScript } from './loadScript';
1112

1213
const win = typeof window === 'undefined' ? { __unlayer_lastEditorId: 0 } : window
@@ -16,7 +17,7 @@ export const EmailEditor = React.forwardRef<EditorRef, EmailEditorProps>(
1617
(props, ref) => {
1718
const { onLoad, onReady, scriptUrl, minHeight = 500, style = {} } = props;
1819

19-
const [editor, setEditor] = useState<Editor | null>(null);
20+
const [editor, setEditor] = useState<UnlayerEditor | null>(null);
2021

2122
const [hasLoadedEmbedScript, setHasLoadedEmbedScript] = useState(false);
2223

src/types.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
/// <reference path="../node_modules/unlayer-types/embed.d.ts" />
2-
31
import { CSSProperties } from 'react';
42

5-
import Embed from 'embed/index';
6-
import { Editor as EditorClass } from 'embed/Editor';
7-
import { AppearanceConfig, DisplayMode, ToolsConfig } from 'state/types/types';
8-
9-
export type Unlayer = typeof Embed;
10-
export type UnlayerOptions = Parameters<Unlayer['createEditor']>[0];
11-
export type Editor = InstanceType<typeof EditorClass>;
3+
import type {
4+
AppearanceConfig,
5+
DisplayMode,
6+
ToolsConfig,
7+
UnlayerEditor,
8+
UnlayerEmbed,
9+
UnlayerOptions,
10+
} from '@unlayer/types';
1211

1312
export interface EditorRef {
14-
editor: Editor | null;
13+
editor: UnlayerEditor | null;
1514
}
1615

1716
export interface EmailEditorProps {
1817
editorId?: string | undefined;
1918
minHeight?: number | string | undefined;
20-
onLoad?(unlayer: Editor): void;
21-
onReady?(unlayer: Editor): void;
19+
onLoad?(unlayer: UnlayerEditor): void;
20+
onReady?(unlayer: UnlayerEditor): void;
2221
options?: UnlayerOptions | undefined;
2322
scriptUrl?: string | undefined;
2423
style?: CSSProperties | undefined;
@@ -37,7 +36,7 @@ export interface EmailEditorProps {
3736
}
3837

3938
declare global {
40-
const unlayer: Unlayer;
39+
const unlayer: UnlayerEmbed;
4140

4241
interface Window {
4342
__unlayer_lastEditorId: number;

0 commit comments

Comments
 (0)