@atlaskit/editor-wikimarkup-transformer 11.2.1 → 11.2.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/CHANGELOG.md +12 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types-ts4.5/char.d.ts +1 -0
- package/dist/types-ts4.5/encoder/emoji-unicode-mapping.d.ts +3 -0
- package/dist/types-ts4.5/encoder/index.d.ts +9 -0
- package/dist/types-ts4.5/encoder/marks/__base.d.ts +5 -0
- package/dist/types-ts4.5/encoder/marks/code.d.ts +2 -0
- package/dist/types-ts4.5/encoder/marks/color.d.ts +2 -0
- package/dist/types-ts4.5/encoder/marks/em.d.ts +2 -0
- package/dist/types-ts4.5/encoder/marks/link.d.ts +2 -0
- package/dist/types-ts4.5/encoder/marks/strike.d.ts +2 -0
- package/dist/types-ts4.5/encoder/marks/strong.d.ts +6 -0
- package/dist/types-ts4.5/encoder/marks/subsup.d.ts +2 -0
- package/dist/types-ts4.5/encoder/marks/underline.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/block-card.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/blockquote.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/bullet-list.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/caption.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/code-block.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/date.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/decisionItem.d.ts +3 -0
- package/dist/types-ts4.5/encoder/nodes/decisionList.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/doc.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/embed-card.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/emoji.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/expand.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/hard-break.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/heading.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/inline-card.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/inlines.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/listItem.d.ts +3 -0
- package/dist/types-ts4.5/encoder/nodes/media-group.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/media-inline.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/media.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/mention.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/ordered-list.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/panel.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/paragraph.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/rule.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/status.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/table.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/taskItem.d.ts +3 -0
- package/dist/types-ts4.5/encoder/nodes/taskList.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/text.d.ts +2 -0
- package/dist/types-ts4.5/encoder/nodes/unknown.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +15 -0
- package/dist/types-ts4.5/interfaces.d.ts +74 -0
- package/dist/types-ts4.5/parser/abstract-tree.d.ts +11 -0
- package/dist/types-ts4.5/parser/builder/list-builder.d.ts +66 -0
- package/dist/types-ts4.5/parser/builder/table-builder.d.ts +45 -0
- package/dist/types-ts4.5/parser/color.d.ts +3 -0
- package/dist/types-ts4.5/parser/error.d.ts +1 -0
- package/dist/types-ts4.5/parser/nodes/mediaGroup.d.ts +3 -0
- package/dist/types-ts4.5/parser/nodes/mediaSingle.d.ts +5 -0
- package/dist/types-ts4.5/parser/nodes/paragraph.d.ts +7 -0
- package/dist/types-ts4.5/parser/nodes/rule.d.ts +3 -0
- package/dist/types-ts4.5/parser/nodes/text.d.ts +2 -0
- package/dist/types-ts4.5/parser/text.d.ts +10 -0
- package/dist/types-ts4.5/parser/tokenize/adf-macro.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/anchor-macro.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/blockquote.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/citation.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/code-macro.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/color-macro.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/common-formatter.d.ts +10 -0
- package/dist/types-ts4.5/parser/tokenize/common-macro.d.ts +10 -0
- package/dist/types-ts4.5/parser/tokenize/dash-token-creator.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/deleted.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/double-dash-symbol.d.ts +1 -0
- package/dist/types-ts4.5/parser/tokenize/emoji.d.ts +15 -0
- package/dist/types-ts4.5/parser/tokenize/emphasis.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/file-link.d.ts +3 -0
- package/dist/types-ts4.5/parser/tokenize/force-line-break.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/hardbreak.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/heading.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/index.d.ts +55 -0
- package/dist/types-ts4.5/parser/tokenize/inserted.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/issue-key.d.ts +20 -0
- package/dist/types-ts4.5/parser/tokenize/keyword.d.ts +19 -0
- package/dist/types-ts4.5/parser/tokenize/link-text.d.ts +3 -0
- package/dist/types-ts4.5/parser/tokenize/links/attachment-link.d.ts +4 -0
- package/dist/types-ts4.5/parser/tokenize/links/issue-link.d.ts +4 -0
- package/dist/types-ts4.5/parser/tokenize/links/link-format.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/links/link-parser.d.ts +17 -0
- package/dist/types-ts4.5/parser/tokenize/links/link-resolver.d.ts +5 -0
- package/dist/types-ts4.5/parser/tokenize/links/mention-link.d.ts +4 -0
- package/dist/types-ts4.5/parser/tokenize/links/url-link.d.ts +4 -0
- package/dist/types-ts4.5/parser/tokenize/list.d.ts +3 -0
- package/dist/types-ts4.5/parser/tokenize/media.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/monospace.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/noformat-macro.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/panel-macro.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/quadruple-dash-symbol.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/quote-macro.d.ts +5 -0
- package/dist/types-ts4.5/parser/tokenize/ruler.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/strong.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/subscript.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/superscript.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/table.d.ts +2 -0
- package/dist/types-ts4.5/parser/tokenize/triple-dash-symbol.d.ts +1 -0
- package/dist/types-ts4.5/parser/tokenize/whitespace.d.ts +3 -0
- package/dist/types-ts4.5/parser/utils/attrs.d.ts +3 -0
- package/dist/types-ts4.5/parser/utils/color-name-mapping.d.ts +10 -0
- package/dist/types-ts4.5/parser/utils/escape.d.ts +2 -0
- package/dist/types-ts4.5/parser/utils/normalize.d.ts +4 -0
- package/dist/types-ts4.5/parser/utils/panel-type.d.ts +3 -0
- package/dist/types-ts4.5/parser/utils/text.d.ts +25 -0
- package/dist/types-ts4.5/parser/utils/title.d.ts +7 -0
- package/dist/types-ts4.5/parser/utils/url.d.ts +8 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-wikimarkup-transformer
|
|
2
2
|
|
|
3
|
+
## 11.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
|
|
8
|
+
|
|
9
|
+
## 11.2.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`a142ba1aa28`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a142ba1aa28) - [ED17172] Bump prosemirror-model to 1.16.0 and prosemirror-view to 1.23.7 and removed work-arounds for fixed issues
|
|
14
|
+
|
|
3
15
|
## 11.2.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/version.json
CHANGED
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EM_DASH = "\u2014";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { Context } from '../interfaces';
|
|
3
|
+
export type MarkEncoder = (text: string, attrs: any) => string;
|
|
4
|
+
export type NodeEncoder = (node: PMNode, opts?: NodeEncoderOpts) => string;
|
|
5
|
+
export type NodeEncoderOpts = {
|
|
6
|
+
parent?: PMNode;
|
|
7
|
+
context?: Context;
|
|
8
|
+
};
|
|
9
|
+
export declare function encode(node: PMNode, context?: Context): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import { Context } from './interfaces';
|
|
3
|
+
interface Transformer<T> {
|
|
4
|
+
encode(node: PMNode): T;
|
|
5
|
+
parse(content: T): PMNode;
|
|
6
|
+
}
|
|
7
|
+
export declare class WikiMarkupTransformer implements Transformer<string> {
|
|
8
|
+
private schema;
|
|
9
|
+
constructor(schema?: Schema);
|
|
10
|
+
private sanitizeWikiMarkup;
|
|
11
|
+
encode(node: PMNode, context?: Context): string;
|
|
12
|
+
parse(wikiMarkup: string, context?: Context): PMNode;
|
|
13
|
+
private buildContext;
|
|
14
|
+
}
|
|
15
|
+
export default WikiMarkupTransformer;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
export interface AddArgs {
|
|
3
|
+
style: string | null;
|
|
4
|
+
content: PMNode[];
|
|
5
|
+
}
|
|
6
|
+
export interface Builder {
|
|
7
|
+
type: string;
|
|
8
|
+
/**
|
|
9
|
+
* Add a item to the builder
|
|
10
|
+
* @param {AddCellArgs[]} items
|
|
11
|
+
*/
|
|
12
|
+
add(items: AddArgs[]): void;
|
|
13
|
+
/**
|
|
14
|
+
* Compile a prosemirror node from the root list
|
|
15
|
+
* @returns {PMNode}
|
|
16
|
+
*/
|
|
17
|
+
buildPMNode(): PMNode;
|
|
18
|
+
}
|
|
19
|
+
export interface ListItem {
|
|
20
|
+
content?: any[];
|
|
21
|
+
parent: List;
|
|
22
|
+
children: List[];
|
|
23
|
+
}
|
|
24
|
+
export interface List {
|
|
25
|
+
children: ListItem[];
|
|
26
|
+
type: ListType;
|
|
27
|
+
parent?: ListItem;
|
|
28
|
+
}
|
|
29
|
+
export type ListType = 'bulletList' | 'orderedList';
|
|
30
|
+
export type CellType = 'tableHeader' | 'tableCell';
|
|
31
|
+
export interface TableCell {
|
|
32
|
+
type: CellType;
|
|
33
|
+
content: PMNode[];
|
|
34
|
+
}
|
|
35
|
+
export interface TableRow {
|
|
36
|
+
cells: TableCell[];
|
|
37
|
+
}
|
|
38
|
+
export interface Table {
|
|
39
|
+
rows: TableRow[];
|
|
40
|
+
}
|
|
41
|
+
export interface AddCellArgs extends AddArgs {
|
|
42
|
+
style: string;
|
|
43
|
+
content: PMNode[];
|
|
44
|
+
}
|
|
45
|
+
export interface ConversionMap {
|
|
46
|
+
[key: string]: string;
|
|
47
|
+
}
|
|
48
|
+
export interface MediaConversionMap {
|
|
49
|
+
[key: string]: {
|
|
50
|
+
transform?: string;
|
|
51
|
+
embed?: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export type TokenErrCallback = (err: Error, tokenType: string) => void;
|
|
55
|
+
export interface Context {
|
|
56
|
+
readonly issueKeyRegex?: RegExp | undefined;
|
|
57
|
+
readonly tokenErrCallback?: TokenErrCallback;
|
|
58
|
+
readonly conversion?: {
|
|
59
|
+
readonly inlineCardConversion?: ConversionMap;
|
|
60
|
+
readonly mediaConversion?: MediaConversionMap;
|
|
61
|
+
mentionConversion?: ConversionMap;
|
|
62
|
+
};
|
|
63
|
+
readonly hydration?: {
|
|
64
|
+
readonly media?: {
|
|
65
|
+
targetCollectionId?: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly defaults?: {
|
|
69
|
+
readonly media?: {
|
|
70
|
+
width: number | null;
|
|
71
|
+
height: number | null;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import { Context } from '../interfaces';
|
|
3
|
+
export default class AbstractTree {
|
|
4
|
+
private schema;
|
|
5
|
+
private wikiMarkup;
|
|
6
|
+
constructor(schema: Schema, wikiMarkup: string);
|
|
7
|
+
/**
|
|
8
|
+
* Convert reduced macros tree into prosemirror model tree
|
|
9
|
+
*/
|
|
10
|
+
getProseMirrorModel(context: Context): PMNode;
|
|
11
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import { AddArgs, ListType } from '../../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Return the type of a list from the bullets
|
|
5
|
+
*/
|
|
6
|
+
export declare function getType(bullets: string): ListType;
|
|
7
|
+
export declare class ListBuilder {
|
|
8
|
+
private schema;
|
|
9
|
+
private root;
|
|
10
|
+
private lastDepth;
|
|
11
|
+
private lastList;
|
|
12
|
+
constructor(schema: Schema, bullets: string);
|
|
13
|
+
/**
|
|
14
|
+
* Return the type of the base list
|
|
15
|
+
* @returns {ListType}
|
|
16
|
+
*/
|
|
17
|
+
get type(): ListType;
|
|
18
|
+
/**
|
|
19
|
+
* Add a list item to the builder
|
|
20
|
+
* @param {AddArgs[]} items
|
|
21
|
+
*/
|
|
22
|
+
add(items: AddArgs[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Compile a prosemirror node from the root list
|
|
25
|
+
* @returns {PMNode[]}
|
|
26
|
+
*/
|
|
27
|
+
buildPMNode(): PMNode[];
|
|
28
|
+
/**
|
|
29
|
+
* Build prosemirror bulletList or orderedList node
|
|
30
|
+
* @param {List} list
|
|
31
|
+
* @returns {PMNode}
|
|
32
|
+
*/
|
|
33
|
+
private parseList;
|
|
34
|
+
/**
|
|
35
|
+
* Build prosemirror listItem node
|
|
36
|
+
* This function would possibly return non listItem nodes
|
|
37
|
+
* which we need to break out later
|
|
38
|
+
* @param {ListItem} item
|
|
39
|
+
*/
|
|
40
|
+
private parseListItem;
|
|
41
|
+
private isParagraphEmptyTextNode;
|
|
42
|
+
private createListItem;
|
|
43
|
+
/**
|
|
44
|
+
* Add an item at the same level as the current list item
|
|
45
|
+
* @param {ListType} type
|
|
46
|
+
* @param {PMNode} content
|
|
47
|
+
* @returns {PMNode}
|
|
48
|
+
*/
|
|
49
|
+
private addListItem;
|
|
50
|
+
/**
|
|
51
|
+
* Append the past content to the last accessed list node (multiline entries)
|
|
52
|
+
* @param {PMNode[]} content
|
|
53
|
+
*/
|
|
54
|
+
private appendToLastItem;
|
|
55
|
+
/**
|
|
56
|
+
* Created a nested list structure of N depth under the current node
|
|
57
|
+
* @param {number} depth
|
|
58
|
+
* @param {ListType} type
|
|
59
|
+
*/
|
|
60
|
+
private createNest;
|
|
61
|
+
/**
|
|
62
|
+
* Find the Nth list ancestor of the current list
|
|
63
|
+
* @param {number} depth
|
|
64
|
+
*/
|
|
65
|
+
private findAncestor;
|
|
66
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import { AddCellArgs, Builder } from '../../interfaces';
|
|
3
|
+
export declare class TableBuilder implements Builder {
|
|
4
|
+
private schema;
|
|
5
|
+
private root;
|
|
6
|
+
private lastRow?;
|
|
7
|
+
constructor(schema: Schema);
|
|
8
|
+
/**
|
|
9
|
+
* Return the type of the base element
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
get type(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Add new cells to the table
|
|
15
|
+
* @param {AddCellArgs[]} cells
|
|
16
|
+
*/
|
|
17
|
+
add(cells: AddCellArgs[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* Build a prosemirror table from the data
|
|
20
|
+
* @returns {PMNode}
|
|
21
|
+
*/
|
|
22
|
+
buildPMNode(): PMNode;
|
|
23
|
+
private emptyTableCell;
|
|
24
|
+
private emptyTableRow;
|
|
25
|
+
/**
|
|
26
|
+
* Build prosemirror table node
|
|
27
|
+
* @returns {PMNode}
|
|
28
|
+
*/
|
|
29
|
+
private buildTableNode;
|
|
30
|
+
/**
|
|
31
|
+
* Build prosemirror tr node
|
|
32
|
+
* @returns {PMNode}
|
|
33
|
+
*/
|
|
34
|
+
private buildTableRowNode;
|
|
35
|
+
/**
|
|
36
|
+
* Build prosemirror td/th node
|
|
37
|
+
* @param {TableCell} cell
|
|
38
|
+
* @returns {PMNode}
|
|
39
|
+
*/
|
|
40
|
+
private buildTableCellNode;
|
|
41
|
+
/**
|
|
42
|
+
* Add a new row to the table
|
|
43
|
+
*/
|
|
44
|
+
private addRow;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function error(message: string, _input: string, line: number, column: number): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
export declare function createEmptyParagraphNode(schema: Schema): PMNode;
|
|
3
|
+
/**
|
|
4
|
+
* Create paragraphs from inline nodes. Function will return
|
|
5
|
+
* an empty array in case only hardbreaks are present
|
|
6
|
+
*/
|
|
7
|
+
export declare function createParagraphNodeFromInlineNodes(inlineNodes: PMNode[], schema: Schema): PMNode[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import { TokenType } from './tokenize';
|
|
3
|
+
import { Context } from '../interfaces';
|
|
4
|
+
export declare function parseString({ input, schema, ignoreTokenTypes, context, includeLeadingSpace, }: {
|
|
5
|
+
input: string;
|
|
6
|
+
schema: Schema;
|
|
7
|
+
ignoreTokenTypes: TokenType[];
|
|
8
|
+
context: Context;
|
|
9
|
+
includeLeadingSpace?: boolean;
|
|
10
|
+
}): PMNode[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import { Token } from './';
|
|
3
|
+
import { Context } from '../../interfaces';
|
|
4
|
+
export interface FormatterOption {
|
|
5
|
+
context: Context;
|
|
6
|
+
opening: string;
|
|
7
|
+
closing: string;
|
|
8
|
+
rawContentProcessor: (raw: string, length: number) => Token;
|
|
9
|
+
}
|
|
10
|
+
export declare function commonFormatter(input: string, position: number, schema: Schema, opt: FormatterOption): Token;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import { Token } from './';
|
|
3
|
+
import { Context } from '../../interfaces';
|
|
4
|
+
export interface MacroOption {
|
|
5
|
+
keyword: string;
|
|
6
|
+
paired: boolean;
|
|
7
|
+
context: Context;
|
|
8
|
+
rawContentProcessor: (rawAttrs: string, rawContent: string, length: number, schema: Schema, context: Context) => Token;
|
|
9
|
+
}
|
|
10
|
+
export declare function commonMacro(input: string, schema: Schema, opt: MacroOption): Token;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const doubleDashSymbol: import("./").TokenParser;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TokenParser } from './';
|
|
2
|
+
export declare const emoji: TokenParser;
|
|
3
|
+
interface AdfEmojiItems {
|
|
4
|
+
[key: string]: {
|
|
5
|
+
id: string;
|
|
6
|
+
shortName: string;
|
|
7
|
+
text: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const adfEmojiItems: AdfEmojiItems;
|
|
11
|
+
export interface WikiToEmojiMapping {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const wikiToAdfEmojiMapping: WikiToEmojiMapping;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import { Context } from '../../interfaces';
|
|
3
|
+
export declare enum TokenType {
|
|
4
|
+
ADF_MACRO = "ADF_MACRO",
|
|
5
|
+
ANCHOR_MACRO = "ANCHOR_MACRO",
|
|
6
|
+
CODE_MACRO = "CODE_MACRO",
|
|
7
|
+
QUOTE_MACRO = "QUOTE_MACRO",
|
|
8
|
+
NOFORMAT_MACRO = "NOFORMAT_MACRO",
|
|
9
|
+
PANEL_MACRO = "PANEL_MACRO",
|
|
10
|
+
COLOR_MACRO = "COLOR_MACRO",
|
|
11
|
+
LOREM_MACRO = "LOREM_MACRO",
|
|
12
|
+
QUOTE = "QUOTE",
|
|
13
|
+
STRING = "STRING",
|
|
14
|
+
ISSUE_KEY = "ISSUE_KEY",
|
|
15
|
+
LINK_FORMAT = "LINK_FORMAT",
|
|
16
|
+
LINK_TEXT = "LINK_TEXT",
|
|
17
|
+
MEDIA = "MEDIA",
|
|
18
|
+
HEADING = "HEADING",
|
|
19
|
+
LIST = "LIST",
|
|
20
|
+
TABLE = "TABLE",
|
|
21
|
+
RULER = "RULER",
|
|
22
|
+
HARD_BREAK = "HARD_BREAK",
|
|
23
|
+
DOUBLE_DASH_SYMBOL = "DOUBLE_DASH_SYMBOL",
|
|
24
|
+
TRIPLE_DASH_SYMBOL = "TRIPLE_DASH_SYMBOL",
|
|
25
|
+
QUADRUPLE_DASH_SYMBOL = "QUADRUPLE_DASH_SYMBOL",
|
|
26
|
+
STRONG = "STRONG",
|
|
27
|
+
MONOSPACE = "MONOSPACE",
|
|
28
|
+
SUPERSCRIPT = "SUPERSCRIPT",
|
|
29
|
+
SUBSCRIPT = "SUBSCRIPT",
|
|
30
|
+
EMPHASIS = "EMPHASIS",
|
|
31
|
+
CITATION = "CITATION",
|
|
32
|
+
DELETED = "DELETED",
|
|
33
|
+
INSERTED = "INSERTED",
|
|
34
|
+
EMOJI = "EMOJI",
|
|
35
|
+
FORCE_LINE_BREAK = "FORCE_LINE_BREAK"
|
|
36
|
+
}
|
|
37
|
+
export interface TextToken {
|
|
38
|
+
readonly type: 'text';
|
|
39
|
+
readonly text: string;
|
|
40
|
+
readonly length: number;
|
|
41
|
+
}
|
|
42
|
+
export interface PMNodeToken {
|
|
43
|
+
readonly type: 'pmnode';
|
|
44
|
+
readonly nodes: PMNode[];
|
|
45
|
+
readonly length: number;
|
|
46
|
+
}
|
|
47
|
+
export type TokenErrCallback = (err: Error, tokenType: string) => void;
|
|
48
|
+
export type Token = TextToken | PMNodeToken;
|
|
49
|
+
export type TokenParser = ({ input, position, schema, context, }: {
|
|
50
|
+
input: string;
|
|
51
|
+
position: number;
|
|
52
|
+
schema: Schema;
|
|
53
|
+
context: Context;
|
|
54
|
+
}) => Token;
|
|
55
|
+
export declare function parseToken(input: string, type: TokenType, position: number, schema: Schema, context: Context): Token;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Schema, Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { TokenParser } from './';
|
|
3
|
+
import { Context, ConversionMap } from '../../interfaces';
|
|
4
|
+
/**
|
|
5
|
+
* Inline Card From Text (ICFT).
|
|
6
|
+
*
|
|
7
|
+
* When we convert WikiMarkup to ADF we stamp all issue keys URLs with the
|
|
8
|
+
* #icft= syntax to identify which keys should be involved by brackets
|
|
9
|
+
* [XX-999] from the ones which should be blue links in the ADF to WikiMarkup
|
|
10
|
+
* convertion.
|
|
11
|
+
*/
|
|
12
|
+
export declare const INLINE_CARD_FROM_TEXT_STAMP: RegExp;
|
|
13
|
+
export interface Issue {
|
|
14
|
+
key: string;
|
|
15
|
+
url: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const issueKey: TokenParser;
|
|
18
|
+
export declare const getIssue: (context: Context, key: string) => Issue | null;
|
|
19
|
+
export declare const buildInlineCard: (schema: Schema, issue: Issue) => PMNode[];
|
|
20
|
+
export declare const buildIssueKeyRegex: (inlineCardConversion?: ConversionMap) => RegExp | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TokenType } from './';
|
|
2
|
+
interface KeywordToken {
|
|
3
|
+
type: TokenType;
|
|
4
|
+
regex: RegExp;
|
|
5
|
+
}
|
|
6
|
+
export declare const macroKeywordTokenMap: KeywordToken[];
|
|
7
|
+
export declare function parseMacroKeyword(input: string): {
|
|
8
|
+
type: TokenType;
|
|
9
|
+
} | null;
|
|
10
|
+
export declare function parseOtherKeyword(input: string): {
|
|
11
|
+
type: TokenType;
|
|
12
|
+
} | null;
|
|
13
|
+
export declare function parseLeadingKeyword(input: string): {
|
|
14
|
+
type: TokenType;
|
|
15
|
+
} | null;
|
|
16
|
+
export declare function parseIssueKeyword(input: string, issueKeyRegex?: RegExp): {
|
|
17
|
+
type: TokenType;
|
|
18
|
+
} | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ContentLink } from './link-parser';
|
|
2
|
+
import { Schema, Node as PMNode } from 'prosemirror-model';
|
|
3
|
+
import { Context } from '../../../interfaces';
|
|
4
|
+
export declare function attachmentLinkResolver(link: ContentLink, schema: Schema, context: Context): PMNode[] | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ContentLink } from './link-parser';
|
|
2
|
+
import { Schema, Node as PMNode } from 'prosemirror-model';
|
|
3
|
+
import { Context } from '../../../interfaces';
|
|
4
|
+
export declare function issueLinkResolver(link: ContentLink, schema: Schema, context: Context): PMNode[] | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Link {
|
|
2
|
+
readonly originalLinkText: string;
|
|
3
|
+
readonly linkBody: string | null;
|
|
4
|
+
readonly notLinkBody: string;
|
|
5
|
+
readonly linkTitle: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseLink(linkText: string): Link;
|
|
8
|
+
export interface ContentLink extends Link {
|
|
9
|
+
readonly spaceKey: string | null;
|
|
10
|
+
readonly destinationTitle: string;
|
|
11
|
+
readonly anchor: string | null;
|
|
12
|
+
readonly shortcutName: string | null;
|
|
13
|
+
readonly shortcutValue: string | null;
|
|
14
|
+
readonly attachmentName: string | null;
|
|
15
|
+
readonly contentId: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseContentLink(link: Link | string): ContentLink;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ContentLink } from './link-parser';
|
|
2
|
+
import { Token } from '../index';
|
|
3
|
+
import { Context } from '../../../interfaces';
|
|
4
|
+
import { Schema } from 'prosemirror-model';
|
|
5
|
+
export declare function resolveLink(link: ContentLink, schema: Schema, context: Context): Token | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ContentLink } from './link-parser';
|
|
2
|
+
import { Schema, Node as PMNode } from 'prosemirror-model';
|
|
3
|
+
import { Context } from '../../../interfaces';
|
|
4
|
+
export declare function mentionLinkResolver(link: ContentLink, schema: Schema, context: Context): PMNode[] | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import { Token, TokenParser } from '.';
|
|
3
|
+
import { Context } from '../../interfaces';
|
|
4
|
+
export declare const quoteMacro: TokenParser;
|
|
5
|
+
export declare const rawContentProcessor: (_rawAttrs: string, rawContent: string, length: number, schema: Schema, context: Context) => Token;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tripleDashSymbol: import("./").TokenParser;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
export declare function normalizePMNodes(nodes: PMNode[], schema: Schema, parentNode?: string): PMNode[];
|
|
3
|
+
export declare function normalizeInlineNodes(nodes: PMNode[], schema: Schema, parentNode?: string): PMNode[];
|
|
4
|
+
export declare function isNextLineEmpty(input: string): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
/**
|
|
3
|
+
* Check if the node has certain marks
|
|
4
|
+
*/
|
|
5
|
+
export declare function hasAnyOfMarks(node: PMNode, types: string[]): boolean;
|
|
6
|
+
export declare function isDigit(value: string): boolean;
|
|
7
|
+
export declare function isBlank(value: string | null): boolean;
|
|
8
|
+
export declare function isNotBlank(value: string | null): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* ESS-2375 Returns the beginning and closing symbol to parse a token
|
|
11
|
+
*/
|
|
12
|
+
export declare const getSurroundingSymbols: (trimmedInput: string, openingText: string, closingText: string) => Record<string, string>;
|
|
13
|
+
export declare class StringBuffer {
|
|
14
|
+
private buffer;
|
|
15
|
+
constructor(buffer?: string);
|
|
16
|
+
indexOf(value: string): number;
|
|
17
|
+
lastIndexOf(value: string): number;
|
|
18
|
+
charAt(index: number): string;
|
|
19
|
+
length(): number;
|
|
20
|
+
delete(start: number, end: number): void;
|
|
21
|
+
append(value: string): void;
|
|
22
|
+
substring(start: number, end?: number): string;
|
|
23
|
+
deleteCharAt(index: number): void;
|
|
24
|
+
toString(): string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* returns a correctly percent-encoded & sanitized url.
|
|
3
|
+
* Will fallback to using a DOM based implementation if the `URL` class
|
|
4
|
+
* doesn't exist.
|
|
5
|
+
*
|
|
6
|
+
* @param raw a 'raw' url (possibly mixed percent-encoded).
|
|
7
|
+
*/
|
|
8
|
+
export declare function decode(raw: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-wikimarkup-transformer",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.3",
|
|
4
4
|
"description": "Wiki markup transformer for JIRA and Confluence",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"@atlaskit/editor-json-transformer": "^8.9.0",
|
|
37
37
|
"@atlaskit/theme": "^12.5.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0",
|
|
39
|
-
"prosemirror-model": "1.
|
|
39
|
+
"prosemirror-model": "1.16.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@atlaskit/activity": "^1.0.1",
|
|
43
43
|
"@atlaskit/docs": "*",
|
|
44
|
-
"@atlaskit/editor-common": "^74.
|
|
45
|
-
"@atlaskit/editor-core": "^183.
|
|
44
|
+
"@atlaskit/editor-common": "^74.1.0",
|
|
45
|
+
"@atlaskit/editor-core": "^183.1.0",
|
|
46
46
|
"@atlaskit/editor-test-helpers": "^18.3.0",
|
|
47
47
|
"@atlaskit/mention": "^22.1.0",
|
|
48
48
|
"@atlaskit/profilecard": "^19.3.0",
|
|
49
|
-
"@atlaskit/renderer": "^108.
|
|
49
|
+
"@atlaskit/renderer": "^108.1.0",
|
|
50
50
|
"@atlaskit/util-data-test": "^17.8.0",
|
|
51
51
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
52
52
|
"@emotion/react": "^11.7.1",
|