dn-react-router-toolkit 0.2.6 → 0.3.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.
Files changed (278) hide show
  1. package/dist/api/create_handler.d.mts +13 -0
  2. package/dist/api/create_handler.d.ts +13 -0
  3. package/dist/api/create_handler.js +276 -0
  4. package/dist/api/create_handler.mjs +282 -0
  5. package/dist/api/index.d.mts +4 -0
  6. package/dist/api/index.d.ts +4 -0
  7. package/dist/api/index.js +276 -0
  8. package/dist/api/index.mjs +282 -0
  9. package/dist/auth/client/index.d.mts +3 -0
  10. package/dist/auth/client/index.d.ts +3 -0
  11. package/dist/{date.js → auth/client/index.js} +25 -32
  12. package/dist/auth/client/index.mjs +21 -0
  13. package/dist/auth/client/redirect_page.d.mts +1 -0
  14. package/dist/auth/client/redirect_page.d.ts +1 -0
  15. package/dist/auth/index.d.mts +4 -0
  16. package/dist/auth/index.d.ts +4 -0
  17. package/dist/auth/index.js +116 -0
  18. package/dist/auth/index.mjs +89 -0
  19. package/dist/auth/server/index.d.mts +1 -0
  20. package/dist/auth/server/index.d.ts +1 -0
  21. package/dist/{slug.js → auth/server/index.js} +6 -14
  22. package/dist/auth/server/index.mjs +2 -0
  23. package/dist/auth/with_auth.d.mts +2 -6
  24. package/dist/auth/with_auth.d.ts +2 -6
  25. package/dist/auth/with_auth.js +3 -0
  26. package/dist/auth/with_auth.mjs +3 -0
  27. package/dist/{components → client}/client_env.d.mts +1 -1
  28. package/dist/{components → client}/client_env.d.ts +1 -1
  29. package/dist/{components → client}/client_env.js +6 -2
  30. package/dist/{components → client}/client_env.mjs +2 -2
  31. package/dist/client/index.d.mts +3 -0
  32. package/dist/client/index.d.ts +3 -0
  33. package/dist/{auth/client/google_login_button.js → client/index.js} +30 -33
  34. package/dist/client/index.mjs +31 -0
  35. package/dist/client/use_user_agent.d.mts +8 -0
  36. package/dist/client/use_user_agent.d.ts +8 -0
  37. package/dist/{file/client/format_size.js → client/use_user_agent.js} +14 -14
  38. package/dist/client/use_user_agent.mjs +13 -0
  39. package/dist/file/client/index.d.mts +1 -0
  40. package/dist/file/client/index.d.ts +1 -0
  41. package/dist/file/{cdn.js → client/index.js} +6 -16
  42. package/dist/file/client/index.mjs +2 -0
  43. package/dist/file/index.d.mts +1 -0
  44. package/dist/file/index.d.ts +1 -0
  45. package/dist/{cn.js → file/index.js} +6 -14
  46. package/dist/file/index.mjs +2 -0
  47. package/dist/file/server/index.d.mts +1 -0
  48. package/dist/file/server/index.d.ts +1 -0
  49. package/dist/file/server/index.js +24 -0
  50. package/dist/file/server/index.mjs +2 -0
  51. package/dist/http/index.d.mts +1 -1
  52. package/dist/http/index.d.ts +1 -1
  53. package/dist/http/index.js +3 -90
  54. package/dist/http/index.mjs +2 -68
  55. package/dist/index.d.mts +8 -6
  56. package/dist/index.d.ts +8 -6
  57. package/dist/index.js +3 -79
  58. package/dist/index.mjs +2 -58
  59. package/dist/modal/index.d.mts +1 -0
  60. package/dist/modal/index.d.ts +1 -0
  61. package/dist/{sleep.js → modal/index.js} +6 -14
  62. package/dist/modal/index.mjs +2 -0
  63. package/dist/seo/index.d.mts +4 -0
  64. package/dist/seo/index.d.ts +4 -0
  65. package/dist/seo/index.js +304 -0
  66. package/dist/seo/index.mjs +267 -0
  67. package/dist/seo/seo.js +9 -1
  68. package/dist/seo/seo.mjs +9 -1
  69. package/dist/text_editor/index.d.mts +1 -0
  70. package/dist/text_editor/index.d.ts +1 -0
  71. package/dist/text_editor/index.js +24 -0
  72. package/dist/text_editor/index.mjs +2 -0
  73. package/package.json +58 -32
  74. package/dist/auth/apple_auth.d.mts +0 -38
  75. package/dist/auth/apple_auth.d.ts +0 -38
  76. package/dist/auth/apple_auth.js +0 -88
  77. package/dist/auth/apple_auth.mjs +0 -63
  78. package/dist/auth/auth_repository.d.mts +0 -41
  79. package/dist/auth/auth_repository.d.ts +0 -41
  80. package/dist/auth/auth_repository.js +0 -18
  81. package/dist/auth/auth_repository.mjs +0 -0
  82. package/dist/auth/auth_service.d.mts +0 -63
  83. package/dist/auth/auth_service.d.ts +0 -63
  84. package/dist/auth/auth_service.js +0 -210
  85. package/dist/auth/auth_service.mjs +0 -171
  86. package/dist/auth/client/google_login_button.d.mts +0 -7
  87. package/dist/auth/client/google_login_button.d.ts +0 -7
  88. package/dist/auth/client/google_login_button.mjs +0 -37
  89. package/dist/auth/client/provider.d.mts +0 -24
  90. package/dist/auth/client/provider.d.ts +0 -24
  91. package/dist/auth/client/provider.js +0 -154
  92. package/dist/auth/client/provider.mjs +0 -118
  93. package/dist/auth/google_auth.d.mts +0 -33
  94. package/dist/auth/google_auth.d.ts +0 -33
  95. package/dist/auth/google_auth.js +0 -135
  96. package/dist/auth/google_auth.mjs +0 -108
  97. package/dist/auth/handlers/find_auth.d.mts +0 -13
  98. package/dist/auth/handlers/find_auth.d.ts +0 -13
  99. package/dist/auth/handlers/find_auth.js +0 -82
  100. package/dist/auth/handlers/find_auth.mjs +0 -55
  101. package/dist/auth/handlers/login.d.mts +0 -13
  102. package/dist/auth/handlers/login.d.ts +0 -13
  103. package/dist/auth/handlers/login.js +0 -107
  104. package/dist/auth/handlers/login.mjs +0 -80
  105. package/dist/auth/handlers/login_with_thirdparty.d.mts +0 -15
  106. package/dist/auth/handlers/login_with_thirdparty.d.ts +0 -15
  107. package/dist/auth/handlers/login_with_thirdparty.js +0 -98
  108. package/dist/auth/handlers/login_with_thirdparty.mjs +0 -71
  109. package/dist/auth/handlers/logout.d.mts +0 -13
  110. package/dist/auth/handlers/logout.d.ts +0 -13
  111. package/dist/auth/handlers/logout.js +0 -102
  112. package/dist/auth/handlers/logout.mjs +0 -75
  113. package/dist/auth/handlers/refresh.d.mts +0 -13
  114. package/dist/auth/handlers/refresh.d.ts +0 -13
  115. package/dist/auth/handlers/refresh.js +0 -92
  116. package/dist/auth/handlers/refresh.mjs +0 -65
  117. package/dist/auth/handlers/request_password_reset.d.mts +0 -10
  118. package/dist/auth/handlers/request_password_reset.d.ts +0 -10
  119. package/dist/auth/handlers/request_password_reset.js +0 -87
  120. package/dist/auth/handlers/request_password_reset.mjs +0 -60
  121. package/dist/auth/handlers/reset_password.d.mts +0 -10
  122. package/dist/auth/handlers/reset_password.d.ts +0 -10
  123. package/dist/auth/handlers/reset_password.js +0 -88
  124. package/dist/auth/handlers/reset_password.mjs +0 -61
  125. package/dist/auth/handlers/signup.d.mts +0 -15
  126. package/dist/auth/handlers/signup.d.ts +0 -15
  127. package/dist/auth/handlers/signup.js +0 -147
  128. package/dist/auth/handlers/signup.mjs +0 -112
  129. package/dist/auth/handlers/signup_with_thirdparty.d.mts +0 -17
  130. package/dist/auth/handlers/signup_with_thirdparty.d.ts +0 -17
  131. package/dist/auth/handlers/signup_with_thirdparty.js +0 -123
  132. package/dist/auth/handlers/signup_with_thirdparty.mjs +0 -98
  133. package/dist/auth/handlers/thirdparty_auth_callback.d.mts +0 -16
  134. package/dist/auth/handlers/thirdparty_auth_callback.d.ts +0 -16
  135. package/dist/auth/handlers/thirdparty_auth_callback.js +0 -129
  136. package/dist/auth/handlers/thirdparty_auth_callback.mjs +0 -102
  137. package/dist/auth/jwt_manager.d.mts +0 -38
  138. package/dist/auth/jwt_manager.d.ts +0 -38
  139. package/dist/auth/jwt_manager.js +0 -90
  140. package/dist/auth/jwt_manager.mjs +0 -65
  141. package/dist/auth/kakao_auth.d.mts +0 -27
  142. package/dist/auth/kakao_auth.d.ts +0 -27
  143. package/dist/auth/kakao_auth.js +0 -56
  144. package/dist/auth/kakao_auth.mjs +0 -31
  145. package/dist/auth/password_recovery.d.mts +0 -34
  146. package/dist/auth/password_recovery.d.ts +0 -34
  147. package/dist/auth/password_recovery.js +0 -169
  148. package/dist/auth/password_recovery.mjs +0 -134
  149. package/dist/auth/thirdparty_auth.d.mts +0 -41
  150. package/dist/auth/thirdparty_auth.d.ts +0 -41
  151. package/dist/auth/thirdparty_auth.js +0 -113
  152. package/dist/auth/thirdparty_auth.mjs +0 -86
  153. package/dist/cn.d.mts +0 -3
  154. package/dist/cn.d.ts +0 -3
  155. package/dist/cn.mjs +0 -7
  156. package/dist/components/index.d.mts +0 -5
  157. package/dist/components/index.d.ts +0 -5
  158. package/dist/components/index.js +0 -261
  159. package/dist/components/index.mjs +0 -219
  160. package/dist/components/modal/fullscreen_container.d.mts +0 -7
  161. package/dist/components/modal/fullscreen_container.d.ts +0 -7
  162. package/dist/components/modal/fullscreen_container.js +0 -102
  163. package/dist/components/modal/fullscreen_container.mjs +0 -68
  164. package/dist/components/modal/hooks.d.mts +0 -18
  165. package/dist/components/modal/hooks.d.ts +0 -18
  166. package/dist/components/modal/hooks.js +0 -236
  167. package/dist/components/modal/hooks.mjs +0 -204
  168. package/dist/components/modal/index.d.mts +0 -4
  169. package/dist/components/modal/index.d.ts +0 -4
  170. package/dist/components/modal/index.js +0 -238
  171. package/dist/components/modal/index.mjs +0 -203
  172. package/dist/components/modal/modal.d.mts +0 -13
  173. package/dist/components/modal/modal.d.ts +0 -13
  174. package/dist/components/modal/modal.js +0 -155
  175. package/dist/components/modal/modal.mjs +0 -130
  176. package/dist/components/styles.d.mts +0 -9
  177. package/dist/components/styles.d.ts +0 -9
  178. package/dist/components/styles.js +0 -48
  179. package/dist/components/styles.mjs +0 -17
  180. package/dist/date.d.mts +0 -5
  181. package/dist/date.d.ts +0 -5
  182. package/dist/date.mjs +0 -29
  183. package/dist/file/cdn.d.mts +0 -6
  184. package/dist/file/cdn.d.ts +0 -6
  185. package/dist/file/cdn.mjs +0 -9
  186. package/dist/file/client/drop_file_input.d.mts +0 -36
  187. package/dist/file/client/drop_file_input.d.ts +0 -36
  188. package/dist/file/client/drop_file_input.js +0 -323
  189. package/dist/file/client/drop_file_input.mjs +0 -294
  190. package/dist/file/client/file_upload_button.d.mts +0 -10
  191. package/dist/file/client/file_upload_button.d.ts +0 -10
  192. package/dist/file/client/file_upload_button.js +0 -89
  193. package/dist/file/client/file_upload_button.mjs +0 -58
  194. package/dist/file/client/file_uploader.d.mts +0 -13
  195. package/dist/file/client/file_uploader.d.ts +0 -13
  196. package/dist/file/client/file_uploader.js +0 -163
  197. package/dist/file/client/file_uploader.mjs +0 -136
  198. package/dist/file/client/format_size.d.mts +0 -3
  199. package/dist/file/client/format_size.d.ts +0 -3
  200. package/dist/file/client/format_size.mjs +0 -13
  201. package/dist/file/client/metadata.d.mts +0 -7
  202. package/dist/file/client/metadata.d.ts +0 -7
  203. package/dist/file/client/metadata.js +0 -85
  204. package/dist/file/client/metadata.mjs +0 -60
  205. package/dist/file/file_repository.d.mts +0 -16
  206. package/dist/file/file_repository.d.ts +0 -16
  207. package/dist/file/file_repository.js +0 -18
  208. package/dist/file/file_repository.mjs +0 -0
  209. package/dist/file/file_service.d.mts +0 -32
  210. package/dist/file/file_service.d.ts +0 -32
  211. package/dist/file/file_service.js +0 -66
  212. package/dist/file/file_service.mjs +0 -41
  213. package/dist/file/handlers/delete_file.d.mts +0 -17
  214. package/dist/file/handlers/delete_file.d.ts +0 -17
  215. package/dist/file/handlers/delete_file.js +0 -99
  216. package/dist/file/handlers/delete_file.mjs +0 -72
  217. package/dist/file/handlers/upload_file.d.mts +0 -16
  218. package/dist/file/handlers/upload_file.d.ts +0 -16
  219. package/dist/file/handlers/upload_file.js +0 -106
  220. package/dist/file/handlers/upload_file.mjs +0 -79
  221. package/dist/file/object_storage.d.mts +0 -19
  222. package/dist/file/object_storage.d.ts +0 -19
  223. package/dist/file/object_storage.js +0 -78
  224. package/dist/file/object_storage.mjs +0 -57
  225. package/dist/file/responsive_image.d.mts +0 -20
  226. package/dist/file/responsive_image.d.ts +0 -20
  227. package/dist/file/responsive_image.js +0 -132
  228. package/dist/file/responsive_image.mjs +0 -96
  229. package/dist/http/response.d.mts +0 -19
  230. package/dist/http/response.d.ts +0 -19
  231. package/dist/http/response.js +0 -109
  232. package/dist/http/response.mjs +0 -68
  233. package/dist/route/api.d.mts +0 -21
  234. package/dist/route/api.d.ts +0 -21
  235. package/dist/route/api.js +0 -584
  236. package/dist/route/api.mjs +0 -547
  237. package/dist/singleton.d.mts +0 -3
  238. package/dist/singleton.d.ts +0 -3
  239. package/dist/singleton.js +0 -37
  240. package/dist/singleton.mjs +0 -12
  241. package/dist/sleep.d.mts +0 -3
  242. package/dist/sleep.d.ts +0 -3
  243. package/dist/sleep.mjs +0 -7
  244. package/dist/slug.d.mts +0 -3
  245. package/dist/slug.d.ts +0 -3
  246. package/dist/slug.mjs +0 -7
  247. package/dist/text_editor/attach_media.d.mts +0 -16
  248. package/dist/text_editor/attach_media.d.ts +0 -16
  249. package/dist/text_editor/attach_media.js +0 -237
  250. package/dist/text_editor/attach_media.mjs +0 -210
  251. package/dist/text_editor/plugins/drag_and_drop.d.mts +0 -13
  252. package/dist/text_editor/plugins/drag_and_drop.d.ts +0 -13
  253. package/dist/text_editor/plugins/drag_and_drop.js +0 -59
  254. package/dist/text_editor/plugins/drag_and_drop.mjs +0 -34
  255. package/dist/text_editor/plugins/keymap.d.mts +0 -5
  256. package/dist/text_editor/plugins/keymap.d.ts +0 -5
  257. package/dist/text_editor/plugins/keymap.js +0 -40
  258. package/dist/text_editor/plugins/keymap.mjs +0 -15
  259. package/dist/text_editor/plugins/placehoder.d.mts +0 -5
  260. package/dist/text_editor/plugins/placehoder.d.ts +0 -5
  261. package/dist/text_editor/plugins/placehoder.js +0 -112
  262. package/dist/text_editor/plugins/placehoder.mjs +0 -87
  263. package/dist/text_editor/plugins/trailing_paragraph.d.mts +0 -5
  264. package/dist/text_editor/plugins/trailing_paragraph.d.ts +0 -5
  265. package/dist/text_editor/plugins/trailing_paragraph.js +0 -46
  266. package/dist/text_editor/plugins/trailing_paragraph.mjs +0 -21
  267. package/dist/text_editor/plugins/upload_placeholder.d.mts +0 -7
  268. package/dist/text_editor/plugins/upload_placeholder.d.ts +0 -7
  269. package/dist/text_editor/plugins/upload_placeholder.js +0 -94
  270. package/dist/text_editor/plugins/upload_placeholder.mjs +0 -68
  271. package/dist/text_editor/schema.d.mts +0 -9
  272. package/dist/text_editor/schema.d.ts +0 -9
  273. package/dist/text_editor/schema.js +0 -354
  274. package/dist/text_editor/schema.mjs +0 -319
  275. package/dist/text_editor/text_editor.d.mts +0 -44
  276. package/dist/text_editor/text_editor.d.ts +0 -44
  277. package/dist/text_editor/text_editor.js +0 -830
  278. package/dist/text_editor/text_editor.mjs +0 -802
@@ -1,354 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/text_editor/schema.tsx
31
- var schema_exports = {};
32
- __export(schema_exports, {
33
- createSchema: () => createSchema
34
- });
35
- module.exports = __toCommonJS(schema_exports);
36
- var import_prosemirror_model = require("prosemirror-model");
37
- var import_prosemirror_schema_list = require("prosemirror-schema-list");
38
-
39
- // src/file/responsive_image.tsx
40
- var import_react = __toESM(require("react"));
41
- var sizes = [
42
- 64,
43
- 128,
44
- 256,
45
- 320,
46
- 480,
47
- 640,
48
- 768,
49
- 1080,
50
- 1200,
51
- 1536,
52
- 1920,
53
- 2560,
54
- 3840
55
- ];
56
- var generateSrc = (cdnOrigin, src, width, height, ratio, image = {}) => {
57
- const searchParams = new URLSearchParams();
58
- if (image.width) {
59
- searchParams.set("w", image.width.toString());
60
- }
61
- if (width) {
62
- searchParams.set("w", width.toString());
63
- if (ratio) {
64
- searchParams.set("h", Math.round(width / ratio).toString());
65
- }
66
- }
67
- if (image.height) {
68
- searchParams.set("h", image.height.toString());
69
- }
70
- if (height) {
71
- searchParams.set("h", height.toString());
72
- }
73
- const search = searchParams.toString() ? `?${searchParams.toString()}` : "";
74
- if (!src.includes(cdnOrigin)) {
75
- return src;
76
- }
77
- return `${encodeURI(decodeURI(src))}${search}`;
78
- };
79
- function generateSrcSet(cdnOrigin, image, ratio, props = {}) {
80
- const src = typeof image === "string" ? image : image.src;
81
- const isGif = src.endsWith(".gif");
82
- if (isGif) {
83
- return void 0;
84
- }
85
- if (props.width) {
86
- return [1, 2, 3].map((scale) => {
87
- const genWidth = Number(props.width) * scale;
88
- return `${generateSrc(
89
- cdnOrigin,
90
- src,
91
- genWidth,
92
- props.height ? Number(props.height) * scale : ratio ? Math.round(genWidth / ratio) : void 0
93
- )} ${scale}x`;
94
- }).join(", ");
95
- }
96
- return sizes.map(
97
- (size) => `${generateSrc(cdnOrigin, src, size, void 0, ratio, props)} ${size}w`
98
- ).join(", ");
99
- }
100
-
101
- // src/text_editor/schema.tsx
102
- function createSchema({ cdnOrigin }) {
103
- const customSchema = new import_prosemirror_model.Schema({
104
- nodes: {
105
- doc: { content: "block+" },
106
- paragraph: {
107
- attrs: { align: { default: null } },
108
- content: "inline*",
109
- group: "block",
110
- parseDOM: [
111
- {
112
- tag: "p",
113
- getAttrs(dom) {
114
- return {
115
- align: dom.style.textAlign || null
116
- };
117
- }
118
- }
119
- ],
120
- toDOM(node) {
121
- return [
122
- "p",
123
- {
124
- style: node.attrs.align ? `text-align: ${node.attrs.align}` : null
125
- },
126
- 0
127
- ];
128
- }
129
- },
130
- text: {
131
- group: "inline"
132
- },
133
- hard_break: {
134
- inline: true,
135
- group: "inline",
136
- selectable: false,
137
- parseDOM: [{ tag: "br" }],
138
- toDOM() {
139
- return ["br"];
140
- }
141
- },
142
- heading: {
143
- attrs: { level: { default: 1 }, align: { default: null } },
144
- content: "inline*",
145
- group: "block",
146
- defining: true,
147
- parseDOM: [
148
- {
149
- tag: "h1",
150
- getAttrs(node) {
151
- return {
152
- level: 1,
153
- algin: node.style.textAlign || null
154
- };
155
- }
156
- },
157
- {
158
- tag: "h2",
159
- getAttrs(node) {
160
- return {
161
- level: 2,
162
- algin: node.style.textAlign || null
163
- };
164
- }
165
- },
166
- {
167
- tag: "h3",
168
- getAttrs(node) {
169
- return {
170
- level: 3,
171
- algin: node.style.textAlign || null
172
- };
173
- }
174
- },
175
- {
176
- tag: "h4",
177
- getAttrs(node) {
178
- return {
179
- level: 4,
180
- algin: node.style.textAlign || null
181
- };
182
- }
183
- },
184
- {
185
- tag: "h5",
186
- getAttrs(node) {
187
- return {
188
- level: 5,
189
- algin: node.style.textAlign || null
190
- };
191
- }
192
- },
193
- {
194
- tag: "h6",
195
- getAttrs(node) {
196
- return {
197
- level: 6,
198
- algin: node.style.textAlign || null
199
- };
200
- }
201
- }
202
- ],
203
- toDOM(node) {
204
- return [
205
- "h" + node.attrs.level,
206
- {
207
- id: node.textContent.toLowerCase().replace(/\s+/g, "-"),
208
- style: node.attrs.align ? `text-align: ${node.attrs.align};` : null
209
- },
210
- 0
211
- ];
212
- }
213
- },
214
- horizontal_rule: {
215
- group: "block",
216
- parseDOM: [{ tag: "hr" }],
217
- toDOM() {
218
- return ["hr"];
219
- }
220
- },
221
- image: {
222
- attrs: {
223
- src: { validate: "string" },
224
- alt: { default: null, validate: "string|null" },
225
- title: {
226
- default: null,
227
- validate: "string|null"
228
- },
229
- width: {
230
- default: null,
231
- validate: "number|null"
232
- },
233
- height: {
234
- default: null,
235
- validate: "number|null"
236
- }
237
- },
238
- inline: true,
239
- group: "inline",
240
- draggable: true,
241
- parseDOM: [
242
- {
243
- tag: "img",
244
- getAttrs(dom) {
245
- return {
246
- src: dom.getAttribute("src"),
247
- title: dom.getAttribute("title"),
248
- alt: dom.getAttribute("alt"),
249
- width: dom.getAttribute("width"),
250
- height: dom.getAttribute("height")
251
- };
252
- }
253
- }
254
- ],
255
- toDOM(node) {
256
- const { src, alt, title, width, height } = node.attrs;
257
- return [
258
- "img",
259
- {
260
- src,
261
- alt,
262
- title,
263
- width,
264
- height,
265
- srcSet: cdnOrigin ? generateSrcSet(cdnOrigin, src) : void 0,
266
- sizes: cdnOrigin ? "(max-width: 768px) 100vw, 768px" : void 0
267
- }
268
- ];
269
- }
270
- }
271
- },
272
- marks: {
273
- link: {
274
- attrs: {
275
- href: { default: "" },
276
- title: { default: null }
277
- },
278
- inclusive: false,
279
- parseDOM: [
280
- {
281
- tag: "a[href]",
282
- getAttrs(dom) {
283
- return {
284
- href: dom.getAttribute("href"),
285
- title: dom.getAttribute("title")
286
- };
287
- }
288
- }
289
- ],
290
- toDOM(node) {
291
- const { href, title } = node.attrs;
292
- const target = "_blank";
293
- const rel = "noopener noreferrer";
294
- return ["a", { href, title: title || href, target, rel }, 0];
295
- }
296
- },
297
- bold: {
298
- parseDOM: [
299
- { tag: "strong" },
300
- {
301
- tag: "b",
302
- getAttrs: (node) => node.style.fontWeight != "normal" && null
303
- },
304
- {
305
- style: "font-weight=400",
306
- clearMark: (m) => m.type.name == "strong"
307
- },
308
- {
309
- style: "font-weight",
310
- getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
311
- }
312
- ],
313
- toDOM() {
314
- return ["strong", 0];
315
- }
316
- },
317
- italic: {
318
- parseDOM: [
319
- { tag: "em" },
320
- { tag: "i" },
321
- { style: "font-style=italic" },
322
- {
323
- style: "font-style=normal",
324
- clearMark: (m) => m.type.name == "em"
325
- }
326
- ],
327
- toDOM() {
328
- return ["em", 0];
329
- }
330
- },
331
- underline: {
332
- parseDOM: [
333
- { tag: "u" },
334
- {
335
- style: "text-decoration",
336
- getAttrs: (value) => value === "underline" && null
337
- }
338
- ],
339
- toDOM() {
340
- return ["u", 0];
341
- }
342
- }
343
- }
344
- });
345
- const prosemirrorSchema = new import_prosemirror_model.Schema({
346
- nodes: (0, import_prosemirror_schema_list.addListNodes)(customSchema.spec.nodes, "paragraph block*", "block"),
347
- marks: customSchema.spec.marks
348
- });
349
- return prosemirrorSchema;
350
- }
351
- // Annotate the CommonJS export names for ESM import in node:
352
- 0 && (module.exports = {
353
- createSchema
354
- });
@@ -1,319 +0,0 @@
1
- // src/text_editor/schema.tsx
2
- import { Schema } from "prosemirror-model";
3
- import { addListNodes } from "prosemirror-schema-list";
4
-
5
- // src/file/responsive_image.tsx
6
- import React from "react";
7
- var sizes = [
8
- 64,
9
- 128,
10
- 256,
11
- 320,
12
- 480,
13
- 640,
14
- 768,
15
- 1080,
16
- 1200,
17
- 1536,
18
- 1920,
19
- 2560,
20
- 3840
21
- ];
22
- var generateSrc = (cdnOrigin, src, width, height, ratio, image = {}) => {
23
- const searchParams = new URLSearchParams();
24
- if (image.width) {
25
- searchParams.set("w", image.width.toString());
26
- }
27
- if (width) {
28
- searchParams.set("w", width.toString());
29
- if (ratio) {
30
- searchParams.set("h", Math.round(width / ratio).toString());
31
- }
32
- }
33
- if (image.height) {
34
- searchParams.set("h", image.height.toString());
35
- }
36
- if (height) {
37
- searchParams.set("h", height.toString());
38
- }
39
- const search = searchParams.toString() ? `?${searchParams.toString()}` : "";
40
- if (!src.includes(cdnOrigin)) {
41
- return src;
42
- }
43
- return `${encodeURI(decodeURI(src))}${search}`;
44
- };
45
- function generateSrcSet(cdnOrigin, image, ratio, props = {}) {
46
- const src = typeof image === "string" ? image : image.src;
47
- const isGif = src.endsWith(".gif");
48
- if (isGif) {
49
- return void 0;
50
- }
51
- if (props.width) {
52
- return [1, 2, 3].map((scale) => {
53
- const genWidth = Number(props.width) * scale;
54
- return `${generateSrc(
55
- cdnOrigin,
56
- src,
57
- genWidth,
58
- props.height ? Number(props.height) * scale : ratio ? Math.round(genWidth / ratio) : void 0
59
- )} ${scale}x`;
60
- }).join(", ");
61
- }
62
- return sizes.map(
63
- (size) => `${generateSrc(cdnOrigin, src, size, void 0, ratio, props)} ${size}w`
64
- ).join(", ");
65
- }
66
-
67
- // src/text_editor/schema.tsx
68
- function createSchema({ cdnOrigin }) {
69
- const customSchema = new Schema({
70
- nodes: {
71
- doc: { content: "block+" },
72
- paragraph: {
73
- attrs: { align: { default: null } },
74
- content: "inline*",
75
- group: "block",
76
- parseDOM: [
77
- {
78
- tag: "p",
79
- getAttrs(dom) {
80
- return {
81
- align: dom.style.textAlign || null
82
- };
83
- }
84
- }
85
- ],
86
- toDOM(node) {
87
- return [
88
- "p",
89
- {
90
- style: node.attrs.align ? `text-align: ${node.attrs.align}` : null
91
- },
92
- 0
93
- ];
94
- }
95
- },
96
- text: {
97
- group: "inline"
98
- },
99
- hard_break: {
100
- inline: true,
101
- group: "inline",
102
- selectable: false,
103
- parseDOM: [{ tag: "br" }],
104
- toDOM() {
105
- return ["br"];
106
- }
107
- },
108
- heading: {
109
- attrs: { level: { default: 1 }, align: { default: null } },
110
- content: "inline*",
111
- group: "block",
112
- defining: true,
113
- parseDOM: [
114
- {
115
- tag: "h1",
116
- getAttrs(node) {
117
- return {
118
- level: 1,
119
- algin: node.style.textAlign || null
120
- };
121
- }
122
- },
123
- {
124
- tag: "h2",
125
- getAttrs(node) {
126
- return {
127
- level: 2,
128
- algin: node.style.textAlign || null
129
- };
130
- }
131
- },
132
- {
133
- tag: "h3",
134
- getAttrs(node) {
135
- return {
136
- level: 3,
137
- algin: node.style.textAlign || null
138
- };
139
- }
140
- },
141
- {
142
- tag: "h4",
143
- getAttrs(node) {
144
- return {
145
- level: 4,
146
- algin: node.style.textAlign || null
147
- };
148
- }
149
- },
150
- {
151
- tag: "h5",
152
- getAttrs(node) {
153
- return {
154
- level: 5,
155
- algin: node.style.textAlign || null
156
- };
157
- }
158
- },
159
- {
160
- tag: "h6",
161
- getAttrs(node) {
162
- return {
163
- level: 6,
164
- algin: node.style.textAlign || null
165
- };
166
- }
167
- }
168
- ],
169
- toDOM(node) {
170
- return [
171
- "h" + node.attrs.level,
172
- {
173
- id: node.textContent.toLowerCase().replace(/\s+/g, "-"),
174
- style: node.attrs.align ? `text-align: ${node.attrs.align};` : null
175
- },
176
- 0
177
- ];
178
- }
179
- },
180
- horizontal_rule: {
181
- group: "block",
182
- parseDOM: [{ tag: "hr" }],
183
- toDOM() {
184
- return ["hr"];
185
- }
186
- },
187
- image: {
188
- attrs: {
189
- src: { validate: "string" },
190
- alt: { default: null, validate: "string|null" },
191
- title: {
192
- default: null,
193
- validate: "string|null"
194
- },
195
- width: {
196
- default: null,
197
- validate: "number|null"
198
- },
199
- height: {
200
- default: null,
201
- validate: "number|null"
202
- }
203
- },
204
- inline: true,
205
- group: "inline",
206
- draggable: true,
207
- parseDOM: [
208
- {
209
- tag: "img",
210
- getAttrs(dom) {
211
- return {
212
- src: dom.getAttribute("src"),
213
- title: dom.getAttribute("title"),
214
- alt: dom.getAttribute("alt"),
215
- width: dom.getAttribute("width"),
216
- height: dom.getAttribute("height")
217
- };
218
- }
219
- }
220
- ],
221
- toDOM(node) {
222
- const { src, alt, title, width, height } = node.attrs;
223
- return [
224
- "img",
225
- {
226
- src,
227
- alt,
228
- title,
229
- width,
230
- height,
231
- srcSet: cdnOrigin ? generateSrcSet(cdnOrigin, src) : void 0,
232
- sizes: cdnOrigin ? "(max-width: 768px) 100vw, 768px" : void 0
233
- }
234
- ];
235
- }
236
- }
237
- },
238
- marks: {
239
- link: {
240
- attrs: {
241
- href: { default: "" },
242
- title: { default: null }
243
- },
244
- inclusive: false,
245
- parseDOM: [
246
- {
247
- tag: "a[href]",
248
- getAttrs(dom) {
249
- return {
250
- href: dom.getAttribute("href"),
251
- title: dom.getAttribute("title")
252
- };
253
- }
254
- }
255
- ],
256
- toDOM(node) {
257
- const { href, title } = node.attrs;
258
- const target = "_blank";
259
- const rel = "noopener noreferrer";
260
- return ["a", { href, title: title || href, target, rel }, 0];
261
- }
262
- },
263
- bold: {
264
- parseDOM: [
265
- { tag: "strong" },
266
- {
267
- tag: "b",
268
- getAttrs: (node) => node.style.fontWeight != "normal" && null
269
- },
270
- {
271
- style: "font-weight=400",
272
- clearMark: (m) => m.type.name == "strong"
273
- },
274
- {
275
- style: "font-weight",
276
- getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
277
- }
278
- ],
279
- toDOM() {
280
- return ["strong", 0];
281
- }
282
- },
283
- italic: {
284
- parseDOM: [
285
- { tag: "em" },
286
- { tag: "i" },
287
- { style: "font-style=italic" },
288
- {
289
- style: "font-style=normal",
290
- clearMark: (m) => m.type.name == "em"
291
- }
292
- ],
293
- toDOM() {
294
- return ["em", 0];
295
- }
296
- },
297
- underline: {
298
- parseDOM: [
299
- { tag: "u" },
300
- {
301
- style: "text-decoration",
302
- getAttrs: (value) => value === "underline" && null
303
- }
304
- ],
305
- toDOM() {
306
- return ["u", 0];
307
- }
308
- }
309
- }
310
- });
311
- const prosemirrorSchema = new Schema({
312
- nodes: addListNodes(customSchema.spec.nodes, "paragraph block*", "block"),
313
- marks: customSchema.spec.marks
314
- });
315
- return prosemirrorSchema;
316
- }
317
- export {
318
- createSchema
319
- };
@@ -1,44 +0,0 @@
1
- import * as orderedmap from 'orderedmap';
2
- import * as prosemirror_model from 'prosemirror-model';
3
- import { Node, Attrs, Fragment, Mark } from 'prosemirror-model';
4
- import React from 'react';
5
- import { EditorStateConfig } from 'prosemirror-state';
6
- import { EditorView, DirectEditorProps } from 'prosemirror-view';
7
- import { FileUploader } from '../file/client/file_uploader.mjs';
8
-
9
- type TextEditorProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
10
- name?: string;
11
- state?: Partial<EditorStateConfig>;
12
- editor?: Partial<DirectEditorProps>;
13
- placeholder?: string;
14
- defaultValue?: string;
15
- onHTMLChanged?: (html: string) => void;
16
- };
17
- declare function createTextEditor<TFile extends {
18
- key: string;
19
- }>({ fileUploader, cdnOrigin, }?: {
20
- fileUploader?: FileUploader<TFile>;
21
- cdnOrigin?: string;
22
- }): {
23
- schema: prosemirror_model.Schema<keyof orderedmap.default<prosemirror_model.NodeSpec>, keyof orderedmap.default<prosemirror_model.MarkSpec>>;
24
- useTextEditor: () => {
25
- readonly schema: prosemirror_model.Schema<keyof orderedmap.default<prosemirror_model.NodeSpec>, keyof orderedmap.default<prosemirror_model.MarkSpec>>;
26
- readonly view: React.RefObject<EditorView | null>;
27
- readonly commands: {
28
- readonly attachMedia: (files: File[]) => Promise<Node[] | undefined>;
29
- readonly toggleMark: <T extends string | number>(type: T, attrs?: Attrs, options?: {
30
- removeWhenPresent?: boolean;
31
- enterInlineAtoms?: boolean;
32
- includeWhitespace?: boolean;
33
- }) => void;
34
- readonly setBlockType: <T extends string | number>(type: T, attrs?: Attrs) => void;
35
- readonly insertNode: (type: string, attrs?: Attrs, content?: Fragment | Node | Node[], marks?: Mark[]) => void;
36
- readonly setHTML: (html: string) => void;
37
- };
38
- readonly Component: ({ name, placeholder, className, defaultValue, onClick, onHTMLChanged, editor, state, ...props }: TextEditorProps) => React.JSX.Element;
39
- readonly serialize: () => string;
40
- readonly getTextContent: () => string;
41
- };
42
- };
43
-
44
- export { type TextEditorProps, createTextEditor as default };