@doist/typist 1.0.7 → 1.0.8
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,9 @@
|
|
|
1
|
+
## [1.0.8](https://github.com/Doist/typist/compare/v1.0.7...v1.0.8) (2022-12-19)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **factories:** Allow alphanumeric IDs for suggestion nodes in `createSuggestionExtension` ([#66](https://github.com/Doist/typist/issues/66)) ([a1726a6](https://github.com/Doist/typist/commit/a1726a6be089e3e1452def641dfcfc622ac3e942))
|
|
6
|
+
|
|
1
7
|
## [1.0.7](https://github.com/Doist/typist/compare/v1.0.6...v1.0.7) (2022-12-14)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
|
@@ -8,7 +8,7 @@ type SuggestionAttributes = {
|
|
|
8
8
|
/**
|
|
9
9
|
* The suggestion node unique identifier to be rendered by the editor as a `data-id` attribute.
|
|
10
10
|
*/
|
|
11
|
-
id: number;
|
|
11
|
+
id: number | string;
|
|
12
12
|
/**
|
|
13
13
|
* The suggestion node label to be rendered by the editor as a `data-label` attribute and the
|
|
14
14
|
* display text itself.
|
|
@@ -84,7 +84,7 @@ type SuggestionStorage<SuggestionItemType> = Readonly<{
|
|
|
84
84
|
* A collection of suggestion items indexed by the item id.
|
|
85
85
|
*/
|
|
86
86
|
itemsById: {
|
|
87
|
-
readonly [id:
|
|
87
|
+
readonly [id: SuggestionAttributes['id']]: SuggestionItemType | undefined;
|
|
88
88
|
};
|
|
89
89
|
}>;
|
|
90
90
|
/**
|
|
@@ -109,11 +109,11 @@ type SuggestionExtensionResult<SuggestionItemType> = Node<SuggestionOptions<Sugg
|
|
|
109
109
|
* @returns A new suggestion extension tailored to a specific use case.
|
|
110
110
|
*/
|
|
111
111
|
declare function createSuggestionExtension<SuggestionItemType extends {
|
|
112
|
-
[id:
|
|
112
|
+
[id: SuggestionAttributes['id']]: unknown;
|
|
113
113
|
} = SuggestionAttributes>(type: string, items?: SuggestionItemType[], ...attributesMapping: SuggestionItemType extends SuggestionAttributes ? [] : [
|
|
114
114
|
RequireAtLeastOne<{
|
|
115
|
-
id: ConditionalKeys<SuggestionItemType,
|
|
116
|
-
label: ConditionalKeys<SuggestionItemType,
|
|
115
|
+
id: ConditionalKeys<SuggestionItemType, SuggestionAttributes['id']>;
|
|
116
|
+
label: ConditionalKeys<SuggestionItemType, SuggestionAttributes['label']>;
|
|
117
117
|
}>
|
|
118
118
|
]): SuggestionExtensionResult<SuggestionItemType>;
|
|
119
119
|
export { createSuggestionExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-suggestion-extension.d.ts","sourceRoot":"","sources":["../../src/factories/create-suggestion-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAA;AAOpD,OAAO,KAAK,EACR,sBAAsB,IAAI,0BAA0B,EACpD,iBAAiB,IAAI,qBAAqB,EAC7C,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEnE;;GAEG;AACH,KAAK,oBAAoB,GAAG;IACxB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"create-suggestion-extension.d.ts","sourceRoot":"","sources":["../../src/factories/create-suggestion-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAA;AAOpD,OAAO,KAAK,EACR,sBAAsB,IAAI,0BAA0B,EACpD,iBAAiB,IAAI,qBAAqB,EAC7C,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEnE;;GAEG;AACH,KAAK,oBAAoB,GAAG;IACxB;;OAEG;IACH,EAAE,EAAE,MAAM,G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AkB,EAAE,CAAA;IAE3B;;OAEG;IACH,SAAS,EAAE;QAAE,QAAQ,EAAE,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAAG,kBAAkB,GAAG,SAAS,CAAA;KAAE,CAAA;CAC3F,CAAC,CAAA;AAEF;;GAEG;AACH,KAAK,yBAAyB,CAAC,kBAAkB,IAAI,IAAI,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAEhG;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,yBAAyB,CAC9B,kBAAkB,SAAS;IAAE,CAAC,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;CAAE,GAAG,oBAAoB,EAE/F,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,kBAAkB,EAAO,EAKhC,GAAG,iBAAiB,EAAE,kBAAkB,SAAS,oBAAoB,GAC/D,EAAE,GACF;IACI,iBAAiB,CAAC;QACd,EAAE,EAAE,eAAe,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;QACnE,KAAK,EAAE,eAAe,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAA;KAC5E,CAAC;CACL,GACR,yBAAyB,CAAC,kBAAkB,CAAC,CAuJ/C;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA;AAEpC,YAAY,EACR,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,GACpB,CAAA"}
|
|
@@ -63,13 +63,13 @@ function createSuggestionExtension(type, items = [],
|
|
|
63
63
|
default: null,
|
|
64
64
|
parseHTML: (element) => element.getAttribute('data-id'),
|
|
65
65
|
renderHTML: (attributes) => ({
|
|
66
|
-
'data-id':
|
|
66
|
+
'data-id': String(attributes[idAttribute]),
|
|
67
67
|
}),
|
|
68
68
|
},
|
|
69
69
|
[labelAttribute]: {
|
|
70
70
|
default: null,
|
|
71
71
|
parseHTML: (element) => {
|
|
72
|
-
const id =
|
|
72
|
+
const id = String(element.getAttribute('data-id'));
|
|
73
73
|
const item = this.storage.itemsById[id];
|
|
74
74
|
// Read the latest item label from the storage, if available, otherwise
|
|
75
75
|
// fallback to the item label in the `data-label` attribute
|
|
@@ -90,7 +90,7 @@ function createSuggestionExtension(type, items = [],
|
|
|
90
90
|
mergeAttributes({
|
|
91
91
|
[`data-${attributeType}`]: '',
|
|
92
92
|
'aria-label': this.options.renderAriaLabel?.({
|
|
93
|
-
id:
|
|
93
|
+
id: String(node.attrs[idAttribute]),
|
|
94
94
|
label: String(node.attrs[labelAttribute]),
|
|
95
95
|
}),
|
|
96
96
|
}, HTMLAttributes),
|
|
@@ -15,7 +15,7 @@ function link(suggestionNodes) {
|
|
|
15
15
|
renderer: {
|
|
16
16
|
link(href, title, text) {
|
|
17
17
|
if (href && linkSchemaRegex.test(href)) {
|
|
18
|
-
const [, schema, id] = /^([a-z-]+):\/\/(\
|
|
18
|
+
const [, schema, id] = /^([a-z-]+):\/\/(\S+)$/i.exec(href) || [];
|
|
19
19
|
if (schema && id && text) {
|
|
20
20
|
return `<span data-${schema} data-id="${id}" data-label="${text}"></span>`;
|
|
21
21
|
}
|
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.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://typist.doist.dev/",
|
|
7
7
|
"repository": "https://github.com/Doist/typist",
|