@doist/typist 1.1.0 → 1.1.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/CHANGELOG.md +6 -0
- package/dist/utilities/can-insert-node-at.d.ts +1 -1
- package/dist/utilities/can-insert-node-at.d.ts.map +1 -1
- package/dist/utilities/can-insert-suggestion.d.ts +2 -2
- package/dist/utilities/can-insert-suggestion.d.ts.map +1 -1
- package/dist/utilities/can-insert-suggestion.js +3 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [1.1.1](https://github.com/Doist/typist/compare/v1.1.0...v1.1.1) (2023-03-03)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- Invalid `hasCodeMarkBefore` check in `canInsertSuggestion` utility function ([#156](https://github.com/Doist/typist/issues/156)) ([21826c5](https://github.com/Doist/typist/commit/21826c58f763d020d3810fe373ab2524e0f0448e))
|
|
6
|
+
|
|
1
7
|
## [1.1.0](https://github.com/Doist/typist/compare/v1.0.19...v1.1.0) (2023-03-02)
|
|
2
8
|
|
|
3
9
|
### Features
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"can-insert-node-at.d.ts","sourceRoot":"","sources":["../../src/utilities/can-insert-node-at.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"can-insert-node-at.d.ts","sourceRoot":"","sources":["../../src/utilities/can-insert-node-at.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;GAIG;AACH,iBAAS,eAAe,CAAC,EACrB,MAAM,EACN,QAAQ,EACR,KAAK,GACR,EAAE;IACC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;CACf,WAIA;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Editor } from '@tiptap/core';
|
|
2
|
-
import { EditorState } from '@tiptap/pm/state';
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import type { EditorState } from '@tiptap/pm/state';
|
|
3
3
|
/**
|
|
4
4
|
* Check if a suggestion can be inserted within the current editor selection.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"can-insert-suggestion.d.ts","sourceRoot":"","sources":["../../src/utilities/can-insert-suggestion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"can-insert-suggestion.d.ts","sourceRoot":"","sources":["../../src/utilities/can-insert-suggestion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,WAoBrF;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -7,12 +7,9 @@ function canInsertSuggestion({ editor, state }) {
|
|
|
7
7
|
const { selection } = state;
|
|
8
8
|
const isInsideCodeMark = editor.isActive('code');
|
|
9
9
|
const isInsideCodeBlockNode = selection.$from.parent.type.name === 'codeBlock';
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const isComposingInlineCode = selection.$from.nodeBefore?.text
|
|
14
|
-
?.split(' ')
|
|
15
|
-
.some((word) => word.startsWith('`'));
|
|
10
|
+
const wordsBeforeSelection = (selection.$from.nodeBefore?.text ?? '').split(' ');
|
|
11
|
+
const hasCodeMarkBefore = (selection.$from.parent.cut(selection.$from.parentOffset - wordsBeforeSelection.slice(-1)[0].length - 1, selection.$from.parentOffset - 1).content.firstChild?.marks.length ?? 0) > 0;
|
|
12
|
+
const isComposingInlineCode = wordsBeforeSelection.some((word) => word.startsWith('`'));
|
|
16
13
|
return (!isInsideCodeMark && !isInsideCodeBlockNode && !hasCodeMarkBefore && !isComposingInlineCode);
|
|
17
14
|
}
|
|
18
15
|
export { canInsertSuggestion };
|
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.1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://typist.doist.dev/",
|
|
7
7
|
"repository": "https://github.com/Doist/typist",
|