tinacms 1.5.12 → 1.5.14

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.
@@ -130,6 +130,7 @@ export declare class Client {
130
130
  usingEditorialWorkflow: boolean;
131
131
  constructor({ tokenStorage, ...options }: ServerOptions);
132
132
  get isLocalMode(): boolean;
133
+ get isCustomContentApi(): boolean;
133
134
  setBranch(branchName: string): void;
134
135
  getBranch(): string;
135
136
  addPendingContent: (props: any) => Promise<unknown>;
package/dist/react.es.js CHANGED
@@ -4,7 +4,10 @@ function useTina(props) {
4
4
  query: props.query,
5
5
  variables: props.variables
6
6
  });
7
- const id = React.useMemo(() => hashFromQuery(stringifiedQuery), [stringifiedQuery]);
7
+ const id = React.useMemo(
8
+ () => hashFromQuery(stringifiedQuery),
9
+ [stringifiedQuery]
10
+ );
8
11
  const [data, setData] = React.useState(props.data);
9
12
  const [isClient, setIsClient] = React.useState(false);
10
13
  const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
@@ -17,17 +20,23 @@ function useTina(props) {
17
20
  if (quickEditEnabled) {
18
21
  let mouseDownHandler = function(e) {
19
22
  const attributeNames = e.target.getAttributeNames();
20
- const tinaAttribute = attributeNames.find((name) => name.startsWith("data-tina-field"));
23
+ const tinaAttribute = attributeNames.find(
24
+ (name) => name.startsWith("data-tina-field")
25
+ );
21
26
  let fieldName;
22
27
  if (tinaAttribute) {
23
28
  e.preventDefault();
24
29
  e.stopPropagation();
25
30
  fieldName = e.target.getAttribute(tinaAttribute);
26
31
  } else {
27
- const ancestor = e.target.closest("[data-tina-field], [data-tina-field-overlay]");
32
+ const ancestor = e.target.closest(
33
+ "[data-tina-field], [data-tina-field-overlay]"
34
+ );
28
35
  if (ancestor) {
29
36
  const attributeNames2 = ancestor.getAttributeNames();
30
- const tinaAttribute2 = attributeNames2.find((name) => name.startsWith("data-tina-field"));
37
+ const tinaAttribute2 = attributeNames2.find(
38
+ (name) => name.startsWith("data-tina-field")
39
+ );
31
40
  if (tinaAttribute2) {
32
41
  e.preventDefault();
33
42
  e.stopPropagation();
@@ -37,7 +46,10 @@ function useTina(props) {
37
46
  }
38
47
  if (fieldName) {
39
48
  if (isInTinaIframe) {
40
- parent.postMessage({ type: "field:selected", fieldName }, window.location.origin);
49
+ parent.postMessage(
50
+ { type: "field:selected", fieldName },
51
+ window.location.origin
52
+ );
41
53
  }
42
54
  }
43
55
  };
@@ -95,9 +107,15 @@ function useTina(props) {
95
107
  setIsInTinaIframe(true);
96
108
  const anyTinaField = document.querySelector("[data-tina-field]");
97
109
  if (anyTinaField) {
98
- parent.postMessage({ type: "quick-edit", value: true }, window.location.origin);
110
+ parent.postMessage(
111
+ { type: "quick-edit", value: true },
112
+ window.location.origin
113
+ );
99
114
  } else {
100
- parent.postMessage({ type: "quick-edit", value: false }, window.location.origin);
115
+ parent.postMessage(
116
+ { type: "quick-edit", value: false },
117
+ window.location.origin
118
+ );
101
119
  }
102
120
  }
103
121
  });
@@ -207,4 +225,10 @@ const hashFromQuery = (input) => {
207
225
  const alphanumericHash = nonNegativeHash.toString(36);
208
226
  return alphanumericHash;
209
227
  };
210
- export { addMetadata, hashFromQuery, tinaField, useEditState, useTina };
228
+ export {
229
+ addMetadata,
230
+ hashFromQuery,
231
+ tinaField,
232
+ useEditState,
233
+ useTina
234
+ };
package/dist/react.js CHANGED
@@ -2,39 +2,44 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
3
3
  })(this, function(exports2, React) {
4
4
  "use strict";
5
- function _interopDefaultLegacy(e) {
6
- return e && typeof e === "object" && "default" in e ? e : { "default": e };
7
- }
8
- var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
9
5
  function useTina(props) {
10
6
  const stringifiedQuery = JSON.stringify({
11
7
  query: props.query,
12
8
  variables: props.variables
13
9
  });
14
- const id = React__default["default"].useMemo(() => hashFromQuery(stringifiedQuery), [stringifiedQuery]);
15
- const [data, setData] = React__default["default"].useState(props.data);
16
- const [isClient, setIsClient] = React__default["default"].useState(false);
17
- const [quickEditEnabled, setQuickEditEnabled] = React__default["default"].useState(false);
18
- const [isInTinaIframe, setIsInTinaIframe] = React__default["default"].useState(false);
19
- React__default["default"].useEffect(() => {
10
+ const id = React.useMemo(
11
+ () => hashFromQuery(stringifiedQuery),
12
+ [stringifiedQuery]
13
+ );
14
+ const [data, setData] = React.useState(props.data);
15
+ const [isClient, setIsClient] = React.useState(false);
16
+ const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
17
+ const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
18
+ React.useEffect(() => {
20
19
  setIsClient(true);
21
20
  setData(props.data);
22
21
  }, [id]);
23
- React__default["default"].useEffect(() => {
22
+ React.useEffect(() => {
24
23
  if (quickEditEnabled) {
25
24
  let mouseDownHandler = function(e) {
26
25
  const attributeNames = e.target.getAttributeNames();
27
- const tinaAttribute = attributeNames.find((name) => name.startsWith("data-tina-field"));
26
+ const tinaAttribute = attributeNames.find(
27
+ (name) => name.startsWith("data-tina-field")
28
+ );
28
29
  let fieldName;
29
30
  if (tinaAttribute) {
30
31
  e.preventDefault();
31
32
  e.stopPropagation();
32
33
  fieldName = e.target.getAttribute(tinaAttribute);
33
34
  } else {
34
- const ancestor = e.target.closest("[data-tina-field], [data-tina-field-overlay]");
35
+ const ancestor = e.target.closest(
36
+ "[data-tina-field], [data-tina-field-overlay]"
37
+ );
35
38
  if (ancestor) {
36
39
  const attributeNames2 = ancestor.getAttributeNames();
37
- const tinaAttribute2 = attributeNames2.find((name) => name.startsWith("data-tina-field"));
40
+ const tinaAttribute2 = attributeNames2.find(
41
+ (name) => name.startsWith("data-tina-field")
42
+ );
38
43
  if (tinaAttribute2) {
39
44
  e.preventDefault();
40
45
  e.stopPropagation();
@@ -44,7 +49,10 @@
44
49
  }
45
50
  if (fieldName) {
46
51
  if (isInTinaIframe) {
47
- parent.postMessage({ type: "field:selected", fieldName }, window.location.origin);
52
+ parent.postMessage(
53
+ { type: "field:selected", fieldName },
54
+ window.location.origin
55
+ );
48
56
  }
49
57
  }
50
58
  };
@@ -91,7 +99,7 @@
91
99
  };
92
100
  }
93
101
  }, [quickEditEnabled, isInTinaIframe]);
94
- React__default["default"].useEffect(() => {
102
+ React.useEffect(() => {
95
103
  parent.postMessage({ type: "open", ...props, id }, window.location.origin);
96
104
  window.addEventListener("message", (event) => {
97
105
  if (event.data.type === "quickEditEnabled") {
@@ -102,9 +110,15 @@
102
110
  setIsInTinaIframe(true);
103
111
  const anyTinaField = document.querySelector("[data-tina-field]");
104
112
  if (anyTinaField) {
105
- parent.postMessage({ type: "quick-edit", value: true }, window.location.origin);
113
+ parent.postMessage(
114
+ { type: "quick-edit", value: true },
115
+ window.location.origin
116
+ );
106
117
  } else {
107
- parent.postMessage({ type: "quick-edit", value: false }, window.location.origin);
118
+ parent.postMessage(
119
+ { type: "quick-edit", value: false },
120
+ window.location.origin
121
+ );
108
122
  }
109
123
  }
110
124
  });
@@ -115,8 +129,8 @@
115
129
  return { data, isClient };
116
130
  }
117
131
  function useEditState() {
118
- const [edit, setEdit] = React__default["default"].useState(false);
119
- React__default["default"].useEffect(() => {
132
+ const [edit, setEdit] = React.useState(false);
133
+ React.useEffect(() => {
120
134
  if (typeof window !== "undefined") {
121
135
  parent.postMessage({ type: "isEditMode" }, window.location.origin);
122
136
  window.addEventListener("message", (event) => {
@@ -219,5 +233,5 @@
219
233
  exports2.tinaField = tinaField;
220
234
  exports2.useEditState = useEditState;
221
235
  exports2.useTina = useTina;
222
- Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
236
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
223
237
  });
@@ -11,11 +11,7 @@ const TinaMarkdown = ({
11
11
  return null;
12
12
  }
13
13
  return /* @__PURE__ */ React.createElement(React.Fragment, null, nodes.map((child, index) => {
14
- return /* @__PURE__ */ React.createElement(MemoNode, {
15
- components,
16
- key: index,
17
- child
18
- });
14
+ return /* @__PURE__ */ React.createElement(MemoNode, { components, key: index, child });
19
15
  }));
20
16
  };
21
17
  const Leaf = (props) => {
@@ -23,61 +19,41 @@ const Leaf = (props) => {
23
19
  const { bold, ...rest } = props;
24
20
  if (props.components.bold) {
25
21
  const Component = props.components.bold;
26
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
27
- ...rest
28
- }));
22
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
29
23
  }
30
- return /* @__PURE__ */ React.createElement("strong", null, /* @__PURE__ */ React.createElement(Leaf, {
31
- ...rest
32
- }));
24
+ return /* @__PURE__ */ React.createElement("strong", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
33
25
  }
34
26
  if (props.italic) {
35
27
  const { italic, ...rest } = props;
36
28
  if (props.components.italic) {
37
29
  const Component = props.components.italic;
38
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
39
- ...rest
40
- }));
30
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
41
31
  }
42
- return /* @__PURE__ */ React.createElement("em", null, /* @__PURE__ */ React.createElement(Leaf, {
43
- ...rest
44
- }));
32
+ return /* @__PURE__ */ React.createElement("em", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
45
33
  }
46
34
  if (props.underline) {
47
35
  const { underline, ...rest } = props;
48
36
  if (props.components.underline) {
49
37
  const Component = props.components.underline;
50
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
51
- ...rest
52
- }));
38
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
53
39
  }
54
- return /* @__PURE__ */ React.createElement("u", null, /* @__PURE__ */ React.createElement(Leaf, {
55
- ...rest
56
- }));
40
+ return /* @__PURE__ */ React.createElement("u", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
57
41
  }
58
42
  if (props.strikethrough) {
59
43
  const { strikethrough, ...rest } = props;
60
44
  if (props.components.strikethrough) {
61
45
  const Component = props.components.strikethrough;
62
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
63
- ...rest
64
- }));
46
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
65
47
  }
66
- return /* @__PURE__ */ React.createElement("s", null, /* @__PURE__ */ React.createElement(Leaf, {
67
- ...rest
68
- }));
48
+ return /* @__PURE__ */ React.createElement("s", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
69
49
  }
70
50
  if (props.code) {
71
51
  const { code, ...rest } = props;
72
52
  if (props.components.code) {
73
53
  const Component = props.components.code;
74
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
75
- ...rest
76
- }));
54
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
77
55
  }
78
- return /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement(Leaf, {
79
- ...rest
80
- }));
56
+ return /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
81
57
  }
82
58
  if (props.components.text) {
83
59
  const Component = props.components.text;
@@ -86,9 +62,10 @@ const Leaf = (props) => {
86
62
  return /* @__PURE__ */ React.createElement(React.Fragment, null, props.text);
87
63
  };
88
64
  const MemoNode = (props) => {
89
- const MNode = React.useMemo(() => /* @__PURE__ */ React.createElement(Node, {
90
- ...props
91
- }), [JSON.stringify(props)]);
65
+ const MNode = React.useMemo(
66
+ () => /* @__PURE__ */ React.createElement(Node, { ...props }),
67
+ [JSON.stringify(props)]
68
+ );
92
69
  return MNode;
93
70
  };
94
71
  const Node = ({ components, child }) => {
@@ -107,104 +84,69 @@ const Node = ({ components, child }) => {
107
84
  case "li":
108
85
  if (components[child.type]) {
109
86
  const Component2 = components[child.type];
110
- return /* @__PURE__ */ React.createElement(Component2, {
111
- ...props
112
- }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
113
- components,
114
- content: children
115
- }));
87
+ return /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }));
116
88
  }
117
89
  return React.createElement(child.type, {
118
- children: /* @__PURE__ */ React.createElement(TinaMarkdown, {
119
- components,
120
- content: children
121
- })
90
+ children: /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children })
122
91
  });
123
92
  case "lic":
124
93
  if (components.lic) {
125
94
  const Component2 = components.lic;
126
- return /* @__PURE__ */ React.createElement(Component2, {
127
- ...props
128
- }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
129
- components,
130
- content: children
131
- }));
95
+ return /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }));
132
96
  }
133
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(TinaMarkdown, {
134
- components,
135
- content: child.children
136
- }));
97
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: child.children }));
137
98
  case "img":
138
99
  if (components[child.type]) {
139
100
  const Component2 = components[child.type];
140
- return /* @__PURE__ */ React.createElement(Component2, {
141
- ...props
142
- });
101
+ return /* @__PURE__ */ React.createElement(Component2, { ...props });
143
102
  }
144
- return /* @__PURE__ */ React.createElement("img", {
145
- src: child.url,
146
- alt: child.caption
147
- });
103
+ return /* @__PURE__ */ React.createElement("img", { src: child.url, alt: child.caption });
148
104
  case "a":
149
105
  if (components[child.type]) {
150
106
  const Component2 = components[child.type];
151
- return /* @__PURE__ */ React.createElement(Component2, {
152
- ...props
153
- }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
154
- components,
155
- content: children
156
- }));
107
+ return (
108
+ // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
109
+ /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }))
110
+ );
157
111
  }
158
- return /* @__PURE__ */ React.createElement("a", {
159
- href: child.url
160
- }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
161
- components,
162
- content: children
163
- }));
112
+ return (
113
+ // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
114
+ /* @__PURE__ */ React.createElement("a", { href: child.url }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }))
115
+ );
164
116
  case "code_block":
165
117
  const value = child.value;
166
118
  if (components[child.type]) {
167
119
  const Component2 = components[child.type];
168
- return /* @__PURE__ */ React.createElement(Component2, {
169
- ...props
170
- });
120
+ return (
121
+ // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
122
+ /* @__PURE__ */ React.createElement(Component2, { ...props })
123
+ );
171
124
  }
172
125
  return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, value));
173
126
  case "hr":
174
127
  if (components[child.type]) {
175
128
  const Component2 = components[child.type];
176
- return /* @__PURE__ */ React.createElement(Component2, {
177
- ...props
178
- });
129
+ return /* @__PURE__ */ React.createElement(Component2, { ...props });
179
130
  }
180
131
  return /* @__PURE__ */ React.createElement("hr", null);
181
132
  case "break":
182
133
  if (components[child.type]) {
183
134
  const Component2 = components[child.type];
184
- return /* @__PURE__ */ React.createElement(Component2, {
185
- ...props
186
- });
135
+ return /* @__PURE__ */ React.createElement(Component2, { ...props });
187
136
  }
188
137
  return /* @__PURE__ */ React.createElement("br", null);
189
138
  case "text":
190
- return /* @__PURE__ */ React.createElement(Leaf, {
191
- components,
192
- ...child
193
- });
139
+ return /* @__PURE__ */ React.createElement(Leaf, { components, ...child });
194
140
  case "mdxJsxTextElement":
195
141
  case "mdxJsxFlowElement":
196
142
  const Component = components[child.name];
197
143
  if (Component) {
198
144
  const props2 = child.props ? child.props : {};
199
- return /* @__PURE__ */ React.createElement(Component, {
200
- ...props2
201
- });
145
+ return /* @__PURE__ */ React.createElement(Component, { ...props2 });
202
146
  } else {
203
147
  const ComponentMissing = components["component_missing"];
204
148
  if (ComponentMissing) {
205
- return /* @__PURE__ */ React.createElement(ComponentMissing, {
206
- name: child.name
207
- });
149
+ return /* @__PURE__ */ React.createElement(ComponentMissing, { name: child.name });
208
150
  } else {
209
151
  return /* @__PURE__ */ React.createElement("span", null, `No component provided for ${child.name}`);
210
152
  }
@@ -215,20 +157,17 @@ const Node = ({ components, child }) => {
215
157
  case "html_inline":
216
158
  if (components[child.type]) {
217
159
  const Component2 = components[child.type];
218
- return /* @__PURE__ */ React.createElement(Component2, {
219
- ...props
220
- });
160
+ return /* @__PURE__ */ React.createElement(Component2, { ...props });
221
161
  }
222
162
  return child.value;
223
163
  case "invalid_markdown":
224
164
  return /* @__PURE__ */ React.createElement("pre", null, child.value);
225
165
  default:
226
166
  if (typeof child.text === "string") {
227
- return /* @__PURE__ */ React.createElement(Leaf, {
228
- components,
229
- ...child
230
- });
167
+ return /* @__PURE__ */ React.createElement(Leaf, { components, ...child });
231
168
  }
232
169
  }
233
170
  };
234
- export { TinaMarkdown };
171
+ export {
172
+ TinaMarkdown
173
+ };