@doist/typist 1.2.5 → 1.2.7
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
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [1.2.7](https://github.com/Doist/typist/compare/v1.2.6...v1.2.7) (2023-05-22)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **paste-markdown:** Incorrect paste behaviour when HTML source is VSCode ([#260](https://github.com/Doist/typist/issues/260)) ([3326796](https://github.com/Doist/typist/commit/3326796a9093a984113ac76f69bc3ec109004288))
|
|
6
|
+
|
|
7
|
+
## [1.2.6](https://github.com/Doist/typist/compare/v1.2.5...v1.2.6) (2023-04-18)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **deps:** update tiptap packages to v2.0.3 ([#226](https://github.com/Doist/typist/issues/226)) ([a1953b0](https://github.com/Doist/typist/commit/a1953b087b51772f5c29671473031cb099c346e0))
|
|
12
|
+
|
|
1
13
|
## [1.2.5](https://github.com/Doist/typist/compare/v1.2.4...v1.2.5) (2023-04-10)
|
|
2
14
|
|
|
3
15
|
### Bug Fixes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paste-markdown.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/paste-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAexC;;;;;;GAMG;AACH,QAAA,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"paste-markdown.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/paste-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAexC;;;;;;GAMG;AACH,QAAA,MAAM,aAAa,qBA8FjB,CAAA;AAEF,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -25,38 +25,50 @@ const PasteMarkdown = Extension.create({
|
|
|
25
25
|
return Slice.maxOpen(Fragment.from(editor.schema.text(text)));
|
|
26
26
|
},
|
|
27
27
|
handlePaste(_, event, slice) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
// The clipboard contains text if the slice content size is greater than
|
|
29
|
+
// zero, otherwise it contains other data types (like files or images)
|
|
30
|
+
const clipboardContainsText = Boolean(slice.content.size);
|
|
31
31
|
const clipboardContainsHTML = Boolean(event.clipboardData?.types.some((type) => type === ClipboardDataType.HTML));
|
|
32
32
|
// Unfortunately, the VS Code clipboard data type is not supported by
|
|
33
33
|
// Firefox or Safari, which means that copy/paste experience from VS Code
|
|
34
|
-
// into the editor with
|
|
34
|
+
// into the editor with either of those browsers is subpar:
|
|
35
35
|
// * The Markdown syntax is not fully converted to rich-text
|
|
36
36
|
// * Code is not detected nor converted to a code-block
|
|
37
37
|
const clipboardContainsVSCodeMetadata = Boolean(event.clipboardData?.types.some((type) => type === ClipboardDataType.VSCode));
|
|
38
|
+
const clipboardContainsHTMLFromUnknownSource = clipboardContainsHTML && !clipboardContainsVSCodeMetadata;
|
|
38
39
|
const vsCodeClipboardMetadata = clipboardContainsVSCodeMetadata
|
|
39
40
|
? JSON.parse(event.clipboardData?.getData(ClipboardDataType.VSCode) ||
|
|
40
41
|
'{}')
|
|
41
42
|
: {};
|
|
43
|
+
const clipboardContainsHTMLFromVSCodeOtherThanTextOrMarkdown = clipboardContainsVSCodeMetadata &&
|
|
44
|
+
// If `mode` from the VS Code metadata is `null` it probably means that
|
|
45
|
+
// the user has the VS Code `editor.copyWithSyntaxHighlighting` setting
|
|
46
|
+
// set to `false`, thus returning plain-text
|
|
47
|
+
vsCodeClipboardMetadata.mode !== null &&
|
|
48
|
+
vsCodeClipboardMetadata.mode !== 'markdown';
|
|
49
|
+
const isInsideCodeBlockNode = editor.state.selection.$from.parent.type.name === 'codeBlock';
|
|
42
50
|
// Do not handle the paste event if:
|
|
43
|
-
// * The clipboard
|
|
44
|
-
// * The clipboard HTML
|
|
45
|
-
//
|
|
46
|
-
// * The
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
// * The clipboard does NOT contain plain-text
|
|
52
|
+
// * The clipboard contains HTML but from an unknown source (like Google
|
|
53
|
+
// Drive, Dropbox Paper, etc.)
|
|
54
|
+
// * The clipboard contains HTML from VS Code that it's NOT plain-text or
|
|
55
|
+
// Markdown (like Python, TypeScript, JSON, etc.)
|
|
56
|
+
// * The user is pasting content inside a code block node
|
|
57
|
+
// For all the above conditions we want the default handling behaviour from
|
|
58
|
+
// ProseMirror to kick-in, otherwise we'll handle it ourselves below
|
|
59
|
+
if (!clipboardContainsText ||
|
|
60
|
+
clipboardContainsHTMLFromUnknownSource ||
|
|
61
|
+
clipboardContainsHTMLFromVSCodeOtherThanTextOrMarkdown ||
|
|
62
|
+
isInsideCodeBlockNode) {
|
|
52
63
|
return false;
|
|
53
64
|
}
|
|
54
65
|
// Send the clipboard text through the HTML serializer to convert potential
|
|
55
66
|
// Markdown into HTML, and then insert it into the editor
|
|
56
67
|
editor.commands.insertMarkdownContent(
|
|
57
|
-
// The slice content is used instead of
|
|
58
|
-
//
|
|
59
|
-
|
|
68
|
+
// The slice content is used instead of getting the text directly from
|
|
69
|
+
// the clipboard data because the pasted content could have already
|
|
70
|
+
// been transformed by other ProseMirror plugins
|
|
71
|
+
slice.content.textBetween(0, slice.content.size, '\n'));
|
|
60
72
|
// Suppress the default handling behaviour
|
|
61
73
|
return true;
|
|
62
74
|
},
|
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.2.
|
|
4
|
+
"version": "1.2.7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://typist.doist.dev/",
|
|
7
7
|
"repository": "https://github.com/Doist/typist",
|
|
@@ -46,98 +46,98 @@
|
|
|
46
46
|
"validate:pre-push": "run-s test"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@tiptap/core": "2.0.
|
|
50
|
-
"@tiptap/extension-blockquote": "2.0.
|
|
51
|
-
"@tiptap/extension-bold": "2.0.
|
|
52
|
-
"@tiptap/extension-bullet-list": "2.0.
|
|
53
|
-
"@tiptap/extension-character-count": "2.0.
|
|
54
|
-
"@tiptap/extension-code": "2.0.
|
|
55
|
-
"@tiptap/extension-code-block": "2.0.
|
|
56
|
-
"@tiptap/extension-document": "2.0.
|
|
57
|
-
"@tiptap/extension-dropcursor": "2.0.
|
|
58
|
-
"@tiptap/extension-gapcursor": "2.0.
|
|
59
|
-
"@tiptap/extension-hard-break": "2.0.
|
|
60
|
-
"@tiptap/extension-heading": "2.0.
|
|
61
|
-
"@tiptap/extension-history": "2.0.
|
|
62
|
-
"@tiptap/extension-horizontal-rule": "2.0.
|
|
63
|
-
"@tiptap/extension-image": "2.0.
|
|
64
|
-
"@tiptap/extension-italic": "2.0.
|
|
65
|
-
"@tiptap/extension-link": "2.0.
|
|
66
|
-
"@tiptap/extension-list-item": "2.0.
|
|
67
|
-
"@tiptap/extension-ordered-list": "2.0.
|
|
68
|
-
"@tiptap/extension-paragraph": "2.0.
|
|
69
|
-
"@tiptap/extension-placeholder": "2.0.
|
|
70
|
-
"@tiptap/extension-strike": "2.0.
|
|
71
|
-
"@tiptap/extension-task-item": "2.0.
|
|
72
|
-
"@tiptap/extension-task-list": "2.0.
|
|
73
|
-
"@tiptap/extension-text": "2.0.
|
|
74
|
-
"@tiptap/extension-typography": "2.0.
|
|
75
|
-
"@tiptap/pm": "2.0.
|
|
76
|
-
"@tiptap/react": "2.0.
|
|
77
|
-
"@tiptap/suggestion": "2.0.
|
|
49
|
+
"@tiptap/core": "2.0.3",
|
|
50
|
+
"@tiptap/extension-blockquote": "2.0.3",
|
|
51
|
+
"@tiptap/extension-bold": "2.0.3",
|
|
52
|
+
"@tiptap/extension-bullet-list": "2.0.3",
|
|
53
|
+
"@tiptap/extension-character-count": "2.0.3",
|
|
54
|
+
"@tiptap/extension-code": "2.0.3",
|
|
55
|
+
"@tiptap/extension-code-block": "2.0.3",
|
|
56
|
+
"@tiptap/extension-document": "2.0.3",
|
|
57
|
+
"@tiptap/extension-dropcursor": "2.0.3",
|
|
58
|
+
"@tiptap/extension-gapcursor": "2.0.3",
|
|
59
|
+
"@tiptap/extension-hard-break": "2.0.3",
|
|
60
|
+
"@tiptap/extension-heading": "2.0.3",
|
|
61
|
+
"@tiptap/extension-history": "2.0.3",
|
|
62
|
+
"@tiptap/extension-horizontal-rule": "2.0.3",
|
|
63
|
+
"@tiptap/extension-image": "2.0.3",
|
|
64
|
+
"@tiptap/extension-italic": "2.0.3",
|
|
65
|
+
"@tiptap/extension-link": "2.0.3",
|
|
66
|
+
"@tiptap/extension-list-item": "2.0.3",
|
|
67
|
+
"@tiptap/extension-ordered-list": "2.0.3",
|
|
68
|
+
"@tiptap/extension-paragraph": "2.0.3",
|
|
69
|
+
"@tiptap/extension-placeholder": "2.0.3",
|
|
70
|
+
"@tiptap/extension-strike": "2.0.3",
|
|
71
|
+
"@tiptap/extension-task-item": "2.0.3",
|
|
72
|
+
"@tiptap/extension-task-list": "2.0.3",
|
|
73
|
+
"@tiptap/extension-text": "2.0.3",
|
|
74
|
+
"@tiptap/extension-typography": "2.0.3",
|
|
75
|
+
"@tiptap/pm": "2.0.3",
|
|
76
|
+
"@tiptap/react": "2.0.3",
|
|
77
|
+
"@tiptap/suggestion": "2.0.3",
|
|
78
78
|
"prosemirror-codemark": "0.4.2"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@doist/eslint-config": "8.1.4",
|
|
82
82
|
"@doist/prettier-config": "3.0.5",
|
|
83
|
-
"@doist/reactist": "20.
|
|
83
|
+
"@doist/reactist": "20.3.0",
|
|
84
84
|
"@mdx-js/react": "2.3.0",
|
|
85
85
|
"@semantic-release/changelog": "6.0.3",
|
|
86
86
|
"@semantic-release/exec": "6.0.3",
|
|
87
87
|
"@semantic-release/git": "10.0.1",
|
|
88
|
-
"@storybook/addon-a11y": "7.0.
|
|
89
|
-
"@storybook/addon-essentials": "7.0.
|
|
90
|
-
"@storybook/addons": "7.0.
|
|
91
|
-
"@storybook/csf": "0.0
|
|
92
|
-
"@storybook/mdx2-csf": "1.
|
|
93
|
-
"@storybook/react": "7.0.
|
|
94
|
-
"@storybook/react-vite": "7.0.
|
|
95
|
-
"@testing-library/dom": "9.
|
|
88
|
+
"@storybook/addon-a11y": "7.0.12",
|
|
89
|
+
"@storybook/addon-essentials": "7.0.12",
|
|
90
|
+
"@storybook/addons": "7.0.12",
|
|
91
|
+
"@storybook/csf": "0.1.0",
|
|
92
|
+
"@storybook/mdx2-csf": "1.1.0",
|
|
93
|
+
"@storybook/react": "7.0.12",
|
|
94
|
+
"@storybook/react-vite": "7.0.12",
|
|
95
|
+
"@testing-library/dom": "9.3.0",
|
|
96
96
|
"@testing-library/jest-dom": "5.16.5",
|
|
97
97
|
"@testing-library/react": "14.0.0",
|
|
98
|
-
"@types/jest": "29.5.
|
|
98
|
+
"@types/jest": "29.5.1",
|
|
99
99
|
"@types/lodash-es": "4.17.7",
|
|
100
|
-
"@types/marked": "4.0
|
|
101
|
-
"@types/react": "18.
|
|
102
|
-
"@types/react-dom": "18.
|
|
100
|
+
"@types/marked": "4.3.0",
|
|
101
|
+
"@types/react": "18.2.6",
|
|
102
|
+
"@types/react-dom": "18.2.4",
|
|
103
103
|
"@types/react-syntax-highlighter": "15.5.6",
|
|
104
104
|
"@types/turndown": "5.0.1",
|
|
105
105
|
"boring-avatars": "1.7.0",
|
|
106
106
|
"classnames": "2.3.2",
|
|
107
107
|
"conventional-changelog-conventionalcommits": "5.0.0",
|
|
108
108
|
"emoji-regex": "10.2.1",
|
|
109
|
-
"eslint": "8.
|
|
109
|
+
"eslint": "8.40.0",
|
|
110
110
|
"eslint-formatter-codeframe": "7.32.1",
|
|
111
|
-
"eslint-import-resolver-typescript": "3.5.
|
|
111
|
+
"eslint-import-resolver-typescript": "3.5.5",
|
|
112
112
|
"eslint-plugin-jest": "27.2.1",
|
|
113
113
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
114
|
-
"eslint-plugin-storybook": "0.6.
|
|
115
|
-
"eslint-plugin-unicorn": "46.0.
|
|
114
|
+
"eslint-plugin-storybook": "0.6.12",
|
|
115
|
+
"eslint-plugin-unicorn": "46.0.1",
|
|
116
116
|
"github-markdown-css": "5.2.0",
|
|
117
117
|
"husky": "8.0.3",
|
|
118
118
|
"ignore-sync": "6.0.2",
|
|
119
119
|
"is-ci": "3.0.1",
|
|
120
120
|
"jest": "29.5.0",
|
|
121
121
|
"jest-environment-jsdom": "29.5.0",
|
|
122
|
-
"lint-staged": "13.2.
|
|
122
|
+
"lint-staged": "13.2.2",
|
|
123
123
|
"npm-run-all": "4.1.5",
|
|
124
|
-
"prettier": "2.8.
|
|
124
|
+
"prettier": "2.8.8",
|
|
125
125
|
"react": "18.2.0",
|
|
126
126
|
"react-dom": "18.2.0",
|
|
127
127
|
"react-icons": "4.8.0",
|
|
128
|
-
"react-markdown": "8.0.
|
|
128
|
+
"react-markdown": "8.0.7",
|
|
129
129
|
"react-syntax-highlighter": "15.5.0",
|
|
130
130
|
"rehype-raw": "6.1.1",
|
|
131
131
|
"remark-gfm": "3.0.1",
|
|
132
132
|
"rimraf": "4.4.1",
|
|
133
|
-
"semantic-release": "21.0.
|
|
134
|
-
"storybook": "7.0.
|
|
133
|
+
"semantic-release": "21.0.2",
|
|
134
|
+
"storybook": "7.0.12",
|
|
135
135
|
"storybook-css-modules": "1.0.8",
|
|
136
136
|
"ts-jest": "29.1.0",
|
|
137
137
|
"ts-node": "10.9.1",
|
|
138
|
-
"type-fest": "3.
|
|
139
|
-
"typescript": "5.0.
|
|
140
|
-
"typescript-plugin-css-modules": "5.0.
|
|
138
|
+
"type-fest": "3.10.0",
|
|
139
|
+
"typescript": "5.0.4",
|
|
140
|
+
"typescript-plugin-css-modules": "5.0.1"
|
|
141
141
|
},
|
|
142
142
|
"peerDependencies": {
|
|
143
143
|
"@react-hookz/web": "^14.2.3 || >=15.x",
|