eddev 0.1.49 → 0.1.50
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/fields/ImageWell.d.ts +8 -0
- package/fields/ImageWell.js +64 -0
- package/fields/installFieldTypes.js +17 -5
- package/package.json +1 -1
- package/blocks/EditorErrorBoundary.d.ts +0 -15
- package/blocks/EditorErrorBoundary.js +0 -64
- package/build/codegen-worker-script.d.ts +0 -5
- package/build/codegen-worker-script.js +0 -543
- package/build/webpack-worker-script.d.ts +0 -2
- package/build/webpack-worker-script.js +0 -160
- package/cli/display/lib/Observable.d.ts +0 -11
- package/cli/display/lib/Observable.js +0 -34
- package/cli/display/lib/useObservable.d.ts +0 -2
- package/cli/display/lib/useObservable.js +0 -12
- package/cli/generate.d.ts +0 -1
- package/cli/generate.js +0 -46
- package/components/ContentBlocks.d.ts +0 -36
- package/components/ContentBlocks.js +0 -92
- package/components/routing.d.ts +0 -44
- package/components/routing.js +0 -363
- package/utils/remoteProps.d.ts +0 -12
- package/utils/remoteProps.js +0 -95
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageWell = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var react_1 = require("@stitches/react");
|
|
6
|
+
var react_2 = require("react");
|
|
7
|
+
function ImageWell(props) {
|
|
8
|
+
var _a = (0, react_2.useState)(null), selectedImage = _a[0], setSelectedImage = _a[1];
|
|
9
|
+
var _b = (0, react_2.useState)(false), imageIsLoading = _b[0], setImageIsLoading = _b[1];
|
|
10
|
+
(0, react_2.useEffect)(function () {
|
|
11
|
+
if (props.value) {
|
|
12
|
+
var cancelled = false;
|
|
13
|
+
setImageIsLoading(true);
|
|
14
|
+
fetch("/wp-json/ed/v1/media/" + Number(props.value))
|
|
15
|
+
.then(function (response) { return response.json(); })
|
|
16
|
+
.then(function (image) {
|
|
17
|
+
setImageIsLoading(false);
|
|
18
|
+
setSelectedImage(image);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}, [props.value]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(Wrapper, { children: [imageIsLoading ? ((0, jsx_runtime_1.jsx)(Loading, { children: (0, jsx_runtime_1.jsx)(Spinner, {}, void 0) }, void 0)) : selectedImage ? ((0, jsx_runtime_1.jsx)(ImageContainer, { children: (0, jsx_runtime_1.jsx)("img", { src: selectedImage.sizes[props.previewSize] || selectedImage.sizes["thumbnail"] }, void 0) }, void 0)) : null, (0, jsx_runtime_1.jsx)(Toolbar, { children: selectedImage || imageIsLoading ? ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button, { children: "Remove" }, void 0), (0, jsx_runtime_1.jsx)(Button, { children: "Edit" }, void 0), (0, jsx_runtime_1.jsx)(Button, { children: "View" }, void 0)] }, void 0)) : null }, void 0)] }, void 0));
|
|
23
|
+
}
|
|
24
|
+
exports.ImageWell = ImageWell;
|
|
25
|
+
var Wrapper = (0, react_1.styled)("div", {
|
|
26
|
+
position: "relative",
|
|
27
|
+
display: "block",
|
|
28
|
+
width: "100%",
|
|
29
|
+
border: "1px solid #aaaaaa",
|
|
30
|
+
});
|
|
31
|
+
var ImageContainer = (0, react_1.styled)("div", {
|
|
32
|
+
padding: "4px",
|
|
33
|
+
img: {
|
|
34
|
+
maxWidth: "100%",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
var spin = (0, react_1.keyframes)({
|
|
38
|
+
from: {
|
|
39
|
+
transform: "rotate(0deg)",
|
|
40
|
+
},
|
|
41
|
+
to: {
|
|
42
|
+
transform: "rotate(360deg)",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
var Spinner = (0, react_1.styled)("div", {
|
|
46
|
+
display: "block",
|
|
47
|
+
width: "32px",
|
|
48
|
+
height: "32px",
|
|
49
|
+
border: "4px solid transparent",
|
|
50
|
+
borderTop: "currentColor",
|
|
51
|
+
animation: "".concat(spin, " 1s linear infinite"),
|
|
52
|
+
});
|
|
53
|
+
var Loading = (0, react_1.styled)("div", {
|
|
54
|
+
display: "flex",
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
padding: "8px",
|
|
58
|
+
});
|
|
59
|
+
var Toolbar = (0, react_1.styled)("div", {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
top: 0,
|
|
62
|
+
right: 0,
|
|
63
|
+
padding: "4px",
|
|
64
|
+
});
|
|
@@ -34,8 +34,9 @@ function installFieldTypes() {
|
|
|
34
34
|
var _loop_1 = function (name_1) {
|
|
35
35
|
var type = fields_1.default[name_1];
|
|
36
36
|
var Component = type.render;
|
|
37
|
-
var init = function (
|
|
38
|
-
|
|
37
|
+
var init = function (field) {
|
|
38
|
+
console.log("Field is", field);
|
|
39
|
+
var $el = field.$el, cid = field.cid, data = field.data;
|
|
39
40
|
var input = $el.find("input[type='hidden']");
|
|
40
41
|
var container = document.createElement("div");
|
|
41
42
|
$el.append(container);
|
|
@@ -52,9 +53,20 @@ exports.installFieldTypes = installFieldTypes;
|
|
|
52
53
|
function FieldWrapper(_a) {
|
|
53
54
|
var input = _a.input, defaultValue = _a.defaultValue, Component = _a.Component, settings = _a.settings;
|
|
54
55
|
var _b = (0, react_1.useState)(function () { var _a; return (_a = (input.value ? JSON.parse(input.value) : null)) !== null && _a !== void 0 ? _a : defaultValue; }), value = _b[0], setValue = _b[1];
|
|
56
|
+
var _c = (0, react_1.useState)(false), valueChanged = _c[0], setValueChanged = _c[1];
|
|
55
57
|
(0, react_1.useEffect)(function () {
|
|
56
58
|
input.value = JSON.stringify(value);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
if (valueChanged) {
|
|
60
|
+
try {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
window.jQuery(input).change();
|
|
63
|
+
}
|
|
64
|
+
catch (err) { }
|
|
65
|
+
setValueChanged(false);
|
|
66
|
+
}
|
|
67
|
+
}, [value, valueChanged]);
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(Component, { value: value, onChange: function (value) {
|
|
69
|
+
setValue(value);
|
|
70
|
+
setValueChanged(true);
|
|
71
|
+
}, settings: settings }, void 0));
|
|
60
72
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React, { Component, ErrorInfo, ReactNode } from "react";
|
|
2
|
-
interface Props {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
}
|
|
5
|
-
interface State {
|
|
6
|
-
hasError: boolean;
|
|
7
|
-
error?: Error;
|
|
8
|
-
}
|
|
9
|
-
export declare class EditorErrorBoundary extends Component<Props, State> {
|
|
10
|
-
state: State;
|
|
11
|
-
static getDerivedStateFromError(err: Error): State;
|
|
12
|
-
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
13
|
-
render(): React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.EditorErrorBoundary = void 0;
|
|
30
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
-
var react_1 = require("react");
|
|
32
|
-
var EditorErrorBoundary = /** @class */ (function (_super) {
|
|
33
|
-
__extends(EditorErrorBoundary, _super);
|
|
34
|
-
function EditorErrorBoundary() {
|
|
35
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
-
_this.state = {
|
|
37
|
-
hasError: false,
|
|
38
|
-
};
|
|
39
|
-
return _this;
|
|
40
|
-
}
|
|
41
|
-
EditorErrorBoundary.getDerivedStateFromError = function (err) {
|
|
42
|
-
// Update state so the next render will show the fallback UI.
|
|
43
|
-
return { hasError: true, error: err };
|
|
44
|
-
};
|
|
45
|
-
EditorErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
|
|
46
|
-
console.error("Uncaught error:", error, errorInfo);
|
|
47
|
-
};
|
|
48
|
-
EditorErrorBoundary.prototype.render = function () {
|
|
49
|
-
if (this.state.hasError) {
|
|
50
|
-
var err = this.state.error;
|
|
51
|
-
return ((0, jsx_runtime_1.jsx)("pre", __assign({ style: {
|
|
52
|
-
fontSize: "12px",
|
|
53
|
-
color: "red",
|
|
54
|
-
border: "1px solid red",
|
|
55
|
-
borderRadius: "4px",
|
|
56
|
-
padding: "4px",
|
|
57
|
-
overflowX: "auto",
|
|
58
|
-
} }, { children: err.stack }), void 0));
|
|
59
|
-
}
|
|
60
|
-
return this.props.children;
|
|
61
|
-
};
|
|
62
|
-
return EditorErrorBoundary;
|
|
63
|
-
}(react_1.Component));
|
|
64
|
-
exports.EditorErrorBoundary = EditorErrorBoundary;
|