tinacms 0.57.0 → 0.57.4
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/CHANGELOG.md +29 -0
- package/dist/admin/components/GetCollection.d.ts +7 -0
- package/dist/admin/components/GetDocumentFields.d.ts +6 -3
- package/dist/auth/TinaCloudProvider.d.ts +1 -1
- package/dist/edit-state.es.js +3 -0
- package/dist/edit-state.js +3 -0
- package/dist/index.es.js +109 -37
- package/dist/index.js +108 -36
- package/dist/rich-text.es.js +35 -10
- package/dist/rich-text.js +35 -10
- package/dist/tina-cms.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# tinacms
|
|
2
2
|
|
|
3
|
+
## 0.57.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4b7795612: Adds support for collection.templates to TinaAdmin
|
|
8
|
+
- a39ddc611: update media store to load only when in edit mode
|
|
9
|
+
- 1096fe3e4: Ensure forms unmount properly when `useGraphQLForms` unmounts
|
|
10
|
+
|
|
11
|
+
## 0.57.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [2724c48c0]
|
|
16
|
+
- @tinacms/toolkit@0.55.2
|
|
17
|
+
|
|
18
|
+
## 0.57.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 7849c1233: Fix styles on panel
|
|
23
|
+
|
|
24
|
+
## 0.57.1
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 9c0d48e09: Fix console errors for mdx editor
|
|
29
|
+
- Updated dependencies [9c0d48e09]
|
|
30
|
+
- @tinacms/toolkit@0.55.1
|
|
31
|
+
|
|
3
32
|
## 0.57.0
|
|
4
33
|
|
|
5
34
|
### Minor Changes
|
|
@@ -14,6 +14,7 @@ import type { TinaCMS } from '@tinacms/toolkit';
|
|
|
14
14
|
interface Document {
|
|
15
15
|
node: {
|
|
16
16
|
sys: {
|
|
17
|
+
template: string;
|
|
17
18
|
breadcrumbs: string[];
|
|
18
19
|
path: string;
|
|
19
20
|
basename: string;
|
|
@@ -23,10 +24,16 @@ interface Document {
|
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
}
|
|
27
|
+
export interface Template {
|
|
28
|
+
name: string;
|
|
29
|
+
label: string;
|
|
30
|
+
fields: any[];
|
|
31
|
+
}
|
|
26
32
|
export interface Collection {
|
|
27
33
|
label: string;
|
|
28
34
|
name: string;
|
|
29
35
|
format: string;
|
|
36
|
+
templates: Template[];
|
|
30
37
|
documents: {
|
|
31
38
|
totalCount: number;
|
|
32
39
|
edges: Document[];
|
|
@@ -14,21 +14,24 @@ import type { TinaCMS } from '@tinacms/toolkit';
|
|
|
14
14
|
interface GetDocumentFields {
|
|
15
15
|
[collectionName: string]: {
|
|
16
16
|
collection: Object;
|
|
17
|
-
|
|
17
|
+
templates?: Object[];
|
|
18
|
+
fields?: Object[];
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
export interface Info {
|
|
21
22
|
collection: Object | undefined;
|
|
23
|
+
template: Object | undefined;
|
|
22
24
|
fields: Object[] | undefined;
|
|
23
25
|
mutationInfo: {
|
|
24
26
|
includeCollection: boolean;
|
|
25
27
|
includeTemplate: boolean;
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
|
-
export declare const useGetDocumentFields: (cms: TinaCMS, collectionName: string) => Info;
|
|
29
|
-
declare const GetDocumentFields: ({ cms, collectionName, children, }: {
|
|
30
|
+
export declare const useGetDocumentFields: (cms: TinaCMS, collectionName: string, templateName: string) => Info;
|
|
31
|
+
declare const GetDocumentFields: ({ cms, collectionName, templateName, children, }: {
|
|
30
32
|
cms: TinaCMS;
|
|
31
33
|
collectionName: string;
|
|
34
|
+
templateName?: string;
|
|
32
35
|
children: any;
|
|
33
36
|
}) => JSX.Element;
|
|
34
37
|
export default GetDocumentFields;
|
|
@@ -29,7 +29,7 @@ export interface TinaCloudAuthWallProps {
|
|
|
29
29
|
action: () => Promise<void>;
|
|
30
30
|
primary: boolean;
|
|
31
31
|
}[];
|
|
32
|
-
mediaStore?: TinaCloudMediaStoreClass | Promise<TinaCloudMediaStoreClass
|
|
32
|
+
mediaStore?: TinaCloudMediaStoreClass | (() => Promise<TinaCloudMediaStoreClass>);
|
|
33
33
|
}
|
|
34
34
|
export declare const AuthWallInner: ({ children, cms, loginScreen, getModalActions, }: TinaCloudAuthWallProps) => JSX.Element;
|
|
35
35
|
/**
|
package/dist/edit-state.es.js
CHANGED
|
@@ -43,6 +43,9 @@ const ToggleButton = () => {
|
|
|
43
43
|
href: "/admin",
|
|
44
44
|
style: {
|
|
45
45
|
borderRadius: "0 50px 50px 0",
|
|
46
|
+
fontSize: "16px",
|
|
47
|
+
fontFamily: "Inter, 'Helvetica Neue', 'Arial Nova', Helvetica, Arial, sans-serif",
|
|
48
|
+
fontWeight: "bold",
|
|
46
49
|
textDecoration: "none",
|
|
47
50
|
background: "rgb(34, 150, 254)",
|
|
48
51
|
boxShadow: "0px 1px 3px rgb(0 0 0 / 10%), 0px 2px 6px rgb(0 0 0 / 20%)",
|
package/dist/edit-state.js
CHANGED
|
@@ -50,6 +50,9 @@ var __objRest = (source, exclude) => {
|
|
|
50
50
|
href: "/admin",
|
|
51
51
|
style: {
|
|
52
52
|
borderRadius: "0 50px 50px 0",
|
|
53
|
+
fontSize: "16px",
|
|
54
|
+
fontFamily: "Inter, 'Helvetica Neue', 'Arial Nova', Helvetica, Arial, sans-serif",
|
|
55
|
+
fontWeight: "bold",
|
|
53
56
|
textDecoration: "none",
|
|
54
57
|
background: "rgb(34, 150, 254)",
|
|
55
58
|
boxShadow: "0px 1px 3px rgb(0 0 0 / 10%), 0px 2px 6px rgb(0 0 0 / 20%)",
|
package/dist/index.es.js
CHANGED
|
@@ -34,7 +34,7 @@ import set from "lodash.set";
|
|
|
34
34
|
import gql$1 from "graphql-tag";
|
|
35
35
|
import { EventBus, StyleReset, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, TinaCMS, BranchSwitcherPlugin, TinaProvider, useCMS, Form, GlobalFormPlugin, FullscreenFormBuilder } from "@tinacms/toolkit";
|
|
36
36
|
export * from "@tinacms/toolkit";
|
|
37
|
-
import React, { useState, useCallback, useEffect } from "react";
|
|
37
|
+
import React, { useState, useCallback, useEffect, Fragment } from "react";
|
|
38
38
|
import styled from "styled-components";
|
|
39
39
|
import * as yup from "yup";
|
|
40
40
|
import { getIn, setIn } from "final-form";
|
|
@@ -746,8 +746,14 @@ const TinaCloudProvider = (props) => {
|
|
|
746
746
|
cms.api.tina = createClient(props);
|
|
747
747
|
}
|
|
748
748
|
const setupMedia = async () => {
|
|
749
|
+
var _a;
|
|
749
750
|
if (props.mediaStore) {
|
|
750
|
-
|
|
751
|
+
if ((_a = props.mediaStore.prototype) == null ? void 0 : _a.persist) {
|
|
752
|
+
cms.media.store = new props.mediaStore(cms.api.tina);
|
|
753
|
+
} else {
|
|
754
|
+
const MediaClass = await props.mediaStore();
|
|
755
|
+
cms.media.store = new MediaClass(cms.api.tina);
|
|
756
|
+
}
|
|
751
757
|
}
|
|
752
758
|
};
|
|
753
759
|
const handleListBranches = async () => {
|
|
@@ -807,7 +813,6 @@ function useGraphqlForms({
|
|
|
807
813
|
const [pendingReset, setPendingReset] = React.useState(null);
|
|
808
814
|
const [isLoading, setIsLoading] = React.useState(true);
|
|
809
815
|
const [newUpdate, setNewUpdate] = React.useState(null);
|
|
810
|
-
React.useState([]);
|
|
811
816
|
const updateData = async () => {
|
|
812
817
|
var _a;
|
|
813
818
|
if (newUpdate) {
|
|
@@ -856,12 +861,14 @@ function useGraphqlForms({
|
|
|
856
861
|
}
|
|
857
862
|
}, [pendingReset]);
|
|
858
863
|
React.useEffect(() => {
|
|
864
|
+
const formIds = [];
|
|
859
865
|
setIsLoading(true);
|
|
860
866
|
cms.api.tina.requestWithForm(query, { variables }).then((payload) => {
|
|
861
867
|
setData(payload);
|
|
862
868
|
setInitialData(payload);
|
|
863
869
|
setIsLoading(false);
|
|
864
870
|
Object.entries(payload).map(([queryName, result]) => {
|
|
871
|
+
formIds.push(queryName);
|
|
865
872
|
const canBeFormified = safeAssertShape(result, (yup2) => yup2.object({
|
|
866
873
|
values: yup2.object().required(),
|
|
867
874
|
form: yup2.object().required()
|
|
@@ -981,6 +988,14 @@ function useGraphqlForms({
|
|
|
981
988
|
console.error(e);
|
|
982
989
|
setIsLoading(false);
|
|
983
990
|
});
|
|
991
|
+
return () => {
|
|
992
|
+
formIds.forEach((name) => {
|
|
993
|
+
const formPlugin = cms.forms.find(name);
|
|
994
|
+
if (formPlugin) {
|
|
995
|
+
cms.forms.remove(formPlugin);
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
};
|
|
984
999
|
}, [queryString, JSON.stringify(variables)]);
|
|
985
1000
|
return [data, isLoading];
|
|
986
1001
|
}
|
|
@@ -1656,12 +1671,14 @@ const useGetCollection = (cms, collectionName, includeDocuments = true) => {
|
|
|
1656
1671
|
name
|
|
1657
1672
|
label
|
|
1658
1673
|
format
|
|
1674
|
+
templates
|
|
1659
1675
|
documents @include(if: $includeDocuments) {
|
|
1660
1676
|
totalCount
|
|
1661
1677
|
edges {
|
|
1662
1678
|
node {
|
|
1663
1679
|
... on Document {
|
|
1664
1680
|
sys {
|
|
1681
|
+
template
|
|
1665
1682
|
breadcrumbs
|
|
1666
1683
|
path
|
|
1667
1684
|
basename
|
|
@@ -1693,8 +1710,46 @@ const GetCollection = ({
|
|
|
1693
1710
|
}
|
|
1694
1711
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection));
|
|
1695
1712
|
};
|
|
1713
|
+
const TemplateMenu = ({ templates }) => {
|
|
1714
|
+
return /* @__PURE__ */ React.createElement(Menu, {
|
|
1715
|
+
as: "div",
|
|
1716
|
+
className: "relative inline-block text-left"
|
|
1717
|
+
}, ({ open }) => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Menu.Button, {
|
|
1718
|
+
className: "inline-flex items-center px-8 py-2.5 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
|
|
1719
|
+
style: { background: "#0084FF" }
|
|
1720
|
+
}, "Create New", /* @__PURE__ */ React.createElement("svg", {
|
|
1721
|
+
width: "20",
|
|
1722
|
+
height: "20",
|
|
1723
|
+
viewBox: "0 0 20 20",
|
|
1724
|
+
fill: "none",
|
|
1725
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1726
|
+
className: `ml-1 flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
|
|
1727
|
+
}, /* @__PURE__ */ React.createElement("g", {
|
|
1728
|
+
opacity: "1.0"
|
|
1729
|
+
}, /* @__PURE__ */ React.createElement("path", {
|
|
1730
|
+
d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
|
|
1731
|
+
fill: "currentColor"
|
|
1732
|
+
}))))), /* @__PURE__ */ React.createElement(Transition, {
|
|
1733
|
+
as: Fragment,
|
|
1734
|
+
enter: "transition ease-out duration-100",
|
|
1735
|
+
enterFrom: "transform opacity-0 scale-95",
|
|
1736
|
+
enterTo: "transform opacity-100 scale-100",
|
|
1737
|
+
leave: "transition ease-in duration-75",
|
|
1738
|
+
leaveFrom: "transform opacity-100 scale-100",
|
|
1739
|
+
leaveTo: "transform opacity-0 scale-95"
|
|
1740
|
+
}, /* @__PURE__ */ React.createElement(Menu.Items, {
|
|
1741
|
+
className: "origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none"
|
|
1742
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1743
|
+
className: "py-1"
|
|
1744
|
+
}, templates.map((template) => /* @__PURE__ */ React.createElement(Menu.Item, {
|
|
1745
|
+
key: `${template.label}-${template.name}`
|
|
1746
|
+
}, ({ active }) => /* @__PURE__ */ React.createElement(Link, {
|
|
1747
|
+
to: `${location.pathname}/${template.name}/new`,
|
|
1748
|
+
className: `w-full text-md px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`
|
|
1749
|
+
}, template.label))))))));
|
|
1750
|
+
};
|
|
1696
1751
|
const CollectionListPage = () => {
|
|
1697
|
-
const
|
|
1752
|
+
const location2 = useLocation();
|
|
1698
1753
|
const { collectionName } = useParams();
|
|
1699
1754
|
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetCollection, {
|
|
1700
1755
|
cms,
|
|
@@ -1711,11 +1766,13 @@ const CollectionListPage = () => {
|
|
|
1711
1766
|
className: "w-full flex justify-between items-end"
|
|
1712
1767
|
}, /* @__PURE__ */ React.createElement("h3", {
|
|
1713
1768
|
className: "text-3xl"
|
|
1714
|
-
}, collection.label), /* @__PURE__ */ React.createElement(Link, {
|
|
1715
|
-
to: `${
|
|
1769
|
+
}, collection.label), !collection.templates && /* @__PURE__ */ React.createElement(Link, {
|
|
1770
|
+
to: `${location2.pathname}/new`,
|
|
1716
1771
|
className: "inline-flex items-center px-8 py-3 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
|
|
1717
1772
|
style: { background: "#0084FF" }
|
|
1718
|
-
}, "Create New")
|
|
1773
|
+
}, "Create New"), collection.templates && /* @__PURE__ */ React.createElement(TemplateMenu, {
|
|
1774
|
+
templates: collection.templates
|
|
1775
|
+
})), totalCount > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
1719
1776
|
className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
|
|
1720
1777
|
}, /* @__PURE__ */ React.createElement("table", {
|
|
1721
1778
|
className: "min-w-full"
|
|
@@ -1726,7 +1783,7 @@ const CollectionListPage = () => {
|
|
|
1726
1783
|
}, /* @__PURE__ */ React.createElement("td", {
|
|
1727
1784
|
className: "px-6 py-2 whitespace-nowrap"
|
|
1728
1785
|
}, /* @__PURE__ */ React.createElement(Link, {
|
|
1729
|
-
to: `${
|
|
1786
|
+
to: `${location2.pathname}/${document2.node.sys.filename}`,
|
|
1730
1787
|
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3"
|
|
1731
1788
|
}, /* @__PURE__ */ React.createElement(BiEdit, {
|
|
1732
1789
|
className: "inline-block h-6 w-auto opacity-70"
|
|
@@ -1740,12 +1797,19 @@ const CollectionListPage = () => {
|
|
|
1740
1797
|
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
1741
1798
|
}, "Extension"), /* @__PURE__ */ React.createElement("span", {
|
|
1742
1799
|
className: "h-5 leading-5 block text-sm font-medium text-gray-900"
|
|
1743
|
-
}, document2.node.sys.extension))
|
|
1800
|
+
}, document2.node.sys.extension)), /* @__PURE__ */ React.createElement("td", {
|
|
1801
|
+
className: "px-6 py-4 whitespace-nowrap"
|
|
1802
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1803
|
+
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
1804
|
+
}, "Template"), /* @__PURE__ */ React.createElement("span", {
|
|
1805
|
+
className: "h-5 leading-5 block text-sm font-medium text-gray-900"
|
|
1806
|
+
}, document2.node.sys.template)))))))));
|
|
1744
1807
|
}));
|
|
1745
1808
|
};
|
|
1746
|
-
const useGetDocumentFields = (cms, collectionName) => {
|
|
1809
|
+
const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
1747
1810
|
const [info, setInfo] = useState({
|
|
1748
1811
|
collection: void 0,
|
|
1812
|
+
template: void 0,
|
|
1749
1813
|
fields: void 0,
|
|
1750
1814
|
mutationInfo: void 0
|
|
1751
1815
|
});
|
|
@@ -1754,10 +1818,18 @@ const useGetDocumentFields = (cms, collectionName) => {
|
|
|
1754
1818
|
const response = await cms.api.tina.request(`query { getDocumentFields }`, {});
|
|
1755
1819
|
const documentFields = response.getDocumentFields;
|
|
1756
1820
|
const collection = documentFields[collectionName].collection;
|
|
1757
|
-
const fields = documentFields[collectionName].fields;
|
|
1758
1821
|
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
1822
|
+
let fields = void 0;
|
|
1823
|
+
let template = void 0;
|
|
1824
|
+
if (templateName && documentFields[collectionName].templates && documentFields[collectionName].templates[templateName]) {
|
|
1825
|
+
template = documentFields[collectionName].templates[templateName].template;
|
|
1826
|
+
fields = documentFields[collectionName].templates[templateName].fields;
|
|
1827
|
+
} else {
|
|
1828
|
+
fields = documentFields[collectionName].fields;
|
|
1829
|
+
}
|
|
1759
1830
|
setInfo({
|
|
1760
1831
|
collection,
|
|
1832
|
+
template,
|
|
1761
1833
|
fields,
|
|
1762
1834
|
mutationInfo
|
|
1763
1835
|
});
|
|
@@ -1769,44 +1841,44 @@ const useGetDocumentFields = (cms, collectionName) => {
|
|
|
1769
1841
|
const GetDocumentFields = ({
|
|
1770
1842
|
cms,
|
|
1771
1843
|
collectionName,
|
|
1844
|
+
templateName,
|
|
1772
1845
|
children
|
|
1773
1846
|
}) => {
|
|
1774
|
-
const { collection, fields, mutationInfo } = useGetDocumentFields(cms, collectionName);
|
|
1775
|
-
if (!collection
|
|
1847
|
+
const { collection, template, fields, mutationInfo } = useGetDocumentFields(cms, collectionName, templateName);
|
|
1848
|
+
if (!collection) {
|
|
1776
1849
|
return null;
|
|
1777
1850
|
}
|
|
1778
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection, fields, mutationInfo));
|
|
1851
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ collection, template, fields, mutationInfo }));
|
|
1779
1852
|
};
|
|
1780
|
-
const createDocument = async (cms, collection, mutationInfo, values) => {
|
|
1853
|
+
const createDocument = async (cms, collection, template, mutationInfo, values) => {
|
|
1781
1854
|
const _a = values, { relativePath } = _a, leftover = __objRest(_a, ["relativePath"]);
|
|
1782
1855
|
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1783
|
-
const params = transformDocumentIntoMutationRequestPayload(__spreadValues({
|
|
1856
|
+
const params = transformDocumentIntoMutationRequestPayload(__spreadValues(__spreadValues({
|
|
1784
1857
|
_collection: collection.name
|
|
1785
|
-
}, leftover), {
|
|
1858
|
+
}, template && { _template: template.name }), leftover), {
|
|
1786
1859
|
includeCollection,
|
|
1787
1860
|
includeTemplate
|
|
1788
1861
|
});
|
|
1789
|
-
await cms.api.tina.request(`mutation($
|
|
1790
|
-
createDocument(
|
|
1791
|
-
collection: $collection,
|
|
1862
|
+
await cms.api.tina.request(`mutation($relativePath: String!, $params: DocumentMutation!) {
|
|
1863
|
+
createDocument(
|
|
1792
1864
|
relativePath: $relativePath,
|
|
1793
1865
|
params: $params
|
|
1794
1866
|
){__typename}
|
|
1795
1867
|
}`, {
|
|
1796
1868
|
variables: {
|
|
1797
|
-
collection: collection.name,
|
|
1798
1869
|
relativePath,
|
|
1799
1870
|
params
|
|
1800
1871
|
}
|
|
1801
1872
|
});
|
|
1802
1873
|
};
|
|
1803
1874
|
const CollectionCreatePage = () => {
|
|
1804
|
-
const { collectionName } = useParams();
|
|
1875
|
+
const { collectionName, templateName } = useParams();
|
|
1805
1876
|
const history = useHistory();
|
|
1806
1877
|
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetDocumentFields, {
|
|
1807
1878
|
cms,
|
|
1808
|
-
collectionName
|
|
1809
|
-
|
|
1879
|
+
collectionName,
|
|
1880
|
+
templateName
|
|
1881
|
+
}, ({ collection, template, fields, mutationInfo }) => {
|
|
1810
1882
|
const form = new Form({
|
|
1811
1883
|
id: "create-form",
|
|
1812
1884
|
label: "form",
|
|
@@ -1821,16 +1893,17 @@ const CollectionCreatePage = () => {
|
|
|
1821
1893
|
...fields
|
|
1822
1894
|
],
|
|
1823
1895
|
onSubmit: async (values) => {
|
|
1824
|
-
await createDocument(cms, collection, mutationInfo, values);
|
|
1896
|
+
await createDocument(cms, collection, template, mutationInfo, values);
|
|
1825
1897
|
history.push(`/admin/collections/${collection.name}`);
|
|
1826
1898
|
}
|
|
1827
1899
|
});
|
|
1900
|
+
const formLabel = template ? `${collection.label} - Create New ${template.label}` : `${collection.label} - Create New`;
|
|
1828
1901
|
return /* @__PURE__ */ React.createElement("div", {
|
|
1829
1902
|
className: "w-full h-screen"
|
|
1830
1903
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
1831
1904
|
className: "flex flex-col items-center w-full flex-1"
|
|
1832
1905
|
}, /* @__PURE__ */ React.createElement(FullscreenFormBuilder, {
|
|
1833
|
-
label:
|
|
1906
|
+
label: formLabel,
|
|
1834
1907
|
form
|
|
1835
1908
|
})));
|
|
1836
1909
|
}));
|
|
@@ -1866,21 +1939,19 @@ const GetDocument = ({
|
|
|
1866
1939
|
}
|
|
1867
1940
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document2));
|
|
1868
1941
|
};
|
|
1869
|
-
const updateDocument = async (cms,
|
|
1870
|
-
const { includeCollection, includeTemplate } =
|
|
1942
|
+
const updateDocument = async (cms, relativePath, mutationInfo, values) => {
|
|
1943
|
+
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1871
1944
|
const params = transformDocumentIntoMutationRequestPayload(values, {
|
|
1872
1945
|
includeCollection,
|
|
1873
1946
|
includeTemplate
|
|
1874
1947
|
});
|
|
1875
|
-
await cms.api.tina.request(`mutation($
|
|
1876
|
-
updateDocument(
|
|
1877
|
-
collection: $collection,
|
|
1948
|
+
await cms.api.tina.request(`mutation($relativePath: String!, $params: DocumentMutation!) {
|
|
1949
|
+
updateDocument(
|
|
1878
1950
|
relativePath: $relativePath,
|
|
1879
1951
|
params: $params
|
|
1880
1952
|
){__typename}
|
|
1881
1953
|
}`, {
|
|
1882
1954
|
variables: {
|
|
1883
|
-
collection: collection.name,
|
|
1884
1955
|
relativePath,
|
|
1885
1956
|
params
|
|
1886
1957
|
}
|
|
@@ -1889,11 +1960,10 @@ const updateDocument = async (cms, collection, document2, relativePath, values)
|
|
|
1889
1960
|
const CollectionUpdatePage = () => {
|
|
1890
1961
|
const { collectionName, filename } = useParams();
|
|
1891
1962
|
const history = useHistory();
|
|
1892
|
-
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(
|
|
1963
|
+
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetDocumentFields, {
|
|
1893
1964
|
cms,
|
|
1894
|
-
collectionName
|
|
1895
|
-
|
|
1896
|
-
}, (collection) => {
|
|
1965
|
+
collectionName
|
|
1966
|
+
}, ({ collection, mutationInfo }) => {
|
|
1897
1967
|
const relativePath = `${filename}.${collection.format}`;
|
|
1898
1968
|
return /* @__PURE__ */ React.createElement(GetDocument, {
|
|
1899
1969
|
cms,
|
|
@@ -1906,7 +1976,7 @@ const CollectionUpdatePage = () => {
|
|
|
1906
1976
|
fields: document2.form.fields,
|
|
1907
1977
|
initialValues: document2.values,
|
|
1908
1978
|
onSubmit: async (values) => {
|
|
1909
|
-
await updateDocument(cms,
|
|
1979
|
+
await updateDocument(cms, relativePath, mutationInfo, values);
|
|
1910
1980
|
history.push(`/admin/collections/${collection.name}`);
|
|
1911
1981
|
}
|
|
1912
1982
|
});
|
|
@@ -2026,6 +2096,8 @@ const TinaAdmin = () => {
|
|
|
2026
2096
|
className: "flex-1"
|
|
2027
2097
|
}, /* @__PURE__ */ React.createElement(Switch, null, /* @__PURE__ */ React.createElement(Route, {
|
|
2028
2098
|
path: `/admin/collections/:collectionName/new`
|
|
2099
|
+
}, /* @__PURE__ */ React.createElement(CollectionCreatePage, null)), /* @__PURE__ */ React.createElement(Route, {
|
|
2100
|
+
path: `/admin/collections/:collectionName/:templateName/new`
|
|
2029
2101
|
}, /* @__PURE__ */ React.createElement(CollectionCreatePage, null)), /* @__PURE__ */ React.createElement(Route, {
|
|
2030
2102
|
path: `/admin/collections/:collectionName/:filename`
|
|
2031
2103
|
}, /* @__PURE__ */ React.createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React.createElement(Route, {
|
package/dist/index.js
CHANGED
|
@@ -767,8 +767,14 @@ mutation addPendingDocumentMutation(
|
|
|
767
767
|
cms.api.tina = createClient(props);
|
|
768
768
|
}
|
|
769
769
|
const setupMedia = async () => {
|
|
770
|
+
var _a;
|
|
770
771
|
if (props.mediaStore) {
|
|
771
|
-
|
|
772
|
+
if ((_a = props.mediaStore.prototype) == null ? void 0 : _a.persist) {
|
|
773
|
+
cms.media.store = new props.mediaStore(cms.api.tina);
|
|
774
|
+
} else {
|
|
775
|
+
const MediaClass = await props.mediaStore();
|
|
776
|
+
cms.media.store = new MediaClass(cms.api.tina);
|
|
777
|
+
}
|
|
772
778
|
}
|
|
773
779
|
};
|
|
774
780
|
const handleListBranches = async () => {
|
|
@@ -828,7 +834,6 @@ mutation addPendingDocumentMutation(
|
|
|
828
834
|
const [pendingReset, setPendingReset] = React__default["default"].useState(null);
|
|
829
835
|
const [isLoading, setIsLoading] = React__default["default"].useState(true);
|
|
830
836
|
const [newUpdate, setNewUpdate] = React__default["default"].useState(null);
|
|
831
|
-
React__default["default"].useState([]);
|
|
832
837
|
const updateData = async () => {
|
|
833
838
|
var _a;
|
|
834
839
|
if (newUpdate) {
|
|
@@ -877,12 +882,14 @@ mutation addPendingDocumentMutation(
|
|
|
877
882
|
}
|
|
878
883
|
}, [pendingReset]);
|
|
879
884
|
React__default["default"].useEffect(() => {
|
|
885
|
+
const formIds = [];
|
|
880
886
|
setIsLoading(true);
|
|
881
887
|
cms.api.tina.requestWithForm(query, { variables }).then((payload) => {
|
|
882
888
|
setData(payload);
|
|
883
889
|
setInitialData(payload);
|
|
884
890
|
setIsLoading(false);
|
|
885
891
|
Object.entries(payload).map(([queryName, result]) => {
|
|
892
|
+
formIds.push(queryName);
|
|
886
893
|
const canBeFormified = safeAssertShape(result, (yup2) => yup2.object({
|
|
887
894
|
values: yup2.object().required(),
|
|
888
895
|
form: yup2.object().required()
|
|
@@ -1002,6 +1009,14 @@ mutation addPendingDocumentMutation(
|
|
|
1002
1009
|
console.error(e);
|
|
1003
1010
|
setIsLoading(false);
|
|
1004
1011
|
});
|
|
1012
|
+
return () => {
|
|
1013
|
+
formIds.forEach((name) => {
|
|
1014
|
+
const formPlugin = cms.forms.find(name);
|
|
1015
|
+
if (formPlugin) {
|
|
1016
|
+
cms.forms.remove(formPlugin);
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
};
|
|
1005
1020
|
}, [queryString, JSON.stringify(variables)]);
|
|
1006
1021
|
return [data, isLoading];
|
|
1007
1022
|
}
|
|
@@ -1677,12 +1692,14 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1677
1692
|
name
|
|
1678
1693
|
label
|
|
1679
1694
|
format
|
|
1695
|
+
templates
|
|
1680
1696
|
documents @include(if: $includeDocuments) {
|
|
1681
1697
|
totalCount
|
|
1682
1698
|
edges {
|
|
1683
1699
|
node {
|
|
1684
1700
|
... on Document {
|
|
1685
1701
|
sys {
|
|
1702
|
+
template
|
|
1686
1703
|
breadcrumbs
|
|
1687
1704
|
path
|
|
1688
1705
|
basename
|
|
@@ -1714,8 +1731,46 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1714
1731
|
}
|
|
1715
1732
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection));
|
|
1716
1733
|
};
|
|
1734
|
+
const TemplateMenu = ({ templates }) => {
|
|
1735
|
+
return /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
|
|
1736
|
+
as: "div",
|
|
1737
|
+
className: "relative inline-block text-left"
|
|
1738
|
+
}, ({ open }) => /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Button, {
|
|
1739
|
+
className: "inline-flex items-center px-8 py-2.5 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
|
|
1740
|
+
style: { background: "#0084FF" }
|
|
1741
|
+
}, "Create New", /* @__PURE__ */ React__default["default"].createElement("svg", {
|
|
1742
|
+
width: "20",
|
|
1743
|
+
height: "20",
|
|
1744
|
+
viewBox: "0 0 20 20",
|
|
1745
|
+
fill: "none",
|
|
1746
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1747
|
+
className: `ml-1 flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
|
|
1748
|
+
}, /* @__PURE__ */ React__default["default"].createElement("g", {
|
|
1749
|
+
opacity: "1.0"
|
|
1750
|
+
}, /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1751
|
+
d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
|
|
1752
|
+
fill: "currentColor"
|
|
1753
|
+
}))))), /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
|
|
1754
|
+
as: React.Fragment,
|
|
1755
|
+
enter: "transition ease-out duration-100",
|
|
1756
|
+
enterFrom: "transform opacity-0 scale-95",
|
|
1757
|
+
enterTo: "transform opacity-100 scale-100",
|
|
1758
|
+
leave: "transition ease-in duration-75",
|
|
1759
|
+
leaveFrom: "transform opacity-100 scale-100",
|
|
1760
|
+
leaveTo: "transform opacity-0 scale-95"
|
|
1761
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Items, {
|
|
1762
|
+
className: "origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none"
|
|
1763
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1764
|
+
className: "py-1"
|
|
1765
|
+
}, templates.map((template) => /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, {
|
|
1766
|
+
key: `${template.label}-${template.name}`
|
|
1767
|
+
}, ({ active }) => /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1768
|
+
to: `${location.pathname}/${template.name}/new`,
|
|
1769
|
+
className: `w-full text-md px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`
|
|
1770
|
+
}, template.label))))))));
|
|
1771
|
+
};
|
|
1717
1772
|
const CollectionListPage = () => {
|
|
1718
|
-
const
|
|
1773
|
+
const location2 = reactRouterDom.useLocation();
|
|
1719
1774
|
const { collectionName } = reactRouterDom.useParams();
|
|
1720
1775
|
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
|
|
1721
1776
|
cms,
|
|
@@ -1732,11 +1787,13 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1732
1787
|
className: "w-full flex justify-between items-end"
|
|
1733
1788
|
}, /* @__PURE__ */ React__default["default"].createElement("h3", {
|
|
1734
1789
|
className: "text-3xl"
|
|
1735
|
-
}, collection.label), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1736
|
-
to: `${
|
|
1790
|
+
}, collection.label), !collection.templates && /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1791
|
+
to: `${location2.pathname}/new`,
|
|
1737
1792
|
className: "inline-flex items-center px-8 py-3 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
|
|
1738
1793
|
style: { background: "#0084FF" }
|
|
1739
|
-
}, "Create New")
|
|
1794
|
+
}, "Create New"), collection.templates && /* @__PURE__ */ React__default["default"].createElement(TemplateMenu, {
|
|
1795
|
+
templates: collection.templates
|
|
1796
|
+
})), totalCount > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1740
1797
|
className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
|
|
1741
1798
|
}, /* @__PURE__ */ React__default["default"].createElement("table", {
|
|
1742
1799
|
className: "min-w-full"
|
|
@@ -1747,7 +1804,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1747
1804
|
}, /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1748
1805
|
className: "px-6 py-2 whitespace-nowrap"
|
|
1749
1806
|
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1750
|
-
to: `${
|
|
1807
|
+
to: `${location2.pathname}/${document2.node.sys.filename}`,
|
|
1751
1808
|
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3"
|
|
1752
1809
|
}, /* @__PURE__ */ React__default["default"].createElement(BiEdit, {
|
|
1753
1810
|
className: "inline-block h-6 w-auto opacity-70"
|
|
@@ -1761,12 +1818,19 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1761
1818
|
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
1762
1819
|
}, "Extension"), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1763
1820
|
className: "h-5 leading-5 block text-sm font-medium text-gray-900"
|
|
1764
|
-
}, document2.node.sys.extension))
|
|
1821
|
+
}, document2.node.sys.extension)), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1822
|
+
className: "px-6 py-4 whitespace-nowrap"
|
|
1823
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1824
|
+
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
1825
|
+
}, "Template"), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1826
|
+
className: "h-5 leading-5 block text-sm font-medium text-gray-900"
|
|
1827
|
+
}, document2.node.sys.template)))))))));
|
|
1765
1828
|
}));
|
|
1766
1829
|
};
|
|
1767
|
-
const useGetDocumentFields = (cms, collectionName) => {
|
|
1830
|
+
const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
1768
1831
|
const [info, setInfo] = React.useState({
|
|
1769
1832
|
collection: void 0,
|
|
1833
|
+
template: void 0,
|
|
1770
1834
|
fields: void 0,
|
|
1771
1835
|
mutationInfo: void 0
|
|
1772
1836
|
});
|
|
@@ -1775,10 +1839,18 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1775
1839
|
const response = await cms.api.tina.request(`query { getDocumentFields }`, {});
|
|
1776
1840
|
const documentFields = response.getDocumentFields;
|
|
1777
1841
|
const collection = documentFields[collectionName].collection;
|
|
1778
|
-
const fields = documentFields[collectionName].fields;
|
|
1779
1842
|
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
1843
|
+
let fields = void 0;
|
|
1844
|
+
let template = void 0;
|
|
1845
|
+
if (templateName && documentFields[collectionName].templates && documentFields[collectionName].templates[templateName]) {
|
|
1846
|
+
template = documentFields[collectionName].templates[templateName].template;
|
|
1847
|
+
fields = documentFields[collectionName].templates[templateName].fields;
|
|
1848
|
+
} else {
|
|
1849
|
+
fields = documentFields[collectionName].fields;
|
|
1850
|
+
}
|
|
1780
1851
|
setInfo({
|
|
1781
1852
|
collection,
|
|
1853
|
+
template,
|
|
1782
1854
|
fields,
|
|
1783
1855
|
mutationInfo
|
|
1784
1856
|
});
|
|
@@ -1790,44 +1862,44 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1790
1862
|
const GetDocumentFields = ({
|
|
1791
1863
|
cms,
|
|
1792
1864
|
collectionName,
|
|
1865
|
+
templateName,
|
|
1793
1866
|
children
|
|
1794
1867
|
}) => {
|
|
1795
|
-
const { collection, fields, mutationInfo } = useGetDocumentFields(cms, collectionName);
|
|
1796
|
-
if (!collection
|
|
1868
|
+
const { collection, template, fields, mutationInfo } = useGetDocumentFields(cms, collectionName, templateName);
|
|
1869
|
+
if (!collection) {
|
|
1797
1870
|
return null;
|
|
1798
1871
|
}
|
|
1799
|
-
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, fields, mutationInfo));
|
|
1872
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children({ collection, template, fields, mutationInfo }));
|
|
1800
1873
|
};
|
|
1801
|
-
const createDocument = async (cms, collection, mutationInfo, values) => {
|
|
1874
|
+
const createDocument = async (cms, collection, template, mutationInfo, values) => {
|
|
1802
1875
|
const _a = values, { relativePath } = _a, leftover = __objRest(_a, ["relativePath"]);
|
|
1803
1876
|
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1804
|
-
const params = transformDocumentIntoMutationRequestPayload(__spreadValues({
|
|
1877
|
+
const params = transformDocumentIntoMutationRequestPayload(__spreadValues(__spreadValues({
|
|
1805
1878
|
_collection: collection.name
|
|
1806
|
-
}, leftover), {
|
|
1879
|
+
}, template && { _template: template.name }), leftover), {
|
|
1807
1880
|
includeCollection,
|
|
1808
1881
|
includeTemplate
|
|
1809
1882
|
});
|
|
1810
|
-
await cms.api.tina.request(`mutation($
|
|
1811
|
-
createDocument(
|
|
1812
|
-
collection: $collection,
|
|
1883
|
+
await cms.api.tina.request(`mutation($relativePath: String!, $params: DocumentMutation!) {
|
|
1884
|
+
createDocument(
|
|
1813
1885
|
relativePath: $relativePath,
|
|
1814
1886
|
params: $params
|
|
1815
1887
|
){__typename}
|
|
1816
1888
|
}`, {
|
|
1817
1889
|
variables: {
|
|
1818
|
-
collection: collection.name,
|
|
1819
1890
|
relativePath,
|
|
1820
1891
|
params
|
|
1821
1892
|
}
|
|
1822
1893
|
});
|
|
1823
1894
|
};
|
|
1824
1895
|
const CollectionCreatePage = () => {
|
|
1825
|
-
const { collectionName } = reactRouterDom.useParams();
|
|
1896
|
+
const { collectionName, templateName } = reactRouterDom.useParams();
|
|
1826
1897
|
const history = reactRouterDom.useHistory();
|
|
1827
1898
|
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetDocumentFields, {
|
|
1828
1899
|
cms,
|
|
1829
|
-
collectionName
|
|
1830
|
-
|
|
1900
|
+
collectionName,
|
|
1901
|
+
templateName
|
|
1902
|
+
}, ({ collection, template, fields, mutationInfo }) => {
|
|
1831
1903
|
const form = new toolkit.Form({
|
|
1832
1904
|
id: "create-form",
|
|
1833
1905
|
label: "form",
|
|
@@ -1842,16 +1914,17 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1842
1914
|
...fields
|
|
1843
1915
|
],
|
|
1844
1916
|
onSubmit: async (values) => {
|
|
1845
|
-
await createDocument(cms, collection, mutationInfo, values);
|
|
1917
|
+
await createDocument(cms, collection, template, mutationInfo, values);
|
|
1846
1918
|
history.push(`/admin/collections/${collection.name}`);
|
|
1847
1919
|
}
|
|
1848
1920
|
});
|
|
1921
|
+
const formLabel = template ? `${collection.label} - Create New ${template.label}` : `${collection.label} - Create New`;
|
|
1849
1922
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1850
1923
|
className: "w-full h-screen"
|
|
1851
1924
|
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1852
1925
|
className: "flex flex-col items-center w-full flex-1"
|
|
1853
1926
|
}, /* @__PURE__ */ React__default["default"].createElement(toolkit.FullscreenFormBuilder, {
|
|
1854
|
-
label:
|
|
1927
|
+
label: formLabel,
|
|
1855
1928
|
form
|
|
1856
1929
|
})));
|
|
1857
1930
|
}));
|
|
@@ -1887,21 +1960,19 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1887
1960
|
}
|
|
1888
1961
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(document2));
|
|
1889
1962
|
};
|
|
1890
|
-
const updateDocument = async (cms,
|
|
1891
|
-
const { includeCollection, includeTemplate } =
|
|
1963
|
+
const updateDocument = async (cms, relativePath, mutationInfo, values) => {
|
|
1964
|
+
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1892
1965
|
const params = transformDocumentIntoMutationRequestPayload(values, {
|
|
1893
1966
|
includeCollection,
|
|
1894
1967
|
includeTemplate
|
|
1895
1968
|
});
|
|
1896
|
-
await cms.api.tina.request(`mutation($
|
|
1897
|
-
updateDocument(
|
|
1898
|
-
collection: $collection,
|
|
1969
|
+
await cms.api.tina.request(`mutation($relativePath: String!, $params: DocumentMutation!) {
|
|
1970
|
+
updateDocument(
|
|
1899
1971
|
relativePath: $relativePath,
|
|
1900
1972
|
params: $params
|
|
1901
1973
|
){__typename}
|
|
1902
1974
|
}`, {
|
|
1903
1975
|
variables: {
|
|
1904
|
-
collection: collection.name,
|
|
1905
1976
|
relativePath,
|
|
1906
1977
|
params
|
|
1907
1978
|
}
|
|
@@ -1910,11 +1981,10 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1910
1981
|
const CollectionUpdatePage = () => {
|
|
1911
1982
|
const { collectionName, filename } = reactRouterDom.useParams();
|
|
1912
1983
|
const history = reactRouterDom.useHistory();
|
|
1913
|
-
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(
|
|
1984
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetDocumentFields, {
|
|
1914
1985
|
cms,
|
|
1915
|
-
collectionName
|
|
1916
|
-
|
|
1917
|
-
}, (collection) => {
|
|
1986
|
+
collectionName
|
|
1987
|
+
}, ({ collection, mutationInfo }) => {
|
|
1918
1988
|
const relativePath = `${filename}.${collection.format}`;
|
|
1919
1989
|
return /* @__PURE__ */ React__default["default"].createElement(GetDocument, {
|
|
1920
1990
|
cms,
|
|
@@ -1927,7 +1997,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1927
1997
|
fields: document2.form.fields,
|
|
1928
1998
|
initialValues: document2.values,
|
|
1929
1999
|
onSubmit: async (values) => {
|
|
1930
|
-
await updateDocument(cms,
|
|
2000
|
+
await updateDocument(cms, relativePath, mutationInfo, values);
|
|
1931
2001
|
history.push(`/admin/collections/${collection.name}`);
|
|
1932
2002
|
}
|
|
1933
2003
|
});
|
|
@@ -2047,6 +2117,8 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2047
2117
|
className: "flex-1"
|
|
2048
2118
|
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2049
2119
|
path: `/admin/collections/:collectionName/new`
|
|
2120
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2121
|
+
path: `/admin/collections/:collectionName/:templateName/new`
|
|
2050
2122
|
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2051
2123
|
path: `/admin/collections/:collectionName/:filename`
|
|
2052
2124
|
}, /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
package/dist/rich-text.es.js
CHANGED
|
@@ -42,7 +42,8 @@ const TinaMarkdown = ({
|
|
|
42
42
|
console.log(`Expected to find structured content for TinaMarkdown`);
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, nodes.map((child) => {
|
|
45
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, nodes.map((child, index) => {
|
|
46
|
+
const key = index;
|
|
46
47
|
const _a = child, { children } = _a, props = __objRest(_a, ["children"]);
|
|
47
48
|
switch (child.type) {
|
|
48
49
|
case "h1":
|
|
@@ -58,7 +59,9 @@ const TinaMarkdown = ({
|
|
|
58
59
|
case "li":
|
|
59
60
|
if (components[child.type]) {
|
|
60
61
|
const Component2 = components[child.type];
|
|
61
|
-
return /* @__PURE__ */ React.createElement(Component2, __spreadProps(__spreadValues({
|
|
62
|
+
return /* @__PURE__ */ React.createElement(Component2, __spreadProps(__spreadValues({
|
|
63
|
+
key
|
|
64
|
+
}, props), {
|
|
62
65
|
childrenRaw: children
|
|
63
66
|
}), /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
64
67
|
components,
|
|
@@ -66,34 +69,43 @@ const TinaMarkdown = ({
|
|
|
66
69
|
}));
|
|
67
70
|
}
|
|
68
71
|
return React.createElement(child.type, {
|
|
72
|
+
key,
|
|
69
73
|
children: /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
70
74
|
components,
|
|
71
75
|
content: children
|
|
72
76
|
})
|
|
73
77
|
});
|
|
74
78
|
case "lic":
|
|
75
|
-
return /* @__PURE__ */ React.createElement("div",
|
|
79
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
80
|
+
key
|
|
81
|
+
}, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
76
82
|
components,
|
|
77
83
|
content: child.children
|
|
78
84
|
}));
|
|
79
85
|
case "img":
|
|
80
86
|
if (components[child.type]) {
|
|
81
87
|
const Component2 = components[child.type];
|
|
82
|
-
return /* @__PURE__ */ React.createElement(Component2, __spreadValues({
|
|
88
|
+
return /* @__PURE__ */ React.createElement(Component2, __spreadValues({
|
|
89
|
+
key
|
|
90
|
+
}, props));
|
|
83
91
|
}
|
|
84
92
|
return /* @__PURE__ */ React.createElement("img", {
|
|
93
|
+
key,
|
|
85
94
|
src: child.url,
|
|
86
95
|
alt: child.caption
|
|
87
96
|
});
|
|
88
97
|
case "a":
|
|
89
98
|
if (components[child.type]) {
|
|
90
99
|
const Component2 = components[child.type];
|
|
91
|
-
return /* @__PURE__ */ React.createElement(Component2, __spreadValues({
|
|
100
|
+
return /* @__PURE__ */ React.createElement(Component2, __spreadValues({
|
|
101
|
+
key
|
|
102
|
+
}, props), /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
92
103
|
components,
|
|
93
104
|
content: children
|
|
94
105
|
}));
|
|
95
106
|
}
|
|
96
107
|
return /* @__PURE__ */ React.createElement("a", {
|
|
108
|
+
key,
|
|
97
109
|
href: child.url
|
|
98
110
|
}, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
99
111
|
components,
|
|
@@ -105,19 +117,28 @@ const TinaMarkdown = ({
|
|
|
105
117
|
}).join("\n");
|
|
106
118
|
if (components[child.type]) {
|
|
107
119
|
const Component2 = components[child.type];
|
|
108
|
-
return /* @__PURE__ */ React.createElement(Component2, __spreadProps(__spreadValues({
|
|
120
|
+
return /* @__PURE__ */ React.createElement(Component2, __spreadProps(__spreadValues({
|
|
121
|
+
key
|
|
122
|
+
}, props), {
|
|
109
123
|
childrenRaw: children
|
|
110
124
|
}), value);
|
|
111
125
|
}
|
|
112
|
-
return /* @__PURE__ */ React.createElement("pre",
|
|
126
|
+
return /* @__PURE__ */ React.createElement("pre", {
|
|
127
|
+
key
|
|
128
|
+
}, /* @__PURE__ */ React.createElement("code", null, value));
|
|
113
129
|
case "hr":
|
|
114
130
|
if (components[child.type]) {
|
|
115
131
|
const Component2 = components[child.type];
|
|
116
|
-
return /* @__PURE__ */ React.createElement(Component2, __spreadValues({
|
|
132
|
+
return /* @__PURE__ */ React.createElement(Component2, __spreadValues({
|
|
133
|
+
key
|
|
134
|
+
}, props));
|
|
117
135
|
}
|
|
118
|
-
return /* @__PURE__ */ React.createElement("hr",
|
|
136
|
+
return /* @__PURE__ */ React.createElement("hr", {
|
|
137
|
+
key
|
|
138
|
+
});
|
|
119
139
|
case "text":
|
|
120
140
|
return /* @__PURE__ */ React.createElement(Leaf, __spreadValues({
|
|
141
|
+
key,
|
|
121
142
|
components
|
|
122
143
|
}, child));
|
|
123
144
|
case "mdxJsxTextElement":
|
|
@@ -125,11 +146,14 @@ const TinaMarkdown = ({
|
|
|
125
146
|
const Component = components[child.name];
|
|
126
147
|
if (Component) {
|
|
127
148
|
const props2 = child.props ? child.props : {};
|
|
128
|
-
return /* @__PURE__ */ React.createElement(Component, __spreadValues({
|
|
149
|
+
return /* @__PURE__ */ React.createElement(Component, __spreadValues({
|
|
150
|
+
key
|
|
151
|
+
}, props2));
|
|
129
152
|
} else {
|
|
130
153
|
const ComponentMissing = components["component_missing"];
|
|
131
154
|
if (ComponentMissing) {
|
|
132
155
|
return /* @__PURE__ */ React.createElement(ComponentMissing, {
|
|
156
|
+
key,
|
|
133
157
|
name: child.name
|
|
134
158
|
});
|
|
135
159
|
} else {
|
|
@@ -139,6 +163,7 @@ const TinaMarkdown = ({
|
|
|
139
163
|
default:
|
|
140
164
|
if (typeof child.text === "string") {
|
|
141
165
|
return /* @__PURE__ */ React.createElement(Leaf, __spreadValues({
|
|
166
|
+
key,
|
|
142
167
|
components
|
|
143
168
|
}, child));
|
|
144
169
|
}
|
package/dist/rich-text.js
CHANGED
|
@@ -49,7 +49,8 @@ var __objRest = (source, exclude) => {
|
|
|
49
49
|
console.log(`Expected to find structured content for TinaMarkdown`);
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
|
-
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, nodes.map((child) => {
|
|
52
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, nodes.map((child, index) => {
|
|
53
|
+
const key = index;
|
|
53
54
|
const _a = child, { children } = _a, props = __objRest(_a, ["children"]);
|
|
54
55
|
switch (child.type) {
|
|
55
56
|
case "h1":
|
|
@@ -65,7 +66,9 @@ var __objRest = (source, exclude) => {
|
|
|
65
66
|
case "li":
|
|
66
67
|
if (components[child.type]) {
|
|
67
68
|
const Component2 = components[child.type];
|
|
68
|
-
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadProps(__spreadValues({
|
|
69
|
+
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadProps(__spreadValues({
|
|
70
|
+
key
|
|
71
|
+
}, props), {
|
|
69
72
|
childrenRaw: children
|
|
70
73
|
}), /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
|
|
71
74
|
components,
|
|
@@ -73,34 +76,43 @@ var __objRest = (source, exclude) => {
|
|
|
73
76
|
}));
|
|
74
77
|
}
|
|
75
78
|
return React__default["default"].createElement(child.type, {
|
|
79
|
+
key,
|
|
76
80
|
children: /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
|
|
77
81
|
components,
|
|
78
82
|
content: children
|
|
79
83
|
})
|
|
80
84
|
});
|
|
81
85
|
case "lic":
|
|
82
|
-
return /* @__PURE__ */ React__default["default"].createElement("div",
|
|
86
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
87
|
+
key
|
|
88
|
+
}, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
|
|
83
89
|
components,
|
|
84
90
|
content: child.children
|
|
85
91
|
}));
|
|
86
92
|
case "img":
|
|
87
93
|
if (components[child.type]) {
|
|
88
94
|
const Component2 = components[child.type];
|
|
89
|
-
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadValues({
|
|
95
|
+
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadValues({
|
|
96
|
+
key
|
|
97
|
+
}, props));
|
|
90
98
|
}
|
|
91
99
|
return /* @__PURE__ */ React__default["default"].createElement("img", {
|
|
100
|
+
key,
|
|
92
101
|
src: child.url,
|
|
93
102
|
alt: child.caption
|
|
94
103
|
});
|
|
95
104
|
case "a":
|
|
96
105
|
if (components[child.type]) {
|
|
97
106
|
const Component2 = components[child.type];
|
|
98
|
-
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadValues({
|
|
107
|
+
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadValues({
|
|
108
|
+
key
|
|
109
|
+
}, props), /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
|
|
99
110
|
components,
|
|
100
111
|
content: children
|
|
101
112
|
}));
|
|
102
113
|
}
|
|
103
114
|
return /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
115
|
+
key,
|
|
104
116
|
href: child.url
|
|
105
117
|
}, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
|
|
106
118
|
components,
|
|
@@ -112,19 +124,28 @@ var __objRest = (source, exclude) => {
|
|
|
112
124
|
}).join("\n");
|
|
113
125
|
if (components[child.type]) {
|
|
114
126
|
const Component2 = components[child.type];
|
|
115
|
-
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadProps(__spreadValues({
|
|
127
|
+
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadProps(__spreadValues({
|
|
128
|
+
key
|
|
129
|
+
}, props), {
|
|
116
130
|
childrenRaw: children
|
|
117
131
|
}), value);
|
|
118
132
|
}
|
|
119
|
-
return /* @__PURE__ */ React__default["default"].createElement("pre",
|
|
133
|
+
return /* @__PURE__ */ React__default["default"].createElement("pre", {
|
|
134
|
+
key
|
|
135
|
+
}, /* @__PURE__ */ React__default["default"].createElement("code", null, value));
|
|
120
136
|
case "hr":
|
|
121
137
|
if (components[child.type]) {
|
|
122
138
|
const Component2 = components[child.type];
|
|
123
|
-
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadValues({
|
|
139
|
+
return /* @__PURE__ */ React__default["default"].createElement(Component2, __spreadValues({
|
|
140
|
+
key
|
|
141
|
+
}, props));
|
|
124
142
|
}
|
|
125
|
-
return /* @__PURE__ */ React__default["default"].createElement("hr",
|
|
143
|
+
return /* @__PURE__ */ React__default["default"].createElement("hr", {
|
|
144
|
+
key
|
|
145
|
+
});
|
|
126
146
|
case "text":
|
|
127
147
|
return /* @__PURE__ */ React__default["default"].createElement(Leaf, __spreadValues({
|
|
148
|
+
key,
|
|
128
149
|
components
|
|
129
150
|
}, child));
|
|
130
151
|
case "mdxJsxTextElement":
|
|
@@ -132,11 +153,14 @@ var __objRest = (source, exclude) => {
|
|
|
132
153
|
const Component = components[child.name];
|
|
133
154
|
if (Component) {
|
|
134
155
|
const props2 = child.props ? child.props : {};
|
|
135
|
-
return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadValues({
|
|
156
|
+
return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadValues({
|
|
157
|
+
key
|
|
158
|
+
}, props2));
|
|
136
159
|
} else {
|
|
137
160
|
const ComponentMissing = components["component_missing"];
|
|
138
161
|
if (ComponentMissing) {
|
|
139
162
|
return /* @__PURE__ */ React__default["default"].createElement(ComponentMissing, {
|
|
163
|
+
key,
|
|
140
164
|
name: child.name
|
|
141
165
|
});
|
|
142
166
|
} else {
|
|
@@ -146,6 +170,7 @@ var __objRest = (source, exclude) => {
|
|
|
146
170
|
default:
|
|
147
171
|
if (typeof child.text === "string") {
|
|
148
172
|
return /* @__PURE__ */ React__default["default"].createElement(Leaf, __spreadValues({
|
|
173
|
+
key,
|
|
149
174
|
components
|
|
150
175
|
}, child));
|
|
151
176
|
}
|
package/dist/tina-cms.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare const TinaCMSProvider2: ({ children, branch, clientId, isLocalCli
|
|
|
38
38
|
/** Callback if you need access to the "document creator" API */
|
|
39
39
|
documentCreatorCallback?: Parameters<typeof useDocumentCreatorPlugin>[0];
|
|
40
40
|
/** TinaCMS media store instance */
|
|
41
|
-
mediaStore?: TinaCloudMediaStoreClass | Promise<TinaCloudMediaStoreClass
|
|
41
|
+
mediaStore?: TinaCloudMediaStoreClass | (() => Promise<TinaCloudMediaStoreClass>);
|
|
42
42
|
tinaioConfig?: TinaIOConfig;
|
|
43
43
|
}) => JSX.Element;
|
|
44
44
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@graphql-codegen/typescript-operations": "^1.15.4",
|
|
26
26
|
"@headlessui/react": "^1.4.1",
|
|
27
27
|
"@heroicons/react": "^1.0.4",
|
|
28
|
-
"@tinacms/toolkit": "0.55.
|
|
28
|
+
"@tinacms/toolkit": "0.55.2",
|
|
29
29
|
"@xstate/react": "^1.1.0",
|
|
30
30
|
"codemirror": "^5.55.0",
|
|
31
31
|
"cors": "^2.8.5",
|