@yimingliao/cms 0.0.141 → 0.0.143

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 (110) hide show
  1. package/dist/ckeditor-editor.css +172 -0
  2. package/dist/export/client/index.js +3 -0
  3. package/dist/src/client/interfaces/components/resources/file/file-card.js +87 -0
  4. package/dist/src/client/interfaces/components/resources/file/file-list.js +159 -0
  5. package/dist/src/client/interfaces/components/resources/file/is-locked-buttons.js +71 -0
  6. package/dist/src/client/interfaces/components/resources/file/type-buttons.js +62 -0
  7. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js +11 -0
  8. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js +12 -1
  9. package/dist/src/client/interfaces/components/ui/cards/action-buttons-card.js +2 -2
  10. package/dist/src/client/interfaces/components/ui/features/smart-image.js +2 -2
  11. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-display.js +0 -17
  12. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-input.js +0 -17
  13. package/dist/src/client/interfaces/components/ui/form/index-field.js +0 -14
  14. package/dist/src/client/interfaces/components/ui/form/slug-field.js +1 -15
  15. package/dist/src/client/interfaces/components/ui/inputs/editor/base/base-editor.js +143 -0
  16. package/dist/src/client/interfaces/components/ui/inputs/editor/base/built-in-plugins.js +71 -0
  17. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/heading.config.js +41 -0
  18. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/image.config.js +32 -0
  19. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/table.config.js +15 -0
  20. package/dist/src/client/interfaces/components/ui/inputs/editor/editor.js +112 -0
  21. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/asset-manager.js +24 -0
  22. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/use-control-asset-mamager.js +26 -0
  23. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.js +17 -0
  24. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/word-count-display.js +81 -0
  25. package/dist/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.js +50 -0
  26. package/dist/src/client/interfaces/pages/auth/change-password/page.js +5 -2
  27. package/dist/src/client/interfaces/pages/auth/email-unverified/page.js +3 -0
  28. package/dist/src/client/interfaces/pages/auth/forgot-password/page.js +5 -2
  29. package/dist/src/client/interfaces/pages/auth/layout.js +3 -0
  30. package/dist/src/client/interfaces/pages/auth/reset-password/page.js +5 -2
  31. package/dist/src/client/interfaces/pages/auth/sign-in/page.js +5 -2
  32. package/dist/src/client/interfaces/pages/dashboard/layout.js +3 -0
  33. package/dist/src/shared/list-items.js +3 -0
  34. package/dist/src/shared/utils/debounce.js +14 -0
  35. package/dist/types/export/client/index.d.ts +1 -1
  36. package/dist/types/export/client/index.d.ts.map +1 -1
  37. package/dist/types/src/client/index.d.ts +1 -1
  38. package/dist/types/src/client/index.d.ts.map +1 -1
  39. package/dist/types/src/client/interfaces/components/index.d.ts +2 -1
  40. package/dist/types/src/client/interfaces/components/index.d.ts.map +1 -1
  41. package/dist/types/src/client/interfaces/components/resources/file/file-card.d.ts +16 -0
  42. package/dist/types/src/client/interfaces/components/resources/file/file-card.d.ts.map +1 -0
  43. package/dist/types/src/client/interfaces/components/resources/file/file-list.d.ts +23 -0
  44. package/dist/types/src/client/interfaces/components/resources/file/file-list.d.ts.map +1 -0
  45. package/dist/types/src/client/interfaces/components/resources/file/index.d.ts +3 -0
  46. package/dist/types/src/client/interfaces/components/resources/file/index.d.ts.map +1 -0
  47. package/dist/types/src/client/interfaces/components/resources/file/is-locked-buttons.d.ts +8 -0
  48. package/dist/types/src/client/interfaces/components/resources/file/is-locked-buttons.d.ts.map +1 -0
  49. package/dist/types/src/client/interfaces/components/resources/file/type-buttons.d.ts +9 -0
  50. package/dist/types/src/client/interfaces/components/resources/file/type-buttons.d.ts.map +1 -0
  51. package/dist/types/src/client/interfaces/components/resources/index.d.ts +2 -0
  52. package/dist/types/src/client/interfaces/components/resources/index.d.ts.map +1 -0
  53. package/dist/types/src/client/interfaces/components/ui/cards/resource-card/resource-card.d.ts +1 -1
  54. package/dist/types/src/client/interfaces/components/ui/cards/resource-card/resource-card.d.ts.map +1 -1
  55. package/dist/types/src/client/interfaces/components/ui/features/smart-image.d.ts.map +1 -1
  56. package/dist/types/src/client/interfaces/components/ui/form/index-field.d.ts.map +1 -1
  57. package/dist/types/src/client/interfaces/components/ui/form/slug-field.d.ts.map +1 -1
  58. package/dist/types/src/client/interfaces/components/ui/index.d.ts +1 -1
  59. package/dist/types/src/client/interfaces/components/ui/index.d.ts.map +1 -1
  60. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/base-editor.d.ts +7 -0
  61. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/base-editor.d.ts.map +1 -0
  62. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/built-in-plugins.d.ts +26 -0
  63. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/built-in-plugins.d.ts.map +1 -0
  64. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/configs/heading.config.d.ts +34 -0
  65. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/configs/heading.config.d.ts.map +1 -0
  66. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/configs/image.config.d.ts +16 -0
  67. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/configs/image.config.d.ts.map +1 -0
  68. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/configs/index.d.ts +4 -0
  69. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/configs/index.d.ts.map +1 -0
  70. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/configs/table.config.d.ts +4 -0
  71. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/configs/table.config.d.ts.map +1 -0
  72. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/index.d.ts +2 -0
  73. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/index.d.ts.map +1 -0
  74. package/dist/types/src/client/interfaces/components/ui/inputs/editor/editor.d.ts +26 -0
  75. package/dist/types/src/client/interfaces/components/ui/inputs/editor/editor.d.ts.map +1 -0
  76. package/dist/types/src/client/interfaces/components/ui/inputs/editor/index.d.ts +2 -0
  77. package/dist/types/src/client/interfaces/components/ui/inputs/editor/index.d.ts.map +1 -0
  78. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/asset-manager.d.ts +8 -0
  79. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/asset-manager.d.ts.map +1 -0
  80. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/index.d.ts +3 -0
  81. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/index.d.ts.map +1 -0
  82. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/use-control-asset-mamager.d.ts +14 -0
  83. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/use-control-asset-mamager.d.ts.map +1 -0
  84. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/index.d.ts +2 -0
  85. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/index.d.ts.map +1 -0
  86. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/upload-adapter.d.ts +28 -0
  87. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/upload-adapter.d.ts.map +1 -0
  88. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.d.ts +4 -0
  89. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.d.ts.map +1 -0
  90. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/index.d.ts +2 -0
  91. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/index.d.ts.map +1 -0
  92. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/word-count-display.d.ts +11 -0
  93. package/dist/types/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/word-count-display.d.ts.map +1 -0
  94. package/dist/types/src/client/interfaces/components/ui/inputs/editor/use-init-editor/index.d.ts +3 -0
  95. package/dist/types/src/client/interfaces/components/ui/inputs/editor/use-init-editor/index.d.ts.map +1 -0
  96. package/dist/types/src/client/interfaces/components/ui/inputs/editor/use-init-editor/types.d.ts +14 -0
  97. package/dist/types/src/client/interfaces/components/ui/inputs/editor/use-init-editor/types.d.ts.map +1 -0
  98. package/dist/types/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.d.ts +4 -0
  99. package/dist/types/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.d.ts.map +1 -0
  100. package/dist/types/src/client/interfaces/components/ui/inputs/index.d.ts +1 -0
  101. package/dist/types/src/client/interfaces/components/ui/inputs/index.d.ts.map +1 -1
  102. package/dist/types/src/client/interfaces/index.d.ts +1 -1
  103. package/dist/types/src/client/interfaces/index.d.ts.map +1 -1
  104. package/dist/types/src/shared/index.d.ts +1 -1
  105. package/dist/types/src/shared/index.d.ts.map +1 -1
  106. package/dist/types/src/shared/utils/debounce.d.ts +7 -0
  107. package/dist/types/src/shared/utils/debounce.d.ts.map +1 -0
  108. package/dist/types/src/shared/utils/index.d.ts +1 -0
  109. package/dist/types/src/shared/utils/index.d.ts.map +1 -1
  110. package/package.json +8 -2
@@ -2,23 +2,6 @@
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import { useTranslator } from 'intor/react';
4
4
  import { Eye, Binary, MapPinCheckInside, Star, House } from 'lucide-react';
5
- import 'react';
6
- import 'ua-parser-js';
7
- import 'clsx';
8
- import 'tailwind-merge';
9
- import 'next/navigation';
10
- import '@radix-ui/react-avatar';
11
- import '../../../shadcn/badge.js';
12
- import '../../../shadcn/button.js';
13
- import '@radix-ui/react-collapsible';
14
- import '@radix-ui/react-dialog';
15
- import '@radix-ui/react-dropdown-menu';
16
- import '../../../shadcn/input-group.js';
17
- import '@radix-ui/react-label';
18
- import '@radix-ui/react-select';
19
- import '@radix-ui/react-separator';
20
- import '../../../shadcn/sidebar.js';
21
- import '@radix-ui/react-tooltip';
22
5
  import { Checkbox } from '../../inputs/checkbox.js';
23
6
  import { Field } from '../field.js';
24
7
  import { IndexField } from '../index-field.js';
@@ -2,23 +2,6 @@
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import { useTranslator } from 'intor/react';
4
4
  import { Eye, EyeOff, Binary, MapPinCheckInside, Star, House } from 'lucide-react';
5
- import 'react';
6
- import 'ua-parser-js';
7
- import 'clsx';
8
- import 'tailwind-merge';
9
- import 'next/navigation';
10
- import '@radix-ui/react-avatar';
11
- import '../../../shadcn/badge.js';
12
- import '../../../shadcn/button.js';
13
- import '@radix-ui/react-collapsible';
14
- import '@radix-ui/react-dialog';
15
- import '@radix-ui/react-dropdown-menu';
16
- import '../../../shadcn/input-group.js';
17
- import '@radix-ui/react-label';
18
- import '@radix-ui/react-select';
19
- import '@radix-ui/react-separator';
20
- import '../../../shadcn/sidebar.js';
21
- import '@radix-ui/react-tooltip';
22
5
  import { Checkbox } from '../../inputs/checkbox.js';
23
6
  import { Field } from '../field.js';
24
7
  import { IndexField } from '../index-field.js';
@@ -7,20 +7,6 @@ import 'ua-parser-js';
7
7
  import { cn } from '../../../../applications/shadcn/utils.js';
8
8
  import 'next/navigation';
9
9
  import { ExpandableList } from '../features/expandable-list/expandable-list.js';
10
- import 'lucide-react';
11
- import '@radix-ui/react-avatar';
12
- import '../../shadcn/badge.js';
13
- import '../../shadcn/button.js';
14
- import '@radix-ui/react-collapsible';
15
- import '@radix-ui/react-dialog';
16
- import '@radix-ui/react-dropdown-menu';
17
- import '../../shadcn/input-group.js';
18
- import '@radix-ui/react-label';
19
- import '@radix-ui/react-select';
20
- import '@radix-ui/react-separator';
21
- import '../../shadcn/sidebar.js';
22
- import '@radix-ui/react-tooltip';
23
- import 'intor/react';
24
10
  import { Checkbox } from '../inputs/checkbox.js';
25
11
  import { Input } from '../inputs/input.js';
26
12
  import { FieldBody } from './field-body.js';
@@ -7,22 +7,8 @@ import 'ua-parser-js';
7
7
  import { cn } from '../../../../applications/shadcn/utils.js';
8
8
  import 'next/navigation';
9
9
  import { ExpandableList } from '../features/expandable-list/expandable-list.js';
10
- import 'lucide-react';
11
- import '@radix-ui/react-avatar';
12
- import '../../shadcn/badge.js';
13
- import '../../shadcn/button.js';
14
- import '@radix-ui/react-collapsible';
15
- import '@radix-ui/react-dialog';
16
- import '@radix-ui/react-dropdown-menu';
17
- import '../../shadcn/input-group.js';
18
- import '@radix-ui/react-label';
19
- import '@radix-ui/react-select';
20
- import '@radix-ui/react-separator';
21
- import '../../shadcn/sidebar.js';
22
- import '@radix-ui/react-tooltip';
23
- import 'intor/react';
24
- import { Textarea } from '../inputs/textarea.js';
25
10
  import { Checkbox } from '../inputs/checkbox.js';
11
+ import { Textarea } from '../inputs/textarea.js';
26
12
  import { FieldBody } from './field-body.js';
27
13
 
28
14
  function SlugField({
@@ -0,0 +1,143 @@
1
+ import { ClassicEditor } from 'ckeditor5';
2
+ import enTranslations from 'ckeditor5/translations/en.js';
3
+ import zhTranslations from 'ckeditor5/translations/zh.js';
4
+ import { ASSET_MANAGER_PLUGIN_NAME } from '../plugins/asset-manager/asset-manager.js';
5
+ import 'intor/react';
6
+ import 'react';
7
+ import 'mime-types';
8
+ import { WORD_COUNT_DISPLAY_PLUGIN_NAME } from '../plugins/word-count-display/word-count-display.js';
9
+ import { builtinPlugins } from './built-in-plugins.js';
10
+ import { headingConfig } from './configs/heading.config.js';
11
+ import { tableConfig } from './configs/table.config.js';
12
+ import { imageConfig } from './configs/image.config.js';
13
+
14
+ class BaseEditor extends ClassicEditor {
15
+ static builtinPlugins = builtinPlugins;
16
+ static defaultConfig = {
17
+ licenseKey: "GPL",
18
+ //====== Translations ======
19
+ translations: [zhTranslations, enTranslations],
20
+ // schema: { allowIn: ["figure"], allowAttributes: ["src"] },
21
+ //====== Toolbar ======
22
+ toolbar: {
23
+ items: [
24
+ //------ 1 row ------
25
+ "undo",
26
+ // [Undo]
27
+ "redo",
28
+ // [Undo]
29
+ "|",
30
+ "heading",
31
+ // [Heading]
32
+ "fontFamily",
33
+ // [Font]
34
+ "fontSize",
35
+ // [Font]
36
+ "fontColor",
37
+ // [Font]
38
+ "fontBackgroundColor",
39
+ // [Font]
40
+ "highlight",
41
+ // [Highlight]
42
+ "|",
43
+ "emoji",
44
+ // [Emoji]
45
+ "specialCharacters",
46
+ // [SpecialCharacters]
47
+ "|",
48
+ "removeFormat",
49
+ // [RemoveFormat]
50
+ "|",
51
+ "selectAll",
52
+ // [SelectAll]
53
+ "findAndReplace",
54
+ // [FindAndReplace]
55
+ "-",
56
+ //------ 2 row ------
57
+ "alignment",
58
+ // [Alignment]
59
+ "indent",
60
+ // [Indent]
61
+ "outdent",
62
+ // [Indent]
63
+ "|",
64
+ "bold",
65
+ // [Bold]
66
+ "italic",
67
+ // [Italic]
68
+ "strikethrough",
69
+ // [Strikethrough]
70
+ "underline",
71
+ // [Underline]
72
+ "subscript",
73
+ // [Subscript]
74
+ "superscript",
75
+ // [Superscript]
76
+ "code",
77
+ // [Code]
78
+ "link",
79
+ // [Link]
80
+ "|",
81
+ ASSET_MANAGER_PLUGIN_NAME,
82
+ "insertImage",
83
+ // [Image]
84
+ "mediaEmbed",
85
+ // [MediaEmbed]
86
+ "|",
87
+ "codeBlock",
88
+ // [CodeBlock]
89
+ "htmlEmbed",
90
+ // [HtmlEmbed]
91
+ //------ 3 row ------
92
+ "-",
93
+ "bulletedList",
94
+ // [List]
95
+ "numberedList",
96
+ // [List]
97
+ "todoList",
98
+ // [TodoList]
99
+ "|",
100
+ "blockQuote",
101
+ // [BlockQuote]
102
+ "horizontalLine",
103
+ // [HorizontalLine]
104
+ "pageBreak",
105
+ // [PageBreak]
106
+ "|",
107
+ "insertTable",
108
+ // [Table]
109
+ "insertTableLayout",
110
+ // [Table]
111
+ "|",
112
+ "showBlocks",
113
+ // [ShowBlocks]
114
+ "sourceEditing",
115
+ // [SourceEditing]
116
+ "|",
117
+ //------ Word Count Display ------
118
+ WORD_COUNT_DISPLAY_PLUGIN_NAME.html,
119
+ WORD_COUNT_DISPLAY_PLUGIN_NAME.characters,
120
+ WORD_COUNT_DISPLAY_PLUGIN_NAME.words
121
+ ],
122
+ shouldNotGroupWhenFull: true
123
+ },
124
+ //====== Specific Configs ======
125
+ heading: headingConfig,
126
+ link: { addTargetToExternalLinks: true },
127
+ table: tableConfig,
128
+ image: imageConfig,
129
+ htmlSupport: {
130
+ allow: [{ name: /.*/, attributes: true, classes: true, styles: true }]
131
+ },
132
+ htmlEmbed: { showPreviews: true },
133
+ emoji: { skinTone: "light" },
134
+ fontFamily: { supportAllValues: false },
135
+ fontSize: {
136
+ options: [12, 14, "default", 16, 18, 20, 22, 24, 26, 28],
137
+ supportAllValues: false
138
+ }
139
+ // menuBar: { isVisible: true },
140
+ };
141
+ }
142
+
143
+ export { BaseEditor };
@@ -0,0 +1,71 @@
1
+ import { Essentials, Paragraph, Autoformat, TextTransformation, Bold, Code, Italic, Strikethrough, Subscript, Superscript, Underline, Indent, IndentBlock, BlockQuote, CodeBlock, Emoji, Mention, FindAndReplace, Font, Heading, Highlight, HorizontalLine, GeneralHtmlSupport, HtmlComment, HtmlEmbed, Image, ImageToolbar, ImageCaption, ImageStyle, ImageResize, LinkImage, ImageInsert, AutoImage, ImageUpload, Link, AutoLink, List, TodoList, MediaEmbed, PageBreak, PasteFromOffice, PasteFromMarkdownExperimental, RemoveFormat, ShowBlocks, SourceEditing, SpecialCharacters, SpecialCharactersEssentials, Table, TableToolbar, TableProperties, TableCellProperties, TableColumnResize, TableCaption, TableLayout, Alignment, WordCount } from 'ckeditor5';
2
+ import { AssetManager } from '../plugins/asset-manager/asset-manager.js';
3
+ import 'intor/react';
4
+ import 'react';
5
+ import 'mime-types';
6
+ import WordCountButtons from '../plugins/word-count-display/word-count-display.js';
7
+
8
+ const builtinPlugins = [
9
+ Essentials,
10
+ Paragraph,
11
+ Autoformat,
12
+ // For markdown
13
+ TextTransformation,
14
+ Bold,
15
+ Code,
16
+ Italic,
17
+ Strikethrough,
18
+ Subscript,
19
+ Superscript,
20
+ Underline,
21
+ Indent,
22
+ IndentBlock,
23
+ BlockQuote,
24
+ CodeBlock,
25
+ Emoji,
26
+ Mention,
27
+ FindAndReplace,
28
+ Font,
29
+ Heading,
30
+ Highlight,
31
+ HorizontalLine,
32
+ GeneralHtmlSupport,
33
+ HtmlComment,
34
+ HtmlEmbed,
35
+ Image,
36
+ ImageToolbar,
37
+ ImageCaption,
38
+ ImageStyle,
39
+ ImageResize,
40
+ LinkImage,
41
+ ImageInsert,
42
+ AutoImage,
43
+ ImageUpload,
44
+ Link,
45
+ AutoLink,
46
+ List,
47
+ TodoList,
48
+ MediaEmbed,
49
+ PageBreak,
50
+ PasteFromOffice,
51
+ PasteFromMarkdownExperimental,
52
+ RemoveFormat,
53
+ ShowBlocks,
54
+ SourceEditing,
55
+ SpecialCharacters,
56
+ SpecialCharactersEssentials,
57
+ Table,
58
+ TableToolbar,
59
+ TableProperties,
60
+ TableCellProperties,
61
+ TableColumnResize,
62
+ TableCaption,
63
+ TableLayout,
64
+ Alignment,
65
+ WordCount,
66
+ //====== Custom Plugins ======
67
+ AssetManager,
68
+ WordCountButtons
69
+ ];
70
+
71
+ export { builtinPlugins };
@@ -0,0 +1,41 @@
1
+ const headingConfig = {
2
+ options: [
3
+ {
4
+ model: "paragraph",
5
+ title: "Paragraph",
6
+ class: "ck-heading_paragraph"
7
+ },
8
+ {
9
+ model: "heading2",
10
+ view: "h2",
11
+ title: "Heading 2",
12
+ class: "ck-heading_heading2"
13
+ },
14
+ {
15
+ model: "heading3",
16
+ view: "h3",
17
+ title: "Heading 3",
18
+ class: "ck-heading_heading3"
19
+ },
20
+ {
21
+ model: "heading4",
22
+ view: "h4",
23
+ title: "Heading 4",
24
+ class: "ck-heading_heading4"
25
+ },
26
+ {
27
+ model: "heading5",
28
+ view: "h5",
29
+ title: "Heading 5",
30
+ class: "ck-heading_heading5"
31
+ },
32
+ {
33
+ model: "heading6",
34
+ view: "h6",
35
+ title: "Heading 6",
36
+ class: "ck-heading_heading6"
37
+ }
38
+ ]
39
+ };
40
+
41
+ export { headingConfig };
@@ -0,0 +1,32 @@
1
+ const imageConfig = {
2
+ toolbar: [
3
+ "toggleImageCaption",
4
+ "imageTextAlternative",
5
+ "|",
6
+ "imageStyle:alignBlockLeft",
7
+ "imageStyle:alignCenter",
8
+ "imageStyle:alignBlockRight",
9
+ "|",
10
+ "imageStyle:alignLeft",
11
+ "imageStyle:alignRight",
12
+ "|",
13
+ "imageStyle:inline",
14
+ "|",
15
+ "resizeImage",
16
+ "|",
17
+ "linkImage"
18
+ ],
19
+ resizeOptions: [
20
+ { name: "resizeImage:original", label: "Original", value: null },
21
+ { name: "resizeImage:custom", label: "Custom", value: "custom" },
22
+ { name: "resizeImage:25", label: "25%", value: "25" },
23
+ { name: "resizeImage:50", label: "50%", value: "50" },
24
+ { name: "resizeImage:75", label: "75%", value: "75" },
25
+ { name: "resizeImage:100", label: "100%", value: "100" }
26
+ ],
27
+ insert: {
28
+ integrations: ["upload", "url"]
29
+ }
30
+ };
31
+
32
+ export { imageConfig };
@@ -0,0 +1,15 @@
1
+ const tableConfig = {
2
+ contentToolbar: [
3
+ "toggleTableCaption",
4
+ "|",
5
+ "tableColumn",
6
+ "tableRow",
7
+ "|",
8
+ "mergeTableCells",
9
+ "|",
10
+ "tableProperties",
11
+ "tableCellProperties"
12
+ ]
13
+ };
14
+
15
+ export { tableConfig };
@@ -0,0 +1,112 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useRef } from 'react';
4
+ import 'ua-parser-js';
5
+ import { cn } from '../../../../../applications/shadcn/utils.js';
6
+ import 'next/navigation';
7
+ import 'lucide-react';
8
+ import 'intor/react';
9
+ import '@radix-ui/react-avatar';
10
+ import '../../../shadcn/badge.js';
11
+ import '../../../shadcn/button.js';
12
+ import '@radix-ui/react-collapsible';
13
+ import '@radix-ui/react-dialog';
14
+ import '@radix-ui/react-dropdown-menu';
15
+ import '../../../shadcn/input-group.js';
16
+ import '@radix-ui/react-label';
17
+ import '@radix-ui/react-select';
18
+ import '@radix-ui/react-separator';
19
+ import '../../../shadcn/sidebar.js';
20
+ import '@radix-ui/react-tooltip';
21
+ import 'next/link';
22
+ import '../../../../../../constants/paths/auth.js';
23
+ import '../../../../../../constants/paths/main.js';
24
+ import '../../../../../../constants/paths/resources.js';
25
+ import '../../../../../../constants/redirect-paths.js';
26
+ import 'mime-types';
27
+ import { FieldBody } from '../../form/field-body.js';
28
+ import '../../../../../../domain/resources/admin/constants.js';
29
+ import { PickModal } from '../../features/pick-modal/pick-modal.js';
30
+ import 'next/image';
31
+ import 'ckeditor5';
32
+ import { useControlAssetManager } from './plugins/asset-manager/use-control-asset-mamager.js';
33
+ import { useInitEditor } from './use-init-editor/use-init-editor.js';
34
+
35
+ function createEditor({
36
+ Uploader,
37
+ useCommand,
38
+ fileCreateAction,
39
+ UploadAdapter,
40
+ FileList,
41
+ storageUrl,
42
+ maxWidth,
43
+ queryClient
44
+ }) {
45
+ return function Editor({
46
+ // editor
47
+ locale,
48
+ value = "",
49
+ onEditorChange,
50
+ // ui states
51
+ isLoading = false,
52
+ isDisabled = false,
53
+ isError = false,
54
+ // base
55
+ className = "",
56
+ ...props
57
+ }) {
58
+ const containerRef = useRef(null);
59
+ const { execute } = useCommand(
60
+ (formData2) => fileCreateAction({ formData: formData2 }),
61
+ { clearAll: false }
62
+ );
63
+ const editorRef = useInitEditor({
64
+ enabled: !isLoading,
65
+ containerRef,
66
+ locale,
67
+ value,
68
+ onEditorChange,
69
+ createUploadAdapter: (loader) => new UploadAdapter(loader, execute, queryClient),
70
+ openAssetManager: () => setIsOpenAssetManager(true)
71
+ });
72
+ const { isOpenAssetManager, setIsOpenAssetManager, formData, setFormData } = useControlAssetManager(editorRef, storageUrl);
73
+ return /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs(
74
+ FieldBody,
75
+ {
76
+ className: cn(
77
+ className,
78
+ "focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",
79
+ "shadow-xs transition-[color,box-shadow]",
80
+ "rounded-lg",
81
+ "border",
82
+ isError && "border-destructive focus-within:ring-destructive/50",
83
+ "mx-auto"
84
+ ),
85
+ childrenClassName: "p-0",
86
+ style: { maxWidth },
87
+ isLoading,
88
+ isDisabled: isDisabled || isLoading,
89
+ ...props,
90
+ children: [
91
+ /* @__PURE__ */ jsx("div", { ref: containerRef }),
92
+ /* @__PURE__ */ jsx("div", { className: "hidden", children: /* @__PURE__ */ jsx(
93
+ PickModal,
94
+ {
95
+ isOpen: isOpenAssetManager,
96
+ setIsOpen: setIsOpenAssetManager,
97
+ fieldName: "file",
98
+ formData,
99
+ setFormData,
100
+ isLoading,
101
+ isDisabled,
102
+ itemList: /* @__PURE__ */ jsx(FileList, {}),
103
+ aboveManagementCard: /* @__PURE__ */ jsx(Uploader, { accept: "image/*" })
104
+ }
105
+ ) })
106
+ ]
107
+ }
108
+ ) });
109
+ };
110
+ }
111
+
112
+ export { createEditor };
@@ -0,0 +1,24 @@
1
+ import { Plugin, ButtonView } from 'ckeditor5';
2
+
3
+ const ASSET_MANAGER_PLUGIN_NAME = "asset-manager";
4
+ const OPEN_ASSET_MANAGER_KEY = "open-asset-manager";
5
+ class AssetManager extends Plugin {
6
+ init() {
7
+ const editor = this.editor;
8
+ editor.ui.componentFactory.add(ASSET_MANAGER_PLUGIN_NAME, () => {
9
+ const button = new ButtonView();
10
+ button.set({
11
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M1.201 1c-.662 0-1.2.47-1.2 1.1v14.248c0 .64.533 1.152 1.185 1.152h6.623v-7.236L6.617 9.15a.694.694 0 0 0-.957-.033L1.602 13.55V2.553l14.798.003V9.7H18V2.1c0-.63-.547-1.1-1.2-1.1zm11.723 2.805a2.1 2.1 0 0 0-1.621.832 2.127 2.127 0 0 0 1.136 3.357 2.13 2.13 0 0 0 2.611-1.506 2.13 2.13 0 0 0-.76-2.244 2.13 2.13 0 0 0-1.366-.44Z"/><path d="M19.898 12.369v6.187a.844.844 0 0 1-.844.844h-8.719a.844.844 0 0 1-.843-.844v-7.312a.844.844 0 0 1 .843-.844h2.531a.84.84 0 0 1 .597.248l.838.852h4.75c.223 0 .441.114.6.272a.84.84 0 0 1 .247.597m-1.52.654-4.377.02-1.1-1.143H11v6h7.4l-.023-4.877Z" clip-rule="evenodd"/></svg>`,
12
+ label: "Asset Manager",
13
+ tooltip: "Select a file from asset manager"
14
+ });
15
+ button.on("execute", () => {
16
+ const openAssetManager = editor.config.get(OPEN_ASSET_MANAGER_KEY);
17
+ openAssetManager?.();
18
+ });
19
+ return button;
20
+ });
21
+ }
22
+ }
23
+
24
+ export { ASSET_MANAGER_PLUGIN_NAME, AssetManager, OPEN_ASSET_MANAGER_KEY };
@@ -0,0 +1,26 @@
1
+ import { ImageUtils } from 'ckeditor5';
2
+ import { useTranslator } from 'intor/react';
3
+ import { useState, useEffect } from 'react';
4
+ import 'mime-types';
5
+ import { findTranslation } from '../../../../../../../../shared/translation/find-translation.js';
6
+ import { joinUrl } from '../../../../../../../../shared/utils/join-url.js';
7
+
8
+ const useControlAssetManager = (editorRef, storageUrl) => {
9
+ const { locale } = useTranslator();
10
+ const [isOpenAssetManager, setIsOpenAssetManager] = useState(false);
11
+ const [formData, setFormData] = useState({
12
+ file: null
13
+ });
14
+ useEffect(() => {
15
+ const { file } = formData;
16
+ if (!editorRef.current || !file) return;
17
+ const src = joinUrl(storageUrl, `${file.key}?id=${file.id}`);
18
+ const alt = findTranslation(file.translations, locale)?.alt ?? "";
19
+ const imageUtils = editorRef.current.plugins.get(ImageUtils.pluginName);
20
+ imageUtils.insertImage({ src, alt });
21
+ queueMicrotask(() => setFormData({ file: null }));
22
+ }, [editorRef, formData, locale]);
23
+ return { isOpenAssetManager, setIsOpenAssetManager, formData, setFormData };
24
+ };
25
+
26
+ export { useControlAssetManager };
@@ -0,0 +1,17 @@
1
+ const HTML_ICON = `
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640">
3
+ <path d="M392.8 65.2C375.8 60.3 358.1 70.2 353.2 87.2L225.2 535.2C220.3 552.2 230.2 569.9 247.2 574.8C264.2 579.7 281.9 569.8 286.8 552.8L414.8 104.8C419.7 87.8 409.8 70.1 392.8 65.2zM457.4 201.3C444.9 213.8 444.9 234.1 457.4 246.6L530.8 320L457.4 393.4C444.9 405.9 444.9 426.2 457.4 438.7C469.9 451.2 490.2 451.2 502.7 438.7L598.7 342.7C611.2 330.2 611.2 309.9 598.7 297.4L502.7 201.4C490.2 188.9 469.9 188.9 457.4 201.4zM182.7 201.3C170.2 188.8 149.9 188.8 137.4 201.3L41.4 297.3C28.9 309.8 28.9 330.1 41.4 342.6L137.4 438.6C149.9 451.1 170.2 451.1 182.7 438.6C195.2 426.1 195.2 405.8 182.7 393.3L109.3 320L182.6 246.6C195.1 234.1 195.1 213.8 182.6 201.3z"/>
4
+ </svg>
5
+ `;
6
+ const CHARACTERS_ICON = `
7
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640">
8
+ <path d="M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"/>
9
+ </svg>
10
+ `;
11
+ const WORDS_ICON = `
12
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640">
13
+ <path d="M192 112L304 112L304 200C304 239.8 336.2 272 376 272L464 272L464 512C464 520.8 456.8 528 448 528L192 528C183.2 528 176 520.8 176 512L176 128C176 119.2 183.2 112 192 112zM352 131.9L444.1 224L376 224C362.7 224 352 213.3 352 200L352 131.9zM192 64C156.7 64 128 92.7 128 128L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 250.5C512 233.5 505.3 217.2 493.3 205.2L370.7 82.7C358.7 70.7 342.5 64 325.5 64L192 64zM263.3 338.2C260.1 325.3 247.1 317.5 234.2 320.7C221.3 323.9 213.5 337 216.7 349.8L248.7 477.8C251.2 488 260.1 495.3 270.6 495.9C281.1 496.5 290.7 490.2 294.4 480.4L319.9 412.3L345.4 480.4C349.1 490.2 358.7 496.5 369.2 495.9C379.7 495.3 388.6 488 391.1 477.8L423.1 349.8C426.3 336.9 418.5 323.9 405.6 320.7C392.7 317.5 379.7 325.3 376.5 338.2L363.2 391.4L342.3 335.6C339 326.2 330 320 320 320C310 320 301 326.2 297.5 335.6L276.6 391.4L263.3 338.2z"/>
14
+ </svg>
15
+ `;
16
+
17
+ export { CHARACTERS_ICON, HTML_ICON, WORDS_ICON };
@@ -0,0 +1,81 @@
1
+ import { Plugin, ButtonView } from 'ckeditor5';
2
+ import 'mime-types';
3
+ import { debounce } from '../../../../../../../../shared/utils/debounce.js';
4
+ import { HTML_ICON, CHARACTERS_ICON, WORDS_ICON } from './icons.js';
5
+
6
+ const WORD_COUNT = "WordCount";
7
+ const WORD_COUNT_DISPLAY_PLUGIN_NAME = {
8
+ default: "word-count-display",
9
+ // CSS Class
10
+ characters: "word-count-display-characters",
11
+ // Plugin Name, CSS Class
12
+ words: "word-count-display-words",
13
+ // Plugin Name, CSS Class
14
+ html: "word-count-display-html"
15
+ // Plugin Name, CSS Class
16
+ };
17
+ class WordCountButtons extends Plugin {
18
+ init() {
19
+ const editor = this.editor;
20
+ const wordCountPlugin = editor.plugins.get(WORD_COUNT);
21
+ editor.ui.componentFactory.add(
22
+ WORD_COUNT_DISPLAY_PLUGIN_NAME.html,
23
+ (locale) => {
24
+ const button = new ButtonView(locale);
25
+ button.set({
26
+ icon: HTML_ICON,
27
+ label: `${editor.getData()?.length}`,
28
+ tooltip: true,
29
+ withText: true,
30
+ isEnabled: false,
31
+ class: `${WORD_COUNT_DISPLAY_PLUGIN_NAME.default} ${WORD_COUNT_DISPLAY_PLUGIN_NAME.html}`
32
+ });
33
+ const update = debounce(
34
+ () => button.label = `${editor.getData()?.length}`
35
+ );
36
+ editor.model.document.on("change:data", update);
37
+ return button;
38
+ }
39
+ );
40
+ editor.ui.componentFactory.add(
41
+ WORD_COUNT_DISPLAY_PLUGIN_NAME.characters,
42
+ (locale) => {
43
+ const button = new ButtonView(locale);
44
+ button.set({
45
+ icon: CHARACTERS_ICON,
46
+ label: `${wordCountPlugin.characters}`,
47
+ tooltip: true,
48
+ withText: true,
49
+ isEnabled: false,
50
+ class: `${WORD_COUNT_DISPLAY_PLUGIN_NAME.default} ${WORD_COUNT_DISPLAY_PLUGIN_NAME.characters}`
51
+ });
52
+ const update = debounce(
53
+ () => button.label = `${wordCountPlugin.characters}`
54
+ );
55
+ wordCountPlugin.on("change:characters", update);
56
+ return button;
57
+ }
58
+ );
59
+ editor.ui.componentFactory.add(
60
+ WORD_COUNT_DISPLAY_PLUGIN_NAME.words,
61
+ (locale) => {
62
+ const button = new ButtonView(locale);
63
+ button.set({
64
+ icon: WORDS_ICON,
65
+ label: `${wordCountPlugin.words}`,
66
+ tooltip: true,
67
+ withText: true,
68
+ isEnabled: false,
69
+ class: `${WORD_COUNT_DISPLAY_PLUGIN_NAME.default} ${WORD_COUNT_DISPLAY_PLUGIN_NAME.words}`
70
+ });
71
+ const update = debounce(
72
+ () => button.label = `${wordCountPlugin.words}`
73
+ );
74
+ wordCountPlugin.on("change:words", update);
75
+ return button;
76
+ }
77
+ );
78
+ }
79
+ }
80
+
81
+ export { WORD_COUNT_DISPLAY_PLUGIN_NAME, WordCountButtons as default };