@yimingliao/cms 0.0.146 → 0.0.147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/export/client/components/index.js +69 -0
- package/dist/src/client/applications/ui/use-parent-pathname.js +10 -0
- package/dist/src/client/interfaces/components/admin-initializer.js +29 -0
- package/dist/src/client/interfaces/components/resources/file/file-card.js +87 -0
- package/dist/src/client/interfaces/components/resources/file/file-list.js +159 -0
- package/dist/src/client/interfaces/components/resources/file/is-locked-buttons.js +71 -0
- package/dist/src/client/interfaces/components/resources/file/type-buttons.js +62 -0
- package/dist/src/client/interfaces/components/shadcn/sidebar.js +1 -1
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js +96 -0
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js +63 -0
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/pagination.js +94 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header-title.js +26 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header.js +74 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch-create.js +33 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch.js +39 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/create.js +33 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/edit.js +33 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/index.js +48 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/show.js +61 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/trash.js +39 -0
- package/dist/src/client/interfaces/components/ui/buttons/return-button.js +61 -0
- package/dist/src/client/interfaces/components/ui/cards/action-buttons-card.js +82 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-status-bar.js +51 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-text-content.js +38 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/resource-card.js +77 -0
- package/dist/src/client/interfaces/components/ui/display/array-list.js +69 -0
- package/dist/src/client/interfaces/components/ui/display/badge.js +41 -0
- package/dist/src/client/interfaces/components/ui/display/html-display.js +32 -0
- package/dist/src/client/interfaces/components/ui/display/object-array-list.js +75 -0
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion-container.js +31 -0
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion-header.js +34 -0
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion.js +81 -0
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expand-bar.js +39 -0
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list-content.js +49 -0
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list.js +53 -0
- package/dist/src/client/interfaces/components/ui/features/external-link.js +15 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-info/file-info.js +118 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-info/file-name.js +48 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-container.js +74 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-placeholder.js +48 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker.js +109 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-list.js +85 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-meta.js +40 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview.js +113 -0
- package/dist/src/client/interfaces/components/ui/features/file/uploader.js +101 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-body.js +112 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-trigger.js +97 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal.js +77 -0
- package/dist/src/client/interfaces/components/ui/features/smart-image.js +57 -0
- package/dist/src/client/interfaces/components/ui/features/tick.js +27 -0
- package/dist/src/client/interfaces/components/ui/form/containers/fields-container.js +24 -0
- package/dist/src/client/interfaces/components/ui/form/containers/main-fields.js +25 -0
- package/dist/src/client/interfaces/components/ui/form/containers/side-fields.js +24 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/built-in-fields.js +9 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-display.js +112 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-input.js +158 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields.js +59 -0
- package/dist/src/client/interfaces/components/ui/form/field-body.js +79 -0
- package/dist/src/client/interfaces/components/ui/form/index-field.js +87 -0
- package/dist/src/client/interfaces/components/ui/form/slug-field.js +82 -0
- package/dist/src/client/interfaces/components/ui/inputs/array-input.js +110 -0
- package/dist/src/client/interfaces/components/ui/inputs/checkbox.js +93 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/base-editor.js +143 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/built-in-plugins.js +71 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/heading.config.js +41 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/image.config.js +32 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/table.config.js +15 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/editor.js +112 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/asset-manager.js +24 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/use-control-asset-mamager.js +26 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/upload-adapter.js +84 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.js +17 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/word-count-display.js +81 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.js +50 -0
- package/dist/src/client/interfaces/components/ui/inputs/search-input.js +61 -0
- package/dist/src/client/interfaces/components/ui/inputs/select.js +69 -0
- package/dist/src/client/interfaces/components/ui/inputs/textarea.js +62 -0
- package/dist/src/client/interfaces/components/ui/layouts/content-container.js +38 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/i18n-selector.js +42 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/nav-user.js +106 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/navbar.js +84 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/sign-out-button.js +58 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/theme-selector.js +51 -0
- package/dist/src/client/interfaces/components/ui/layouts/sidebar/nav-main.js +99 -0
- package/dist/src/client/interfaces/styles/constants.js +3 -1
- package/dist/src/constants/file.js +27 -0
- package/dist/src/shared/list-items.js +3 -0
- package/dist/src/shared/utils/debounce.js +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'ua-parser-js';
|
|
5
|
+
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
6
|
+
import 'next/navigation';
|
|
7
|
+
import '@radix-ui/react-avatar';
|
|
8
|
+
import '../../shadcn/badge.js';
|
|
9
|
+
import '../../shadcn/button.js';
|
|
10
|
+
import '@radix-ui/react-collapsible';
|
|
11
|
+
import '@radix-ui/react-dialog';
|
|
12
|
+
import 'lucide-react';
|
|
13
|
+
import '@radix-ui/react-dropdown-menu';
|
|
14
|
+
import '../../shadcn/input-group.js';
|
|
15
|
+
import '@radix-ui/react-label';
|
|
16
|
+
import '@radix-ui/react-select';
|
|
17
|
+
import '@radix-ui/react-separator';
|
|
18
|
+
import '../../shadcn/sidebar.js';
|
|
19
|
+
import { Spinner } from '../../shadcn/spinner.js';
|
|
20
|
+
import '@radix-ui/react-tooltip';
|
|
21
|
+
|
|
22
|
+
function Checkbox({
|
|
23
|
+
// form context
|
|
24
|
+
fieldName,
|
|
25
|
+
formData,
|
|
26
|
+
setFormData,
|
|
27
|
+
// ui states
|
|
28
|
+
isLoading = false,
|
|
29
|
+
isDisabled = false,
|
|
30
|
+
// base
|
|
31
|
+
isDisplay = false,
|
|
32
|
+
className = "",
|
|
33
|
+
...props
|
|
34
|
+
}) {
|
|
35
|
+
isDisabled = isDisabled || isLoading || isDisplay;
|
|
36
|
+
const isChecked = !!formData?.[fieldName ?? ""];
|
|
37
|
+
return /* @__PURE__ */ jsxs(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: cn(
|
|
41
|
+
className,
|
|
42
|
+
"group relative",
|
|
43
|
+
"h-6 w-12 min-w-12",
|
|
44
|
+
"p-1",
|
|
45
|
+
"rounded-full",
|
|
46
|
+
"overflow-hidden",
|
|
47
|
+
"shadow-inner",
|
|
48
|
+
!isChecked || isLoading ? "bg-secondary" : "bg-success",
|
|
49
|
+
"transition"
|
|
50
|
+
),
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
className: cn(
|
|
56
|
+
"size-4",
|
|
57
|
+
"rounded-full",
|
|
58
|
+
"bg-white",
|
|
59
|
+
"shadow",
|
|
60
|
+
isChecked && "translate-x-6",
|
|
61
|
+
isLoading && "opacity-0",
|
|
62
|
+
!isDisabled && "group-hover:scale-95 group-active:scale-90",
|
|
63
|
+
"duration-200"
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
isLoading && /* @__PURE__ */ jsx("span", { className: "absolute top-1 left-1", children: /* @__PURE__ */ jsx(Spinner, {}) }),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
"input",
|
|
70
|
+
{
|
|
71
|
+
type: "checkbox",
|
|
72
|
+
onChange: (e) => {
|
|
73
|
+
if (!setFormData || !fieldName) return;
|
|
74
|
+
setFormData((p) => ({ ...p, [fieldName]: e.target.checked }));
|
|
75
|
+
},
|
|
76
|
+
checked: isChecked,
|
|
77
|
+
disabled: isDisabled,
|
|
78
|
+
className: cn(
|
|
79
|
+
"absolute top-0 left-0",
|
|
80
|
+
"h-full w-full",
|
|
81
|
+
"rounded-full",
|
|
82
|
+
"opacity-0",
|
|
83
|
+
isDisabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
84
|
+
),
|
|
85
|
+
...props
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { Checkbox };
|
|
@@ -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,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,84 @@
|
|
|
1
|
+
import { toast } from 'sonner';
|
|
2
|
+
import '../../../../../../../../constants/paths/auth.js';
|
|
3
|
+
import '../../../../../../../../constants/paths/main.js';
|
|
4
|
+
import '../../../../../../../../constants/paths/resources.js';
|
|
5
|
+
import { CACHE_KEYS } from '../../../../../../../../constants/cache-keys.js';
|
|
6
|
+
import '../../../../../../../../constants/redirect-paths.js';
|
|
7
|
+
import '../../../../../../../../domain/resources/admin/constants.js';
|
|
8
|
+
import { SIMPLE_UPLOAD_FOLDER_KEY } from '../../../../../../../../domain/resources/constants.js';
|
|
9
|
+
import 'mime-types';
|
|
10
|
+
import { getMediaInfo } from '../../../../../../../../shared/blob-file/get-media-info/get-media-info.js';
|
|
11
|
+
import { joinUrl } from '../../../../../../../../shared/utils/join-url.js';
|
|
12
|
+
|
|
13
|
+
function createUploadAdapter({
|
|
14
|
+
fileUploadApi,
|
|
15
|
+
buildTranslations,
|
|
16
|
+
logger,
|
|
17
|
+
storageUrl
|
|
18
|
+
}) {
|
|
19
|
+
return class UploadAdapter {
|
|
20
|
+
constructor(loader, execute, queryClient) {
|
|
21
|
+
this.loader = loader;
|
|
22
|
+
this.execute = execute;
|
|
23
|
+
this.queryClient = queryClient;
|
|
24
|
+
}
|
|
25
|
+
async upload() {
|
|
26
|
+
try {
|
|
27
|
+
const blobFile = await this.loader.file;
|
|
28
|
+
if (!blobFile || !(blobFile instanceof Blob)) {
|
|
29
|
+
throw new Error("Invalid file provided by loader.");
|
|
30
|
+
}
|
|
31
|
+
if (!blobFile.type.startsWith("image/")) {
|
|
32
|
+
throw new Error("Images Only");
|
|
33
|
+
}
|
|
34
|
+
const mediaInfo = await getMediaInfo(blobFile);
|
|
35
|
+
const response = await fileUploadApi({
|
|
36
|
+
blobFile,
|
|
37
|
+
folderKey: SIMPLE_UPLOAD_FOLDER_KEY,
|
|
38
|
+
folder: null
|
|
39
|
+
});
|
|
40
|
+
let key = "", checksum = "";
|
|
41
|
+
if (response.success) {
|
|
42
|
+
key = response.data?.key || "";
|
|
43
|
+
checksum = response.data?.checksum || "";
|
|
44
|
+
}
|
|
45
|
+
const { name, size, type } = blobFile;
|
|
46
|
+
const result = await this.execute({
|
|
47
|
+
key,
|
|
48
|
+
checksum,
|
|
49
|
+
fileMeta: { name, size, type },
|
|
50
|
+
folderKey: SIMPLE_UPLOAD_FOLDER_KEY,
|
|
51
|
+
folder: null,
|
|
52
|
+
width: mediaInfo.width,
|
|
53
|
+
height: mediaInfo.height,
|
|
54
|
+
translations: buildTranslations([
|
|
55
|
+
{ key: "name", value: null },
|
|
56
|
+
{ key: "alt", value: null }
|
|
57
|
+
])
|
|
58
|
+
});
|
|
59
|
+
if (result) {
|
|
60
|
+
await this.queryClient.invalidateQueries({
|
|
61
|
+
queryKey: [CACHE_KEYS.findListCards("file")]
|
|
62
|
+
});
|
|
63
|
+
const id = result.file.id;
|
|
64
|
+
return { default: joinUrl(storageUrl, `${key}?id=${id}`) };
|
|
65
|
+
} else {
|
|
66
|
+
return { default: "" };
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof Error) {
|
|
70
|
+
toast.error(error.message, {
|
|
71
|
+
position: "bottom-left",
|
|
72
|
+
duration: 4e3
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return { default: "" };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
abort() {
|
|
79
|
+
logger.debug("Image upload cancelled.");
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { createUploadAdapter };
|
package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.js
ADDED
|
@@ -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 };
|