@teamias/rex-design 0.0.16 → 0.0.17
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.
|
@@ -4,12 +4,24 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
13
|
import enUS from "../../../locales/en-US.json";
|
|
8
14
|
import { RexProConfigProvider, TiptapEditor } from "../../..";
|
|
9
15
|
import { crush } from 'radash';
|
|
16
|
+
import { useState } from 'react';
|
|
10
17
|
import { createIntl } from 'react-intl';
|
|
11
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
19
|
export default (function () {
|
|
20
|
+
var _useState = useState('<p>Hello World</p>'),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
value = _useState2[0],
|
|
23
|
+
setValue = _useState2[1];
|
|
24
|
+
// window.setValue=setValue
|
|
13
25
|
return /*#__PURE__*/_jsx(RexProConfigProvider, {
|
|
14
26
|
value: {
|
|
15
27
|
intl: createIntl({
|
|
@@ -18,8 +30,14 @@ export default (function () {
|
|
|
18
30
|
})
|
|
19
31
|
},
|
|
20
32
|
children: /*#__PURE__*/_jsx(TiptapEditor, {
|
|
21
|
-
readOnly: true
|
|
22
|
-
defaultValue
|
|
33
|
+
readOnly: true
|
|
34
|
+
// defaultValue={value}
|
|
35
|
+
,
|
|
36
|
+
value: value,
|
|
37
|
+
onChange: function onChange(e) {
|
|
38
|
+
console.log(e);
|
|
39
|
+
setValue(e);
|
|
40
|
+
}
|
|
23
41
|
})
|
|
24
42
|
});
|
|
25
43
|
});
|
|
@@ -32,7 +32,6 @@ import { Box } from "./styles";
|
|
|
32
32
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
33
33
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
34
34
|
export var TiptapEditor = function TiptapEditor(_ref) {
|
|
35
|
-
var _ref2;
|
|
36
35
|
var _ref$type = _ref.type,
|
|
37
36
|
type = _ref$type === void 0 ? 'html' : _ref$type,
|
|
38
37
|
_ref$maxHeight = _ref.maxHeight,
|
|
@@ -122,9 +121,9 @@ export var TiptapEditor = function TiptapEditor(_ref) {
|
|
|
122
121
|
// onError: (error) => console.error('Upload failed:', error),
|
|
123
122
|
// }),
|
|
124
123
|
]),
|
|
125
|
-
content:
|
|
126
|
-
onUpdate: function onUpdate(
|
|
127
|
-
var editor =
|
|
124
|
+
content: value || defaultValue || '',
|
|
125
|
+
onUpdate: function onUpdate(_ref2) {
|
|
126
|
+
var editor = _ref2.editor;
|
|
128
127
|
if (type === 'text') {
|
|
129
128
|
// `<p style="margin: 0">/qwe/<react-variable-node selected="qwe"></react-variable-node></p>`.replace(/<p.*?>(.*?)<\/p>/, '$1');
|
|
130
129
|
var text = editor.getHTML();
|
|
@@ -473,6 +472,8 @@ export var TiptapEditor = function TiptapEditor(_ref) {
|
|
|
473
472
|
};
|
|
474
473
|
}, []);
|
|
475
474
|
useEffect(function () {
|
|
475
|
+
if (typeof readOnly !== 'boolean') return;
|
|
476
|
+
if (!readOnly === (editor === null || editor === void 0 ? void 0 : editor.isEditable)) return;
|
|
476
477
|
editor === null || editor === void 0 || editor.setEditable(!readOnly);
|
|
477
478
|
}, [readOnly]);
|
|
478
479
|
useEffect(function () {
|