@team-monolith/cds 0.29.5 → 0.29.7
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/patterns/ReactEditorJS/ReactEditorJS.js +7 -5
- package/dist/patterns/ReactEditorJS/customTools/block/Callout.d.ts +4 -6
- package/dist/patterns/ReactEditorJS/customTools/block/Callout.js +10 -8
- package/dist/patterns/ReactEditorJS/customTools/block/Quote.d.ts +4 -6
- package/dist/patterns/ReactEditorJS/customTools/block/Quote.js +10 -8
- package/dist/patterns/ReactEditorJS/customTools/block/Table.d.ts +1 -2
- package/dist/patterns/ReactEditorJS/customTools/block/Table.js +6 -10
- package/package.json +3 -3
|
@@ -27,19 +27,21 @@ export function ReactEditorJS(props) {
|
|
|
27
27
|
}
|
|
28
28
|
}), []);
|
|
29
29
|
const handleSave = useCallback((onChange) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
var _a;
|
|
31
30
|
if (!editorCore.current || readOnly) {
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
34
33
|
// 저장 전에 isReady 상태를 기다리기
|
|
35
34
|
// https://github.com/codex-team/editor.js/issues/1136
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const savedData = yield
|
|
35
|
+
try {
|
|
36
|
+
yield editorCore.current.dangerouslyLowLevelInstance.isReady;
|
|
37
|
+
const savedData = yield editorCore.current.save();
|
|
39
38
|
if (savedData) {
|
|
40
39
|
onChange(savedData.blocks);
|
|
41
40
|
}
|
|
42
|
-
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
44
|
+
}
|
|
43
45
|
}), []);
|
|
44
46
|
// blocks가 변경될 때 preview가 다시 렌더링되게 하려면 controlled component를 위한 "value"인자를 전달하는 것이 올바른 방법이지만
|
|
45
47
|
// controlled를 위해 "defaultValue" 대신 "value"를 사용하면 불필요하게 많이 리렌더링 되고, 그에 따른 오류가 발생합니다.
|
|
@@ -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 CalloutStyle: (theme: Theme) => import("@emotion/utils").SerializedStyles;
|
|
9
5
|
export declare class Callout implements BlockTool {
|
|
10
6
|
api: any;
|
|
@@ -12,11 +8,13 @@ export declare class Callout implements BlockTool {
|
|
|
12
8
|
readOnly: any;
|
|
13
9
|
private _wrapper;
|
|
14
10
|
constructor({ api, config, readOnly, data }: any);
|
|
15
|
-
|
|
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;
|
|
@@ -74,6 +74,7 @@ export class Callout {
|
|
|
74
74
|
this.readOnly = readOnly;
|
|
75
75
|
this._wrapper = this.createWrapper(data);
|
|
76
76
|
}
|
|
77
|
+
/** 주어진 data에 따라 HTML Element를 반환함. */
|
|
77
78
|
createWrapper(data) {
|
|
78
79
|
const wrapper = document.createElement("div");
|
|
79
80
|
wrapper.classList.add("ce-callout", data.color || this.defaultColor);
|
|
@@ -81,6 +82,13 @@ export class Callout {
|
|
|
81
82
|
wrapper.innerHTML = data.text || "";
|
|
82
83
|
return wrapper;
|
|
83
84
|
}
|
|
85
|
+
/** 주어진 data에 따라 this._wrapper를 업데이트함. */
|
|
86
|
+
updateWrapper(data) {
|
|
87
|
+
var _a;
|
|
88
|
+
const newWrapper = this.createWrapper(data);
|
|
89
|
+
(_a = this._wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(newWrapper, this._wrapper);
|
|
90
|
+
this._wrapper = newWrapper;
|
|
91
|
+
}
|
|
84
92
|
get colors() {
|
|
85
93
|
return ["grey", "red", "yellow", "blue", "green"];
|
|
86
94
|
}
|
|
@@ -90,12 +98,6 @@ export class Callout {
|
|
|
90
98
|
get color() {
|
|
91
99
|
return this._wrapper.classList[1];
|
|
92
100
|
}
|
|
93
|
-
set data(data) {
|
|
94
|
-
var _a;
|
|
95
|
-
const newWrapper = this.createWrapper(data);
|
|
96
|
-
(_a = this._wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(newWrapper, this._wrapper);
|
|
97
|
-
this._wrapper = newWrapper;
|
|
98
|
-
}
|
|
99
101
|
save() {
|
|
100
102
|
var _a;
|
|
101
103
|
return {
|
|
@@ -138,10 +140,10 @@ export class Callout {
|
|
|
138
140
|
closeOnActivate: true,
|
|
139
141
|
onActivate: () => {
|
|
140
142
|
var _a;
|
|
141
|
-
this.
|
|
143
|
+
this.updateWrapper({
|
|
142
144
|
color: tune.name,
|
|
143
145
|
text: (_a = this._wrapper.innerHTML) !== null && _a !== void 0 ? _a : "",
|
|
144
|
-
};
|
|
146
|
+
});
|
|
145
147
|
},
|
|
146
148
|
}));
|
|
147
149
|
}
|
|
@@ -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
|
-
|
|
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.
|
|
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
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import EditorJSTable from "@editorjs/table";
|
|
2
2
|
export declare class Table extends EditorJSTable {
|
|
3
|
-
constructor({ api, config, readOnly, data }: any);
|
|
4
3
|
static get toolbox(): {
|
|
5
4
|
icon: string;
|
|
6
5
|
title: string;
|
|
7
6
|
};
|
|
8
|
-
getConfig(configName: string, savedData: any): any;
|
|
7
|
+
getConfig(configName: string, defaultValue: any, savedData: any): any;
|
|
9
8
|
renderSettings(): any[];
|
|
10
9
|
}
|
|
@@ -4,11 +4,8 @@ const TUNE_ICONS = [
|
|
|
4
4
|
`<img src="${layoutTopLineSvg}" />`,
|
|
5
5
|
`<img src="${layoutGridLineSvg}" />`,
|
|
6
6
|
];
|
|
7
|
+
// https://github.com/editor-js/table/blob/master/src/plugin.js
|
|
7
8
|
export class Table extends EditorJSTable {
|
|
8
|
-
constructor({ api, config, readOnly, data }) {
|
|
9
|
-
super({ api, config, readOnly, data });
|
|
10
|
-
this.data = Object.assign(Object.assign({}, this.data), { withHeadings: this.getConfig("withHeadings", data) });
|
|
11
|
-
}
|
|
12
9
|
static get toolbox() {
|
|
13
10
|
return {
|
|
14
11
|
icon: `<img src="${table2Svg}" />`,
|
|
@@ -16,15 +13,14 @@ export class Table extends EditorJSTable {
|
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
15
|
// https://github.com/editor-js/table/pull/134
|
|
19
|
-
// 기존 내부의 getConfig에 오류가 있고, 이를 수정하기 위해
|
|
20
|
-
getConfig(configName, savedData) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return data[configName];
|
|
16
|
+
// 기존 내부의 getConfig에 오류가 있고, 이를 수정하기 위해 override합니다.
|
|
17
|
+
getConfig(configName, defaultValue = false, savedData) {
|
|
18
|
+
if (savedData && configName in savedData) {
|
|
19
|
+
return savedData[configName];
|
|
24
20
|
}
|
|
25
21
|
return this.config && this.config[configName]
|
|
26
22
|
? this.config[configName]
|
|
27
|
-
:
|
|
23
|
+
: defaultValue;
|
|
28
24
|
}
|
|
29
25
|
renderSettings() {
|
|
30
26
|
return Array.from(super.renderSettings()).map((setting, i) => (Object.assign(Object.assign({}, setting), { icon: TUNE_ICONS[i] })));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@team-monolith/cds",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@editorjs/underline": "^1.1.0",
|
|
17
17
|
"@emotion/react": "^11.8.2",
|
|
18
18
|
"@emotion/styled": "^11.8.1",
|
|
19
|
-
"@mui/material": "^5.13.6",
|
|
19
|
+
"@mui/material": "^5.13.6",
|
|
20
20
|
"@types/node": "^16.11.26",
|
|
21
21
|
"@types/react": "^17.0.39",
|
|
22
22
|
"@types/react-dom": "^17.0.11",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"hex-to-css-filter": "^5.4.0",
|
|
25
25
|
"react": "^17.0.2",
|
|
26
26
|
"react-dom": "^17.0.2",
|
|
27
|
-
"react-editor-js": "^2.1.0",
|
|
27
|
+
"react-editor-js": "^2.1.0",
|
|
28
28
|
"remixicon": "^3.4.0",
|
|
29
29
|
"typescript": "^4.5.5",
|
|
30
30
|
"uid": "^2.0.2"
|