@team-monolith/cds 1.2.1 → 1.2.2

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.
@@ -70,7 +70,23 @@ export declare const light: {
70
70
  };
71
71
  };
72
72
  };
73
+ interface CodleDesignSystemContext {
74
+ editorjs?: {
75
+ image: {
76
+ uploader: {
77
+ uploadByFile: (file: File) => Promise<{
78
+ success: number;
79
+ file: {
80
+ url: string;
81
+ };
82
+ }>;
83
+ };
84
+ };
85
+ };
86
+ }
87
+ export declare const CodleDesignSystemContext: import("react").Context<CodleDesignSystemContext>;
73
88
  export default function (props: {
74
89
  children: React.ReactNode;
75
90
  fontFamily?: string;
76
- }): React.ReactElement;
91
+ } & CodleDesignSystemContext): React.ReactElement;
92
+ export {};
@@ -4,6 +4,7 @@ import { ThemeProvider as MuiThemeProvider } from "@mui/material";
4
4
  import COLOR from "./foundation/color";
5
5
  import FONT from "./foundation/font";
6
6
  import { createTheme } from "@mui/material";
7
+ import { createContext } from "react";
7
8
  export const light = {
8
9
  fontFamily: {
9
10
  ui: FONT.pretendard,
@@ -75,6 +76,7 @@ export const light = {
75
76
  },
76
77
  },
77
78
  };
79
+ export const CodleDesignSystemContext = createContext({});
78
80
  // eslint-disable-next-line import/no-anonymous-default-export
79
81
  export default function (props) {
80
82
  const muiTheme = createTheme({
@@ -93,5 +95,5 @@ export default function (props) {
93
95
  body {
94
96
  font-family: ${FONT.pretendard};
95
97
  }
96
- ` }), _jsx(MuiThemeProvider, Object.assign({ theme: muiTheme }, { children: _jsx(ThemeProvider, Object.assign({ theme: light }, { children: props.children })) }))] }));
98
+ ` }), _jsx(MuiThemeProvider, Object.assign({ theme: muiTheme }, { children: _jsx(ThemeProvider, Object.assign({ theme: light }, { children: _jsx(CodleDesignSystemContext.Provider, Object.assign({ value: props }, { children: props.children })) })) }))] }));
97
99
  }
@@ -8,16 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- import { useCallback, useEffect, useRef, useState } from "react";
11
+ import { useCallback, useContext, useEffect, useRef, useState } from "react";
12
12
  import { createReactEditorJS } from "react-editor-js";
13
13
  import Layout from "./Layout";
14
14
  import TOOLS from "./tools";
15
15
  import I18n from "./i18n";
16
+ import { CodleDesignSystemContext } from "../../CodleDesignSystemProvider";
16
17
  export function ReactEditorJS(props) {
18
+ var _a;
17
19
  const { className, readOnly = false, blocks, onChange, onError, onInitialize, } = props;
18
20
  const ReactEditorJS = createReactEditorJS();
19
21
  const editorCore = useRef(null);
20
22
  const [isInitialized, setIsInitialized] = useState(false);
23
+ const codleDesignSystemContext = useContext(CodleDesignSystemContext);
21
24
  const handleInitialize = useCallback((instance) => __awaiter(this, void 0, void 0, function* () {
22
25
  try {
23
26
  setIsInitialized(false);
@@ -59,14 +62,17 @@ export function ReactEditorJS(props) {
59
62
  blocks,
60
63
  });
61
64
  }, [blocks, readOnly, isInitialized]);
65
+ const tools = Object.assign(Object.assign({}, TOOLS), { image: Object.assign(Object.assign({}, TOOLS.image), { config: {
66
+ uploader: (_a = codleDesignSystemContext.editorjs) === null || _a === void 0 ? void 0 : _a.image.uploader,
67
+ } }) });
62
68
  // readOnly가 변경되면 ReactEditorJS를 다시 마운트하기 위해 key를 변경합니다.
63
69
  // readOnly 모드에서는 onChange를 전달할 수 없어서 케이스를 분리합니다.
64
70
  if (readOnly) {
65
- return (_jsx(Layout, Object.assign({ className: className, readOnly: true }, { children: _jsx(ReactEditorJS, { onInitialize: handleInitialize, tools: TOOLS, defaultValue: {
71
+ return (_jsx(Layout, Object.assign({ className: className, readOnly: true }, { children: _jsx(ReactEditorJS, { onInitialize: handleInitialize, tools: tools, defaultValue: {
66
72
  blocks,
67
73
  }, i18n: I18n, readOnly: true }, "readOnly") })));
68
74
  }
69
- return (_jsx(Layout, Object.assign({ className: className }, { children: _jsx(ReactEditorJS, { onInitialize: handleInitialize, tools: TOOLS, inlineToolbar: [
75
+ return (_jsx(Layout, Object.assign({ className: className }, { children: _jsx(ReactEditorJS, { onInitialize: handleInitialize, tools: tools, inlineToolbar: [
70
76
  "bold",
71
77
  "italic",
72
78
  "underline",
@@ -50,7 +50,9 @@ declare const TOOLS: {
50
50
  withHeadings: boolean;
51
51
  };
52
52
  };
53
- image: typeof Image;
53
+ image: {
54
+ class: typeof Image;
55
+ };
54
56
  bold: {
55
57
  class: typeof Bold;
56
58
  shortcut: string;
@@ -74,7 +74,9 @@ const TOOLS = {
74
74
  withHeadings: true,
75
75
  },
76
76
  },
77
- image: Image,
77
+ image: {
78
+ class: Image,
79
+ },
78
80
  // 인라인 툴 : ReactEditorJS에서 inlineToolbar를 지정하여 노출합니다.
79
81
  bold: {
80
82
  class: Bold,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,