Skip to content

Commit cbdafad

Browse files
committed
fix: slate issues fixed
1 parent 21dfb3a commit cbdafad

File tree

15 files changed

+156
-90
lines changed

15 files changed

+156
-90
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
],
3333
"dependencies": {
3434
"@date-io/moment": "1.3.9",
35-
"@emotion/css": "11.1.3",
3635
"@material-ui/core": "4.11.2",
3736
"@material-ui/icons": "4.11.2",
3837
"@material-ui/lab": "4.0.0-alpha.58",
@@ -66,6 +65,7 @@
6665
"slate-plain-serializer": "0.7.13",
6766
"slate-react": "0.22.9",
6867
"slate-soft-break": "0.9.0",
68+
"styled-components": "^5.3.0",
6969
"typeface-roboto": "0.0.75",
7070
"url-shim": "1.0.1",
7171
"util": "0.12.3"

scripts/generator/components.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@
9292
"name": "upload"
9393
},
9494
"@react-jsonschema-form-components/rich-text-editor": {
95-
"version": "1.0.3",
95+
"version": "2.0.0",
9696
"type": "string",
9797
"isEnum": false,
98+
"hasDist": true,
9899
"name": "rich-text-editor"
99100
},
100101
"@react-jsonschema-form-components/material-input": {

scripts/generator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@react-jsonschema-form-components/material-radio-group": "2.0.1",
1919
"@react-jsonschema-form-components/material-select": "2.0.1",
2020
"@react-jsonschema-form-components/react-select": "2.0.1",
21-
"@react-jsonschema-form-components/rich-text-editor": "1.0.3",
21+
"@react-jsonschema-form-components/rich-text-editor": "2.0.0",
2222
"@react-jsonschema-form-components/upload": "1.0.4",
2323
"@react-jsonschema-form-interceptors/translate-currency": "1.0.4",
2424
"@react-jsonschema-form-interceptors/translate-range-date": "1.0.2",

scripts/generator/templates/components-config.template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const COMP_CONFIG = {
9696
.filter((c) => !c.isEnum && c.type === "string" && !c.notAvailable && !c.isDefault).forEach((comp) => { %>
9797
<%= comp.name.toUpperCase().replace(/-/g, '_') %>: {
9898
name: '<%= comp.name %>',
99-
component: require('./<%= comp.name %>').default,
99+
component: <% if(comp.hasDist) { %> require('./<%= comp.name %>/dist').default <% } else { %> require('./<%= comp.name %>').default <% } %>,
100100
},
101101
<% }); %>
102102
...DEFAULT_COMPONENTS,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__tests__
2+
src
3+
node_modules
4+
tsconfig.json
5+
package-lock.json

src/fields/components/RichTextEditor/lib/components.jsx

Lines changed: 0 additions & 72 deletions
This file was deleted.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"name": "@react-jsonschema-form-components/rich-text-editor",
3-
"version": "1.0.3",
4-
"author": "Vipin Tanna"
3+
"version": "2.0.0",
4+
"author": "Vipin Tanna",
5+
"main": "dist/index.js",
6+
"scripts": {
7+
"build": "rm -rf dist && tsc",
8+
"prepublishOnly": "npm run build"
9+
}
510
}

src/fields/components/RichTextEditor/lib/RichText.jsx renamed to src/fields/components/RichTextEditor/src/lib/RichText.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* eslint-disable react/sort-comp */
2+
/* eslint-disable react/state-in-constructor */
3+
/* eslint-disable react/destructuring-assignment */
4+
/* eslint-disable default-case */
5+
/* eslint-disable consistent-return */
16
import React from 'react';
27
import Html from 'slate-html-serializer';
38
import { Editor, getEventTransfer } from 'slate-react';
@@ -146,7 +151,7 @@ const isCodeHotkey = isKeyHotkey('mod+`');
146151
* @type {Component}
147152
*/
148153

149-
class RichText extends React.Component {
154+
class RichText extends React.Component<any, any> {
150155
/**
151156
* Deserialize the initial editor value.
152157
*
@@ -210,7 +215,7 @@ class RichText extends React.Component {
210215

211216
onPaste = (event, change, next) => {
212217
const transfer = getEventTransfer(event);
213-
if (transfer.type != 'html') return next();
218+
if (transfer.type !== 'html') return next();
214219
const { document } = serializer.deserialize(transfer.html);
215220
change.insertFragment(document);
216221
}
@@ -247,7 +252,7 @@ class RichText extends React.Component {
247252
else {
248253
// Handle the extra wrapping required for list buttons.
249254
const isList = this.hasBlock('list-item');
250-
const isType = value.blocks.some((block) => !!document.getClosest(block.key, (parent) => parent.type == type));
255+
const isType = value.blocks.some((block) => !!document.getClosest(block.key, (parent) => parent.type === type));
251256

252257
if (isList && isType) {
253258
change
@@ -375,6 +380,8 @@ class RichText extends React.Component {
375380
return next();
376381
}
377382
}
383+
384+
editor: any;
378385

379386
/**
380387
* Render.

0 commit comments

Comments
 (0)