slate-angular 17.1.3 → 17.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slate-angular",
3
- "version": "17.1.3",
3
+ "version": "17.2.1",
4
4
  "description": "Angular view layer for Slate",
5
5
  "author": "pubuzhixing <pubuzhixing@gmail.com>",
6
6
  "homepage": "https://github.com/worktile/slate-angular#readme",
@@ -4,14 +4,15 @@ import { Injector } from '@angular/core';
4
4
  import { NodeEntry } from 'slate';
5
5
  import { SlateError } from '../types/error';
6
6
  import { Key } from '../utils/key';
7
+ import { OriginEvent } from '../types/clipboard';
7
8
  /**
8
9
  * An Angular and DOM-specific version of the `Editor` interface.
9
10
  */
10
11
  export interface AngularEditor extends BaseEditor {
11
12
  insertData: (data: DataTransfer) => void;
12
- insertFragmentData: (data: DataTransfer) => boolean;
13
- insertTextData: (data: DataTransfer) => boolean;
14
- setFragmentData: (data: DataTransfer, originEvent?: 'drag' | 'copy' | 'cut') => void;
13
+ insertFragmentData: (data: DataTransfer) => Promise<boolean>;
14
+ insertTextData: (data: DataTransfer) => Promise<boolean>;
15
+ setFragmentData: (data: DataTransfer, originEvent?: OriginEvent) => void;
15
16
  deleteCutData: () => void;
16
17
  onKeydown: (event: KeyboardEvent) => void;
17
18
  onClick: (event: MouseEvent) => void;
@@ -80,11 +81,11 @@ export declare const AngularEditor: {
80
81
  /**
81
82
  * Insert fragment data from a `DataTransfer` into the editor.
82
83
  */
83
- insertFragmentData(editor: AngularEditor, data: DataTransfer): boolean;
84
+ insertFragmentData(editor: AngularEditor, data: DataTransfer): Promise<boolean>;
84
85
  /**
85
86
  * Insert text data from a `DataTransfer` into the editor.
86
87
  */
87
- insertTextData(editor: AngularEditor, data: DataTransfer): boolean;
88
+ insertTextData(editor: AngularEditor, data: DataTransfer): Promise<boolean>;
88
89
  /**
89
90
  * onKeydown hook.
90
91
  */
@@ -96,7 +97,7 @@ export declare const AngularEditor: {
96
97
  /**
97
98
  * Sets data from the currently selected fragment on a `DataTransfer`.
98
99
  */
99
- setFragmentData(editor: AngularEditor, data: DataTransfer, originEvent?: 'drag' | 'copy' | 'cut'): void;
100
+ setFragmentData(editor: AngularEditor, data: DataTransfer, originEvent?: OriginEvent): void;
100
101
  deleteCutData(editor: AngularEditor): void;
101
102
  /**
102
103
  * Find the native DOM element from a Slate node.
@@ -0,0 +1,8 @@
1
+ import { Element } from 'slate';
2
+ export interface ClipboardData {
3
+ files?: File[];
4
+ elements?: Element[];
5
+ text?: string;
6
+ html?: string;
7
+ }
8
+ export type OriginEvent = 'drag' | 'copy' | 'cut';
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './error';
2
2
  export * from './view';
3
3
  export * from './feature';
4
+ export * from './clipboard';
4
5
  export type SafeAny = any;
@@ -0,0 +1,12 @@
1
+ import { Element } from 'slate';
2
+ import { ClipboardData } from '../../types/clipboard';
3
+ export declare const buildHTMLText: (wrapper: HTMLElement, attach: HTMLElement, data: Element[]) => string;
4
+ export declare const getClipboardFromHTMLText: (html: string) => ClipboardData;
5
+ export declare const createClipboardData: (html: string, elements: Element[], text: string, files: File[]) => ClipboardData;
6
+ export declare const getClipboardData: (dataTransfer?: DataTransfer) => Promise<ClipboardData>;
7
+ /**
8
+ * @param wrapper get wrapper.innerHTML string which will be written in clipboard
9
+ * @param attach attach must be child element of wrapper which will be attached json data
10
+ * @returns void
11
+ */
12
+ export declare const setClipboardData: (clipboardData: ClipboardData, wrapper: HTMLElement, attach: HTMLElement, dataTransfer?: Pick<DataTransfer, 'getData' | 'setData'>) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ export declare const isClipboardReadSupported: () => boolean;
2
+ export declare const isClipboardWriteSupported: () => boolean;
3
+ export declare const isClipboardWriteTextSupported: () => boolean;
4
+ export declare const isClipboardFile: (item: ClipboardItem) => string;
5
+ export declare const stripHtml: (html: string) => string;
6
+ export declare const blobAsString: (blob: Blob) => Promise<string>;
@@ -0,0 +1,5 @@
1
+ import { ClipboardData } from '../../types/clipboard';
2
+ export declare const setDataTransferClipboard: (dataTransfer: Pick<DataTransfer, 'getData' | 'setData'> | null, htmlText: string) => void;
3
+ export declare const setDataTransferClipboardText: (data: Pick<DataTransfer, 'getData' | 'setData'> | null, text: string) => void;
4
+ export declare const getDataTransferClipboard: (data: Pick<DataTransfer, 'getData' | 'setData'> | null) => ClipboardData;
5
+ export declare const getDataTransferClipboardText: (data: Pick<DataTransfer, 'getData' | 'setData'> | null) => ClipboardData;
@@ -0,0 +1,4 @@
1
+ export * from './clipboard';
2
+ export * from './data-transfer';
3
+ export * from './navigator-clipboard';
4
+ export * from './common';
@@ -0,0 +1,4 @@
1
+ import { Element } from 'slate';
2
+ import { ClipboardData } from '../../types/clipboard';
3
+ export declare const setNavigatorClipboard: (htmlText: string, data: Element[], text?: string) => Promise<void>;
4
+ export declare const getNavigatorClipboard: () => Promise<ClipboardData>;
package/utils/dom.d.ts CHANGED
@@ -70,9 +70,5 @@ export declare const getEditableChild: (parent: DOMElement, index: number, direc
70
70
  * The domNode must be attached to the DOM.
71
71
  */
72
72
  export declare const getPlainText: (domNode: DOMNode) => string;
73
- export declare const getSlateFragmentAttribute: (dataTransfer: DataTransfer) => string | void;
74
- /**
75
- * Get the x-slate-fragment attribute that exist in text/html data
76
- * and append it to the DataTransfer object
77
- */
78
- export declare const getClipboardData: (dataTransfer: DataTransfer, clipboardFormatKey?: string) => DataTransfer;
73
+ export declare const SlateFragmentAttributeKey = "data-slate-angular-fragment";
74
+ export declare const getSlateFragmentAttribute: (htmlData: string) => string | void;
package/utils/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './range-list';
8
8
  export * from './block-card';
9
9
  export * from './global-normalize';
10
10
  export * from './throttle';
11
+ export * from './clipboard';