@doist/typist 1.0.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 +9 -0
- package/CODE_OF_CONDUCT.md +83 -0
- package/CONTRIBUTING.md +123 -0
- package/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/components/typist-editor.d.ts +173 -0
- package/dist/components/typist-editor.d.ts.map +1 -0
- package/dist/components/typist-editor.helper.d.ts +22 -0
- package/dist/components/typist-editor.helper.d.ts.map +1 -0
- package/dist/components/typist-editor.helper.js +26 -0
- package/dist/components/typist-editor.js +160 -0
- package/dist/constants/common.d.ts +10 -0
- package/dist/constants/common.d.ts.map +1 -0
- package/dist/constants/common.js +9 -0
- package/dist/constants/extension-priorities.d.ts +26 -0
- package/dist/constants/extension-priorities.d.ts.map +1 -0
- package/dist/constants/extension-priorities.js +25 -0
- package/dist/constants/regular-expressions.d.ts +6 -0
- package/dist/constants/regular-expressions.d.ts.map +1 -0
- package/dist/constants/regular-expressions.js +5 -0
- package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts +24 -0
- package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts.map +1 -0
- package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js +32 -0
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts +28 -0
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts.map +1 -0
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js +25 -0
- package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts +9 -0
- package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts.map +1 -0
- package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js +18 -0
- package/dist/extensions/core/view-event-handlers.d.ts +33 -0
- package/dist/extensions/core/view-event-handlers.d.ts.map +1 -0
- package/dist/extensions/core/view-event-handlers.js +35 -0
- package/dist/extensions/plain-text/paste-multiline-text.d.ts +10 -0
- package/dist/extensions/plain-text/paste-multiline-text.d.ts.map +1 -0
- package/dist/extensions/plain-text/paste-multiline-text.js +66 -0
- package/dist/extensions/plain-text/plain-text-document.d.ts +17 -0
- package/dist/extensions/plain-text/plain-text-document.d.ts.map +1 -0
- package/dist/extensions/plain-text/plain-text-document.js +17 -0
- package/dist/extensions/plain-text/plain-text-kit.d.ts +42 -0
- package/dist/extensions/plain-text/plain-text-kit.d.ts.map +1 -0
- package/dist/extensions/plain-text/plain-text-kit.js +47 -0
- package/dist/extensions/plain-text/plain-text-paragraph.d.ts +9 -0
- package/dist/extensions/plain-text/plain-text-paragraph.d.ts.map +1 -0
- package/dist/extensions/plain-text/plain-text-paragraph.js +13 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts +9 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts.map +1 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js +89 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts +9 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts.map +1 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js +49 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts +9 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts.map +1 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js +43 -0
- package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts +8 -0
- package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts.map +1 -0
- package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js +17 -0
- package/dist/extensions/rich-text/bold-and-italics.d.ts +8 -0
- package/dist/extensions/rich-text/bold-and-italics.d.ts.map +1 -0
- package/dist/extensions/rich-text/bold-and-italics.js +40 -0
- package/dist/extensions/rich-text/curvenote-codemark.d.ts +11 -0
- package/dist/extensions/rich-text/curvenote-codemark.d.ts.map +1 -0
- package/dist/extensions/rich-text/curvenote-codemark.js +18 -0
- package/dist/extensions/rich-text/paste-emojis.d.ts +9 -0
- package/dist/extensions/rich-text/paste-emojis.d.ts.map +1 -0
- package/dist/extensions/rich-text/paste-emojis.js +28 -0
- package/dist/extensions/rich-text/paste-markdown.d.ts +11 -0
- package/dist/extensions/rich-text/paste-markdown.d.ts.map +1 -0
- package/dist/extensions/rich-text/paste-markdown.js +68 -0
- package/dist/extensions/rich-text/rich-text-document.d.ts +17 -0
- package/dist/extensions/rich-text/rich-text-document.d.ts.map +1 -0
- package/dist/extensions/rich-text/rich-text-document.js +17 -0
- package/dist/extensions/rich-text/rich-text-image.d.ts +80 -0
- package/dist/extensions/rich-text/rich-text-image.d.ts.map +1 -0
- package/dist/extensions/rich-text/rich-text-image.js +109 -0
- package/dist/extensions/rich-text/rich-text-kit.d.ts +129 -0
- package/dist/extensions/rich-text/rich-text-kit.d.ts.map +1 -0
- package/dist/extensions/rich-text/rich-text-kit.js +130 -0
- package/dist/extensions/rich-text/rich-text-link.d.ts +10 -0
- package/dist/extensions/rich-text/rich-text-link.d.ts.map +1 -0
- package/dist/extensions/rich-text/rich-text-link.js +102 -0
- package/dist/extensions/shared/copy-markdown-source.d.ts +20 -0
- package/dist/extensions/shared/copy-markdown-source.d.ts.map +1 -0
- package/dist/extensions/shared/copy-markdown-source.js +35 -0
- package/dist/extensions/shared/paste-singleline-text.d.ts +10 -0
- package/dist/extensions/shared/paste-singleline-text.d.ts.map +1 -0
- package/dist/extensions/shared/paste-singleline-text.js +43 -0
- package/dist/factories/create-suggestion-extension.d.ts +121 -0
- package/dist/factories/create-suggestion-extension.d.ts.map +1 -0
- package/dist/factories/create-suggestion-extension.js +149 -0
- package/dist/helpers/dom.d.ts +8 -0
- package/dist/helpers/dom.d.ts.map +1 -0
- package/dist/helpers/dom.js +9 -0
- package/dist/helpers/schema.d.ts +19 -0
- package/dist/helpers/schema.d.ts.map +1 -0
- package/dist/helpers/schema.js +21 -0
- package/dist/helpers/serializer.d.ts +11 -0
- package/dist/helpers/serializer.d.ts.map +1 -0
- package/dist/helpers/serializer.js +16 -0
- package/dist/hooks/use-editor.d.ts +19 -0
- package/dist/hooks/use-editor.d.ts.map +1 -0
- package/dist/hooks/use-editor.js +46 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/serializers/html/extensions/checkbox.d.ts +8 -0
- package/dist/serializers/html/extensions/checkbox.d.ts.map +1 -0
- package/dist/serializers/html/extensions/checkbox.js +12 -0
- package/dist/serializers/html/extensions/code.d.ts +9 -0
- package/dist/serializers/html/extensions/code.d.ts.map +1 -0
- package/dist/serializers/html/extensions/code.js +20 -0
- package/dist/serializers/html/extensions/html.d.ts +10 -0
- package/dist/serializers/html/extensions/html.d.ts.map +1 -0
- package/dist/serializers/html/extensions/html.js +15 -0
- package/dist/serializers/html/extensions/link.d.ts +11 -0
- package/dist/serializers/html/extensions/link.d.ts.map +1 -0
- package/dist/serializers/html/extensions/link.js +28 -0
- package/dist/serializers/html/extensions/paragraph.d.ts +12 -0
- package/dist/serializers/html/extensions/paragraph.d.ts.map +1 -0
- package/dist/serializers/html/extensions/paragraph.js +51 -0
- package/dist/serializers/html/extensions/task-list.d.ts +9 -0
- package/dist/serializers/html/extensions/task-list.d.ts.map +1 -0
- package/dist/serializers/html/extensions/task-list.js +31 -0
- package/dist/serializers/html/html.d.ts +27 -0
- package/dist/serializers/html/html.d.ts.map +1 -0
- package/dist/serializers/html/html.js +129 -0
- package/dist/serializers/markdown/markdown.d.ts +40 -0
- package/dist/serializers/markdown/markdown.d.ts.map +1 -0
- package/dist/serializers/markdown/markdown.js +126 -0
- package/dist/serializers/markdown/plugins/image.d.ts +12 -0
- package/dist/serializers/markdown/plugins/image.d.ts.map +1 -0
- package/dist/serializers/markdown/plugins/image.js +31 -0
- package/dist/serializers/markdown/plugins/list-item.d.ts +14 -0
- package/dist/serializers/markdown/plugins/list-item.d.ts.map +1 -0
- package/dist/serializers/markdown/plugins/list-item.js +41 -0
- package/dist/serializers/markdown/plugins/paragraph.d.ts +12 -0
- package/dist/serializers/markdown/plugins/paragraph.d.ts.map +1 -0
- package/dist/serializers/markdown/plugins/paragraph.js +18 -0
- package/dist/serializers/markdown/plugins/strikethrough.d.ts +13 -0
- package/dist/serializers/markdown/plugins/strikethrough.d.ts.map +1 -0
- package/dist/serializers/markdown/plugins/strikethrough.js +23 -0
- package/dist/serializers/markdown/plugins/suggestion.d.ts +11 -0
- package/dist/serializers/markdown/plugins/suggestion.d.ts.map +1 -0
- package/dist/serializers/markdown/plugins/suggestion.js +21 -0
- package/dist/serializers/markdown/plugins/task-item.d.ts +14 -0
- package/dist/serializers/markdown/plugins/task-item.d.ts.map +1 -0
- package/dist/serializers/markdown/plugins/task-item.js +39 -0
- package/package.json +146 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paste-singleline-text.d.ts","sourceRoot":"","sources":["../../../src/extensions/shared/paste-singleline-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAQxC;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,qBAiCvB,CAAA;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { escape } from 'lodash-es';
|
|
3
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
4
|
+
import { REGEX_LINE_BREAKS } from '../../constants/regular-expressions';
|
|
5
|
+
import { parseHtmlToElement } from '../../helpers/dom';
|
|
6
|
+
import { isPlainTextDocument } from '../../helpers/schema';
|
|
7
|
+
/**
|
|
8
|
+
* The `PasteSinglelineText` extension joins all paragraphs into a single fragment when
|
|
9
|
+
* copying-and-pasting text into the editor, adding spaces as block separators. This custom
|
|
10
|
+
* extension is required for an editor configured with `multiline: false`, so that multiline
|
|
11
|
+
* clipboard text is pasted into the singleline editor correctly.
|
|
12
|
+
*/
|
|
13
|
+
const PasteSinglelineText = Extension.create({
|
|
14
|
+
name: 'pasteSinglelineText',
|
|
15
|
+
addProseMirrorPlugins() {
|
|
16
|
+
return [
|
|
17
|
+
new Plugin({
|
|
18
|
+
key: new PluginKey('pasteSinglelineText'),
|
|
19
|
+
props: {
|
|
20
|
+
transformPastedHTML(html, view) {
|
|
21
|
+
const bodyElement = parseHtmlToElement(html);
|
|
22
|
+
bodyElement.innerHTML = bodyElement.innerHTML
|
|
23
|
+
// Join break lines with a space character in-between
|
|
24
|
+
.replace(/<br>/g, ' ')
|
|
25
|
+
// Join paragraphs with a space character in-between
|
|
26
|
+
.replace(/<p[^>]+>(.*?)<\/p>/g, '$1 ');
|
|
27
|
+
return isPlainTextDocument(view.state.schema)
|
|
28
|
+
? escape(bodyElement.innerText)
|
|
29
|
+
: bodyElement.innerHTML;
|
|
30
|
+
},
|
|
31
|
+
transformPastedText(text) {
|
|
32
|
+
return (text
|
|
33
|
+
// Join new lines with a space character in-between
|
|
34
|
+
.replace(REGEX_LINE_BREAKS, ' ')
|
|
35
|
+
// Collapse multiple space characters into one
|
|
36
|
+
.replace(/\s+/g, ' '));
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
];
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
export { PasteSinglelineText };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
import type { SuggestionKeyDownProps as CoreSuggestionKeyDownProps, SuggestionOptions as CoreSuggestionOptions } from '@tiptap/suggestion';
|
|
3
|
+
import type { ConditionalKeys, RequireAtLeastOne } from 'type-fest';
|
|
4
|
+
/**
|
|
5
|
+
* The properties that describe the suggestion node attributes.
|
|
6
|
+
*/
|
|
7
|
+
declare type SuggestionAttributes = {
|
|
8
|
+
/**
|
|
9
|
+
* The suggestion node unique identifier to be rendered by the editor as a `data-id` attribute.
|
|
10
|
+
*/
|
|
11
|
+
id: number;
|
|
12
|
+
/**
|
|
13
|
+
* The suggestion node label to be rendered by the editor as a `data-label` attribute and the
|
|
14
|
+
* display text itself.
|
|
15
|
+
*/
|
|
16
|
+
label: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The properties that describe the minimal props that an autocomplete dropdown must receive.
|
|
20
|
+
*/
|
|
21
|
+
declare type SuggestionRendererProps<SuggestionItemType> = {
|
|
22
|
+
/**
|
|
23
|
+
* The function that must be invoked when a suggestion item is selected.
|
|
24
|
+
*/
|
|
25
|
+
command: (item: SuggestionItemType) => void;
|
|
26
|
+
/**
|
|
27
|
+
* The list of suggestion items to be rendered by the autocomplete dropdown.
|
|
28
|
+
*/
|
|
29
|
+
items: SuggestionItemType[];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A type that describes the forwarded ref that an autocomplete dropdown must implement with
|
|
33
|
+
* `useImperativeHandle` to receive `keyDown` events from the render function.
|
|
34
|
+
*/
|
|
35
|
+
declare type SuggestionRendererRef = {
|
|
36
|
+
onKeyDown: (props: CoreSuggestionKeyDownProps) => boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The options available to customize the extension created by the factory function.
|
|
40
|
+
*/
|
|
41
|
+
declare type SuggestionOptions<SuggestionItemType> = {
|
|
42
|
+
/**
|
|
43
|
+
* The character that triggers the autocomplete dropdown.
|
|
44
|
+
*/
|
|
45
|
+
triggerChar: '@' | '#' | '+';
|
|
46
|
+
/**
|
|
47
|
+
* Allows or disallows spaces in suggested items.
|
|
48
|
+
*/
|
|
49
|
+
allowSpaces: CoreSuggestionOptions['allowSpaces'];
|
|
50
|
+
/**
|
|
51
|
+
* The prefix characters that are allowed to trigger a suggestion.
|
|
52
|
+
*/
|
|
53
|
+
allowedPrefixes: CoreSuggestionOptions['allowedPrefixes'];
|
|
54
|
+
/**
|
|
55
|
+
* Trigger the autocomplete dropdown at the start of a line only.
|
|
56
|
+
*/
|
|
57
|
+
startOfLine: CoreSuggestionOptions['startOfLine'];
|
|
58
|
+
/**
|
|
59
|
+
* Define how the suggestion item `aria-label` attribute should be rendered.
|
|
60
|
+
*/
|
|
61
|
+
renderAriaLabel?: (attrs: SuggestionAttributes) => string;
|
|
62
|
+
/**
|
|
63
|
+
* A render function for the autocomplete dropdown.
|
|
64
|
+
*/
|
|
65
|
+
dropdownRenderFn?: CoreSuggestionOptions<SuggestionItemType>['render'];
|
|
66
|
+
/**
|
|
67
|
+
* The event handler that is fired when the search string has changed.
|
|
68
|
+
*/
|
|
69
|
+
onSearchChange?: (query: string, storage: SuggestionStorage<SuggestionItemType>) => SuggestionItemType[] | Promise<SuggestionItemType[]>;
|
|
70
|
+
/**
|
|
71
|
+
* The event handler that is fired when a suggestion item is selected.
|
|
72
|
+
*/
|
|
73
|
+
onItemSelect?: (item: SuggestionItemType) => void;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The storage holding the suggestion items original array, and a collection indexed by the item id.
|
|
77
|
+
*/
|
|
78
|
+
declare type SuggestionStorage<SuggestionItemType> = Readonly<{
|
|
79
|
+
/**
|
|
80
|
+
* The original array of suggestion items.
|
|
81
|
+
*/
|
|
82
|
+
items: SuggestionItemType[];
|
|
83
|
+
/**
|
|
84
|
+
* A collection of suggestion items indexed by the item id.
|
|
85
|
+
*/
|
|
86
|
+
itemsById: {
|
|
87
|
+
readonly [id: number]: SuggestionItemType | undefined;
|
|
88
|
+
};
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* The return type for a suggestion extension created by the factory function.
|
|
92
|
+
*/
|
|
93
|
+
declare type SuggestionExtensionResult<SuggestionItemType> = Node<SuggestionOptions<SuggestionItemType>>;
|
|
94
|
+
/**
|
|
95
|
+
* A factory function responsible for creating different types of suggestion extensions with
|
|
96
|
+
* flexibility and customizability in mind.
|
|
97
|
+
*
|
|
98
|
+
* Extensions created by this factory function render editor nodes with internal `data-id` and
|
|
99
|
+
* `data-label` attributes (as a way to save and restore the editor nodes data) based on properties
|
|
100
|
+
* of the same name (minus the `data-` prefix) from the source item type. However, in the event of
|
|
101
|
+
* unmatched properties between the internal attributes and the source item type, you should
|
|
102
|
+
* specify the source item type, and use the optional `attributesMapping` option to map the
|
|
103
|
+
* source properties to the internal `data-id` and `data-label` attributes.
|
|
104
|
+
*
|
|
105
|
+
* @param type A unique identifier for the suggestion extension type.
|
|
106
|
+
* @param attributesMapping An object to map the `data-id` and `data-label` attributes with the
|
|
107
|
+
* source item type properties.
|
|
108
|
+
*
|
|
109
|
+
* @returns A new suggestion extension tailored to a specific use case.
|
|
110
|
+
*/
|
|
111
|
+
declare function createSuggestionExtension<SuggestionItemType extends {
|
|
112
|
+
[id: string]: unknown;
|
|
113
|
+
} = SuggestionAttributes>(type: string, items?: SuggestionItemType[], ...attributesMapping: SuggestionItemType extends SuggestionAttributes ? [] : [
|
|
114
|
+
RequireAtLeastOne<{
|
|
115
|
+
id: ConditionalKeys<SuggestionItemType, number>;
|
|
116
|
+
label: ConditionalKeys<SuggestionItemType, string>;
|
|
117
|
+
}>
|
|
118
|
+
]): SuggestionExtensionResult<SuggestionItemType>;
|
|
119
|
+
export { createSuggestionExtension };
|
|
120
|
+
export type { SuggestionExtensionResult, SuggestionOptions, SuggestionRendererProps, SuggestionRendererRef, SuggestionStorage, };
|
|
121
|
+
//# sourceMappingURL=create-suggestion-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-suggestion-extension.d.ts","sourceRoot":"","sources":["../../src/factories/create-suggestion-extension.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { mergeAttributes, Node } from '@tiptap/core';
|
|
2
|
+
import { Suggestion as TiptapSuggestion } from '@tiptap/suggestion';
|
|
3
|
+
import { camelCase, kebabCase } from 'lodash-es';
|
|
4
|
+
import { PluginKey } from 'prosemirror-state';
|
|
5
|
+
import { SUGGESTION_EXTENSION_PRIORITY } from '../constants/extension-priorities';
|
|
6
|
+
/**
|
|
7
|
+
* A factory function responsible for creating different types of suggestion extensions with
|
|
8
|
+
* flexibility and customizability in mind.
|
|
9
|
+
*
|
|
10
|
+
* Extensions created by this factory function render editor nodes with internal `data-id` and
|
|
11
|
+
* `data-label` attributes (as a way to save and restore the editor nodes data) based on properties
|
|
12
|
+
* of the same name (minus the `data-` prefix) from the source item type. However, in the event of
|
|
13
|
+
* unmatched properties between the internal attributes and the source item type, you should
|
|
14
|
+
* specify the source item type, and use the optional `attributesMapping` option to map the
|
|
15
|
+
* source properties to the internal `data-id` and `data-label` attributes.
|
|
16
|
+
*
|
|
17
|
+
* @param type A unique identifier for the suggestion extension type.
|
|
18
|
+
* @param attributesMapping An object to map the `data-id` and `data-label` attributes with the
|
|
19
|
+
* source item type properties.
|
|
20
|
+
*
|
|
21
|
+
* @returns A new suggestion extension tailored to a specific use case.
|
|
22
|
+
*/
|
|
23
|
+
function createSuggestionExtension(type, items = [],
|
|
24
|
+
// This type makes sure that if a generic type variable is specified, the `attributesMapping`
|
|
25
|
+
// is also defined (and vice versa) along with making sure that at least one attribute is
|
|
26
|
+
// specified, and that all constraints are satisfied.
|
|
27
|
+
...attributesMapping) {
|
|
28
|
+
// Normalize the node type and add the `Suggestion` suffix so that it can be easily identified
|
|
29
|
+
// when parsing the editor schema programatically (useful for Markdown/HTML serialization)
|
|
30
|
+
const nodeType = `${camelCase(type)}Suggestion`;
|
|
31
|
+
// Normalize the node type to kebab-case to be used as a `data-*` HTML attribute
|
|
32
|
+
const attributeType = kebabCase(type);
|
|
33
|
+
// Get the specified attributes, if available, or use the defaults
|
|
34
|
+
const idAttribute = String(attributesMapping[0]?.id ?? 'id');
|
|
35
|
+
const labelAttribute = String(attributesMapping[0]?.label ?? 'label');
|
|
36
|
+
// Create a personalized suggestion extension
|
|
37
|
+
return Node.create({
|
|
38
|
+
name: nodeType,
|
|
39
|
+
priority: SUGGESTION_EXTENSION_PRIORITY,
|
|
40
|
+
inline: true,
|
|
41
|
+
group: 'inline',
|
|
42
|
+
selectable: false,
|
|
43
|
+
atom: true,
|
|
44
|
+
addOptions() {
|
|
45
|
+
return {
|
|
46
|
+
triggerChar: '@',
|
|
47
|
+
// Disable option by default until the following Tiptap issue is fixed:
|
|
48
|
+
// https://github.com/ueberdosis/tiptap/issues/2159
|
|
49
|
+
allowSpaces: false,
|
|
50
|
+
allowedPrefixes: [' '],
|
|
51
|
+
startOfLine: false,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
addStorage() {
|
|
55
|
+
return {
|
|
56
|
+
items,
|
|
57
|
+
itemsById: items.reduce((acc, item) => ({ ...acc, [String(item[idAttribute])]: item }), {}),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
addAttributes() {
|
|
61
|
+
return {
|
|
62
|
+
[idAttribute]: {
|
|
63
|
+
default: null,
|
|
64
|
+
parseHTML: (element) => element.getAttribute('data-id'),
|
|
65
|
+
renderHTML: (attributes) => ({
|
|
66
|
+
'data-id': Number(attributes[idAttribute]),
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
[labelAttribute]: {
|
|
70
|
+
default: null,
|
|
71
|
+
parseHTML: (element) => {
|
|
72
|
+
const id = Number(element.getAttribute('data-id'));
|
|
73
|
+
const item = this.storage.itemsById[id];
|
|
74
|
+
// Read the latest item label from the storage, if available, otherwise
|
|
75
|
+
// fallback to the item label in the `data-label` attribute
|
|
76
|
+
return String(item?.[labelAttribute] ?? element.getAttribute('data-label'));
|
|
77
|
+
},
|
|
78
|
+
renderHTML: (attributes) => ({
|
|
79
|
+
'data-label': String(attributes[labelAttribute]),
|
|
80
|
+
}),
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
parseHTML() {
|
|
85
|
+
return [{ tag: `span[data-${attributeType}]` }];
|
|
86
|
+
},
|
|
87
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
88
|
+
return [
|
|
89
|
+
'span',
|
|
90
|
+
mergeAttributes({
|
|
91
|
+
[`data-${attributeType}`]: '',
|
|
92
|
+
'aria-label': this.options.renderAriaLabel?.({
|
|
93
|
+
id: Number(node.attrs[idAttribute]),
|
|
94
|
+
label: String(node.attrs[labelAttribute]),
|
|
95
|
+
}),
|
|
96
|
+
}, HTMLAttributes),
|
|
97
|
+
`${String(this.options.triggerChar)}${String(node.attrs[labelAttribute])}`,
|
|
98
|
+
];
|
|
99
|
+
},
|
|
100
|
+
renderText({ node }) {
|
|
101
|
+
return `${String(this.options.triggerChar)}${String(node.attrs[labelAttribute])}`;
|
|
102
|
+
},
|
|
103
|
+
addProseMirrorPlugins() {
|
|
104
|
+
const { triggerChar, allowSpaces, allowedPrefixes, startOfLine, onSearchChange, onItemSelect, dropdownRenderFn, } = this.options;
|
|
105
|
+
return [
|
|
106
|
+
TiptapSuggestion({
|
|
107
|
+
pluginKey: new PluginKey(nodeType),
|
|
108
|
+
editor: this.editor,
|
|
109
|
+
char: triggerChar,
|
|
110
|
+
allowedPrefixes,
|
|
111
|
+
allowSpaces,
|
|
112
|
+
startOfLine,
|
|
113
|
+
items({ query, editor }) {
|
|
114
|
+
return (onSearchChange?.(query, editor.storage[nodeType]) || []);
|
|
115
|
+
},
|
|
116
|
+
allow({ editor, range }) {
|
|
117
|
+
return editor.can().insertContentAt(range, {
|
|
118
|
+
type: nodeType,
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
command({ editor, range, props }) {
|
|
122
|
+
const nodeAfter = editor.view.state.selection.$to.nodeAfter;
|
|
123
|
+
const overrideSpace = nodeAfter?.text?.startsWith(' ');
|
|
124
|
+
if (overrideSpace) {
|
|
125
|
+
range.to += 1;
|
|
126
|
+
}
|
|
127
|
+
editor
|
|
128
|
+
.chain()
|
|
129
|
+
.focus()
|
|
130
|
+
.insertContentAt(range, [
|
|
131
|
+
{
|
|
132
|
+
type: nodeType,
|
|
133
|
+
attrs: props,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: 'text',
|
|
137
|
+
text: ' ',
|
|
138
|
+
},
|
|
139
|
+
])
|
|
140
|
+
.run();
|
|
141
|
+
onItemSelect?.(props);
|
|
142
|
+
},
|
|
143
|
+
render: dropdownRenderFn,
|
|
144
|
+
}),
|
|
145
|
+
];
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
export { createSuggestionExtension };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a given HTML string and returns the `HTMLElement` for the document body.
|
|
3
|
+
*
|
|
4
|
+
* @param html The HTML string to parse.
|
|
5
|
+
*/
|
|
6
|
+
declare function parseHtmlToElement(html: string): HTMLElement;
|
|
7
|
+
export { parseHtmlToElement };
|
|
8
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/helpers/dom.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,iBAAS,kBAAkB,CAAC,IAAI,EAAE,MAAM,eAEvC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a given HTML string and returns the `HTMLElement` for the document body.
|
|
3
|
+
*
|
|
4
|
+
* @param html The HTML string to parse.
|
|
5
|
+
*/
|
|
6
|
+
function parseHtmlToElement(html) {
|
|
7
|
+
return new DOMParser().parseFromString(html, 'text/html').body;
|
|
8
|
+
}
|
|
9
|
+
export { parseHtmlToElement };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Schema } from 'prosemirror-model';
|
|
2
|
+
/**
|
|
3
|
+
* Check if the document schema accepts multiple lines of input.
|
|
4
|
+
*
|
|
5
|
+
* @param schema The current editor document schema.
|
|
6
|
+
*
|
|
7
|
+
* @returns True if the schema accepts multiple lines of input, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
declare function isMultilineDocument(schema: Schema): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Check if a document schema contains a plain-text document top node.
|
|
12
|
+
*
|
|
13
|
+
* @param schema The current editor document schema.
|
|
14
|
+
*
|
|
15
|
+
* @returns True if the schema contains a plain-text document, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
declare function isPlainTextDocument(schema: Schema): boolean;
|
|
18
|
+
export { isMultilineDocument, isPlainTextDocument };
|
|
19
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/helpers/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;;;;;GAMG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the document schema accepts multiple lines of input.
|
|
3
|
+
*
|
|
4
|
+
* @param schema The current editor document schema.
|
|
5
|
+
*
|
|
6
|
+
* @returns True if the schema accepts multiple lines of input, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
function isMultilineDocument(schema) {
|
|
9
|
+
return /(?:\+|\*)$/.test(schema.topNodeType.spec.content || '');
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Check if a document schema contains a plain-text document top node.
|
|
13
|
+
*
|
|
14
|
+
* @param schema The current editor document schema.
|
|
15
|
+
*
|
|
16
|
+
* @returns True if the schema contains a plain-text document, false otherwise.
|
|
17
|
+
*/
|
|
18
|
+
function isPlainTextDocument(schema) {
|
|
19
|
+
return Boolean(schema.topNodeType.spec.content?.startsWith('paragraph'));
|
|
20
|
+
}
|
|
21
|
+
export { isMultilineDocument, isPlainTextDocument };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ParseRule } from 'prosemirror-model';
|
|
2
|
+
/**
|
|
3
|
+
* Extract all tags from the given parse rules argument, and returns an array of said tags.
|
|
4
|
+
*
|
|
5
|
+
* @param parseRules The parse rules for a DOM node or inline style.
|
|
6
|
+
*
|
|
7
|
+
* @returns An array of tags extracted from the parse rules.
|
|
8
|
+
*/
|
|
9
|
+
declare function extractTagsFromParseRules(parseRules?: readonly ParseRule[]): (keyof HTMLElementTagNameMap)[];
|
|
10
|
+
export { extractTagsFromParseRules };
|
|
11
|
+
//# sourceMappingURL=serializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/helpers/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD;;;;;;GAMG;AACH,iBAAS,yBAAyB,CAC9B,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,GAClC,CAAC,MAAM,qBAAqB,CAAC,EAAE,CAQjC;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract all tags from the given parse rules argument, and returns an array of said tags.
|
|
3
|
+
*
|
|
4
|
+
* @param parseRules The parse rules for a DOM node or inline style.
|
|
5
|
+
*
|
|
6
|
+
* @returns An array of tags extracted from the parse rules.
|
|
7
|
+
*/
|
|
8
|
+
function extractTagsFromParseRules(parseRules) {
|
|
9
|
+
if (!parseRules || parseRules.length === 0) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return parseRules
|
|
13
|
+
.filter((rule) => rule.tag)
|
|
14
|
+
.map((rule) => rule.tag);
|
|
15
|
+
}
|
|
16
|
+
export { extractTagsFromParseRules };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DependencyList } from 'react';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
import type { EditorOptions } from '@tiptap/core';
|
|
4
|
+
/**
|
|
5
|
+
* This is a fork of the official `useEditor` hook with one key difference, which is to prevent a
|
|
6
|
+
* `null` Editor object instance from being returned on the first render.
|
|
7
|
+
*
|
|
8
|
+
* This change was once fixed in the `@tiptap/react` package, but was reverted because it didn't
|
|
9
|
+
* have support for server-side rendering ([ref](https://github.com/ueberdosis/tiptap/pull/2282)),
|
|
10
|
+
* which is a problem we don't currently have.
|
|
11
|
+
*
|
|
12
|
+
* @param options The options to configure the editor component with.
|
|
13
|
+
* @param dependencies If present, re-create the editor instance if the values in the list change.
|
|
14
|
+
*
|
|
15
|
+
* @returns A new editor instance with the given options.
|
|
16
|
+
*/
|
|
17
|
+
declare function useEditor(options?: Partial<EditorOptions>, dependencies?: DependencyList): Editor;
|
|
18
|
+
export { useEditor };
|
|
19
|
+
//# sourceMappingURL=use-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,OAAO,CAAA;AAG3D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;;;;;;;;;GAYG;AACH,iBAAS,SAAS,CACd,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,EACpC,YAAY,GAAE,cAAmB,GAClC,MAAM,CAmCR;AAED,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useRerender } from '@react-hookz/web';
|
|
3
|
+
import { Editor } from '@tiptap/react';
|
|
4
|
+
/**
|
|
5
|
+
* This is a fork of the official `useEditor` hook with one key difference, which is to prevent a
|
|
6
|
+
* `null` Editor object instance from being returned on the first render.
|
|
7
|
+
*
|
|
8
|
+
* This change was once fixed in the `@tiptap/react` package, but was reverted because it didn't
|
|
9
|
+
* have support for server-side rendering ([ref](https://github.com/ueberdosis/tiptap/pull/2282)),
|
|
10
|
+
* which is a problem we don't currently have.
|
|
11
|
+
*
|
|
12
|
+
* @param options The options to configure the editor component with.
|
|
13
|
+
* @param dependencies If present, re-create the editor instance if the values in the list change.
|
|
14
|
+
*
|
|
15
|
+
* @returns A new editor instance with the given options.
|
|
16
|
+
*/
|
|
17
|
+
function useEditor(options = {}, dependencies = []) {
|
|
18
|
+
const [editor, setEditor] = useState(() => new Editor(options));
|
|
19
|
+
const forceRerender = useRerender();
|
|
20
|
+
useEffect(function initializeEditorInstance() {
|
|
21
|
+
let instance;
|
|
22
|
+
if (editor.isDestroyed) {
|
|
23
|
+
instance = new Editor(options);
|
|
24
|
+
setEditor(instance);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
instance = editor;
|
|
28
|
+
}
|
|
29
|
+
instance.on('transaction', () => {
|
|
30
|
+
requestAnimationFrame(() => {
|
|
31
|
+
requestAnimationFrame(() => {
|
|
32
|
+
if (!instance.isDestroyed) {
|
|
33
|
+
forceRerender();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return function destroyEditorInstance() {
|
|
39
|
+
instance.destroy();
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
+
dependencies);
|
|
44
|
+
return editor;
|
|
45
|
+
}
|
|
46
|
+
export { useEditor };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type { BeforeCreateProps, BlurProps, CreateProps, DestroyProps, FocusProps, SelectionUpdateProps, TransacationProps, TypistEditorProps, TypistEditorRef, UpdateProps, } from './components/typist-editor';
|
|
2
|
+
export { TypistEditor } from './components/typist-editor';
|
|
3
|
+
export { SUGGESTION_EXTENSION_PRIORITY } from './constants/extension-priorities';
|
|
4
|
+
export * from './extensions/core/extra-editor-commands/commands/extend-word-range';
|
|
5
|
+
export * from './extensions/core/extra-editor-commands/commands/insert-markdown-content';
|
|
6
|
+
export { PlainTextKit } from './extensions/plain-text/plain-text-kit';
|
|
7
|
+
export type { RichTextImageAttributes, RichTextImageOptions, } from './extensions/rich-text/rich-text-image';
|
|
8
|
+
export { RichTextKit } from './extensions/rich-text/rich-text-kit';
|
|
9
|
+
export type { SuggestionExtensionResult, SuggestionOptions, SuggestionRendererProps, SuggestionRendererRef, SuggestionStorage, } from './factories/create-suggestion-extension';
|
|
10
|
+
export { createSuggestionExtension } from './factories/create-suggestion-extension';
|
|
11
|
+
export { isMultilineDocument, isPlainTextDocument } from './helpers/schema';
|
|
12
|
+
export { createHTMLSerializer } from './serializers/html/html';
|
|
13
|
+
export { createMarkdownSerializer } from './serializers/markdown/markdown';
|
|
14
|
+
export type { AnyConfig, Editor as CoreEditor, EditorEvents, MarkRange, Range } from '@tiptap/core';
|
|
15
|
+
export { combineTransactionSteps, defaultBlockAt, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarksBetween, getMarkType, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, isActive, isList, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isTextSelection, mergeAttributes, posToDOMRect, } from '@tiptap/core';
|
|
16
|
+
export { Extension, Mark } from '@tiptap/core';
|
|
17
|
+
export * from '@tiptap/extension-character-count';
|
|
18
|
+
export type { Editor, NodeViewProps, ReactRendererOptions } from '@tiptap/react';
|
|
19
|
+
export { NodeViewWrapper, ReactRenderer } from '@tiptap/react';
|
|
20
|
+
export type { SuggestionKeyDownProps, SuggestionOptions as TiptapSuggestionOptions, } from '@tiptap/suggestion';
|
|
21
|
+
export { Suggestion } from '@tiptap/suggestion';
|
|
22
|
+
export { DOMParser, Fragment, Node as ProseMirrorNode } from 'prosemirror-model';
|
|
23
|
+
export type { Selection, Transaction } from 'prosemirror-state';
|
|
24
|
+
export { EditorState, Plugin, PluginKey } from 'prosemirror-state';
|
|
25
|
+
export type { EditorView } from 'prosemirror-view';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,GACd,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAA;AAChF,cAAc,oEAAoE,CAAA;AAClF,cAAc,0EAA0E,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AACrE,YAAY,EACR,uBAAuB,EACvB,oBAAoB,GACvB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAClE,YAAY,EACR,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,GACpB,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAA;AACnF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAC1E,YAAY,EAAE,SAAS,EAAE,MAAM,IAAI,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACnG,OAAO,EACH,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,0BAA0B,EAC1B,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,OAAO,EACP,cAAc,EACd,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,GACf,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC9C,cAAc,mCAAmC,CAAA;AACjD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC9D,YAAY,EACR,sBAAsB,EACtB,iBAAiB,IAAI,uBAAuB,GAC/C,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAChF,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { TypistEditor } from './components/typist-editor';
|
|
2
|
+
export { SUGGESTION_EXTENSION_PRIORITY } from './constants/extension-priorities';
|
|
3
|
+
export * from './extensions/core/extra-editor-commands/commands/extend-word-range';
|
|
4
|
+
export * from './extensions/core/extra-editor-commands/commands/insert-markdown-content';
|
|
5
|
+
export { PlainTextKit } from './extensions/plain-text/plain-text-kit';
|
|
6
|
+
export { RichTextKit } from './extensions/rich-text/rich-text-kit';
|
|
7
|
+
export { createSuggestionExtension } from './factories/create-suggestion-extension';
|
|
8
|
+
export { isMultilineDocument, isPlainTextDocument } from './helpers/schema';
|
|
9
|
+
export { createHTMLSerializer } from './serializers/html/html';
|
|
10
|
+
export { createMarkdownSerializer } from './serializers/markdown/markdown';
|
|
11
|
+
export { combineTransactionSteps, defaultBlockAt, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarksBetween, getMarkType, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, isActive, isList, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isTextSelection, mergeAttributes, posToDOMRect, } from '@tiptap/core';
|
|
12
|
+
export { Extension, Mark } from '@tiptap/core';
|
|
13
|
+
export * from '@tiptap/extension-character-count';
|
|
14
|
+
export { NodeViewWrapper, ReactRenderer } from '@tiptap/react';
|
|
15
|
+
export { Suggestion } from '@tiptap/suggestion';
|
|
16
|
+
export { DOMParser, Fragment, Node as ProseMirrorNode } from 'prosemirror-model';
|
|
17
|
+
export { EditorState, Plugin, PluginKey } from 'prosemirror-state';
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 };
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 };
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|