@atlaskit/editor-plugin-paste 0.1.22 → 0.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/.eslintrc.js +18 -0
- package/CHANGELOG.md +12 -0
- package/dist/cjs/actions.js +12 -0
- package/dist/cjs/commands.js +255 -0
- package/dist/cjs/edge-cases/index.js +88 -0
- package/dist/cjs/edge-cases/lists.js +107 -0
- package/dist/cjs/handlers.js +939 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/plugin.js +43 -0
- package/dist/cjs/plugins/media.js +207 -0
- package/dist/cjs/pm-plugins/analytics.js +376 -0
- package/dist/cjs/pm-plugins/clipboard-text-serializer.js +43 -0
- package/dist/cjs/pm-plugins/main.js +484 -0
- package/dist/cjs/pm-plugins/plugin-factory.js +42 -0
- package/dist/cjs/reducer.js +41 -0
- package/dist/cjs/util/index.js +214 -0
- package/dist/cjs/util/tinyMCE.js +183 -0
- package/dist/es2019/actions.js +6 -0
- package/dist/es2019/commands.js +236 -0
- package/dist/es2019/edge-cases/index.js +87 -0
- package/dist/es2019/edge-cases/lists.js +113 -0
- package/dist/es2019/handlers.js +919 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/plugin.js +38 -0
- package/dist/es2019/plugins/media.js +204 -0
- package/dist/es2019/pm-plugins/analytics.js +332 -0
- package/dist/es2019/pm-plugins/clipboard-text-serializer.js +37 -0
- package/dist/es2019/pm-plugins/main.js +453 -0
- package/dist/es2019/pm-plugins/plugin-factory.js +30 -0
- package/dist/es2019/reducer.js +32 -0
- package/dist/es2019/util/index.js +209 -0
- package/dist/es2019/util/tinyMCE.js +168 -0
- package/dist/esm/actions.js +6 -0
- package/dist/esm/commands.js +249 -0
- package/dist/esm/edge-cases/index.js +81 -0
- package/dist/esm/edge-cases/lists.js +98 -0
- package/dist/esm/handlers.js +918 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugin.js +37 -0
- package/dist/esm/plugins/media.js +199 -0
- package/dist/esm/pm-plugins/analytics.js +364 -0
- package/dist/esm/pm-plugins/clipboard-text-serializer.js +37 -0
- package/dist/esm/pm-plugins/main.js +471 -0
- package/dist/esm/pm-plugins/plugin-factory.js +36 -0
- package/dist/esm/reducer.js +34 -0
- package/dist/esm/util/index.js +194 -0
- package/dist/esm/util/tinyMCE.js +176 -0
- package/dist/types/actions.d.ts +21 -0
- package/dist/types/commands.d.ts +29 -0
- package/dist/types/edge-cases/index.d.ts +11 -0
- package/dist/types/edge-cases/lists.d.ts +18 -0
- package/dist/types/handlers.d.ts +55 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/plugins/media.d.ts +23 -0
- package/dist/types/pm-plugins/analytics.d.ts +44 -0
- package/dist/types/pm-plugins/clipboard-text-serializer.d.ts +13 -0
- package/dist/types/pm-plugins/main.d.ts +12 -0
- package/dist/types/pm-plugins/plugin-factory.d.ts +3 -0
- package/dist/types/reducer.d.ts +3 -0
- package/dist/types/util/index.d.ts +21 -0
- package/dist/types/util/tinyMCE.d.ts +32 -0
- package/dist/types-ts4.5/actions.d.ts +21 -0
- package/dist/types-ts4.5/commands.d.ts +29 -0
- package/dist/types-ts4.5/edge-cases/index.d.ts +11 -0
- package/dist/types-ts4.5/edge-cases/lists.d.ts +18 -0
- package/dist/types-ts4.5/handlers.d.ts +55 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +2 -0
- package/dist/types-ts4.5/plugins/media.d.ts +23 -0
- package/dist/types-ts4.5/pm-plugins/analytics.d.ts +44 -0
- package/dist/types-ts4.5/pm-plugins/clipboard-text-serializer.d.ts +13 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +3 -0
- package/dist/types-ts4.5/reducer.d.ts +3 -0
- package/dist/types-ts4.5/util/index.d.ts +21 -0
- package/dist/types-ts4.5/util/tinyMCE.d.ts +32 -0
- package/package.json +18 -6
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const isPastedFromTinyMCEConfluence: (pasteEvent: ClipboardEvent, html: string) => boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Wraps html markup with a `<table>` and uses `DOMParser` to generate
|
|
4
|
+
* and return both the table-wrapped and non-table-wrapped DOM document
|
|
5
|
+
* instances.
|
|
6
|
+
*/
|
|
7
|
+
export declare const wrapWithTable: (html: string) => {
|
|
8
|
+
tableWrappedDoc: Document;
|
|
9
|
+
nonTableWrappedDoc: Document;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Given a DOM document, it will try to rebuild table rows by using the
|
|
13
|
+
* table headers count as an initial starting point for the assumed
|
|
14
|
+
* number of columns that make up a row (`colsInRow`). It will slowly
|
|
15
|
+
* decrease that `colsInRow` count until it finds exact fit for table
|
|
16
|
+
* headers and cells with `colsInRow` else it returns the original
|
|
17
|
+
* document's markup.
|
|
18
|
+
*
|
|
19
|
+
* NOTE: It will NOT try to rebuild table rows if it encounters merged cells
|
|
20
|
+
* or compex table configurations (where table headers exist after normal
|
|
21
|
+
* table cells). It will build a single column table if NO table
|
|
22
|
+
* headers exist.
|
|
23
|
+
*/
|
|
24
|
+
export declare const tryReconstructTableRows: (doc: Document) => string;
|
|
25
|
+
export declare const htmlHasIncompleteTable: (html: string) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Strictly for ED-7331. Given incomplete table html from tinyMCE, it will try to rebuild
|
|
28
|
+
* a whole valid table. If it rebuilds the table, it may first rebuild it as a single
|
|
29
|
+
* row table, so this also then tries to reconstruct the table rows/columns if
|
|
30
|
+
* possible (best effort).
|
|
31
|
+
*/
|
|
32
|
+
export declare const tryRebuildCompleteTableHtml: (incompleteTableHtml: string) => string | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LastContentPasted } from './types';
|
|
2
|
+
export declare enum PastePluginActionTypes {
|
|
3
|
+
START_TRACKING_PASTED_MACRO_POSITIONS = "START_TRACKING_PASTED_MACRO_POSITIONS",
|
|
4
|
+
STOP_TRACKING_PASTED_MACRO_POSITIONS = "STOP_TRACKING_PASTED_MACRO_POSITIONS",
|
|
5
|
+
ON_PASTE = "ON_PASTE"
|
|
6
|
+
}
|
|
7
|
+
export interface StartTrackingPastedMacroPositions {
|
|
8
|
+
type: PastePluginActionTypes.START_TRACKING_PASTED_MACRO_POSITIONS;
|
|
9
|
+
pastedMacroPositions: {
|
|
10
|
+
[key: string]: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface OnPaste {
|
|
14
|
+
type: PastePluginActionTypes.ON_PASTE;
|
|
15
|
+
contentPasted: LastContentPasted;
|
|
16
|
+
}
|
|
17
|
+
export interface StopTrackingPastedMacroPositions {
|
|
18
|
+
type: PastePluginActionTypes.STOP_TRACKING_PASTED_MACRO_POSITIONS;
|
|
19
|
+
pastedMacroPositionKeys: string[];
|
|
20
|
+
}
|
|
21
|
+
export type PastePluginAction = StartTrackingPastedMacroPositions | StopTrackingPastedMacroPositions | OnPaste;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Mark, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
/**
|
|
4
|
+
* Use this to register macro link positions during a paste operation, that you
|
|
5
|
+
* want to track in a document over time, through any document changes.
|
|
6
|
+
*
|
|
7
|
+
* @param positions a map of string keys (custom position references) and position values e.g. { ['my-key-1']: 11 }
|
|
8
|
+
*
|
|
9
|
+
* **Context**: This is neccessary if there is an async process or an unknown period of time
|
|
10
|
+
* between obtaining an original position, and wanting to know about what its final eventual
|
|
11
|
+
* value. In that scenario, positions will need to be actively tracked and mapped in plugin
|
|
12
|
+
* state so that they can be mapped through any other independent document change transactions being
|
|
13
|
+
* dispatched to the editor that could affect their value.
|
|
14
|
+
*/
|
|
15
|
+
export declare const startTrackingPastedMacroPositions: (pastedMacroPositions: {
|
|
16
|
+
[key: string]: number;
|
|
17
|
+
}) => import("@atlaskit/editor-common/types").Command;
|
|
18
|
+
export declare const stopTrackingPastedMacroPositions: (pastedMacroPositionKeys: string[]) => import("@atlaskit/editor-common/types").Command;
|
|
19
|
+
export declare const upgradeTextToLists: (slice: Slice, schema: Schema) => Slice;
|
|
20
|
+
export declare const splitParagraphs: (slice: Slice, schema: Schema) => Slice;
|
|
21
|
+
/**
|
|
22
|
+
* Walks the slice, creating paragraphs that were previously separated by hardbreaks.
|
|
23
|
+
* Returns the original paragraph node (as a fragment), or a fragment containing multiple nodes.
|
|
24
|
+
*/
|
|
25
|
+
export declare const splitIntoParagraphs: ({ fragment, blockMarks, schema, }: {
|
|
26
|
+
fragment: Fragment;
|
|
27
|
+
blockMarks?: readonly Mark[] | undefined;
|
|
28
|
+
schema: Schema;
|
|
29
|
+
}) => Fragment;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare function insertSliceForLists({ tr, slice, schema, }: {
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
slice: Slice;
|
|
6
|
+
schema: Schema;
|
|
7
|
+
}): void | Transaction;
|
|
8
|
+
export declare function insertSliceForListsInsideBlockquote({ tr, slice, }: {
|
|
9
|
+
tr: Transaction;
|
|
10
|
+
slice: Slice;
|
|
11
|
+
}): Transaction | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare function insertSliceIntoEmptyNode({ tr, slice, }: {
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
slice: Slice;
|
|
6
|
+
}): void;
|
|
7
|
+
export declare function insertSliceAtNodeEdge({ tr, slice, }: {
|
|
8
|
+
tr: Transaction;
|
|
9
|
+
slice: Slice;
|
|
10
|
+
}): void;
|
|
11
|
+
export declare function insertSliceIntoRangeSelectionInsideList({ tr, slice, }: {
|
|
12
|
+
tr: Transaction;
|
|
13
|
+
slice: Slice;
|
|
14
|
+
}): Transaction | undefined;
|
|
15
|
+
export declare function insertSliceInsideOfPanelNodeSelected(panelNode: PMNode): ({ tr, slice }: {
|
|
16
|
+
tr: Transaction;
|
|
17
|
+
slice: Slice;
|
|
18
|
+
}) => void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI, InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { CardOptions, QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
|
|
3
|
+
import type { ExtensionAutoConvertHandler } from '@atlaskit/editor-common/extensions';
|
|
4
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { RunMacroAutoConvert } from '@atlaskit/editor-plugin-extension';
|
|
6
|
+
import type { FindRootParentListNode } from '@atlaskit/editor-plugin-list';
|
|
7
|
+
import type { InsertMediaAsMediaSingle } from '@atlaskit/editor-plugin-media/types';
|
|
8
|
+
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
9
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
10
|
+
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
+
export declare function handleMention(slice: Slice, schema: Schema): Slice;
|
|
12
|
+
export declare function handlePasteIntoTaskOrDecisionOrPanel(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined): Command;
|
|
13
|
+
export declare function handlePasteNonNestableBlockNodesIntoList(slice: Slice): Command;
|
|
14
|
+
export declare const doesSelectionWhichStartsOrEndsInListContainEntireList: (selection: Selection, findRootParentListNode: FindRootParentListNode | undefined) => boolean;
|
|
15
|
+
export declare function handlePastePanelOrDecisionContentIntoList(slice: Slice, findRootParentListNode: FindRootParentListNode | undefined): Command;
|
|
16
|
+
export declare function handlePasteLinkOnSelectedText(slice: Slice): Command;
|
|
17
|
+
export declare function handlePasteAsPlainText(slice: Slice, _event: ClipboardEvent, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): Command;
|
|
18
|
+
export declare function handlePastePreservingMarks(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined): Command;
|
|
19
|
+
export declare function handleMacroAutoConvert(text: string, slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined, runMacroAutoConvert: RunMacroAutoConvert | undefined, cardsOptions?: CardOptions, extensionAutoConverter?: ExtensionAutoConvertHandler): Command;
|
|
20
|
+
export declare function handleCodeBlock(text: string): Command;
|
|
21
|
+
export declare function handleMediaSingle(inputMethod: InputMethodInsertMedia, insertMediaAsMediaSingle: InsertMediaAsMediaSingle | undefined): (slice: Slice) => Command;
|
|
22
|
+
export declare function handleExpandPasteInTable(slice: Slice): Command;
|
|
23
|
+
export declare function handleMarkdown(markdownSlice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined, from?: number, to?: number): Command;
|
|
24
|
+
export declare function handleParagraphBlockMarks(state: EditorState, slice: Slice): Slice;
|
|
25
|
+
/**
|
|
26
|
+
* ED-6300: When a nested list is pasted in a table cell and the slice has openStart > openEnd,
|
|
27
|
+
* it splits the table. As a workaround, we flatten the list to even openStart and openEnd.
|
|
28
|
+
*
|
|
29
|
+
* Note: this only happens if the first child is a list
|
|
30
|
+
*
|
|
31
|
+
* Example: copying "one" and "two"
|
|
32
|
+
* - zero
|
|
33
|
+
* - one
|
|
34
|
+
* - two
|
|
35
|
+
*
|
|
36
|
+
* Before:
|
|
37
|
+
* ul
|
|
38
|
+
* ┗━ li
|
|
39
|
+
* ┗━ ul
|
|
40
|
+
* ┗━ li
|
|
41
|
+
* ┗━ p -> "one"
|
|
42
|
+
* ┗━ li
|
|
43
|
+
* ┗━ p -> "two"
|
|
44
|
+
*
|
|
45
|
+
* After:
|
|
46
|
+
* ul
|
|
47
|
+
* ┗━ li
|
|
48
|
+
* ┗━ p -> "one"
|
|
49
|
+
* ┗━ li
|
|
50
|
+
* ┗━p -> "two"
|
|
51
|
+
*/
|
|
52
|
+
export declare function flattenNestedListInSlice(slice: Slice): Slice;
|
|
53
|
+
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined): Command;
|
|
54
|
+
export declare function handlePasteIntoCaption(slice: Slice): Command;
|
|
55
|
+
export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
/**
|
|
4
|
+
* Ensure correct layout in nested mode
|
|
5
|
+
*
|
|
6
|
+
* TODO: this func is only used in handlePaste, so layout update won't work for drop event
|
|
7
|
+
*/
|
|
8
|
+
export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
|
|
9
|
+
export declare const isImage: (fileType?: string) => boolean;
|
|
10
|
+
export declare const transformSliceToCorrectMediaWrapper: (slice: Slice, schema: Schema) => Slice;
|
|
11
|
+
/**
|
|
12
|
+
* This func will be called when copy & paste, drag & drop external html with media, media files, and slices from editor
|
|
13
|
+
* Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare const transformSliceToMediaSingleWithNewExperience: (slice: Slice, schema: Schema) => Slice;
|
|
17
|
+
/**
|
|
18
|
+
* Given a html string, we attempt to hoist any nested `<img>` tags,
|
|
19
|
+
* not directly wrapped by a `<div>` as ProseMirror no-op's
|
|
20
|
+
* on those scenarios.
|
|
21
|
+
* @param html
|
|
22
|
+
*/
|
|
23
|
+
export declare const unwrapNestedMediaElements: (html: string) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AnalyticsEventPayload, EditorAnalyticsAPI, PasteContent, PasteType } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { FindRootParentListNode } from '@atlaskit/editor-plugin-list';
|
|
4
|
+
import type { InsertMediaAsMediaSingle } from '@atlaskit/editor-plugin-media/types';
|
|
5
|
+
import type { Fragment, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import type { PastePlugin } from '../index';
|
|
8
|
+
type PasteContext = {
|
|
9
|
+
type: PasteType;
|
|
10
|
+
asPlain?: boolean;
|
|
11
|
+
/** Has the hyperlink been pasted while text is selected, making the text into a link? */
|
|
12
|
+
hyperlinkPasteOnText?: boolean;
|
|
13
|
+
/** Did this paste action split a list in half? */
|
|
14
|
+
pasteSplitList?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type GetContentProps = {
|
|
17
|
+
schema: Schema;
|
|
18
|
+
slice: Slice;
|
|
19
|
+
};
|
|
20
|
+
export declare function getContent({ schema, slice }: GetContentProps): PasteContent;
|
|
21
|
+
export declare function getMediaTraceId(slice: Slice): undefined;
|
|
22
|
+
export declare function createPasteAnalyticsPayload(view: EditorView, event: ClipboardEvent, slice: Slice, pasteContext: PasteContext): AnalyticsEventPayload;
|
|
23
|
+
export declare const sendPasteAnalyticsEvent: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, pasteContext: PasteContext) => void;
|
|
24
|
+
export declare const handlePasteAsPlainTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
25
|
+
export declare const handlePasteIntoTaskAndDecisionWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
26
|
+
export declare const handlePasteIntoCaptionWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType) => Command;
|
|
27
|
+
export declare const handleCodeBlockWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, text: string) => Command;
|
|
28
|
+
export declare const handleMediaSingleWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType, insertMediaAsMediaSingle: InsertMediaAsMediaSingle | undefined) => Command;
|
|
29
|
+
export declare const handlePastePreservingMarksWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
30
|
+
export declare const handleMarkdownWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
31
|
+
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
32
|
+
export declare const handlePastePanelOrDecisionIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, findRootParentListNode: FindRootParentListNode | undefined) => Command;
|
|
33
|
+
export declare const handlePasteNonNestableBlockNodesIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
34
|
+
export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
35
|
+
export declare const handleSelectedTableWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
36
|
+
export declare const handlePasteLinkOnSelectedTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType) => Command;
|
|
37
|
+
export declare const createPasteMeasurePayload: ({ view, duration, content, distortedDuration, }: {
|
|
38
|
+
view: EditorView;
|
|
39
|
+
duration: number;
|
|
40
|
+
content: Array<string>;
|
|
41
|
+
distortedDuration: boolean;
|
|
42
|
+
}) => AnalyticsEventPayload;
|
|
43
|
+
export declare const getContentNodeTypes: (content: Fragment) => string[];
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
4
|
+
* section of the clipboard on copy.
|
|
5
|
+
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
6
|
+
* previously were empty on plain text copy).
|
|
7
|
+
* Unknown nodes are passed to node.textBetween().
|
|
8
|
+
*
|
|
9
|
+
* By default (without this function passed to the editor), the editor uses
|
|
10
|
+
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
11
|
+
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
12
|
+
*/
|
|
13
|
+
export declare function clipboardTextSerializer(slice: Slice): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
4
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
|
+
import type { ExtractInjectionAPI, FeatureFlags } from '@atlaskit/editor-common/types';
|
|
7
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import type { PastePlugin } from '../index';
|
|
10
|
+
export { pluginKey as stateKey } from './plugin-factory';
|
|
11
|
+
export declare const isInsideBlockQuote: (state: EditorState) => boolean;
|
|
12
|
+
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("../types").PastePluginState>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const pluginKey: PluginKey<any>;
|
|
3
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("..").PastePluginState | ((state: import("prosemirror-state").EditorState) => import("..").PastePluginState)) => import("prosemirror-state").SafeStateField<import("..").PastePluginState>, createCommand: <A = import("../actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("..").PastePluginState;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI, PasteSource } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
|
+
import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { Mark, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
export declare function isPastedFromWord(html?: string): boolean;
|
|
7
|
+
export declare function isPastedFromExcel(html?: string): boolean;
|
|
8
|
+
export declare const isSingleLine: (text: string) => boolean;
|
|
9
|
+
export declare function htmlContainsSingleFile(html: string): boolean;
|
|
10
|
+
export declare function getPasteSource(event: ClipboardEvent): PasteSource;
|
|
11
|
+
export declare function escapeLinks(text: string): string;
|
|
12
|
+
export declare function hasOnlyNodesOfType(...nodeTypes: NodeType[]): (slice: Slice) => boolean;
|
|
13
|
+
export declare function applyTextMarksToSlice(schema: Schema, marks?: readonly Mark[]): (slice: Slice) => Slice;
|
|
14
|
+
export declare function isEmptyNode(node: PMNode | null | undefined): boolean | null;
|
|
15
|
+
export declare function isCursorSelectionAtTextStartOrEnd(selection: Selection): boolean | null;
|
|
16
|
+
export declare function isPanelNode(node: PMNode | null | undefined): boolean;
|
|
17
|
+
export declare function isSelectionInsidePanel(selection: Selection): PMNode | null;
|
|
18
|
+
export declare const htmlHasInvalidLinkTags: (html?: string) => boolean;
|
|
19
|
+
export declare const removeDuplicateInvalidLinks: (html: string) => string;
|
|
20
|
+
export declare const addReplaceSelectedTableAnalytics: (state: EditorState, tr: Transaction, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Transaction;
|
|
21
|
+
export declare const transformUnsupportedBlockCardToInline: (slice: Slice, state: EditorState, cardOptions?: CardOptions) => Slice;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const isPastedFromTinyMCEConfluence: (pasteEvent: ClipboardEvent, html: string) => boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Wraps html markup with a `<table>` and uses `DOMParser` to generate
|
|
4
|
+
* and return both the table-wrapped and non-table-wrapped DOM document
|
|
5
|
+
* instances.
|
|
6
|
+
*/
|
|
7
|
+
export declare const wrapWithTable: (html: string) => {
|
|
8
|
+
tableWrappedDoc: Document;
|
|
9
|
+
nonTableWrappedDoc: Document;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Given a DOM document, it will try to rebuild table rows by using the
|
|
13
|
+
* table headers count as an initial starting point for the assumed
|
|
14
|
+
* number of columns that make up a row (`colsInRow`). It will slowly
|
|
15
|
+
* decrease that `colsInRow` count until it finds exact fit for table
|
|
16
|
+
* headers and cells with `colsInRow` else it returns the original
|
|
17
|
+
* document's markup.
|
|
18
|
+
*
|
|
19
|
+
* NOTE: It will NOT try to rebuild table rows if it encounters merged cells
|
|
20
|
+
* or compex table configurations (where table headers exist after normal
|
|
21
|
+
* table cells). It will build a single column table if NO table
|
|
22
|
+
* headers exist.
|
|
23
|
+
*/
|
|
24
|
+
export declare const tryReconstructTableRows: (doc: Document) => string;
|
|
25
|
+
export declare const htmlHasIncompleteTable: (html: string) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Strictly for ED-7331. Given incomplete table html from tinyMCE, it will try to rebuild
|
|
28
|
+
* a whole valid table. If it rebuilds the table, it may first rebuild it as a single
|
|
29
|
+
* row table, so this also then tries to reconstruct the table rows/columns if
|
|
30
|
+
* possible (best effort).
|
|
31
|
+
*/
|
|
32
|
+
export declare const tryRebuildCompleteTableHtml: (incompleteTableHtml: string) => string | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,15 +32,23 @@
|
|
|
32
32
|
".": "./src/index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@atlaskit/editor-common": "^76.
|
|
35
|
+
"@atlaskit/editor-common": "^76.30.0",
|
|
36
|
+
"@atlaskit/editor-markdown-transformer": "^5.2.5",
|
|
36
37
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
37
38
|
"@atlaskit/editor-plugin-annotation": "^0.1.0",
|
|
38
39
|
"@atlaskit/editor-plugin-better-type-history": "^0.1.0",
|
|
39
40
|
"@atlaskit/editor-plugin-card": "^0.14.0",
|
|
40
41
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
41
42
|
"@atlaskit/editor-plugin-list": "^3.0.0",
|
|
42
|
-
"@atlaskit/editor-plugin-media": "^0.
|
|
43
|
-
"@
|
|
43
|
+
"@atlaskit/editor-plugin-media": "^0.9.0",
|
|
44
|
+
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
45
|
+
"@atlaskit/editor-tables": "^2.3.0",
|
|
46
|
+
"@atlaskit/media-client": "^26.1.0",
|
|
47
|
+
"@atlaskit/media-common": "^11.0.0",
|
|
48
|
+
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
49
|
+
"@babel/runtime": "^7.0.0",
|
|
50
|
+
"lodash": "^4.17.21",
|
|
51
|
+
"uuid": "^3.1.0"
|
|
44
52
|
},
|
|
45
53
|
"peerDependencies": {
|
|
46
54
|
"react": "^16.8.0"
|
|
@@ -50,7 +58,6 @@
|
|
|
50
58
|
"@atlaskit/adf-schema": "^35.2.0",
|
|
51
59
|
"@atlaskit/editor-plugin-history": "^0.1.0",
|
|
52
60
|
"@atlaskit/editor-plugin-type-ahead": "^0.8.0",
|
|
53
|
-
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
54
61
|
"@atlaskit/ssr": "*",
|
|
55
62
|
"@atlaskit/visual-regression": "*",
|
|
56
63
|
"@atlaskit/webdriver-runner": "*",
|
|
@@ -103,5 +110,10 @@
|
|
|
103
110
|
"@atlassian/tangerine/project-structure"
|
|
104
111
|
]
|
|
105
112
|
},
|
|
106
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
113
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|
|
114
|
+
"platform-feature-flags": {
|
|
115
|
+
"platform.editor.media.extended-resize-experience": {
|
|
116
|
+
"type": "boolean"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
107
119
|
}
|