@canva/cli 1.19.0 → 1.20.0

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.
Files changed (231) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -9
  3. package/cli.js +408 -409
  4. package/package.json +1 -2
  5. package/templates/base/backend/base_backend/create.ts +0 -114
  6. package/templates/base/backend/database/database.ts +0 -42
  7. package/templates/base/backend/routers/auth.ts +0 -288
  8. package/templates/base/declarations/declarations.d.ts +0 -29
  9. package/templates/base/eslint.config.mjs +0 -14
  10. package/templates/base/package.json +0 -91
  11. package/templates/base/scripts/copy_env.ts +0 -13
  12. package/templates/base/scripts/ssl/ssl.ts +0 -131
  13. package/templates/base/scripts/start/app_runner.ts +0 -223
  14. package/templates/base/scripts/start/context.ts +0 -171
  15. package/templates/base/scripts/start/start.ts +0 -46
  16. package/templates/base/scripts/start.tests.ts +0 -61
  17. package/templates/base/styles/components.css +0 -38
  18. package/templates/base/tsconfig.json +0 -56
  19. package/templates/base/webpack.config.ts +0 -247
  20. package/templates/common/.env.template +0 -6
  21. package/templates/common/.gitignore.template +0 -8
  22. package/templates/common/.nvmrc +0 -1
  23. package/templates/common/.prettierrc +0 -21
  24. package/templates/common/LICENSE.md +0 -48
  25. package/templates/common/README.md +0 -179
  26. package/templates/common/jest.config.mjs +0 -35
  27. package/templates/common/jest.setup.ts +0 -35
  28. package/templates/content_publisher/README.md +0 -58
  29. package/templates/content_publisher/canva-app.json +0 -17
  30. package/templates/content_publisher/declarations/declarations.d.ts +0 -29
  31. package/templates/content_publisher/eslint.config.mjs +0 -14
  32. package/templates/content_publisher/package.json +0 -90
  33. package/templates/content_publisher/scripts/copy_env.ts +0 -13
  34. package/templates/content_publisher/scripts/ssl/ssl.ts +0 -131
  35. package/templates/content_publisher/scripts/start/app_runner.ts +0 -223
  36. package/templates/content_publisher/scripts/start/context.ts +0 -171
  37. package/templates/content_publisher/scripts/start/start.ts +0 -46
  38. package/templates/content_publisher/src/index.tsx +0 -4
  39. package/templates/content_publisher/src/intents/content_publisher/index.tsx +0 -107
  40. package/templates/content_publisher/src/intents/content_publisher/post_preview.tsx +0 -240
  41. package/templates/content_publisher/src/intents/content_publisher/preview_ui.tsx +0 -62
  42. package/templates/content_publisher/src/intents/content_publisher/settings_ui.tsx +0 -81
  43. package/templates/content_publisher/src/intents/content_publisher/types.ts +0 -29
  44. package/templates/content_publisher/styles/components.css +0 -38
  45. package/templates/content_publisher/styles/preview_ui.css +0 -49
  46. package/templates/content_publisher/tsconfig.json +0 -56
  47. package/templates/content_publisher/webpack.config.ts +0 -247
  48. package/templates/dam/backend/routers/dam.ts +0 -108
  49. package/templates/dam/backend/server.ts +0 -65
  50. package/templates/dam/canva-app.json +0 -25
  51. package/templates/dam/declarations/declarations.d.ts +0 -29
  52. package/templates/dam/eslint.config.mjs +0 -14
  53. package/templates/dam/package.json +0 -97
  54. package/templates/dam/scripts/copy_env.ts +0 -13
  55. package/templates/dam/scripts/ssl/ssl.ts +0 -131
  56. package/templates/dam/scripts/start/app_runner.ts +0 -223
  57. package/templates/dam/scripts/start/context.ts +0 -171
  58. package/templates/dam/scripts/start/start.ts +0 -46
  59. package/templates/dam/src/index.tsx +0 -4
  60. package/templates/dam/src/intents/design_editor/adapter.ts +0 -44
  61. package/templates/dam/src/intents/design_editor/app.tsx +0 -35
  62. package/templates/dam/src/intents/design_editor/config.ts +0 -220
  63. package/templates/dam/src/intents/design_editor/index.css +0 -3
  64. package/templates/dam/src/intents/design_editor/index.tsx +0 -25
  65. package/templates/dam/tsconfig.json +0 -56
  66. package/templates/dam/utils/backend/base_backend/create.ts +0 -114
  67. package/templates/dam/webpack.config.ts +0 -247
  68. package/templates/data_connector/README.md +0 -84
  69. package/templates/data_connector/canva-app.json +0 -21
  70. package/templates/data_connector/declarations/declarations.d.ts +0 -29
  71. package/templates/data_connector/eslint.config.mjs +0 -14
  72. package/templates/data_connector/package.json +0 -92
  73. package/templates/data_connector/scripts/copy_env.ts +0 -13
  74. package/templates/data_connector/scripts/ssl/ssl.ts +0 -131
  75. package/templates/data_connector/scripts/start/app_runner.ts +0 -223
  76. package/templates/data_connector/scripts/start/context.ts +0 -171
  77. package/templates/data_connector/scripts/start/start.ts +0 -46
  78. package/templates/data_connector/src/api/connect_client.ts +0 -6
  79. package/templates/data_connector/src/api/data_source.ts +0 -97
  80. package/templates/data_connector/src/api/data_sources/designs.tsx +0 -296
  81. package/templates/data_connector/src/api/data_sources/index.ts +0 -4
  82. package/templates/data_connector/src/api/data_sources/templates.tsx +0 -328
  83. package/templates/data_connector/src/api/fetch_data_table.ts +0 -55
  84. package/templates/data_connector/src/api/index.ts +0 -4
  85. package/templates/data_connector/src/api/oauth.ts +0 -8
  86. package/templates/data_connector/src/api/tests/data_source.test.tsx +0 -99
  87. package/templates/data_connector/src/components/app_error.tsx +0 -15
  88. package/templates/data_connector/src/components/footer.tsx +0 -26
  89. package/templates/data_connector/src/components/header.tsx +0 -40
  90. package/templates/data_connector/src/components/index.ts +0 -3
  91. package/templates/data_connector/src/components/inputs/messages.tsx +0 -95
  92. package/templates/data_connector/src/components/inputs/search_filter.tsx +0 -109
  93. package/templates/data_connector/src/components/inputs/select_field.tsx +0 -26
  94. package/templates/data_connector/src/context/app_context.tsx +0 -125
  95. package/templates/data_connector/src/context/index.ts +0 -2
  96. package/templates/data_connector/src/context/use_app_context.ts +0 -17
  97. package/templates/data_connector/src/index.tsx +0 -4
  98. package/templates/data_connector/src/intents/data_connector/app.tsx +0 -20
  99. package/templates/data_connector/src/intents/data_connector/entrypoint.tsx +0 -70
  100. package/templates/data_connector/src/intents/data_connector/home.tsx +0 -21
  101. package/templates/data_connector/src/intents/data_connector/index.tsx +0 -56
  102. package/templates/data_connector/src/pages/data_source_config.tsx +0 -9
  103. package/templates/data_connector/src/pages/error.tsx +0 -37
  104. package/templates/data_connector/src/pages/index.ts +0 -4
  105. package/templates/data_connector/src/pages/login.tsx +0 -145
  106. package/templates/data_connector/src/pages/select_source.tsx +0 -24
  107. package/templates/data_connector/src/routes/index.ts +0 -2
  108. package/templates/data_connector/src/routes/paths.ts +0 -7
  109. package/templates/data_connector/src/routes/protected_route.tsx +0 -26
  110. package/templates/data_connector/src/routes/routes.tsx +0 -42
  111. package/templates/data_connector/src/utils/data_params.ts +0 -17
  112. package/templates/data_connector/src/utils/data_table.ts +0 -116
  113. package/templates/data_connector/src/utils/fetch_result.ts +0 -36
  114. package/templates/data_connector/src/utils/index.ts +0 -2
  115. package/templates/data_connector/src/utils/tests/data_table.test.ts +0 -133
  116. package/templates/data_connector/styles/components.css +0 -38
  117. package/templates/data_connector/tsconfig.json +0 -56
  118. package/templates/data_connector/webpack.config.ts +0 -247
  119. package/templates/gen_ai/README.md +0 -27
  120. package/templates/gen_ai/backend/routers/image.ts +0 -232
  121. package/templates/gen_ai/backend/server.ts +0 -65
  122. package/templates/gen_ai/canva-app.json +0 -25
  123. package/templates/gen_ai/declarations/declarations.d.ts +0 -29
  124. package/templates/gen_ai/eslint.config.mjs +0 -14
  125. package/templates/gen_ai/package.json +0 -101
  126. package/templates/gen_ai/scripts/copy_env.ts +0 -13
  127. package/templates/gen_ai/scripts/ssl/ssl.ts +0 -131
  128. package/templates/gen_ai/scripts/start/app_runner.ts +0 -223
  129. package/templates/gen_ai/scripts/start/context.ts +0 -171
  130. package/templates/gen_ai/scripts/start/start.ts +0 -46
  131. package/templates/gen_ai/src/api/api.ts +0 -194
  132. package/templates/gen_ai/src/api/index.ts +0 -1
  133. package/templates/gen_ai/src/components/app_error.tsx +0 -18
  134. package/templates/gen_ai/src/components/footer.messages.ts +0 -48
  135. package/templates/gen_ai/src/components/footer.tsx +0 -156
  136. package/templates/gen_ai/src/components/image_grid.tsx +0 -103
  137. package/templates/gen_ai/src/components/index.ts +0 -7
  138. package/templates/gen_ai/src/components/loading_results.tsx +0 -169
  139. package/templates/gen_ai/src/components/prompt_input.messages.ts +0 -14
  140. package/templates/gen_ai/src/components/prompt_input.tsx +0 -154
  141. package/templates/gen_ai/src/components/remaining_credits.tsx +0 -84
  142. package/templates/gen_ai/src/components/report_box.tsx +0 -54
  143. package/templates/gen_ai/src/components/tests/remaining_credit.tests.tsx +0 -47
  144. package/templates/gen_ai/src/config.ts +0 -21
  145. package/templates/gen_ai/src/context/app_context.tsx +0 -153
  146. package/templates/gen_ai/src/context/context.messages.ts +0 -30
  147. package/templates/gen_ai/src/context/index.ts +0 -2
  148. package/templates/gen_ai/src/context/use_app_context.ts +0 -17
  149. package/templates/gen_ai/src/index.tsx +0 -4
  150. package/templates/gen_ai/src/intents/design_editor/app.tsx +0 -19
  151. package/templates/gen_ai/src/intents/design_editor/home.tsx +0 -13
  152. package/templates/gen_ai/src/intents/design_editor/index.tsx +0 -17
  153. package/templates/gen_ai/src/pages/error.tsx +0 -41
  154. package/templates/gen_ai/src/pages/generate.tsx +0 -9
  155. package/templates/gen_ai/src/pages/index.ts +0 -3
  156. package/templates/gen_ai/src/pages/results.tsx +0 -31
  157. package/templates/gen_ai/src/routes/index.ts +0 -1
  158. package/templates/gen_ai/src/routes/paths.ts +0 -4
  159. package/templates/gen_ai/src/routes/routes.tsx +0 -24
  160. package/templates/gen_ai/src/utils/index.ts +0 -1
  161. package/templates/gen_ai/src/utils/obscenity_filter.ts +0 -33
  162. package/templates/gen_ai/styles/components.css +0 -38
  163. package/templates/gen_ai/styles/utils.css +0 -3
  164. package/templates/gen_ai/tsconfig.json +0 -56
  165. package/templates/gen_ai/utils/backend/base_backend/create.ts +0 -114
  166. package/templates/gen_ai/webpack.config.ts +0 -247
  167. package/templates/hello_world/canva-app.json +0 -21
  168. package/templates/hello_world/declarations/declarations.d.ts +0 -29
  169. package/templates/hello_world/eslint.config.mjs +0 -14
  170. package/templates/hello_world/package.json +0 -90
  171. package/templates/hello_world/scripts/copy_env.ts +0 -13
  172. package/templates/hello_world/scripts/ssl/ssl.ts +0 -131
  173. package/templates/hello_world/scripts/start/app_runner.ts +0 -223
  174. package/templates/hello_world/scripts/start/context.ts +0 -171
  175. package/templates/hello_world/scripts/start/start.ts +0 -46
  176. package/templates/hello_world/src/index.tsx +0 -4
  177. package/templates/hello_world/src/intents/design_editor/app.tsx +0 -86
  178. package/templates/hello_world/src/intents/design_editor/index.tsx +0 -25
  179. package/templates/hello_world/src/intents/design_editor/tests/__snapshots__/app.tests.tsx.snap +0 -45
  180. package/templates/hello_world/src/intents/design_editor/tests/app.tests.tsx +0 -92
  181. package/templates/hello_world/styles/components.css +0 -38
  182. package/templates/hello_world/tsconfig.json +0 -56
  183. package/templates/hello_world/webpack.config.ts +0 -247
  184. package/templates/mls/README.md +0 -81
  185. package/templates/mls/canva-app.json +0 -25
  186. package/templates/mls/declarations/declarations.d.ts +0 -29
  187. package/templates/mls/eslint.config.mjs +0 -14
  188. package/templates/mls/jest.config.mjs +0 -36
  189. package/templates/mls/jest.setup.ts +0 -39
  190. package/templates/mls/package.json +0 -117
  191. package/templates/mls/scripts/copy_env.ts +0 -13
  192. package/templates/mls/scripts/ssl/ssl.ts +0 -131
  193. package/templates/mls/scripts/start/app_runner.ts +0 -223
  194. package/templates/mls/scripts/start/context.ts +0 -171
  195. package/templates/mls/scripts/start/start.ts +0 -46
  196. package/templates/mls/src/__tests__/app.tests.tsx +0 -11
  197. package/templates/mls/src/__tests__/office_selection_page.tests.tsx +0 -72
  198. package/templates/mls/src/__tests__/utils.tsx +0 -19
  199. package/templates/mls/src/adapter.ts +0 -126
  200. package/templates/mls/src/components/agent/agent_card.tsx +0 -57
  201. package/templates/mls/src/components/agent/agent_grid.tsx +0 -37
  202. package/templates/mls/src/components/agent/agent_list.tsx +0 -17
  203. package/templates/mls/src/components/agent/agent_search_filters.tsx +0 -88
  204. package/templates/mls/src/components/breadcrumb/breadcrumb.tsx +0 -40
  205. package/templates/mls/src/components/listing/listing_card.tsx +0 -64
  206. package/templates/mls/src/components/listing/listing_grid.tsx +0 -37
  207. package/templates/mls/src/components/listing/listing_list.tsx +0 -21
  208. package/templates/mls/src/components/listing/listing_search_filters.tsx +0 -145
  209. package/templates/mls/src/components/placeholders/placeholders.tsx +0 -65
  210. package/templates/mls/src/data.ts +0 -359
  211. package/templates/mls/src/index.tsx +0 -4
  212. package/templates/mls/src/intents/design_editor/app.tsx +0 -44
  213. package/templates/mls/src/intents/design_editor/index.tsx +0 -25
  214. package/templates/mls/src/pages/agent_details_page/agent_details_page.tsx +0 -175
  215. package/templates/mls/src/pages/list_page/agent_tab_panel.tsx +0 -126
  216. package/templates/mls/src/pages/list_page/list_page.tsx +0 -67
  217. package/templates/mls/src/pages/list_page/listing_tab_panel.tsx +0 -135
  218. package/templates/mls/src/pages/listing_details_page/listing_details_page.tsx +0 -418
  219. package/templates/mls/src/pages/loading_page/loading_page.tsx +0 -152
  220. package/templates/mls/src/pages/office_selection_page/office_selection_page.tsx +0 -144
  221. package/templates/mls/src/real_estate.type.ts +0 -44
  222. package/templates/mls/src/util/use_add_element.tsx +0 -62
  223. package/templates/mls/src/util/use_drag_element.tsx +0 -68
  224. package/templates/mls/styles/components.css +0 -38
  225. package/templates/mls/tsconfig.json +0 -54
  226. package/templates/mls/webpack.config.ts +0 -248
  227. package/templates/optional/.cursor/mcp.json +0 -8
  228. package/templates/optional/.vscode/extensions.json +0 -6
  229. package/templates/optional/.vscode/mcp.json +0 -9
  230. package/templates/optional/AGENTS.md +0 -154
  231. package/templates/optional/CLAUDE.md +0 -154
@@ -1,144 +0,0 @@
1
- import {
2
- Avatar,
3
- Box,
4
- Button,
5
- FormField,
6
- Rows,
7
- Select,
8
- Text,
9
- } from "@canva/app-ui-kit";
10
- import React from "react";
11
- import { useForm } from "react-hook-form";
12
- import { useIntl } from "react-intl";
13
- import { useNavigate } from "react-router-dom";
14
- import { mockUserData, offices } from "../../data";
15
-
16
- type FormValues = {
17
- office: string;
18
- agent: string;
19
- };
20
-
21
- export const OfficeSelectionPage = () => {
22
- const navigate = useNavigate();
23
- const intl = useIntl();
24
- const {
25
- handleSubmit,
26
- setValue,
27
- watch,
28
- formState: { touchedFields, isSubmitted },
29
- } = useForm<FormValues>({
30
- mode: "onSubmit",
31
- defaultValues: {
32
- office: "",
33
- },
34
- criteriaMode: "all",
35
- });
36
-
37
- const selectedOffice = watch("office");
38
-
39
- const onSubmit = (data: FormValues) => {
40
- const office = offices.find((o) => o.id === data.office);
41
- if (office) {
42
- navigate(`/loading`, { state: { office } });
43
- }
44
- };
45
-
46
- return (
47
- <Box paddingY="2u" height="full">
48
- <Box
49
- height="full"
50
- display="flex"
51
- flexDirection="column"
52
- justifyContent="spaceBetween"
53
- >
54
- <form onSubmit={handleSubmit(onSubmit)}>
55
- <Rows spacing="2u">
56
- <FormField
57
- label={intl.formatMessage({
58
- defaultMessage: "Office",
59
- description: "Label for office selection dropdown",
60
- })}
61
- error={
62
- touchedFields.office &&
63
- !selectedOffice &&
64
- intl.formatMessage({
65
- defaultMessage: "Please select an office",
66
- description: "Error message when office is not selected",
67
- })
68
- }
69
- control={(props) => (
70
- <Select
71
- {...props}
72
- stretch
73
- options={offices.map((office) => ({
74
- label: office.name,
75
- value: office.id,
76
- }))}
77
- placeholder={intl.formatMessage({
78
- defaultMessage: "Select office",
79
- description: "Placeholder text for office selection",
80
- })}
81
- onChange={(value) => {
82
- setValue("office", value, {
83
- shouldValidate: true,
84
- });
85
- }}
86
- value={selectedOffice}
87
- />
88
- )}
89
- />
90
- <Rows spacing="0.5u">
91
- <Button
92
- variant="primary"
93
- stretch
94
- type="submit"
95
- disabled={isSubmitted && !selectedOffice}
96
- >
97
- {intl.formatMessage({
98
- defaultMessage: "Continue",
99
- description: "Button text to proceed with selection",
100
- })}
101
- </Button>
102
- {isSubmitted && !selectedOffice && (
103
- <Text variant="regular" tone="critical">
104
- {intl.formatMessage({
105
- defaultMessage: "Please select an office and agent",
106
- description:
107
- "Text to prompt user to select office and agent",
108
- })}
109
- </Text>
110
- )}
111
- </Rows>
112
- </Rows>
113
- </form>
114
-
115
- <Box paddingTop="4u">
116
- <Rows spacing="1u">
117
- <Text variant="bold">
118
- {intl.formatMessage({
119
- defaultMessage: "Account",
120
- description: "Section header for account information",
121
- })}
122
- </Text>
123
- <Rows spacing="1u" align="start">
124
- <Box display="flex" alignItems="start">
125
- <Box paddingEnd="1u">
126
- <Avatar
127
- photo={mockUserData.userAvatarUrl}
128
- name={mockUserData.userName || ""}
129
- />
130
- </Box>
131
- <Rows spacing="0">
132
- <Text>{mockUserData.userName}</Text>
133
- <Text variant="regular" tone="secondary">
134
- {mockUserData.userEmail}
135
- </Text>
136
- </Rows>
137
- </Box>
138
- </Rows>
139
- </Rows>
140
- </Box>
141
- </Box>
142
- </Box>
143
- );
144
- };
@@ -1,44 +0,0 @@
1
- export interface Property {
2
- id: string;
3
- thumbnail: {
4
- url: string;
5
- width: number;
6
- height: number;
7
- };
8
- url: string;
9
- title: string;
10
- name: string;
11
- description: string;
12
- address: string;
13
- price: string;
14
- suburb: string;
15
- listingType: string;
16
- listing_images?: {
17
- url: string;
18
- alt: string;
19
- width: number;
20
- height: number;
21
- }[];
22
- agent?: Agent;
23
- }
24
-
25
- export interface Agent {
26
- id: string;
27
- name: string;
28
- officeId?: string;
29
- phoneNumber?: string;
30
- roleTitle?: string;
31
- headshots?: {
32
- url: string;
33
- width: number;
34
- height: number;
35
- }[];
36
- }
37
-
38
- export interface Office {
39
- id: string;
40
- name: string;
41
- address?: string;
42
- phoneNumber?: string;
43
- email?: string;
44
- }
@@ -1,62 +0,0 @@
1
- import { useFeatureSupport } from "@canva/app-hooks";
2
- import { type ImageMimeType, upload } from "@canva/asset";
3
- import { addElementAtCursor, addElementAtPoint } from "@canva/design";
4
- import type { ImageElement, TextElement } from "@canva/design";
5
-
6
- const getMimeTypeFromUrl = (url: string): ImageMimeType => {
7
- const extension = url.split(".").pop()?.toLowerCase();
8
- switch (extension) {
9
- case "jpg":
10
- case "jpeg":
11
- return "image/jpeg";
12
- case "png":
13
- return "image/png";
14
- case "tiff":
15
- return "image/tiff";
16
- default:
17
- return "image/jpeg"; // fallback to jpeg
18
- }
19
- };
20
-
21
- export const useAddElement = () => {
22
- const isSupported = useFeatureSupport();
23
- const addElement = [addElementAtPoint, addElementAtCursor].find((fn) =>
24
- isSupported(fn),
25
- );
26
-
27
- const addText = (text?: string) => {
28
- const textElement: TextElement = {
29
- type: "text",
30
- children: [text || ""],
31
- };
32
-
33
- addElement?.(textElement);
34
- };
35
-
36
- const addImage = async (imageUrl: string, altText: string) => {
37
- const mimeType = getMimeTypeFromUrl(imageUrl);
38
- const image = await upload({
39
- mimeType,
40
- thumbnailUrl: imageUrl,
41
- type: "image",
42
- url: imageUrl,
43
- aiDisclosure: "none",
44
- });
45
-
46
- const imageElement: ImageElement = {
47
- type: "image",
48
- altText: {
49
- text: altText,
50
- decorative: true,
51
- },
52
- ref: image.ref,
53
- };
54
-
55
- addElement?.(imageElement);
56
- };
57
-
58
- return {
59
- addText,
60
- addImage,
61
- };
62
- };
@@ -1,68 +0,0 @@
1
- import { useFeatureSupport } from "@canva/app-hooks";
2
- import { type ImageMimeType, upload } from "@canva/asset";
3
- import { ui } from "@canva/design";
4
- import type { DragStartEvent } from "@canva/design";
5
- import type { DragEvent } from "react";
6
-
7
- const getMimeTypeFromUrl = (url: string): ImageMimeType => {
8
- const extension = url.split(".").pop()?.toLowerCase();
9
- switch (extension) {
10
- case "jpg":
11
- case "jpeg":
12
- return "image/jpeg";
13
- case "png":
14
- return "image/png";
15
- case "tiff":
16
- return "image/tiff";
17
- default:
18
- return "image/jpeg"; // fallback to jpeg
19
- }
20
- };
21
-
22
- export const useDragElement = () => {
23
- const isSupported = useFeatureSupport();
24
- const startDrag = [ui.startDragToPoint].find((fn) => isSupported(fn));
25
-
26
- const dragText = (event: DragEvent<Element>, text: string) => {
27
- startDrag?.(event as unknown as DragStartEvent<HTMLElement>, {
28
- type: "text",
29
- children: [text],
30
- });
31
- };
32
-
33
- const dragImage = (
34
- event: DragStartEvent<Element>,
35
- imageUrl: string,
36
- altText: string,
37
- width: number,
38
- height: number,
39
- ) => {
40
- const mimeType = getMimeTypeFromUrl(imageUrl);
41
- startDrag?.(event as unknown as DragStartEvent<HTMLElement>, {
42
- type: "image",
43
- resolveImageRef: () => {
44
- return upload({
45
- mimeType,
46
- thumbnailUrl: imageUrl,
47
- type: "image",
48
- url: imageUrl,
49
- aiDisclosure: "none",
50
- });
51
- },
52
- previewUrl: imageUrl,
53
- previewSize: {
54
- width,
55
- height,
56
- },
57
- fullSize: {
58
- width,
59
- height,
60
- },
61
- });
62
- };
63
-
64
- return {
65
- dragText,
66
- dragImage,
67
- };
68
- };
@@ -1,38 +0,0 @@
1
- /* Scroll container */
2
- .scrollContainer {
3
- box-sizing: border-box;
4
- overflow-y: scroll;
5
- height: 100%;
6
- padding-top: var(--ui-kit-space-200);
7
- padding-right: var(--ui-kit-space-200);
8
- padding-bottom: var(--ui-kit-space-200);
9
-
10
- /* for firefox */
11
- scrollbar-width: thin;
12
- scrollbar-color: var(--ui-kit-color-content-placeholder-fg) transparent;
13
- }
14
-
15
- .scrollContainer::-webkit-scrollbar {
16
- position: absolute;
17
- width: var(--ui-kit-base-unit);
18
- height: 0;
19
- }
20
-
21
- .scrollContainer::-webkit-scrollbar-track {
22
- background: transparent;
23
- width: var(--ui-kit-base-unit);
24
- margin-top: var(--ui-kit-space-100);
25
- margin-bottom: var(--ui-kit-space-100);
26
- }
27
-
28
- .scrollContainer::-webkit-scrollbar-thumb {
29
- border-radius: var(--ui-kit-radius-element-standard);
30
- background: var(--ui-kit-color-content-placeholder-fg);
31
- visibility: hidden;
32
- }
33
-
34
- .scrollContainer:hover::-webkit-scrollbar-thumb,
35
- .scrollContainer:focus::-webkit-scrollbar-thumb,
36
- .scrollContainer:focus-within::-webkit-scrollbar-thumb {
37
- visibility: visible;
38
- }
@@ -1,54 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "lib": [
5
- "dom",
6
- "dom.iterable",
7
- "es2018",
8
- "es2019.array",
9
- "es2019.object",
10
- "es2019.string",
11
- "es2020.promise",
12
- "es2020.string"
13
- ],
14
- "types": ["node", "webpack-env", "jest", "@testing-library/jest-dom"],
15
- "composite": false,
16
- "declaration": false,
17
- "declarationMap": false,
18
- "experimentalDecorators": true,
19
- "importHelpers": true,
20
- "noImplicitOverride": true,
21
- "moduleResolution": "node",
22
- "rootDir": ".",
23
- "outDir": "dist",
24
- "strict": true,
25
- "skipLibCheck": true,
26
- "target": "ES2019",
27
- "sourceMap": true,
28
- "inlineSources": true,
29
- "module": "ESNext",
30
- "noImplicitAny": false,
31
- "removeComments": true,
32
- "preserveConstEnums": true,
33
- "allowSyntheticDefaultImports": true,
34
- "esModuleInterop": true,
35
- "baseUrl": "./",
36
- "paths": {
37
- "styles": ["./styles"]
38
- }
39
- },
40
- "include": [
41
- "./src/**/*",
42
- "./backend/**/*",
43
- "./utils/**/*",
44
- "./scripts/**/*",
45
- "./declarations/declarations.d.ts",
46
- "./styles/**/*",
47
- "./node_modules/@types/**/*"
48
- ],
49
- "ts-node": {
50
- "compilerOptions": {
51
- "module": "commonjs"
52
- }
53
- }
54
- }
@@ -1,248 +0,0 @@
1
- import type { Configuration } from "webpack";
2
- import { DefinePlugin, optimize } from "webpack";
3
- import * as path from "path";
4
- import TerserPlugin from "terser-webpack-plugin";
5
- import { transform } from "@formatjs/ts-transformer";
6
- import chalk from "chalk";
7
- import { config } from "dotenv";
8
- import { Configuration as DevServerConfiguration } from "webpack-dev-server";
9
-
10
- config();
11
-
12
- type DevConfig = {
13
- port: number;
14
- enableHmr: boolean;
15
- enableHttps: boolean;
16
- appOrigin?: string;
17
- appId?: string; // Deprecated in favour of appOrigin
18
- certFile?: string;
19
- keyFile?: string;
20
- };
21
-
22
- export function buildConfig({
23
- devConfig,
24
- appEntry = path.join(process.cwd(), "src", "index.tsx"),
25
- backendHost = process.env.CANVA_BACKEND_HOST,
26
- // For IN_HARNESS, refer to the following docs for more information: https://www.canva.dev/docs/apps/test-harness/
27
- inHarness = process.env.IN_HARNESS?.toLowerCase() === "true",
28
- }: {
29
- devConfig?: DevConfig;
30
- appEntry?: string;
31
- backendHost?: string;
32
- inHarness?: boolean;
33
- } = {}): Configuration & DevServerConfiguration {
34
- const mode = devConfig ? "development" : "production";
35
-
36
- if (!backendHost) {
37
- console.error(
38
- chalk.redBright.bold("BACKEND_HOST is undefined."),
39
- `Refer to "Customizing the backend host" in the README.md for more information.`,
40
- );
41
- process.exit(-1);
42
- } else if (backendHost.includes("localhost") && mode === "production") {
43
- console.error(
44
- chalk.redBright.bold(
45
- "BACKEND_HOST should not be set to localhost for production builds!",
46
- ),
47
- `Refer to "Customizing the backend host" in the README.md for more information.`,
48
- );
49
- }
50
-
51
- return {
52
- mode,
53
- context: path.resolve(process.cwd(), "./"),
54
- entry: inHarness
55
- ? {
56
- harness: path.join(process.cwd(), "harness", "harness.tsx"),
57
- init: path.join(process.cwd(), "harness", "init.ts"),
58
- }
59
- : {
60
- app: appEntry,
61
- },
62
- target: "web",
63
- resolve: {
64
- alias: {
65
- styles: path.resolve(process.cwd(), "styles"),
66
- src: path.resolve(process.cwd(), "src"),
67
- },
68
- extensions: [".ts", ".tsx", ".js", ".css", ".svg", ".woff", ".woff2"],
69
- },
70
- infrastructureLogging: {
71
- level: inHarness ? "info" : "none",
72
- },
73
- module: {
74
- rules: [
75
- {
76
- test: /\.tsx?$/,
77
- exclude: /node_modules/,
78
- use: [
79
- {
80
- loader: "ts-loader",
81
- options: {
82
- transpileOnly: true,
83
- getCustomTransformers() {
84
- return {
85
- before: [
86
- transform({
87
- overrideIdFn: "[sha512:contenthash:base64:6]",
88
- }),
89
- ],
90
- };
91
- },
92
- },
93
- },
94
- ],
95
- },
96
- {
97
- test: /\.css$/,
98
- exclude: /node_modules/,
99
- use: [
100
- "style-loader",
101
- {
102
- loader: "css-loader",
103
- options: {
104
- modules: true,
105
- },
106
- },
107
- {
108
- loader: "postcss-loader",
109
- options: {
110
- postcssOptions: {
111
- plugins: [require("cssnano")({ preset: "default" })],
112
- },
113
- },
114
- },
115
- ],
116
- },
117
- {
118
- test: /\.(png|jpg|jpeg)$/i,
119
- type: "asset/inline",
120
- },
121
- {
122
- test: /\.(woff|woff2)$/,
123
- type: "asset/inline",
124
- },
125
- {
126
- test: /\.svg$/,
127
- oneOf: [
128
- {
129
- issuer: /\.[jt]sx?$/,
130
- resourceQuery: /react/, // *.svg?react
131
- use: ["@svgr/webpack", "url-loader"],
132
- },
133
- {
134
- type: "asset/resource",
135
- parser: {
136
- dataUrlCondition: {
137
- maxSize: 200,
138
- },
139
- },
140
- },
141
- ],
142
- },
143
- {
144
- test: /\.css$/,
145
- include: /node_modules/,
146
- use: [
147
- "style-loader",
148
- "css-loader",
149
- {
150
- loader: "postcss-loader",
151
- options: {
152
- postcssOptions: {
153
- plugins: [require("cssnano")({ preset: "default" })],
154
- },
155
- },
156
- },
157
- ],
158
- },
159
- ],
160
- },
161
- optimization: {
162
- minimizer: [
163
- new TerserPlugin({
164
- terserOptions: {
165
- format: {
166
- // Turned on because emoji and regex is not minified properly using default
167
- // https://github.com/facebook/create-react-app/issues/2488
168
- ascii_only: true,
169
- },
170
- },
171
- }),
172
- ],
173
- },
174
- output: {
175
- filename: `[name].js`,
176
- path: path.resolve(process.cwd(), "dist"),
177
- clean: true,
178
- },
179
- plugins: [
180
- new DefinePlugin({
181
- BACKEND_HOST: JSON.stringify(backendHost),
182
- }),
183
- // Apps can only submit a single JS file via the Developer Portal
184
- new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
185
- ].filter(Boolean),
186
- ...buildDevConfig(devConfig),
187
- };
188
- }
189
-
190
- function buildDevConfig(options?: DevConfig): {
191
- devtool?: string;
192
- devServer?: DevServerConfiguration;
193
- } {
194
- if (!options) {
195
- return {};
196
- }
197
-
198
- const { port, enableHmr, appOrigin, appId, enableHttps, certFile, keyFile } =
199
- options;
200
- const host = "localhost";
201
-
202
- let devServer: DevServerConfiguration = {
203
- server: enableHttps
204
- ? {
205
- type: "https",
206
- options: {
207
- cert: certFile,
208
- key: keyFile,
209
- },
210
- }
211
- : "http",
212
- host,
213
- allowedHosts: [host],
214
- historyApiFallback: {
215
- rewrites: [{ from: /^\/$/, to: "/app.js" }],
216
- },
217
- port,
218
- client: {
219
- logging: "verbose",
220
- },
221
- };
222
-
223
- if (enableHmr && appOrigin) {
224
- devServer = {
225
- ...devServer,
226
- allowedHosts: [host, new URL(appOrigin).hostname],
227
- headers: {
228
- "Access-Control-Allow-Origin": appOrigin,
229
- "Access-Control-Allow-Credentials": "true",
230
- "Access-Control-Allow-Private-Network": "true",
231
- },
232
- };
233
- } else {
234
- if (enableHmr && !appOrigin) {
235
- console.warn(
236
- "Attempted to enable Hot Module Replacement (HMR) without configuring App Origin... Disabling HMR.",
237
- );
238
- }
239
- devServer.webSocketServer = false;
240
- }
241
-
242
- return {
243
- devtool: "source-map",
244
- devServer,
245
- };
246
- }
247
-
248
- export default buildConfig;
@@ -1,8 +0,0 @@
1
- {
2
- "mcpServers": {
3
- "canva": {
4
- "command": "npx",
5
- "args": ["-y", "@canva/cli@latest", "mcp"]
6
- }
7
- }
8
- }
@@ -1,6 +0,0 @@
1
- {
2
- // For developers using vscode we recommend the following extensions. Following
3
- // and listening to the formatting and linting guidelines can help with
4
- // implementation quality and in some instances reduce app review timelines.
5
- "recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
6
- }
@@ -1,9 +0,0 @@
1
- {
2
- "servers": {
3
- "canva": {
4
- "type": "stdio",
5
- "command": "npx",
6
- "args": ["-y", "@canva/cli@latest", "mcp"]
7
- }
8
- }
9
- }