markdown-text-editor 1.9.0 → 2.0.0-beta.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 (68) hide show
  1. package/README.md +87 -5
  2. package/dist/markdown-text-editor.css +3 -0
  3. package/dist/markdown-text-editor.es.js +730 -786
  4. package/dist/markdown-text-editor.es.js.map +1 -1
  5. package/dist/markdown-text-editor.min.js +65 -64
  6. package/dist/markdown-text-editor.min.js.map +1 -1
  7. package/dist/markdown-text-editor.umd.js +65 -64
  8. package/dist/markdown-text-editor.umd.js.map +1 -1
  9. package/locale/ar.js +55 -0
  10. package/locale/az.js +55 -0
  11. package/locale/bg.js +55 -0
  12. package/locale/bn.js +55 -0
  13. package/locale/bs.js +55 -0
  14. package/locale/ca.js +55 -0
  15. package/locale/cs.js +55 -0
  16. package/locale/da.js +55 -0
  17. package/locale/de.js +55 -0
  18. package/locale/el.js +55 -0
  19. package/locale/es.js +55 -0
  20. package/locale/et.js +55 -0
  21. package/locale/fa.js +55 -0
  22. package/locale/fi.js +55 -0
  23. package/locale/fil.js +55 -0
  24. package/locale/fr.js +55 -0
  25. package/locale/ga.js +55 -0
  26. package/locale/he.js +55 -0
  27. package/locale/hi.js +55 -0
  28. package/locale/hr.js +55 -0
  29. package/locale/hu.js +55 -0
  30. package/locale/hy.js +55 -0
  31. package/locale/id.js +55 -0
  32. package/locale/is.js +55 -0
  33. package/locale/it.js +55 -0
  34. package/locale/ja.js +55 -0
  35. package/locale/kn.js +55 -0
  36. package/locale/ko.js +55 -0
  37. package/locale/locale.d.ts +10 -0
  38. package/locale/lt.js +55 -0
  39. package/locale/lv.js +55 -0
  40. package/locale/mk.js +55 -0
  41. package/locale/mr.js +55 -0
  42. package/locale/ms.js +55 -0
  43. package/locale/mt.js +55 -0
  44. package/locale/nl.js +55 -0
  45. package/locale/no.js +55 -0
  46. package/locale/pl.js +55 -0
  47. package/locale/pt.js +55 -0
  48. package/locale/ro.js +55 -0
  49. package/locale/ru.js +55 -0
  50. package/locale/sk.js +55 -0
  51. package/locale/sl.js +55 -0
  52. package/locale/sq.js +55 -0
  53. package/locale/sr.js +55 -0
  54. package/locale/sv.js +55 -0
  55. package/locale/sw.js +55 -0
  56. package/locale/ta.js +55 -0
  57. package/locale/te.js +55 -0
  58. package/locale/template.js +62 -0
  59. package/locale/th.js +55 -0
  60. package/locale/tr.js +55 -0
  61. package/locale/uk.js +55 -0
  62. package/locale/ur.js +55 -0
  63. package/locale/uz.js +55 -0
  64. package/locale/vi.js +55 -0
  65. package/locale/zh-hk.js +55 -0
  66. package/locale/zh.js +55 -0
  67. package/package.json +22 -9
  68. package/types/index.d.ts +35 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-text-editor",
3
- "version": "1.9.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "type": "module",
5
5
  "description": "A markdown editor that enhances your textarea instead of replacing it, so form submission, validation and required fields keep working. WYSIWYG hybrid mode, live preview, find and replace, RTL, TypeScript types. Works with any backend.",
6
6
  "funding": "https://ko-fi.com/nezanuha",
@@ -15,11 +15,23 @@
15
15
  "import": "./dist/markdown-text-editor.es.js",
16
16
  "require": "./dist/markdown-text-editor.umd.js",
17
17
  "default": "./dist/markdown-text-editor.umd.js"
18
- }
18
+ },
19
+ "./style.css": "./dist/markdown-text-editor.css",
20
+ "./locale/*.js": {
21
+ "types": "./locale/locale.d.ts",
22
+ "default": "./locale/*.js"
23
+ },
24
+ "./locale/*": {
25
+ "types": "./locale/locale.d.ts",
26
+ "default": "./locale/*.js"
27
+ },
28
+ "./dist/*": "./dist/*",
29
+ "./package.json": "./package.json"
19
30
  },
20
31
  "files": [
21
32
  "dist/",
22
33
  "types/",
34
+ "locale/",
23
35
  "README.md",
24
36
  "LICENSE"
25
37
  ],
@@ -32,9 +44,11 @@
32
44
  "build": "vite build",
33
45
  "preview": "vite preview",
34
46
  "prepublishOnly": "npm run build",
47
+ "locale:extract": "node scripts/locale-extract.mjs",
48
+ "locale:check": "node scripts/locale-check.mjs",
35
49
  "version": "node scripts/check-changelog.mjs",
36
50
  "postversion": "git push origin HEAD --follow-tags",
37
- "test": "node test/smoke.mjs",
51
+ "test": "node test/smoke.mjs && node scripts/locale-check.mjs",
38
52
  "typecheck": "tsc --noEmit --strict --lib es2020,dom --moduleResolution bundler --module esnext test/types.test.ts"
39
53
  },
40
54
  "publishConfig": {
@@ -76,20 +90,19 @@
76
90
  },
77
91
  "dependencies": {
78
92
  "dompurify": "^3.4.16",
79
- "marked": "~18.0.14"
93
+ "marked": "~18.1.0"
80
94
  },
81
95
  "devDependencies": {
82
96
  "@tailwindcss/postcss": "^4.3.3",
83
97
  "@tailwindcss/typography": "^0.5.20",
84
98
  "@tailwindcss/vite": "^4.3.3",
85
99
  "diff": "^9.0.0",
86
- "frutjam": "^2.2.6",
87
- "happy-dom": "^20.14.5",
88
- "postcss": "^8.5.28",
100
+ "frutjam": "^2.3.0",
101
+ "happy-dom": "^20.14.6",
102
+ "postcss": "^8.5.29",
89
103
  "tailwindcss": "^4.3.3",
90
104
  "typescript": "^7.0.2",
91
- "vite": "^8.3.1",
92
- "vite-plugin-css-injected-by-js": "^5.0.2"
105
+ "vite": "^8.3.4"
93
106
  },
94
107
  "types": "./types/index.d.ts"
95
108
  }
package/types/index.d.ts CHANGED
@@ -52,6 +52,24 @@ export interface VariablesTool {
52
52
  variables: Array<Variable | VariableGroup>;
53
53
  }
54
54
 
55
+ export interface HeadingTool {
56
+ heading: {
57
+ /**
58
+ * Which heading levels the dropdown offers, in the order 1-6 regardless
59
+ * of how you list them. Defaults to all six. Useful where H1 belongs to
60
+ * the page rather than the content, e.g. `[2, 3, 4]`.
61
+ *
62
+ * `Ctrl+1`, `Ctrl+2` and `Ctrl+3` follow this list, so a level you leave
63
+ * out cannot be inserted from the keyboard either.
64
+ *
65
+ * This restricts the toolbar, not the document: someone can still type
66
+ * `# Title` by hand and it renders as a heading. Enforce the rule on the
67
+ * server if it has to hold.
68
+ */
69
+ levels?: Array<1 | 2 | 3 | 4 | 5 | 6>;
70
+ };
71
+ }
72
+
55
73
  export interface ImageTool {
56
74
  image: {
57
75
  fileInput?: {
@@ -96,7 +114,7 @@ export type CustomTool = new (editor: MarkdownEditor, config?: any) => {
96
114
  */
97
115
  export interface DeclarativeTool {
98
116
  custom: {
99
- /** Tooltip, and the source of the button's CSS class. Translatable via `labels`. */
117
+ /** Tooltip, and the source of the button's CSS class. Translatable via `locale`. */
100
118
  title: string;
101
119
  /** Inline SVG for the button face. */
102
120
  icon?: string;
@@ -114,6 +132,7 @@ export type ToolbarEntry =
114
132
  | ToolName
115
133
  | VariablesTool
116
134
  | ImageTool
135
+ | HeadingTool
117
136
  | DeclarativeTool
118
137
  | CustomTool
119
138
  | { tool: CustomTool; config?: any };
@@ -166,11 +185,22 @@ export interface MarkdownEditorOptions {
166
185
 
167
186
  /**
168
187
  * Translations for the editor's own interface, keyed by the English text:
169
- * tooltips, menu items, modal fields and buttons. Anything not listed stays
170
- * in English. CSS class names are unaffected.
188
+ * tooltips, menu items, modal fields, buttons and screen reader names.
189
+ * Anything not listed stays in English. CSS class names are unaffected.
190
+ *
191
+ * Takes the strings themselves, not a language code. Import the one you want
192
+ * so nobody pays for the languages they do not use.
193
+ * `locale/template.js` lists every key.
171
194
  *
172
- * @example labels: { Bold: 'Negrita', 'Insert variable': 'Insertar variable' }
195
+ * @example
196
+ * import es from 'markdown-text-editor/locale/es.js';
197
+ * new MarkdownEditor('#editor', { locale: es });
198
+ *
199
+ * @example locale: { Bold: 'Negrita', '{n} words': '{n} palabras' }
173
200
  */
201
+ locale?: Record<string, string>;
202
+
203
+ /** @deprecated Renamed to `locale` in 2.0.0. Still works. */
174
204
  labels?: Record<string, string>;
175
205
 
176
206
  /**
@@ -239,7 +269,7 @@ export default class MarkdownEditor {
239
269
  /**
240
270
  * Builds a small toolbar bound to another textarea, for a custom tool that
241
271
  * collects rich text in its own dialog. The tools are the real ones, and
242
- * `labels` are inherited. Returns the element; append it where you like.
272
+ * `locale` is inherited. Returns the element; append it where you like.
243
273
  *
244
274
  * No preview button is added, whatever you pass.
245
275
  */