tinacms 0.68.14 → 0.69.1

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.
@@ -18,150 +18,11 @@
18
18
  return null;
19
19
  }
20
20
  return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, nodes.map((child, index) => {
21
- const key = index;
22
- const { children, ...props } = child;
23
- switch (child.type) {
24
- case "h1":
25
- case "h2":
26
- case "h3":
27
- case "h4":
28
- case "h5":
29
- case "h6":
30
- case "p":
31
- case "blockquote":
32
- case "ol":
33
- case "ul":
34
- case "li":
35
- if (components[child.type]) {
36
- const Component2 = components[child.type];
37
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
38
- key,
39
- ...props
40
- }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
41
- components,
42
- content: children
43
- }));
44
- }
45
- return React__default["default"].createElement(child.type, {
46
- key,
47
- children: /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
48
- components,
49
- content: children
50
- })
51
- });
52
- case "lic":
53
- return /* @__PURE__ */ React__default["default"].createElement("div", {
54
- key
55
- }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
56
- components,
57
- content: child.children
58
- }));
59
- case "img":
60
- if (components[child.type]) {
61
- const Component2 = components[child.type];
62
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
63
- key,
64
- ...props
65
- });
66
- }
67
- return /* @__PURE__ */ React__default["default"].createElement("img", {
68
- key,
69
- src: child.url,
70
- alt: child.caption
71
- });
72
- case "a":
73
- if (components[child.type]) {
74
- const Component2 = components[child.type];
75
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
76
- key,
77
- ...props
78
- }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
79
- components,
80
- content: children
81
- }));
82
- }
83
- return /* @__PURE__ */ React__default["default"].createElement("a", {
84
- key,
85
- href: child.url
86
- }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
87
- components,
88
- content: children
89
- }));
90
- case "code_block":
91
- const value = child.children.map((item) => {
92
- var _a;
93
- return item.children ? ((_a = item.children[0]) == null ? void 0 : _a.text) || "" : "";
94
- }).join("\n");
95
- if (components[child.type]) {
96
- const Component2 = components[child.type];
97
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
98
- key,
99
- ...props
100
- }, value);
101
- }
102
- return /* @__PURE__ */ React__default["default"].createElement("pre", {
103
- key
104
- }, /* @__PURE__ */ React__default["default"].createElement("code", null, value));
105
- case "hr":
106
- if (components[child.type]) {
107
- const Component2 = components[child.type];
108
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
109
- key,
110
- ...props
111
- });
112
- }
113
- return /* @__PURE__ */ React__default["default"].createElement("hr", {
114
- key
115
- });
116
- case "break":
117
- if (components[child.type]) {
118
- const Component2 = components[child.type];
119
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
120
- key,
121
- ...props
122
- });
123
- }
124
- return /* @__PURE__ */ React__default["default"].createElement("br", {
125
- key
126
- });
127
- case "text":
128
- return /* @__PURE__ */ React__default["default"].createElement(Leaf, {
129
- key,
130
- components,
131
- ...child
132
- });
133
- case "mdxJsxTextElement":
134
- case "mdxJsxFlowElement":
135
- const Component = components[child.name];
136
- if (Component) {
137
- const props2 = child.props ? child.props : {};
138
- return /* @__PURE__ */ React__default["default"].createElement(Component, {
139
- key,
140
- ...props2
141
- });
142
- } else {
143
- const ComponentMissing = components["component_missing"];
144
- if (ComponentMissing) {
145
- return /* @__PURE__ */ React__default["default"].createElement(ComponentMissing, {
146
- key,
147
- name: child.name
148
- });
149
- } else {
150
- throw new Error(`No component provided for ${child.name}`);
151
- }
152
- }
153
- case "maybe_mdx":
154
- return null;
155
- default:
156
- if (typeof child.text === "string") {
157
- return /* @__PURE__ */ React__default["default"].createElement(Leaf, {
158
- key,
159
- components,
160
- ...child
161
- });
162
- }
163
- console.log(`No tina renderer for ${child.type}`, child);
164
- }
21
+ return /* @__PURE__ */ React__default["default"].createElement(MemoNode, {
22
+ components,
23
+ key: index,
24
+ child
25
+ });
165
26
  }));
166
27
  };
167
28
  const Leaf = (props) => {
@@ -227,6 +88,143 @@
227
88
  }
228
89
  return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, props.text);
229
90
  };
91
+ const MemoNode = (props) => {
92
+ const MNode = React__default["default"].useMemo(() => /* @__PURE__ */ React__default["default"].createElement(Node, {
93
+ ...props
94
+ }), [JSON.stringify(props)]);
95
+ return MNode;
96
+ };
97
+ const Node = ({ components, child }) => {
98
+ const { children, ...props } = child;
99
+ switch (child.type) {
100
+ case "h1":
101
+ case "h2":
102
+ case "h3":
103
+ case "h4":
104
+ case "h5":
105
+ case "h6":
106
+ case "p":
107
+ case "blockquote":
108
+ case "ol":
109
+ case "ul":
110
+ case "li":
111
+ if (components[child.type]) {
112
+ const Component2 = components[child.type];
113
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
114
+ ...props
115
+ }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
116
+ components,
117
+ content: children
118
+ }));
119
+ }
120
+ return React__default["default"].createElement(child.type, {
121
+ children: /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
122
+ components,
123
+ content: children
124
+ })
125
+ });
126
+ case "lic":
127
+ return /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
128
+ components,
129
+ content: child.children
130
+ }));
131
+ case "img":
132
+ if (components[child.type]) {
133
+ const Component2 = components[child.type];
134
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
135
+ ...props
136
+ });
137
+ }
138
+ return /* @__PURE__ */ React__default["default"].createElement("img", {
139
+ src: child.url,
140
+ alt: child.caption
141
+ });
142
+ case "a":
143
+ if (components[child.type]) {
144
+ const Component2 = components[child.type];
145
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
146
+ ...props
147
+ }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
148
+ components,
149
+ content: children
150
+ }));
151
+ }
152
+ return /* @__PURE__ */ React__default["default"].createElement("a", {
153
+ href: child.url
154
+ }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
155
+ components,
156
+ content: children
157
+ }));
158
+ case "code_block":
159
+ const value = child.value;
160
+ if (components[child.type]) {
161
+ const Component2 = components[child.type];
162
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
163
+ ...props
164
+ }, value);
165
+ }
166
+ return /* @__PURE__ */ React__default["default"].createElement("pre", null, /* @__PURE__ */ React__default["default"].createElement("code", null, value));
167
+ case "hr":
168
+ if (components[child.type]) {
169
+ const Component2 = components[child.type];
170
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
171
+ ...props
172
+ });
173
+ }
174
+ return /* @__PURE__ */ React__default["default"].createElement("hr", null);
175
+ case "break":
176
+ if (components[child.type]) {
177
+ const Component2 = components[child.type];
178
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
179
+ ...props
180
+ });
181
+ }
182
+ return /* @__PURE__ */ React__default["default"].createElement("br", null);
183
+ case "text":
184
+ return /* @__PURE__ */ React__default["default"].createElement(Leaf, {
185
+ components,
186
+ ...child
187
+ });
188
+ case "mdxJsxTextElement":
189
+ case "mdxJsxFlowElement":
190
+ const Component = components[child.name];
191
+ if (Component) {
192
+ const props2 = child.props ? child.props : {};
193
+ return /* @__PURE__ */ React__default["default"].createElement(Component, {
194
+ ...props2
195
+ });
196
+ } else {
197
+ const ComponentMissing = components["component_missing"];
198
+ if (ComponentMissing) {
199
+ return /* @__PURE__ */ React__default["default"].createElement(ComponentMissing, {
200
+ name: child.name
201
+ });
202
+ } else {
203
+ return /* @__PURE__ */ React__default["default"].createElement("span", null, `No component provided for ${child.name}`);
204
+ }
205
+ }
206
+ case "maybe_mdx":
207
+ return null;
208
+ case "html":
209
+ case "html_inline":
210
+ if (components[child.type]) {
211
+ const Component2 = components[child.type];
212
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
213
+ ...props
214
+ });
215
+ }
216
+ return child.value;
217
+ case "invalid_markdown":
218
+ return /* @__PURE__ */ React__default["default"].createElement("pre", null, child.value);
219
+ default:
220
+ if (typeof child.text === "string") {
221
+ return /* @__PURE__ */ React__default["default"].createElement(Leaf, {
222
+ components,
223
+ ...child
224
+ });
225
+ }
226
+ }
227
+ };
230
228
  exports2.TinaMarkdown = TinaMarkdown;
231
229
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
232
230
  });
package/dist/style.css CHANGED
@@ -544,6 +544,9 @@
544
544
  .tina-tailwind .gap-4 {
545
545
  gap: 16px;
546
546
  }
547
+ .tina-tailwind .gap-2 {
548
+ gap: 8px;
549
+ }
547
550
  .tina-tailwind .gap-3 {
548
551
  gap: 12px;
549
552
  }
@@ -562,6 +565,9 @@
562
565
  .tina-tailwind .overflow-y-auto {
563
566
  overflow-y: auto;
564
567
  }
568
+ .tina-tailwind .whitespace-normal {
569
+ white-space: normal;
570
+ }
565
571
  .tina-tailwind .whitespace-nowrap {
566
572
  white-space: nowrap;
567
573
  }
@@ -683,8 +689,8 @@
683
689
  .tina-tailwind .pb-4 {
684
690
  padding-bottom: 16px;
685
691
  }
686
- .tina-tailwind .pt-18 {
687
- padding-top: 72px;
692
+ .tina-tailwind .pt-16 {
693
+ padding-top: 64px;
688
694
  }
689
695
  .tina-tailwind .pt-3 {
690
696
  padding-top: 12px;
@@ -728,6 +734,9 @@
728
734
  .tina-tailwind .font-medium {
729
735
  font-weight: 500;
730
736
  }
737
+ .tina-tailwind .font-semibold {
738
+ font-weight: 600;
739
+ }
731
740
  .tina-tailwind .uppercase {
732
741
  text-transform: uppercase;
733
742
  }
@@ -10,107 +10,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import React from 'react';
14
- import type { TinaClient } from './client';
15
- import { TinaCloudMediaStoreClass } from './auth';
16
- import type { TinaCMS } from '@tinacms/toolkit';
17
- import type { TinaCloudSchema } from '@tinacms/schema-tools';
18
- import type { TinaIOConfig } from './internalClient/index';
19
13
  import type { formifyCallback } from './hooks/use-graphql-forms';
20
- import { useDocumentCreatorPlugin } from './hooks/use-content-creator';
21
- declare type APIProviderProps = {
22
- /**
23
- * The API url From this client will be used to make requests.
24
- *
25
- */
26
- client?: never;
27
- /**
28
- * Content API URL
29
- *
30
- */
31
- apiURL: string;
32
- /**
33
- * Point to the local version of GraphQL instead of tina.io
34
- * https://tina.io/docs/tinacms-context/#adding-tina-to-the-sites-frontend
35
- *
36
- * @deprecated use apiURL instead
37
- */
38
- isLocalClient?: never;
39
- /**
40
- * The base branch to pull content from. Note that this is ignored for local development
41
- *
42
- * @deprecated use apiURL instead
43
- */
44
- branch?: never;
45
- /**
46
- * Your clientId from tina.io
47
- *
48
- * @deprecated use apiURL instead
49
- */
50
- clientId?: never;
51
- } | {
52
- /**
53
- * The API url From this client will be used to make requests.
54
- *
55
- */
56
- client: TinaClient<unknown>;
57
- /**
58
- * Content API URL
59
- *
60
- */
61
- apiURL?: never;
62
- /**
63
- * Point to the local version of GraphQL instead of tina.io
64
- * https://tina.io/docs/tinacms-context/#adding-tina-to-the-sites-frontend
65
- *
66
- * @deprecated use apiURL instead
67
- */
68
- isLocalClient?: never;
69
- /**
70
- * The base branch to pull content from. Note that this is ignored for local development
71
- *
72
- * @deprecated use apiURL instead
73
- */
74
- branch?: never;
75
- /**
76
- * Your clientId from tina.io
77
- *
78
- * @deprecated use apiURL instead
79
- */
80
- clientId?: never;
81
- };
82
- interface BaseProviderProps {
83
- /** Callback if you need access to the TinaCMS instance */
84
- cmsCallback?: (cms: TinaCMS) => TinaCMS;
85
- /** Callback if you need access to the "formify" API */
86
- formifyCallback?: formifyCallback;
87
- /** Callback if you need access to the "document creator" API */
88
- documentCreatorCallback?: Parameters<typeof useDocumentCreatorPlugin>[0];
89
- /** TinaCMS media store instance */
90
- mediaStore?: TinaCloudMediaStoreClass | (() => Promise<TinaCloudMediaStoreClass>);
91
- tinaioConfig?: TinaIOConfig;
92
- schema?: TinaCloudSchema<false>;
93
- }
94
- declare type QueryProviderProps = {
95
- /** Your React page component */
96
- children: (props?: any) => React.ReactNode;
97
- /** The query from getStaticProps */
98
- query: string | undefined;
99
- /** Any variables from getStaticProps */
100
- variables: object | undefined;
101
- /** The `data` from getStaticProps */
102
- data: object;
103
- } | {
104
- /** Your React page component */
105
- children: React.ReactNode;
106
- /** The query from getStaticProps */
107
- query?: never;
108
- /** Any variables from getStaticProps */
109
- variables?: never;
110
- /** The `data` from getStaticProps */
111
- data?: never;
112
- };
113
- export declare type TinaCMSProviderDefaultProps = QueryProviderProps & APIProviderProps & BaseProviderProps;
14
+ import { TinaCMSProviderDefaultProps } from './types/cms';
114
15
  export declare const TinaCMSProvider2: ({ query, documentCreatorCallback, formifyCallback, schema, ...props }: TinaCMSProviderDefaultProps) => JSX.Element;
115
16
  export declare const TinaDataProvider: ({ children, formifyCallback, }: {
116
17
  children: any;
@@ -144,4 +45,3 @@ export declare const staticRequest: ({ query, variables, }: {
144
45
  * query or muation
145
46
  */
146
47
  export declare function gql(strings: TemplateStringsArray, ...args: string[]): string;
147
- export {};
@@ -0,0 +1,64 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ /// <reference types="react" />
14
+ import type { TinaCMS } from '@tinacms/toolkit';
15
+ import type { TinaCloudSchema, TinaCloudSchemaConfig } from '@tinacms/schema-tools';
16
+ import type { TinaCloudMediaStoreClass } from '../auth';
17
+ import type { useDocumentCreatorPlugin } from '../hooks/use-content-creator';
18
+ import type { formifyCallback } from '../hooks/use-graphql-forms';
19
+ import type { TinaIOConfig } from '../internalClient';
20
+ import type { TinaClient } from '../client';
21
+ declare type APIProviderProps = {
22
+ /**
23
+ * @deprecated Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API
24
+ *
25
+ */
26
+ apiURL?: string;
27
+ /**
28
+ * The API url From this client will be used to make requests.
29
+ */
30
+ client: TinaClient<unknown>;
31
+ };
32
+ interface BaseProviderProps {
33
+ /** Callback if you need access to the TinaCMS instance */
34
+ cmsCallback?: (cms: TinaCMS) => TinaCMS;
35
+ /** Callback if you need access to the "formify" API */
36
+ formifyCallback?: formifyCallback;
37
+ /** Callback if you need access to the "document creator" API */
38
+ documentCreatorCallback?: Parameters<typeof useDocumentCreatorPlugin>[0];
39
+ /** TinaCMS media store instance */
40
+ mediaStore?: TinaCloudMediaStoreClass | (() => Promise<TinaCloudMediaStoreClass>);
41
+ tinaioConfig?: TinaIOConfig;
42
+ schema?: TinaCloudSchema<false>;
43
+ }
44
+ declare type QueryProviderProps = {
45
+ /** Your React page component */
46
+ children: (props?: any) => React.ReactNode;
47
+ /** The query from getStaticProps */
48
+ query: string | undefined;
49
+ /** Any variables from getStaticProps */
50
+ variables: object | undefined;
51
+ /** The `data` from getStaticProps */
52
+ data: object;
53
+ } | {
54
+ /** Your React page component */
55
+ children: React.ReactNode;
56
+ /** The query from getStaticProps */
57
+ query?: never;
58
+ /** Any variables from getStaticProps */
59
+ variables?: never;
60
+ /** The `data` from getStaticProps */
61
+ data?: never;
62
+ };
63
+ export declare type TinaCMSProviderDefaultProps = QueryProviderProps & APIProviderProps & BaseProviderProps & TinaCloudSchemaConfig;
64
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.68.14",
3
+ "version": "0.69.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {
@@ -20,9 +20,14 @@
20
20
  "require": "./dist/edit-state.js"
21
21
  },
22
22
  "./dist/rich-text": {
23
- "types": "./dist/rich-text.d.ts",
24
- "import": "./dist/rich-text.es.js",
25
- "require": "./dist/rich-text.js"
23
+ "types": "./dist/rich-text/index.d.ts",
24
+ "import": "./dist/rich-text/index.es.js",
25
+ "require": "./dist/rich-text/index.js"
26
+ },
27
+ "./dist/rich-text/prism": {
28
+ "types": "./dist/rich-text/prism.d.ts",
29
+ "import": "./dist/rich-text/prism.es.js",
30
+ "require": "./dist/rich-text/prism.js"
26
31
  }
27
32
  },
28
33
  "files": [
@@ -32,7 +37,7 @@
32
37
  "entryPoints": [
33
38
  "src/index.ts",
34
39
  "src/edit-state.tsx",
35
- "src/rich-text.tsx",
40
+ "src/rich-text/index.tsx",
36
41
  "src/client.ts"
37
42
  ]
38
43
  },
@@ -43,15 +48,17 @@
43
48
  "@headlessui/react": "^1.5.0",
44
49
  "@heroicons/react": "^1.0.4",
45
50
  "@react-hook/window-size": "^3.0.7",
46
- "@tinacms/schema-tools": "0.0.9",
51
+ "@tinacms/schema-tools": "0.1.0",
47
52
  "@tinacms/sharedctx": "0.1.2",
48
- "@tinacms/toolkit": "0.56.36",
53
+ "@tinacms/toolkit": "0.57.0",
49
54
  "crypto-js": "^4.0.0",
50
55
  "fetch-ponyfill": "^7.1.0",
51
56
  "final-form": "4.20.1",
52
57
  "graphql": "^15.1.0",
53
58
  "graphql-tag": "^2.11.0",
54
59
  "lodash.set": "^4.3.2",
60
+ "prism-react-renderer": "^1.3.5",
61
+ "prism": "^4.1.2",
55
62
  "react-icons": "^4.3.1",
56
63
  "react-router-dom": "6",
57
64
  "url-pattern": "^1.0.3",
@@ -63,7 +70,7 @@
63
70
  "@testing-library/react": "^12.0.0",
64
71
  "@testing-library/react-hooks": "^7.0.2",
65
72
  "@testing-library/user-event": "^12.7.0",
66
- "@tinacms/scripts": "0.50.9",
73
+ "@tinacms/scripts": "0.51.0",
67
74
  "@types/jest": "^27.0.1",
68
75
  "@types/lodash": "^4.14.169",
69
76
  "@types/node": "^14.0.13",