@team-monolith/cds 0.29.6 → 0.29.8

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.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { EditorCore } from "@react-editor-js/core";
2
3
  export interface ReactEditorJSProps {
3
4
  className?: string;
4
5
  /** 읽기모드 여부(preview 여부) */
@@ -9,5 +10,7 @@ export interface ReactEditorJSProps {
9
10
  onChange?: (blocks: any) => void;
10
11
  /** 에러 발생시 처리콜백 */
11
12
  onError?: (error: any) => void;
13
+ /** 초기화시 콜백 */
14
+ onInitialize?: (instance: EditorCore) => void;
12
15
  }
13
16
  export declare function ReactEditorJS(props: ReactEditorJSProps): JSX.Element;
@@ -14,13 +14,14 @@ import Layout from "./Layout";
14
14
  import TOOLS from "./tools";
15
15
  import I18n from "./i18n";
16
16
  export function ReactEditorJS(props) {
17
- const { className, readOnly = false, blocks, onChange, onError } = props;
17
+ const { className, readOnly = false, blocks, onChange, onError, onInitialize } = props;
18
18
  const ReactEditorJS = createReactEditorJS();
19
19
  const editorCore = useRef(null);
20
20
  const handleInitialize = useCallback((instance) => __awaiter(this, void 0, void 0, function* () {
21
21
  try {
22
22
  yield instance.dangerouslyLowLevelInstance.isReady;
23
23
  editorCore.current = instance;
24
+ onInitialize === null || onInitialize === void 0 ? void 0 : onInitialize(instance);
24
25
  }
25
26
  catch (e) {
26
27
  onError === null || onError === void 0 ? void 0 : onError(e);
@@ -8,7 +8,9 @@ export declare class Callout implements BlockTool {
8
8
  readOnly: any;
9
9
  private _wrapper;
10
10
  constructor({ api, config, readOnly, data }: any);
11
+ /** 주어진 data에 따라 HTML Element를 반환함. */
11
12
  private createWrapper;
13
+ /** 주어진 data에 따라 this._wrapper를 업데이트함. */
12
14
  private updateWrapper;
13
15
  get colors(): string[];
14
16
  get defaultColor(): string;
@@ -74,7 +74,7 @@ export class Callout {
74
74
  this.readOnly = readOnly;
75
75
  this._wrapper = this.createWrapper(data);
76
76
  }
77
- /* 주어진 data에 HTML Element를 반환함. */
77
+ /** 주어진 data에 따라 HTML Element를 반환함. */
78
78
  createWrapper(data) {
79
79
  const wrapper = document.createElement("div");
80
80
  wrapper.classList.add("ce-callout", data.color || this.defaultColor);
@@ -82,6 +82,7 @@ export class Callout {
82
82
  wrapper.innerHTML = data.text || "";
83
83
  return wrapper;
84
84
  }
85
+ /** 주어진 data에 따라 this._wrapper를 업데이트함. */
85
86
  updateWrapper(data) {
86
87
  var _a;
87
88
  const newWrapper = this.createWrapper(data);
@@ -1,10 +1,6 @@
1
1
  import { BlockTool } from "@editorjs/editorjs";
2
2
  import { Theme } from "@emotion/react";
3
3
  type COLOR_TYPE = "grey" | "red" | "yellow" | "blue" | "green";
4
- type DATA_TYPE = {
5
- color: COLOR_TYPE;
6
- text: string;
7
- };
8
4
  export declare const QuoteStyle: (theme: Theme) => import("@emotion/utils").SerializedStyles;
9
5
  export declare class Quote implements BlockTool {
10
6
  api: any;
@@ -12,11 +8,13 @@ export declare class Quote implements BlockTool {
12
8
  readOnly: any;
13
9
  private _wrapper;
14
10
  constructor({ api, config, readOnly, data }: any);
15
- createWrapper(data: DATA_TYPE): HTMLDivElement;
11
+ /** 주어진 data 따라 HTML Element를 반환함. */
12
+ private createWrapper;
13
+ /** 주어진 data에 따라 this._wrapper를 업데이트함. */
14
+ private updateWrapper;
16
15
  get colors(): string[];
17
16
  get defaultColor(): string;
18
17
  get color(): COLOR_TYPE;
19
- set data(data: DATA_TYPE);
20
18
  save(): {
21
19
  color: COLOR_TYPE;
22
20
  text: string;
@@ -73,6 +73,7 @@ export class Quote {
73
73
  this.readOnly = readOnly;
74
74
  this._wrapper = this.createWrapper(data);
75
75
  }
76
+ /** 주어진 data에 따라 HTML Element를 반환함. */
76
77
  createWrapper(data) {
77
78
  const wrapper = document.createElement("div");
78
79
  wrapper.classList.add("ce-quote", data.color || this.defaultColor);
@@ -80,6 +81,13 @@ export class Quote {
80
81
  wrapper.innerHTML = data.text || "";
81
82
  return wrapper;
82
83
  }
84
+ /** 주어진 data에 따라 this._wrapper를 업데이트함. */
85
+ updateWrapper(data) {
86
+ var _a;
87
+ const newWrapper = this.createWrapper(data);
88
+ (_a = this._wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(newWrapper, this._wrapper);
89
+ this._wrapper = newWrapper;
90
+ }
83
91
  get colors() {
84
92
  return ["grey", "red", "yellow", "blue", "green"];
85
93
  }
@@ -89,12 +97,6 @@ export class Quote {
89
97
  get color() {
90
98
  return this._wrapper.classList[1];
91
99
  }
92
- set data(data) {
93
- var _a;
94
- const newWrapper = this.createWrapper(data);
95
- (_a = this._wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(newWrapper, this._wrapper);
96
- this._wrapper = newWrapper;
97
- }
98
100
  save() {
99
101
  var _a;
100
102
  return {
@@ -137,10 +139,10 @@ export class Quote {
137
139
  closeOnActivate: true,
138
140
  onActivate: () => {
139
141
  var _a;
140
- this.data = {
142
+ this.updateWrapper({
141
143
  color: tune.name,
142
144
  text: (_a = this._wrapper.innerHTML) !== null && _a !== void 0 ? _a : "",
143
- };
145
+ });
144
146
  },
145
147
  }));
146
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "0.29.6",
3
+ "version": "0.29.8",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,