@haklex/rich-ext-gallery 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Innei
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+
24
+ Additional Terms and Conditions
25
+
26
+ ----------------
27
+
28
+ Use of this software is governed by the terms of MIT and, in addition, by the terms and conditions described in the additional file (ADDITIONAL_TERMS.md). By using this software, you agree to abide by these additional terms and conditions.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @haklex/rich-ext-gallery
2
+
3
+ 图片画廊扩展。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add @haklex/rich-ext-gallery @haklex/rich-editor
9
+ ```
10
+
11
+ ## 导出
12
+
13
+ ```ts
14
+ // 节点
15
+ export { GalleryNode } from './GalleryNode'
16
+ export { $createGalleryNode, $isGalleryNode } from './GalleryNode'
17
+ export type { GalleryNodePayload, SerializedGalleryNode } from './GalleryNode'
18
+
19
+ // 渲染器
20
+ export { GalleryRenderer } from './GalleryRenderer'
21
+ export { GalleryEditRenderer } from './GalleryEditRenderer'
22
+
23
+ // 节点集合
24
+ export const galleryNodes: Array<Klass<LexicalNode>>
25
+ ```
26
+
27
+ ## 使用
28
+
29
+ ```tsx
30
+ import { GalleryRenderer, galleryNodes } from '@haklex/rich-ext-gallery'
31
+ import { RichRenderer } from '@haklex/rich-editor/renderer'
32
+ import type { RendererConfig } from '@haklex/rich-editor'
33
+
34
+ const config: RendererConfig = {
35
+ Gallery: GalleryRenderer,
36
+ }
37
+
38
+ <RichRenderer
39
+ value={content}
40
+ rendererConfig={config}
41
+ extraNodes={[...galleryNodes]}
42
+ />
43
+ ```
44
+
45
+ ## License
46
+
47
+ MIT
@@ -0,0 +1,4 @@
1
+ import { GalleryRendererProps } from '@haklex/rich-editor';
2
+ import { FC } from 'react';
3
+ export declare const GalleryEditRenderer: FC<GalleryRendererProps>;
4
+ //# sourceMappingURL=GalleryEditRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GalleryEditRenderer.d.ts","sourceRoot":"","sources":["../src/GalleryEditRenderer.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAgB,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAY7E,OAAO,KAAK,EAAiB,EAAE,EAAE,MAAM,OAAO,CAAA;AAmV9C,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,oBAAoB,CAmExD,CAAA"}
@@ -0,0 +1,32 @@
1
+ import { GalleryImage, SlashMenuItemConfig } from '@haklex/rich-editor';
2
+ import { EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread, DecoratorNode } from 'lexical';
3
+ import { ReactElement } from 'react';
4
+ export type SerializedGalleryNode = Spread<{
5
+ images: GalleryImage[];
6
+ layout?: 'grid' | 'masonry' | 'carousel';
7
+ }, SerializedLexicalNode>;
8
+ export interface GalleryNodePayload {
9
+ images: GalleryImage[];
10
+ layout?: 'grid' | 'masonry' | 'carousel';
11
+ }
12
+ export declare class GalleryNode extends DecoratorNode<ReactElement> {
13
+ __images: GalleryImage[];
14
+ __layout: 'grid' | 'masonry' | 'carousel';
15
+ static slashMenuItems: SlashMenuItemConfig[];
16
+ static getType(): string;
17
+ static clone(node: GalleryNode): GalleryNode;
18
+ constructor(payload: GalleryNodePayload, key?: NodeKey);
19
+ createDOM(_config: EditorConfig): HTMLElement;
20
+ updateDOM(): boolean;
21
+ isInline(): boolean;
22
+ static importJSON(serializedNode: SerializedGalleryNode): GalleryNode;
23
+ exportJSON(): SerializedGalleryNode;
24
+ getImages(): GalleryImage[];
25
+ setImages(images: GalleryImage[]): void;
26
+ getLayout(): 'grid' | 'masonry' | 'carousel';
27
+ setLayout(layout: 'grid' | 'masonry' | 'carousel'): void;
28
+ decorate(editor: LexicalEditor, _config: EditorConfig): ReactElement;
29
+ }
30
+ export declare function $createGalleryNode(payload: GalleryNodePayload): GalleryNode;
31
+ export declare function $isGalleryNode(node: LexicalNode | null | undefined): node is GalleryNode;
32
+ //# sourceMappingURL=GalleryNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GalleryNode.d.ts","sourceRoot":"","sources":["../src/GalleryNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,EAA+B,aAAa,EAAE,MAAM,SAAS,CAAA;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAKzC,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC;IACE,MAAM,EAAE,YAAY,EAAE,CAAA;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+1,6 @@
1
+ import { GalleryRendererProps } from '@haklex/rich-editor';
2
+ import { ComponentType } from 'react';
3
+ export declare const GalleryRenderer: ComponentType<GalleryRendererProps>;
4
+ declare const _default: import('react').NamedExoticComponent<GalleryRendererProps>;
5
+ export default _default;
6
+ //# sourceMappingURL=GalleryRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GalleryRenderer.d.ts","sourceRoot":"","sources":["../src/GalleryRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,4CAA4C,CAAA;AAEnD,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAA;AAyC1D,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,oBAAoB,CA2L/D,CAAA;;AAuBD,wBAAoC"}
@@ -0,0 +1,7 @@
1
+ import { Klass, LexicalNode } from 'lexical';
2
+ export { GalleryEditRenderer } from './GalleryEditRenderer';
3
+ export type { GalleryNodePayload, SerializedGalleryNode } from './GalleryNode';
4
+ export { $createGalleryNode, $isGalleryNode, GalleryNode } from './GalleryNode';
5
+ export { default, GalleryRenderer } from './GalleryRenderer';
6
+ export declare const galleryNodes: Array<Klass<LexicalNode>>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAIjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC/E,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAE5D,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAiB,CAAA"}