@doist/typist 1.2.8 → 1.3.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.
- package/CHANGELOG.md +14 -2
- package/dist/constants/extension-priorities.d.ts +7 -1
- package/dist/constants/extension-priorities.d.ts.map +1 -1
- package/dist/constants/extension-priorities.js +7 -1
- package/dist/extensions/plain-text/plain-text-kit.d.ts +4 -0
- package/dist/extensions/plain-text/plain-text-kit.d.ts.map +1 -1
- package/dist/extensions/plain-text/plain-text-kit.js +5 -0
- package/dist/extensions/rich-text/rich-text-image.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-image.js +4 -0
- package/dist/extensions/rich-text/rich-text-kit.d.ts +4 -0
- package/dist/extensions/rich-text/rich-text-kit.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-kit.js +5 -0
- package/dist/extensions/shared/paste-html-table-as-string.d.ts +16 -0
- package/dist/extensions/shared/paste-html-table-as-string.d.ts.map +1 -0
- package/dist/extensions/shared/paste-html-table-as-string.js +64 -0
- package/dist/extensions/shared/paste-singleline-text.js +1 -1
- package/dist/helpers/unified.d.ts +11 -0
- package/dist/helpers/unified.d.ts.map +1 -0
- package/dist/helpers/unified.js +12 -0
- package/dist/serializers/html/html.d.ts +3 -10
- package/dist/serializers/html/html.d.ts.map +1 -1
- package/dist/serializers/html/html.js +66 -48
- package/dist/serializers/html/plugins/rehype-code-block.d.ts +10 -0
- package/dist/serializers/html/plugins/rehype-code-block.d.ts.map +1 -0
- package/dist/serializers/html/plugins/rehype-code-block.js +22 -0
- package/dist/serializers/html/plugins/rehype-image.d.ts +11 -0
- package/dist/serializers/html/plugins/rehype-image.d.ts.map +1 -0
- package/dist/serializers/html/plugins/rehype-image.js +34 -0
- package/dist/serializers/html/plugins/rehype-suggestions.d.ts +10 -0
- package/dist/serializers/html/plugins/rehype-suggestions.d.ts.map +1 -0
- package/dist/serializers/html/plugins/rehype-suggestions.js +36 -0
- package/dist/serializers/html/plugins/rehype-task-list.d.ts +7 -0
- package/dist/serializers/html/plugins/rehype-task-list.d.ts.map +1 -0
- package/dist/serializers/html/plugins/rehype-task-list.js +37 -0
- package/dist/serializers/html/plugins/remark-disable-constructs.d.ts +11 -0
- package/dist/serializers/html/plugins/remark-disable-constructs.d.ts.map +1 -0
- package/dist/serializers/html/plugins/remark-disable-constructs.js +48 -0
- package/dist/serializers/html/plugins/remark-strikethrough.d.ts +18 -0
- package/dist/serializers/html/plugins/remark-strikethrough.d.ts.map +1 -0
- package/dist/serializers/html/plugins/remark-strikethrough.js +26 -0
- package/package.json +37 -25
- package/dist/serializers/html/extensions/checkbox.d.ts +0 -8
- package/dist/serializers/html/extensions/checkbox.d.ts.map +0 -1
- package/dist/serializers/html/extensions/checkbox.js +0 -12
- package/dist/serializers/html/extensions/code.d.ts +0 -9
- package/dist/serializers/html/extensions/code.d.ts.map +0 -1
- package/dist/serializers/html/extensions/code.js +0 -20
- package/dist/serializers/html/extensions/disabled.d.ts +0 -13
- package/dist/serializers/html/extensions/disabled.d.ts.map +0 -1
- package/dist/serializers/html/extensions/disabled.js +0 -125
- package/dist/serializers/html/extensions/html.d.ts +0 -10
- package/dist/serializers/html/extensions/html.d.ts.map +0 -1
- package/dist/serializers/html/extensions/html.js +0 -15
- package/dist/serializers/html/extensions/link.d.ts +0 -11
- package/dist/serializers/html/extensions/link.d.ts.map +0 -1
- package/dist/serializers/html/extensions/link.js +0 -25
- package/dist/serializers/html/extensions/paragraph.d.ts +0 -12
- package/dist/serializers/html/extensions/paragraph.d.ts.map +0 -1
- package/dist/serializers/html/extensions/paragraph.js +0 -51
- package/dist/serializers/html/extensions/task-list.d.ts +0 -9
- package/dist/serializers/html/extensions/task-list.d.ts.map +0 -1
- package/dist/serializers/html/extensions/task-list.js +0 -31
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isElement } from 'hast-util-is-element';
|
|
2
|
+
import { visit } from 'unist-util-visit';
|
|
3
|
+
import { buildSuggestionSchemaPartialRegex } from '../../../helpers/serializer';
|
|
4
|
+
import { isTextNode } from '../../../helpers/unified';
|
|
5
|
+
/**
|
|
6
|
+
* A rehype plugin to add support for suggestions nodes (e.g., `@username` or `#channel).
|
|
7
|
+
*
|
|
8
|
+
* @param schema The editor schema to be used for suggestion nodes detection.
|
|
9
|
+
*/
|
|
10
|
+
function rehypeSuggestions(schema) {
|
|
11
|
+
const suggestionSchemaPartialRegex = buildSuggestionSchemaPartialRegex(schema);
|
|
12
|
+
// Return the tree as-is if the editor does not support suggestions
|
|
13
|
+
if (!suggestionSchemaPartialRegex) {
|
|
14
|
+
return (tree) => tree;
|
|
15
|
+
}
|
|
16
|
+
return (...[tree]) => {
|
|
17
|
+
const suggestionSchemaRegex = new RegExp(`^${suggestionSchemaPartialRegex}`);
|
|
18
|
+
visit(tree, 'element', (node) => {
|
|
19
|
+
if (isElement(node, 'a') && suggestionSchemaRegex.test(String(node.properties?.href))) {
|
|
20
|
+
const [, schema, id] = /^([a-z-]+):\/\/(\S+)$/i.exec(String(node.properties?.href)) || [];
|
|
21
|
+
// Replace the link element with a span containing the suggestion attributes
|
|
22
|
+
if (schema && id && isTextNode(node.children[0])) {
|
|
23
|
+
node.tagName = 'span';
|
|
24
|
+
node.properties = {
|
|
25
|
+
[`data-${schema}`]: '',
|
|
26
|
+
'data-id': id,
|
|
27
|
+
'data-label': node.children[0].value,
|
|
28
|
+
};
|
|
29
|
+
node.children = [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return tree;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export { rehypeSuggestions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rehype-task-list.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-task-list.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;GAEG;AACH,iBAAS,cAAc,IAAI,WAAW,CAoCrC;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isElement } from 'hast-util-is-element';
|
|
2
|
+
import { visit } from 'unist-util-visit';
|
|
3
|
+
import { isTextNode } from '../../../helpers/unified';
|
|
4
|
+
/**
|
|
5
|
+
* A rehype plugin to add support for Tiptap task lists (i.e., `* [ ] Task`).
|
|
6
|
+
*/
|
|
7
|
+
function rehypeTaskList() {
|
|
8
|
+
return (...[tree]) => {
|
|
9
|
+
visit(tree, 'element', (node) => {
|
|
10
|
+
if (isElement(node, 'ul')) {
|
|
11
|
+
const areAllChildrenTaskItems = node.children.every((c) => isElement(c, 'li') &&
|
|
12
|
+
isTextNode(c.children[0]) &&
|
|
13
|
+
/^\[[ x]\] /i.test(c.children[0].value));
|
|
14
|
+
// Add the required attributes to the list and list items if all children are tasks,
|
|
15
|
+
// removing the `[ ] ` or `[x] ` at the beginning of the task item text
|
|
16
|
+
if (areAllChildrenTaskItems) {
|
|
17
|
+
node.properties = {
|
|
18
|
+
...node.properties,
|
|
19
|
+
'data-type': 'taskList',
|
|
20
|
+
};
|
|
21
|
+
node.children.forEach((c) => {
|
|
22
|
+
if (isElement(c, 'li') && isTextNode(c.children[0])) {
|
|
23
|
+
c.properties = {
|
|
24
|
+
...c.properties,
|
|
25
|
+
'data-type': 'taskItem',
|
|
26
|
+
'data-checked': String(/^\[x\]/i.test(c.children[0].value)),
|
|
27
|
+
};
|
|
28
|
+
c.children[0].value = c.children[0].value.substring(4).trim();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return tree;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export { rehypeTaskList };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Schema } from 'prosemirror-model';
|
|
2
|
+
import type { Processor } from 'unified';
|
|
3
|
+
/**
|
|
4
|
+
* A remark plugin to disable multiple language constructs based on the availability of marks and/or
|
|
5
|
+
* nodes in the given editor schema.
|
|
6
|
+
*
|
|
7
|
+
* @param schema The editor schema to be used for nodes and marks detection.
|
|
8
|
+
*/
|
|
9
|
+
declare function remarkDisableConstructs(this: Processor, schema: Schema): void;
|
|
10
|
+
export { remarkDisableConstructs };
|
|
11
|
+
//# sourceMappingURL=remark-disable-constructs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-disable-constructs.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/remark-disable-constructs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;GAKG;AACH,iBAAS,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAqD/D;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A remark plugin to disable multiple language constructs based on the availability of marks and/or
|
|
3
|
+
* nodes in the given editor schema.
|
|
4
|
+
*
|
|
5
|
+
* @param schema The editor schema to be used for nodes and marks detection.
|
|
6
|
+
*/
|
|
7
|
+
function remarkDisableConstructs(schema) {
|
|
8
|
+
const data = this.data();
|
|
9
|
+
function add(field, value) {
|
|
10
|
+
const list = (data[field] ? data[field] : (data[field] = []));
|
|
11
|
+
list.push(value);
|
|
12
|
+
}
|
|
13
|
+
const disabledConstructs = [];
|
|
14
|
+
if (!schema.nodes.blockquote) {
|
|
15
|
+
disabledConstructs.push('blockQuote');
|
|
16
|
+
}
|
|
17
|
+
if (!schema.marks.bold || !schema.marks.italic) {
|
|
18
|
+
disabledConstructs.push('attention');
|
|
19
|
+
}
|
|
20
|
+
if (!schema.nodes.bulletList || !schema.nodes.orderedList) {
|
|
21
|
+
disabledConstructs.push('list');
|
|
22
|
+
}
|
|
23
|
+
if (!schema.marks.code) {
|
|
24
|
+
disabledConstructs.push('codeText');
|
|
25
|
+
}
|
|
26
|
+
if (!schema.nodes.codeBlock) {
|
|
27
|
+
disabledConstructs.push('codeFenced', 'codeIndented');
|
|
28
|
+
}
|
|
29
|
+
if (!schema.nodes.heading) {
|
|
30
|
+
disabledConstructs.push('headingAtx');
|
|
31
|
+
}
|
|
32
|
+
if (!schema.nodes.horizontalRule) {
|
|
33
|
+
disabledConstructs.push('thematicBreak');
|
|
34
|
+
}
|
|
35
|
+
if (!schema.nodes.image) {
|
|
36
|
+
disabledConstructs.push('labelStartImage');
|
|
37
|
+
}
|
|
38
|
+
if (!schema.marks.link) {
|
|
39
|
+
disabledConstructs.push('labelStartLink');
|
|
40
|
+
}
|
|
41
|
+
// https://github.com/micromark/micromark#case-turn-off-constructs
|
|
42
|
+
add('micromarkExtensions', {
|
|
43
|
+
disable: {
|
|
44
|
+
null: disabledConstructs,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export { remarkDisableConstructs };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Options } from 'micromark-extension-gfm-strikethrough';
|
|
2
|
+
import type { Processor } from 'unified';
|
|
3
|
+
/**
|
|
4
|
+
* A remark plugin to add support for the strikethrough extension from the GitHub Flavored Markdown
|
|
5
|
+
* (GFM) specification.
|
|
6
|
+
*
|
|
7
|
+
* This is an standalone plugin which makes use of both the `mdast-util-gfm-strikethrough` and
|
|
8
|
+
* `micromark-extension-gfm-strikethrough` packages, and the implementation is inspired by the
|
|
9
|
+
* third-party `remark-gfm` plugin.
|
|
10
|
+
*
|
|
11
|
+
* The reason why we don't use `remark-gfm` directly is because we don't want to support all other
|
|
12
|
+
* GFM features (autolink literals, footnotes, tables, and tasklists).
|
|
13
|
+
*
|
|
14
|
+
* @param options Configuration options for the plugin.
|
|
15
|
+
*/
|
|
16
|
+
declare function remarkStrikethrough(this: Processor, options?: Options): void;
|
|
17
|
+
export { remarkStrikethrough };
|
|
18
|
+
//# sourceMappingURL=remark-strikethrough.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-strikethrough.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/remark-strikethrough.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;;;;GAYG;AACH,iBAAS,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,OAAY,QAYlE;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown, } from 'mdast-util-gfm-strikethrough';
|
|
2
|
+
import { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough';
|
|
3
|
+
/**
|
|
4
|
+
* A remark plugin to add support for the strikethrough extension from the GitHub Flavored Markdown
|
|
5
|
+
* (GFM) specification.
|
|
6
|
+
*
|
|
7
|
+
* This is an standalone plugin which makes use of both the `mdast-util-gfm-strikethrough` and
|
|
8
|
+
* `micromark-extension-gfm-strikethrough` packages, and the implementation is inspired by the
|
|
9
|
+
* third-party `remark-gfm` plugin.
|
|
10
|
+
*
|
|
11
|
+
* The reason why we don't use `remark-gfm` directly is because we don't want to support all other
|
|
12
|
+
* GFM features (autolink literals, footnotes, tables, and tasklists).
|
|
13
|
+
*
|
|
14
|
+
* @param options Configuration options for the plugin.
|
|
15
|
+
*/
|
|
16
|
+
function remarkStrikethrough(options = {}) {
|
|
17
|
+
const data = this.data();
|
|
18
|
+
function add(field, value) {
|
|
19
|
+
const list = (data[field] ? data[field] : (data[field] = []));
|
|
20
|
+
list.push(value);
|
|
21
|
+
}
|
|
22
|
+
add('micromarkExtensions', gfmStrikethrough(options));
|
|
23
|
+
add('fromMarkdownExtensions', gfmStrikethroughFromMarkdown);
|
|
24
|
+
add('toMarkdownExtensions', gfmStrikethroughToMarkdown);
|
|
25
|
+
}
|
|
26
|
+
export { remarkStrikethrough };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doist/typist",
|
|
3
3
|
"description": "The mighty Tiptap-based rich-text editor React component that powers Doist products.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://typist.doist.dev/",
|
|
7
7
|
"repository": "https://github.com/Doist/typist",
|
|
@@ -81,70 +81,82 @@
|
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@doist/eslint-config": "9.0.0",
|
|
83
83
|
"@doist/prettier-config": "3.0.5",
|
|
84
|
-
"@doist/reactist": "21.0.
|
|
84
|
+
"@doist/reactist": "21.0.2",
|
|
85
85
|
"@mdx-js/react": "2.3.0",
|
|
86
86
|
"@semantic-release/changelog": "6.0.3",
|
|
87
87
|
"@semantic-release/exec": "6.0.3",
|
|
88
88
|
"@semantic-release/git": "10.0.1",
|
|
89
|
-
"@storybook/addon-a11y": "7.0.
|
|
90
|
-
"@storybook/addon-essentials": "7.0.
|
|
91
|
-
"@storybook/addons": "7.0.
|
|
92
|
-
"@storybook/csf": "0.1.
|
|
89
|
+
"@storybook/addon-a11y": "7.0.18",
|
|
90
|
+
"@storybook/addon-essentials": "7.0.18",
|
|
91
|
+
"@storybook/addons": "7.0.18",
|
|
92
|
+
"@storybook/csf": "0.1.1",
|
|
93
93
|
"@storybook/mdx2-csf": "1.1.0",
|
|
94
|
-
"@storybook/react": "7.0.
|
|
95
|
-
"@storybook/react-vite": "7.0.
|
|
94
|
+
"@storybook/react": "7.0.18",
|
|
95
|
+
"@storybook/react-vite": "7.0.18",
|
|
96
96
|
"@testing-library/dom": "9.3.0",
|
|
97
97
|
"@testing-library/jest-dom": "5.16.5",
|
|
98
98
|
"@testing-library/react": "14.0.0",
|
|
99
|
+
"@types/hast": "2.3.4",
|
|
99
100
|
"@types/lodash-es": "4.17.7",
|
|
100
|
-
"@types/
|
|
101
|
-
"@types/react": "18.2.7",
|
|
101
|
+
"@types/react": "18.2.8",
|
|
102
102
|
"@types/react-dom": "18.2.4",
|
|
103
|
-
"@types/react-syntax-highlighter": "15.5.
|
|
103
|
+
"@types/react-syntax-highlighter": "15.5.7",
|
|
104
104
|
"@types/turndown": "5.0.1",
|
|
105
105
|
"boring-avatars": "1.7.0",
|
|
106
106
|
"classnames": "2.3.2",
|
|
107
|
-
"conventional-changelog-conventionalcommits": "
|
|
107
|
+
"conventional-changelog-conventionalcommits": "6.0.0",
|
|
108
108
|
"emoji-regex": "10.2.1",
|
|
109
|
-
"eslint": "8.
|
|
109
|
+
"eslint": "8.42.0",
|
|
110
110
|
"eslint-formatter-codeframe": "7.32.1",
|
|
111
111
|
"eslint-import-resolver-typescript": "3.5.5",
|
|
112
112
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
113
113
|
"eslint-plugin-storybook": "0.6.12",
|
|
114
114
|
"eslint-plugin-unicorn": "47.0.0",
|
|
115
|
-
"eslint-plugin-vitest": "0.2.
|
|
115
|
+
"eslint-plugin-vitest": "0.2.5",
|
|
116
116
|
"eslint-plugin-vitest-globals": "1.3.1",
|
|
117
117
|
"github-markdown-css": "5.2.0",
|
|
118
118
|
"husky": "8.0.3",
|
|
119
119
|
"ignore-sync": "7.0.1",
|
|
120
120
|
"is-ci": "3.0.1",
|
|
121
|
-
"jsdom": "22.
|
|
121
|
+
"jsdom": "22.1.0",
|
|
122
122
|
"lint-staged": "13.2.2",
|
|
123
123
|
"npm-run-all": "4.1.5",
|
|
124
124
|
"prettier": "2.8.8",
|
|
125
125
|
"react": "18.2.0",
|
|
126
126
|
"react-dom": "18.2.0",
|
|
127
|
-
"react-icons": "4.
|
|
127
|
+
"react-icons": "4.9.0",
|
|
128
128
|
"react-markdown": "8.0.7",
|
|
129
129
|
"react-syntax-highlighter": "15.5.0",
|
|
130
|
-
"rehype-raw": "6.1.1",
|
|
131
|
-
"remark-gfm": "3.0.1",
|
|
132
130
|
"rimraf": "5.0.1",
|
|
133
|
-
"semantic-release": "21.0.
|
|
134
|
-
"storybook": "7.0.
|
|
131
|
+
"semantic-release": "21.0.3",
|
|
132
|
+
"storybook": "7.0.18",
|
|
135
133
|
"storybook-css-modules": "1.0.8",
|
|
136
|
-
"type-fest": "3.11.
|
|
137
|
-
"typescript": "5.
|
|
134
|
+
"type-fest": "3.11.1",
|
|
135
|
+
"typescript": "5.1.3",
|
|
138
136
|
"typescript-plugin-css-modules": "5.0.1",
|
|
139
|
-
"vitest": "0.31.
|
|
137
|
+
"vitest": "0.31.4"
|
|
140
138
|
},
|
|
141
139
|
"peerDependencies": {
|
|
142
140
|
"@react-hookz/web": "^14.2.3 || >=15.x",
|
|
143
141
|
"emoji-regex": "^10.2.1",
|
|
142
|
+
"hast-util-is-element": "^2.1.0",
|
|
144
143
|
"lodash-es": "^4.17.21",
|
|
145
|
-
"
|
|
144
|
+
"mdast-util-gfm-strikethrough": "^1.0.0",
|
|
145
|
+
"micromark-extension-gfm-strikethrough": "^1.0.0",
|
|
146
146
|
"react": "^17.0.0 || ^18.0.0",
|
|
147
147
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
148
|
-
"
|
|
148
|
+
"rehype": "^12.0.0",
|
|
149
|
+
"rehype-minify-whitespace": "^5.0.0",
|
|
150
|
+
"rehype-raw": "^6.1.0",
|
|
151
|
+
"rehype-stringify": "^9.0.0",
|
|
152
|
+
"remark": "^14.0.0",
|
|
153
|
+
"remark-breaks": "^3.0.0",
|
|
154
|
+
"remark-gfm": "^3.0.0",
|
|
155
|
+
"remark-rehype": "^10.1.0",
|
|
156
|
+
"turndown": "^7.1.0",
|
|
157
|
+
"unified": "^10.1.0",
|
|
158
|
+
"unist-util-is": "^5.2.0",
|
|
159
|
+
"unist-util-remove": "^3.1.0",
|
|
160
|
+
"unist-util-visit": "^4.1.0"
|
|
149
161
|
}
|
|
150
162
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
/**
|
|
3
|
-
* A Marked extension which tweaks the `checkbox` renderer to prevent rendering of task lists with
|
|
4
|
-
* GitHub's Flavored Markdown syntax, which is unsupported by Tiptap.
|
|
5
|
-
*/
|
|
6
|
-
declare const checkbox: marked.MarkedExtension;
|
|
7
|
-
export { checkbox };
|
|
8
|
-
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/extensions/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;GAGG;AACH,QAAA,MAAM,QAAQ,EAAE,MAAM,CAAC,eAMtB,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A Marked extension which tweaks the `checkbox` renderer to prevent rendering of task lists with
|
|
3
|
-
* GitHub's Flavored Markdown syntax, which is unsupported by Tiptap.
|
|
4
|
-
*/
|
|
5
|
-
const checkbox = {
|
|
6
|
-
renderer: {
|
|
7
|
-
checkbox(checked) {
|
|
8
|
-
return `[${checked ? 'x' : ' '}] `;
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
export { checkbox };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
/**
|
|
3
|
-
* A Marked extension which tweaks the `code` renderer to remove the newline between the last code
|
|
4
|
-
* line and `</code></pre>`. Although that newline is part of the CommonMark spec, this custom rule
|
|
5
|
-
* is required to prevent Tiptap from rendering a blank line at the end of the code block.
|
|
6
|
-
*/
|
|
7
|
-
declare const code: marked.MarkedExtension;
|
|
8
|
-
export { code };
|
|
9
|
-
//# sourceMappingURL=code.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/extensions/code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAO/B;;;;GAIG;AACH,QAAA,MAAM,IAAI,EAAE,MAAM,CAAC,eAQlB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
/**
|
|
3
|
-
* Initialize a new instance of the original renderer to be used by the extension.
|
|
4
|
-
*/
|
|
5
|
-
const markedRenderer = new marked.Renderer();
|
|
6
|
-
/**
|
|
7
|
-
* A Marked extension which tweaks the `code` renderer to remove the newline between the last code
|
|
8
|
-
* line and `</code></pre>`. Although that newline is part of the CommonMark spec, this custom rule
|
|
9
|
-
* is required to prevent Tiptap from rendering a blank line at the end of the code block.
|
|
10
|
-
*/
|
|
11
|
-
const code = {
|
|
12
|
-
renderer: {
|
|
13
|
-
code(code, infostring, escaped) {
|
|
14
|
-
return markedRenderer.code
|
|
15
|
-
.apply(this, [code, infostring, escaped])
|
|
16
|
-
.replace(/\n(<\/code><\/pre>)$/m, '$1');
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
export { code };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
import type { Schema } from 'prosemirror-model';
|
|
3
|
-
/**
|
|
4
|
-
* A Marked extension which disables multiple parsing rules by disabling the rules respective
|
|
5
|
-
* tokenizers based on the availability of marks and/or nodes in the editor schema.
|
|
6
|
-
*
|
|
7
|
-
* @param schema The editor schema to be used for nodes and marks detection.
|
|
8
|
-
*/
|
|
9
|
-
declare function disabled(schema: Schema): {
|
|
10
|
-
tokenizer: Partial<Omit<marked.Tokenizer<false>, "constructor" | "options">>;
|
|
11
|
-
};
|
|
12
|
-
export { disabled };
|
|
13
|
-
//# sourceMappingURL=disabled.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"disabled.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/extensions/disabled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAK/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C;;;;;GAKG;AACH,iBAAS,QAAQ,CAAC,MAAM,EAAE,MAAM;;EAyI/B;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
import { buildSuggestionSchemaPartialRegex } from '../../../helpers/serializer';
|
|
3
|
-
import { INITIAL_MARKED_OPTIONS } from '../html';
|
|
4
|
-
/**
|
|
5
|
-
* A Marked extension which disables multiple parsing rules by disabling the rules respective
|
|
6
|
-
* tokenizers based on the availability of marks and/or nodes in the editor schema.
|
|
7
|
-
*
|
|
8
|
-
* @param schema The editor schema to be used for nodes and marks detection.
|
|
9
|
-
*/
|
|
10
|
-
function disabled(schema) {
|
|
11
|
-
const markedTokenizer = new marked.Tokenizer(INITIAL_MARKED_OPTIONS);
|
|
12
|
-
const tokenizer = {};
|
|
13
|
-
if (!schema.nodes.blockquote) {
|
|
14
|
-
Object.assign(tokenizer, {
|
|
15
|
-
blockquote() {
|
|
16
|
-
return undefined;
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
if (!schema.marks.bold || !schema.marks.italic) {
|
|
21
|
-
Object.assign(tokenizer, {
|
|
22
|
-
emStrong() {
|
|
23
|
-
return undefined;
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
// Given that there isn't a one to one mapping between the bullet/ordered list nodes and Marked
|
|
28
|
-
// tokenizers, we need to conditionally disable the `list` tokenizer based on the input
|
|
29
|
-
if (!schema.nodes.bulletList || !schema.nodes.orderedList) {
|
|
30
|
-
Object.assign(tokenizer, {
|
|
31
|
-
list(src) {
|
|
32
|
-
const isOrdered = /^\d+/.test(src);
|
|
33
|
-
if ((isOrdered && schema.nodes.orderedList) ||
|
|
34
|
-
(!isOrdered && schema.nodes.bulletList)) {
|
|
35
|
-
return markedTokenizer.list.apply(this, [src]);
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (!schema.marks.code) {
|
|
42
|
-
Object.assign(tokenizer, {
|
|
43
|
-
codespan() {
|
|
44
|
-
return undefined;
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (!schema.nodes.codeBlock) {
|
|
49
|
-
Object.assign(tokenizer, {
|
|
50
|
-
code() {
|
|
51
|
-
return undefined;
|
|
52
|
-
},
|
|
53
|
-
fences() {
|
|
54
|
-
return undefined;
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
if (!schema.nodes.hardBreak) {
|
|
59
|
-
Object.assign(tokenizer, {
|
|
60
|
-
br() {
|
|
61
|
-
return undefined;
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (!schema.nodes.heading) {
|
|
66
|
-
Object.assign(tokenizer, {
|
|
67
|
-
heading() {
|
|
68
|
-
return undefined;
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
if (!schema.nodes.horizontalRule) {
|
|
73
|
-
Object.assign(tokenizer, {
|
|
74
|
-
hr() {
|
|
75
|
-
return undefined;
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
if (!schema.marks.link) {
|
|
80
|
-
Object.assign(tokenizer, {
|
|
81
|
-
url() {
|
|
82
|
-
return undefined;
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
// Given that there isn't a one to one mapping between the link/image mark/node and Marked
|
|
87
|
-
// tokenizers, nor Marked supports our custom Markdown syntax for suggestions, we need to
|
|
88
|
-
// conditionally disable the `link` tokenizer based on the input
|
|
89
|
-
if (!schema.marks.link || !schema.nodes.image) {
|
|
90
|
-
const suggestionSchemaPartialRegex = buildSuggestionSchemaPartialRegex(schema);
|
|
91
|
-
const suggestionSchemaRegex = suggestionSchemaPartialRegex
|
|
92
|
-
? new RegExp(`^\\[[^\\]]*\\]\\(${suggestionSchemaPartialRegex}`)
|
|
93
|
-
: null;
|
|
94
|
-
Object.assign(tokenizer, {
|
|
95
|
-
link(src) {
|
|
96
|
-
const isImage = /^!\[[^\]]*\]\([^)]+\)/.test(src);
|
|
97
|
-
const isSuggestion = suggestionSchemaRegex?.test(src);
|
|
98
|
-
if ((isImage && schema.nodes.image) ||
|
|
99
|
-
(!isImage && schema.marks.link) ||
|
|
100
|
-
isSuggestion) {
|
|
101
|
-
return markedTokenizer.link.apply(this, [src]);
|
|
102
|
-
}
|
|
103
|
-
return undefined;
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
if (!schema.marks.strike) {
|
|
108
|
-
Object.assign(tokenizer, {
|
|
109
|
-
del() {
|
|
110
|
-
return undefined;
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
if (!schema.nodes.table) {
|
|
115
|
-
Object.assign(tokenizer, {
|
|
116
|
-
table() {
|
|
117
|
-
return undefined;
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
tokenizer,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
export { disabled };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
/**
|
|
3
|
-
* A Marked extension which tweaks the `html` renderer to escape special characters (i.e. `&`, `<`,
|
|
4
|
-
* `>`, `"`, and `'`) for unsupported tokens. This custom rule is required because the escaping must
|
|
5
|
-
* be performed at the token level to avoid escaping the full input, which would result in unwanted
|
|
6
|
-
* escaped output (i.e. valid HTML would be escaped).
|
|
7
|
-
*/
|
|
8
|
-
declare const html: marked.MarkedExtension;
|
|
9
|
-
export { html };
|
|
10
|
-
//# sourceMappingURL=html.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/extensions/html.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;GAKG;AACH,QAAA,MAAM,IAAI,EAAE,MAAM,CAAC,eAMlB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { escape } from 'lodash-es';
|
|
2
|
-
/**
|
|
3
|
-
* A Marked extension which tweaks the `html` renderer to escape special characters (i.e. `&`, `<`,
|
|
4
|
-
* `>`, `"`, and `'`) for unsupported tokens. This custom rule is required because the escaping must
|
|
5
|
-
* be performed at the token level to avoid escaping the full input, which would result in unwanted
|
|
6
|
-
* escaped output (i.e. valid HTML would be escaped).
|
|
7
|
-
*/
|
|
8
|
-
const html = {
|
|
9
|
-
renderer: {
|
|
10
|
-
html(html) {
|
|
11
|
-
return escape(html);
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
export { html };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
/**
|
|
3
|
-
* A Marked extension which tweaks the `link` renderer to add support for suggestion nodes, while
|
|
4
|
-
* preserving the original renderer for standard links.
|
|
5
|
-
*
|
|
6
|
-
* @param suggestionSchemaRegex A regular expression with valid URL schemas for the available
|
|
7
|
-
* suggestion nodes.
|
|
8
|
-
*/
|
|
9
|
-
declare function link(suggestionSchemaRegex: RegExp): marked.MarkedExtension;
|
|
10
|
-
export { link };
|
|
11
|
-
//# sourceMappingURL=link.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/extensions/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B;;;;;;GAMG;AACH,iBAAS,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,MAAM,CAAC,eAAe,CAgBnE;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
const markedRenderer = new marked.Renderer();
|
|
3
|
-
/**
|
|
4
|
-
* A Marked extension which tweaks the `link` renderer to add support for suggestion nodes, while
|
|
5
|
-
* preserving the original renderer for standard links.
|
|
6
|
-
*
|
|
7
|
-
* @param suggestionSchemaRegex A regular expression with valid URL schemas for the available
|
|
8
|
-
* suggestion nodes.
|
|
9
|
-
*/
|
|
10
|
-
function link(suggestionSchemaRegex) {
|
|
11
|
-
return {
|
|
12
|
-
renderer: {
|
|
13
|
-
link(href, title, text) {
|
|
14
|
-
if (href && suggestionSchemaRegex?.test(href)) {
|
|
15
|
-
const [, schema, id] = /^([a-z-]+):\/\/(\S+)$/i.exec(href) || [];
|
|
16
|
-
if (schema && id && text) {
|
|
17
|
-
return `<span data-${schema} data-id="${id}" data-label="${text}"></span>`;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return markedRenderer.link.apply(this, [href, title, text]);
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export { link };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
import type { NodeType } from 'prosemirror-model';
|
|
3
|
-
/**
|
|
4
|
-
* A Marked extension which tweaks the `paragraph` renderer to remove the surrounding `<p></p>` tag
|
|
5
|
-
* when it's wrapping an image element as a single child, or to remove all inline images if the
|
|
6
|
-
* editor was configured without inline image support (default).
|
|
7
|
-
*
|
|
8
|
-
* @param imageNode The node object for the schema image node.
|
|
9
|
-
*/
|
|
10
|
-
declare function paragraph(imageNode?: NodeType): marked.MarkedExtension;
|
|
11
|
-
export { paragraph };
|
|
12
|
-
//# sourceMappingURL=paragraph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/extensions/paragraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAOjD;;;;;;GAMG;AACH,iBAAS,SAAS,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,eAAe,CA6C/D;AAED,OAAO,EAAE,SAAS,EAAE,CAAA"}
|