@react-editor-js/client
Advanced tools
Comparing version 2.0.4 to 2.0.5
'use strict'; | ||
var React = require('react'); | ||
var Paragraph = require('@editorjs/paragraph'); | ||
var EditorJS = require('@editorjs/editorjs'); | ||
var Paragraph = require('@editorjs/paragraph'); | ||
@@ -10,4 +10,4 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var Paragraph__default = /*#__PURE__*/_interopDefaultLegacy(Paragraph); | ||
var EditorJS__default = /*#__PURE__*/_interopDefaultLegacy(EditorJS); | ||
var Paragraph__default = /*#__PURE__*/_interopDefaultLegacy(Paragraph); | ||
@@ -41,4 +41,4 @@ /*! ***************************************************************************** | ||
const ReactEditorJS = function ReactEditorJS(_a) { | ||
var { holder, tools, defaultValue, children, value, onInitialize } = _a, restProps = __rest(_a, ["holder", "tools", "defaultValue", "children", "value", "onInitialize"]); | ||
function ReactEditorJS(_a) { | ||
var { factory, holder, tools, defaultValue, children, value, onInitialize } = _a, restProps = __rest(_a, ["factory", "holder", "tools", "defaultValue", "children", "value", "onInitialize"]); | ||
const memoizedHolder = React__default["default"].useRef(holder !== null && holder !== void 0 ? holder : `react-editor-js-${Date.now().toString(16)}`); | ||
@@ -53,3 +53,3 @@ const editorJS = React__default["default"].useRef(null); | ||
} }, tools); | ||
editorJS.current = new EditorJS__default["default"](Object.assign(Object.assign({ tools: extendTools, holder: memoizedHolder.current }, (defaultValue && { data: defaultValue })), restProps)); | ||
editorJS.current = factory.create(Object.assign(Object.assign({ tools: extendTools, holder: memoizedHolder.current }, (defaultValue && { data: defaultValue })), restProps)); | ||
onInitialize === null || onInitialize === void 0 ? void 0 : onInitialize(editorJS.current); | ||
@@ -68,4 +68,15 @@ return () => { | ||
return children || React__default["default"].createElement("div", { id: memoizedHolder.current }); | ||
}; | ||
} | ||
module.exports = ReactEditorJS; | ||
class ClientEditorJSFactory { | ||
create(config) { | ||
return new EditorJS__default["default"](config); | ||
} | ||
} | ||
function ReactEditorJSClient(props) { | ||
const factory = React__default["default"].useMemo(() => new ClientEditorJSFactory(), []); | ||
return React__default["default"].createElement(ReactEditorJS, Object.assign({ factory: factory }, props)); | ||
} | ||
module.exports = ReactEditorJSClient; |
import React from 'react'; | ||
import Paragraph from '@editorjs/paragraph'; | ||
import EditorJS from '@editorjs/editorjs'; | ||
import Paragraph from '@editorjs/paragraph'; | ||
@@ -32,4 +32,4 @@ /*! ***************************************************************************** | ||
const ReactEditorJS = function ReactEditorJS(_a) { | ||
var { holder, tools, defaultValue, children, value, onInitialize } = _a, restProps = __rest(_a, ["holder", "tools", "defaultValue", "children", "value", "onInitialize"]); | ||
function ReactEditorJS(_a) { | ||
var { factory, holder, tools, defaultValue, children, value, onInitialize } = _a, restProps = __rest(_a, ["factory", "holder", "tools", "defaultValue", "children", "value", "onInitialize"]); | ||
const memoizedHolder = React.useRef(holder !== null && holder !== void 0 ? holder : `react-editor-js-${Date.now().toString(16)}`); | ||
@@ -44,3 +44,3 @@ const editorJS = React.useRef(null); | ||
} }, tools); | ||
editorJS.current = new EditorJS(Object.assign(Object.assign({ tools: extendTools, holder: memoizedHolder.current }, (defaultValue && { data: defaultValue })), restProps)); | ||
editorJS.current = factory.create(Object.assign(Object.assign({ tools: extendTools, holder: memoizedHolder.current }, (defaultValue && { data: defaultValue })), restProps)); | ||
onInitialize === null || onInitialize === void 0 ? void 0 : onInitialize(editorJS.current); | ||
@@ -59,4 +59,15 @@ return () => { | ||
return children || React.createElement("div", { id: memoizedHolder.current }); | ||
}; | ||
} | ||
export { ReactEditorJS as default }; | ||
class ClientEditorJSFactory { | ||
create(config) { | ||
return new EditorJS(config); | ||
} | ||
} | ||
function ReactEditorJSClient(props) { | ||
const factory = React.useMemo(() => new ClientEditorJSFactory(), []); | ||
return React.createElement(ReactEditorJS, Object.assign({ factory: factory }, props)); | ||
} | ||
export { ReactEditorJSClient as default }; |
@@ -1,2 +0,1 @@ | ||
import ReactEditorJS from './ReactEditorJS'; | ||
export default ReactEditorJS; | ||
export { default } from './ReactEditorJSClient'; |
{ | ||
"name": "@react-editor-js/client", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "The unofficial editor-js component for React on client", | ||
@@ -17,17 +17,13 @@ "main": "./dist/client.cjs.js", | ||
"@editorjs/editorjs": "*", | ||
"@editorjs/paragraph": "*", | ||
"@react-editor-js/core": "2.0.4", | ||
"react": "*" | ||
}, | ||
"dependencies": { | ||
"@react-editor-js/core": "2.0.4" | ||
"@react-editor-js/core": "2.0.5" | ||
}, | ||
"devDependencies": { | ||
"@editorjs/editorjs": "*", | ||
"@editorjs/paragraph": "*", | ||
"@types/react": "*", | ||
"react": "*", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.3.5" | ||
} | ||
} |
@@ -1,3 +0,1 @@ | ||
import ReactEditorJS from './ReactEditorJS' | ||
export default ReactEditorJS | ||
export { default } from './ReactEditorJSClient' |
15785
3
4
15
185
+ Added@codexteam/icons@0.0.4(transitive)
+ Added@editorjs/paragraph@2.11.7(transitive)
+ Added@react-editor-js/core@2.0.5(transitive)
- Removed@editorjs/paragraph@2.11.6(transitive)
- Removed@react-editor-js/core@2.0.4(transitive)
Updated@react-editor-js/core@2.0.5