@easyx/editor 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import type { EasyxEditorOptions } from '../types';
3
+ import { EventEmitter } from '../utils/event-emitter';
4
+ export declare function createEditorInstance(container: HTMLElement, options: EasyxEditorOptions): {
5
+ editor: Editor;
6
+ emitter: EventEmitter;
7
+ };
@@ -0,0 +1,21 @@
1
+ import { Node } from '@tiptap/core';
2
+ export interface AttachmentNodeOptions {
3
+ upload?: (file: File, onProgress?: (progress: number) => void) => Promise<{
4
+ url: string;
5
+ name?: string;
6
+ size?: number;
7
+ }>;
8
+ }
9
+ declare module '@tiptap/core' {
10
+ interface Commands<ReturnType> {
11
+ attachmentNode: {
12
+ setAttachment: (options: {
13
+ src: string;
14
+ name?: string;
15
+ size?: number;
16
+ }) => ReturnType;
17
+ };
18
+ }
19
+ }
20
+ declare const AttachmentNode: Node<AttachmentNodeOptions, any>;
21
+ export default AttachmentNode;
@@ -0,0 +1,17 @@
1
+ import { Node } from '@tiptap/core';
2
+ export interface AudioNodeOptions {
3
+ upload?: (file: File, onProgress?: (progress: number) => void) => Promise<{
4
+ url: string;
5
+ }>;
6
+ }
7
+ declare module '@tiptap/core' {
8
+ interface Commands<ReturnType> {
9
+ audioNode: {
10
+ setAudio: (options: {
11
+ src: string;
12
+ }) => ReturnType;
13
+ };
14
+ }
15
+ }
16
+ declare const AudioNode: Node<AudioNodeOptions, any>;
17
+ export default AudioNode;
@@ -0,0 +1,20 @@
1
+ import type { Editor } from '@tiptap/core';
2
+ import type { Node } from '@tiptap/pm/model';
3
+ import type { NodeView } from '@tiptap/pm/view';
4
+ /** 图片可缩放 NodeView 配置 */
5
+ export interface ImageNodeViewResizeOptions {
6
+ minWidth: number;
7
+ minHeight: number;
8
+ }
9
+ export interface ImageNodeViewProps {
10
+ node: Node;
11
+ editor: Editor;
12
+ getPos: () => number | undefined;
13
+ HTMLAttributes: Record<string, unknown>;
14
+ }
15
+ /**
16
+ * 图片可缩放 NodeView:尺寸落在 wrapper 上(img 以 100% 填满),
17
+ * 四角手柄相对 wrapper 定位,随图片尺寸同步移动。
18
+ * 支持像素与百分比两种宽度,拖动时按当前单位提交并保持纵横比。
19
+ */
20
+ export declare function createImageNodeView(props: ImageNodeViewProps, resize: ImageNodeViewResizeOptions): NodeView;
@@ -0,0 +1,23 @@
1
+ export type ImageAlign = 'left' | 'center' | 'right';
2
+ /** 图片缩放配置 */
3
+ export interface ImageResizeOptions {
4
+ enabled: boolean;
5
+ minWidth?: number;
6
+ minHeight?: number;
7
+ }
8
+ export interface ImageUploadOptions {
9
+ upload: (file: File, onProgress?: (progress: number) => void) => Promise<{
10
+ url: string;
11
+ }>;
12
+ /** 是否开启拖拽缩放(自定义 NodeView,支持像素与百分比宽度) */
13
+ resize?: ImageResizeOptions | false;
14
+ }
15
+ declare module '@tiptap/core' {
16
+ interface Commands<ReturnType> {
17
+ imageUpload: {
18
+ setImageAlign: (align: ImageAlign) => ReturnType;
19
+ };
20
+ }
21
+ }
22
+ declare const ImageUpload: import("@tiptap/core").Node<ImageUploadOptions, any>;
23
+ export default ImageUpload;
@@ -0,0 +1,12 @@
1
+ import { Extension } from '@tiptap/core';
2
+ declare module '@tiptap/core' {
3
+ interface Commands<ReturnType> {
4
+ indent: {
5
+ /** 直接设置缩进 em 值 */
6
+ setIndent: (value: number) => ReturnType;
7
+ /** 切换缩进:有缩进则清除,无缩进则应用 step em */
8
+ toggleIndent: (step: number) => ReturnType;
9
+ };
10
+ }
11
+ }
12
+ export declare const Indent: Extension<any, any>;
@@ -0,0 +1,3 @@
1
+ import { Extension } from '@tiptap/core';
2
+ /** 在可编辑态用 Cmd/Ctrl+Click 或 Alt+Enter 打开光标/点击处的链接 */
3
+ export declare const LinkOpen: Extension<any, any>;
@@ -0,0 +1,11 @@
1
+ import type { Node } from '@tiptap/pm/model';
2
+ import type { NodeView } from '@tiptap/pm/view';
3
+ export interface VideoNodeViewProps {
4
+ node: Node;
5
+ HTMLAttributes: Record<string, unknown>;
6
+ }
7
+ /**
8
+ * 视频 NodeView:复用同一个 <video> 元素,属性更新时只同步发生变化的值,
9
+ * 避免重建 DOM 或重复赋值 src 触发重新加载导致编辑器闪动。
10
+ */
11
+ export declare function createVideoNodeView(props: VideoNodeViewProps): NodeView;
@@ -0,0 +1,19 @@
1
+ import { Node } from '@tiptap/core';
2
+ export type VideoAlign = 'left' | 'center' | 'right';
3
+ export interface VideoNodeOptions {
4
+ upload?: (file: File, onProgress?: (progress: number) => void) => Promise<{
5
+ url: string;
6
+ }>;
7
+ }
8
+ declare module '@tiptap/core' {
9
+ interface Commands<ReturnType> {
10
+ videoNode: {
11
+ setVideo: (options: {
12
+ src: string;
13
+ }) => ReturnType;
14
+ setVideoAlign: (align: VideoAlign) => ReturnType;
15
+ };
16
+ }
17
+ }
18
+ declare const VideoNode: Node<VideoNodeOptions, any>;
19
+ export default VideoNode;