@thangph2146/nextjs-editor 1.0.2 → 1.0.3
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/README.md +1 -1
- package/dist/index.cjs +6 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -27
- package/dist/index.js.map +1 -1
- package/dist/uploads-hooks.cjs +89 -0
- package/dist/uploads-hooks.cjs.map +1 -0
- package/dist/uploads-hooks.d.cts +79 -0
- package/dist/uploads-hooks.d.ts +79 -0
- package/dist/uploads-hooks.js +59 -0
- package/dist/uploads-hooks.js.map +1 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ export function MyEditor() {
|
|
|
61
61
|
|
|
62
62
|
## Ghi chú
|
|
63
63
|
|
|
64
|
-
- **Ảnh**: Trong bản standalone, dialog chèn ảnh
|
|
64
|
+
- **Ảnh**: Trong bản standalone, dialog chèn ảnh chỉ có tab **URL** và **File**. Để tab **Thư viện** hiển thị ảnh từ API của project, trong `next.config` (webpack) thêm alias: `"@thangph2146/nextjs-editor/uploads-hooks"` → đường dẫn tới file hooks uploads của app (ví dụ `src/features/uploads/hooks/use-uploads-queries.ts`). Hook cần export `useImagesList(page, limit)` trả về `{ data: { data: { folderTree, pagination } }, isLoading }` với `folderTree` có cấu trúc `FolderNode` (name, path, images, subfolders).
|
|
65
65
|
- **Next.js**: Package dùng `next/image` và `next/dynamic` khi chạy trong Next.js; cần cài `next` trong project.
|
|
66
66
|
|
|
67
67
|
## Build từ source
|
package/dist/index.cjs
CHANGED
|
@@ -1166,32 +1166,6 @@ var init_tabs = __esm({
|
|
|
1166
1166
|
}
|
|
1167
1167
|
});
|
|
1168
1168
|
|
|
1169
|
-
// src/features/uploads/hooks/use-uploads-queries.ts
|
|
1170
|
-
var emptyFolderTree, useImagesList;
|
|
1171
|
-
var init_use_uploads_queries = __esm({
|
|
1172
|
-
"src/features/uploads/hooks/use-uploads-queries.ts"() {
|
|
1173
|
-
"use strict";
|
|
1174
|
-
emptyFolderTree = {
|
|
1175
|
-
name: "",
|
|
1176
|
-
path: "",
|
|
1177
|
-
images: [],
|
|
1178
|
-
subfolders: []
|
|
1179
|
-
};
|
|
1180
|
-
useImagesList = (_page = 1, _limit = 50) => ({
|
|
1181
|
-
data: {
|
|
1182
|
-
success: true,
|
|
1183
|
-
data: {
|
|
1184
|
-
data: [],
|
|
1185
|
-
folderTree: emptyFolderTree,
|
|
1186
|
-
pagination: { page: 1, limit: 50, total: 0, totalPages: 0 }
|
|
1187
|
-
}
|
|
1188
|
-
},
|
|
1189
|
-
isLoading: false,
|
|
1190
|
-
isError: false
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
|
-
});
|
|
1194
|
-
|
|
1195
1169
|
// src/components/ui/collapsible.tsx
|
|
1196
1170
|
function Collapsible({
|
|
1197
1171
|
className,
|
|
@@ -1449,7 +1423,7 @@ function InsertImageUploadsDialogBody({
|
|
|
1449
1423
|
const [altText, setAltText] = (0, import_react5.useState)("");
|
|
1450
1424
|
const [openFolders, setOpenFolders] = (0, import_react5.useState)(/* @__PURE__ */ new Set());
|
|
1451
1425
|
const limit = 100;
|
|
1452
|
-
const { data: imagesData, isLoading } = useImagesList(1, limit);
|
|
1426
|
+
const { data: imagesData, isLoading } = (0, import_uploads_hooks.useImagesList)(1, limit);
|
|
1453
1427
|
const folderTree = imagesData?.data?.folderTree;
|
|
1454
1428
|
const isDisabled = !selectedImage;
|
|
1455
1429
|
const handleImageSelect = React6.useCallback((imageUrl, originalName) => {
|
|
@@ -1744,7 +1718,7 @@ function getDragSelection(event) {
|
|
|
1744
1718
|
}
|
|
1745
1719
|
return range;
|
|
1746
1720
|
}
|
|
1747
|
-
var import_react5, React6, import_LexicalComposerContext2, import_utils14, import_lexical5, import_lucide_react3, import_image, import_jsx_runtime13, getDOMSelection, INSERT_IMAGE_COMMAND;
|
|
1721
|
+
var import_react5, React6, import_LexicalComposerContext2, import_utils14, import_lexical5, import_uploads_hooks, import_lucide_react3, import_image, import_jsx_runtime13, getDOMSelection, INSERT_IMAGE_COMMAND;
|
|
1748
1722
|
var init_images_plugin = __esm({
|
|
1749
1723
|
"src/components/editor/plugins/images-plugin.tsx"() {
|
|
1750
1724
|
"use strict";
|
|
@@ -1761,7 +1735,7 @@ var init_images_plugin = __esm({
|
|
|
1761
1735
|
init_input();
|
|
1762
1736
|
init_label();
|
|
1763
1737
|
init_tabs();
|
|
1764
|
-
|
|
1738
|
+
import_uploads_hooks = require("@thangph2146/nextjs-editor/uploads-hooks");
|
|
1765
1739
|
import_lucide_react3 = require("lucide-react");
|
|
1766
1740
|
import_image = __toESM(require("next/image"), 1);
|
|
1767
1741
|
init_collapsible();
|
|
@@ -19644,12 +19618,12 @@ var init_emoji_list = __esm({
|
|
|
19644
19618
|
});
|
|
19645
19619
|
|
|
19646
19620
|
// src/index.tsx
|
|
19647
|
-
var
|
|
19648
|
-
__export(
|
|
19621
|
+
var src_exports = {};
|
|
19622
|
+
__export(src_exports, {
|
|
19649
19623
|
Editor: () => Editor,
|
|
19650
19624
|
editorThemePath: () => editorThemePath
|
|
19651
19625
|
});
|
|
19652
|
-
module.exports = __toCommonJS(
|
|
19626
|
+
module.exports = __toCommonJS(src_exports);
|
|
19653
19627
|
|
|
19654
19628
|
// src/components/editor/editor-x/editor.tsx
|
|
19655
19629
|
var import_LexicalComposer = require("@lexical/react/LexicalComposer");
|